Previous 15994 Revisions Next

r4136 Thursday 15th January, 2009 at 11:55:32 UTC by Nathan Woods
Updated to MAME 0.129u1 core
[docs]messnew.txt
[src/emu]deprecat.h drawgfx.c drawgfx.h drawgfxm.h* emu.mak emupal.h mame.c mame.h mconfig.c mconfig.h memory.c memory.h profiler.c sndintrf.c sndintrf.h sound.c tilemap.c tilemap.h uigfx.c video.c video.h
[src/emu/cpu]cpu.mak
[src/emu/cpu/alph8201]alph8201.h
[src/emu/cpu/arm]arm.c
[src/emu/cpu/arm7]arm7core.c arm7core.h
[src/emu/cpu/cop400]cop400.c* cop400.h cop400op.c*
[src/emu/cpu/dsp56k]dsp56dsm.c dsp56mem.c dsp56ops.c
[src/emu/cpu/esrip]esrip.c
[src/emu/cpu/g65816]g65816cm.h g65816ds.c
[src/emu/cpu/h6280]h6280.c
[src/emu/cpu/h83002]h8_8.c
[src/emu/cpu/hd6309]6309ops.c
[src/emu/cpu/i860]i860.c i860.h i860dec.c* i860dis.c*
[src/emu/cpu/m37710]m37710.c m37710cm.h m37710op.h m7700ds.c
[src/emu/cpu/mb86233]mb86233.c
[src/emu/cpu/mb88xx]mb88xx.h
[src/emu/cpu/mcs51]mcs51dasm.c
[src/emu/cpu/pic16c5x]pic16c5x.c
[src/emu/cpu/se3208]se3208.c se3208dis.c
[src/emu/cpu/sh2]sh2drc.c sh2fe.c
[src/emu/cpu/sm8500]sm8500.c
[src/emu/cpu/spc700]spc700.c spc700.h spc700ds.c
[src/emu/cpu/tms32010]tms32010.c
[src/emu/cpu/tms32025]tms32025.c
[src/emu/cpu/tms34010]34010ops.h
[src/emu/cpu/tms9900]9900dasm.c
[src/emu/cpu/v60]am1.c
[src/emu/debug]debugcpu.c
[src/emu/machine]6821new.c* 6821new.h* 6821pia.c f3853.c
[src/emu/sound]2151intf.h 2203intf.h 2413intf.h 2608intf.h 2610intf.h 2612intf.h 262intf.h 3812intf.c 3812intf.h 5110intf.c 5110intf.h 5220intf.c 5220intf.h aica.c aica.h astrocde.h ay8910.c ay8910.h beep.h bsmt2000.h c140.h c352.h c6280.h cdda.h cdp1869.h cem3394.c cem3394.h custom.h dac.h digitalk.c* digitalk.h* discrete.c discrete.h dmadac.h es5503.c es5503.h es5506.c es5506.h es8712.h flt_rc.h flt_vol.h fm.h gaelco.h hc55516.c hc55516.h ics2115.c ics2115.h iremga20.c iremga20.h k005289.h k007232.h k051649.h k053260.c k053260.h k054539.h msm5205.c msm5205.h msm5232.h multipcm.h n63701x.h namco.h namco52.h nes_apu.h nile.h okim6258.h okim6295.c okim6295.h okim6376.c* okim6376.h* pokey.c pokey.h psx.h qsound.h rf5c400.h rf5c68.h s14001a.c s14001a.h saa1099.h samples.h scsp.c scsp.h segapcm.h sid6581.h sn76477.h sn76496.c sn76496.h snkwave.h sound.mak sp0250.h sp0256.h speaker.h st0016.h tiaintf.h tms3615.h tms36xx.h upd7759.h vlm5030.h votrax.h vrender0.h wave.c wave.h x1_010.h ym2151.c ymf262.c ymf271.c ymf271.h ymf278b.c ymf278b.h ymz280b.c ymz280b.h
[src/emu/video]mc6845.c voodoo.c
[src/lib/util]bitmap.c bitmap.h palette.c palette.h
[src/mame]mame.mak mamedriv.c
[src/mame/audio]8080bw.c atarijsa.c cyberbal.c snes.c taitosnd.c tx1.c
[src/mame/drivers]2mindril.c 3super8.c* 8080bw.c 86lions.c* ace.c acefruit.c actfancr.c adp.c aeroboto.c aerofgt.c airbustr.c ajax.c aleck64.c alpha68k.c ambush.c ampoker2.c amspdwy.c angelkds.c appoooh.c aquarium.c arabian.c arcadecl.c atarig1.c baraduke.c bbusters.c bingoc.c bnstars.c brasil.c btime.c buster.c* caswin.c cb2001.c cchasm.c centiped.c cham24.c coinmstr.c cowrace.c cps1.c cps3.c cubocd32.c cvs.c cyberbal.c deco32.c deco_mlc.c deshoros.c dynax.c esripsys.c fastfred.c firebeat.c gal3.c galaxian.c galdrvr.c galpani3.c gamecstl.c gcpinbal.c genesis.c goldstar.c goodejan.c gticlub.c highvdeo.c* hng64.c hornet.c hyperspt.c igs009.c igs017.c igs_ncs.c* ilpag.c jackpool.c jangou.c janshi.c jantotsu.c jchan.c kaneko16.c konamigx.c lemmings.c lethal.c limenko.c luckgrln.c madalien.c magicfly.c mastboy.c mediagx.c megadriv.h megasys1.c mil4000.c mitchell.c mlanding.c model3.c mogura.c mpoker.c mpu4drvr.c msisaac.c multigam.c namcoic.c namcona1.c namconb1.c namcos12.c namcos22.c namcos23.c naomi.c nemesis.c neogeo.c nwk-tr.c parentj.c pastelg.c pcxt.c* peplus.c plygonet.c polyplay.c punchout.c qix.c queen.c re900.c relief.c rungun.c sbasketb.c scramble.c segac2.c seibuspi.c sengokmj.c sfbonus.c* sfkick.c skykid.c skylncr.c slotcarn.c sms.c* spaceg.c spool99.c srmp6.c ssfindo.c ssv.c st0016.c stv.c suprnova.c taito_b.c taito_l.c taitojc.c taitowlf.c tarzan.c thepit.c tiamc1.c trvmadns.c turbo.c vcombat.c williams.c xyonix.c zac2650.c zn.c zr107.c
[src/mame/includes]8080bw.h ajax.h balsente.h deco16ic.h esripsys.h madalien.h megasys1.h polyplay.h segas24.h snes.h stv.h suprnova.h tiamc1.h tmnt.h williams.h wrally.h
[src/mame/machine]ajax.c amiga.c atarigen.c balsente.c gaplus.c kaneko16.c konamigx.c konamigx.h midyunit.c namcoio.c nb1413m3.c segas24.c segas32.c seicop.c snes.c snesdsp1.c snesdsp2.c snesobc1.c stvcd.c tnzs.c toaplan1.c vsnes.c williams.c
[src/mame/video]8080bw.c 88games.c aeroboto.c aerofgt.c airbustr.c ajax.c aliens.c alpha68k.c angelkds.c appoooh.c arabian.c asterix.c atari.c atarimo.c atarisy1.c balsente.c battlera.c bbusters.c beathead.c blockhl.c boogwing.c bottom9.c btime.c buggychl.c bwing.c chqflag.c circus.c cischeat.c cninja.c crimfght.c cvs.c dassault.c dday.c deco16ic.c deco32.c deco_mlc.c decocass.c equites.c esripsys.c exerion.c exidy440.c f1gp.c gaelco2.c gaiden.c gbusters.c goldstar.c goodejan.c gottlieb.c gradius3.c grchamp.c gridlee.c gticlub.c hyprduel.c irobot.c itech32.c jalblend.c kan_pand.c kaneko16.c konamigx.c konamiic.c konamiic.h lemmings.c lethal.c m10.c m58.c macrossp.c madalien.c magmax.c mainevt.c mainsnk.c mcr.c mcr68.c metro.c model1.c model2.c moo.c ms32.c mystwarr.c namcona1.c namcos1.c namcos2.c namcos22.c namcos86.c nemesis.c parodius.c phoenix.c plygonet.c polepos.c policetr.c polyplay.c ppu2c0x.c psikyosh.c psx.c qix.c rallyx.c realbrk.c relief.c rockola.c rohga.c rollerg.c rungun.c segag80r.c segaic24.c segaic24.h segas18.c segas24.c segasyse.c seibuspi.c sengokmj.c shangha3.c skyraid.c snes.c snk.c snk68.c spbactn.c spy.c ssv.c st0016.c stvvdp1.c stvvdp2.c suprnova.c surpratk.c tail2nos.c taito_b.c taito_f2.c taito_f3.c taito_l.c taitoic.c taitojc.c taitosj.c tatsumi.c tceptor.c tecmo16.c thunderx.c tiamc1.c tmnt.c toaplan1.c toaplan2.c toypop.c tryout.c tunhunt.c twincobr.c ultraman.c usgames.c victory.c wecleman.c wrally.c xexex.c xmen.c ygv608.c zac2650.c
[src/mess]mess.mak
[src/mess/drivers]a2600.c a310.c a7800.c advision.c amiga.c amstrad.c apexc.c apogee.c apple2.c apple2gs.c at.c atari.c atom.c bbc.c bebox.c bk.c c128.c c64.c cgenie.c coco.c comx35.c cybiko.c dai.c dc.c electron.c exidy.c galaxy.c gamepock.c geneve.c hp48.c ip20.c ip22.c jaguar.c jupiter.c kc.c kim1.c lisa.c lviv.c mbee.c mc10.c mekd2.c microtan.c mikro80.c mikrosha.c msx.c mz700.c mz80.c n64.c ondra.c orao.c oric.c orion.c osborne1.c p2000t.c partner.c pc.c pc8801.c pce.c pecom.c pmd85.c primo.c radio86.c special.c spectrum.c ssystem3.c super80.c svi318.c sym1.c ti85.c ti990_10.c ti99_4p.c ti99_4x.c ti99_8.c tm990189.c tmc600.c trs80.c tutor.c ut88.c vc20.c vector06.c vectrex.c vtech1.c vtech2.c zx.c
[src/mess/machine]apple2gs.c apple3.c c64.c cdp1871.c lisa.c osborne1.c
[src/mess/video]733_asr.c amstrad.c avigo.c mbee.c pdp1.c spectrum.c ted7360.c thomson.c tx0.c vdc8563.c x68k.c
[src/osd/winui]properties.c treeview.c

src/mame/audio/snes.c
r4135r4136
200200
201201/***** DSP_Reset *****/
202202
203void DSP_Reset                      /* Reset emulated DSP           */
203static void DSP_Reset                      /* Reset emulated DSP           */
204204    ( void )
205205{
206206int                     i;
r4135r4136
235235
236236/***** DSP_Update *****/
237237
238void DSP_Update                     /* Mix one sample of audio      */
238static void DSP_Update                     /* Mix one sample of audio      */
239239    (
240240    short *             sound_ptr   /* Pointer to mix audio into    */
241241    )
src/mame/audio/cyberbal.c
r4135r4136
55****************************************************************************/
66
77#include "driver.h"
8#include "sound/dac.h"
9#include "sound/2151intf.h"
810#include "machine/atarigen.h"
9#include "sound/dac.h"
1011#include "includes/cyberbal.h"
1112
1213
src/mame/audio/atarijsa.c
r4135r4136
124124   has_tms5220 = has_oki6295 = has_pokey = has_ym2151 = 0;
125125   for (i = 0; i < MAX_SOUND; i++)
126126   {
127      switch (machine->config->sound[i].type)
128      {
129         case SOUND_TMS5220:
130            has_tms5220 = 1;
131            break;
132         case SOUND_OKIM6295:
133            has_oki6295 = 1;
134            break;
135         case SOUND_POKEY:
136            has_pokey = 1;
137            break;
138         case SOUND_YM2151:
139            has_ym2151 = 1;
140            break;
141         default:
142            break;
143      }
127      sound_type type = machine->config->sound[i].type;
128      if (type == SOUND_TMS5220)
129         has_tms5220 = 1;
130      if (type == SOUND_OKIM6295)
131         has_oki6295 = 1;
132      if (type == SOUND_POKEY)
133         has_pokey = 1;
134      if (type == SOUND_YM2151)
135         has_ym2151 = 1;
144136   }
145137
146138   /* install POKEY memory handlers */
src/mame/audio/tx1.c
r4135r4136
66
77#include "driver.h"
88#include "streams.h"
9#include "sound/ay8910.h"
10#include "sound/custom.h"
11#include "video/resnet.h"
912#include "includes/tx1.h"
10#include "video/resnet.h"
11#include "sound/custom.h"
1213
1314
1415/*************************************
src/mame/audio/taitosnd.c
r4135r4136
119119      case 0x00:      // mode #0
120120         //logerror("taitosnd: Master cpu read portdata %01x\n", tc0140syt.masterdata[0]);
121121         return tc0140syt.masterdata[tc0140syt.mainmode ++];
122         break;
123122
124123      case 0x01:      // mode #1
125124         //logerror("taitosnd: Master cpu receives 0/1 : %01x%01x\n", tc0140syt.masterdata[1],tc0140syt.masterdata[0]);
126125         tc0140syt.status &= ~TC0140SYT_PORT01_FULL_MASTER;
127126         return tc0140syt.masterdata[tc0140syt.mainmode ++];
128         break;
129127
130128      case 0x02:      // mode #2
131129         //logerror("taitosnd: Master cpu read masterdata %01x\n", tc0140syt.masterdata[2]);
132130         return tc0140syt.masterdata[tc0140syt.mainmode ++];
133         break;
134131
135132      case 0x03:      // mode #3
136133         //logerror("taitosnd: Master cpu receives 2/3 : %01x%01x\n", tc0140syt.masterdata[3],tc0140syt.masterdata[2]);
137134         tc0140syt.status &= ~TC0140SYT_PORT23_FULL_MASTER;
138135         return tc0140syt.masterdata[tc0140syt.mainmode ++];
139         break;
140136
141137      case 0x04:      // port status
142138         //logerror("tc0140syt : Master cpu read status : %02x\n", tc0140syt.status);
143139         return tc0140syt.status;
144         break;
145140
146141      default:
147142         logerror("tc0140syt : Master cpu read in mode [%02x]\n", tc0140syt.mainmode);
src/mame/audio/8080bw.c
r4135r4136
1111
1212static emu_timer *schaser_effect_555_timer;
1313static attotime schaser_effect_555_time_remain;
14static INT32 schaser_effect_555_time_remain_savable;
1415static int schaser_effect_555_is_low;
1516static int schaser_explosion;
16static UINT8 port_1_last = 0;
17static UINT8 port_2_last = 0;
18static UINT8 port_3_last = 0;
17static UINT8 port_1_last_extra = 0;
18static UINT8 port_2_last_extra = 0;
19static UINT8 port_3_last_extra = 0;
1920
21/*******************************************************/
22/*                                                     */
23/* Global state registration                           */
24/*                                                     */
25/*******************************************************/
2026
27MACHINE_START( extra_8080bw_sh )
28{
29    state_save_register_global(machine, port_1_last_extra);
30    state_save_register_global(machine, port_2_last_extra);
31    state_save_register_global(machine, port_3_last_extra);
32}
33
2134/*******************************************************/
2235/*                                                     */
2336/* Midway "Space Invaders Part II"                     */
r4135r4136
2639
2740WRITE8_HANDLER( invadpt2_sh_port_1_w )
2841{
29   UINT8 rising_bits = data & ~port_1_last;
42   UINT8 rising_bits = data & ~port_1_last_extra;
3043
3144   sn76477_enable_w(0, !(data & 0x01));         /* SAUCER SOUND */
3245
r4135r4136
3952
4053   sound_global_enable(data & 0x20);
4154
42   port_1_last = data;
55   port_1_last_extra = data;
4356
4457}
4558
r4135r4136
5265       D2 = 82K
5366       D3 = 100K */
5467
55   UINT8 rising_bits = data & ~port_2_last;
68   UINT8 rising_bits = data & ~port_2_last_extra;
5669
5770   if (rising_bits & 0x01) sample_start_n(0, 4, 3, 0);      /* FLEET */
5871   if (rising_bits & 0x02) sample_start_n(0, 4, 4, 0);      /* FLEET */
r4135r4136
6275
6376    c8080bw_flip_screen_w(space, data & 0x20);
6477
65   port_2_last = data;
78   port_2_last_extra = data;
6679}
6780
6881
r4135r4136
7487
7588WRITE8_HANDLER( spcewars_sh_port_w )
7689{
77   UINT8 rising_bits = data & ~port_1_last;
90   UINT8 rising_bits = data & ~port_1_last_extra;
7891
7992   sn76477_enable_w(0, !(data & 0x01));         /* Saucer Sound */
8093
r4135r4136
8497
8598   speaker_level_w(0, (data & 0x10) ? 1 : 0);      /* Various bitstream tunes */
8699
87   port_1_last = data;
100   port_1_last_extra = data;
88101}
89102
90103
r4135r4136
117130
118131WRITE8_HANDLER( lrescue_sh_port_1_w )
119132{
120   UINT8 rising_bits = data & ~port_1_last;
133   UINT8 rising_bits = data & ~port_1_last_extra;
121134
122135   if (rising_bits & 0x01) sample_start(0, 3, 0);      /* Thrust */
123136   if (rising_bits & 0x02) sample_start(1, 2, 0);      /* Shot Sound */
r4135r4136
129142
130143   c8080bw_screen_red_w(data & 0x04);
131144
132   port_1_last = data;
145   port_1_last_extra = data;
133146}
134147
135148WRITE8_HANDLER( lrescue_sh_port_2_w )
136149{
137   UINT8 rising_bits = data & ~port_2_last;
150   UINT8 rising_bits = data & ~port_2_last_extra;
138151
139152   if (rising_bits & 0x01) sample_start(1, 8, 0);      /* Footstep high tone */
140153   if (rising_bits & 0x02) sample_start(1, 7, 0);      /* Footstep low tone */
r4135r4136
143156   speaker_level_w(0, (data & 0x08) ? 1 : 0);      /* Bitstream tunes - endlevel and bonus1 */
144157
145158   if (rising_bits & 0x10) sample_start(3, 6, 0);      /* Shooting Star and Rescue Ship sounds */
146   if (~data & 0x10 && port_2_last & 0x10) sample_stop (3);   /* This makes the rescue ship sound beep on and off */
159   if (~data & 0x10 && port_2_last_extra & 0x10) sample_stop (3);   /* This makes the rescue ship sound beep on and off */
147160
148161   c8080bw_flip_screen_w(space, data & 0x20);
149162
150   port_2_last = data;
163   port_2_last_extra = data;
151164}
152165
153166
r4135r4136
173186
174187WRITE8_HANDLER( ballbomb_sh_port_1_w )
175188{
176   UINT8 rising_bits = data & ~port_1_last;
189   UINT8 rising_bits = data & ~port_1_last_extra;
177190
178191   if (rising_bits & 0x01) sample_start(1, 2, 0);      /* Hit a balloon */
179192   if (rising_bits & 0x02) sample_start(2, 0, 0);      /* Shot Sound */
r4135r4136
185198
186199   c8080bw_screen_red_w(data & 0x04);
187200
188   port_1_last = data;
201   port_1_last_extra = data;
189202}
190203
191204WRITE8_HANDLER( ballbomb_sh_port_2_w )
192205{
193   UINT8 rising_bits = data & ~port_2_last;
206   UINT8 rising_bits = data & ~port_2_last_extra;
194207
195208   if (data & 0x01) sample_start(0, 7, 0);      /* Indicates plane will drop bombs */
196209   if (data & 0x04) sample_start(0, 4, 0);      /* Plane is dropping new balloons at start of level */
r4135r4136
198211
199212   c8080bw_flip_screen_w(space, data & 0x20);
200213
201   port_2_last = data;
214   port_2_last_extra = data;
202215}
203216
204217
r4135r4136
249262{
250263   /* bit 4 occurs every 5.25 seconds during gameplay */
251264
252   UINT8 rising_bits = data & ~port_1_last;
265   UINT8 rising_bits = data & ~port_1_last_extra;
253266
254267   if (rising_bits & 0x01) sample_start(1, 7, 0);   /* Death */
255268   if (rising_bits & 0x02) sample_start(0, 1, 0);      /* Shot Sound */
r4135r4136
260273
261274   c8080bw_screen_red_w(data & 0x01);
262275
263   port_1_last = data;
276   port_1_last_extra = data;
264277}
265278
266279WRITE8_HANDLER( indianbt_sh_port_2_w )
267280{
268   UINT8 rising_bits = data & ~port_2_last;
281   UINT8 rising_bits = data & ~port_2_last_extra;
269282
270283   if (rising_bits & 0x01) sample_start(4, 0, 0);      /* Bird dropped an egg, Lasso used */
271284   if (rising_bits & 0x02) sample_start(4, 2, 0);   /* Egg hatches, egg shot */
272285   if (rising_bits & 0x08) sample_start(5, 0, 0);      /* Grabber, Lasso caught something */
273286   if (rising_bits & 0x10) sample_start(3, 7, 0);      /* Lasso sound */
274287
275   port_2_last = data;
288   port_2_last_extra = data;
276289}
277290
278291WRITE8_HANDLER( indianbt_sh_port_3_w )
r4135r4136
783796       bit 4 - Effect Sound C (SX4)
784797       bit 5 - Explosion (SX5) */
785798
799    //printf( "schaser_sh_port_1_w: %02x\n", data );
786800   discrete_sound_w(space, SCHASER_DOT_EN, data & 0x01);
787801   discrete_sound_w(space, SCHASER_DOT_SEL, data & 0x02);
788802
r4135r4136
815829         if (!schaser_effect_555_is_low)
816830         {
817831            schaser_effect_555_time_remain = timer_timeleft(schaser_effect_555_timer);
832                schaser_effect_555_time_remain_savable = attotime_to_double(schaser_effect_555_time_remain);
818833            timer_adjust_oneshot(schaser_effect_555_timer, attotime_never, 0);
819834         }
820835      }
r4135r4136
844859       bit 4 - Field Control B (SX10)
845860       bit 5 - Flip Screen */
846861
862    printf( "schaser_sh_port_2_w: %02x\n", data );
863
847864   discrete_sound_w(space, SCHASER_MUSIC_BIT, data & 0x01);
848865
849866   discrete_sound_w(space, SCHASER_SND_EN, data & 0x02);
r4135r4136
854871   schaser_background_control_w(data & 0x18);
855872
856873   c8080bw_flip_screen_w(space, data & 0x20);
874
875    port_2_last_extra = data;
857876}
858877
859878
r4135r4136
864883   /* Toggle 555 output */
865884   schaser_effect_555_is_low = !schaser_effect_555_is_low;
866885   schaser_effect_555_time_remain = attotime_zero;
886    schaser_effect_555_time_remain_savable = attotime_to_double(schaser_effect_555_time_remain);
867887
868888   if (schaser_effect_555_is_low)
869889      new_time = attotime_div(PERIOD_OF_555_ASTABLE(0, RES_K(20), CAP_U(1)), 2);
r4135r4136
880900}
881901
882902
903static STATE_POSTLOAD( schaser_reinit_555_time_remain )
904{
905    const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
906    schaser_effect_555_time_remain = double_to_attotime(schaser_effect_555_time_remain_savable);
907    schaser_sh_port_2_w(space, 0, port_2_last_extra);
908}
909
910
883911MACHINE_START( schaser )
884912{
885913   schaser_effect_555_timer = timer_alloc(machine, schaser_effect_555_cb, NULL);
886914
915    state_save_register_global(machine, schaser_explosion);
916    state_save_register_global(machine, schaser_effect_555_is_low);
917    state_save_register_global(machine, schaser_effect_555_time_remain_savable);
918    state_save_register_global(machine, port_2_last_extra);
919    state_save_register_postload(machine, schaser_reinit_555_time_remain, NULL);
920
921    MACHINE_START_CALL(extra_8080bw_vh);
887922   MACHINE_START_CALL(mw8080bw);
888923}
889924
r4135r4136
896931   schaser_sh_port_1_w(space, 0, 0);
897932   schaser_sh_port_2_w(space, 0, 0);
898933   schaser_effect_555_time_remain = attotime_zero;
934    schaser_effect_555_time_remain_savable = attotime_to_double(schaser_effect_555_time_remain);
899935
900936   MACHINE_RESET_CALL(mw8080bw);
901937}
r4135r4136
909945
910946WRITE8_HANDLER( rollingc_sh_port_w )
911947{
912   UINT8 rising_bits = data & ~port_3_last;
948   UINT8 rising_bits = data & ~port_3_last_extra;
913949
914950   if (rising_bits & 0x02) sample_start(4, 0, 0);   /* Steering */
915951   if (rising_bits & 0x04) sample_start(0, 1, 0);   /* Collision */
916952   if (rising_bits & 0x10) sample_start(1, 8, 0);   /* Computer car is starting to move */
917953
918   port_3_last = data;
954   port_3_last_extra = data;
919955}
920956
921957
r4135r4136
9751011
9761012WRITE8_HANDLER( lupin3_sh_port_1_w )
9771013{
978   UINT8 rising_bits = data & ~port_1_last;
1014   UINT8 rising_bits = data & ~port_1_last_extra;
9791015
9801016   if (rising_bits & 0x01) sample_start(0, 6, 0);      /* Walking, get money */
9811017
r4135r4136
9851021   if (rising_bits & 0x08) sample_start(0, 1, 0);      /* Jail */
9861022   if (rising_bits & 0x10) sample_start(3, 8, 0);      /* Bonus Man */
9871023
988   port_1_last = data;
1024   port_1_last_extra = data;
9891025}
9901026
9911027WRITE8_HANDLER( lupin3_sh_port_2_w )
9921028{
993   UINT8 rising_bits = data & ~port_2_last;
1029   UINT8 rising_bits = data & ~port_2_last_extra;
9941030
9951031   if (rising_bits & 0x01) sample_start(0, 3, 0);      /* Lands on top of building, wife kicks man */
9961032   if (rising_bits & 0x02) sample_start(1, 2, 0);      /* deposit money, start intermission, end game */
r4135r4136
10001036
10011037   c8080bw_flip_screen_w(space, data & 0x20);
10021038
1003   port_2_last = data;
1039   port_2_last_extra = data;
10041040}
10051041
10061042
r4135r4136
10161052       bit 3 = 1st speedup
10171053       Death is a stream of ff's with some fe's thrown in */
10181054
1019   UINT8 rising_bits = data & ~port_1_last;
1055   UINT8 rising_bits = data & ~port_1_last_extra;
10201056
10211057   if (rising_bits & 0x02) sample_start(1, 6, 0);      /* Ran over a dot */
10221058   if (rising_bits & 0x10) sample_start(0, 1, 0);      /* Death */
10231059
1024   port_1_last = data;
1060   port_1_last_extra = data;
10251061}
10261062
10271063WRITE8_HANDLER( schasrcv_sh_port_2_w )
r4135r4136
10411077
10421078WRITE8_HANDLER( yosakdon_sh_port_1_w )
10431079{
1044   UINT8 rising_bits = data & ~port_1_last;
1080   UINT8 rising_bits = data & ~port_1_last_extra;
10451081
10461082   if (rising_bits & 0x01) sample_start(0, 3, 0);         /* Game Over */
10471083   if (rising_bits & 0x02) sample_start(2, 0, 0);         /* Bird dead */
r4135r4136
10511087
10521088   sound_global_enable(data & 0x20);
10531089
1054   port_1_last = data;
1090   port_1_last_extra = data;
10551091}
10561092
10571093WRITE8_HANDLER( yosakdon_sh_port_2_w )
10581094{
1059   UINT8 rising_bits = data & ~port_2_last;
1095   UINT8 rising_bits = data & ~port_2_last_extra;
10601096
10611097   if (rising_bits & 0x01) sample_start(1, 6, 0);         /* Ready? , Game Over */
10621098   if (rising_bits & 0x04) sample_start(3, 7, 0);         /* Big bird dead */
r4135r4136
10671103
10681104   c8080bw_flip_screen_w(space, data & 0x20);
10691105
1070   port_2_last = data;
1106   port_2_last_extra = data;
10711107}
10721108
10731109
r4135r4136
10801116{
10811117   /* bit 3 is high while you are alive and playing */
10821118
1083   UINT8 rising_bits = data & ~port_1_last;
1119   UINT8 rising_bits = data & ~port_1_last_extra;
10841120
10851121   if (rising_bits & 0x01) sample_start(4, 4, 0);         /* Fleet move */
10861122   if (rising_bits & 0x02) sample_start(5, 8, 0);         /* Extra Tank */
10871123
10881124   sn76477_enable_w(0, data & 0x04 ? 0:1);            /* UFO */
10891125
1090   port_1_last = data;
1126   port_1_last_extra = data;
10911127}
10921128
10931129WRITE8_HANDLER( shuttlei_sh_port_2_w )
src/mame/machine/snesdsp2.c
r4135r4136
1010
1111***************************************************************************/
1212
13int DSP2_waiting_for_command = 0;
14int DSP2_command = 0;
15int DSP2_in_count = 0,  DSP2_in_index = 0;
16int DSP2_out_count = 0, DSP2_out_index = 0;
13static int DSP2_waiting_for_command = 0;
14static int DSP2_command = 0;
15static int DSP2_in_count = 0,  DSP2_in_index = 0;
16static int DSP2_out_count = 0, DSP2_out_index = 0;
1717
18UINT8 DSP2_parameters[512] = {0};
19UINT8 DSP2_output[512] = {0};
18static UINT8 DSP2_parameters[512] = {0};
19static UINT8 DSP2_output[512] = {0};
2020
21UINT8 DSP2_op05transparent = 0;
22int DSP2_op05haslen = 0;
23int DSP2_op05len = 0;
24int DSP2_op06haslen = 0;
25int DSP2_op06len = 0;
26UINT16 DSP2_op09word1 = 0;
27UINT16 DSP2_op09word2 = 0;
28int DSP2_op0dhaslen = 0;
29int DSP2_op0doutlen = 0;
30int DSP2_op0dinlen = 0;
21static UINT8 DSP2_op05transparent = 0;
22static int DSP2_op05haslen = 0;
23static int DSP2_op05len = 0;
24static int DSP2_op06haslen = 0;
25static int DSP2_op06len = 0;
26static UINT16 DSP2_op09word1 = 0;
27static UINT16 DSP2_op09word2 = 0;
28static int DSP2_op0dhaslen = 0;
29static int DSP2_op0doutlen = 0;
30static int DSP2_op0dinlen = 0;
3131
3232
3333//convert bitmap to bitplane tile
34void DSP2_op01( void )
34static void DSP2_op01( void )
3535{
3636//op01 size is always 32 bytes input and output
3737//the hardware does strange things if you vary the size
r4135r4136
8989}
9090
9191//set transparent color
92void DSP2_op03( void )
92static void DSP2_op03( void )
9393{
9494   DSP2_op05transparent = DSP2_parameters[0];
9595}
9696
9797//replace bitmap using transparent color
98void DSP2_op05( void )
98static void DSP2_op05( void )
9999{
100100   UINT8 color;
101101// Overlay bitmap with transparency.
r4135r4136
170170}
171171
172172//scale bitmap
173void DSP2_op0d( void )
173static void DSP2_op0d( void )
174174{
175175// Bit accurate hardware algorithm - uses fixed point math
176176// This should match the DSP2 Op0D output exactly
r4135r4136
239239   DSP2_op0dinlen       = 0;
240240}
241241
242UINT8 DSP2_read( void )
242static UINT8 DSP2_read( void )
243243{
244244   UINT8 r = 0xff;
245245   if (DSP2_out_count)
r4135r4136
252252   return r;
253253}
254254
255void DSP2_write(UINT8 data)
255static void DSP2_write(UINT8 data)
256256{
257257   if(DSP2_waiting_for_command)
258258   {
src/mame/machine/tnzs.c
r4135r4136
242242            logerror("error, unknown mcu command\n");
243243            /* should not happen */
244244            return 0xff;
245            break;
246245      }
247246   }
248247   else
r4135r4136
370369            logerror("error, unknown mcu command\n");
371370            /* should not happen */
372371            return 0xff;
373            break;
374372      }
375373   }
376374   else
r4135r4136
573571      case MCU_TNZS:
574572      case MCU_CHUKATAI:
575573         return mcu_tnzs_r(space,offset);
576         break;
577574      case MCU_ARKANOID:
578575         return mcu_arknoid2_r(space,offset);
579         break;
580576      case MCU_EXTRMATN:
581577      case MCU_DRTOPPEL:
582578      case MCU_PLUMPOP:
583579         return mcu_extrmatn_r(space,offset);
584         break;
585580      default:
586581         return 0xff;
587         break;
588582   }
589583}
590584
src/mame/machine/midyunit.c
r4135r4136
164164   switch (term2_analog_select)
165165   {
166166      default:
167      case 0:  return input_port_read(space->machine, "STICK0_X");  break;
168      case 1:  return input_port_read(space->machine, "STICK0_Y");  break;
169      case 2:  return input_port_read(space->machine, "STICK1_X");  break;
170      case 3:  return input_port_read(space->machine, "STICK1_Y");  break;
167      case 0:  return input_port_read(space->machine, "STICK0_X");
168      case 1:  return input_port_read(space->machine, "STICK0_Y");
169      case 2:  return input_port_read(space->machine, "STICK1_X");
170      case 3:  return input_port_read(space->machine, "STICK1_Y");
171171   }
172172}
173173
src/mame/machine/segas32.c
r4135r4136
165165         case 2:
166166         case 3:
167167            return 0;
168            break;
169168      }
170169   }
171170
r4135r4136
212211            return;
213212         logerror("brival_protection_w: UNKNOWN WRITE: offset %x value %x\n", offset, data);
214213         return;
215         break;
216214   }
217215
218216   memcpy(ret, &ROM[protAddress[curProtType][0]], 16);
src/mame/machine/snesobc1.c
r4135r4136
1212
1313#include "includes/snes.h"
1414
15int obc1_address;
16int obc1_offset;
17int obc1_shift;
15static int obc1_address;
16static int obc1_offset;
17static int obc1_shift;
1818
19READ8_HANDLER( obc1_read )
19static READ8_HANDLER( obc1_read )
2020{
2121   UINT16 address = offset & 0x1fff;
2222   UINT8 value;
r4135r4136
5252}
5353
5454
55WRITE8_HANDLER( obc1_write )
55static WRITE8_HANDLER( obc1_write )
5656{
5757   UINT16 address = offset & 0x1fff;
5858   UINT8 temp;
r4135r4136
9898   }
9999}
100100
101void obc1_init( void )
101static void obc1_init( void )
102102{
103103   obc1_offset  = (snes_ram[0x1ff5] & 0x01) ? 0x1800 : 0x1c00;
104104   obc1_address = (snes_ram[0x1ff6] & 0x7f);
src/mame/machine/segas24.c
r4135r4136
3434void system24temp_sys16_io_set_callbacks(UINT8 (*io_r)(running_machine *machine, int port),
3535                       void  (*io_w)(running_machine *machine, int port, UINT8 data),
3636                       void  (*cnt_w)(const address_space *space, UINT8 data),
37                       READ16_HANDLER ((*iod_r)),
38                       WRITE16_HANDLER((*iod_w)))
37                       read16_space_func iod_r,
38                       write16_space_func iod_w)
3939{
4040   system24temp_sys16_io_io_r = io_r;
4141   system24temp_sys16_io_io_w = io_w;
src/mame/machine/konamigx.c
r4135r4136
211211      bitmap_t *dst_bitmap, bitmap_t *src_bitmap,
212212      const rectangle *dst_cliprect, const rectangle *src_cliprect,
213213      UINT32 _startx,UINT32 _starty,int _incxx,int _incxy,int _incyx,int _incyy,
214      int tilebpp, int blend, int clip )
214      int tilebpp, int blend, int alpha, int clip )
215215{
216216   static const int colormask[8]={1,3,7,0xf,0x1f,0x3f,0x7f,0xff};
217217
r4135r4136
288288            if (!(pixel & cmask))
289289               continue;
290290
291            dst_ptr[ecx] = alpha_blend32(pal_base[pixel], dst_ptr[ecx]);
291            dst_ptr[ecx] = alpha_blend_r32(pal_base[pixel], dst_ptr[ecx], alpha);
292292         }
293293         while (++ecx);
294294
r4135r4136
361361static void K053936GP_zoom_draw(running_machine *machine,
362362      int chip, UINT16 *ctrl, UINT16 *linectrl,
363363      bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap,
364      int tilebpp, int blend)
364      int tilebpp, int blend, int alpha)
365365{
366366   bitmap_t *src_bitmap;
367367   rectangle *src_cliprect;
r4135r4136
401401         K053936GP_copyroz32clip(machine,
402402               bitmap, src_bitmap, &my_clip, src_cliprect,
403403               startx<<5, starty<<5, incxx<<5, incxy<<5, 0, 0,
404               tilebpp, blend, clip);
404               tilebpp, blend, alpha, clip);
405405         y++;
406406      }
407407   }
r4135r4136
426426      K053936GP_copyroz32clip(machine,
427427            bitmap, src_bitmap, cliprect, src_cliprect,
428428            startx<<5, starty<<5, incxx<<5, incxy<<5, incyx<<5, incyy<<5,
429            tilebpp, blend, clip);
429            tilebpp, blend, alpha, clip);
430430   }
431431}
432432
433433void K053936GP_0_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,
434      tilemap *tmap, int tilebpp, int blend)
434      tilemap *tmap, int tilebpp, int blend, int alpha)
435435{
436   K053936GP_zoom_draw(machine, 0,K053936_0_ctrl,K053936_0_linectrl,bitmap,cliprect,tmap,tilebpp,blend);
436   K053936GP_zoom_draw(machine, 0,K053936_0_ctrl,K053936_0_linectrl,bitmap,cliprect,tmap,tilebpp,blend,alpha);
437437}
438438
439439void K053936GP_1_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,
440      tilemap *tmap, int tilebpp, int blend)
440      tilemap *tmap, int tilebpp, int blend, int alpha)
441441{
442   K053936GP_zoom_draw(machine, 1,K053936_1_ctrl,K053936_1_linectrl,bitmap,cliprect,tmap,tilebpp,blend);
442   K053936GP_zoom_draw(machine, 1,K053936_1_ctrl,K053936_1_linectrl,bitmap,cliprect,tmap,tilebpp,blend,alpha);
443443}
444444
445445
r4135r4136
471471#define FPENT  0
472472
473473   // inner loop
474   UINT8  *src_ptr;
474   const UINT8  *src_ptr;
475475   int src_x;
476476   int eax, ecx;
477477   int src_fx, src_fdx;
r4135r4136
485485
486486   // outter loop
487487   int src_fby, src_fdy, src_fbx;
488   UINT8 *src_base;
488   const UINT8 *src_base;
489489   int dst_w, dst_h;
490490
491491   // one-time
r4135r4136
524524   src_pitch = 16;
525525   src_fw    = 16;
526526   src_fh    = 16;
527   src_base  = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
527   src_base  = gfx_element_get_data(gfx, code % gfx->total_elements);
528528
529529   pal_base  = machine->pens + gfx->color_base + (color % gfx->total_colors) * granularity;
530530   shd_base  = machine->shadow_table;
r4135r4136
691691                     if (!eax || ozbuf_ptr[ecx] < z8) continue;
692692                     ozbuf_ptr[ecx] = z8;
693693
694                     dst_ptr[ecx] = alpha_blend32(pal_base[eax], dst_ptr[ecx]);
694                     dst_ptr[ecx] = alpha_blend_r32(pal_base[eax], dst_ptr[ecx], alpha);
695695                  }
696696                  while (++ecx);
697697
r4135r4136
717717                     if (!eax || eax >= shdpen || ozbuf_ptr[ecx] < z8) continue;
718718                     ozbuf_ptr[ecx] = z8;
719719
720                     dst_ptr[ecx] = alpha_blend32(pal_base[eax], dst_ptr[ecx]);
720                     dst_ptr[ecx] = alpha_blend_r32(pal_base[eax], dst_ptr[ecx], alpha);
721721                  }
722722                  while (++ecx);
723723
r4135r4136
838838                     if (!eax || ozbuf_ptr[ecx] < z8) continue;
839839                     ozbuf_ptr[ecx] = z8;
840840
841                     dst_ptr[ecx] = alpha_blend32(pal_base[eax], dst_ptr[ecx]);
841                     dst_ptr[ecx] = alpha_blend_r32(pal_base[eax], dst_ptr[ecx], alpha);
842842                  }
843843                  while (++ecx);
844844
r4135r4136
858858                     if (!eax || eax >= shdpen || ozbuf_ptr[ecx] < z8) continue;
859859                     ozbuf_ptr[ecx] = z8;
860860
861                     dst_ptr[ecx] = alpha_blend32(pal_base[eax], dst_ptr[ecx]);
861                     dst_ptr[ecx] = alpha_blend_r32(pal_base[eax], dst_ptr[ecx], alpha);
862862                  }
863863                  while (++ecx);
864864
r4135r4136
16031603                  temp4 = K054338_set_alpha_level(temp2);
16041604
16051605                  if (temp4 <= 0) continue;
1606                  if (temp4 < 255) k = TILEMAP_DRAW_ALPHA;
1606                  if (temp4 < 255) k = TILEMAP_DRAW_ALPHA(temp4);
16071607               }
16081608
1609               if (mixerflags & 1<<(code+12)) k |= TILE_LINE_DISABLED;
1609               if (mixerflags & 1<<(code+12)) k |= K056382_DRAW_FLAG_FORCE_XYSCROLL;
16101610
16111611               K056832_tilemap_draw(machine, bitmap, cliprect, code, k, 0);
16121612            }
r4135r4136
16151615            case -4:
16161616            if (disp & K55_INP_SUB1)
16171617            {
1618               int alpha = 255;
16181619               if (j == GXMIX_BLEND_NONE)  { temp1 = 0xff; temp2 = temp3 = 0; } else
16191620               if (j == GXMIX_BLEND_FORCE) { temp1 = 0x00; temp2 = mixerflags>>24; temp3 = 3; }
16201621               else
r4135r4136
16261627
16271628               if (temp1!=0xff && temp2 /*&& temp3==3*/)
16281629               {
1629                  temp4 = K054338_set_alpha_level(temp2);
1630                  alpha = temp4 = K054338_set_alpha_level(temp2);
16301631
16311632                  if (temp4 <= 0) continue;
16321633                  if (temp4 < 255) k = (j == GXMIX_BLEND_FAST) ? ~parity : 1;
r4135r4136
16351636               l = sub1flags & 0xf;
16361637
16371638               if (offs == -2)
1638                  K053936GP_0_zoom_draw(machine, bitmap, cliprect, sub1, l, k);
1639                  K053936GP_0_zoom_draw(machine, bitmap, cliprect, sub1, l, k, alpha);
16391640               else
16401641                  K053250_draw(machine, bitmap, cliprect, 0, vcblk[4]<<l, 0, 0);
16411642            }
r4135r4136
16441645            case -5:
16451646            if (disp & K55_INP_SUB2)
16461647            {
1648               int alpha = 255;
16471649               if (j == GXMIX_BLEND_NONE)  { temp1 = 0xff; temp2 = temp3 = 0; } else
16481650               if (j == GXMIX_BLEND_FORCE) { temp1 = 0x00; temp2 = mixerflags>>26; temp3 = 3; }
16491651               else
r4135r4136
16551657
16561658               if (temp1!=0xff && temp2 /*&& temp3==3*/)
16571659               {
1658                  temp4 = K054338_set_alpha_level(temp2);
1660                  alpha = temp4 = K054338_set_alpha_level(temp2);
16591661
16601662                  if (temp4 <= 0) continue;
16611663                  if (temp4 < 255) k = (j == GXMIX_BLEND_FAST) ? ~parity : 1;
r4135r4136
16641666               l = sub2flags & 0xf;
16651667
16661668               if (offs == -3)
1667                  K053936GP_1_zoom_draw(machine, bitmap, cliprect, sub2, l, k);
1669                  K053936GP_1_zoom_draw(machine, bitmap, cliprect, sub2, l, k, alpha);
16681670               else
16691671                  K053250_draw(machine, bitmap, cliprect, 1, vcblk[5]<<l, 0, 0);
16701672            }
src/mame/machine/toaplan1.c
r4135r4136
77#include "cpu/z80/z80.h"
88#include "cpu/m68000/m68000.h"
99#include "cpu/tms32010/tms32010.h"
10#include "sound/3812intf.h"
1011#include "includes/toaplan1.h"
1112
1213#define CLEAR 0
src/mame/machine/konamigx.h
r4135r4136
2121void K053936GP_set_offset(int chip, int xoffs, int yoffs);
2222void K053936GP_clip_enable(int chip, int status);
2323void K053936GP_set_cliprect(int chip, int minx, int maxx, int miny, int maxy);
24void K053936GP_0_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int tilebpp, int blend);
25void K053936GP_1_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int tilebpp, int blend);
24void K053936GP_0_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int tilebpp, int blend, int alpha);
25void K053936GP_1_zoom_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int tilebpp, int blend, int alpha);
2626
2727
2828
src/mame/machine/stvcd.c
r4135r4136
383383//          CDROM_LOG(("%s:RW HIRQ: %04x\n", cpuexec_describe_context(Machine), rv))
384384
385385         return rv;
386         break;
387386
388387      case 0x000c:
389388      case 0x000e:
390389         CDROM_LOG(("RW HIRM: %04x\n", hirqmask))
391390         return hirqmask;
392         break;
393391
394392      case 0x0018:
395393      case 0x001a:
396394//          CDROM_LOG(("RW CR1: %04x\n", cr1))
397395         return cr1;
398         break;
399396
400397      case 0x001c:
401398      case 0x001e:
402399//          CDROM_LOG(("RW CR2: %04x\n", cr2))
403400         return cr2;
404         break;
405401
406402      case 0x0020:
407403      case 0x0022:
408404//          CDROM_LOG(("RW CR3: %04x\n", cr3))
409405         return cr3;
410         break;
411406
412407      case 0x0024:
413408      case 0x0026:
414409//          CDROM_LOG(("RW CR4: %04x\n", cr4))
415410         return cr4;
416         break;
417411
418412      case 0x8000:
419413         rv = 0xffff;
r4135r4136
450444         }
451445
452446         return rv;
453         break;
454447
455448      default:
456449         CDROM_LOG(("%s:CD: RW %08x\n", cpuexec_describe_context(machine), addr))
457450         return 0xffff;
458         break;
459451   }
460452
461453}
r4135r4136
526518         }
527519
528520         return rv;
529         break;
530521
531522      default:
532523         CDROM_LOG(("%s:CD: RL %08x\n", cpuexec_describe_context(machine), addr))
533524         return 0xffff;
534         break;
535525   }
536526}
537527
r4135r4136
566556   case 0x0022:
567557//              CDROM_LOG(("WW CR3: %04x\n", data))
568558      cr3 = data;
569         break;
559      break;
570560   case 0x0024:
571561   case 0x0026:
572562//              CDROM_LOG(("WW CR4: %04x\n", data))
r4135r4136
13481338      case 0x90026:
13491339         rv = cd_readWord(offset);
13501340         return rv<<16;
1351         break;
13521341
13531342      case 0x98000:
13541343      case 0x18000:
src/mame/machine/namcoio.c
r4135r4136
967967
968968   switch (customio_command[chip] & 0xf)
969969   {
970      case 0x1: return namco_06xx_data_read(machine, 4*chip + 0); break;
971      case 0x2: return namco_06xx_data_read(machine, 4*chip + 1); break;
972      case 0x4: return namco_06xx_data_read(machine, 4*chip + 2); break;
973      case 0x8: return namco_06xx_data_read(machine, 4*chip + 3); break;
970      case 0x1: return namco_06xx_data_read(machine, 4*chip + 0);
971      case 0x2: return namco_06xx_data_read(machine, 4*chip + 1);
972      case 0x4: return namco_06xx_data_read(machine, 4*chip + 2);
973      case 0x8: return namco_06xx_data_read(machine, 4*chip + 3);
974974      default:
975975         logerror("%s: 06XX #%d read in unsupported mode %02x\n",cpuexec_describe_context(machine),chip,customio_command[chip]);
976976         return 0xff;
src/mame/machine/gaplus.c
r4135r4136
3636   {
3737      case 0:
3838         return input_port_read(space->machine, "IN2");      /* cabinet & test mode */
39         break;
4039      case 1:
4140         return (mode == 2) ? gaplus_customio_3[offset] : 0x0f;
42         break;
4341      case 2:
4442         return (mode == 2) ? 0x0f : 0x0e;
45         break;
4643      case 3:
4744         return (mode == 2) ? gaplus_customio_3[offset] : 0x01;
48         break;
4945      default:
5046         return gaplus_customio_3[offset];
5147   }
src/mame/machine/balsente.c
r4135r4136
8383
8484/* noise generator states */
8585static UINT32 noise_position[6];
86static const device_config *cem_device[6];
8687
8788/* game-specific states */
8889static UINT8 nstocker_bits;
r4135r4136
182183
183184   /* reset the noise generator */
184185   memset(noise_position, 0, sizeof(noise_position));
186   memset(cem_device, 0, sizeof(cem_device));
185187
186188   /* point the banks to bank 0 */
187189   numbanks = (memory_region_length(machine, "main") > 0x40000) ? 16 : 8;
r4135r4136
279281}
280282
281283
282void balsente_noise_gen(int chip, int count, short *buffer)
284void balsente_noise_gen(const device_config *device, int count, short *buffer)
283285{
286   int chip;
287   UINT32 step, noise_counter;
288
289   /* find the chip we are referring to */
290   for (chip = 0; chip < ARRAY_LENGTH(cem_device); chip++)
291   {
292      if (device == cem_device[chip])
293         break;
294      else if (cem_device[chip] == NULL)
295      {
296         cem_device[chip] = device;
297         break;
298      }
299   }
300   assert(chip < ARRAY_LENGTH(cem_device));
301
284302   /* noise generator runs at 100kHz */
285   UINT32 step = (100000 << 14) / CEM3394_SAMPLE_RATE;
286   UINT32 noise_counter = noise_position[chip];
303   step = (100000 << 14) / CEM3394_SAMPLE_RATE;
304   noise_counter = noise_position[chip];
287305
288306   while (count--)
289307   {
src/mame/machine/vsnes.c
r4135r4136
10001000      {
10011001            case 9:
10021002             return 0x6F;
1003         break;
10041003
10051004         case 14:
10061005            return 0x94;
1007         break;
10081006
10091007            default:
10101008             return 0xB4;
1011         break;
10121009      }
10131010   }
10141011}
src/mame/machine/snes.c
r4135r4136
514514         return snes_ram[offset];
515515      case RDIO:         /* Programmable I/O port - echos back what's written to WRIO */
516516         return snes_ram[WRIO];
517         break;
518517      case RDDIVL:      /* Quotient of divide result (low) */
519518      case RDDIVH:      /* Quotient of divide result (high) */
520519      case RDMPYL:      /* Product/Remainder of mult/div result (low) */
src/mame/machine/amiga.c
r4135r4136
12211221
12221222      case REG_DENISEID:
12231223         return CUSTOM_REG(REG_DENISEID);
1224         break;
12251224   }
12261225
12271226   if (LOG_CUSTOM)
src/mame/machine/atarigen.c
r4135r4136
88
99
1010#include "driver.h"
11#include "cpu/m6502/m6502.h"
12#include "sound/2151intf.h"
13#include "sound/2413intf.h"
14#include "sound/5220intf.h"
15#include "sound/okim6295.h"
16#include "sound/pokey.h"
17#include "slapstic.h"
1118#include "atarigen.h"
12#include "slapstic.h"
13#include "cpu/m6502/m6502.h"
1419
1520
1621
r4135r4136
16051610{
16061611   gfx_element *gx0 = machine->gfx[gfx0];
16071612   gfx_element *gx1 = machine->gfx[gfx1];
1613   UINT8 *srcdata, *dest;
16081614   int c, x, y;
16091615
1616   /* allocate memory for the assembled data */
1617   srcdata = auto_malloc(gx0->total_elements * gx0->width * gx0->height);
1618
16101619   /* loop over elements */
1620   dest = srcdata;
16111621   for (c = 0; c < gx0->total_elements; c++)
16121622   {
1613      UINT8 *c0base = gx0->gfxdata + gx0->char_modulo * c;
1614      UINT8 *c1base = gx1->gfxdata + gx1->char_modulo * c;
1615      UINT32 usage = 0;
1623      const UINT8 *c0base = gfx_element_get_data(gx0, c);
1624      const UINT8 *c1base = gfx_element_get_data(gx1, c);
16161625
16171626      /* loop over height */
16181627      for (y = 0; y < gx0->height; y++)
16191628      {
1620         UINT8 *c0 = c0base, *c1 = c1base;
1629         const UINT8 *c0 = c0base;
1630         const UINT8 *c1 = c1base;
16211631
1622         for (x = 0; x < gx0->width; x++, c0++, c1++)
1623         {
1624            *c0 = (*c0 & mask0) | (*c1 & mask1);
1625            usage |= 1 << *c0;
1626         }
1632         for (x = 0; x < gx0->width; x++)
1633            *dest++ = (*c0++ & mask0) | (*c1++ & mask1);
16271634         c0base += gx0->line_modulo;
16281635         c1base += gx1->line_modulo;
1629         if (gx0->pen_usage)
1630            gx0->pen_usage[c] = usage;
16311636      }
16321637   }
16331638
16341639   /* free the second graphics element */
1635   freegfx(gx1);
1640   gfx_element_free(gx1);
16361641   machine->gfx[gfx1] = NULL;
1642
1643   /* create a simple target layout */
1644   gx0->layout.planes = 8;
1645   for (x = 0; x < 8; x++)
1646      gx0->layout.planeoffset[x] = x;
1647   for (x = 0; x < gx0->width; x++)
1648      gx0->layout.xoffset[x] = 8 * x;
1649   for (y = 0; y < gx0->height; y++)
1650      gx0->layout.yoffset[y] = 8 * y * gx0->width;
1651   gx0->layout.charincrement = 8 * gx0->width * gx0->height;
1652
1653   /* make the assembled data our new source data */
1654   gfx_element_set_source(gx0, srcdata);
16371655}
16381656
16391657
src/mame/machine/snesdsp1.c
r4135r4136
121121
122122//////////////////////////////////////////////////////////////////
123123
124UINT8 DSP1_getSr(void)
124static UINT8 DSP1_getSr(void)
125125{
126126   mSrLowByteAccess = ~mSrLowByteAccess;
127127   if (mSrLowByteAccess)
r4135r4136
136136
137137//////////////////////////////////////////////////////////////////
138138
139UINT8 DSP1_getDr(void)
139static UINT8 DSP1_getDr(void)
140140{
141141   UINT8 oDr;
142142
r4135r4136
146146
147147//////////////////////////////////////////////////////////////////
148148
149void DSP1_setDr(UINT8 iDr)
149static void DSP1_setDr(UINT8 iDr)
150150{
151151    DSP1_fsmStep(0, &iDr);
152152}
153153
154154//////////////////////////////////////////////////////////////////
155155
156void DSP1_reset(running_machine *machine)
156static void DSP1_reset(running_machine *machine)
157157{
158158   UINT32 i;
159159   UINT8 *dspin = memory_region(machine, "user6");
src/mame/machine/kaneko16.c
r4135r4136
330330
331331      case 0x00ff:
332332      {
333            static UINT16 shogwarr_snip_[] = {
333            static const UINT16 shogwarr_snip_[] = {
334334          0x48E7,0xFFFE,            // movem.l D0-D7/A0-A6, -(A7)
335335
336336         0x3039,0x00A8,0x0000,      // move.w  $a80000.l, D0
r4135r4136
567567*/
568568
569569
570static UINT8 toybox_mcu_decryption_table[0x100] = {
570static const UINT8 toybox_mcu_decryption_table[0x100] = {
5715710x7b,0x82,0xf0,0xbc,0x7f,0x1d,0xa2,0xc5,0x2a,0xfa,0x55,0xee,0x1a,0xd0,0x59,0x76,
5725720x5e,0x75,0x79,0x16,0xa5,0xf6,0x84,0xed,0x0f,0x2e,0xf2,0x36,0x61,0xac,0xcd,0xab,
5735730x01,0x3b,0x01,0x87,0x73,0xab,0xce,0x5d,0xd4,0x1d,0x68,0x2a,0x35,0xea,0x13,0x27,
r4135r4136
587587};
588588
589589
590static UINT8 toybox_mcu_decryption_table_alt[0x100] = {
590static const UINT8 toybox_mcu_decryption_table_alt[0x100] = {
5915910x26,0x17,0xb9,0xcf,0x1a,0xf5,0x14,0x1e,0x0c,0x35,0xb3,0x66,0xa0,0x17,0xe9,0xe4,
5925920x90,0xf6,0xd5,0x35,0xac,0x95,0x49,0x43,0x64,0x0c,0x03,0x75,0x4d,0xda,0xb6,0xdf,
5935930x06,0xcf,0x83,0x9e,0x35,0x2c,0x71,0x2a,0xab,0xcc,0x65,0xd4,0x1f,0xb0,0x88,0x3c,
src/mame/machine/williams.c
r4135r4136
88#include "audio/williams.h"
99#include "cpu/m6800/m6800.h"
1010#include "cpu/m6809/m6809.h"
11#include "machine/6821pia.h"
11#include "machine/6821new.h"
1212#include "machine/ticket.h"
1313#include "williams.h"
1414#include "sound/dac.h"
r4135r4136
3131static UINT16 joust2_current_sound_data;
3232
3333/* older-Williams routines */
34static void williams_main_irq(running_machine *machine, int state);
35static void williams_main_firq(running_machine *machine, int state);
36static void williams_snd_irq(running_machine *machine, int state);
37static WRITE8_HANDLER( williams_snd_cmd_w );
38static WRITE8_HANDLER( playball_snd_cmd_w );
34static void williams_main_irq(const device_config *device, int state);
35static void williams_main_firq(const device_config *device, int state);
36static void williams_snd_irq(const device_config *device, int state);
37static WRITE8_DEVICE_HANDLER( williams_snd_cmd_w );
38static WRITE8_DEVICE_HANDLER( playball_snd_cmd_w );
3939
4040/* input port mapping */
4141static UINT8 port_select;
42static WRITE8_HANDLER( williams_port_select_w );
43static READ8_HANDLER( williams_input_port_49way_0_5_r );
44static READ8_HANDLER( williams_49way_port_0_r );
42static WRITE8_DEVICE_HANDLER( williams_port_select_w );
43static READ8_DEVICE_HANDLER( williams_input_port_49way_0_5_r );
44static READ8_DEVICE_HANDLER( williams_49way_port_0_r );
4545
4646/* newer-Williams routines */
47static WRITE8_HANDLER( williams2_snd_cmd_w );
48static void mysticm_main_irq(running_machine *machine, int state);
49static void tshoot_main_irq(running_machine *machine, int state);
47static WRITE8_DEVICE_HANDLER( williams2_snd_cmd_w );
48static void mysticm_main_irq(const device_config *device, int state);
49static void tshoot_main_irq(const device_config *device, int state);
5050
5151/* Lotto Fun-specific code */
52static READ8_HANDLER( lottofun_input_port_0_r );
52static READ8_DEVICE_HANDLER( lottofun_input_port_0_r );
5353
5454/* Turkey Shoot-specific code */
55static READ8_HANDLER( tshoot_input_port_0_3_r );
56static WRITE8_HANDLER( tshoot_lamp_w );
57static WRITE8_HANDLER( tshoot_maxvol_w );
55static READ8_DEVICE_HANDLER( tshoot_input_port_0_3_r );
56static WRITE8_DEVICE_HANDLER( tshoot_lamp_w );
57static WRITE8_DEVICE_HANDLER( tshoot_maxvol_w );
5858
5959/* Joust 2-specific code */
60static WRITE8_HANDLER( joust2_snd_cmd_w );
61static WRITE8_HANDLER( joust2_pia_3_cb1_w );
60static WRITE8_DEVICE_HANDLER( joust2_snd_cmd_w );
61static WRITE8_DEVICE_HANDLER( joust2_pia_3_cb1_w );
6262
6363
6464
6565/*************************************
6666 *
67 *  Trampoline functions
68 *
69 *************************************/
70
71static READ8_DEVICE_HANDLER( input_port_0_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 0)); }
72static READ8_DEVICE_HANDLER( input_port_1_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 1)); }
73static READ8_DEVICE_HANDLER( input_port_2_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 2)); }
74static READ8_DEVICE_HANDLER( input_port_3_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 3)); }
75static READ8_DEVICE_HANDLER( input_port_4_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 4)); }
76
77static WRITE8_DEVICE_HANDLER( williams_dac_data_w )
78{
79   const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
80   dac_0_data_w(space, offset, data);
81}
82
83static WRITE8_DEVICE_HANDLER( williams_ticket_dispenser_w )
84{
85   const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
86   ticket_dispenser_w(space, offset, data);
87}
88
89static WRITE8_DEVICE_HANDLER( williams_hc55516_0_digit_w )
90{
91   const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
92   hc55516_0_digit_w(space, offset, data);
93}
94
95static WRITE8_DEVICE_HANDLER( williams_hc55516_0_clock_w )
96{
97   const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
98   hc55516_0_clock_w(space, offset, data);
99}
100
101static WRITE8_DEVICE_HANDLER( pia_1_portb_w )
102{
103   const device_config *pia_1 = devtag_get_device(device->machine, PIA6821, "pia_1");
104   pia_portb_w(pia_1, offset, data);
105}
106
107static WRITE8_DEVICE_HANDLER( pia_1_cb1_w )
108{
109   const device_config *pia_1 = devtag_get_device(device->machine, PIA6821, "pia_1");
110   pia_cb1_w(pia_1, offset, data);
111}
112
113static WRITE8_DEVICE_HANDLER( pia_2_ca1_w )
114{
115   const device_config *pia_2 = devtag_get_device(device->machine, PIA6821, "pia_2");
116   pia_ca1_w(pia_2, offset, data);
117}
118
119/*************************************
120 *
67121 *  Generic old-Williams PIA interfaces
68122 *
69123 *************************************/
r4135r4136
71125/* Generic PIA 0, maps to input ports 0 and 1 */
72126const pia6821_interface williams_pia_0_intf =
73127{
74   /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_r, input_port_1_r, 0, 0, 0, 0,
128   /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_device_r, input_port_1_device_r, 0, 0, 0, 0,
75129   /*outputs: A/B,CA/B2       */ 0, 0, 0, 0,
76130   /*irqs   : A/B             */ 0, 0
77131};
r4135r4136
81135/* muxing done in williams_mux_r */
82136const pia6821_interface williams_muxed_pia_0_intf =
83137{
84   /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_r, input_port_1_r, 0, 0, 0, 0,
138   /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_device_r, input_port_1_device_r, 0, 0, 0, 0,
85139   /*outputs: A/B,CA/B2       */ 0, 0, 0, williams_port_select_w,
86140   /*irqs   : A/B             */ 0, 0
87141};
r4135r4136
89143/* Generic 49-way joystick PIA 0 for Sinistar/Blaster */
90144const pia6821_interface williams_49way_pia_0_intf =
91145{
92   /*inputs : A/B,CA/B1,CA/B2 */ williams_49way_port_0_r, input_port_1_r, 0, 0, 0, 0,
146   /*inputs : A/B,CA/B1,CA/B2 */ williams_49way_port_0_r, input_port_1_device_r, 0, 0, 0, 0,
93147   /*outputs: A/B,CA/B2       */ 0, 0, 0, 0,
94148   /*irqs   : A/B             */ 0, 0
95149};
r4135r4136
97151/* Muxing 49-way joystick PIA 0 for Blaster kit */
98152const pia6821_interface williams_49way_muxed_pia_0_intf =
99153{
100   /*inputs : A/B,CA/B1,CA/B2 */ williams_input_port_49way_0_5_r, input_port_1_r, 0, 0, 0, 0,
154   /*inputs : A/B,CA/B1,CA/B2 */ williams_input_port_49way_0_5_r, input_port_1_device_r, 0, 0, 0, 0,
101155   /*outputs: A/B,CA/B2       */ 0, 0, 0, williams_port_select_w,
102156   /*irqs   : A/B             */ 0, 0
103157};
r4135r4136
105159/* Generic PIA 1, maps to input port 2, sound command out, and IRQs */
106160const pia6821_interface williams_pia_1_intf =
107161{
108   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0,
162   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0,
109163   /*outputs: A/B,CA/B2       */ 0, williams_snd_cmd_w, 0, 0,
110164   /*irqs   : A/B             */ williams_main_irq, williams_main_irq
111165};
r4135r4136
114168const pia6821_interface williams_snd_pia_intf =
115169{
116170   /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
117   /*outputs: A/B,CA/B2       */ dac_0_data_w, 0, 0, 0,
171   /*outputs: A/B,CA/B2       */ williams_dac_data_w, 0, 0, 0,
118172   /*irqs   : A/B             */ williams_snd_irq, williams_snd_irq
119173};
120174
r4135r4136
129183/* Special PIA 0 for Lotto Fun, to handle the controls and ticket dispenser */
130184const pia6821_interface lottofun_pia_0_intf =
131185{
132   /*inputs : A/B,CA/B1,CA/B2 */ lottofun_input_port_0_r, input_port_1_r, 0, 0, 0, 0,
133   /*outputs: A/B,CA/B2       */ 0, ticket_dispenser_w, 0, 0,
186   /*inputs : A/B,CA/B1,CA/B2 */ lottofun_input_port_0_r, input_port_1_device_r, 0, 0, 0, 0,
187   /*outputs: A/B,CA/B2       */ 0, williams_ticket_dispenser_w, 0, 0,
134188   /*irqs   : A/B             */ 0, 0
135189};
136190
r4135r4136
138192const pia6821_interface sinistar_snd_pia_intf =
139193{
140194   /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
141   /*outputs: A/B,CA/B2       */ dac_0_data_w, 0, hc55516_0_digit_w, hc55516_0_clock_w,
195   /*outputs: A/B,CA/B2       */ williams_dac_data_w, 0, williams_hc55516_0_digit_w, williams_hc55516_0_clock_w,
142196   /*irqs   : A/B             */ williams_snd_irq, williams_snd_irq
143197};
144198
145199/* Special PIA 1 for PlayBall, doesn't set the high bits on sound commands */
146200const pia6821_interface playball_pia_1_intf =
147201{
148   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0,
202   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0,
149203   /*outputs: A/B,CA/B2       */ 0, playball_snd_cmd_w, 0, 0,
150204   /*irqs   : A/B             */ williams_main_irq, williams_main_irq
151205};
r4135r4136
153207/* extra PIA 3 for Speed Ball */
154208const pia6821_interface spdball_pia_3_intf =
155209{
156   /*inputs : A/B,CA/B1,CA/B2 */ input_port_3_r, input_port_4_r, 0, 0, 0, 0,
210   /*inputs : A/B,CA/B1,CA/B2 */ input_port_3_device_r, input_port_4_device_r, 0, 0, 0, 0,
157211   /*outputs: A/B,CA/B2       */ 0, 0, 0, 0,
158212   /*irqs   : A/B             */ 0, 0
159213};
r4135r4136
169223/* Generic muxing PIA 0, maps to input ports 0/3 and 1; port select is CA2 */
170224const pia6821_interface williams2_muxed_pia_0_intf =
171225{
172   /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_r, input_port_1_r, 0, 0, 0, 0,
226   /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_device_r, input_port_1_device_r, 0, 0, 0, 0,
173227   /*outputs: A/B,CA/B2       */ 0, 0, williams_port_select_w, 0,
174228   /*irqs   : A/B             */ 0, 0
175229};
r4135r4136
177231/* Generic PIA 1, maps to input port 2, sound command out, and IRQs */
178232const pia6821_interface williams2_pia_1_intf =
179233{
180   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0,
234   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0,
181235   /*outputs: A/B,CA/B2       */ 0, williams2_snd_cmd_w, 0, pia_2_ca1_w,
182236   /*irqs   : A/B             */ williams_main_irq, williams_main_irq
183237};
r4135r4136
186240const pia6821_interface williams2_snd_pia_intf =
187241{
188242   /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
189   /*outputs: A/B,CA/B2       */ pia_1_portb_w, dac_0_data_w, pia_1_cb1_w, 0,
243   /*outputs: A/B,CA/B2       */ pia_1_portb_w, williams_dac_data_w, pia_1_cb1_w, 0,
190244   /*irqs   : A/B             */ williams_snd_irq, williams_snd_irq
191245};
192246
r4135r4136
201255/* Mystic Marathon PIA 0 */
202256const pia6821_interface mysticm_pia_0_intf =
203257{
204   /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_r, input_port_1_r, 0, 0, 0, 0,
258   /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_device_r, input_port_1_device_r, 0, 0, 0, 0,
205259   /*outputs: A/B,CA/B2       */ 0, 0, 0, 0,
206260   /*irqs   : A/B             */ williams_main_firq, mysticm_main_irq
207261};
r4135r4136
209263/* Mystic Marathon PIA 1 */
210264const pia6821_interface mysticm_pia_1_intf =
211265{
212   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0,
266   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0,
213267   /*outputs: A/B,CA/B2       */ 0, williams2_snd_cmd_w, 0, pia_2_ca1_w,
214268   /*irqs   : A/B             */ mysticm_main_irq, mysticm_main_irq
215269};
r4135r4136
217271/* Turkey Shoot PIA 0 */
218272const pia6821_interface tshoot_pia_0_intf =
219273{
220   /*inputs : A/B,CA/B1,CA/B2 */ tshoot_input_port_0_3_r, input_port_1_r, 0, 0, 0, 0,
274   /*inputs : A/B,CA/B1,CA/B2 */ tshoot_input_port_0_3_r, input_port_1_device_r, 0, 0, 0, 0,
221275   /*outputs: A/B,CA/B2       */ 0, tshoot_lamp_w, williams_port_select_w, 0,
222276   /*irqs   : A/B             */ tshoot_main_irq, tshoot_main_irq
223277};
r4135r4136
225279/* Turkey Shoot PIA 1 */
226280const pia6821_interface tshoot_pia_1_intf =
227281{
228   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0,
282   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0,
229283   /*outputs: A/B,CA/B2       */ 0, williams2_snd_cmd_w, 0, pia_2_ca1_w,
230284   /*irqs   : A/B             */ tshoot_main_irq, tshoot_main_irq
231285};
r4135r4136
234288const pia6821_interface tshoot_snd_pia_intf =
235289{
236290   /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
237   /*outputs: A/B,CA/B2       */ pia_1_portb_w, dac_0_data_w, pia_1_cb1_w, tshoot_maxvol_w,
291   /*outputs: A/B,CA/B2       */ pia_1_portb_w, williams_dac_data_w, pia_1_cb1_w, tshoot_maxvol_w,
238292   /*irqs   : A/B             */ williams_snd_irq, williams_snd_irq
239293};
240294
241295/* Joust 2 PIA 1 */
242296const pia6821_interface joust2_pia_1_intf =
243297{
244   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_r, 0, 0, 0, 0, 0,
298   /*inputs : A/B,CA/B1,CA/B2 */ input_port_2_device_r, 0, 0, 0, 0, 0,
245299   /*outputs: A/B,CA/B2       */ 0, joust2_snd_cmd_w, joust2_pia_3_cb1_w, pia_2_ca1_w,
246300   /*irqs   : A/B             */ williams_main_irq, williams_main_irq
247301};
248302
303/* Joust 2 PIA 3 */
304const pia6821_interface joust2_pia_3_intf =
305{
306   0,
307};
249308
250309
251310/*************************************
r4135r4136
256315
257316static TIMER_CALLBACK( williams_va11_callback )
258317{
259   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
318   const device_config *pia_1 = devtag_get_device(machine, PIA6821, "pia_1");
260319   int scanline = param;
261320
262321   /* the IRQ signal comes into CB1, and is set to VA11 */
263   pia_1_cb1_w(space, 0, scanline & 0x20);
322   pia_cb1_w(pia_1, 0, scanline & 0x20);
264323
265324   /* set a timer for the next update */
266325   scanline += 0x20;
r4135r4136
271330
272331static TIMER_CALLBACK( williams_count240_off_callback )
273332{
274   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
333   const device_config *pia_1 = devtag_get_device(machine, PIA6821, "pia_1");
275334
276335   /* the COUNT240 signal comes into CA1, and is set to the logical AND of VA10-VA13 */
277   pia_1_ca1_w(space, 0, 0);
336   pia_ca1_w(pia_1, 0, 0);
278337}
279338
280339
281340static TIMER_CALLBACK( williams_count240_callback )
282341{
283   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
342   const device_config *pia_1 = devtag_get_device(machine, PIA6821, "pia_1");
284343
285344   /* the COUNT240 signal comes into CA1, and is set to the logical AND of VA10-VA13 */
286   pia_1_ca1_w(space, 0, 1);
345   pia_ca1_w(pia_1, 0, 1);
287346
288347   /* set a timer to turn it off once the scanline counter resets */
289348   timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, williams_count240_off_callback);
r4135r4136
293352}
294353
295354
296static void williams_main_irq(running_machine *machine, int state)
355static void williams_main_irq(const device_config *device, int state)
297356{
298   int combined_state = pia_get_irq_a(1) | pia_get_irq_b(1);
357   const device_config *pia_1 = devtag_get_device(device->machine, PIA6821, "pia_1");
358   int combined_state = pianew_get_irq_a(pia_1) | pianew_get_irq_b(pia_1);
299359
300360   /* IRQ to the main CPU */
301   cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
361   cpu_set_input_line(device->machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
302362}
303363
304364
305static void williams_main_firq(running_machine *machine, int state)
365static void williams_main_firq(const device_config *device, int state)
306366{
307367   /* FIRQ to the main CPU */
308   cpu_set_input_line(machine->cpu[0], M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
368   cpu_set_input_line(device->machine->cpu[0], M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
309369}
310370
311371
312static void williams_snd_irq(running_machine *machine, int state)
372static void williams_snd_irq(const device_config *device, int state)
313373{
314   int combined_state = pia_get_irq_a(2) | pia_get_irq_b(2);
374   const device_config *pia_2 = devtag_get_device(device->machine, PIA6821, "pia_2");
375   int combined_state = pianew_get_irq_a(pia_2) | pianew_get_irq_b(pia_2);
315376
316377   /* IRQ to the sound CPU */
317   cpu_set_input_line(machine->cpu[1], M6800_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
378   cpu_set_input_line(device->machine->cpu[1], M6800_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
318379}
319380
320381
r4135r4136
325386 *
326387 *************************************/
327388
328static void mysticm_main_irq(running_machine *machine, int state)
389static void mysticm_main_irq(const device_config *device, int state)
329390{
330   int combined_state = pia_get_irq_b(0) | pia_get_irq_a(1) | pia_get_irq_b(1);
391   const device_config *pia_0 = devtag_get_device(device->machine, PIA6821, "pia_0");
392   const device_config *pia_1 = devtag_get_device(device->machine, PIA6821, "pia_1");
393   int combined_state = pianew_get_irq_b(pia_0) | pianew_get_irq_a(pia_1) | pianew_get_irq_b(pia_1);
331394
332395   /* IRQ to the main CPU */
333   cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
396   cpu_set_input_line(device->machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
334397}
335398
336399
337static void tshoot_main_irq(running_machine *machine, int state)
400static void tshoot_main_irq(const device_config *device, int state)
338401{
339   int combined_state = pia_get_irq_a(0) | pia_get_irq_b(0) | pia_get_irq_a(1) | pia_get_irq_b(1);
402   const device_config *pia_0 = devtag_get_device(device->machine, PIA6821, "pia_0");
403   const device_config *pia_1 = devtag_get_device(device->machine, PIA6821, "pia_1");
404   int combined_state = pianew_get_irq_a(pia_0) | pianew_get_irq_b(pia_0) | pianew_get_irq_a(pia_1) | pianew_get_irq_b(pia_1);
340405
341406   /* IRQ to the main CPU */
342   cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
407   cpu_set_input_line(device->machine->cpu[0], M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
343408}
344409
345410
r4135r4136
352417
353418static MACHINE_RESET( williams_common )
354419{
355   /* reset the PIAs */
356   pia_reset();
357
358420   /* reset the ticket dispenser (Lotto Fun) */
359421   ticket_dispenser_init(machine, 70, TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_HIGH);
360422
r4135r4136
389451
390452static TIMER_CALLBACK( williams2_va11_callback )
391453{
392   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
454   const device_config *pia_0 = devtag_get_device(machine, PIA6821, "pia_0");
455   const device_config *pia_1 = devtag_get_device(machine, PIA6821, "pia_1");
393456   int scanline = param;
394457
395458   /* the IRQ signal comes into CB1, and is set to VA11 */
396   pia_0_cb1_w(space, 0, scanline & 0x20);
397   pia_1_ca1_w(space, 0, scanline & 0x20);
459   pia_cb1_w(pia_0, 0, scanline & 0x20);
460   pia_ca1_w(pia_1, 0, scanline & 0x20);
398461
399462   /* set a timer for the next update */
400463   scanline += 0x20;
r4135r4136
405468
406469static TIMER_CALLBACK( williams2_endscreen_off_callback )
407470{
408   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
471   const device_config *pia_0 = devtag_get_device(machine, PIA6821, "pia_0");
409472
410473   /* the /ENDSCREEN signal comes into CA1 */
411   pia_0_ca1_w(space, 0, 1);
474   pia_ca1_w(pia_0, 0, 1);
412475}
413476
414477
415478static TIMER_CALLBACK( williams2_endscreen_callback )
416479{
417   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
480   const device_config *pia_0 = devtag_get_device(machine, PIA6821, "pia_0");
418481
419482   /* the /ENDSCREEN signal comes into CA1 */
420   pia_0_ca1_w(space, 0, 0);
483   pia_ca1_w(pia_0, 0, 0);
421484
422485   /* set a timer to turn it off once the scanline counter resets */
423486   timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 8, 0), NULL, 0, williams2_endscreen_off_callback);
r4135r4136
445508{
446509   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
447510
448   /* reset the PIAs */
449   pia_reset();
450
451511   /* configure memory banks */
452512   memory_configure_bank(machine, 1, 0, 1, williams_videoram, 0);
453513   memory_configure_bank(machine, 1, 1, 4, memory_region(machine, "main") + 0x10000, 0x10000);
r4135r4136
529589
530590static TIMER_CALLBACK( williams_deferred_snd_cmd_w )
531591{
532   const address_space *space = ptr;
533   pia_2_portb_w(space, 0, param);
534   pia_2_cb1_w(space, 0, (param == 0xff) ? 0 : 1);
592   const device_config *pia_2 = devtag_get_device(machine, PIA6821, "pia_2");
593
594   pia_portb_w(pia_2, 0, param);
595   pia_cb1_w(pia_2, 0, (param == 0xff) ? 0 : 1);
535596}
536597
537WRITE8_HANDLER( williams_snd_cmd_w )
598WRITE8_DEVICE_HANDLER( williams_snd_cmd_w )
538599{
539600   /* the high two bits are set externally, and should be 1 */
540   timer_call_after_resynch(space->machine, (void *)space, data | 0xc0, williams_deferred_snd_cmd_w);
601   timer_call_after_resynch(device->machine, NULL, data | 0xc0, williams_deferred_snd_cmd_w);
541602}
542603
543WRITE8_HANDLER( playball_snd_cmd_w )
604WRITE8_DEVICE_HANDLER( playball_snd_cmd_w )
544605{
545   timer_call_after_resynch(space->machine, (void *)space, data, williams_deferred_snd_cmd_w);
606   timer_call_after_resynch(device->machine, NULL, data, williams_deferred_snd_cmd_w);
546607}
547608
548609
549610static TIMER_CALLBACK( williams2_deferred_snd_cmd_w )
550611{
551   const address_space *space = ptr;
552   pia_2_porta_w(space, 0, param);
612   const device_config *pia_2 = devtag_get_device(machine, PIA6821, "pia_2");
613
614   pia_porta_w(pia_2, 0, param);
553615}
554616
555static WRITE8_HANDLER( williams2_snd_cmd_w )
617static WRITE8_DEVICE_HANDLER( williams2_snd_cmd_w )
556618{
557   timer_call_after_resynch(space->machine, (void *)space, data, williams2_deferred_snd_cmd_w);
619   timer_call_after_resynch(device->machine, NULL, data, williams2_deferred_snd_cmd_w);
558620}
559621
560622
r4135r4136
565627 *
566628 *************************************/
567629
568WRITE8_HANDLER( williams_port_select_w )
630WRITE8_DEVICE_HANDLER( williams_port_select_w )
569631{
570632   port_select = data;
571633}
r4135r4136
605667 *      1000 = right/down full
606668 */
607669
608READ8_HANDLER( williams_49way_port_0_r )
670READ8_DEVICE_HANDLER( williams_49way_port_0_r )
609671{
610672   static const UINT8 translate49[7] = { 0x0, 0x4, 0x6, 0x7, 0xb, 0x9, 0x8 };
611   return (translate49[input_port_read(space->machine, "49WAYX") >> 4] << 4) | translate49[input_port_read(space->machine, "49WAYY") >> 4];
673   return (translate49[input_port_read(device->machine, "49WAYX") >> 4] << 4) | translate49[input_port_read(device->machine, "49WAYY") >> 4];
612674}
613675
614676
615READ8_HANDLER( williams_input_port_49way_0_5_r )
677READ8_DEVICE_HANDLER( williams_input_port_49way_0_5_r )
616678{
617679   if (port_select)
618      return williams_49way_port_0_r(space,0);
680      return williams_49way_port_0_r(device, 0);
619681   else
620      return input_port_read(space->machine, "IN3");
682      return input_port_read(device->machine, "IN3");
621683}
622684
623685
r4135r4136
866928 *
867929 *************************************/
868930
869static READ8_HANDLER( lottofun_input_port_0_r )
931static READ8_DEVICE_HANDLER( lottofun_input_port_0_r )
870932{
933   const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
934
871935   /* merge in the ticket dispenser status */
872   return input_port_read(space->machine, "IN0") | ticket_dispenser_r(space,offset);
936   return input_port_read(device->machine, "IN0") | ticket_dispenser_r(space,offset);
873937}
874938
875939
r4135r4136
880944 *
881945 *************************************/
882946
883static READ8_HANDLER( tshoot_input_port_0_3_r )
947static READ8_DEVICE_HANDLER( tshoot_input_port_0_3_r )
884948{
885949   /* merge in the gun inputs with the standard data */
886   int data = input_port_read(space->machine, "IN0");
950   int data = input_port_read(device->machine, "IN0");
887951   int gun = (data & 0x3f) ^ ((data & 0x3f) >> 1);
888952   return (data & 0xc0) | gun;
889953
954   // FIXME: this code is never reached
890955   return 0;
891956}
892957
893958
894static WRITE8_HANDLER( tshoot_maxvol_w )
959static WRITE8_DEVICE_HANDLER( tshoot_maxvol_w )
895960{
896961   /* something to do with the sound volume */
897   logerror("tshoot maxvol = %d (pc:%x)\n", data, cpu_get_pc(space->cpu));
962   logerror("tshoot maxvol = %d (%s)\n", data, cpuexec_describe_context(device->machine));
898963}
899964
900965
901static WRITE8_HANDLER( tshoot_lamp_w )
966static WRITE8_DEVICE_HANDLER( tshoot_lamp_w )
902967{
903968   /* set the grenade lamp */
904969   set_led_status(0,data & 0x04);
r4135r4136
9391004
9401005MACHINE_RESET( joust2 )
9411006{
1007   const device_config *pia_3 = devtag_get_device(machine, PIA6821, "pia_3");
1008
9421009   /* standard init */
9431010   MACHINE_RESET_CALL(williams2);
944   pia_set_input_ca1(3, 1);
1011   pia_ca1_w(pia_3, 0, 1);
9451012   state_save_register_global(machine, joust2_current_sound_data);
9461013}
9471014
9481015
9491016static TIMER_CALLBACK( joust2_deferred_snd_cmd_w )
9501017{
951   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
952   pia_2_porta_w(space, 0, param & 0xff);
1018   const device_config *pia_2 = devtag_get_device(machine, PIA6821, "pia_2");
1019   pia_porta_w(pia_2, 0, param & 0xff);
9531020}
9541021
9551022
956static WRITE8_HANDLER( joust2_pia_3_cb1_w )
1023static WRITE8_DEVICE_HANDLER( joust2_pia_3_cb1_w )
9571024{
1025   const device_config *pia_3 = devtag_get_device(device->machine, PIA6821, "pia_3");
1026
9581027   joust2_current_sound_data = (joust2_current_sound_data & ~0x100) | ((data << 8) & 0x100);
959   pia_3_cb1_w(space, offset, data);
1028   pia_cb1_w(pia_3, offset, data);
9601029}
9611030
9621031
963static WRITE8_HANDLER( joust2_snd_cmd_w )
1032static WRITE8_DEVICE_HANDLER( joust2_snd_cmd_w )
9641033{
9651034   joust2_current_sound_data = (joust2_current_sound_data & ~0xff) | (data & 0xff);
966   williams_cvsd_data_w(space->machine, joust2_current_sound_data);
967   timer_call_after_resynch(space->machine, NULL, joust2_current_sound_data, joust2_deferred_snd_cmd_w);
1035   williams_cvsd_data_w(device->machine, joust2_current_sound_data);
1036   timer_call_after_resynch(device->machine, NULL, joust2_current_sound_data, joust2_deferred_snd_cmd_w);
9681037}
src/mame/machine/nb1413m3.c
r4135r4136
432432      case NB1413M3_PAIRSNB:
433433      case NB1413M3_PAIRSTEN:
434434         return input_port_read(space->machine, "P1");
435         break;
436435      default:
437436         switch ((nb1413m3_inputport ^ 0xff) & 0x1f)
438437         {
r4135r4136
482481      case NB1413M3_PAIRSNB:
483482      case NB1413M3_PAIRSTEN:
484483         return input_port_read(space->machine, "P2");
485         break;
486484      default:
487485         switch ((nb1413m3_inputport ^ 0xff) & 0x1f)
488486         {
r4135r4136
516514      case NB1413M3_FINALBNY:
517515      case NB1413M3_MMSIKAKU:
518516         return ((nb1413m3_outcoin_flag & 0x01) << 1);
519         break;
520517      default:
521518         return 0xff;
522         break;
523519   }
524520}
525521
r4135r4136
530526      case NB1413M3_KANATUEN:
531527      case NB1413M3_KYUHITO:
532528         return input_port_read(space->machine, "DSWB");
533         break;
534529      case NB1413M3_TAIWANMB:
535530         return ((input_port_read(space->machine, "DSWA") & 0xf0) | ((input_port_read(space->machine, "DSWB") & 0xf0) >> 4));
536         break;
537531      case NB1413M3_OTONANO:
538532      case NB1413M3_MJCAMERA:
539533      case NB1413M3_IDHIMITU:
540534      case NB1413M3_KAGUYA2:
541535         return (((input_port_read(space->machine, "DSWA") & 0x0f) << 4) | (input_port_read(space->machine, "DSWB") & 0x0f));
542         break;
543536      case NB1413M3_SCANDAL:
544537      case NB1413M3_SCANDALM:
545538      case NB1413M3_MJFOCUSM:
r4135r4136
551544      case NB1413M3_TOKIMBSJ:
552545      case NB1413M3_TOKYOGAL:
553546         return ((input_port_read(space->machine, "DSWA") & 0x0f) | ((input_port_read(space->machine, "DSWB") & 0x0f) << 4));
554         break;
555547      case NB1413M3_TRIPLEW1:
556548      case NB1413M3_NTOPSTAR:
557549      case NB1413M3_PSTADIUM:
r4135r4136
565557                 ((input_port_read(space->machine, "DSWB") & 0x10) >> 2) | ((input_port_read(space->machine, "DSWB") & 0x40) >> 3) |
566558                 ((input_port_read(space->machine, "DSWA") & 0x01) << 4) | ((input_port_read(space->machine, "DSWA") & 0x04) << 3) |
567559                 ((input_port_read(space->machine, "DSWA") & 0x10) << 2) | ((input_port_read(space->machine, "DSWA") & 0x40) << 1));
568         break;
569560      default:
570561         return input_port_read(space->machine, "DSWA");
571         break;
572562   }
573563}
574564
r4135r4136
579569      case NB1413M3_KANATUEN:
580570      case NB1413M3_KYUHITO:
581571         return input_port_read(space->machine, "DSWA");
582         break;
583572      case NB1413M3_TAIWANMB:
584573         return (((input_port_read(space->machine, "DSWA") & 0x0f) << 4) | (input_port_read(space->machine, "DSWB") & 0x0f));
585         break;
586574      case NB1413M3_OTONANO:
587575      case NB1413M3_MJCAMERA:
588576      case NB1413M3_IDHIMITU:
589577      case NB1413M3_KAGUYA2:
590578         return ((input_port_read(space->machine, "DSWA") & 0xf0) | ((input_port_read(space->machine, "DSWB") & 0xf0) >> 4));
591         break;
592579      case NB1413M3_SCANDAL:
593580      case NB1413M3_SCANDALM:
594581      case NB1413M3_MJFOCUSM:
r4135r4136
600587      case NB1413M3_TOKIMBSJ:
601588      case NB1413M3_TOKYOGAL:
602589         return (((input_port_read(space->machine, "DSWA") & 0xf0) >> 4) | (input_port_read(space->machine, "DSWB") & 0xf0));
603         break;
604590      case NB1413M3_TRIPLEW1:
605591      case NB1413M3_NTOPSTAR:
606592      case NB1413M3_PSTADIUM:
r4135r4136
614600                 ((input_port_read(space->machine, "DSWB") & 0x20) >> 3) | ((input_port_read(space->machine, "DSWB") & 0x80) >> 4) |
615601                 ((input_port_read(space->machine, "DSWA") & 0x02) << 3) | ((input_port_read(space->machine, "DSWA") & 0x08) << 2) |
616602                 ((input_port_read(space->machine, "DSWA") & 0x20) << 1) | ((input_port_read(space->machine, "DSWA") & 0x80) << 0));
617         break;
618603      default:
619604         return input_port_read(space->machine, "DSWB");
620         break;
621605   }
622606}
623607
src/mame/machine/seicop.c
r4135r4136
11251125      default:
11261126         seibu_cop_log("%06x: COPX unhandled read returning %04x from offset %04x\n", cpu_get_pc(space->cpu), retvalue, offset*2);
11271127         return retvalue;
1128         break;
11291128
11301129      /* BCD protection reads */
11311130      case (0x190/2): { return ((prot_bcd[0] & 0x0000ffff) >> 0 ) + 0x3030; }
r4135r4136
12921291   {
12931292      default:
12941293         return generic_cop_r(space, offset, mem_mask);
1295         break;
12961294
12971295       /*********************************************************************
12981296        400-5ff -  Protection reads
r4135r4136
13191317      case (0x344/2):   return input_port_read(space->machine, "PLAYERS12");
13201318      case (0x348/2): return input_port_read(space->machine, "PLAYERS34");
13211319      case (0x34c/2): return input_port_read(space->machine, "SYSTEM");
1322
13231320   }
13241321}
13251322
r4135r4136
14121409   {
14131410      default:
14141411         return generic_cop_r(space, offset, mem_mask);
1415         break;
14161412
14171413      //case (0x07e/2):
14181414      //case (0x1b0/2):
r4135r4136
15651561   {
15661562      default:
15671563         return generic_cop_r(space, offset, mem_mask);
1568         break;
15691564
15701565      /* Non-protection reads */
15711566      case (0x308/2):   return seibu_main_word_r(space,2,0xffff);
r4135r4136
16151610   {
16161611      default:
16171612         return generic_cop_r(space, offset, mem_mask);
1618         break;
16191613
16201614      /* Non-protection reads */
16211615
r4135r4136
16751669   {
16761670      default:
16771671         return generic_cop_r(space, offset, mem_mask);
1678         break;
16791672
16801673      /*hit protection*/
16811674      case (0x180/2): { return xy_check; }
16821675
16831676      case (0x1b0/2):
16841677         return 2;
1678         // FIXME: this code is never reached
16851679         /*check if the DMA has been finished*/
16861680         if(dma_status == 1)
16871681         {
r4135r4136
18821876   {
18831877      default:
18841878         return generic_cop_r(space, offset, mem_mask);
1885         break;
18861879
18871880      /*********************************************************************
18881881        400-5ff -  Protection reads
r4135r4136
19841977   {
19851978      default:
19861979         return generic_cop_r(space, offset, mem_mask);
1987         break;
19881980
19891981      case (0x340/2): return input_port_read(space->machine, "DSWA") | (input_port_read(space->machine, "DSWB") << 8);
19901982      case (0x344/2): return input_port_read(space->machine, "P1") | (input_port_read(space->machine, "P2") << 8);
src/mame/machine/ajax.c
r4135r4136
197197   memory_set_bankptr(space->machine, 1,&RAM[bankaddress]);
198198}
199199
200MACHINE_START( ajax )
201{
202    state_save_register_global(machine, firq_enable);
203}
200204
201205MACHINE_RESET( ajax )
202206{
src/mame/mamedriv.c
r4135r4136
415415   /* Jangou Night   *//* (c) 1983 */
416416   DRIVER( jngolady )  /* (c) 1984 */
417417   DRIVER( cntrygrl )  /* (c) 1984 Royal Denshi */
418   DRIVER( luckygrl )  /* (c) 1984 Wing? */
418419   DRIVER( nightgal )  /* (c) 1984 */
419420   DRIVER( ngtbunny )  /* (c) 1984 */
420421   DRIVER( royalngt )  /* (c) 1984 Royal Denshi */
r4135r4136
18571858   DRIVER( ashura )   /* C43 (c) 1990 Taito Corporation (Japan) */
18581859   DRIVER( ashurau )   /* C43 (c) 1990 Taito America Corporation (US) */
18591860   DRIVER( hitice )   /* C59 (c) 1990 Williams (US) */
1861   DRIVER( hiticej )   /* C59 (c) 1990 Midway/Taito Corporation (Japan) */
18601862   DRIVER( sbm )      /* C69 (c) 1990 Taito Corporation (Japan) */
18611863   DRIVER( selfeena )   /* ??? (c) 1991 East Technology */
18621864   DRIVER( silentd )   /* ??? (c) 1992 Taito Corporation Japan (World) */
r4135r4136
49644966   DRIVER( tbyahhoo )   /* GX424 (c) 1995 (Japan) */
49654967   DRIVER( tkmmpzdm )   /* GX515 (c) 1995 (Japan) */
49664968   DRIVER( salmndr2 )   /* GX521 (c) 1996 (Japan) */
4969   DRIVER( salmnd2a )   /* GX521 (c) 1996 (Asia) */
49674970   DRIVER( sexyparo )   /* GX533 (c) 1996 (Japan) */
49684971   DRIVER( daiskiss )   /* GX535 (c) 1996 (Japan) */
49694972   DRIVER( tokkae )   /* GX615 (c) 1996 (Japan) */
r4135r4136
74907493   DRIVER( slqz2 )      /* (c) 1998 */
74917494   DRIVER( sdmg2 )      /* (c) 1997 */
74927495
7496   DRIVER( igs_ncs )   /* (c) 2000 */
7497
74937498   DRIVER( bigd2 )      /* (c) 2000 */
74947499   DRIVER( sdwx )      /* (c) 2002 */
74957500   DRIVER( sddz )      /* (c) 200? */
r4135r4136
82128217   DRIVER( sidewndr )   /* (c) 1981? ACE */
82138218   DRIVER( spellbnd )   /* (c) 1981? ACE */
82148219   DRIVER( starspnr )   /* (c) 1982? ACE */
8220   DRIVER( acefruit )   /* (c) 1982? ACE */
82158221   DRIVER( attckufo )   /* (c) 1980 Ryoto Electric Co. */
82168222   DRIVER( fortecar )
82178223   DRIVER( jackpool )   /* (c) 1997 Electronic Projects */
r4135r4136
82218227   DRIVER( quizmstr )   /* (c) 1985 Coinmaster */
82228228   DRIVER( trailblz )   /* (c) 1987 Coinmaster */
82238229   DRIVER( supnudg2 )   /* (c) 1989 Coinmaster */
8230   DRIVER( pokeroul )    /* (c) 1990 Coinmaster */
82248231   DRIVER( fruit )     /* (c) 1987? Coinmaster? */
82258232   DRIVER( egghunt )   /* (c) 1995 Invi Image */
82268233   DRIVER( magic10 )   /* (c) 1995 A.W.P. Games */
r4135r4136
83668373   DRIVER( destryea )   /* (c) 1981 Cidelsa */
83678374   DRIVER( draco )      /* (c) 1981 Cidelsa */
83688375   DRIVER( rockduck )   /* (c) 1983 Datel SAS */
8369   DRIVER( tetriunk )
8370   DRIVER( smstrv )   /* (c) 1984 SMS MFG CORP */
8376   DRIVER( tetriskr )   /* (c) 1988? bootleg */
8377   DRIVER( trvhang )   /* (c) 1984 SMS MFG CORP */
8378   DRIVER( trvhanga )   /* (c) 1984 SMS MFG CORP */
8379   DRIVER( sureshot )   /* (c) 1985 SMS MFG CORP */
83718380   DRIVER( skylncr )   /* (c) 1995 Bordun International */
83728381   DRIVER( butrfly )   /* (c) 1995 Bordun International */
83738382   DRIVER( madzoo )   /* (c) 1995 Bordun International */
r4135r4136
84168425   DRIVER( pexp0112 )   /* (c) 1995 IGT - International Gaming Technology */
84178426   DRIVER( pexs0006 )   /* (c) 1997 IGT - International Gaming Technology */
84188427   DRIVER( pexmp006 )   /* (c) 1997 IGT - International Gaming Technology */
8428   DRIVER( pexmp017 )   /* (c) 1997 IGT - International Gaming Technology */
84198429   DRIVER( mirage )   /* (c) 1994 Mitchell */
84208430   DRIVER( dominob )   /* (c) 1990 Wonwoo Systems */
84218431   DRIVER( jongkyo )   /* (c) 1985 Kiwako */
r4135r4136
84268436   DRIVER( blazlaz )   /* (c) 1989 Hudson Soft */
84278437   DRIVER( paranoia )   /* (c) 1990 Naxat Soft */
84288438   DRIVER( vcombat )   /* (c) 1993 VR8 Inc. */
8429   DRIVER( shadfgtr )   /* (c) 1989 Sega? */
8439   DRIVER( shadfgtr )   /* (c) 1989 DUTECH Inc. */
84308440   DRIVER( blackt96 )   /* (c) 1996 D.G.R.M. of Korea */
84318441   DRIVER( magictg )   /* (c) 199? Acclaim */
84328442   DRIVER( magictga )   /* (c) 199? Acclaim */
r4135r4136
84738483   DRIVER( brasil )    /* (c) 2000 unknown */
84748484   DRIVER( fashion )   /* (c) 2000 unknown */
84758485
8486   /* V30-based italian gambling games */
8487    DRIVER( tour4000 )   /* (c) 2000 High Video */
8488    DRIVER( cfever40 )   /* (c) 2000 High Video */
8489    DRIVER( cfever50 )   /* (c) 2000 High Video */
8490    DRIVER( tour4010 )   /* (c) 2000 High Video */
8491    DRIVER( cfever51 )   /* (c) 2000 High Video */
8492    DRIVER( cfever61 )   /* (c) 2000 High Video */
8493    DRIVER( cfever1k )   /* (c) 2000 High Video */
8494    DRIVER( girotutt )   /* (c) 2000 High Video */
8495
84768496   /* M68k based italian gambling games */
84778497   DRIVER( ilpag )     /* (c) 19?? unknown */
84788498   DRIVER( mil4000 )   /* (c) 2000 Sure Milano */
r4135r4136
84878507   DRIVER( showhanc )   /* (c) 1999? Astro Corp. */
84888508
84898509   /* Dyna */
8490   DRIVER( cb2001 )   /* (c) Dyna */
8491   DRIVER( ncb3 )      /* (c) 199? Dyna/bootleg? */
8492   DRIVER( cb3a )      /* (c) 199? Dyna/bootleg? */
8493   DRIVER( cb3 )      /* (c) 199? Dyna/bootleg? */
8510   DRIVER( cb2001 )   /* (c) 2001 Dyna Electronics */
8511   DRIVER( ncb3 )      /* (c) 199? Dyna Electronics */
8512   DRIVER( cb3a )      /* (c) 199? Dyna Electronics */
8513   DRIVER( cb3 )      /* (c) 199? Dyna Electronics */
84948514   DRIVER( cmv801 )   /* (c) 198? Corsica */
8495   DRIVER( cmv4 )      /* (c) 1992 Dyna */
8496   DRIVER( cmaster )   /* (c) 1991 Dyna */
8497   DRIVER( cm2v841 )   /* (c) 198? Dyna Electronics */
8498   DRIVER( cm2841a )   /* (c) 198? Dyna Electronics */
8499   DRIVER( cmast91 )   /* (c) 1991 Dyna */
8515   DRIVER( cmv4 )      /* (c) 1992 Dyna Electronics */
8516   DRIVER( cmv4a )      /* (c) 1992 Dyna Electronics */
8517   DRIVER( cmaster )   /* (c) 1991 Dyna Electronics */
8518   DRIVER( cmasterb )   /* (c) 1991 Dyna Electronics */
8519   DRIVER( cmasterc )   /* (c) 1991 Dyna Electronics */
8520   DRIVER( cmast91 )   /* (c) 1991 Dyna Electronics */
85008521
85018522   /* STG? */
85028523   DRIVER ( queen )
85038524
85048525   /* Aristocrat */
8505   DRIVER ( caswin )
8526   DRIVER ( 86lions )   /* (c) 1985? */
8527   DRIVER ( caswin )   /* (c) 1985 */
85068528
85078529   /* Eagle */
85088530   DRIVER ( janshi )
r4135r4136
85158537   DRIVER( lucky8a )   /* (c) 1989 Wing Co. Ltd */
85168538   DRIVER( luckgrln )   /* (c) 1991 Wing Co. Ltd */
85178539
8540   DRIVER( schery98 )   /* (c) 1998 Amcoe */
8541   DRIVER( schery97 )   /* (c) 1998 Amcoe */
8542   DRIVER( sfbonus )   /* (c) 199? Amcoe */
8543   DRIVER( ladylinr )   /* (c) 198? TAB Austria */
8544   DRIVER( kkojnoli )   /* 198? south korean hack */
8545   DRIVER( mtonic )   /* 198? (c) Tonic */
8546
8547   DRIVER( 3super8 )   /* unknown */
8548   DRIVER( buster )   /* (c) 1987 Marian Electronics Ltd. */
8549   DRIVER( spielbud )   /* (c) 1985 ADP */
8550
85188551#endif   /* DRIVER_RECURSIVE */
src/mame/includes/stv.h
r4135r4136
8181extern UINT32* stv_vdp2_vram;
8282extern UINT32* stv_vdp2_cram;
8383
84UINT8 stv_get_vblank(running_machine *machine);
85
8486WRITE32_HANDLER ( stv_vdp2_vram_w );
8587READ32_HANDLER ( stv_vdp2_vram_r );
8688
src/mame/includes/deco16ic.h
r4135r4136
4040void deco16_pdrawgfx(running_machine *machine,
4141      bitmap_t *dest,const gfx_element *gfx,
4242      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
43      const rectangle *clip,int transparency,int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri);
43      const rectangle *clip,int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri,UINT8 alpha);
4444
4545tilemap *deco16_get_tilemap(int pf, int size);
4646
src/mame/includes/suprnova.h
r4135r4136
99
1010/*----------- defined in video/suprnova.c -----------*/
1111
12extern int suprnova_alt_enable_sprites;
13
1214void skns_sprite_kludge(int x, int y);
1315void skns_draw_sprites(
14running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,
15UINT32* spriteram_source, size_t spriteram_size,
16UINT8* gfx_source, size_t gfx_length,
17UINT32* sprite_regs );
16   running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,
17   UINT32* spriteram_source, size_t spriteram_size,
18   UINT8* gfx_source, size_t gfx_length,
19   UINT32* sprite_regs );
1820
1921WRITE32_HANDLER ( skns_tilemapA_w );
2022WRITE32_HANDLER ( skns_tilemapB_w );
src/mame/includes/8080bw.h
r4135r4136
2121
2222/*----------- defined in audio/8080bw.c -----------*/
2323
24MACHINE_START( extra_8080bw_sh );
25
2426WRITE8_HANDLER( invadpt2_sh_port_1_w );
2527WRITE8_HANDLER( invadpt2_sh_port_2_w );
2628
r4135r4136
6870WRITE8_HANDLER( shuttlei_sh_port_1_w );
6971WRITE8_HANDLER( shuttlei_sh_port_2_w );
7072
71
7273/*----------- defined in video/8080bw.c -----------*/
7374
7475extern UINT8 *c8080bw_colorram;
7576
77MACHINE_START( extra_8080bw_vh );
78
7679void c8080bw_flip_screen_w(const address_space *space, int data);
7780void c8080bw_screen_red_w(int data);
7881void schaser_background_control_w(int data);
src/mame/includes/balsente.h
r4135r4136
2929
3030MACHINE_RESET( balsente );
3131
32void balsente_noise_gen(int chip, int count, short *buffer);
32void balsente_noise_gen(const device_config *device, int count, short *buffer);
3333
3434WRITE8_HANDLER( balsente_random_reset_w );
3535READ8_HANDLER( balsente_random_num_r );
src/mame/includes/esripsys.h
r4135r4136
66
77/* TODO */
88#define ESRIPSYS_PIXEL_CLOCK   (XTAL_25MHz / 2)
9#define ESRIPSYS_HTOTAL         (512 + 141)
9#define ESRIPSYS_HTOTAL         (512 + 141 + 2)
1010#define ESRIPSYS_HBLANK_START   (512)
1111#define ESRIPSYS_HBLANK_END      (0)
1212#define ESRIPSYS_VTOTAL         (384 + 20)
r4135r4136
2626
2727/*----------- defined in video/esripsys.c -----------*/
2828
29extern int esripsys_hblank;
2930extern UINT8 *esripsys_pal_ram;
3031extern int esripsys_frame_vbl;
3132extern int esripsys__12sel;
src/mame/includes/polyplay.h
r4135r4136
1414extern UINT8 *polyplay_characterram;
1515
1616PALETTE_INIT( polyplay );
17VIDEO_START( polyplay );
1718VIDEO_UPDATE( polyplay );
1819WRITE8_HANDLER( polyplay_characterram_w );
src/mame/includes/madalien.h
r4135r4136
2626
2727MACHINE_DRIVER_EXTERN( madalien_video );
2828
29WRITE8_HANDLER( madalien_videoram_w );
30WRITE8_HANDLER( madalien_charram_w );
2931
32
3033/*----------- defined in audio/madalien.c -----------*/
3134
3235DISCRETE_SOUND_EXTERN( madalien );
src/mame/includes/segas24.h
r4135r4136
1414void system24temp_sys16_io_set_callbacks(UINT8 (*io_r)(running_machine *machine, int port),
1515                     void  (*io_w)(running_machine *machine, int port, UINT8 data),
1616                     void  (*cnt_w)(const address_space *space, UINT8 data),
17                     READ16_HANDLER ((*iod_r)),
18                     WRITE16_HANDLER((*iod_w)));
17                     read16_space_func iod_r,
18                     write16_space_func iod_w);
1919READ16_HANDLER ( system24temp_sys16_io_r );
2020WRITE16_HANDLER( system24temp_sys16_io_w );
2121READ32_HANDLER ( system24temp_sys16_io_dword_r );
src/mame/includes/tiamc1.h
r4135r4136
1010
1111/*----------- defined in video/tiamc1.c -----------*/
1212
13extern UINT8 *tiamc1_charram;
14extern UINT8 *tiamc1_tileram;
15extern UINT8 *tiamc1_spriteram_x;
16extern UINT8 *tiamc1_spriteram_y;
17extern UINT8 *tiamc1_spriteram_n;
18extern UINT8 *tiamc1_spriteram_a;
19
2013PALETTE_INIT( tiamc1 );
2114VIDEO_START( tiamc1 );
2215VIDEO_UPDATE( tiamc1 );
src/mame/includes/tmnt.h
r4135r4136
77WRITE16_HANDLER( blswhstl_700300_w );
88READ16_HANDLER( glfgreat_rom_r );
99WRITE16_HANDLER( glfgreat_122000_w );
10WRITE16_HANDLER( ssriders_eeprom_w );
1011WRITE16_HANDLER( ssriders_1c0300_w );
1112WRITE16_HANDLER( prmrsocr_122000_w );
1213WRITE16_HANDLER( tmnt_priority_w );
src/mame/includes/snes.h
r4135r4136
553553/* All other writes should store the value in the addressed register as
554554   expected. */
555555
556/*========== PROCEDURES ==========*/
557
558void DSP_Reset                      /* Reset emulated DSP           */
559    ( void );
560
561void DSP_Update                     /* Mix one sample of audio      */
562    (
563    short *             sound_ptr   /* Pointer to mix audio into    */
564    );
565
566556/*----------- defined in video/snes.c -----------*/
567557
568558extern struct SNES_PPU_STRUCT snes_ppu;
src/mame/includes/megasys1.h
r4135r4136
88    This file contains definitions used across multiple megasys1
99    and non megasys1 Jaleco games:
1010
11    * Input ports
1211    * Scrolling layers handling
1312    * Code decryption handling
1413
r4135r4136
1716
1817/***************************************************************************
1918
20                                Input Ports
21
22***************************************************************************/
23
24
25#define COINS \
26   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 )\
27   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START2 )\
28   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN )\
29   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN )\
30   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )\
31   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_SERVICE1 )\
32   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_COIN1 )\
33   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN2 )\
34   PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
35
36#define JOY_4BUTTONS(_flag_) \
37   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_8WAY PORT_PLAYER(_flag_)\
38   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_8WAY PORT_PLAYER(_flag_)\
39   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_8WAY PORT_PLAYER(_flag_)\
40   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_8WAY PORT_PLAYER(_flag_)\
41   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(_flag_)\
42   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(_flag_)\
43   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(_flag_)\
44   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_PLAYER(_flag_)
45
46#define JOY_3BUTTONS(_flag_) \
47   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_8WAY PORT_PLAYER(_flag_)\
48   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_8WAY PORT_PLAYER(_flag_)\
49   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_8WAY PORT_PLAYER(_flag_)\
50   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_8WAY PORT_PLAYER(_flag_)\
51   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(_flag_)\
52   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(_flag_)\
53   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(_flag_)\
54   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN)
55
56#define JOY_2BUTTONS(_flag_) \
57   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_8WAY PORT_PLAYER(_flag_)\
58   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_8WAY PORT_PLAYER(_flag_)\
59   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_8WAY PORT_PLAYER(_flag_)\
60   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_8WAY PORT_PLAYER(_flag_)\
61   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(_flag_)\
62   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(_flag_)\
63   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN) \
64   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN)
65
66#define RESERVE \
67   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Reserve 1P */\
68   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )\
69   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )\
70   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )\
71   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Reserve 2P */\
72   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )\
73   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )\
74   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
75
76/* Coinage DSWs */
77//  1]  01-41 02-31 03-21 07-11 06-12 05-13 04-14 00-FC * 2
78//  2]  04-31 02-21 07-11 03-12 05-13 01-14 06-15 00-FC
79//      00-41 20-31 10-21 38-11 18-12 28-13 08-14 30-15
80
81
82#define COINAGE_6BITS \
83   PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coin_A ) )\
84   PORT_DIPSETTING(      0x0400, DEF_STR( 3C_1C ) )\
85   PORT_DIPSETTING(      0x0200, DEF_STR( 2C_1C ) )\
86   PORT_DIPSETTING(      0x0700, DEF_STR( 1C_1C ) )\
87   PORT_DIPSETTING(      0x0300, DEF_STR( 1C_2C ) )\
88   PORT_DIPSETTING(      0x0500, DEF_STR( 1C_3C ) )\
89   PORT_DIPSETTING(      0x0100, DEF_STR( 1C_4C ) )\
90   PORT_DIPSETTING(      0x0600, DEF_STR( 1C_5C ) )\
91   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )\
92   PORT_DIPNAME( 0x3800, 0x3800, DEF_STR( Coin_B ) )\
93   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )\
94   PORT_DIPSETTING(      0x2000, DEF_STR( 3C_1C ) )\
95   PORT_DIPSETTING(      0x1000, DEF_STR( 2C_1C ) )\
96   PORT_DIPSETTING(      0x3800, DEF_STR( 1C_1C ) )\
97   PORT_DIPSETTING(      0x1800, DEF_STR( 1C_2C ) )\
98   PORT_DIPSETTING(      0x2800, DEF_STR( 1C_3C ) )\
99   PORT_DIPSETTING(      0x0800, DEF_STR( 1C_4C ) )\
100   PORT_DIPSETTING(      0x3000, DEF_STR( 1C_5C ) )\
101
102#define COINAGE_6BITS_2 \
103   PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coin_A ) )\
104   PORT_DIPSETTING(      0x0100, DEF_STR( 4C_1C ) )\
105   PORT_DIPSETTING(      0x0200, DEF_STR( 3C_1C ) )\
106   PORT_DIPSETTING(      0x0300, DEF_STR( 2C_1C ) )\
107   PORT_DIPSETTING(      0x0700, DEF_STR( 1C_1C ) )\
108   PORT_DIPSETTING(      0x0600, DEF_STR( 1C_2C ) )\
109   PORT_DIPSETTING(      0x0500, DEF_STR( 1C_3C ) )\
110   PORT_DIPSETTING(      0x0400, DEF_STR( 1C_4C ) )\
111   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )\
112   PORT_DIPNAME( 0x3800, 0x3800, DEF_STR( Coin_B ) )\
113   PORT_DIPSETTING(      0x0800, DEF_STR( 4C_1C ) )\
114   PORT_DIPSETTING(      0x1000, DEF_STR( 3C_1C ) )\
115   PORT_DIPSETTING(      0x1800, DEF_STR( 2C_1C ) )\
116   PORT_DIPSETTING(      0x3800, DEF_STR( 1C_1C ) )\
117   PORT_DIPSETTING(      0x3000, DEF_STR( 1C_2C ) )\
118   PORT_DIPSETTING(      0x2800, DEF_STR( 1C_3C ) )\
119   PORT_DIPSETTING(      0x2000, DEF_STR( 1C_4C ) )\
120   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )\
121
122#define COINAGE_8BITS \
123   PORT_DIPNAME( 0x000f, 0x000f, DEF_STR( Coin_A ) )\
124   PORT_DIPSETTING(      0x0007, DEF_STR( 4C_1C ) )\
125   PORT_DIPSETTING(      0x0008, DEF_STR( 3C_1C ) )\
126   PORT_DIPSETTING(      0x0009, DEF_STR( 2C_1C ) )\
127   PORT_DIPSETTING(      0x000f, DEF_STR( 1C_1C ) )\
128/*  PORT_DIPSETTING(      0x0005, DEF_STR( 1C_1C ) )*/\
129/*  PORT_DIPSETTING(      0x0004, DEF_STR( 1C_1C ) )*/\
130/*  PORT_DIPSETTING(      0x0003, DEF_STR( 1C_1C ) )*/\
131/*  PORT_DIPSETTING(      0x0002, DEF_STR( 1C_1C ) )*/\
132/*  PORT_DIPSETTING(      0x0001, DEF_STR( 1C_1C ) )*/\
133   PORT_DIPSETTING(      0x0006, DEF_STR( 2C_3C ) )\
134   PORT_DIPSETTING(      0x000e, DEF_STR( 1C_2C ) )\
135   PORT_DIPSETTING(      0x000d, DEF_STR( 1C_3C ) )\
136   PORT_DIPSETTING(      0x000c, DEF_STR( 1C_4C ) )\
137   PORT_DIPSETTING(      0x000b, DEF_STR( 1C_5C ) )\
138   PORT_DIPSETTING(      0x000a, DEF_STR( 1C_6C ) )\
139   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )\
140   PORT_DIPNAME( 0x00f0, 0x00f0, DEF_STR( Coin_B ) )\
141   PORT_DIPSETTING(      0x0070, DEF_STR( 4C_1C ) )\
142   PORT_DIPSETTING(      0x0080, DEF_STR( 3C_1C ) )\
143   PORT_DIPSETTING(      0x0090, DEF_STR( 2C_1C ) )\
144   PORT_DIPSETTING(      0x00f0, DEF_STR( 1C_1C ) )\
145/*  PORT_DIPSETTING(      0x0050, DEF_STR( 1C_1C ) )*/\
146/*  PORT_DIPSETTING(      0x0040, DEF_STR( 1C_1C ) )*/\
147/*  PORT_DIPSETTING(      0x0030, DEF_STR( 1C_1C ) )*/\
148/*  PORT_DIPSETTING(      0x0020, DEF_STR( 1C_1C ) )*/\
149/*  PORT_DIPSETTING(      0x0010, DEF_STR( 1C_1C ) )*/\
150   PORT_DIPSETTING(      0x0060, DEF_STR( 2C_3C ) )\
151   PORT_DIPSETTING(      0x00e0, DEF_STR( 1C_2C ) )\
152   PORT_DIPSETTING(      0x00d0, DEF_STR( 1C_3C ) )\
153   PORT_DIPSETTING(      0x00c0, DEF_STR( 1C_4C ) )\
154   PORT_DIPSETTING(      0x00b0, DEF_STR( 1C_5C ) )\
155   PORT_DIPSETTING(      0x00a0, DEF_STR( 1C_6C ) )\
156   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
157
158
159/***************************************************************************
160
16119                            Scrolling Layers Handling
16220
16321***************************************************************************/
src/mame/includes/williams.h
r4135r4136
55**************************************************************************/
66
77
8#include "machine/6821pia.h"
8#include "machine/6821new.h"
99
1010/*----------- defined in drivers/williams.c -----------*/
1111
r4135r4136
4040extern const pia6821_interface tshoot_pia_1_intf;
4141extern const pia6821_interface tshoot_snd_pia_intf;
4242extern const pia6821_interface joust2_pia_1_intf;
43extern const pia6821_interface joust2_pia_3_intf;
4344
4445/* initialization */
4546MACHINE_RESET( defender );
src/mame/includes/wrally.h
r4135r4136
11/*----------- defined in machine/wrally.c -----------*/
22
3DRIVER_INIT( wrally );
4MACHINE_RESET( wrally );
5
63WRITE16_HANDLER( wrally_vram_w );
74WRITE16_HANDLER( wrally_flipscreen_w );
85WRITE16_HANDLER( OKIM6295_bankswitch_w );
src/mame/includes/ajax.h
r4135r4136
33WRITE8_HANDLER( ajax_bankswitch_2_w );
44READ8_HANDLER( ajax_ls138_f10_r );
55WRITE8_HANDLER( ajax_ls138_f10_w );
6MACHINE_START( ajax );
67MACHINE_RESET( ajax );
78INTERRUPT_GEN( ajax_interrupt );
89
src/mame/mame.mak
r4135r4136
178178CPUS += ALPHA8201
179179CPUS += ALPHA8301
180180CPUS += CDP1802
181CPUS += COP401
182CPUS += COP410
183CPUS += COP411
184CPUS += COP402
185CPUS += COP420
186CPUS += COP421
187CPUS += COP422
188CPUS += COP404
189CPUS += COP424
190CPUS += COP425
191CPUS += COP426
192CPUS += COP444
193CPUS += COP445
181CPUS += COP400
194182CPUS += TLCS90
195183CPUS += MB8841
196184CPUS += MB8842
r4135r4136
274262SOUNDS += MSM5232
275263SOUNDS += OKIM6258
276264SOUNDS += OKIM6295
265SOUNDS += OKIM6376
277266SOUNDS += UPD7759
278267SOUNDS += HC55516
279268SOUNDS += K005289
r4135r4136
314303#SOUNDS += SID6581
315304#SOUNDS += SID8580
316305SOUNDS += SP0256
306SOUNDS += DIGITALKER
317307
318308
319309#-------------------------------------------------
r4135r4136
328318   $(MAMEOBJ)/alliedl.a \
329319   $(MAMEOBJ)/alpha.a \
330320   $(MAMEOBJ)/amiga.a \
321   $(MAMEOBJ)/aristocr.a \
331322   $(MAMEOBJ)/atari.a \
332323   $(MAMEOBJ)/atlus.a \
333324   $(MAMEOBJ)/barcrest.a \
r4135r4136
461452   $(DRIVERS)/mquake.o \
462453   $(DRIVERS)/upscope.o \
463454
455$(MAMEOBJ)/aristocr.a: \
456   $(DRIVERS)/86lions.o \
457   $(DRIVERS)/caswin.o \
458
464459$(MAMEOBJ)/atari.a: \
465460    $(DRIVERS)/atarigx2.o $(VIDEO)/atarigx2.o \
466461   $(DRIVERS)/arcadecl.o $(VIDEO)/arcadecl.o \
r4135r4136
764759   $(DRIVERS)/igs017.o \
765760   $(DRIVERS)/igs_m027.o \
766761   $(DRIVERS)/igs_m68.o \
762   $(DRIVERS)/igs_ncs.o \
767763   $(DRIVERS)/iqblock.o $(VIDEO)/iqblock.o \
768764   $(DRIVERS)/lordgun.o $(VIDEO)/lordgun.o \
769765   $(DRIVERS)/pgm.o $(VIDEO)/pgm.o \
r4135r4136
15221518   $(DRIVERS)/39in1.o \
15231519   $(DRIVERS)/1945kiii.o \
15241520   $(DRIVERS)/2mindril.o \
1521   $(DRIVERS)/3super8.o \
15251522   $(DRIVERS)/4enraya.o $(VIDEO)/4enraya.o \
15261523   $(DRIVERS)/4roses.o \
15271524   $(DRIVERS)/acefruit.o \
r4135r4136
15361533   $(DRIVERS)/beaminv.o \
15371534   $(DRIVERS)/blackt96.o \
15381535   $(DRIVERS)/brasil.o \
1536   $(DRIVERS)/buster.o \
15391537   $(DRIVERS)/calomega.o $(VIDEO)/calomega.o \
15401538   $(DRIVERS)/carrera.o \
1541   $(DRIVERS)/caswin.o \
15421539   $(DRIVERS)/cave.o $(VIDEO)/cave.o \
15431540   $(DRIVERS)/cidelsa.o $(VIDEO)/cidelsa.o \
15441541   $(DRIVERS)/coinmstr.o \
r4135r4136
15641561   $(DRIVERS)/esh.o \
15651562   $(DRIVERS)/esripsys.o $(VIDEO)/esripsys.o \
15661563   $(DRIVERS)/ettrivia.o \
1567   $(DRIVERS)/filetto.o \
15681564   $(DRIVERS)/flower.o $(AUDIO)/flower.o $(VIDEO)/flower.o \
15691565   $(DRIVERS)/fortecar.o \
15701566   $(DRIVERS)/freekick.o $(VIDEO)/freekick.o \
r4135r4136
15811577   $(DRIVERS)/gumbo.o $(VIDEO)/gumbo.o \
15821578   $(DRIVERS)/gunpey.o \
15831579   $(DRIVERS)/hexa.o $(VIDEO)/hexa.o \
1580   $(DRIVERS)/highvdeo.o \
15841581   $(DRIVERS)/homedata.o $(VIDEO)/homedata.o \
15851582   $(DRIVERS)/hotblock.o \
15861583   $(DRIVERS)/ilpag.o \
r4135r4136
16271624   $(DRIVERS)/pangofun.o \
16281625   $(DRIVERS)/pasha2.o \
16291626   $(DRIVERS)/pass.o $(VIDEO)/pass.o \
1627   $(DRIVERS)/pcxt.o \
16301628   $(DRIVERS)/peplus.o \
16311629   $(DRIVERS)/pipeline.o \
16321630   $(DRIVERS)/pkscram.o \
r4135r4136
16441642   $(DRIVERS)/skylncr.o \
16451643   $(DRIVERS)/sliver.o \
16461644   $(DRIVERS)/slotcarn.o \
1647   $(DRIVERS)/smstrv.o \
1645   $(DRIVERS)/sms.o \
16481646   $(DRIVERS)/snookr10.o $(VIDEO)/snookr10.o \
16491647   $(DRIVERS)/spool99.o \
16501648   $(DRIVERS)/sprcros2.o $(VIDEO)/sprcros2.o \
r4135r4136
16571655   $(DRIVERS)/tattack.o \
16581656   $(DRIVERS)/taxidrvr.o $(VIDEO)/taxidrvr.o \
16591657   $(DRIVERS)/tcl.o \
1660   $(DRIVERS)/tetriunk.o \
16611658   $(DRIVERS)/thayers.o \
16621659   $(DRIVERS)/thedeep.o $(VIDEO)/thedeep.o \
16631660   $(DRIVERS)/tiamc1.o $(VIDEO)/tiamc1.o $(AUDIO)/tiamc1.o \
r4135r4136
16771674   $(DRIVERS)/xyonix.o $(VIDEO)/xyonix.o \
16781675   $(DRIVERS)/hikaru.o \
16791676   $(DRIVERS)/cb2001.o \
1677   $(DRIVERS)/sfbonus.o \
16801678
16811679#-------------------------------------------------
16821680# layout dependencies
src/mame/video/deco_mlc.c
r4135r4136
2020
2121VIDEO_START( mlc )
2222{
23   alpha_set_level(0x80);
24
2523   if (machine->gfx[0]->color_granularity==16)
2624      colour_mask=0x7f;
2725   else if (machine->gfx[0]->color_granularity==32)
r4135r4136
6563static void mlc_drawgfxzoom(running_machine *machine,
6664      bitmap_t *dest_bmp,const gfx_element *gfx,
6765      UINT32 code1,UINT32 code2, UINT32 color,int flipx,int flipy,int sx,int sy,
68      const rectangle *clip,int transparency,int transparent_color,int use8bpp,
69      int scalex, int scaley)
66      const rectangle *clip,int transparent_color,int use8bpp,
67      int scalex, int scaley,int alpha)
7068{
7169   rectangle myclip;
7270
r4135r4136
9997      if( gfx )
10098      {
10199         const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
102         int source_base1 = (code1 % gfx->total_elements) * gfx->height;
103         int source_base2 = (code2 % gfx->total_elements) * gfx->height;
100         const UINT8 *code_base1 = gfx_element_get_data(gfx, code1 % gfx->total_elements);
101         const UINT8 *code_base2 = gfx_element_get_data(gfx, code2 % gfx->total_elements);
104102
105103         int sprite_screen_height = (scaley*gfx->height+(sy&0xffff))>>16;
106104         int sprite_screen_width = (scalex*gfx->width+(sx&0xffff))>>16;
r4135r4136
172170               int y;
173171
174172               /* case 1: TRANSPARENCY_PEN */
175               if (transparency == TRANSPARENCY_PEN)
173               if (alpha == 0xff)
176174               {
177175                  {
178176                     for( y=sy; y<ey; y++ )
179177                     {
180                        UINT8 *source1 = gfx->gfxdata + (source_base1+(y_index>>16)) * gfx->line_modulo;
181                        UINT8 *source2 = gfx->gfxdata + (source_base2+(y_index>>16)) * gfx->line_modulo;
178                        const UINT8 *source1 = code_base1 + (y_index>>16) * gfx->line_modulo;
179                        const UINT8 *source2 = code_base2 + (y_index>>16) * gfx->line_modulo;
182180                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
183181
184182                        int x, x_index = x_index_base;
r4135r4136
199197                  }
200198               }
201199
202               /* case 6: TRANSPARENCY_ALPHA */
203               if (transparency == TRANSPARENCY_ALPHA)
200               /* case 6: alpha blended */
201               else
204202               {
205203                  {
206204                     for( y=sy; y<ey; y++ )
207205                     {
208                        UINT8 *source = gfx->gfxdata + (source_base1+(y_index>>16)) * gfx->line_modulo;
206                        const UINT8 *source = code_base1 + (y_index>>16) * gfx->line_modulo;
209207                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
210208
211209                        int x, x_index = x_index_base;
212210                        for( x=sx; x<ex; x++ )
213211                        {
214212                           int c = source[x_index>>16];
215                           if( c != transparent_color ) dest[x] = alpha_blend32(dest[x], 0); //pal[c]);
213                           if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], 0, alpha); //pal[c]);
216214                           x_index += dx;
217215                        }
218216
r4135r4136
237235   int sprite2=0,indx2=0,use8bppMode=0;
238236   int yscale,xscale;
239237   int ybase,yinc;
240   int trans;
238   int alpha;
241239   int useIndicesInRom=0;
242240   int hibits=0;
243241   int tileFormat=0;
r4135r4136
325323
326324      /* Any colours out of range (for the bpp value) trigger 'shadow' mode */
327325      if (color & (colour_mask+1))
328         trans=TRANSPARENCY_ALPHA;
326         alpha=0x80;
329327      else
330         trans=TRANSPARENCY_PEN;
328         alpha=0xff;
331329      color&=colour_mask;
332330
333331      /* If this bit is set, combine this block with the next one */
r4135r4136
491489                        /*rasterMode ? temp_bitmap : */bitmap,machine->gfx[0],
492490                        tile,tile2,
493491                        color + colorOffset,fx,fy,xbase,ybase,
494                        &user_clip,trans,0,
495                        use8bppMode,(xscale<<8),(yscale<<8));
492                        &user_clip,0,
493                        use8bppMode,(xscale<<8),(yscale<<8),alpha);
496494
497495            sprite++;
498496            sprite2++;
src/mame/video/tunhunt.c
r4135r4136
251251   }
252252   scalex = (1<<16);
253253
254   copyrozbitmap(
255      bitmap,tmpbitmap,
254   copyrozbitmap_trans(
255      bitmap,cliprect,tmpbitmap,
256256      -x0*scalex,/* startx */
257257      -y0*scaley,/* starty */
258258      scalex,/* incxx */
259259      0,0,/* incxy,incyx */
260260      scaley,/* incyy */
261261      0, /* no wraparound */
262      cliprect,
263      TRANSPARENCY_PEN,0,
264      0 /* priority */
262      0
265263   );
266264}
267265
src/mame/video/tryout.c
r4135r4136
140140      break;
141141   }
142142
143   decodechar(space->machine->gfx[2],(offset-0x400/64)&0x7f,tryout_vram_gfx);
144   tilemap_mark_all_tiles_dirty(bg_tilemap);
143   gfx_element_mark_dirty(space->machine->gfx[2], (offset-0x400/64)&0x7f);
145144}
146145
147146WRITE8_HANDLER( tryout_vram_bankswitch_w )
r4135r4136
179178   tryout_vram=auto_malloc(8 * 0x800);
180179   tryout_vram_gfx=auto_malloc(0x6000);
181180
181   gfx_element_set_source(machine->gfx[2], tryout_vram_gfx);
182
182183   tilemap_set_transparent_pen(fg_tilemap,0);
183184}
184185
src/mame/video/rungun.c
r4135r4136
9797   assert(ttl_gfx_index != MAX_GFX_ELEMENTS);
9898
9999   // decode the ttl layer's gfx
100   machine->gfx[ttl_gfx_index] = allocgfx(machine, &charlayout);
101   decodegfx(machine->gfx[ttl_gfx_index], memory_region(machine, "gfx3"), 0, machine->gfx[ttl_gfx_index]->total_elements);
100   machine->gfx[ttl_gfx_index] = gfx_element_alloc(machine, &charlayout, memory_region(machine, "gfx3"), machine->config->total_colors / 16, 0);
102101
103   machine->gfx[ttl_gfx_index]->total_colors = machine->config->total_colors / 16;
104
105102   // create the tilemap
106103   ttl_tilemap = tilemap_create(machine, ttl_get_tile_info, tilemap_scan_rows,  8, 8, 64, 32);
107104
src/mame/video/aerofgt.c
r4135r4136
9595
9696***************************************************************************/
9797
98static void aerofgt_register_state_globals(running_machine *machine)
99{
100    state_save_register_global_array(machine, gfxbank);
101    state_save_register_global(machine, bg1scrollx);
102    state_save_register_global(machine, bg1scrolly);
103    state_save_register_global(machine, bg2scrollx);
104    state_save_register_global(machine, bg2scrolly);
105    state_save_register_global(machine, charpalettebank);
106    state_save_register_global(machine, spritepalettebank);
107}
108
98109VIDEO_START( pspikes )
99110{
100111   bg1_tilemap = tilemap_create(machine, get_pspikes_tile_info,tilemap_scan_rows,8,8,64,32);
101112   /* no bg2 in this game */
102113
103114   sprite_gfx = 1;
115
116    aerofgt_register_state_globals(machine);
117    state_save_register_global(machine, spikes91_lookup);
104118}
105119
106120
r4135r4136
114128   spritepalettebank = 0;
115129
116130   sprite_gfx = 2;
131
132    aerofgt_register_state_globals(machine);
117133}
118134
119135VIDEO_START( spinlbrk )
r4135r4136
140156   aerofgt_spriteram1 = aerofgt_spriteram2 + aerofgt_spriteram2_size/2;
141157   aerofgt_spriteram1_size = 0x4000;
142158   for (i = 0;i < aerofgt_spriteram1_size/2;i++)
159    {
143160      aerofgt_spriteram1[i] = i;
161    }
162
163    aerofgt_register_state_globals(machine);
144164}
145165
146166VIDEO_START( turbofrc )
r4135r4136
153173   spritepalettebank = 0;
154174
155175   sprite_gfx = 2;
176
177    aerofgt_register_state_globals(machine);
156178}
157179
158180VIDEO_START( wbbc97 )
r4135r4136
163185   tilemap_set_transparent_pen(bg1_tilemap,15);
164186
165187   sprite_gfx = 1;
188
189    aerofgt_register_state_globals(machine);
190
191    state_save_register_global(machine, wbbc97_bitmap_enable);
166192}
167193
168194/***************************************************************************
src/mame/video/mainsnk.c
r4135r4136
66UINT8 *mainsnk_bgram;
77
88
9static UINT32 bg_tile_offset;
910
11
1012static TILEMAP_MAPPER( marvins_tx_scan_cols )
1113{
1214   // tilemap is 36x28, the central part is from the first RAM page and the
r4135r4136
3335
3436   SET_TILE_INFO(
3537         0,
36         code,
38         bg_tile_offset + code,
3739         0,
3840         0);
3941}
r4135r4136
6769   else if (space->machine->gfx[0]->total_elements == 0x800)   // canvas
6870      bank = ((data & 0x40) >> 6) | ((data & 0x30) >> 3);
6971
70   tilemap_set_pen_data_offset(bg_tilemap, (bank << 8) * space->machine->gfx[0]->char_modulo);
72   if (bg_tile_offset != (bank << 8))
73   {
74      bg_tile_offset = bank << 8;
75      tilemap_mark_all_tiles_dirty(bg_tilemap);
76   }
7177}
7278
7379WRITE8_HANDLER( mainsnk_fgram_w )
src/mame/video/ygv608.c
r4135r4136
882882  cos_theta = (double)ygv608.dx / (double)0x10000;
883883
884884  if( ygv608.regs.s.zron )
885    copyrozbitmap( bitmap, work_bitmap,
885    copyrozbitmap( bitmap, cliprect, work_bitmap,
886886                   ( visarea->min_x << 16 ) +
887887                    ygv608.ax + 0x10000 * r *
888888                    ( -sin( alpha ) * cos_theta + cos( alpha ) * sin_theta ),
889889                   ( visarea->min_y << 16 ) +
890890                    ygv608.ay + 0x10000 * r *
891891                    ( cos( alpha ) * cos_theta + sin( alpha ) * sin_theta ),
892                   ygv608.dx, ygv608.dxy, ygv608.dyx, ygv608.dy, 0,
893                   cliprect,
894                   TRANSPARENCY_NONE, 0, 0 );
892                   ygv608.dx, ygv608.dxy, ygv608.dyx, ygv608.dy, 0);
895893  else
896894#endif
897895    copybitmap( bitmap, work_bitmap, 0, 0, 0, 0, cliprect);
r4135r4136
909907
910908#ifdef _ENABLE_ROTATE_ZOOM
911909  if( ygv608.regs.s.zron )
912    copyrozbitmap( bitmap, work_bitmap,
910    copyrozbitmap_trans( bitmap, cliprect, work_bitmap,
913911                   ygv608.ax, // + ( visarea->min_x << 16 ),
914912                   ygv608.ay, // + ( visarea->min_y << 16 ),
915913                   ygv608.dx, ygv608.dxy, ygv608.dyx, ygv608.dy, 0,
916                   cliprect,
917                   TRANSPARENCY_PEN, 0, 0 );
914                   0 );
918915  else
919916#endif
920917    copybitmap_trans( bitmap, work_bitmap, 0, 0, 0, 0, cliprect, 0 );
r4135r4136
10461043         if (ygv608.regs.s.r2 & r2_saar)
10471044            ygv608.regs.s.saa++;
10481045         return (data << 8);
1049         break;
10501046
10511047      case 0x02: /* P#2 - scroll data port */
10521048         data = ygv608.scroll_data_table[(ygv608.regs.s.r2 & r2_b_a) >> 4][ygv608.regs.s.sca];
r4135r4136
10581054               ygv608.regs.s.r2 ^= r2_b_a;
10591055         }
10601056         return( data << 8 );
1061         break;
10621057
10631058      case 0x03: /* P#3 - color palette data port */
10641059         data = ygv608.colour_palette[ygv608.regs.s.cc][p3_state];
r4135r4136
10691064               ygv608.regs.s.cc++;
10701065         }
10711066         return( data << 8 );
1072         break;
10731067
10741068      case 0x04: /* P#4 - register data port */
10751069      {
src/mame/video/stvvdp1.c
r4135r4136
2525UINT32 *stv_vdp1_vram;
2626static UINT32 *stv_vdp1_regs;
2727UINT8* stv_vdp1_gfx_decode;
28extern UINT8 get_vblank(running_machine *machine);
2928
3029static UINT16    *stv_framebuffer[2];
3130static UINT16    **stv_framebuffer_draw_lines;
r4135r4136
294293      else
295294      {
296295         if ( vdp1_sprite_log ) logerror( "VDP1: Access to register TVMR = %1X\n", STV_VDP1_TVMR );
297         if ( STV_VDP1_VBE && get_vblank(space->machine) )
296         if ( STV_VDP1_VBE && stv_get_vblank(space->machine) )
298297         {
299298            stv_vdp1_clear_framebuffer_on_next_frame = 1;
300299         }
src/mame/video/twincobr.c
r4135r4136
338338{
339339   int shift = 8 * (offset & 1);
340340   switch (offset/2) {
341      case 0: return twincobr_txram_r(space,0,0xffff) >> shift; break;
342      case 1: return twincobr_bgram_r(space,0,0xffff) >> shift; break;
343      case 2: return twincobr_fgram_r(space,0,0xffff) >> shift; break;
341      case 0: return twincobr_txram_r(space,0,0xffff) >> shift;
342      case 1: return twincobr_bgram_r(space,0,0xffff) >> shift;
343      case 2: return twincobr_fgram_r(space,0,0xffff) >> shift;
344344   }
345345   return 0;
346346}
src/mame/video/arabian.c
r4135r4136
217217      converted_gfx[offs * 4 + 1] = p3;
218218      converted_gfx[offs * 4 + 0] = p4;
219219   }
220
221    state_save_register_global_pointer(machine, main_bitmap, BITMAP_WIDTH * BITMAP_HEIGHT);
222    state_save_register_global_pointer(machine, converted_gfx, 0x8000 * 2);
223    state_save_register_global(machine, arabian_video_control);
224    state_save_register_global(machine, arabian_flip_screen);
220225}
221226
222227
r4135r4136
381386   {
382387      /* non-flipped case */
383388      if (!arabian_flip_screen)
384         draw_scanline8(bitmap, 0, y, BITMAP_WIDTH, &main_bitmap[y * BITMAP_WIDTH], pens, -1);
389         draw_scanline8(bitmap, 0, y, BITMAP_WIDTH, &main_bitmap[y * BITMAP_WIDTH], pens);
385390
386391      /* flipped case */
387392      else
r4135r4136
390395         int x;
391396         for (x = 0; x < BITMAP_WIDTH; x++)
392397            scanline[BITMAP_WIDTH - 1 - x] = main_bitmap[y * BITMAP_WIDTH + x];
393         draw_scanline8(bitmap, 0, BITMAP_HEIGHT - 1 - y, BITMAP_WIDTH, scanline, pens, -1);
398         draw_scanline8(bitmap, 0, BITMAP_HEIGHT - 1 - y, BITMAP_WIDTH, scanline, pens);
394399      }
395400   }
396401   return 0;
src/mame/video/policetr.c
r4135r4136
366366
367367   /* render all the scanlines from the dstbitmap to MAME's bitmap */
368368   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
369      draw_scanline8(bitmap, cliprect->min_x, y, width, &dstbitmap[DSTBITMAP_WIDTH * y + cliprect->min_x], NULL, -1);
369      draw_scanline8(bitmap, cliprect->min_x, y, width, &dstbitmap[DSTBITMAP_WIDTH * y + cliprect->min_x], NULL);
370370
371371   return 0;
372372}
src/mame/video/seibuspi.c
r4135r4136
235235static void draw_blend_gfx(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy)
236236{
237237   const pen_t *pens = &machine->pens[gfx->color_base];
238   UINT8 *dp;
238   const UINT8 *dp;
239239   int i, j;
240240   int x1, x2;
241241   int y1, y2;
r4135r4136
314314      code &= 0xffff;
315315   }
316316
317   dp = gfx->gfxdata + code * gfx->char_modulo;
317   dp = gfx_element_get_data(gfx, code);
318318
319319   // draw
320320   for (j=y1; j <= y2; j++)
src/mame/video/stvvdp2.c
r4135r4136
108108
109109UINT32* stv_vdp2_regs;
110110UINT32* stv_vdp2_vram;
111/* this won't be used in the end .. */
112static UINT8*  stv_vdp2_vram_dirty_8x8x4;
113static UINT8*  stv_vdp2_vram_dirty_8x8x8;
114111
115112static UINT8* stv_vdp2_gfx_decode;
116113
117114static int stv_vdp2_render_rbg0;
118int stv_hblank,stv_vblank,stv_odd;
119int horz_res,vert_res;
115int stv_hblank,stv_vblank;
116static int stv_odd;
117static int horz_res,vert_res;
120118
121119UINT32* stv_vdp2_cram;
122120
123121static void stv_vdp2_dynamic_res_change(running_machine *machine);
124UINT8 get_vblank(running_machine *machine);
125UINT8 get_hblank(running_machine *machine);
126int   get_vblank_duration(running_machine *machine);
122static UINT8 get_hblank(running_machine *machine);
123static int   get_vblank_duration(running_machine *machine);
127124//int get_hblank_duration(running_machine *machine); //<- when we know that...
128UINT8 get_odd_bit(running_machine *machine);
125static UINT8 get_odd_bit(running_machine *machine);
129126
130127static void refresh_palette_data(running_machine *machine);
131128static int stv_vdp2_window_process(int x,int y);
r4135r4136
138135{
139136   STV_TRANSPARENCY_NONE      = TRANSPARENCY_NONE,
140137   STV_TRANSPARENCY_PEN      = TRANSPARENCY_PEN,
141   STV_TRANSPARENCY_ALPHA      = TRANSPARENCY_ALPHA,
142   STV_TRANSPARENCY_ADD_BLEND  = TRANSPARENCY_MODES
138   STV_TRANSPARENCY_ADD_BLEND  = TRANSPARENCY_MODES,
139   STV_TRANSPARENCY_ALPHA      = TRANSPARENCY_MODES + 1
143140};
144141
145142#if DEBUG_MODE
r4135r4136
20722069   UINT8  transparency;
20732070   UINT8  colour_calculation_enabled;
20742071   UINT8  colour_depth;
2072   UINT8  alpha;
20752073   UINT8  tile_size;
20762074   UINT8  bitmap_enable;
20772075   UINT8  bitmap_size;
r4135r4136
23982396      bitmap_t *dest_bmp,const gfx_element *gfx,
23992397      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
24002398      const rectangle *clip,int transparency,int transparent_color,int scalex, int scaley,
2401      int sprite_screen_width, int sprite_screen_height)
2399      int sprite_screen_width, int sprite_screen_height, int alpha)
24022400{
24032401   rectangle myclip;
24042402
r4135r4136
24522450   if( gfx )
24532451   {
24542452      const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
2455      UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
2453      const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
24562454
24572455      //int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
24582456      //int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
r4135r4136
25292527               {
25302528                  for( y=sy; y<ey; y++ )
25312529                  {
2532                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2530                     const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
25332531                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
25342532
25352533                     int x, x_index = x_index_base;
r4135r4136
25462544               {
25472545                  for( y=sy; y<ey; y++ )
25482546                  {
2549                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2547                     const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
25502548                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
25512549
25522550                     int x, x_index = x_index_base;
r4135r4136
25682566               {
25692567                  for( y=sy; y<ey; y++ )
25702568                  {
2571                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2569                     const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
25722570                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
25732571
25742572                     int x, x_index = x_index_base;
r4135r4136
25862584               {
25872585                  for( y=sy; y<ey; y++ )
25882586                  {
2589                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2587                     const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
25902588                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
25912589
25922590                     int x, x_index = x_index_base;
r4135r4136
26022600               }
26032601            }
26042602
2605            /* case 6: TRANSPARENCY_ALPHA */
2606            if (transparency == TRANSPARENCY_ALPHA)
2603            /* case 6: STV_TRANSPARENCY_ALPHA */
2604            if (transparency == STV_TRANSPARENCY_ALPHA)
26072605            {
26082606               for( y=sy; y<ey; y++ )
26092607               {
2610                  UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2608                  const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
26112609                  UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
26122610
26132611                  int x, x_index = x_index_base;
26142612                  for( x=sx; x<ex; x++ )
26152613                  {
26162614                     int c = source[x_index>>16];
2617                     if( c != transparent_color ) dest[x] = alpha_blend16(dest[x], pal[c]);
2615                     if( c != transparent_color ) dest[x] = alpha_blend_r16(dest[x], pal[c], alpha);
26182616                     x_index += dx;
26192617                  }
26202618
r4135r4136
26292627               {
26302628                  for( y=sy; y<ey; y++ )
26312629                  {
2632                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2630                     const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
26332631                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
26342632
26352633                     int x, x_index = x_index_base;
r4135r4136
26472645               {
26482646                  for( y=sy; y<ey; y++ )
26492647                  {
2650                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2648                     const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
26512649                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
26522650
26532651                     int x, x_index = x_index_base;
r4135r4136
27292727}
27302728
27312729static void stv_vdp2_drawgfx_rgb555( bitmap_t *dest_bmp, UINT32 code, int flipx, int flipy,
2732                            int sx, int sy, const rectangle *clip, int transparency)
2730                            int sx, int sy, const rectangle *clip, int transparency, int alpha)
27332731{
27342732   rectangle myclip;
27352733   UINT8* gfxdata;
r4135r4136
28172815
28182816         for( y=sy; y<ey; y++ )
28192817         {
2820            UINT8 *source = gfxdata + (y_index>>16)*16;
2818            const UINT8 *source = gfxdata + (y_index>>16)*16;
28212819            UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
28222820            UINT16 data;
28232821
r4135r4136
28362834                  if(stv2_current_tilemap.fade_control & 1)
28372835                     stv_vdp2_compute_color_offset_RGB555(&r,&g,&b,stv2_current_tilemap.fade_control & 2);
28382836
2839                  if ( transparency == TRANSPARENCY_ALPHA )
2840                     dest[x] = alpha_blend16( dest[x], b | g << 5 | r << 10 );
2837                  if ( transparency == STV_TRANSPARENCY_ALPHA )
2838                     dest[x] = alpha_blend_r16( dest[x], b | g << 5 | r << 10, alpha );
28412839                  else
28422840                     dest[x] = b | g << 5 | r << 10;
28432841               }
r4135r4136
29372935                     if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
29382936                        *BITMAP_ADDR16(bitmap, ycnt, xcnt+1) = machine->pens[((gfxdata[0] & 0x0f) >> 0) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
29392937                     else
2940                        *BITMAP_ADDR16(bitmap, ycnt, xcnt+1) = alpha_blend16(*BITMAP_ADDR16(bitmap, ycnt, xcnt+1), machine->pens[((gfxdata[0] & 0x0f) >> 0) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]);
2938                        *BITMAP_ADDR16(bitmap, ycnt, xcnt+1) = alpha_blend_r16(*BITMAP_ADDR16(bitmap, ycnt, xcnt+1), machine->pens[((gfxdata[0] & 0x0f) >> 0) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha);
29412939                  }
29422940               }
29432941               tw = stv_vdp2_window_process(xcnt,ycnt);
r4135r4136
29502948                     if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
29512949                        *BITMAP_ADDR16(bitmap, ycnt, xcnt) = machine->pens[((gfxdata[0] & 0xf0) >> 4) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
29522950                     else
2953                        *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[((gfxdata[0] & 0xf0) >> 4) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]);
2951                        *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend_r16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[((gfxdata[0] & 0xf0) >> 4) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha);
29542952                  }
29552953               }
29562954               gfxdata++;
r4135r4136
29822980                        if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
29832981                           *BITMAP_ADDR16(bitmap, ycnt, xcnt) = machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
29842982                        else
2985                           *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]);
2983                           *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend_r16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha);
29862984                     }
29872985                  }
29882986                  if ( (gfxdata + xs) >= gfxdatahigh )
r4135r4136
30253023                        if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
30263024                           *BITMAP_ADDR16(bitmap, ycnt, xcnt) = machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset];
30273025                        else
3028                           *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset]);
3026                           *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend_r16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[(gfxdata[xs] & 0xff) | (stv2_current_tilemap.bitmap_palette_number * 0x100) | pal_color_offset], stv2_current_tilemap.alpha);
30293027                     }
30303028                  }
30313029
r4135r4136
30503048                     if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
30513049                        *BITMAP_ADDR16(bitmap, ycnt, xcnt) = machine->pens[((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff) | pal_color_offset];
30523050                     else
3053                        *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff) | pal_color_offset]);
3051                        *BITMAP_ADDR16(bitmap, ycnt, xcnt) = alpha_blend_r16(*BITMAP_ADDR16(bitmap, ycnt, xcnt), machine->pens[((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff) | pal_color_offset], stv2_current_tilemap.alpha);
30543052                  }
30553053               }
30563054
r4135r4136
30943092                     if ( stv2_current_tilemap.colour_calculation_enabled == 0 )
30953093                        destline[xcnt] = b | g << 5 | r << 10;
30963094                     else
3097                        destline[xcnt] = alpha_blend16( destline[xcnt], b | g << 5 | r << 10 );
3095                        destline[xcnt] = alpha_blend_r16( destline[xcnt], b | g << 5 | r << 10, stv2_current_tilemap.alpha );
30983096                  }
30993097
31003098                  if ( (gfxdata + 2*xs) >= gfxdatahigh ) gfxdata = gfxdatalow;
r4135r4136
31343132                     if(t_pen)
31353133                     {
31363134                        if ( stv2_current_tilemap.colour_calculation_enabled == 1 )
3137                           destline[xcnt] = alpha_blend16( destline[xcnt], b | g << 5 | r << 10 );
3135                           destline[xcnt] = alpha_blend_r16( destline[xcnt], b | g << 5 | r << 10, stv2_current_tilemap.alpha );
31383136                        else
31393137                           destline[xcnt] = b | g << 5 | r << 10;
31403138                     }
r4135r4136
33973395      }
33983396      else
33993397      {
3400         stv2_current_tilemap.transparency = TRANSPARENCY_ALPHA;
3398         stv2_current_tilemap.transparency = STV_TRANSPARENCY_ALPHA;
34013399      }
34023400   }
34033401
r4135r4136
36063604
36073605      for (x = 0; x<mptiles_x; x++) {
36083606         int xpageoffs;
3607         int tilecodespacing = 1;
36093608
36103609         if ( x == 0 )
36113610         {
r4135r4136
36863685
36873686         if (stv2_current_tilemap.colour_depth == 1)
36883687         {
3689            UINT8 gfx_mem_offset = (tilecode & 0x1) ? 0x20 : 0x0;
3690
3691            tilecode = tilecode >> 1;
36923688            gfx = 2;
36933689            pal = pal >>4;
3694
3695            /* do a bit of tile decoding */
3696            tilecode &=0x3fff;
3697            if (stv2_current_tilemap.tile_size==1)
3698            { /* we're treating 16x16 tiles as 4 8x8's atm */
3699               if (stv_vdp2_vram_dirty_8x8x8[tilecode] == 1) { stv_vdp2_vram_dirty_8x8x8[tilecode] = 0; decodechar(machine->gfx[2], tilecode,  stv_vdp2_gfx_decode + gfx_mem_offset); };
3700               if (stv_vdp2_vram_dirty_8x8x8[tilecode+1] == 1) { stv_vdp2_vram_dirty_8x8x8[tilecode+1] = 0; decodechar(machine->gfx[2], tilecode+1,  stv_vdp2_gfx_decode + gfx_mem_offset); };
3701               if (stv_vdp2_vram_dirty_8x8x8[tilecode+2] == 1) { stv_vdp2_vram_dirty_8x8x8[tilecode+2] = 0; decodechar(machine->gfx[2], tilecode+2,  stv_vdp2_gfx_decode + gfx_mem_offset); };
3702               if (stv_vdp2_vram_dirty_8x8x8[tilecode+3] == 1) { stv_vdp2_vram_dirty_8x8x8[tilecode+3] = 0; decodechar(machine->gfx[2], tilecode+3,  stv_vdp2_gfx_decode + gfx_mem_offset); };
3703            }
3704            else
3705            {
3706               if (stv_vdp2_vram_dirty_8x8x8[tilecode] == 1) { stv_vdp2_vram_dirty_8x8x8[tilecode] = 0; decodechar(machine->gfx[2], tilecode,  stv_vdp2_gfx_decode + gfx_mem_offset); };
3707            }
3708
3690            tilecode &=0x7fff;
3691            if (tilecode == 0x7fff) tilecode--;   /* prevents crash but unsure what should happen; wrapping? */
3692            tilecodespacing = 2;
37093693         }
37103694         else if (stv2_current_tilemap.colour_depth == 0)
37113695         {
37123696            gfx = 0;
3713
3714            /* do a bit of tile decoding */
37153697            tilecode &=0x7fff;
3716            if (stv2_current_tilemap.tile_size==1)
3717            { /* we're treating 16x16 tiles as 4 8x8's atm */
3718               if (stv_vdp2_vram_dirty_8x8x4[tilecode] == 1) { stv_vdp2_vram_dirty_8x8x4[tilecode] = 0; decodechar(machine->gfx[0], tilecode,  stv_vdp2_gfx_decode); };
3719               if (stv_vdp2_vram_dirty_8x8x4[tilecode+1] == 1) { stv_vdp2_vram_dirty_8x8x4[tilecode+1] = 0; decodechar(machine->gfx[0], tilecode+1,  stv_vdp2_gfx_decode); };
3720               if (stv_vdp2_vram_dirty_8x8x4[tilecode+2] == 1) { stv_vdp2_vram_dirty_8x8x4[tilecode+2] = 0; decodechar(machine->gfx[0], tilecode+2,  stv_vdp2_gfx_decode); };
3721               if (stv_vdp2_vram_dirty_8x8x4[tilecode+3] == 1) { stv_vdp2_vram_dirty_8x8x4[tilecode+3] = 0; decodechar(machine->gfx[0], tilecode+3,  stv_vdp2_gfx_decode); };
3722            }
3723            else
3724            {
3725               if (stv_vdp2_vram_dirty_8x8x4[tilecode] == 1) { stv_vdp2_vram_dirty_8x8x4[tilecode] = 0; decodechar(machine->gfx[0], tilecode,  stv_vdp2_gfx_decode); };
3726            }
3698            tilecodespacing = 1;
37273699         }
37283700/* TILES ARE NOW DECODED */
37293701
r4135r4136
37393711            if (stv2_current_tilemap.tile_size==1)
37403712            {
37413713               /* normal */
3742               stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+0+(flipyx&1)+(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos >> 16, drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y);
3743               stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+1-(flipyx&1)+(flipyx&2),pal,flipyx&1,flipyx&2,(drawxpos+tilesizex) >> 16,drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y);
3744               stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+2+(flipyx&1)-(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos >> 16,(drawypos+tilesizey) >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y1(tilesizey));
3745               stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+3-(flipyx&1)-(flipyx&2),pal,flipyx&1,flipyx&2,(drawxpos+tilesizex)>> 16,(drawypos+tilesizey) >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y1(tilesizey));
3714               stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+(0+(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos >> 16, drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y,stv2_current_tilemap.alpha);
3715               stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,(drawxpos+tilesizex) >> 16,drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y,stv2_current_tilemap.alpha);
3716               stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos >> 16,(drawypos+tilesizey) >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X, SCR_TILESIZE_Y1(tilesizey),stv2_current_tilemap.alpha);
3717               stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,(drawxpos+tilesizex)>> 16,(drawypos+tilesizey) >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X1(tilesizex), SCR_TILESIZE_Y1(tilesizey),stv2_current_tilemap.alpha);
37463718
37473719            }
37483720            else
37493721            {
3750               stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos >> 16, drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X,SCR_TILESIZE_Y);
3722               stv_vdp2_drawgfxzoom(machine,bitmap,machine->gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos >> 16, drawypos >> 16,cliprect,stv2_current_tilemap.transparency,0,scalex,scaley,SCR_TILESIZE_X,SCR_TILESIZE_Y,stv2_current_tilemap.alpha);
37513723            }
37523724         }
37533725         else
r4135r4136
37603732               if ( stv2_current_tilemap.colour_depth == 3 )
37613733               {
37623734                  /* normal */
3763                  stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(0+(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency);
3764                  stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(1-(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos,cliprect,stv2_current_tilemap.transparency);
3765                  stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(2+(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos,drawypos+8,cliprect,stv2_current_tilemap.transparency);
3766                  stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(3-(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,cliprect,stv2_current_tilemap.transparency);
3735                  stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(0+(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3736                  stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(1-(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos,cliprect,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3737                  stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(2+(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos,drawypos+8,cliprect,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
3738                  stv_vdp2_drawgfx_rgb555(bitmap,tilecode+(3-(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,cliprect,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
37673739
37683740               }
3741               else if (stv2_current_tilemap.transparency == STV_TRANSPARENCY_ALPHA)
3742               {
3743                  /* alpha */
3744                  drawgfx_alpha(bitmap,cliprect,machine->gfx[gfx],tilecode+(0+(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos, drawypos,0,stv2_current_tilemap.alpha);
3745                  drawgfx_alpha(bitmap,cliprect,machine->gfx[gfx],tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos,0,stv2_current_tilemap.alpha);
3746                  drawgfx_alpha(bitmap,cliprect,machine->gfx[gfx],tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos,drawypos+8,0,stv2_current_tilemap.alpha);
3747                  drawgfx_alpha(bitmap,cliprect,machine->gfx[gfx],tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,0,stv2_current_tilemap.alpha);
3748
3749               }
37693750               else
37703751               {
37713752                  /* normal */
3772                  drawgfx(bitmap,machine->gfx[gfx],tilecode+0+(flipyx&1)+(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency,0);
3773                  drawgfx(bitmap,machine->gfx[gfx],tilecode+1-(flipyx&1)+(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos+8,drawypos,cliprect,stv2_current_tilemap.transparency,0);
3774                  drawgfx(bitmap,machine->gfx[gfx],tilecode+2+(flipyx&1)-(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos,drawypos+8,cliprect,stv2_current_tilemap.transparency,0);
3775                  drawgfx(bitmap,machine->gfx[gfx],tilecode+3-(flipyx&1)-(flipyx&2),pal,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,cliprect,stv2_current_tilemap.transparency,0);
3753                  drawgfx(bitmap,machine->gfx[gfx],tilecode+(0+(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency,0);
3754                  drawgfx(bitmap,machine->gfx[gfx],tilecode+(1-(flipyx&1)+(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos,cliprect,stv2_current_tilemap.transparency,0);
3755                  drawgfx(bitmap,machine->gfx[gfx],tilecode+(2+(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos,drawypos+8,cliprect,stv2_current_tilemap.transparency,0);
3756                  drawgfx(bitmap,machine->gfx[gfx],tilecode+(3-(flipyx&1)-(flipyx&2))*tilecodespacing,pal,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,cliprect,stv2_current_tilemap.transparency,0);
37763757
37773758               }
37783759            }
r4135r4136
37803761            {
37813762               if ( stv2_current_tilemap.colour_depth == 3 )
37823763               {
3783                  stv_vdp2_drawgfx_rgb555(bitmap,tilecode,flipyx&1,flipyx&2,drawxpos,drawypos,cliprect,stv2_current_tilemap.transparency);
3764                  stv_vdp2_drawgfx_rgb555(bitmap,tilecode,flipyx&1,flipyx&2,drawxpos,drawypos,cliprect,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha);
37843765               }
37853766               else
37863767               {
3787                  drawgfx(bitmap,machine->gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency,0);
3768                  if (stv2_current_tilemap.transparency == STV_TRANSPARENCY_ALPHA)
3769                     drawgfx_alpha(bitmap,cliprect,machine->gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos, drawypos,0,stv2_current_tilemap.alpha);
3770                  else
3771                     drawgfx(bitmap,machine->gfx[gfx],tilecode,pal,flipyx&1,flipyx&2, drawxpos, drawypos,cliprect,stv2_current_tilemap.transparency,0);
37883772               }
37893773            }
37903774            drawxpos = olddrawxpos;
r4135r4136
41424126      }
41434127      else
41444128      {
4145         stv2_current_tilemap.transparency = TRANSPARENCY_ALPHA;
4129         stv2_current_tilemap.transparency = STV_TRANSPARENCY_ALPHA;
41464130      }
41474131   }
41484132
r4135r4136
42874271               case TRANSPARENCY_NONE:
42884272                  line[hcnt] = pix;
42894273                  break;
4290               case TRANSPARENCY_ALPHA:
4291                  if ( pix != 0x000 ) line[hcnt] = alpha_blend16( line[hcnt], pix );
4274               case STV_TRANSPARENCY_ALPHA:
4275                  if ( pix != 0x000 ) line[hcnt] = alpha_blend_r16( line[hcnt], pix, stv2_current_tilemap.alpha );
42924276                  break;
42934277               case STV_TRANSPARENCY_ADD_BLEND:
42944278                  if ( pix != 0x0000 ) line[hcnt] = stv_add_blend( line[hcnt], pix );
r4135r4136
43794363               case TRANSPARENCY_NONE:
43804364                  line[hcnt] = pix;
43814365                  break;
4382               case TRANSPARENCY_ALPHA:
4383                  if ( pix != 0x000 ) line[hcnt] = alpha_blend16( line[hcnt], pix );
4366               case STV_TRANSPARENCY_ALPHA:
4367                  if ( pix != 0x000 ) line[hcnt] = alpha_blend_r16( line[hcnt], pix, stv2_current_tilemap.alpha );
43844368                  break;
43854369               case STV_TRANSPARENCY_ADD_BLEND:
43864370                  if ( pix != 0x0000 ) line[hcnt] = stv_add_blend( line[hcnt], pix );
r4135r4136
44154399   if ( STV_VDP2_N0CCEN )
44164400   {
44174401      stv2_current_tilemap.colour_calculation_enabled = 1;
4418      alpha_set_level( ((UINT16)(0x1f-STV_VDP2_N0CCRT)*0xff)/0x1f);
4402      stv2_current_tilemap.alpha = ((UINT16)(0x1f-STV_VDP2_N0CCRT)*0xff)/0x1f;
44194403   }
44204404   else
44214405   {
r4135r4136
45054489   if ( STV_VDP2_N1CCEN )
45064490   {
45074491      stv2_current_tilemap.colour_calculation_enabled = 1;
4508      alpha_set_level( ((UINT16)(0x1f-STV_VDP2_N1CCRT)*0xff)/0x1f);
4492      stv2_current_tilemap.alpha = ((UINT16)(0x1f-STV_VDP2_N1CCRT)*0xff)/0x1f;
45094493   }
45104494   else
45114495   {
r4135r4136
46024586   if ( STV_VDP2_N2CCEN )
46034587   {
46044588      stv2_current_tilemap.colour_calculation_enabled = 1;
4605      alpha_set_level( ((UINT16)(0x1f-STV_VDP2_N2CCRT)*0xff)/0x1f);
4589      stv2_current_tilemap.alpha = ((UINT16)(0x1f-STV_VDP2_N2CCRT)*0xff)/0x1f;
46064590   }
46074591   else
46084592   {
r4135r4136
47024686   if ( STV_VDP2_N3CCEN )
47034687   {
47044688      stv2_current_tilemap.colour_calculation_enabled = 1;
4705      alpha_set_level( ((UINT16)(0x1f-STV_VDP2_N3CCRT)*0xff)/0x1f);
4689      stv2_current_tilemap.alpha = ((UINT16)(0x1f-STV_VDP2_N3CCRT)*0xff)/0x1f;
47064690   }
47074691   else
47084692   {
r4135r4136
49324916      stv2_current_tilemap.colour_calculation_enabled = colour_calculation_enabled;
49334917      if ( colour_calculation_enabled )
49344918      {
4935         stv2_current_tilemap.transparency = TRANSPARENCY_ALPHA;
4919         stv2_current_tilemap.transparency = STV_TRANSPARENCY_ALPHA;
49364920      }
49374921
49384922      mycliprect.min_x = cliprect->min_x;
r4135r4136
49804964   if ( STV_VDP2_R0CCEN )
49814965   {
49824966      stv2_current_tilemap.colour_calculation_enabled = 1;
4983      alpha_set_level( ((UINT16)(0x1f-STV_VDP2_R0CCRT)*0xff)/0x1f);
4967      stv2_current_tilemap.alpha = ((UINT16)(0x1f-STV_VDP2_R0CCRT)*0xff)/0x1f;
49844968   }
49854969   else
49864970   {
r4135r4136
51115095   stv_vdp2_vram_decode[offset*4+2] = (data & 0x0000ff00) >> 8;
51125096   stv_vdp2_vram_decode[offset*4+3] = (data & 0x000000ff) >> 0;
51135097
5114   stv_vdp2_vram_dirty_8x8x4[offset/8] = 1;
5115   stv_vdp2_vram_dirty_8x8x8[offset/16] = 1;
5098   gfx_element_mark_dirty(space->machine->gfx[0], offset/8);
5099   gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
5100   gfx_element_mark_dirty(space->machine->gfx[2], offset/8);
5101   gfx_element_mark_dirty(space->machine->gfx[3], offset/8);
51165102
5103   /* 8-bit tiles overlap, so this affects the previous one as well */
5104   if (offset/8 != 0)
5105   {
5106      gfx_element_mark_dirty(space->machine->gfx[2], offset/8 - 1);
5107      gfx_element_mark_dirty(space->machine->gfx[3], offset/8 - 1);
5108   }
5109
51175110   if ( stv_rbg_cache_data.watch_vdp2_vram_writes )
51185111   {
51195112      if ( stv_rbg_cache_data.watch_vdp2_vram_writes & STV_VDP2_RBG_ROTATION_PARAMETER_A )
r4135r4136
52725265   }
52735266}
52745267
5275UINT8 get_hblank(running_machine *machine)
5268static UINT8 get_hblank(running_machine *machine)
52765269{
52775270   static int cur_h;
52785271
r4135r4136
52885281//int get_hblank_duration(running_machine *machine)
52895282//...
52905283
5291UINT8 get_vblank(running_machine *machine)
5284UINT8 stv_get_vblank(running_machine *machine)
52925285{
52935286   static int cur_v;
52945287   rectangle visarea = *video_screen_get_visible_area(machine->primary_screen);
r4135r4136
53015294}
53025295
53035296/*some vblank lines measurements (according to Charles MacDonald)*/
5304int get_vblank_duration(running_machine *machine)
5297static int get_vblank_duration(running_machine *machine)
53055298{
53065299   if(STV_VDP2_HRES & 4)
53075300   {
r4135r4136
53235316   return 0;
53245317}
53255318
5326UINT8 get_odd_bit(running_machine *machine)
5319static UINT8 get_odd_bit(running_machine *machine)
53275320{
53285321   static int cur_v;
53295322   cur_v = video_screen_get_vpos(machine->primary_screen);
r4135r4136
53465339      case 0x4/4:
53475340      {
53485341         /*Screen Status Register*/
5349         stv_vblank = get_vblank(space->machine);
5342         stv_vblank = stv_get_vblank(space->machine);
53505343         stv_hblank = get_hblank(space->machine);
53515344         stv_odd = get_odd_bit(space->machine);
53525345
r4135r4136
53795372      stv_vdp2_vram_decode[offset*4+1] = (data & 0x00ff0000) >> 16;
53805373      stv_vdp2_vram_decode[offset*4+2] = (data & 0x0000ff00) >> 8;
53815374      stv_vdp2_vram_decode[offset*4+3] = (data & 0x000000ff) >> 0;
5382
5383      stv_vdp2_vram_dirty_8x8x4[offset/8] = 1;
5384      stv_vdp2_vram_dirty_8x8x8[offset/16] = 1;
53855375   }
53865376
53875377   memset( &stv_rbg_cache_data, 0, sizeof(stv_rbg_cache_data));
r4135r4136
53975387   stv_vdp2_vram = auto_malloc ( 0x100000 ); // actually we only need half of it since we don't emulate extra 4mbit ram cart.
53985388   stv_vdp2_cram = auto_malloc ( 0x080000 );
53995389   stv_vdp2_gfx_decode = auto_malloc ( 0x100000 );
5400   stv_vdp2_vram_dirty_8x8x4 = auto_malloc ( 0x100000 );
5401   stv_vdp2_vram_dirty_8x8x8 = auto_malloc ( 0x100000 );
54025390
54035391   memset(stv_vdp2_regs, 0, 0x040000);
54045392   memset(stv_vdp2_vram, 0, 0x100000);
r4135r4136
54295417   debug.l_en = 0xff;
54305418   debug.error = 0xffffffff;
54315419   debug.roz = 0;
5420   gfx_element_set_source(machine->gfx[0], stv_vdp2_gfx_decode);
5421   gfx_element_set_source(machine->gfx[1], stv_vdp2_gfx_decode);
5422   gfx_element_set_source(machine->gfx[2], stv_vdp2_gfx_decode);
5423   gfx_element_set_source(machine->gfx[3], stv_vdp2_gfx_decode);
5424   gfx_element_set_source(machine->gfx[4], stv_vdp1_gfx_decode);
5425   gfx_element_set_source(machine->gfx[5], stv_vdp1_gfx_decode);
5426   gfx_element_set_source(machine->gfx[6], stv_vdp1_gfx_decode);
5427   gfx_element_set_source(machine->gfx[7], stv_vdp1_gfx_decode);
54325428}
54335429
54345430/*TODO: frame_period should be different for every kind of resolution (needs tests on actual boards)*/
r4135r4136
62956291
62966292      for (tilecode = 0;tilecode<0x8000;tilecode++)
62976293      {
6298         decodechar(screen->machine->gfx[0], tilecode,  stv_vdp2_gfx_decode);
6294         gfx_element_mark_dirty(screen->machine->gfx[0], tilecode);
62996295      }
63006296
63016297      for (tilecode = 0;tilecode<0x2000;tilecode++)
63026298      {
6303         decodechar(screen->machine->gfx[1], tilecode,  stv_vdp2_gfx_decode);
6299         gfx_element_mark_dirty(screen->machine->gfx[1], tilecode);
63046300      }
63056301
63066302      for (tilecode = 0;tilecode<0x4000;tilecode++)
63076303      {
6308         decodechar(screen->machine->gfx[2], tilecode,  stv_vdp2_gfx_decode);
6304         gfx_element_mark_dirty(screen->machine->gfx[2], tilecode);
63096305      }
63106306
63116307      for (tilecode = 0;tilecode<0x1000;tilecode++)
63126308      {
6313         decodechar(screen->machine->gfx[3], tilecode, stv_vdp2_gfx_decode);
6309         gfx_element_mark_dirty(screen->machine->gfx[3], tilecode);
63146310      }
63156311
63166312      /* vdp 1 ... doesn't have to be tile based */
63176313
63186314      for (tilecode = 0;tilecode<0x8000;tilecode++)
63196315      {
6320         decodechar(screen->machine->gfx[4], tilecode,  stv_vdp1_gfx_decode);
6316         gfx_element_mark_dirty(screen->machine->gfx[4], tilecode);
63216317      }
63226318      for (tilecode = 0;tilecode<0x2000;tilecode++)
63236319      {
6324         decodechar(screen->machine->gfx[5], tilecode,  stv_vdp1_gfx_decode);
6320         gfx_element_mark_dirty(screen->machine->gfx[5], tilecode);
63256321      }
63266322      for (tilecode = 0;tilecode<0x4000;tilecode++)
63276323      {
6328         decodechar(screen->machine->gfx[6], tilecode,  stv_vdp1_gfx_decode);
6324         gfx_element_mark_dirty(screen->machine->gfx[6], tilecode);
63296325      }
63306326      for (tilecode = 0;tilecode<0x1000;tilecode++)
63316327      {
6332         decodechar(screen->machine->gfx[7], tilecode,  stv_vdp1_gfx_decode);
6328         gfx_element_mark_dirty(screen->machine->gfx[7], tilecode);
63336329      }
63346330   }
63356331
src/mame/video/suprnova.c
r4135r4136
127127
128128// This ignores the alpha values atm.
129129static int spc_changed=0, v3_changed=0, palette_updated=0;
130int suprnova_alt_enable_background, suprnova_alt_enable_sprites;
130static int suprnova_alt_enable_background;
131int suprnova_alt_enable_sprites;
131132
132133WRITE32_HANDLER ( skns_pal_regs_w )
133134{
r4135r4136
991992
992993VIDEO_UPDATE(skns)
993994{
994   int i, offset;
995
996   UINT8 *btiles;
997
998
999995   palette_update(screen->machine);
1000996
1001   btiles = memory_region (screen->machine, "gfx3");
1002
1003//  if (!(skns_v3_regs[0x0c/4] & 0x0100)); // if tilemap b is in 8bpp mode
1004   {
1005      if (skns_v3t_somedirty)
1006      {
1007         skns_v3t_somedirty = 0;
1008
1009         /* check if & where that tile is used in the tilemap */
1010         for (offset=0;offset<0x4000/4;offset++)
1011         {
1012            int code = ((skns_tilemapB_ram[offset] & 0x001fffff) >> 0 );
1013            if (skns_v3t_dirty[code&0x3ff])
1014               tilemap_mark_tile_dirty(skns_tilemap_B,offset);
1015         }
1016
1017         for (i = 0; i < 0x0400; i++)
1018         {
1019            if (skns_v3t_dirty[i] == 1)
1020            {
1021               decodechar(screen->machine->gfx[1], i, (UINT8*)btiles);
1022
1023               skns_v3t_dirty[i] = 0;
1024            }
1025         }
1026      }
1027   }
1028
1029//  if (skns_v3_regs[0x0c/4] & 0x0100); // if tilemap b is in 4bpp mode
1030   {
1031      if (skns_v3t_4bpp_somedirty)
1032      {
1033         skns_v3t_4bpp_somedirty = 0;
1034
1035         /* check if & where that tile is used in the tilemap */
1036         for (offset=0;offset<0x4000/4;offset++)
1037         {
1038            int code = ((skns_tilemapB_ram[offset] & 0x001fffff) >> 0 );
1039            if (skns_v3t_4bppdirty[code&0x7ff])
1040               tilemap_mark_tile_dirty(skns_tilemap_B,offset);
1041         }
1042
1043         for (i = 0; i < 0x0800; i++)
1044         {
1045            if (skns_v3t_4bppdirty[i] == 1)
1046            {
1047               decodechar(screen->machine->gfx[3], i, (UINT8*)btiles);
1048
1049               skns_v3t_4bppdirty[i] = 0;
1050            }
1051         }
1052      }
1053   }
1054
1055997   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
1056998   bitmap_fill(tilemap_bitmap_lower, NULL, 0);
1057999   bitmap_fill(tilemap_bitmapflags_lower, NULL, 0);
src/mame/video/balsente.c
r4135r4136
227227
228228   /* draw scanlines from the VRAM directly */
229229   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
230      draw_scanline8(bitmap, 0, y, 256, &local_videoram[(y - BALSENTE_VBEND) * 256], pens, -1);
230      draw_scanline8(bitmap, 0, y, 256, &local_videoram[(y - BALSENTE_VBEND) * 256], pens);
231231
232232   /* draw the sprite images */
233233   for (i = 0; i < 40; i++)
src/mame/video/itech32.c
r4135r4136
14751475         }
14761476
14771477         /* draw from the buffer */
1478         draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL, -1);
1478         draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL);
14791479      }
14801480
14811481      /* otherwise, draw directly from VRAM */
14821482      else
1483         draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &src1[cliprect->min_x], NULL, -1);
1483         draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &src1[cliprect->min_x], NULL);
14841484   }
14851485   return 0;
14861486}
src/mame/video/deco32.c
r4135r4136
284284   for (offs = 0x400 - 4; offs >= 0; offs -=4)
285285   {
286286      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult,pri=0;
287      int trans;
287      int alpha = 0xff;
288288
289289      sprite = spritedata[offs+1] & 0xffff;
290290
r4135r4136
292292      flash=y&0x1000;
293293      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
294294
295      trans=TRANSPARENCY_PEN;
296295      x = spritedata[offs+2];
297296      colour = (x >>9) & colourmask;
298297
r4135r4136
332331               colour,
333332               fx,fy,
334333               x,y + mult * multi,
335               cliprect,trans,0,pri,1<<gfxbank, 1);
334               cliprect,0,pri,1<<gfxbank, 1, alpha);
336335
337336         multi--;
338337      }
r4135r4136
348347      UINT32 code,UINT32 priority,int flipx,int flipy,int sx,int sy,
349348      const rectangle *clip)
350349{
350   const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
351351   int ox,oy,cx,cy;
352352   int x_index,y_index,x,y;
353353
354   int source_base = (code % gfx->total_elements) * gfx->height;
355
356354   /* check bounds */
357355   ox = sx;
358356   oy = sy;
r4135r4136
371369
372370   for( y=0; y<16-cy; y++ )
373371   {
374      UINT8 *source = gfx->gfxdata + ((source_base+y_index) * gfx->line_modulo);
372      const UINT8 *source = code_base + y_index * gfx->line_modulo;
375373      UINT16 *destb = BITMAP_ADDR16(dest, sy, 0);
376374
377375      if (flipx) { source+=15-(sx-ox); x_index=-1; } else { x_index=1; source+=(sx-ox); }
r4135r4136
458456INLINE void dragngun_drawgfxzoom( running_machine *machine,
459457      bitmap_t *dest_bmp,const gfx_element *gfx,
460458      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
461      const rectangle *clip,int transparency,int transparent_color,
462      int scalex, int scaley,bitmap_t *pri_buffer,UINT32 pri_mask, int sprite_screen_width, int  sprite_screen_height )
459      const rectangle *clip,int transparent_color,
460      int scalex, int scaley,bitmap_t *pri_buffer,UINT32 pri_mask, int sprite_screen_width, int  sprite_screen_height, UINT8 alpha )
463461{
464462   rectangle myclip;
465463
r4135r4136
492490      if( gfx )
493491      {
494492         const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
495         int source_base = (code % gfx->total_elements) * gfx->height;
493         const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
496494
497495         if (sprite_screen_width && sprite_screen_height)
498496         {
r4135r4136
558556               int y;
559557
560558               /* case 1: TRANSPARENCY_PEN */
561               if (transparency == TRANSPARENCY_PEN)
559               if (alpha == 0xff)
562560               {
563561                  if (pri_buffer)
564562                  {
565563                     for( y=sy; y<ey; y++ )
566564                     {
567                        UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * gfx->line_modulo;
565                        const UINT8 *source = code_base + (y_index>>16) * gfx->line_modulo;
568566                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
569567                        UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
570568
r4135r4136
588586                  {
589587                     for( y=sy; y<ey; y++ )
590588                     {
591                        UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * gfx->line_modulo;
589                        const UINT8 *source = code_base + (y_index>>16) * gfx->line_modulo;
592590                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
593591
594592                        int x, x_index = x_index_base;
r4135r4136
604602                  }
605603               }
606604
607               /* case 6: TRANSPARENCY_ALPHA */
608               if (transparency == TRANSPARENCY_ALPHA)
605               /* alpha-blended */
606               else
609607               {
610608                  if (pri_buffer)
611609                  {
612610                     for( y=sy; y<ey; y++ )
613611                     {
614                        UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * gfx->line_modulo;
612                        const UINT8 *source = code_base + (y_index>>16) * gfx->line_modulo;
615613                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
616614                        UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
617615
r4135r4136
622620                           if( c != transparent_color )
623621                           {
624622                              if (((1 << pri[x]) & pri_mask) == 0)
625                                 dest[x] = alpha_blend32(dest[x], pal[c]);
623                                 dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
626624                              pri[x] = 31;
627625                           }
628626                           x_index += dx;
r4135r4136
635633                  {
636634                     for( y=sy; y<ey; y++ )
637635                     {
638                        UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * gfx->line_modulo;
636                        const UINT8 *source = code_base + (y_index>>16) * gfx->line_modulo;
639637                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
640638
641639                        int x, x_index = x_index_base;
642640                        for( x=sx; x<ex; x++ )
643641                        {
644642                           int c = source[x_index>>16];
645                           if( c != transparent_color ) dest[x] = alpha_blend32(dest[x], pal[c]);
643                           if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
646644                           x_index += dx;
647645                        }
648646
r4135r4136
713711
714712   for (offs = 0;offs < 0x800;offs += 8)
715713   {
716      int sx,sy,colour,fx,fy,w,h,x,y,bx,by,trans,scalex,scaley;
714      int sx,sy,colour,fx,fy,w,h,x,y,bx,by,alpha,scalex,scaley;
717715      int zoomx,zoomy;
718716      int xpos,ypos;
719717
r4135r4136
743741      colour = spritedata[offs+6]&0x1f;
744742
745743      if (spritedata[offs+6]&0x80)
746         trans=TRANSPARENCY_ALPHA;
744         alpha=0x80;
747745      else
748         trans=TRANSPARENCY_PEN;
746         alpha=0xff;
749747
750748      fx = spritedata[offs+4]&0x8000;
751749      fy = spritedata[offs+5]&0x8000;
r4135r4136
808806                  colour,
809807                  fx,fy,
810808                  xpos>>16,ypos>>16,
811                  cliprect,trans,15,zoomx,zoomy,NULL,0,
812                  ((xpos+(zoomx<<4))>>16) - (xpos>>16), ((ypos+(zoomy<<4))>>16) - (ypos>>16) );
809                  cliprect,15,zoomx,zoomy,NULL,0,
810                  ((xpos+(zoomx<<4))>>16) - (xpos>>16), ((ypos+(zoomy<<4))>>16) - (ypos>>16), alpha );
813811            else
814               drawgfx(bitmap,machine->gfx[bank],
812               drawgfx_alpha(bitmap,cliprect,machine->gfx[bank],
815813                  sprite,
816814                  colour,
817815                  fx,fy,
818816                  xpos>>16,ypos>>16,
819                  cliprect,trans,15);
817                  15,alpha);
820818
821819            if (fx)
822820               xpos-=zoomx<<4;
r4135r4136
10061004
10071005   deco32_pf2_colourbank=deco32_pf4_colourbank=0;
10081006
1009   alpha_set_level(0x80);
10101007   state_save_register_global(machine, dragngun_sprite_ctrl);
10111008   has_ace_ram=0;
10121009}
r4135r4136
10301027
10311028   deco32_pf2_colourbank=deco32_pf4_colourbank=0;
10321029
1033   alpha_set_level(0x80);
10341030   state_save_register_global(machine, dragngun_sprite_ctrl);
10351031   has_ace_ram=0;
10361032}
r4135r4136
10611057   deco32_pf2_colourbank=16;
10621058   deco32_pf4_colourbank=16;
10631059   state_save_register_global(machine, deco32_pri);
1064   alpha_set_level(0x80);
10651060   has_ace_ram=1;
10661061}
10671062
r4135r4136
14831478                        Pri 2 -
14841479                        Pri 3 -
14851480                    */
1486               alpha_set_level(0x80);
14871481
14881482               /* Alpha values are tied to ACE ram... */
14891483               //int alpha=((deco32_ace_ram[0x0 + (((priColAlphaPal1&0xf0)>>4)/2)]) * 8)-1;
14901484               //if (alpha<0)
14911485               //  alpha=0;
1492               //alpha_set_level(255-alpha);
14931486
14941487               /* I don't really understand how object ACE ram is really hooked up,
14951488                        the only obvious place in Night Slashers is the stagecoach in level 2 */
r4135r4136
14971490               if (pri1==0 && (((priColAlphaPal0&0xff)==0 || ((pri0&0x3)!=0 && (pri0&0x3)!=1 && (pri0&0x3)!=2))))
14981491               {
14991492                  if ((deco32_pri&1)==0 || ((deco32_pri&1)==1 && tilemapPri[x]<4) || ((deco32_pri&1)==1 && mixAlphaTilemap))
1500                     destLine[x]=alpha_blend32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)]);
1493                     destLine[x]=alpha_blend_r32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)], 0x80);
15011494               }
15021495               else if (pri1==1 && ((priColAlphaPal0&0xff)==0 || ((pri0&0x3)!=0 && (pri0&0x3)!=1 && (pri0&0x3)!=2)))
1503                  destLine[x]=alpha_blend32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)]);
1496                  destLine[x]=alpha_blend_r32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)], 0x80);
15041497               else if (pri1==2)// TOdo
1505                  destLine[x]=alpha_blend32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)]);
1498                  destLine[x]=alpha_blend_r32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)], 0x80);
15061499               else if (pri1==3)// TOdo
1507                  destLine[x]=alpha_blend32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)]);
1500                  destLine[x]=alpha_blend_r32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)], 0x80);
15081501            }
15091502            else
15101503            {
r4135r4136
15381531                  int alpha=((deco32_ace_ram[0x17 + (((p&0xf0)>>4)/2)]) * 8)-1;
15391532                  if (alpha<0)
15401533                     alpha=0;
1541                  alpha_set_level(255-alpha);
15421534
1543                  destLine[x]=alpha_blend32(destLine[x], pal2[p]);
1535                  destLine[x]=alpha_blend_r32(destLine[x], pal2[p], 255-alpha);
15441536               }
15451537            }
15461538         }
r4135r4136
15941586   bitmap_fill(sprite0_mix_bitmap,cliprect,0);
15951587   bitmap_fill(sprite1_mix_bitmap,cliprect,0);
15961588   bitmap_fill(priority_bitmap,cliprect,0);
1597   bitmap_fill(tilemap_alpha_bitmap,cliprect,0);
15981589   if ((deco32_pf34_control[5]&0x8000)==0)
15991590      bitmap_fill(bitmap,cliprect,screen->machine->pens[0x200]);
16001591
r4135r4136
16031594   nslasher_draw_sprites(screen->machine,sprite1_mix_bitmap,cliprect,buffered_spriteram32_2,4);
16041595
16051596   /* Render alpha-blended tilemap to seperate buffer for proper mixing */
1606   if (alphaTilemap)
1607      bitmap_fill(tilemap_alpha_bitmap,cliprect,0);
1597   bitmap_fill(tilemap_alpha_bitmap,cliprect,0);
16081598
16091599   /* Draw playfields & sprites */
16101600   if (deco32_pri&2)
src/mame/video/grchamp.c
r4135r4136
283283         int code = (codeflip & 0x3f) + (change >> 2);
284284         int yflip = (codeflip & 0x80) ? 0x0f : 0x00;
285285         int xflip = (codeflip & 0x40) ? 0x0f : 0x00;
286         const UINT8 *src = gfx->gfxdata + code * gfx->char_modulo + ((dy ^ yflip) & 15) * gfx->line_modulo;
286         const UINT8 *src = gfx_element_get_data(gfx, code) + ((dy ^ yflip) & 15) * gfx->line_modulo;
287287
288288         /* the third byte is: color in bits 0-2 */
289289         int color = (state->spriteram[0x42 + (dataoffs & ~0x20)] & 0x07) << 2;
r4135r4136
327327      int dy = sy + ~y;
328328      int color = (state->spriteram[0x01 + dataoffs] & 0x07) << 2;
329329      int code = state->videoram[hprime | ((dy & 0xf8) << 2)] + change;
330      const UINT8 *src = gfx->gfxdata + code * gfx->char_modulo + (dy & 7) * gfx->line_modulo;
330      const UINT8 *src = gfx_element_get_data(gfx, code) + (dy & 7) * gfx->line_modulo;
331331      int x;
332332
333333      /* draw 8 pixels */
src/mame/video/goodejan.c
r4135r4136
33static tilemap *bg_tilemap, *tx_tilemap;
44UINT16 *goodejan_bgvram,*goodejan_txvram;
55static UINT16 goodejan_layer_en;
6static UINT16 goodejan_gfx_bank;
67
78WRITE16_HANDLER( goodejan_bgvram_w )
89{
r4135r4136
2324   goodejan_layer_en = data;
2425}
2526
27/*Not from the Seibu CRTC,it's an external ROM banking.*/
28WRITE16_HANDLER( goodejan_gfxbank_w )
29{
30   goodejan_gfx_bank = (data & 0x100)>>8;
31   tilemap_mark_all_tiles_dirty(bg_tilemap);
32}
33
2634static TILE_GET_INFO( goodejan_bg_tile_info )
2735{
2836   int tile = goodejan_bgvram[tile_index]&0x0fff;
2937   int color = (goodejan_bgvram[tile_index]&0xf000)>>12;
3038
31   // WRONG!
32   tile|= (goodejan_bgvram[tile_index]&0x8000)>>3;
39   tile|= goodejan_gfx_bank<<12;
3340//  if ((goodejan_bgvram[tile_index]&0x8000)==0x0000) tile+=0x1000;
3441
3542   SET_TILE_INFO(1, tile, color, 0);
src/mame/video/gaiden.c
r4135r4136
361361               int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
362362               int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
363363
364               pdrawgfx(bitmap, gfx,
364               pdrawgfx_transpen_raw(bitmap, cliprect, gfx,
365365                  number + layout[row][col],
366366                  gfx->color_base + color * gfx->color_granularity,
367367                  flipx, flipy,
368368                  sx, sy,
369                  cliprect, TRANSPARENCY_PEN_RAW, 0,
370                  priority_mask);
369                  priority_bitmap, priority_mask, 0);
371370            }
372371         }
373372      }
r4135r4136
462461                  int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
463462                  int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
464463
465                  pdrawgfx(bitmap_sp, gfx,
464                  pdrawgfx_transpen_raw(bitmap_sp, cliprect, gfx,
466465                     number + layout[row][col],
467466                     gfx->color_base + color * gfx->color_granularity,
468467                     flipx, flipy,
469468                     sx, sy,
470                     cliprect, TRANSPARENCY_PEN_RAW, 0,
471                     priority_mask);
469                     priority_bitmap, priority_mask, 0);
472470               }
473471            }
474472         }
r4135r4136
483481                  int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col);
484482                  int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row);
485483
486                  pdrawgfx(bitmap, gfx,
484                  pdrawgfx_transpen_raw(bitmap, cliprect, gfx,
487485                     number + layout[row][col],
488486                     gfx->color_base + color * gfx->color_granularity,
489487                     flipx, flipy,
490488                     sx, sy,
491                     cliprect, TRANSPARENCY_PEN_RAW, 0,
492                     priority_mask);
489                     priority_bitmap, priority_mask, 0);
493490               }
494491            }
495492         }
r4135r4136
541538      else
542539         priority_mask = 0;
543540
544      pdrawgfx(bitmap,machine->gfx[3],
541      pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[3],
545542            code,
546543            machine->gfx[3]->color_base + color * machine->gfx[3]->color_granularity,
547544            flipx,flipy,x,y,
548            cliprect,
549            TRANSPARENCY_PEN_RAW,15,
550            priority_mask);
545            priority_bitmap, priority_mask,15);
551546
552547      /* wrap x*/
553      pdrawgfx(bitmap,machine->gfx[3],
548      pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[3],
554549            code,
555550            machine->gfx[3]->color_base + color * machine->gfx[3]->color_granularity,
556551            flipx,flipy,x-512,y,
557            cliprect,
558            TRANSPARENCY_PEN_RAW,15,
559            priority_mask);
552            priority_bitmap, priority_mask,15);
560553
561554   }
562555}
src/mame/video/gticlub.c
r4135r4136
1919
2020// defined in drivers/nwk-tr.c
2121int K001604_vh_start(running_machine *machine, int chip);
22void K001604_tile_update(running_machine *machine, int chip);
2322void K001604_draw_front_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
2423void K001604_draw_back_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
2524
r4135r4136
989988
990989VIDEO_UPDATE( gticlub )
991990{
992   K001604_tile_update(screen->machine, 0);
993991   K001604_draw_back_layer(0, bitmap, cliprect);
994992
995993   K001005_draw(bitmap, cliprect);
src/mame/video/namcona1.c
r4135r4136
1919//UINT16 *namcona1_pixmap;
2020
2121/* private variables */
22static char *dirtychar;
23static char dirtygfx;
2422static UINT16 *shaperam;
2523static UINT16 *cgram;
2624static tilemap *roz_tilemap;
2725static int roz_palette;
28static int roz_dirty;
2926static tilemap *bg_tilemap[NAMCONA1_NUM_TILEMAPS];
3027static int tilemap_palette_bank[NAMCONA1_NUM_TILEMAPS];
3128static int palette_is_dirty;
r4135r4136
139136   }
140137   else if( offset<0xa000/2 )
141138   {
142      roz_dirty = 1;
139      tilemap_mark_all_tiles_dirty( roz_tilemap );
143140   }
144141} /* namcona1_videoram_w */
145142
r4135r4136
262259         old_word = shaperam[offset];
263260         COMBINE_DATA( &shaperam[offset] );
264261         if( shaperam[offset]!=old_word )
265         {
266            dirtygfx = 1;
267            dirtychar[offset/4] = 1;
268         }
262            gfx_element_mark_dirty(space->machine->gfx[2], offset/4);
269263      }
270264   }
271265   else if( type == 0x02 )
r4135r4136
274268      COMBINE_DATA( &cgram[offset] );
275269      if( cgram[offset]!=old_word )
276270      {
277         dirtygfx = 1;
278         dirtychar[offset/0x20] = 1;
271         gfx_element_mark_dirty(space->machine->gfx[0], offset/0x20);
272         gfx_element_mark_dirty(space->machine->gfx[1], offset/0x20);
279273      }
280274   }
281275} /* namcona1_gfxram_w */
282276
283277static void UpdateGfx(running_machine *machine)
284278{
285   const UINT16 *pSource = videoram16;
286   int page;
287   int i;
288
289   if( dirtygfx )
290   {
291      for( page = 0; page<NAMCONA1_NUM_TILEMAPS; page++ )
292      {
293         for( i=0; i<0x1000; i++ )
294         {
295            if( dirtychar[*pSource++ & 0xfff] )
296            {
297               tilemap_mark_tile_dirty( bg_tilemap[page], i );
298            }
299         }
300      }
301
302      for( i=0; i<0x1000; i++ )
303      {
304         if( dirtychar[*pSource++ & 0xfff] )
305         {
306            roz_dirty = 1;
307            break;
308         }
309      }
310
311      for( i = 0;i <0x1000; i++ )
312      {
313         if( dirtychar[i] )
314         {
315            dirtychar[i] = 0;
316            decodechar(machine->gfx[0],i,(UINT8 *)cgram);
317            decodechar(machine->gfx[1],i,(UINT8 *)cgram);
318            decodechar(machine->gfx[2],i,(UINT8 *)shaperam);
319         }
320      }
321      dirtygfx = 0;
322   }
323279} /* UpdateGfx */
324280
325281VIDEO_START( namcona1 )
326282{
327283   static const tile_get_info_func get_info[4] = { tilemap_get_info0, tilemap_get_info1, tilemap_get_info2, tilemap_get_info3 };
328284   int i;
329   gfx_element *gfx0,*gfx1,*gfx2;
330285
331286   roz_tilemap = tilemap_create( machine, roz_get_info, tilemap_scan_rows, 8,8,64,64 );
332287   roz_palette = -1;
r4135r4136
339294
340295   shaperam           = auto_malloc( 0x2000*4 );
341296   cgram              = auto_malloc( 0x1000*0x40 );
342   dirtychar           = auto_malloc( 0x1000 );
343297
344   gfx0 = allocgfx( machine, &cg_layout_8bpp );
345   gfx0->total_colors = machine->config->total_colors/256;
346   machine->gfx[0] = gfx0;
298   machine->gfx[0] = gfx_element_alloc( machine, &cg_layout_8bpp, (UINT8 *)cgram, machine->config->total_colors/256, 0 );
299   machine->gfx[1] = gfx_element_alloc( machine, &cg_layout_4bpp, (UINT8 *)cgram, machine->config->total_colors/16, 0 );
300   machine->gfx[2] = gfx_element_alloc( machine, &shape_layout, (UINT8 *)shaperam, machine->config->total_colors/2, 0 );
347301
348   gfx1 = allocgfx( machine, &cg_layout_4bpp );
349   gfx1->total_colors = machine->config->total_colors/16;
350   machine->gfx[1] = gfx1;
351
352   gfx2 = allocgfx( machine, &shape_layout );
353   gfx2->total_colors = machine->config->total_colors/2;
354   machine->gfx[2] = gfx2;
355302} /* namcona1_vh_start */
356303
357304/*************************************************************************/
r4135r4136
372319   const gfx_element *mask = machine->gfx[2];
373320
374321   int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
375   UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
376   UINT8 *mask_base = mask->gfxdata + (code % mask->total_elements) * mask->char_modulo;
322   const UINT8 *source_base = gfx_element_get_data(gfx, (code % gfx->total_elements));
323   const UINT8 *mask_base = gfx_element_get_data(mask, (code % mask->total_elements));
377324
378325   int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16;
379326   int sprite_screen_width  = ((1<<16)*gfx->width+0x8000)>>16;
r4135r4136
443390
444391         for( y=sy; y<ey; y++ )
445392         {
446            UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
447            UINT8 *mask_addr = mask_base + (y_index>>16) * mask->line_modulo;
393            const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
394            const UINT8 *mask_addr = mask_base + (y_index>>16) * mask->line_modulo;
448395            UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
449396            UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0);
450397
r4135r4136
714661         int color = namcona1_vreg[0xba/2]&0xf;
715662         if( color != roz_palette )
716663         {
717            roz_dirty = 1;
664            tilemap_mark_all_tiles_dirty( roz_tilemap );
718665            roz_palette = color;
719666         }
720667      }
721668
722      if( roz_dirty )
723      {
724         tilemap_mark_all_tiles_dirty( roz_tilemap );
725         roz_dirty = 0;
726      }
727
728669      bitmap_fill( priority_bitmap,cliprect ,0);
729670
730671      bitmap_fill( bitmap, cliprect , 0xff); /* background color? */
src/mame/video/appoooh.c
r4135r4136
145145   tilemap_set_transparent_pen(fg_tilemap,0);
146146   tilemap_set_scrolldy(fg_tilemap,8,8);
147147   tilemap_set_scrolldy(bg_tilemap,8,8);
148
149    state_save_register_global(machine, scroll_x);
150    state_save_register_global(machine, priority);
148151}
149152
150153WRITE8_HANDLER( appoooh_scroll_w )
src/mame/video/skyraid.c
r4135r4136
143143{
144144   bitmap_fill(bitmap, cliprect, 0);
145145
146   draw_terrain(screen->machine, helper, cliprect);
147   draw_sprites(screen->machine, helper, cliprect);
148   draw_missiles(screen->machine, helper, cliprect);
146   draw_terrain(screen->machine, helper, NULL);
147   draw_sprites(screen->machine, helper, NULL);
148   draw_missiles(screen->machine, helper, NULL);
149149   draw_trapezoid(screen->machine, bitmap, helper);
150150   draw_text(screen->machine, bitmap, cliprect);
151151   return 0;
src/mame/video/psx.c
r4135r4136
537537            }
538538            p_n_interleave[ n_x ] = m_p_p_vram[ n_yi ][ n_xi ];
539539         }
540         draw_scanline16( bitmap, 0, n_y, width, p_n_interleave, machine->pens, -1 );
540         draw_scanline16( bitmap, 0, n_y, width, p_n_interleave, machine->pens );
541541      }
542542   }
543543   return m_debug.b_texture;
r4135r4136
922922         n_line = n_lines;
923923         while( n_line > 0 )
924924         {
925            draw_scanline16( bitmap, n_x + n_left, n_y + n_top, n_columns, m_p_p_vram[ n_y + m_n_displaystarty ] + n_x + n_displaystartx, NULL, -1 );
925            draw_scanline16( bitmap, n_x + n_left, n_y + n_top, n_columns, m_p_p_vram[ n_y + m_n_displaystarty ] + n_x + n_displaystartx, NULL );
926926            n_y++;
927927            n_line--;
928928         }
src/mame/video/aliens.c
r4135r4136
8181   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,2);
8282   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,4);
8383
84   K051960_sprites_draw(bitmap,cliprect,-1,-1);
84   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
8585   return 0;
8686}
src/mame/video/88games.c
r4135r4136
8686   if (k88games_priority)
8787   {
8888      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],TILEMAP_DRAW_OPAQUE,0);
89      K051960_sprites_draw(bitmap,cliprect,1,1);
89      K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
9090      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
9191      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
92      K051960_sprites_draw(bitmap,cliprect,0,0);
92      K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
9393      K051316_zoom_draw_0(bitmap,cliprect,0,0);
9494   }
9595   else
9696   {
9797      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
9898      K051316_zoom_draw_0(bitmap,cliprect,0,0);
99      K051960_sprites_draw(bitmap,cliprect,0,0);
99      K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
100100      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
101      K051960_sprites_draw(bitmap,cliprect,1,1);
101      K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
102102      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
103103   }
104104   return 0;
src/mame/video/kaneko16.c
r4135r4136
437437      const rectangle *clip,int priority)
438438{
439439   pen_t pen_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
440   UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
440   const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
441441
442442   int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16;
443443   int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16;
r4135r4136
507507
508508         for( y=sy; y<ey; y++ )
509509         {
510            UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
510            const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
511511            UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
512512            UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0);
513513
src/mame/video/goldstar.c
r4135r4136
1010
1111
1212
13UINT8 *goldstar_video1, *goldstar_video2, *goldstar_video3;
14size_t goldstar_video_size;
13//UINT8 *goldstar_video1, *goldstar_video2, *goldstar_video3;
14//size_t goldstar_video_size;
1515UINT8 *goldstar_reel1_scroll, *goldstar_reel2_scroll, *goldstar_reel3_scroll;
1616
1717static int bgcolor;
r4135r4136
173173static const rectangle visible2 = { 0*8, (14+48)*8-1, 12*8, (12+7)*8-1 };
174174static const rectangle visible3 = { 0*8, (14+48)*8-1, 20*8, (20+7)*8-1 };
175175
176static const rectangle cm91_visible1 = { 0*8, (14+48)*8-1, 4*8,  (4+7)*8-1 };   /* same start for reel1 */
177static const rectangle cm91_visible2 = { 0*8, (14+48)*8-1, 11*8, (12+7)*8-1 };   /* 4 pixels less for reel2 */
178static const rectangle cm91_visible3 = { 0*8, (14+48)*8-1, 19*8, (19+7)*8-1 };   /* 8 pixels less for reel3 */
176179
180
177181VIDEO_UPDATE( goldstar )
178182{
179183   int i;
r4135r4136
195199
196200   return 0;
197201}
202
203VIDEO_UPDATE( cmast91 )
204{
205   int i;
206
207   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
208
209   for (i= 0;i < 64;i++)
210   {
211      tilemap_set_scrolly(goldstar_reel1_tilemap, i, goldstar_reel1_scroll[i]);
212      tilemap_set_scrolly(goldstar_reel2_tilemap, i, goldstar_reel2_scroll[i]);
213      tilemap_set_scrolly(goldstar_reel3_tilemap, i, goldstar_reel3_scroll[i]);
214   }
215
216   tilemap_draw(bitmap, &cm91_visible1, goldstar_reel1_tilemap, 0, 0);
217   tilemap_draw(bitmap, &cm91_visible2, goldstar_reel2_tilemap, 0, 0);
218   tilemap_draw(bitmap, &cm91_visible3, goldstar_reel3_tilemap, 0, 0);
219
220   tilemap_draw(bitmap, cliprect, goldstar_fg_tilemap, 0, 0);
221
222   return 0;
223}
src/mame/video/ms32.c
r4135r4136
283283   int xsize, ysize, xzoom, yzoom;
284284   int code, attr, color, size, pri, pri_mask, trans;
285285   gfx_element *gfx = machine->gfx[0];
286   gfx_element mygfx = *gfx;
287286
288287   UINT32      *source   = sprram_top;
289288   const UINT32   *finish   = sprram_top + (sprram_size - 0x20) / 4;
r4135r4136
346345         flipy = !flipy;
347346      }
348347
349      /* change GfxElement parameters to draw only the needed part of the 256x256 tile */
350      mygfx.width = xsize;
351      mygfx.height = ysize;
352      mygfx.gfxdata = gfx->gfxdata + tx + ty * gfx->line_modulo;
353
354348#if 0
355349if (input_code_pressed(KEYCODE_A) && (pri & 8)) color = rand();
356350if (input_code_pressed(KEYCODE_S) && (pri & 4)) color = rand();
r4135r4136
368362      else
369363         pri_mask = 0xfe;
370364
371      pdrawgfxzoom(bitmap, &mygfx,
365      gfx_element_set_source_clip(gfx, tx, xsize, ty, ysize);
366      pdrawgfxzoom(bitmap, gfx,
372367            code,
373368            color,
374369            flipx, flipy,
src/mame/video/spbactn.c
r4135r4136
9090               int x = sx + 8 * (flipx ? (size - 1 - col) : col);
9191               int y = sy + 8 * (flipy ? (size - 1 - row) : row);
9292
93               drawgfx(bitmap, machine->gfx[2],
93               drawgfx_transpen_raw(bitmap, cliprect, machine->gfx[2],
9494                  code + layout[row][col],
9595                  machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
9696                  flipx, flipy,
9797                  x, y,
98                  cliprect, TRANSPARENCY_PEN_RAW, 0);
98                  0);
9999            }
100100         }
101101
r4135r4136
133133
134134      color = ((attr & 0x00f0) >> 4) | 0x80;
135135
136      drawgfx(tile_bitmap_bg, screen->machine->gfx[1],
136      drawgfx_transpen_raw(tile_bitmap_bg, cliprect, screen->machine->gfx[1],
137137               code,
138138               screen->machine->gfx[1]->color_base + color * screen->machine->gfx[1]->color_granularity,
139139               0, 0,
140140               16 * sx, 8 * sy,
141               cliprect, TRANSPARENCY_PEN_RAW, -1);
141               -1);
142142
143143      sx++;
144144      if (sx > 63)
r4135r4136
160160
161161         color = ((attr & 0x00f0) >> 4) | 0x80;
162162
163         drawgfx(tile_bitmap_bg, screen->machine->gfx[1],
163         drawgfx_transpen_raw(tile_bitmap_bg, cliprect, screen->machine->gfx[1],
164164               code,
165165               screen->machine->gfx[1]->color_base + color * screen->machine->gfx[1]->color_granularity,
166166               0, 0,
167167               16 * sx, 8 * sy,
168               cliprect, TRANSPARENCY_PEN_RAW, 0);
168               0);
169169
170170         sx++;
171171         if (sx > 63)
r4135r4136
194194      else
195195         color |= 0x0080;
196196
197      drawgfx(tile_bitmap_fg, screen->machine->gfx[0],
197      drawgfx_transpen_raw(tile_bitmap_fg, cliprect, screen->machine->gfx[0],
198198               code,
199199               screen->machine->gfx[0]->color_base + color * screen->machine->gfx[0]->color_granularity,
200200               0, 0,
201201               16 * sx, 8 * sy,
202               cliprect, TRANSPARENCY_PEN_RAW, 0);
202               0);
203203
204204      sx++;
205205      if (sx > 63)
src/mame/video/atarimo.c
r4135r4136
862862               continue;
863863
864864            /* draw the sprite */
865            drawgfx(bitmap, gfx, code, color, hflip, vflip, sx, sy, cliprect, TRANSPARENCY_PEN_RAW, mo->transpen);
865            drawgfx_transpen_raw(bitmap, cliprect, gfx, code, color, hflip, vflip, sx, sy, mo->transpen);
866866            rendered = 1;
867867
868868            /* mark the grid dirty */
r4135r4136
899899               continue;
900900
901901            /* draw the sprite */
902            drawgfx(bitmap, gfx, code, color, hflip, vflip, sx, sy, cliprect, TRANSPARENCY_PEN_RAW, mo->transpen);
902            drawgfx_transpen_raw(bitmap, cliprect, gfx, code, color, hflip, vflip, sx, sy, mo->transpen);
903903            rendered = 1;
904904
905905            /* mark the grid dirty */
src/mame/video/polepos.c
r4135r4136
423423      }
424424
425425      /* draw the scanline */
426      draw_scanline16(bitmap, 0, y, 256, &scanline[xscroll], NULL, -1);
426      draw_scanline16(bitmap, 0, y, 256, &scanline[xscroll], NULL);
427427   }
428428}
429429
r4135r4136
432432      int sizex,int sizey)
433433{
434434   const gfx_element *gfx = machine->gfx[big ? 3 : 2];
435   UINT8 *gfxdata = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
435   const UINT8 *gfxdata = gfx_element_get_data(gfx, code % gfx->total_elements);
436436   UINT8 *scaling_rom = memory_region(machine, "gfx6");
437437   UINT32 transmask = colortable_get_transpen_mask(machine->colortable, gfx, color, 0x1f);
438438   int coloroffs = gfx->color_base + color * gfx->color_granularity;
r4135r4136
451451         int xx = sx & 0x3ff;
452452         int siz = 0;
453453         int offs = 0;
454         UINT8 *src;
454         const UINT8 *src;
455455
456456         if (!big) dy >>= 1;
457457         src = gfxdata + dy * gfx->line_modulo;
src/mame/video/model1.c
r4135r4136
14601460
14611461VIDEO_UPDATE(model1)
14621462{
1463   sys24_tile_update(screen->machine);
14641463#if 0
14651464   {
14661465      int mod = 0;
src/mame/video/taito_b.c
r4135r4136
430430
431431    if ( zoomx || zoomy )
432432    {
433      drawgfxzoom (bitmap,machine->gfx[1],
433      drawgfxzoom_transpen_raw (bitmap,cliprect,machine->gfx[1],
434434        code,
435435        color,
436436        flipx,flipy,
437437        x,y,
438        cliprect,
439        TRANSPARENCY_PEN_RAW,0,(zx << 16) / 16,(zy << 16) / 16);
438        (zx << 16) / 16,(zy << 16) / 16,0);
440439    }
441440    else
442441    {
443      drawgfx (bitmap,machine->gfx[1],
442      drawgfx_transpen_raw (bitmap,cliprect,machine->gfx[1],
444443        code,
445444        color,
446445        flipx,flipy,
447446        x,y,
448        cliprect,
449        TRANSPARENCY_PEN_RAW,0);
447        0);
450448    }
451449  }
452450}
src/mame/video/taitoic.c
r4135r4136
533533***************************************************************************/
534534
535535#include "driver.h"
536#include "drawgfxm.h"
536537#include "taitoic.h"
537538
538539#define TOPSPEED_ROAD_COLORS
r4135r4136
13441345
13451346static tilemap *TC0080VCO_tilemap[3];
13461347
1347static UINT8 *TC0080VCO_char_dirty;
1348static int TC0080VCO_chars_dirty;
13491348static int TC0080VCO_bg_gfx,TC0080VCO_tx_gfx;
13501349static int TC0080VCO_bg_xoffs,TC0080VCO_bg_yoffs;
13511350static int TC0080VCO_bg_flip_yoffs;
r4135r4136
14791478   TC0080VCO_scroll_ram    = TC0080VCO_ram + 0x20800/2;
14801479}
14811480
1482static void TC0080VCO_dirty_chars(void)
1483{
1484   memset(TC0080VCO_char_dirty,1,TC0080VCO_TOTAL_CHARS);
1485   TC0080VCO_chars_dirty = 1;
1486}
1487
14881481static void TC0080VCO_restore_scroll(void)
14891482{
14901483   TC0080VCO_flipscreen = TC0080VCO_scroll_ram[0] & 0x0c00;
r4135r4136
15031496static STATE_POSTLOAD( TC0080VCO_postload )
15041497{
15051498   TC0080VCO_set_layer_ptrs();
1506   TC0080VCO_dirty_chars();
15071499   TC0080VCO_restore_scroll();
15081500}
15091501
r4135r4136
15401532   /* Perform extra initialisations for text layer */
15411533   {
15421534      TC0080VCO_tilemap[2] = tilemap_create(machine, TC0080VCO_get_tx_tile_info,tilemap_scan_rows,8,8,64,64);
1543      TC0080VCO_char_dirty = auto_malloc(TC0080VCO_TOTAL_CHARS);
15441535
1545      TC0080VCO_dirty_chars();
1546
15471536       /* find first empty slot to decode gfx */
15481537      for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++)
15491538         if (machine->gfx[gfx_index] == 0)
r4135r4136
15511540      assert(gfx_index != MAX_GFX_ELEMENTS);
15521541
15531542      /* create the char set (gfx will then be updated dynamically from RAM) */
1554      machine->gfx[gfx_index] = allocgfx(machine, &TC0080VCO_charlayout);
1555
1556      /* set the color information */
1557      machine->gfx[gfx_index]->total_colors = 64;   // is this correct ?
1543      machine->gfx[gfx_index] = gfx_element_alloc(machine, &TC0080VCO_charlayout, (UINT8 *)TC0080VCO_char_ram, 64, 0);
15581544      TC0080VCO_tx_gfx = gfx_index;
15591545
15601546      tilemap_set_scrolldx(TC0080VCO_tilemap[2],0,0);
r4135r4136
16121598
16131599   if (offset < 0x1000/2)
16141600   {
1615      TC0080VCO_char_dirty[offset / 8] = 1;
1616      TC0080VCO_chars_dirty = 1;
1601      gfx_element_mark_dirty(space->machine->gfx[TC0080VCO_tx_gfx], offset / 8);
16171602#if 0
16181603      if (!TC0080VCO_has_tx)
16191604      {
r4135r4136
16441629
16451630   else if (offset < 0x11000/2)
16461631   {
1647      TC0080VCO_char_dirty[(offset - 0x10000/2) / 8] = 1;
1648      TC0080VCO_chars_dirty = 1;
1632      gfx_element_mark_dirty(space->machine->gfx[TC0080VCO_tx_gfx], (offset - 0x10000/2) / 8);
16491633#if 0
16501634      if (!TC0080VCO_has_tx)
16511635      {
r4135r4136
17001684   tilemap_set_scrolly(TC0080VCO_tilemap[1],0, TC0080VCO_bg1_scrolly);
17011685   tilemap_set_scrollx(TC0080VCO_tilemap[2],0,0);   /* no scroll (maybe) */
17021686   tilemap_set_scrolly(TC0080VCO_tilemap[2],0,0);
1703
1704   /* Decode any characters that have changed */
1705
1706   if (TC0080VCO_chars_dirty)
1707   {
1708      int tile_index;
1709
1710      for (tile_index = 0;tile_index < 64*64;tile_index++)
1711      {
1712         int attr = TC0080VCO_tx_ram_0[tile_index >> 1];
1713
1714         /* should this be reversed in flipscreen ?? */
1715         if (tile_index & 1)   /* each word has 2 chars */
1716         {
1717            attr = (attr &0xff);
1718         }
1719         else
1720         {
1721            attr = (attr &0xff00) >> 8;
1722         }
1723
1724         if (TC0080VCO_char_dirty[attr])
1725            tilemap_mark_tile_dirty(TC0080VCO_tilemap[2],tile_index);
1726      }
1727
1728      for (j = 0;j < TC0080VCO_TOTAL_CHARS;j++)
1729      {
1730         if (TC0080VCO_char_dirty[j])
1731            decodechar(machine->gfx[TC0080VCO_tx_gfx],j,
1732               (UINT8 *)TC0080VCO_char_ram);
1733         TC0080VCO_char_dirty[j] = 0;
1734      }
1735      TC0080VCO_chars_dirty = 0;
1736   }
17371687}
17381688
17391689
r4135r4136
18931843}
18941844
18951845
1846#define PIXEL_OP_COPY_TRANS0_SET_PRIORITY(DEST, PRIORITY, SOURCE)                \
1847do                                                               \
1848{                                                               \
1849   UINT32 srcdata = (SOURCE);                                          \
1850   if (srcdata != 0)                                                \
1851   {                                                            \
1852      (DEST) = SOURCE;                                             \
1853      (PRIORITY) = privalue;                                          \
1854   }                                                            \
1855}                                                               \
1856while (0)                                                         \
1857
18961858static void TC0080VCO_bg1_tilemap_draw(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int flags,UINT32 priority)
18971859{
18981860   UINT8 layer=1;
r4135r4136
19591921               - (max_y + min_y) * (zy-0x10000);
19601922      }
19611923
1962      copyrozbitmap(bitmap,srcbitmap,
1963         sx, sy,
1964         zx, 0, 0, zy,
1965         0,               /* why no wraparound ?? */
1966         cliprect,
1967         TRANSPARENCY_PEN, 0, priority);
1924      {
1925         bitmap_t *dest = bitmap;
1926         bitmap_t *src = srcbitmap;
1927         INT32 startx = sx;
1928         INT32 starty = sy;
1929         INT32 incxx = zx;
1930         INT32 incxy = 0;
1931         INT32 incyx = 0;
1932         INT32 incyy = zy;
1933         int wraparound = 0;
1934         UINT32 privalue = priority;
1935         bitmap_t *priority = priority_bitmap;
1936
1937         if (dest->bpp == 16)
1938            COPYROZBITMAP_CORE(UINT16, PIXEL_OP_COPY_TRANS0_SET_PRIORITY, UINT8);
1939         else
1940            COPYROZBITMAP_CORE(UINT32, PIXEL_OP_COPY_TRANS0_SET_PRIORITY, UINT8);
1941      }
19681942   }
19691943}
19701944
r4135r4136
20251999static tilemap *TC0100SCN_tilemap[TC0100SCN_MAX_CHIPS][3][2];
20262000static rectangle TC0100SCN_cliprect[TC0100SCN_MAX_CHIPS];
20272001
2028static char *TC0100SCN_char_dirty[TC0100SCN_MAX_CHIPS];
2029static int TC0100SCN_chars_dirty[TC0100SCN_MAX_CHIPS];
20302002static int TC0100SCN_bg_gfx[TC0100SCN_MAX_CHIPS],TC0100SCN_tx_gfx[TC0100SCN_MAX_CHIPS];
20312003static int TC0100SCN_bg_col_mult,TC0100SCN_bg_tilemask,TC0100SCN_tx_col_mult;
20322004static INT32 TC0100SCN_gfxbank,TC0100SCN_chip_colbank[3],TC0100SCN_colbank[3];
r4135r4136
22262198   tilemap_mark_all_tiles_dirty(TC0100SCN_tilemap[chip][2][TC0100SCN_dblwidth[chip]]);
22272199}
22282200
2229static void TC0100SCN_dirty_chars(int chip)
2230{
2231   memset(TC0100SCN_char_dirty[chip],1,TC0100SCN_TOTAL_CHARS);
2232   TC0100SCN_chars_dirty[chip] = 1;
2233}
2234
22352201static void TC0100SCN_restore_scroll(int chip)
22362202{
22372203   int flip;
r4135r4136
22612227   int chip = (FPTR)param;
22622228
22632229   TC0100SCN_set_layer_ptrs(chip);
2264   TC0100SCN_dirty_chars(chip);
22652230   TC0100SCN_restore_scroll(chip);
22662231}
22672232
r4135r4136
23042269      TC0100SCN_cliprect[i] = myclip;
23052270
23062271      TC0100SCN_ram[i] = auto_malloc(TC0100SCN_RAM_SIZE);
2307      TC0100SCN_char_dirty[i] = auto_malloc(TC0100SCN_TOTAL_CHARS);
23082272
23092273      TC0100SCN_set_layer_ptrs(i);
2310      TC0100SCN_dirty_chars(i);
23112274      memset(TC0100SCN_ram[i],0,TC0100SCN_RAM_SIZE);
23122275
23132276      {
r4135r4136
23252288      assert(gfx_index != MAX_GFX_ELEMENTS);
23262289
23272290      /* create the char set (gfx will then be updated dynamically from RAM) */
2328      machine->gfx[gfx_index] = allocgfx(machine, &TC0100SCN_charlayout);
2329
2330      /* set the color information */
2331      machine->gfx[gfx_index]->total_colors = 64;
2332
2291      machine->gfx[gfx_index] = gfx_element_alloc(machine, &TC0100SCN_charlayout, (UINT8 *)TC0100SCN_char_ram[i], 64, 0);
23332292      TC0100SCN_tx_gfx[i] = gfx_index;
23342293
23352294      /* use the given gfx set for bg tiles; 2nd/3rd chips will
r4135r4136
24312390   return TC0100SCN_ram[2][offset];
24322391}
24332392
2434static void TC0100SCN_word_w(int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
2393static void TC0100SCN_word_w(const address_space *space,int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
24352394{
24362395   COMBINE_DATA(&TC0100SCN_ram[chip][offset]);
24372396   if (!TC0100SCN_dblwidth[chip])
r4135r4136
24412400      else if (offset < 0x3000)
24422401         tilemap_mark_tile_dirty(TC0100SCN_tilemap[chip][2][0],(offset & 0x0fff));
24432402      else if (offset < 0x3800)
2444      {
2445         TC0100SCN_char_dirty[chip][(offset - 0x3000) / 8] = 1;
2446         TC0100SCN_chars_dirty[chip] = 1;
2447      }
2403         gfx_element_mark_dirty(space->machine->gfx[TC0100SCN_tx_gfx[chip]], (offset - 0x3000) / 8);
24482404      else if (offset >= 0x4000 && offset < 0x6000)
24492405         tilemap_mark_tile_dirty(TC0100SCN_tilemap[chip][1][0],(offset & 0x1fff) / 2);
24502406   }
r4135r4136
24552411      else if (offset >= 0x4000 && offset < 0x8000)
24562412         tilemap_mark_tile_dirty(TC0100SCN_tilemap[chip][1][1],(offset & 0x3fff) / 2);
24572413      else if (offset >= 0x8800 && offset < 0x9000)
2458      {
2459         TC0100SCN_char_dirty[chip][(offset - 0x8800) / 8] = 1;
2460         TC0100SCN_chars_dirty[chip] = 1;
2461      }
2414         gfx_element_mark_dirty(space->machine->gfx[TC0100SCN_tx_gfx[chip]], (offset - 0x8800) / 8);
24622415      else if (offset >= 0x9000)
24632416         tilemap_mark_tile_dirty(TC0100SCN_tilemap[chip][2][1],(offset & 0x0fff));
24642417   }
r4135r4136
24662419
24672420WRITE16_HANDLER( TC0100SCN_word_0_w )
24682421{
2469   TC0100SCN_word_w(0,offset,data,mem_mask);
2422   TC0100SCN_word_w(space,0,offset,data,mem_mask);
24702423}
24712424
24722425WRITE16_HANDLER( TC0100SCN_word_1_w )
24732426{
2474   TC0100SCN_word_w(1,offset,data,mem_mask);
2427   TC0100SCN_word_w(space,1,offset,data,mem_mask);
24752428}
24762429
24772430WRITE16_HANDLER( TC0100SCN_word_2_w )
24782431{
2479   TC0100SCN_word_w(2,offset,data,mem_mask);
2432   TC0100SCN_word_w(space,2,offset,data,mem_mask);
24802433}
24812434
24822435WRITE16_HANDLER( TC0100SCN_dual_screen_w )
r4135r4136
25092462}
25102463
25112464
2512static void TC0100SCN_ctrl_word_w(int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
2465static void TC0100SCN_ctrl_word_w(const address_space *space,int chip,offs_t offset,UINT16 data,UINT32 mem_mask)
25132466{
25142467   COMBINE_DATA(&TC0100SCN_ctrl[chip][offset]);
25152468
r4135r4136
25552508
25562509            /* and ensure full redraw of the tilemaps */
25572510            TC0100SCN_dirty_tilemaps(chip);
2511
2512            /* reset the pointer to the text characters (and dirty them all) */
2513            gfx_element_set_source(space->machine->gfx[TC0100SCN_tx_gfx[chip]], (UINT8 *)TC0100SCN_char_ram[chip]);
25582514         }
25592515
25602516         break;
r4135r4136
25782534
25792535WRITE16_HANDLER( TC0100SCN_ctrl_word_0_w )
25802536{
2581   TC0100SCN_ctrl_word_w(0,offset,data,mem_mask);
2537   TC0100SCN_ctrl_word_w(space,0,offset,data,mem_mask);
25822538}
25832539
25842540WRITE16_HANDLER( TC0100SCN_ctrl_word_1_w )
25852541{
2586   TC0100SCN_ctrl_word_w(1,offset,data,mem_mask);
2542   TC0100SCN_ctrl_word_w(space,1,offset,data,mem_mask);
25872543}
25882544
25892545WRITE16_HANDLER( TC0100SCN_ctrl_word_2_w )
25902546{
2591   TC0100SCN_ctrl_word_w(2,offset,data,mem_mask);
2547   TC0100SCN_ctrl_word_w(space,2,offset,data,mem_mask);
25922548}
25932549
25942550
r4135r4136
25992555
26002556WRITE32_HANDLER( TC0100SCN_ctrl_long_w )
26012557{
2602   if (ACCESSING_BITS_16_31) TC0100SCN_ctrl_word_w(0,offset*2,data>>16,mem_mask>>16);
2603   if (ACCESSING_BITS_0_15) TC0100SCN_ctrl_word_w(0,(offset*2)+1,data&0xffff,mem_mask&0xffff);
2558   if (ACCESSING_BITS_16_31) TC0100SCN_ctrl_word_w(space,0,offset*2,data>>16,mem_mask>>16);
2559   if (ACCESSING_BITS_0_15) TC0100SCN_ctrl_word_w(space,0,(offset*2)+1,data&0xffff,mem_mask&0xffff);
26042560}
26052561
26062562READ32_HANDLER( TC0100SCN_long_r )
r4135r4136
26502606         tilemap_set_scrollx(TC0100SCN_tilemap[chip][1][TC0100SCN_dblwidth[chip]],
26512607               (j + TC0100SCN_fgscrolly[chip]) & 0x1ff,
26522608               TC0100SCN_fgscrollx[chip] - TC0100SCN_fgscroll_ram[chip][j]);
2653
2654      /* Decode any characters that have changed */
2655      if (TC0100SCN_chars_dirty[chip])
2656      {
2657         int tile_index;
2658
2659
2660         for (tile_index = 0;tile_index < 64*64;tile_index++)
2661         {
2662            int attr = TC0100SCN_tx_ram[chip][tile_index];
2663            if (TC0100SCN_char_dirty[chip][attr & 0xff])
2664               tilemap_mark_tile_dirty(TC0100SCN_tilemap[chip][2][TC0100SCN_dblwidth[chip]],tile_index);
2665         }
2666
2667         for (j = 0;j < TC0100SCN_TOTAL_CHARS;j++)
2668         {
2669            if (TC0100SCN_char_dirty[chip][j])
2670               decodechar(machine->gfx[TC0100SCN_tx_gfx[chip]],j,
2671               (UINT8 *)TC0100SCN_char_ram[chip]);
2672            TC0100SCN_char_dirty[chip][j] = 0;
2673         }
2674         TC0100SCN_chars_dirty[chip] = 0;
2675      }
26762609   }
26772610}
26782611
r4135r4136
29472880
29482881/* We keep two tilemaps for each of the 5 actual tilemaps: one at standard width, one double */
29492882static tilemap *TC0480SCP_tilemap[5][2];
2950static char *TC0480SCP_char_dirty;
2951static int TC0480SCP_chars_dirty;
29522883static int TC0480SCP_bg_gfx,TC0480SCP_tx_gfx;
29532884static INT32 TC0480SCP_tile_colbase,TC0480SCP_dblwidth;
29542885static int TC0480SCP_x_offs,TC0480SCP_y_offs;
r4135r4136
30723003   tilemap_mark_all_tiles_dirty(TC0480SCP_tilemap[4][TC0480SCP_dblwidth]);
30733004}
30743005
3075static void TC0480SCP_dirty_chars(void)
3076{
3077   memset(TC0480SCP_char_dirty,1,TC0480SCP_TOTAL_CHARS);
3078   TC0480SCP_chars_dirty = 1;
3079}
3080
30813006static void TC0480SCP_restore_scroll(void)
30823007{
30833008   int reg;
r4135r4136
31443069static STATE_POSTLOAD( TC0480SCP_postload )
31453070{
31463071   TC0480SCP_set_layer_ptrs();
3147   TC0480SCP_dirty_chars();
31483072   TC0480SCP_restore_scroll();
31493073}
31503074
r4135r4136
31763100      TC0480SCP_tilemap[4][1] = tilemap_create(machine, tc480_get_tile_info[4],tilemap_scan_rows,8,8,64,64);
31773101
31783102      TC0480SCP_ram = auto_malloc(TC0480SCP_RAM_SIZE);
3179      TC0480SCP_char_dirty = auto_malloc(TC0480SCP_TOTAL_CHARS);
31803103
31813104      TC0480SCP_set_layer_ptrs();
3182      TC0480SCP_dirty_chars();
31833105      memset(TC0480SCP_ram,0,TC0480SCP_RAM_SIZE);
31843106
31853107      state_save_register_global_pointer(machine, TC0480SCP_ram, TC0480SCP_RAM_SIZE/2);
r4135r4136
31943116      assert(gfx_index != MAX_GFX_ELEMENTS);
31953117
31963118      /* create the char set (gfx will then be updated dynamically from RAM) */
3197      machine->gfx[gfx_index] = allocgfx(machine, &TC0480SCP_charlayout);
3198
3199      /* set the color information */
3200      machine->gfx[gfx_index]->total_colors = 64;
3201
3119      machine->gfx[gfx_index] = gfx_element_alloc(machine, &TC0480SCP_charlayout, (UINT8 *)TC0480SCP_char_ram, 64, 0);
32023120      TC0480SCP_tx_gfx = gfx_index;
32033121
32043122      /* use the given gfx set for bg tiles */
r4135r4136
33083226   return TC0480SCP_ram[offset];
33093227}
33103228
3311static void TC0480SCP_word_write(offs_t offset,UINT16 data,UINT32 mem_mask)
3229static void TC0480SCP_word_write(const address_space *space,offs_t offset,UINT16 data,UINT32 mem_mask)
33123230{
33133231   COMBINE_DATA(&TC0480SCP_ram[offset]);
33143232
r4135r4136
33293247      }
33303248      else if (offset <= 0x7fff)
33313249      {
3332         TC0480SCP_char_dirty[(offset - 0x7000) / 16] = 1;
3333         TC0480SCP_chars_dirty = 1;
3250         gfx_element_mark_dirty(space->machine->gfx[TC0480SCP_tx_gfx], (offset - 0x7000) / 16);
33343251      }
33353252   }
33363253   else
r4135r4136
33503267      }
33513268      else if (offset <= 0x7fff)
33523269      {
3353         TC0480SCP_char_dirty[(offset - 0x7000) / 16] = 1;
3354         TC0480SCP_chars_dirty = 1;
3270         gfx_element_mark_dirty(space->machine->gfx[TC0480SCP_tx_gfx], (offset - 0x7000) / 16);
33553271      }
33563272   }
33573273}
33583274
33593275WRITE16_HANDLER( TC0480SCP_word_w )
33603276{
3361   TC0480SCP_word_write(offset,data,mem_mask);
3277   TC0480SCP_word_write(space,offset,data,mem_mask);
33623278}
33633279
33643280READ16_HANDLER( TC0480SCP_ctrl_word_r )
r4135r4136
35233439         }
35243440      }
35253441   }
3526
3527   /* Decode any characters that have changed */
3528   if (TC0480SCP_chars_dirty)
3529   {
3530      int tile_index;
3531
3532      for (tile_index = 0;tile_index < 64*64;tile_index++)
3533      {
3534         int attr = TC0480SCP_tx_ram[tile_index];
3535         if (TC0480SCP_char_dirty[attr & 0xff])
3536            tilemap_mark_tile_dirty(TC0480SCP_tilemap[4][TC0480SCP_dblwidth],tile_index);
3537      }
3538
3539      for (j = 0;j < TC0480SCP_TOTAL_CHARS;j++)
3540      {
3541         if (TC0480SCP_char_dirty[j])
3542            decodechar(machine->gfx[TC0480SCP_tx_gfx],j,
3543               (UINT8 *)TC0480SCP_char_ram);
3544         TC0480SCP_char_dirty[j] = 0;
3545      }
3546      TC0480SCP_chars_dirty = 0;
3547   }
35483442}
35493443
35503444
src/mame/video/namcos86.c
r4135r4136
267267   const UINT8 *source = &spriteram[0x0800-0x20];   /* the last is NOT a sprite */
268268   const UINT8 *finish = &spriteram[0];
269269   gfx_element *gfx = machine->gfx[2];
270   gfx_element mygfx = *gfx;
271270
272271   int sprite_xoffs = spriteram[0x07f5] + ((spriteram[0x07f4] & 1) << 8);
273272   int sprite_yoffs = spriteram[0x07f7];
r4135r4136
310309
311310      sy++;   /* sprites are buffered and delayed by one scanline */
312311
313      /* change GfxElement parameters to draw only the needed part of the 32x32 tile */
314      mygfx.width = sizex;
315      mygfx.height = sizey;
316      mygfx.gfxdata = gfx->gfxdata + tx + ty * gfx->line_modulo;
317
318      pdrawgfx( bitmap, &mygfx,
312      gfx_element_set_source_clip(gfx, tx, sizex, ty, sizey);
313      pdrawgfx( bitmap, gfx,
319314            sprite,
320315            color,
321316            flipx,flipy,
src/mame/video/btime.c
r4135r4136
2626static UINT8 bnj_scroll2 = 0;
2727static bitmap_t *background_bitmap;
2828
29static UINT8 *sprite_dirty, *char_dirty;
30
3129/***************************************************************************
3230
3331    Burger Time doesn't have a color PROM. It uses RAM to dynamically
r4135r4136
141139    bnj_scroll2 = 0;
142140    btime_palette = 0;
143141
144   sprite_dirty = auto_malloc(256 * sizeof(*sprite_dirty));
145   memset(sprite_dirty, 1, 256 * sizeof(*sprite_dirty));
146
147   char_dirty = auto_malloc(1024 * sizeof(*char_dirty));
148   memset(char_dirty, 1, 1024 * sizeof(*char_dirty));
142   if (machine->gfx[0]->srcdata == NULL)
143      gfx_element_set_source(machine->gfx[0], deco_charram);
144   if (machine->gfx[1]->srcdata == NULL)
145      gfx_element_set_source(machine->gfx[1], deco_charram);
149146}
150147
151148
r4135r4136
242239    offset &= 0x1fff;
243240
244241    /* dirty sprite */
245    sprite_dirty[offset >> 5] = 1;
242    gfx_element_mark_dirty(space->machine->gfx[1], offset >> 5);
246243
247244    /* diry char */
248    char_dirty  [offset >> 3] = 1;
245    gfx_element_mark_dirty(space->machine->gfx[0], offset >> 3);
249246}
250247
251248WRITE8_HANDLER( bnj_background_w )
r4135r4136
431428}
432429
433430
434static void decode_modified(running_machine *machine, UINT8 *sprite_ram, int interleave)
435{
436    int i,offs;
437
438
439    /* decode dirty characters */
440    for (offs = btime_videoram_size - 1;offs >= 0;offs--)
441    {
442        int code;
443
444        code = btime_videoram[offs] + 256 * (btime_colorram[offs] & 3);
445
446        if (char_dirty[code])
447        {
448            decodechar(machine->gfx[0],code,deco_charram);
449
450            char_dirty[code] = 0;
451        }
452    }
453
454    /* decode dirty sprites */
455    for (i = 0, offs = 0;i < 8; i++, offs += 4*interleave)
456    {
457        int code;
458
459        code  = sprite_ram[offs + interleave];
460
461        if (sprite_dirty[code])
462        {
463            decodechar(machine->gfx[1],code,deco_charram);
464
465            sprite_dirty[code] = 0;
466        }
467    }
468}
469
470
471431VIDEO_UPDATE( btime )
472432{
473433    if (bnj_scroll1 & 0x10)
r4135r4136
620580
621581VIDEO_UPDATE( disco )
622582{
623    decode_modified(screen->machine, spriteram, 1);
624583    draw_chars(screen->machine, bitmap, cliprect, TRANSPARENCY_NONE, btime_palette, -1);
625584    draw_sprites(screen->machine, bitmap, cliprect, btime_palette, 0, 0, spriteram, 1);
626585
r4135r4136
630589
631590VIDEO_UPDATE( progolf )
632591{
633   decode_modified(screen->machine, spriteram, 1);
634592   draw_chars(screen->machine, bitmap, cliprect, TRANSPARENCY_NONE, /*btime_palette*/0, -1);
635593//  draw_sprites(screen->machine, bitmap, cliprect, 0/*btime_palette*/, 0, 0, spriteram, 1);
636594
src/mame/video/bbusters.c
r4135r4136
108108
109109INLINE const UINT8 *get_source_ptr(gfx_element *gfx, UINT32 sprite, int dx, int dy, int block)
110110{
111   int source_base,code=0;
111   int code=0;
112112
113113   /* Get a tile index from the x,y position in the block */
114114   switch (block)
r4135r4136
141141      break;
142142   }
143143
144   source_base=((sprite+code) % gfx->total_elements) * 16;
145   return gfx->gfxdata + ((source_base+(dy%16)) * gfx->line_modulo);
144   return gfx_element_get_data(gfx, (sprite+code) % gfx->total_elements) + ((dy%16) * gfx->line_modulo);
146145}
147146
148147static void bbusters_draw_block(running_machine *machine, bitmap_t *dest,int x,int y,int size,int flipx,int flipy,UINT32 sprite,int color,int bank,int block)
src/mame/video/snk.c
r4135r4136
3333static int sp16_scrollx, sp16_scrolly, sp32_scrollx, sp32_scrolly;
3434static UINT8 sprite_split_point;
3535static int num_sprites, yscroll_mask;
36static UINT32 bg_tile_offset;
37static UINT32 tx_tile_offset;
3638
3739static UINT8 empty_tile[16*16];
40static UINT8 drawmode_table[16];
3841
3942/**************************************************************************************/
4043
r4135r4136
8790   int code = snk_tx_videoram[tile_index];
8891   int color = code >> 5;
8992   SET_TILE_INFO(0,
90         code,
93         tx_tile_offset + code,
9194         color,
9295         tile_index & 0x400 ? TILE_FORCE_LAYER0 : 0);
9396}
r4135r4136
9699{
97100   int code = snk_tx_videoram[tile_index];
98101   SET_TILE_INFO(0,
99         code,
102         tx_tile_offset + code,
100103         0,
101104         tile_index & 0x400 ? TILE_FORCE_LAYER0 : 0);
102105}
r4135r4136
105108{
106109   int code = snk_tx_videoram[tile_index];
107110   SET_TILE_INFO(0,
108         code,
111         tx_tile_offset + code,
109112         0,
110113         0);
111114}
r4135r4136
134137{
135138   int code = snk_bg_videoram[tile_index];
136139   SET_TILE_INFO(1,
137         code,
140         bg_tile_offset + code,
138141         0,
139142         0);
140143}
r4135r4136
189192      fatalerror("driver should use VIDEO_HAS_SHADOWS");
190193
191194   /* prepare shadow draw table */
192   for(i = 0; i <= 5; i++) gfx_drawmode_table[i] = DRAWMODE_SOURCE;
193   gfx_drawmode_table[6] = DRAWMODE_SHADOW;
194   gfx_drawmode_table[7] = DRAWMODE_NONE;
195   for(i = 0; i <= 5; i++) drawmode_table[i] = DRAWMODE_SOURCE;
196   drawmode_table[6] = (machine->config->video_attributes & VIDEO_HAS_SHADOWS) ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
197   drawmode_table[7] = DRAWMODE_NONE;
195198
196199   for (i = 0x000;i < 0x400;i++)
197200      machine->shadow_table[i] = i | 0x200;
r4135r4136
205208      fatalerror("driver should use VIDEO_HAS_SHADOWS");
206209
207210   /* prepare shadow draw table */
208   for(i = 0; i <= 13; i++) gfx_drawmode_table[i] = DRAWMODE_SOURCE;
209   gfx_drawmode_table[14] = DRAWMODE_SHADOW;
210   gfx_drawmode_table[15] = DRAWMODE_NONE;
211   for(i = 0; i <= 13; i++) drawmode_table[i] = DRAWMODE_SOURCE;
212   drawmode_table[14] = DRAWMODE_SHADOW;
213   drawmode_table[15] = DRAWMODE_NONE;
211214
212215   /* all palette entries are not affected by shadow sprites... */
213216   for (i = 0x000;i < 0x400;i++)
r4135r4136
235238
236239   tilemap_set_scrolldx(bg_tilemap, 15,  31);
237240   tilemap_set_scrolldy(bg_tilemap,  8, -32);
241
242   tx_tile_offset = 0;
238243}
239244
240245VIDEO_START( jcross )
r4135r4136
252257
253258   num_sprites = 25;
254259   yscroll_mask = 0x1ff;
260   bg_tile_offset = 0;
261   tx_tile_offset = 0;
255262}
256263
257264VIDEO_START( sgladiat )
r4135r4136
269276
270277   num_sprites = 25;
271278   yscroll_mask = 0x0ff;
279   bg_tile_offset = 0;
280   tx_tile_offset = 0;
272281}
273282
274283VIDEO_START( hal21 )
r4135r4136
307316
308317   num_sprites = 50;
309318   yscroll_mask = 0x1ff;
319   tx_tile_offset = 0;
310320}
311321
312322VIDEO_START( ikari )
r4135r4136
321331
322332   tilemap_set_scrolldx(bg_tilemap, 15, 24);
323333   tilemap_set_scrolldy(bg_tilemap,  8, -32);
334
335   tx_tile_offset = 0;
324336}
325337
326338VIDEO_START( gwar )
327339{
340   int i;
341
342   /* prepare drawmode table */
343   for(i = 0; i <= 14; i++) drawmode_table[i] = DRAWMODE_SOURCE;
344   drawmode_table[15] = DRAWMODE_NONE;
345
328346   memset(empty_tile,0xf,sizeof(empty_tile));
329347
330348   tx_tilemap = tilemap_create(machine, gwar_get_tx_tile_info, tilemap_scan_cols,  8,  8, 50, 32);
r4135r4136
334352
335353   tilemap_set_scrolldx(bg_tilemap, 16, 143);
336354   tilemap_set_scrolldy(bg_tilemap,  0, -32);
355
356   tx_tile_offset = 0;
337357}
338358
339359VIDEO_START( tdfever )
340360{
361   VIDEO_START_CALL(gwar);
341362   VIDEO_START_CALL(snk_4bpp_shadow);
342
343   VIDEO_START_CALL(gwar);
344363}
345364
346365/**************************************************************************************/
r4135r4136
443462   flip_screen_set(space->machine, data & 0x80);
444463
445464   tilemap_set_palette_offset(bg_tilemap, ((data & 0xf) ^ 8) << 4);
446   tilemap_set_pen_data_offset(bg_tilemap, ((data & 0x20) << 3) * space->machine->gfx[1]->char_modulo);
465   if (bg_tile_offset != ((data & 0x20) << 3))
466   {
467      bg_tile_offset = (data & 0x20) << 3;
468      tilemap_mark_all_tiles_dirty(bg_tilemap);
469   }
447470
448471   // other bits unknown
449472}
r4135r4136
507530
508531   flip_screen_set(space->machine, data & 0x80);
509532
510   tilemap_set_pen_data_offset(tx_tilemap, ((data & 0x40) << 2) * space->machine->gfx[0]->char_modulo);
533   if (tx_tile_offset != ((data & 0x40) << 2))
534   {
535      tx_tile_offset = (data & 0x40) << 2;
536      tilemap_mark_all_tiles_dirty(tx_tilemap);
537   }
511538
512539   bg_scrolly =   (bg_scrolly   & 0xff) | ((data & 0x10) << 4);
513540   sp16_scrolly = (sp16_scrolly & 0xff) | ((data & 0x08) << 5);
r4135r4136
518545WRITE8_HANDLER( aso_bg_bank_w )
519546{
520547   tilemap_set_palette_offset(bg_tilemap, ((data & 0xf) ^ 8) << 4);
521   tilemap_set_pen_data_offset(bg_tilemap, ((data & 0x30) << 4) * space->machine->gfx[1]->char_modulo);
548   if (bg_tile_offset != ((data & 0x30) << 4))
549   {
550      bg_tile_offset = (data & 0x30) << 4;
551      tilemap_mark_all_tiles_dirty(bg_tilemap);
552   }
522553}
523554
524555WRITE8_HANDLER( ikari_bg_scroll_msb_w )
r4135r4136
549580   popmessage("attrs %02x contact MAMEDEV", data);
550581
551582   tilemap_set_palette_offset(tx_tilemap, (data & 0x01) << 4);
552   tilemap_set_pen_data_offset(tx_tilemap, ((data & 0x10) << 4) * space->machine->gfx[0]->char_modulo);
583   if (tx_tile_offset != ((data & 0x10) << 4))
584   {
585      tx_tile_offset = (data & 0x10) << 4;
586      tilemap_mark_all_tiles_dirty(tx_tilemap);
587   }
553588}
554589
555590WRITE8_HANDLER( gwar_tx_bank_w )
556591{
557592   tilemap_set_palette_offset(tx_tilemap, (data & 0xf) << 4);
558   tilemap_set_pen_data_offset(tx_tilemap, ((data & 0x30) << 4) * space->machine->gfx[0]->char_modulo);
593   if (tx_tile_offset != ((data & 0x30) << 4))
594   {
595      tx_tile_offset = (data & 0x30) << 4;
596      tilemap_mark_all_tiles_dirty(tx_tilemap);
597   }
559598}
560599
561600WRITE8_HANDLER( gwar_videoattrs_w )
r4135r4136
640679      if (sx > 512-16) sx -= 512;
641680      if (sy > 256-16) sy -= 256;
642681
643      drawgfx( bitmap,gfx,
682      drawgfx_transtable(bitmap,cliprect,gfx,
644683         tile_number,
645684         color,
646685         flipx, flipy,
647686         sx, sy,
648         cliprect,TRANSPARENCY_PEN_TABLE,7);
687         drawmode_table, machine->shadow_table);
649688
650689      source+=4;
651690   }
r4135r4136
705744      if (sx > 512-size) sx -= 512;
706745      if (sy > (yscroll_mask+1)-size) sy -= (yscroll_mask+1);
707746
708      drawgfx(bitmap,gfx,
747      drawgfx_transtable(bitmap,cliprect,gfx,
709748            tile_number,
710749            color,
711750            xflip,yflip,
712751            sx,sy,
713            cliprect,TRANSPARENCY_PEN_TABLE,7);
752            drawmode_table, machine->shadow_table);
714753   }
715754}
716755
r4135r4136
751790      if (sx > 512-size) sx -= 512;
752791      if (sy > 512-size) sy -= 512;
753792
754      drawgfx(bitmap,gfx,
793      drawgfx_transtable(bitmap,cliprect,gfx,
755794            tile_number,
756795            color,
757796            0,0,
758797            sx,sy,
759            cliprect,TRANSPARENCY_PEN_TABLE,7);
798            drawmode_table, machine->shadow_table);
760799   }
761800}
762801
r4135r4136
791830{
792831   const gfx_element *gfx = machine->gfx[gfxnum];
793832   const int size = gfx->width;
794   int tile_number, attributes, sx, sy, color, pen_mode;
833   int tile_number, attributes, sx, sy, color;
795834   int which;
796835   int flipx, flipy;
797836
798   pen_mode = (machine->config->video_attributes & VIDEO_HAS_SHADOWS) ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN;
799
800837   for(which = from*4; which < to*4; which+=4)
801838   {
802839      tile_number = source[which+1];
r4135r4136
838875      if (sx > 512-size) sx -= 512;
839876      if (sy > 512-size) sy -= 512;
840877
841      drawgfx(bitmap,gfx,
878      drawgfx_transtable(bitmap,cliprect,gfx,
842879            tile_number,
843880            color,
844881            flipx,flipy,
845882            sx,sy,
846            cliprect,pen_mode,15);
883            drawmode_table, machine->shadow_table);
847884   }
848885}
849886
src/mame/video/hyprduel.c
r4135r4136
417417      for ( ; src >= end; src -= 8/2 )
418418      {
419419         int x,y, attr,code,color,flipx,flipy, zoom, curr_pri,width,height;
420         gfx_element gfx;
420421         UINT8 *gfxdata;
421422
422423         /* Exponential zoom table extracted from daitoride */
r4135r4136
468469
469470         if (color == 0xf)   /* 8bpp */
470471         {
471            /* prepare GfxElement on the fly */
472            gfx_element gfx;
473            gfx.machine = machine;
474            gfx.width = width;
475            gfx.height = height;
476            gfx.total_elements = 1;
477            gfx.color_depth = 256;
478            gfx.color_granularity = 256;
479            gfx.color_base = 0;
480            gfx.total_colors = 0x20;
481            gfx.pen_usage = NULL;
482            gfx.gfxdata = gfxdata;
483            gfx.line_modulo = width;
484            gfx.char_modulo = 0;   /* doesn't matter */
485            gfx.flags = 0;
486            gfx.machine = machine;
487
488472            /* Bounds checking */
489473            if ( (gfxdata + width * height - 1) >= gfx_max )
490474               continue;
491475
476            gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width, 0, 256, 0);
477
492478            pdrawgfxzoom(   bitmap,&gfx,
493479                        0,
494480                        color_start >> 4,
r4135r4136
500486         }
501487         else
502488         {
503            /* prepare GfxElement on the fly */
504            gfx_element gfx;
505            gfx.machine = machine;
506            gfx.width = width;
507            gfx.height = height;
508            gfx.total_elements = 1;
509            gfx.color_depth = 16;
510            gfx.color_granularity = 16;
511            gfx.color_base = 0;
512            gfx.total_colors = 0x200;
513            gfx.pen_usage = NULL;
514            gfx.gfxdata = gfxdata;
515            gfx.line_modulo = width/2;
516            gfx.char_modulo = 0;   /* doesn't matter */
517            gfx.flags = GFX_ELEMENT_PACKED;
518            gfx.machine = machine;
519
520489            /* Bounds checking */
521490            if ( (gfxdata + width/2 * height - 1) >= gfx_max )
522491               continue;
523492
493            gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width/2, 0, 16, GFX_ELEMENT_PACKED);
494
524495            pdrawgfxzoom(   bitmap,&gfx,
525496                        0,
526497                        (color ^ 0x0f) + color_start,
src/mame/video/model2.c
r4135r4136
27342734{
27352735   logerror("--- frame ---\n");
27362736
2737   sys24_tile_update(screen->machine);
27382737   bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
27392738   bitmap_fill(sys24_bitmap, cliprect, 0);
27402739
src/mame/video/segaic24.c
r4135r4136
8181
8282static UINT16 *sys24_char_ram, *sys24_tile_ram;
8383static UINT16 sys24_tile_mask;
84static UINT8 *sys24_char_dirtymap;
85static int sys24_char_dirty, sys24_char_gfx_index;
84static int sys24_char_gfx_index;
8685static tilemap *sys24_tile_layer[4];
8786
8887#ifdef LSB_FIRST
r4135r4136
135134   SET_TILE_INFO(sys24_char_gfx_index, val & sys24_tile_mask, (val >> 7) & 0xff, 0);
136135}
137136
138static STATE_POSTLOAD( sys24_tile_dirtyall )
139{
140   memset(sys24_char_dirtymap, 1, SYS24_TILES);
141   sys24_char_dirty = 1;
142}
143
144137void sys24_tile_vh_start(running_machine *machine, UINT16 tile_mask)
145138{
146139   sys24_tile_mask = tile_mask;
r4135r4136
154147
155148   sys24_tile_ram = auto_malloc(0x10000);
156149
157   sys24_char_dirtymap = auto_malloc(SYS24_TILES);
158
159150   sys24_tile_layer[0] = tilemap_create(machine, sys24_tile_info_0s, tilemap_scan_rows,  8, 8, 64, 64);
160151   sys24_tile_layer[1] = tilemap_create(machine, sys24_tile_info_0w, tilemap_scan_rows,  8, 8, 64, 64);
161152   sys24_tile_layer[2] = tilemap_create(machine, sys24_tile_info_1s, tilemap_scan_rows,  8, 8, 64, 64);
r4135r4136
168159
169160   memset(sys24_char_ram, 0, 0x80000);
170161   memset(sys24_tile_ram, 0, 0x10000);
171   memset(sys24_char_dirtymap, 1, SYS24_TILES);
172   sys24_char_dirty = 1;
173162
174   machine->gfx[sys24_char_gfx_index] = allocgfx(machine, &sys24_char_layout);
163   machine->gfx[sys24_char_gfx_index] = gfx_element_alloc(machine, &sys24_char_layout, (UINT8 *)sys24_char_ram, machine->config->total_colors / 16, 0);
175164
176   machine->gfx[sys24_char_gfx_index]->total_colors = machine->config->total_colors / 16;
177
178165   state_save_register_global_pointer(machine, sys24_tile_ram, 0x10000/2);
179166   state_save_register_global_pointer(machine, sys24_char_ram, 0x80000/2);
180   state_save_register_postload(machine, sys24_tile_dirtyall, NULL);
181167}
182168
183void sys24_tile_update(running_machine *machine)
184{
185   if(sys24_char_dirty) {
186      int i;
187      for(i=0; i<SYS24_TILES; i++) {
188         if(sys24_char_dirtymap[i]) {
189            sys24_char_dirtymap[i] = 0;
190            decodechar(machine->gfx[sys24_char_gfx_index], i, (UINT8 *)sys24_char_ram);
191         }
192      }
193      tilemap_mark_all_tiles_dirty(sys24_tile_layer[0]);
194      tilemap_mark_all_tiles_dirty(sys24_tile_layer[1]);
195      tilemap_mark_all_tiles_dirty(sys24_tile_layer[2]);
196      tilemap_mark_all_tiles_dirty(sys24_tile_layer[3]);
197      sys24_char_dirty = 0;
198   }
199}
200
201169static void sys24_tile_draw_rect(running_machine *machine, bitmap_t *bm, bitmap_t *tm, bitmap_t *dm, const UINT16 *mask,
202170                         UINT16 tpri, UINT8 lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2)
203171{
r4135r4136
604572   UINT16 old = sys24_char_ram[offset];
605573   COMBINE_DATA(sys24_char_ram + offset);
606574   if(old != sys24_char_ram[offset]) {
607      sys24_char_dirtymap[offset / 16] = 1;
608      sys24_char_dirty = 1;
575      gfx_element_mark_dirty(space->machine->gfx[sys24_char_gfx_index], offset / 16);
609576   }
610577}
611578
src/mame/video/segaic24.h
r4135r4136
1212// Tilemaps
1313//  System24
1414void sys24_tile_vh_start(running_machine *machine, UINT16 tile_mask);
15void sys24_tile_update(running_machine *machine);
1615void sys24_tile_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int pri, int flags);
1716
1817READ16_HANDLER(sys24_tile_r);
src/mame/video/lemmings.c
r4135r4136
1717
1818UINT16 *lemmings_pixel_0_data,*lemmings_pixel_1_data,*lemmings_vram_data,*lemmings_control_data;
1919static UINT16 *sprite_triple_buffer_0,*sprite_triple_buffer_1;
20static UINT8 *vram_buffer, *vram_dirty;
20static UINT8 *vram_buffer;
2121static bitmap_t *bitmap0;
2222static tilemap *vram_tilemap;
2323
r4135r4136
9797   vram_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_cols,8,8,64,32);
9898
9999   vram_buffer = (UINT8*)auto_malloc(2048*64); /* 64 bytes per VRAM character */
100   vram_dirty = (UINT8*)auto_malloc(2048);
101100   sprite_triple_buffer_0 = (UINT16*)auto_malloc(0x800);
102101   sprite_triple_buffer_1 = (UINT16*)auto_malloc(0x800);
103102
104103   tilemap_set_transparent_pen(vram_tilemap,0);
105104   bitmap_fill(bitmap0,0,0x100);
105
106   gfx_element_set_source(machine->gfx[2], vram_buffer);
106107}
107108
108109VIDEO_EOF( lemmings )
r4135r4136
148149
149150   /* Copy pixel to buffer for easier decoding later */
150151   tile=((sx/8)*32)+(sy/8);
151   vram_dirty[tile]=1;
152   gfx_element_mark_dirty(space->machine->gfx[2], tile);
152153   vram_buffer[(tile*64) + ((sx&7)) + ((sy&7)*8)]=(src>>8)&0xf;
153154
154155   sx+=1; /* Update both pixels in the word */
r4135r4136
163164
164165VIDEO_UPDATE( lemmings )
165166{
166   int x1=-lemmings_control_data[0],x0=-lemmings_control_data[2],i,y=0;
167   int x1=-lemmings_control_data[0],x0=-lemmings_control_data[2],y=0;
167168   rectangle rect;
168169   rect.max_y=cliprect->max_y;
169170   rect.min_y=cliprect->min_y;
170171
171   /* Decode any characters that have changed in vram */
172   for (i=0; i<2048; i++) {
173      if (vram_dirty[i]) {
174         decodechar(screen->machine->gfx[2],i,vram_buffer);
175         tilemap_mark_tile_dirty(vram_tilemap,i);
176         vram_dirty[i]=0;
177      }
178   }
179
180172   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
181173   draw_sprites(screen->machine,bitmap,cliprect,sprite_triple_buffer_1,1,0x0000);
182174
src/mame/video/tiamc1.c
r4135r4136
1111#include "includes/tiamc1.h"
1212
1313
14UINT8 *tiamc1_tileram;
15UINT8 *tiamc1_charram;
16UINT8 *tiamc1_spriteram_x;
17UINT8 *tiamc1_spriteram_y;
18UINT8 *tiamc1_spriteram_a;
19UINT8 *tiamc1_spriteram_n;
14static UINT8 *tiamc1_tileram;
15static UINT8 *tiamc1_charram;
16static UINT8 *tiamc1_spriteram_x;
17static UINT8 *tiamc1_spriteram_y;
18static UINT8 *tiamc1_spriteram_a;
19static UINT8 *tiamc1_spriteram_n;
2020static UINT8 tiamc1_layers_ctrl;
2121static UINT8 tiamc1_bg_vshift;
2222static UINT8 tiamc1_bg_hshift;
r4135r4136
3535   if(!(tiamc1_layers_ctrl & 16))
3636      tiamc1_charram[offset + 0x1800] = data;
3737
38   if((tiamc1_layers_ctrl & 30) ^ 0xff)
39      tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
38   if ((tiamc1_layers_ctrl & (16|8|4|2)) != (16|8|4|2))
39      gfx_element_mark_dirty(space->machine->gfx[0], (offset / 8) & 0xff);
4040
4141   if(!(tiamc1_layers_ctrl & 1)) {
4242      tiamc1_tileram[offset] = data;
43      if (offset >= 1024)
44         tilemap_mark_tile_dirty(bg_tilemap1, offset);
43      if (offset < 1024)
44         tilemap_mark_tile_dirty(bg_tilemap1, offset & 0x3ff);
4545      else
46         tilemap_mark_tile_dirty(bg_tilemap2, offset);
46         tilemap_mark_tile_dirty(bg_tilemap2, offset & 0x3ff);
4747   }
4848}
4949
r4135r4136
122122
123123static TILE_GET_INFO( get_bg1_tile_info )
124124{
125   int code = tiamc1_tileram[tile_index];
126
127   decodechar(machine->gfx[0], code, tiamc1_charram);
128
129   SET_TILE_INFO(0, code, 0, 0);
125   SET_TILE_INFO(0, tiamc1_tileram[tile_index], 0, 0);
130126}
131127
132128static TILE_GET_INFO( get_bg2_tile_info )
133129{
134   int code = tiamc1_tileram[tile_index + 1024];
135
136   decodechar(machine->gfx[0], code, tiamc1_charram);
137
138   SET_TILE_INFO(0, code, 0, 0);
130   SET_TILE_INFO(0, tiamc1_tileram[tile_index + 1024], 0, 0);
139131}
140132
141133VIDEO_START( tiamc1 )
142134{
135   UINT8 *video_ram;
136
137   video_ram = auto_malloc(0x3040);
138   memset(video_ram, 0, 0x3040);
139
140        tiamc1_charram = video_ram + 0x0800;     /* Ram is banked */
141        tiamc1_tileram = video_ram + 0x0000;
142
143   tiamc1_spriteram_y = video_ram + 0x3000;
144   tiamc1_spriteram_x = video_ram + 0x3010;
145   tiamc1_spriteram_n = video_ram + 0x3020;
146   tiamc1_spriteram_a = video_ram + 0x3030;
147
148   state_save_register_global_pointer(machine, video_ram, 0x3040);
149
143150   bg_tilemap1 = tilemap_create(machine, get_bg1_tile_info, tilemap_scan_rows,
144151       8, 8, 32, 32);
145152
r4135r4136
152159   state_save_register_global(machine, tiamc1_layers_ctrl);
153160   state_save_register_global(machine, tiamc1_bg_vshift);
154161   state_save_register_global(machine, tiamc1_bg_hshift);
162
163   gfx_element_set_source(machine->gfx[0], tiamc1_charram);
155164}
156165
157166static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
src/mame/video/toaplan1.c
r4135r4136
948948      const rectangle *clip,int priority)
949949{
950950   int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
951   UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
951   const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
952952
953953   int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16;
954954   int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16;
r4135r4136
10181018
10191019         for( y=sy; y<ey; y++ )
10201020         {
1021            UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1021            const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
10221022            UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
10231023            UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0);
10241024
src/mame/video/segag80r.c
r4135r4136
1313
1414static double rweights[3], gweights[3], bweights[2];
1515
16static UINT8 *dirtychar;
1716static UINT8 video_control;
1817static UINT8 video_flip;
1918static UINT8 vblank_latch;
r4135r4136
209208         3,   rg_resistances, gweights, 220, 0,
210209         2,   b_resistances,  bweights, 220, 0);
211210
212   /* allocate paletteram */
213   dirtychar = auto_malloc(256);
214   memset(dirtychar, 1, 256);
211   gfx_element_set_source(machine->gfx[0], &videoram[0x800]);
215212
216213   /* allocate paletteram */
217214   paletteram = auto_malloc(0x80);
r4135r4136
288285
289286   /* track which characters are dirty */
290287   if (offset & 0x800)
291      dirtychar[(offset & 0x7ff) / 8] = TRUE;
288      gfx_element_mark_dirty(space->machine->gfx[0], (offset & 0x7ff) / 8);
292289}
293290
294291
r4135r4136
658655         int offs = effy * 32 + (x ^ flipmask);
659656         UINT8 tile = videoram[offs];
660657
661         /* if the tile is dirty, decode it */
662         if (dirtychar[tile])
663         {
664            decodechar(machine->gfx[0], tile, &videoram[0x800]);
665            dirtychar[tile] = 0;
666         }
667
668658         /* draw the tile */
669659         drawgfx(bitmap, machine->gfx[0], tile, tile >> 4, video_flip, video_flip, x*8, y*8, cliprect, TRANSPARENCY_PENS, transparent_pens[tile >> 4]);
670660      }
src/mame/video/tmnt.c
r4135r4136
590590   K052109_tilemap_update();
591591
592592   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
593   if ((priorityflag & 1) == 1) K051960_sprites_draw(bitmap,cliprect,0,0);
593   if ((priorityflag & 1) == 1) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
594594   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
595   if ((priorityflag & 1) == 0) K051960_sprites_draw(bitmap,cliprect,0,0);
595   if ((priorityflag & 1) == 0) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
596596   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
597597   return 0;
598598}
r4135r4136
602602   K052109_tilemap_update();
603603
604604   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
605   if ((priorityflag & 1) == 1) K051960_sprites_draw(bitmap,cliprect,0,0);
605   if ((priorityflag & 1) == 1) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
606606   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
607   if ((priorityflag & 1) == 0) K051960_sprites_draw(bitmap,cliprect,0,0);
607   if ((priorityflag & 1) == 0) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
608608   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
609609   return 0;
610610}
r4135r4136
634634   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[1]],0,2);
635635   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[2]],0,4);
636636
637   K051960_sprites_draw(bitmap,cliprect,-1,-1);
637   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
638638   return 0;
639639}
640640
r4135r4136
664664   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[1]],0,2);
665665   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[2]],0,4);
666666
667   K053245_sprites_draw(0, bitmap,cliprect);
667   K053245_sprites_draw(screen->machine, 0, bitmap,cliprect);
668668   return 0;
669669}
670670
r4135r4136
724724      glfgreat_pixel = *BITMAP_ADDR16(bitmap,0x80,0x105);
725725   }
726726
727   K053245_sprites_draw(0, bitmap,cliprect);
727   K053245_sprites_draw(screen->machine, 0, bitmap,cliprect);
728728   return 0;
729729}
730730
r4135r4136
804804   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[1]],0,2);
805805   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[2]],0,4);
806806
807   K051960_sprites_draw(bitmap,cliprect,-1,-1);
807   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
808808   return 0;
809809}
810810
src/mame/video/taitojc.c
r4135r4136
2222
2323static int taitojc_gfx_index;
2424
25static UINT8 *taitojc_dirty_map;
2625static UINT32 *taitojc_char_ram;
2726static UINT32 *taitojc_tile_ram;
28static int taitojc_char_dirty;
2927static tilemap *taitojc_tilemap;
3028
3129static poly_manager *poly;
r4135r4136
5149   SET_TILE_INFO(taitojc_gfx_index, tile, color, 0);
5250}
5351
54static void taitojc_tile_update(running_machine *machine)
55{
56   int i;
57   if (taitojc_char_dirty)
58   {
59      for (i=0; i < TAITOJC_NUM_TILES; i++)
60      {
61         if (taitojc_dirty_map[i])
62         {
63            taitojc_dirty_map[i] = 0;
64            decodechar(machine->gfx[taitojc_gfx_index], i, (UINT8 *)taitojc_char_ram);
65         }
66      }
67      tilemap_mark_all_tiles_dirty(taitojc_tilemap);
68      taitojc_char_dirty = 0;
69   }
70}
71
7252READ32_HANDLER(taitojc_tile_r)
7353{
7454   return taitojc_tile_ram[offset];
r4135r4136
8868WRITE32_HANDLER(taitojc_char_w)
8969{
9070   COMBINE_DATA(taitojc_char_ram + offset);
91   taitojc_dirty_map[offset/32] = 1;
92   taitojc_char_dirty = 1;
71   gfx_element_mark_dirty(space->machine->gfx[taitojc_gfx_index], offset/32);
9372}
9473
9574// Object data format:
r4135r4136
196175{
197176   int width, height;
198177
199   taitojc_char_dirty = 1;
200
201178   poly = poly_alloc(machine, 4000, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS);
202179   add_exit_callback(machine, taitojc_exit);
203180
r4135r4136
209186   assert(taitojc_gfx_index != MAX_GFX_ELEMENTS);
210187
211188   taitojc_tilemap = tilemap_create(machine, taitojc_tile_info, tilemap_scan_rows,  16, 16, 64, 64);
212   taitojc_dirty_map = auto_malloc(TAITOJC_NUM_TILES);
213189
214190   tilemap_set_transparent_pen(taitojc_tilemap, 0);
215191
r4135r4136
220196   memset(taitojc_tile_ram, 0, 0x4000);
221197
222198   /* create the char set (gfx will then be updated dynamically from RAM) */
223   machine->gfx[taitojc_gfx_index] = allocgfx(machine, &taitojc_char_layout);
199   machine->gfx[taitojc_gfx_index] = gfx_element_alloc(machine, &taitojc_char_layout, (UINT8 *)taitojc_char_ram, machine->config->total_colors / 16, 0);
224200
225   /* set the color information */
226   machine->gfx[taitojc_gfx_index]->total_colors = machine->config->total_colors / 16;
227
228201   taitojc_texture = auto_malloc(0x400000);
229202
230203   framebuffer = video_screen_auto_bitmap_alloc(machine->primary_screen);
r4135r4136
280253      }
281254   }
282255
283   taitojc_tile_update(screen->machine);
284256   tilemap_draw(bitmap, cliprect, taitojc_tilemap, 0,0);
285257
286258#if 0
src/mame/video/spy.c
r4135r4136
7676   {
7777      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,1);
7878      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,2);
79      K051960_sprites_draw(bitmap,cliprect,-1,-1);
79      K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
8080      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
8181   }
8282
src/mame/video/beathead.c
r4135r4136
206206      }
207207
208208      /* then draw it */
209      draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL, -1);
209      draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL);
210210   }
211211   return 0;
212212}
src/mame/video/st0016.c
r4135r4136
1414
1515static INT32 st0016_spr_bank,st0016_spr2_bank,st0016_pal_bank,st0016_char_bank;
1616static int spr_dx,spr_dy;
17static UINT8 *chardirty;
1817
1918static UINT8 st0016_vregs[0xc0];
2019static int st0016_ramgfx;
r4135r4136
115114WRITE8_HANDLER(st0016_character_ram_w)
116115{
117116   st0016_charram[ST0016_CHAR_BANK_SIZE*st0016_char_bank+offset]=data;
118   chardirty[st0016_char_bank] = 1;
117   gfx_element_mark_dirty(space->machine->gfx[st0016_ramgfx], st0016_char_bank);
119118}
120119
121120READ8_HANDLER(st0016_vregs_r)
r4135r4136
353352                     int yloop,xloop;
354353                     int ypos, xpos;
355354                     int tileno;
356                     UINT8 *srcgfx;
355                     const UINT8 *srcgfx;
357356                     int gfxoffs;
358357                     ypos = sy+y0*8+spr_dy;
359358                     xpos = sx+x0*8+spr_dx;
360359                     tileno = (code+i0++)&ST0016_CHAR_BANK_MASK ;
361360
362                     if (chardirty[tileno])
363                     {
364                        chardirty[tileno] = 0;
365                        decodechar(gfx, tileno, (UINT8 *) st0016_charram);
366                     }
367
368361                     gfxoffs = 0;
369                     srcgfx= gfx->gfxdata+(64*tileno);
362                     srcgfx= gfx_element_get_data(gfx, tileno);
370363
371364                     for (yloop=0; yloop<8; yloop++)
372365                     {
r4135r4136
424417   }
425418}
426419
427static STATE_POSTLOAD( st0016_postload )
428{
429   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
430420
431   st0016_rom_bank_w(space,0,st0016_rom_bank);
432   memset(chardirty, 1, ST0016_MAX_CHAR_BANK);
433}
434
435
436421void st0016_save_init(running_machine *machine)
437422{
438423   state_save_register_global(machine, st0016_spr_bank);
r4135r4136
444429   state_save_register_global_pointer(machine, st0016_charram, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE);
445430   state_save_register_global_pointer(machine, st0016_paletteram, ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE);
446431   state_save_register_global_pointer(machine, st0016_spriteram, ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE);
447   state_save_register_postload(machine, st0016_postload, NULL);
448432}
449433
450434
r4135r4136
463447   assert(gfx_index != MAX_GFX_ELEMENTS);
464448
465449   /* create the char set (gfx will then be updated dynamically from RAM) */
466   machine->gfx[gfx_index] = allocgfx(machine, &charlayout);
467   chardirty = auto_malloc(ST0016_MAX_CHAR_BANK);
468   memset(chardirty, 1, ST0016_MAX_CHAR_BANK);
469
470   /* set the color information */
471   machine->gfx[gfx_index]->color_base = 0;
472   machine->gfx[gfx_index]->total_colors = 0x40;
450   machine->gfx[gfx_index] = gfx_element_alloc(machine, &charlayout, (UINT8 *) st0016_charram, 0x40, 0);
473451   st0016_ramgfx = gfx_index;
474452
475453   spr_dx=0;
r4135r4136
531509                flipx=st0016_spriteram[i+3]&0x80;
532510               flipy=st0016_spriteram[i+3]&0x40;
533511
534               if (chardirty[code])
535               {
536                  chardirty[code] = 0;
537                  decodechar(gfx, code, (UINT8 *) st0016_charram);
538               }
539
540512                if(priority)
541513                {
542514                   drawgfx(bitmap,gfx,
r4135r4136
551523                     UINT16 *destline;
552524                     int yloop,xloop;
553525                     int ypos, xpos;
554                     UINT8 *srcgfx;
526                     const UINT8 *srcgfx;
555527                     int gfxoffs;
556528                     ypos = y*8+spr_dy;//+((st0016_vregs[j+2]==0xaf)?0x50:0);//hack for mayjinsen title screen
557529                     xpos = x*8+spr_dx;
558530                     gfxoffs = 0;
559                     srcgfx= gfx->gfxdata+(gfx->char_modulo*code);
531                     srcgfx= gfx_element_get_data(gfx, code);
560532
561533                     for (yloop=0; yloop<8; yloop++)
562534                     {
src/mame/video/qix.c
r4135r4136
327327static MC6845_UPDATE_ROW( update_row )
328328{
329329   qix_state *state = device->machine->driver_data;
330   UINT32 *dest = BITMAP_ADDR32(bitmap, y, 0);
330331   UINT16 x;
331   UINT8 scanline[256];
332332
333333   pen_t *pens = (pen_t *)param;
334334
r4135r4136
337337   offs_t offs_xor = state->flip ? 0xffff : 0;
338338
339339   for (x = 0; x < x_count * 8; x++)
340      scanline[x] = state->videoram[(offs + x) ^ offs_xor];
341
342   draw_scanline8(bitmap, 0, y, x_count * 8, scanline, pens, -1);
340      dest[x] = pens[state->videoram[(offs + x) ^ offs_xor]];
343341}
344342
345343
src/mame/video/xexex.c
r4135r4136
134134
135135      if (alpha > 0)
136136      {
137         K056832_tilemap_draw(screen->machine, bitmap, cliprect, 1, (alpha >= 255) ? 0 : TILEMAP_DRAW_ALPHA, 0);
137         K056832_tilemap_draw(screen->machine, bitmap, cliprect, 1, TILEMAP_DRAW_ALPHA(alpha), 0);
138138      }
139139   }
140140
src/mame/video/snes.c
r4135r4136
19411941      addr = tileaddr + (jj * bpl * 16 * 32);
19421942      for( kk = 0; kk < 8; kk++ )
19431943      {
1944         UINT32 *destline = BITMAP_ADDR32(bitmap, jj * 8 + kk, 0);
1945
19441946         /* Clear buffers */
19451947         memset( scanlines[MAINSCREEN].buffer, 0, SNES_SCR_WIDTH * 2 );
19461948         memset( scanlines[MAINSCREEN].zbuf, 0, SNES_SCR_WIDTH * 2 );
r4135r4136
19601962            }
19611963            addr += (bpl * 16);
19621964         }
1963         draw_scanline16( bitmap, 0, jj * 8 + kk, SNES_SCR_WIDTH * 2, scanlines[MAINSCREEN].buffer, machine->pens, 200 );
1965         for (ii = 0; ii < SNES_SCR_WIDTH * 2; ii++)
1966         {
1967            int pixdata = scanlines[MAINSCREEN].buffer[ii];
1968            if (pixdata != 200)
1969               destline[ii] = machine->pens[pixdata];
1970         }
19641971         addr -= (32 * (bpl * 16)) - 2;
19651972      }
19661973   }
r4135r4136
21422149      {
21432150         static UINT32 tmaddr = 0;
21442151         static INT8 tmbg = 0;
2152         UINT32 *destline = BITMAP_ADDR32(bitmap, curline, 0);
21452153         if( curline == 0 )
21462154         {
21472155            if( adjust & 0x1 ) tmaddr += 2;
r4135r4136
21592167         for( ii = 0; ii < SNES_SCR_WIDTH; ii++ )
21602168            scanlines[MAINSCREEN].buffer[ii] = machine->pens[0];
21612169         snes_dbg_draw_maps(bitmap, tmaddr, dm, curline, tmbg );
2162         draw_scanline16( bitmap, 0, curline, SNES_SCR_WIDTH, scanlines[MAINSCREEN].buffer, machine->pens, 200 );
2170         for (ii = 0; ii < SNES_SCR_WIDTH; ii++)
2171         {
2172            int pixdata = scanlines[MAINSCREEN].buffer[ii];
2173            if (pixdata != 200)
2174               destline[ii] = machine->pens[pixdata];
2175         }
21632176         return 1;
21642177            }
21652178      }
21662179
21672180         /* Draw some useful information about the back/fixed colours and current bg mode etc. */
2168         *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 26) = machine->pens[dbg_mode_colours[(snes_ram[CGWSEL] & 0xc0) >> 6]];
2169         *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 24) = machine->pens[dbg_mode_colours[(snes_ram[CGWSEL] & 0x30) >> 4]];
2170         *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 22) = machine->pens[dbg_mode_colours[snes_ram[BGMODE] & 0x7]];
2171         *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 12) = machine->pens[32767];
2172         *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 2 ) = machine->pens[32767];
2181         *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 26) = machine->pens[dbg_mode_colours[(snes_ram[CGWSEL] & 0xc0) >> 6]];
2182         *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 24) = machine->pens[dbg_mode_colours[(snes_ram[CGWSEL] & 0x30) >> 4]];
2183         *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 22) = machine->pens[dbg_mode_colours[snes_ram[BGMODE] & 0x7]];
2184         *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 12) = machine->pens[32767];
2185         *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 2 ) = machine->pens[32767];
21732186         for( ii = 0; ii < 5; ii++ )
21742187         {
2175         *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 19 + ii) = snes_cgram[0];
2176         *BITMAP_ADDR16(bitmap, curline, SNES_DBG_HORZ_POS - 9  + ii) = snes_cgram[FIXED_COLOUR];
2188         *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 19 + ii) = snes_cgram[0];
2189         *BITMAP_ADDR32(bitmap, curline, SNES_DBG_HORZ_POS - 9  + ii) = snes_cgram[FIXED_COLOUR];
21772190         }
21782191         /* Draw window positions */
21792192         scanlines[MAINSCREEN].buffer[snes_ram[WH0]] = machine->pens[dbg_mode_colours[0]];
src/mame/video/toaplan2.c
r4135r4136
146146
147147#include "driver.h"
148148#include "cpu/m68000/m68000.h"
149#include "sound/3812intf.h"
149150#include "includes/toaplan2.h"
150151
151152
r4135r4136
558559   toaplan2_vram_alloc(0);
559560   truxton2_create_tilemaps_0(machine);
560561
562   if (machine->gfx[2]->srcdata == NULL)
563      gfx_element_set_source(machine->gfx[2], (UINT8 *)toaplan2_tx_gfxram16);
564
561565   if(!strcmp(machine->gamedrv->name,"fixeighb"))
562566   {
563567      xoffset[0]=-26;
r4135r4136
595599   memset(raizing_tx_gfxram16,0,RAIZING_TX_GFXRAM_SIZE);
596600   state_save_register_global_pointer(machine, raizing_tx_gfxram16, RAIZING_TX_GFXRAM_SIZE/2);
597601
602   gfx_element_set_source(machine->gfx[2], (UINT8 *)raizing_tx_gfxram16);
603
598604   toaplan2_vram_alloc(0);
599605   spriteram16_n[0] = spriteram16_new[0];
600606
r4135r4136
702708   /*** Dynamic GFX decoding for Truxton 2 / FixEight ***/
703709
704710   UINT16 oldword = toaplan2_tx_gfxram16[offset];
705   UINT8 *toaplan2_tx_gfxram = (UINT8 *)(toaplan2_tx_gfxram16);
706711
707712   if (oldword != data)
708713   {
709714      int code = offset/32;
710715      COMBINE_DATA(&toaplan2_tx_gfxram16[offset]);
711      decodechar(space->machine->gfx[2], code, toaplan2_tx_gfxram);
712
713      tilemap_mark_all_tiles_dirty(tx_tilemap);
716      gfx_element_mark_dirty(space->machine->gfx[2], code);
714717   }
715718}
716719
r4135r4136
738741   /*** Only done once during start-up ***/
739742
740743   int code;
741   UINT8 *raizing_tx_gfxram = (UINT8 *)raizing_tx_gfxram16;
742744   UINT16 *dest = (UINT16 *)raizing_tx_gfxram16;
743745
744746   memcpy(dest, toaplan2_txvideoram16, toaplan2_tx_vram_size);
r4135r4136
749751   dest += (toaplan2_tx_offs_vram_size/2);
750752   memcpy(dest, toaplan2_txscrollram16, toaplan2_tx_scroll_vram_size);
751753
752   /* Decode text characters */
754   /* Decode text characters; force them to update immediately */
753755   for (code = 0; code < 1024; code++)
754      decodechar (space->machine->gfx[2], code, raizing_tx_gfxram);
755   tilemap_mark_all_tiles_dirty(tx_tilemap);
756      gfx_element_decode(space->machine->gfx[2], code);
756757}
757758
758759WRITE16_HANDLER( batrider_objectbank_w )
src/mame/video/wecleman.c
r4135r4136
585585   };
586586
587587
588   UINT8 *src_ptr;
588   const UINT8 *src_ptr;
589589   const pen_t *pal_ptr, *rgb_ptr;
590590
591591   int scrollx, sy, sx;
r4135r4136
614614   else if (priority == 0x04)
615615   {
616616      // draw road
617      UINT8 *src_base = machine->gfx[1]->gfxdata;
618617      pen_t road_rgb[48];
619618
620619      for (i=0; i<48; i++)
r4135r4136
633632         if ((road>>8) != 0x04) continue;
634633         road &= YMASK;
635634
636         src_ptr = src_base + (road << 9);
635         src_ptr = gfx_element_get_data(machine->gfx[1], (road << 3));
636         gfx_element_get_data(machine->gfx[1], (road << 3) + 1);
637         gfx_element_get_data(machine->gfx[1], (road << 3) + 2);
638         gfx_element_get_data(machine->gfx[1], (road << 3) + 3);
639         gfx_element_get_data(machine->gfx[1], (road << 3) + 4);
640         gfx_element_get_data(machine->gfx[1], (road << 3) + 5);
641         gfx_element_get_data(machine->gfx[1], (road << 3) + 6);
642         gfx_element_get_data(machine->gfx[1], (road << 3) + 7);
637643         mdy = ((road * MIDCURB_DY) >> 8) * bitmap->rowpixels;
638644         tdy = ((road * TOPCURB_DY) >> 8) * bitmap->rowpixels;
639645
r4135r4136
680686             int tmw_l2, int tmh_l2,      // tilemap width and height in log(2)
681687             int alpha, int pal_offset )   // alpha(0-3f), # of color codes to shift
682688{
683   UINT8 *src_base, *src_ptr;
689   const UINT8 *src_ptr;
684690   UINT16 *tmap_ptr;
685691   UINT32 *dst_base, *dst_ptr;
686692   const pen_t *pal_base, *pal_ptr;
r4135r4136
706712   tmskipy = scrolly / tileh;
707713   dy = -(scrolly & (tileh-1));
708714
709   src_base = gfx->gfxdata;
710
711715   dst_base = BITMAP_ADDR32(bitmap, y0+dy, x0+dx);
712716
713717   pal_base = machine->pens + pal_offset * gfx->color_granularity;
r4135r4136
730734         // Wec Le Mans specific: decodes tile color in EAX
731735         UINT16 tile_color = ((tiledata >> 5) & 0x78) + (tiledata >> 12);
732736
733         src_ptr = src_base + tile_index * gfx->char_modulo;
737         src_ptr = gfx_element_get_data(gfx, tile_index);
734738         pal_ptr = pal_base + tile_color * gfx->color_granularity;
735739         dst_ptr = dst_base + j * tilew;
736740
src/mame/video/alpha68k.c
r4135r4136
1515
1616/******************************************************************************/
1717
18VIDEO_START( alpha68k_common_vh )
19{
20    state_save_register_global(machine, flipscreen);
21}
22
1823void alpha68k_flipscreen_w(int flip)
1924{
2025   flipscreen = flip;
r4135r4136
7176   fix_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_cols,8,8,32,32);
7277
7378   tilemap_set_transparent_pen(fix_tilemap,0);
79
80    state_save_register_global(machine, bank_base);
81
82    VIDEO_START_CALL(alpha68k_common_vh);
7483}
7584
7685/******************************************************************************/
86
7787//AT
7888static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int j, int s, int e)
7989{
src/mame/video/cischeat.c
r4135r4136
6060
6161static int cischeat_ip_select;
6262static int shift_ret = 1;
63static UINT8 drawmode_table[16];
6364
6465#ifdef MAME_DEBUG
6566static int debugsprites;   // For debug purposes
r4135r4136
129130{
130131   int i;
131132   for (i = 0;i < 16;i++)
132      gfx_drawmode_table[i] = DRAWMODE_SOURCE;
133      drawmode_table[i] = DRAWMODE_SOURCE;
133134
134   gfx_drawmode_table[ 0] = DRAWMODE_SHADOW;
135   gfx_drawmode_table[15] = DRAWMODE_NONE;
135   drawmode_table[ 0] = DRAWMODE_SHADOW;
136   drawmode_table[15] = DRAWMODE_NONE;
136137}
137138
138139/**************************************************************************
r4135r4136
923924      if (flipy)   { ystart = ynum-1;  yend = -1;    yinc = -1; }
924925      else      { ystart = 0;       yend = ynum;  yinc = +1; }
925926
927      drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
928
926929      for (y = ystart; y != yend; y += yinc)
927930      {
928931         for (x = xstart; x != xend; x += xinc)
929932         {
930            drawgfxzoom(bitmap,machine->gfx[3],
933            drawgfxzoom_transtable(bitmap,cliprect,machine->gfx[3],
931934                     code++,
932935                     color,
933936                     flipx,flipy,
934937                     (sx + x * xdim) / 0x10000, (sy + y * ydim) / 0x10000,
935                     cliprect,
936                     shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,15,
937                     xscale, yscale );
938                     xscale, yscale, drawmode_table, machine->shadow_table);
938939         }
939940      }
940941#ifdef MAME_DEBUG
r4135r4136
10771078      if (flipy)   { ystart = ynum-1;  yend = -1;    yinc = -1; }
10781079      else      { ystart = 0;       yend = ynum;  yinc = +1; }
10791080
1081      drawmode_table[ 0] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
1082
10801083      for (y = ystart; y != yend; y += yinc)
10811084      {
10821085         for (x = xstart; x != xend; x += xinc)
10831086         {
1084            drawgfxzoom(bitmap,machine->gfx[3],
1087            drawgfxzoom_transtable(bitmap,cliprect,machine->gfx[3],
10851088                     code++,
10861089                     color,
10871090                     flipx,flipy,
10881091                     (sx + x * xdim) / 0x10000, (sy + y * ydim) / 0x10000,
1089                     cliprect,
1090                     shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,15,
1091                     xscale, yscale );
1092                     xscale, yscale, drawmode_table, machine->shadow_table);
10921093         }
10931094      }
10941095#ifdef MAME_DEBUG
src/mame/video/namcos22.c
r4135r4136
558558mydrawgfxzoom(
559559   bitmap_t *dest_bmp,const gfx_element *gfx,
560560   UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
561   const rectangle *clip,int transparency,int transparent_color,
561   const rectangle *clip,
562562   int scalex, int scaley, int z, int prioverchar, int alpha )
563563{
564564   int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
r4135r4136
597597      extra->prioverchar = prioverchar;
598598      extra->line_modulo = gfx->line_modulo;
599599      extra->pens = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
600      extra->source = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
600      extra->source = gfx_element_get_data(gfx, code % gfx->total_elements);
601601#ifdef RENDER_AS_QUADS
602602      poly_render_quad_fan(poly, dest_bmp, clip, renderscanline_sprite, 2, 4, &vert[0]);
603603#else
r4135r4136
671671      flipx, flipy,
672672      sx, sy,
673673      &clip,
674      TRANSPARENCY_ALPHA, 0xff,
675674      (width<<16)/32,
676675      (height<<16)/32,
677676      zc, pri, 0xff - translucency );
r4135r4136
10631062
10641063UINT32 *namcos22_tilemapattr;
10651064
1066static int cgsomethingisdirty;
1067static UINT8 *cgdirty;
10681065static UINT8 *dirtypal;
10691066
10701067READ32_HANDLER( namcos22_czram_r )
r4135r4136
15381535static void
15391536DrawTranslucentCharacters( bitmap_t *bitmap, const rectangle *cliprect )
15401537{
1541   alpha_set_level( 0xff-mixer.text_translucency ); /* ? */
1542   tilemap_draw( bitmap, cliprect, bgtilemap, TILEMAP_DRAW_ALPHA|1, 0 );
1538   UINT8 alpha = 0xff-mixer.text_translucency; /* ? */
1539   tilemap_draw( bitmap, cliprect, bgtilemap, TILEMAP_DRAW_ALPHA(alpha)|1, 0 );
15431540}
15441541
15451542static void DrawCharacterLayer(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
15461543{
1547   unsigned i;
15481544   INT32 dx = namcos22_tilemapattr[0]>>16;
15491545   INT32 dy = namcos22_tilemapattr[0]&0xffff;
15501546   /**
r4135r4136
15521548    * namcos22_tilemapattr[0x8/4] == 0x01ff0000
15531549    * namcos22_tilemapattr[0xe/4] == ?
15541550    */
1555   if( cgsomethingisdirty )
1556   {
1557      for( i=0; i<64*64; i+=2 )
1558      {
1559         UINT32 data = namcos22_textram[i/2];
1560         if( cgdirty[(data>>16)&0x3ff] )
1561         {
1562            tilemap_mark_tile_dirty( bgtilemap,i );
1563         }
1564         if( cgdirty[data&0x3ff] )
1565         {
1566            tilemap_mark_tile_dirty( bgtilemap,i+1 );
1567         }
1568      }
1569
1570      for( i=0; i<NUM_CG_CHARS; i++ )
1571      {
1572         if( cgdirty[i] )
1573         {
1574            decodechar( machine->gfx[GFX_CHAR],i,(UINT8 *)namcos22_cgram );
1575            cgdirty[i] = 0;
1576         }
1577      }
1578      cgsomethingisdirty = 0;
1579   }
1580
15811551   bitmap_fill(priority_bitmap,cliprect,0);
15821552   tilemap_set_scrollx( bgtilemap,0, (dx-0x35c)&0x3ff );
15831553   tilemap_set_scrolly( bgtilemap,0, dy&0x3ff );
r4135r4136
21922162WRITE32_HANDLER( namcos22_cgram_w )
21932163{
21942164   COMBINE_DATA( &namcos22_cgram[offset] );
2195   cgdirty[offset/32] = 1;
2196   cgsomethingisdirty = 1;
2165   gfx_element_mark_dirty(space->machine->gfx[GFX_CHAR],offset/32);
21972166}
21982167
21992168READ32_HANDLER( namcos22_gamma_r )
r4135r4136
22302199
22312200static VIDEO_START( common )
22322201{
2202   int code;
2203
22332204   bgtilemap = tilemap_create( machine, TextTilemapGetInfo,tilemap_scan_rows,16,16,64,64 );
22342205      tilemap_set_transparent_pen( bgtilemap, 0xf );
22352206
22362207   mbDSPisActive = 0;
22372208   memset( namcos22_polygonram, 0xcc, 0x20000 );
22382209
2210   for (code = 0; code < machine->gfx[GFX_TEXTURE_TILE]->total_elements; code++)
2211      gfx_element_decode(machine->gfx[GFX_TEXTURE_TILE], code);
22392212   Prepare3dTexture(memory_region(machine, "textilemap"), machine->gfx[GFX_TEXTURE_TILE]->gfxdata );
22402213   dirtypal = auto_malloc(NAMCOS22_PALETTE_SIZE/4);
2241   cgdirty = auto_malloc( 0x400 );
22422214   mPtRomSize = memory_region_length(machine, "pointrom")/3;
22432215   mpPolyL = memory_region(machine, "pointrom");
22442216   mpPolyM = mpPolyL + mPtRomSize;
r4135r4136
22512223#endif
22522224   add_reset_callback(machine, namcos22_reset);
22532225   add_exit_callback(machine, namcos22_exit);
2226
2227   gfx_element_set_source(machine->gfx[GFX_CHAR], (UINT8 *)namcos22_cgram);
22542228}
22552229
22562230VIDEO_START( namcos22 )
src/mame/video/rockola.c
r4135r4136
107107   if (rockola_charram[offset] != data)
108108   {
109109      rockola_charram[offset] = data;
110      tilemap_mark_all_tiles_dirty(fg_tilemap);
110      gfx_element_mark_dirty(space->machine->gfx[0], (offset/8) % 256);
111111   }
112112}
113113
r4135r4136
171171   int code = rockola_videoram2[tile_index];
172172   int color = colorram[tile_index] & 0x07;
173173
174   decodechar(machine->gfx[0], code, rockola_charram);
175
176174   SET_TILE_INFO(0, code, color, 0);
177175}
178176
r4135r4136
182180   fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
183181
184182   tilemap_set_transparent_pen(fg_tilemap, 0);
183
184   gfx_element_set_source(machine->gfx[0], rockola_charram);
185185}
186186
187187VIDEO_UPDATE( rockola )
r4135r4136
291291   int code = rockola_videoram2[tile_index];
292292   int color = colorram[tile_index] & 0x03;
293293
294   decodechar(machine->gfx[0], code, rockola_charram);
295
296294   SET_TILE_INFO(0, code, color, 0);
297295}
298296
r4135r4136
302300   fg_tilemap = tilemap_create(machine, satansat_get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
303301
304302   tilemap_set_transparent_pen(fg_tilemap, 0);
303
304   gfx_element_set_source(machine->gfx[0], rockola_charram);
305305}
src/mame/video/atarisy1.c
r4135r4136
630630
631631static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp)
632632{
633   const UINT8 *srcdata;
633634   int bank_index, gfx_index;
634635
635636   /* determine the bank index */
r4135r4136
668669   assert(gfx_index != MAX_GFX_ELEMENTS);
669670
670671   /* decode the graphics */
672   srcdata = &memory_region(machine, "tiles")[0x80000 * (bank_index - 1)];
671673   switch (bpp)
672674   {
673675   case 4:
674      machine->gfx[gfx_index] = allocgfx(machine, &objlayout_4bpp);
676      machine->gfx[gfx_index] = gfx_element_alloc(machine, &objlayout_4bpp, srcdata, 0x40, 256);
675677      break;
676678
677679   case 5:
678      machine->gfx[gfx_index] = allocgfx(machine, &objlayout_5bpp);
680      machine->gfx[gfx_index] = gfx_element_alloc(machine, &objlayout_5bpp, srcdata, 0x40, 256);
679681      break;
680682
681683   case 6:
682      machine->gfx[gfx_index] = allocgfx(machine, &objlayout_6bpp);
684      machine->gfx[gfx_index] = gfx_element_alloc(machine, &objlayout_6bpp, srcdata, 0x40, 256);
683685      break;
684686
685687   default:
686688      fatalerror("Unsupported bpp");
687689   }
688   decodegfx(machine->gfx[gfx_index], &memory_region(machine, "tiles")[0x80000 * (bank_index - 1)], 0, machine->gfx[gfx_index]->total_elements);
689690
690691   /* set the color information */
691   machine->gfx[gfx_index]->color_base = 256;
692692   machine->gfx[gfx_index]->color_granularity = 8;
693   machine->gfx[gfx_index]->total_colors = 0x40;
694693   bank_color_shift[gfx_index] = bpp - 3;
695694
696695   /* set the entry and return it */
src/mame/video/ssv.c
r4135r4136
147147               UINT32 code,UINT32 color,int flipx,int flipy,int x0,int y0,
148148               const rectangle *cliprect, int shadow   )
149149{
150   UINT8 *source, *addr, pen;
150   const UINT8 *addr, *source;
151   UINT8 pen;
151152   UINT16 *dest;
152153   int sx, x1, dx;
153154   int sy, y1, dy;
154155
155   addr   =   (code  % gfx->total_elements) * gfx->char_modulo + gfx->gfxdata;
156   addr   =   gfx_element_get_data(gfx, code  % gfx->total_elements);
156157   color   =   gfx->color_granularity * (color % gfx->total_colors);
157158
158159   if ( flipx )   {   x1 = x0-1;            x0 += gfx->width-1;      dx = -1;   }
r4135r4136
202203   VIDEO_START_CALL(ssv);
203204
204205   eaglshot_gfxram      =   (UINT16*)auto_malloc(16 * 0x40000);
205   eaglshot_dirty_tile   =   (char*)auto_malloc(16 * 0x40000 / (16*8));
206
207   gfx_element_set_source(machine->gfx[0], (UINT8 *)eaglshot_gfxram);
208   gfx_element_set_source(machine->gfx[1], (UINT8 *)eaglshot_gfxram);
206209}
207210
208211static tilemap *gdfs_tmap;
r4135r4136
223226{
224227   VIDEO_START_CALL(ssv);
225228
226   machine->gfx[2]->color_granularity = 64; /* 256 colour sprites with palette selectable on 64 colour boundaries */
227
228229   eaglshot_gfxram      =   (UINT16*)auto_malloc(4 * 0x100000);
229   eaglshot_dirty_tile   =   (char*)auto_malloc(4 * 0x100000 / (16*8));
230230
231   machine->gfx[2]->color_granularity = 64; /* 256 colour sprites with palette selectable on 64 colour boundaries */
232   gfx_element_set_source(machine->gfx[2], (UINT8 *)eaglshot_gfxram);
233
231234   gdfs_tmap         =   tilemap_create(   machine, get_tile_info_0, tilemap_scan_rows,
232235                                  16,16, 0x100,0x100   );
233236
r4135r4136
245248int ssv_tilemap_offsx, ssv_tilemap_offsy;
246249
247250UINT16 *eaglshot_gfxram, *gdfs_tmapram, *gdfs_tmapscroll;
248char eaglshot_dirty, *eaglshot_dirty_tile;
249251
250252/***************************************************************************
251253
r4135r4136
917919
918920VIDEO_UPDATE( eaglshot )
919921{
920   int tile;
921
922   // Decode tiles from ram
923   if (eaglshot_dirty)
924   {
925      eaglshot_dirty = 0;
926
927      for (tile = 0; tile < (16 * 0x40000 / (16*8)); tile++)
928      {
929         if (eaglshot_dirty_tile[tile])
930         {
931            eaglshot_dirty_tile[tile] = 0;
932
933            decodechar(screen->machine->gfx[0], tile, (UINT8 *)eaglshot_gfxram);
934            decodechar(screen->machine->gfx[1], tile, (UINT8 *)eaglshot_gfxram);
935         }
936      }
937   }
938
939   VIDEO_UPDATE_CALL(ssv);
940   return 0;
922   return VIDEO_UPDATE_CALL(ssv);
941923}
942924
943925/*
r4135r4136
11051087
11061088VIDEO_UPDATE( gdfs )
11071089{
1108   int tile, pri;
1090   int pri;
11091091
11101092   VIDEO_UPDATE_CALL(ssv);
11111093
1112   // Decode zooming sprites tiles from ram
1113   if (eaglshot_dirty)
1114   {
1115      eaglshot_dirty = 0;
1116
1117      for (tile = 0; tile < (4 * 0x100000 / (16*8)); tile++)
1118      {
1119         if (eaglshot_dirty_tile[tile])
1120         {
1121            eaglshot_dirty_tile[tile] = 0;
1122
1123            decodechar(screen->machine->gfx[2], tile, (UINT8 *)eaglshot_gfxram);
1124         }
1125      }
1126   }
1127
11281094   for (pri = 0; pri <= 0xf; pri++)
11291095      gdfs_draw_zooming_sprites(screen->machine, bitmap, cliprect, pri);
11301096
src/mame/video/tceptor.c
r4135r4136
276276   free(buffer);
277277
278278   /* decode the graphics */
279   machine->gfx[gfx_index] = allocgfx(machine, &bg_layout);
280   decodegfx(machine->gfx[gfx_index], memory_region(machine, region), 0, machine->gfx[gfx_index]->total_elements);
281
282   /* set the color information */
283   machine->gfx[gfx_index]->color_base = 2048;
284   machine->gfx[gfx_index]->total_colors = 64;
279   machine->gfx[gfx_index] = gfx_element_alloc(machine, &bg_layout, memory_region(machine, region), 64, 2048);
285280}
286281
287282static void decode_sprite(running_machine *machine, int gfx_index, const gfx_layout *layout, const void *data)
288283{
289284   /* decode the graphics */
290   machine->gfx[gfx_index] = allocgfx(machine, layout);
291   decodegfx(machine->gfx[gfx_index], data, 0, machine->gfx[gfx_index]->total_elements);
292
293   /* set the color information */
294   machine->gfx[gfx_index]->color_base = 1024;
295   machine->gfx[gfx_index]->total_colors = 64;
285   machine->gfx[gfx_index] = gfx_element_alloc(machine, layout, data, 64, 1024);
296286}
297287
298288// fix sprite order
r4135r4136
320310   UINT8 *dst;
321311   int i, y;
322312
323   dst = malloc_or_die(len);
313   dst = auto_malloc(len);
324314
325315   for (i = 0; i < len / (4*4*16); i++)
326316      for (y = 0; y < 16; y++)
r4135r4136
340330      }
341331
342332   decode_sprite(machine, sprite16, &spr16_layout, dst);
343
344   free(dst);
345333}
346334
347335// fix sprite order
r4135r4136
375363   UINT8 *dst;
376364   int i;
377365
378   dst = malloc_or_die(len);
366   dst = auto_malloc(len);
379367
380368   memset(dst, 0, len);
381369
r4135r4136
391379   }
392380
393381   decode_sprite(machine, sprite32, &spr32_layout, dst);
394
395   free(dst);
396382}
397383
398384VIDEO_START( tceptor )
src/mame/video/metro.c
r4135r4136
621621
622622   for (i=0; i<0x20; i++)
623623   {
624      gfx_element gfx;
625
624626      if (!(metro_videoregs[0x02/2] & 0x8000))
625627      {
626628         src = spriteram16 + (sprites - 1) * (8/2);
r4135r4136
689691
690692         if (support_8bpp && color == 0xf)   /* 8bpp */
691693         {
692            /* prepare GfxElement on the fly */
693            gfx_element gfx;
694            gfx.machine = machine;
695            gfx.width = width;
696            gfx.height = height;
697            gfx.total_elements = 1;
698            gfx.color_depth = 256;
699            gfx.color_granularity = 256;
700            gfx.color_base = 0;
701            gfx.total_colors = 0x20;
702            gfx.pen_usage = NULL;
703            gfx.gfxdata = gfxdata;
704            gfx.line_modulo = width;
705            gfx.char_modulo = 0;   /* doesn't matter */
706            gfx.flags = 0;
707            gfx.machine = machine;
708
709694            /* Bounds checking */
710695            if ( (gfxdata + width * height - 1) >= gfx_max )
711696               continue;
712697
698            gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width, 0, 256, 0);
699
713700            pdrawgfxzoom(   bitmap,&gfx,
714701                        0,
715702                        color_start >> 4,
r4135r4136
721708         }
722709         else
723710         {
724            /* prepare GfxElement on the fly */
725            gfx_element gfx;
726            gfx.machine = machine;
727            gfx.width = width;
728            gfx.height = height;
729            gfx.total_elements = 1;
730            gfx.color_depth = 16;
731            gfx.color_granularity = 16;
732            gfx.color_base = 0;
733            gfx.total_colors = 0x200;
734            gfx.pen_usage = NULL;
735            gfx.gfxdata = gfxdata;
736            gfx.line_modulo = width/2;
737            gfx.char_modulo = 0;   /* doesn't matter */
738            gfx.flags = GFX_ELEMENT_PACKED;
739            gfx.machine = machine;
740
741711            /* Bounds checking */
742712            if ( (gfxdata + width/2 * height - 1) >= gfx_max )
743713               continue;
744714
715            gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width/2, 0, 16, GFX_ELEMENT_PACKED);
716
745717            pdrawgfxzoom(   bitmap,&gfx,
746718                        0,
747719                        color + color_start,
src/mame/video/angelkds.c
r4135r4136
1313
1414UINT8 *angelkds_txvideoram, *angelkds_bgbotvideoram, *angelkds_bgtopvideoram;
1515
16static int angelkds_txbank;
17static int angelkds_bgbotbank;
18static int angelkds_bgtopbank;
19
1620/*** Text Layer Tilemap
1721
1822*/
1923
20static int angelkds_txbank;
21
22
2324static TILE_GET_INFO( get_tx_tile_info )
2425{
2526   int tileno;
r4135r4136
5051
5152*/
5253
53static int angelkds_bgtopbank;
54
55
5654static TILE_GET_INFO( get_bgtop_tile_info )
5755{
5856   int tileno;
r4135r4136
8987
9088*/
9189
92static int angelkds_bgbotbank;
93
9490static TILE_GET_INFO( get_bgbot_tile_info )
9591{
9692   int tileno;
r4135r4136
271267
272268   bgtop_tilemap = tilemap_create(machine, get_bgtop_tile_info,tilemap_scan_rows, 8, 8,32,32);
273269   tilemap_set_transparent_pen(bgtop_tilemap,15);
270
271    state_save_register_global(machine, angelkds_txbank);
272    state_save_register_global(machine, angelkds_bgbotbank);
273    state_save_register_global(machine, angelkds_bgtopbank);
274274}
275275
276276/* enable bits are uncertain */
src/mame/video/usgames.c
r4135r4136
4949VIDEO_START(usgames)
5050{
5151   usgames_tilemap = tilemap_create(machine, get_usgames_tile_info,tilemap_scan_rows, 8, 8,64,32);
52   gfx_element_set_source(machine->gfx[0], usgames_charram);
5253}
5354
5455
r4135r4136
6162WRITE8_HANDLER( usgames_charram_w )
6263{
6364   usgames_charram[offset] = data;
64
65   decodechar(space->machine->gfx[0], offset/8, usgames_charram);
66
67   tilemap_mark_all_tiles_dirty(usgames_tilemap);
65   gfx_element_mark_dirty(space->machine->gfx[0], offset/8);
6866}
6967
7068
src/mame/video/surpratk.c
r4135r4136
9494   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
9595   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
9696
97   K053245_sprites_draw(0,bitmap,cliprect);
97   K053245_sprites_draw(screen->machine,0,bitmap,cliprect);
9898   return 0;
9999}
src/mame/video/jalblend.c
r4135r4136
7575   {
7676      const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
7777      const UINT8 *alpha = &jal_blend_table[gfx->color_granularity * (color % gfx->total_colors)];
78      UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
78      const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
7979      int x_index_base, y_index, sx, sy, ex, ey;
8080      int xinc, yinc;
8181
r4135r4136
128128            /* taken from case 7: TRANSPARENCY_ALPHARANGE */
129129            for (y = sy; y < ey; y++)
130130            {
131               UINT8 *source = source_base + y_index*gfx->line_modulo;
131               const UINT8 *source = source_base + y_index*gfx->line_modulo;
132132               UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
133133               int x_index = x_index_base;
134134               for (x = sx; x < ex; x++)
r4135r4136
159159            /* taken from case 7: TRANSPARENCY_ALPHARANGE */
160160            for (y = sy; y < ey; y++)
161161            {
162               UINT8 *source = source_base + y_index*gfx->line_modulo;
162               const UINT8 *source = source_base + y_index*gfx->line_modulo;
163163               UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
164164               int x_index = x_index_base;
165165               for (x = sx; x < ex; x++)
src/mame/video/cvs.c
r4135r4136
208208VIDEO_UPDATE( cvs )
209209{
210210   static const int ram_based_char_start_indices[] = { 0xe0, 0xc0, 0x100, 0x80 };
211   int code;
212211   offs_t offs;
213212   int scroll[8];
214213   UINT8 character_banking_mode;
r4135r4136
223222
224223   character_banking_mode = cvs_get_character_banking_mode();
225224
226   /* ROM based tiles first */
227   for (code = 0; code < ram_based_char_start_indices[character_banking_mode]; code++)
228      decodechar(screen->machine->gfx[0], code, memory_region(screen->machine, "gfx1"));
229
230   /* now the RAM based ones */
231   for (; code < 0x100; code++)
232      decodechar(screen->machine->gfx[0], code, cvs_character_ram);
233
234225   /* draw the background */
235226   for (offs = 0; offs < 0x0400; offs++)
236227   {
r4135r4136
242233      UINT8 x = offs << 3;
243234      UINT8 y = offs >> 5 << 3;
244235
245      drawgfx(background_bitmap, screen->machine->gfx[0],
236      int gfxnum = (code < ram_based_char_start_indices[character_banking_mode]) ? 0 : 1;
237
238      drawgfx(background_bitmap, screen->machine->gfx[gfxnum],
246239            code, color,
247240            0, 0,
248241            x, y,
r4135r4136
259252            collision_color = 0x102;
260253      }
261254
262      drawgfx(cvs_collision_background, screen->machine->gfx[0],
255      drawgfx(cvs_collision_background, screen->machine->gfx[gfxnum],
263256            code, collision_color,
264257            0, 0,
265258            x, y,
src/mame/video/rohga.c
r4135r4136
4646   deco16_set_tilemap_bank_callback(3,wizdfire_bank_callback);
4747
4848   deco16_pf1_rowscroll=deco16_pf2_rowscroll=0;
49
50   alpha_set_level(0x80);
5149}
5250
5351VIDEO_START( nitrobal )
r4135r4136
6361   deco16_set_tilemap_colour_mask(2,0);
6462   deco16_set_tilemap_colour_base(3,0);
6563   deco16_set_tilemap_colour_mask(3,0);
66
67   alpha_set_level(0x80);
6864}
6965
7066/******************************************************************************/
r4135r4136
153149   for (offs = 0;offs < 0x400;offs += 4)
154150   {
155151      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
156      int trans=TRANSPARENCY_PEN;
152      int alpha=0xff;
157153
158154      sprite = spriteptr[offs+1];
159155      if (!sprite) continue;
r4135r4136
194190      colour = (x >> 9) &0x1f;
195191
196192      if (bank==4 && colour&0x10) {
197         trans=TRANSPARENCY_ALPHA;
193         alpha=0x80;
198194         colour&=0xf;
199195      }
200196
r4135r4136
231227
232228      while (multi >= 0)
233229      {
234         drawgfx(bitmap,machine->gfx[bank],
230         drawgfx_alpha(bitmap,cliprect,machine->gfx[bank],
235231               sprite - multi * inc,
236232               colour,
237233               fx,fy,
238234               x,y + mult * multi,
239               cliprect,trans,0);
235               0,alpha);
240236
241237         multi--;
242238      }
r4135r4136
283279   while (offs!=end)
284280   {
285281      int x,y,sprite,colour,fx,fy,w,h,sx,sy,x_mult,y_mult,tilemap_pri,sprite_pri;
286      int trans=TRANSPARENCY_PEN;
282      int alpha=0xff;
287283
288284      sprite = spriteptr[offs+3];
289285      if (!sprite) {
r4135r4136
387383      }
388384
389385      if (gfxbank==4 && colour&0x10) {
390         trans=TRANSPARENCY_ALPHA;
386         alpha=0x80;
391387         colour&=0xf;
392388      }
393389
r4135r4136
426422                  colour,
427423                  fx,fy,
428424                  sx + x_mult * (w-x),sy + y_mult * (h-y),
429                  cliprect,trans,0,tilemap_pri,sprite_pri,1);
425                  cliprect,0,tilemap_pri,sprite_pri,1,alpha);
430426         }
431427      }
432428
r4135r4136
509505   wizdfire_draw_sprites(screen->machine,bitmap,cliprect,buffered_spriteram16,3,3);
510506
511507   if ((deco16_priority&0x1f)==0x1f) /* Wizdfire has bit 0x40 always set, Dark Seal 2 doesn't?! */
512      deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_ALPHA,0);
508      deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_ALPHA(0x80),0);
513509   else
514510      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,0);
515511
src/mame/video/plygonet.c
r4135r4136
7272   assert(ttl_gfx_index != MAX_GFX_ELEMENTS);
7373
7474   // decode the ttl layer's gfx
75   machine->gfx[ttl_gfx_index] = allocgfx(machine, &charlayout);
76   decodegfx(machine->gfx[ttl_gfx_index], memory_region(machine, "gfx1"), 0, machine->gfx[ttl_gfx_index]->total_elements);
75   machine->gfx[ttl_gfx_index] = gfx_element_alloc(machine, &charlayout, memory_region(machine, "gfx1"), machine->config->total_colors / 16, 0);
7776
78   machine->gfx[ttl_gfx_index]->total_colors = machine->config->total_colors / 16;
79
8077   // create the tilemap
8178   ttl_tilemap = tilemap_create(machine, ttl_get_tile_info, plygonet_scan,  8, 8, 64, 32);
8279
src/mame/video/nemesis.c
r4135r4136
2424
2525static tilemap *background, *foreground;
2626
27static UINT8 *blank_characterdata; /* pseudo character */
28
29/* gfxram dirty flags */
30
31/* we should be able to draw sprite gfx directly without caching to GfxElements */
32
33static UINT8 *sprite_dirty[8];
34
3527static const struct
3628{
3729   UINT8 width;
r4135r4136
4436   {  8,  8, 0 }, { 16,  8, 6 }, {  8, 16, 3 }, { 16, 16, 1 }
4537};
4638
39static UINT8 blank_tile[8*8];
40
4741static TILE_GET_INFO( get_bg_tile_info )
4842{
4943   int code,color,flags;
r4135r4136
5751   if (code & 0xf800) {
5852      SET_TILE_INFO( 0, code&0x7ff, color&0x7f, flags );
5953   } else {
60      SET_TILE_INFO( 0, 0x800, 0x00, 0 );
54      SET_TILE_INFO( 0, 0, 0x00, 0 );
55      tileinfo->pen_data = blank_tile;
6156   }
6257   tileinfo->category = (code & 0x1000)>>12;
6358}
r4135r4136
7570   if (code & 0xf800) {
7671      SET_TILE_INFO( 0, code&0x7ff, color&0x7f, flags );
7772   } else {
78      SET_TILE_INFO( 0, 0x800, 0x00, 0 );
73      SET_TILE_INFO( 0, 0, 0x00, 0 );
74      tileinfo->pen_data = blank_tile;
7975   }
8076   tileinfo->category = (code & 0x1000)>>12;
8177}
r4135r4136
199195      {
200196         int w = sprite_data[i].width;
201197         int h = sprite_data[i].height;
202         sprite_dirty[i][offset * 4 / (w * h)] = 1;
198         gfx_element_mark_dirty(space->machine->gfx[sprite_data[i].char_type], offset * 4 / (w * h));
203199      }
204200   }
205201}
r4135r4136
208204/* claim a palette dirty array */
209205VIDEO_START( nemesis )
210206{
211   int i;
212207   spriteram_words = spriteram_size / 2;
213208
214209   background = tilemap_create(machine,
r4135r4136
222217   tilemap_set_scroll_rows( background, 256 );
223218   tilemap_set_scroll_rows( foreground, 256 );
224219
225   for (i=0; i<8; i++)
226   {
227      int w = sprite_data[i].width;
228      int h = sprite_data[i].height;
229      int size = 0x20000 / (w * h);
230      sprite_dirty[i] = auto_malloc(size);
231      memset(sprite_dirty[i], 1, size);
232   }
233
234220   memset(nemesis_characterram,0,nemesis_characterram_size);
235221
222   gfx_element_set_source(machine->gfx[0], (UINT8 *)nemesis_characterram);
223   gfx_element_set_source(machine->gfx[1], (UINT8 *)nemesis_characterram);
224   gfx_element_set_source(machine->gfx[2], (UINT8 *)nemesis_characterram);
225   gfx_element_set_source(machine->gfx[3], (UINT8 *)nemesis_characterram);
226   gfx_element_set_source(machine->gfx[4], (UINT8 *)nemesis_characterram);
227   gfx_element_set_source(machine->gfx[5], (UINT8 *)nemesis_characterram);
228   gfx_element_set_source(machine->gfx[6], (UINT8 *)nemesis_characterram);
229   gfx_element_set_source(machine->gfx[7], (UINT8 *)nemesis_characterram);
236230
237   blank_characterdata = auto_malloc(32*8/8*(2048+1));
238   memset(blank_characterdata,0x00,32*8/8*(2048+1));
239   decodechar(machine->gfx[0],0x800,(UINT8 *)blank_characterdata);
240
241231   flipscreen = 0;
242232   tilemap_flip = 0;
243233}
r4135r4136
329319
330320/******************************************************************************/
331321
332static void update_gfx(running_machine *machine)
333{
334   int offs,code;
335   int bAnyDirty;
336
337   bAnyDirty = 0;
338   for (offs = spriteram_words - 1;offs >= 0;offs --)
339   {
340      if (sprite_dirty[4][offs])
341      {
342         decodechar(machine->gfx[0],offs,(UINT8 *)nemesis_characterram);
343         bAnyDirty = 1;
344         sprite_dirty[4][offs] = 0;
345      }
346   }
347   if( bAnyDirty )
348   {
349      tilemap_mark_all_tiles_dirty( background );
350      tilemap_mark_all_tiles_dirty( foreground );
351   }
352
353   for (offs = 0;offs < spriteram_words;offs += 8)
354   {
355      int char_type;
356      int zoom;
357
358      zoom = spriteram16[offs+2] & 0xff;
359      if (!(spriteram16[offs+2] & 0xff00) && ((spriteram16[offs+3] & 0xff00) != 0xff00))
360         code = spriteram16[offs+3] + ((spriteram16[offs+4] & 0xc0) << 2);
361      else
362         code = (spriteram16[offs+3] & 0xff) + ((spriteram16[offs+4] & 0xc0) << 2);
363
364      if (zoom != 0xFF || code!=0)
365      {
366         int size = spriteram16[offs+1];
367         int idx = (size >> 3) & 7;
368         int w, h;
369
370         w = sprite_data[idx].width;
371         h = sprite_data[idx].height;
372         code = code * 8 * 16 / (w * h);
373         char_type = sprite_data[idx].char_type;
374         if (sprite_dirty[idx][code] == 1)
375         {
376            decodechar(machine->gfx[char_type],code,(UINT8 *)nemesis_characterram);
377            sprite_dirty[idx][code] = 0;
378         }
379      }
380   }
381}
382
383/******************************************************************************/
384
385322VIDEO_UPDATE( nemesis )
386323{
387324   int offs;
388325
389   update_gfx(screen->machine);
390
391326   bitmap_fill(priority_bitmap,cliprect,0);
392327   bitmap_fill(bitmap,cliprect,0);
393328
r4135r4136
415350   int offs;
416351   rectangle clip;
417352
418   update_gfx(screen->machine);
419
420353   bitmap_fill(priority_bitmap,cliprect,0);
421354   bitmap_fill(bitmap,cliprect,0);
422355
src/mame/video/magmax.c
r4135r4136
167167            UINT16 line_data_flip_x[256];
168168            for (i=0; i<256; i++)
169169               line_data_flip_x[i] = line_data[255-i];
170            draw_scanline16(bitmap, 0, 255-v, 256, line_data_flip_x, NULL , -1);
170            draw_scanline16(bitmap, 0, 255-v, 256, line_data_flip_x, NULL);
171171         }
172172         else
173            draw_scanline16(bitmap, 0, v, 256, line_data, NULL, -1);
173            draw_scanline16(bitmap, 0, v, 256, line_data, NULL);
174174      }
175175   }
176176
src/mame/video/deco16ic.c
r4135r4136
838838void deco16_pdrawgfx(running_machine *machine,
839839      bitmap_t *dest,const gfx_element *gfx,
840840      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
841      const rectangle *clip,int transparency,int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri)
841      const rectangle *clip,int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri,UINT8 alpha)
842842{
843843   int ox,oy,cx,cy;
844844   int x_index,y_index,x,y;
845845
846846   const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
847   int source_base = (code % gfx->total_elements) * gfx->height;
847   const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
848848
849849   /* check bounds */
850850   ox = sx;
r4135r4136
864864
865865   for( y=0; y<16-cy; y++ )
866866   {
867      UINT8 *source = gfx->gfxdata + ((source_base+y_index) * gfx->line_modulo);
867      const UINT8 *source = code_base + (y_index * gfx->line_modulo);
868868      UINT32 *destb = BITMAP_ADDR32(dest, sy, 0);
869869      UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, 0);
870870      UINT8 *spri = BITMAP_ADDR8(sprite_priority_bitmap, sy, 0);
r4135r4136
879879            if( c != transparent_color && x >= 0 && x < 320 )
880880            {
881881               if (pri_mask>pri[x] && sprite_mask>spri[x]) {
882                  if (transparency == TRANSPARENCY_ALPHA)
883                     destb[x] = alpha_blend32(destb[x], pal[c]);
882                  if (alpha != 0xff)
883                     destb[x] = alpha_blend_r32(destb[x], pal[c], alpha);
884884                  else
885885                     destb[x] = pal[c];
886886                  if (write_pri)
src/mame/video/rallyx.c
r4135r4136
1616palette entry number is NOT changed; therefore, the sprite pixels that are
1717covered by the bullet just change bank. This is emulated by first drawing the
1818bullets normally, then drawing the sprites (with pdrawgfx so they are not
19drawn over high priority tiles), then drawing the pullets again in
20TRANSPARENCY_PEN_TABLE mode, so that bullets not covered by sprites remain
19drawn over high priority tiles), then drawing the pullets again with
20drawgfx_transtable mode, so that bullets not covered by sprites remain
2121the same while the others alter the sprite color.
2222
2323
r4135r4136
5050};
5151static struct star stars[MAX_STARS];
5252static int total_stars;
53static UINT8 drawmode_table[4];
5354
5455
5556/***************************************************************************
r4135r4136
356357      machine->shadow_table[i] = i;
357358
358359   for (i = 0;i < 3;i++)
359      gfx_drawmode_table[i] = DRAWMODE_SHADOW;
360      drawmode_table[i] = DRAWMODE_SHADOW;
360361
361   gfx_drawmode_table[3] = DRAWMODE_NONE;
362   drawmode_table[3] = DRAWMODE_NONE;
362363}
363364
364365
r4135r4136
383384      machine->shadow_table[i] = i;
384385
385386   for (i = 0;i < 3;i++)
386      gfx_drawmode_table[i] = DRAWMODE_SHADOW;
387      drawmode_table[i] = DRAWMODE_SHADOW;
387388
388   gfx_drawmode_table[3] = DRAWMODE_NONE;
389   drawmode_table[3] = DRAWMODE_NONE;
389390
390391   calculate_star_field();
391392}
r4135r4136
419420      machine->shadow_table[i] = i;
420421
421422   for (i = 0;i < 3;i++)
422      gfx_drawmode_table[i] = DRAWMODE_SHADOW;
423      drawmode_table[i] = DRAWMODE_SHADOW;
423424
424   gfx_drawmode_table[3] = DRAWMODE_NONE;
425   drawmode_table[3] = DRAWMODE_NONE;
425426
426427   calculate_star_field();
427428}
r4135r4136
456457      machine->shadow_table[i] = i;
457458
458459   for (i = 0;i < 3;i++)
459      gfx_drawmode_table[i] = DRAWMODE_SHADOW;
460      drawmode_table[i] = DRAWMODE_SHADOW;
460461
461   gfx_drawmode_table[3] = DRAWMODE_NONE;
462   drawmode_table[3] = DRAWMODE_NONE;
462463
463464   calculate_star_field();
464465}
r4135r4136
575576   }
576577}
577578
578static void rallyx_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transparency )
579static void rallyx_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transpen )
579580{
580581   int offs;
581582
r4135r4136
587588      y = 253 - rallyx_radary[offs];
588589      if (flip_screen_get(machine)) x -= 3;
589590
590      drawgfx(bitmap,machine->gfx[2],
591            ((rallyx_radarattr[offs & 0x0f] & 0x0e) >> 1) ^ 0x07,
592            0,
593            0,0,
594            x,y,
595            cliprect,transparency,3);
591      if (transpen)
592         drawgfx_transpen(bitmap,cliprect,machine->gfx[2],
593               ((rallyx_radarattr[offs & 0x0f] & 0x0e) >> 1) ^ 0x07,
594               0,
595               0,0,
596               x,y,
597               3);
598      else
599         drawgfx_transtable(bitmap,cliprect,machine->gfx[2],
600               ((rallyx_radarattr[offs & 0x0f] & 0x0e) >> 1) ^ 0x07,
601               0,
602               0,0,
603               x,y,
604               drawmode_table,machine->shadow_table);
596605   }
597606}
598607
599static void jungler_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transparency )
608static void jungler_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transpen )
600609{
601610   int offs;
602611
r4135r4136
607616      x = rallyx_radarx[offs] + ((~rallyx_radarattr[offs & 0x0f] & 0x08) << 5);
608617      y = 253 - rallyx_radary[offs];
609618
610      drawgfx(bitmap,machine->gfx[2],
611            (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
612            0,
613            0,0,
614            x,y,
615            cliprect,transparency,3);
619      if (transpen)
620         drawgfx_transpen(bitmap,cliprect,machine->gfx[2],
621               (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
622               0,
623               0,0,
624               x,y,
625               3);
626      else
627         drawgfx_transtable(bitmap,cliprect,machine->gfx[2],
628               (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
629               0,
630               0,0,
631               x,y,
632               drawmode_table,machine->shadow_table);
616633   }
617634}
618635
619static void locomotn_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transparency )
636static void locomotn_draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int transpen )
620637{
621638   int offs;
622639
r4135r4136
635652      x = rallyx_radarx[offs] + ((~rallyx_radarattr[offs & 0x0f] & 0x08) << 5);
636653      y = 252 - rallyx_radary[offs];
637654
638      drawgfx(bitmap,machine->gfx[2],
639            (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
640            0,
641            0,0,
642            x,y,
643            cliprect,transparency,3);
655      if (transpen)
656         drawgfx_transpen(bitmap,cliprect,machine->gfx[2],
657               (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
658               0,
659               0,0,
660               x,y,
661               3);
662      else
663         drawgfx_transtable(bitmap,cliprect,machine->gfx[2],
664               (rallyx_radarattr[offs & 0x0f] & 0x07) ^ 0x07,
665               0,
666               0,0,
667               x,y,
668               drawmode_table,machine->shadow_table);
644669   }
645670}
646671
r4135r4136
669694   tilemap_draw(bitmap,&bg_clip,bg_tilemap,1,1);
670695   tilemap_draw(bitmap,&fg_clip,fg_tilemap,1,1);
671696
672   rallyx_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN);
673   rallyx_draw_sprites(screen->machine, bitmap,cliprect,1);
674   rallyx_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN_TABLE);
697   rallyx_draw_bullets(screen->machine,bitmap,cliprect,TRUE);
698   rallyx_draw_sprites(screen->machine,bitmap,cliprect,1);
699   rallyx_draw_bullets(screen->machine,bitmap,cliprect,FALSE);
675700
676701   return 0;
677702}
r4135r4136
702727   tilemap_draw(bitmap,&bg_clip,bg_tilemap,1,0);
703728   tilemap_draw(bitmap,&fg_clip,fg_tilemap,1,0);
704729
705   jungler_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN);
706   rallyx_draw_sprites(screen->machine, bitmap,cliprect,0);
707   jungler_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN_TABLE);
730   jungler_draw_bullets(screen->machine,bitmap,cliprect,TRUE);
731   rallyx_draw_sprites(screen->machine,bitmap,cliprect,0);
732   jungler_draw_bullets(screen->machine,bitmap,cliprect,FALSE);
708733
709734   if (stars_enable)
710735      draw_stars(screen->machine, bitmap, cliprect);
r4135r4136
746771   tilemap_draw(bitmap,&bg_clip,bg_tilemap,1,1);
747772   tilemap_draw(bitmap,&fg_clip,fg_tilemap,1,1);
748773
749   locomotn_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN);
750   locomotn_draw_sprites(screen->machine, bitmap,cliprect,0);
751   locomotn_draw_bullets(screen->machine, bitmap,cliprect,TRANSPARENCY_PEN_TABLE);
774   locomotn_draw_bullets(screen->machine,bitmap,cliprect,TRUE);
775   locomotn_draw_sprites(screen->machine,bitmap,cliprect,0);
776   locomotn_draw_bullets(screen->machine,bitmap,cliprect,FALSE);
752777
753778   if (stars_enable)
754779      draw_stars(screen->machine, bitmap, cliprect);
src/mame/video/gridlee.c
r4135r4136
160160   {
161161      /* non-flipped: draw directly from the bitmap */
162162      if (!gridlee_cocktail_flip)
163         draw_scanline8(bitmap, 0, y, 256, &local_videoram[(y - BALSENTE_VBEND) * 256], pens + 16, -1);
163         draw_scanline8(bitmap, 0, y, 256, &local_videoram[(y - BALSENTE_VBEND) * 256], pens + 16);
164164
165165      /* flipped: x-flip the scanline into a temp buffer and draw that */
166166      else
r4135r4136
171171
172172         for (xx = 0; xx < 256; xx++)
173173            temp[xx] = local_videoram[srcy * 256 + 255 - xx];
174         draw_scanline8(bitmap, 0, y, 256, temp, pens + 16, -1);
174         draw_scanline8(bitmap, 0, y, 256, temp, pens + 16);
175175      }
176176   }
177177
src/mame/video/blockhl.c
r4135r4136
6262   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,1);
6363   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,2);
6464
65   K051960_sprites_draw(bitmap,cliprect,0,-1); // draw sprites with pdrawgfx
65   K051960_sprites_draw(screen->machine,bitmap,cliprect,0,-1); // draw sprites with pdrawgfx
6666   return 0;
6767}
src/mame/video/realbrk.c
r4135r4136
222222   rectangle spritetile_clip;
223223   spritetile_clip.min_x = 0;
224224   spritetile_clip.min_y = 0;
225   spritetile_clip.max_x = 32;
226   spritetile_clip.max_y = 32;
225   spritetile_clip.max_x = 31;
226   spritetile_clip.max_y = 31;
227227
228228   for ( offs = 0x3000/2; offs < 0x3600/2; offs += 2/2 )
229229   {
r4135r4136
314314            switch( rot )
315315            {
316316               case 0x10: // rot 90
317                  copyrozbitmap( tmpbitmap1, tmpbitmap0,
317                  copyrozbitmap_trans( tmpbitmap1, NULL, tmpbitmap0,
318318                     (UINT32)0<<16,
319319                     (UINT32)16<<16,
320320                     0 << 16,
321321                     -1 << 16,
322322                     1 << 16,
323323                     0 << 16,
324                     0, cliprect, TRANSPARENCY_PEN, 0, 0 );
324                     0, 0 );
325325
326326                     currx = (sx - (y+1) * ydim) / 0x10000;
327327                     curry = (sy + x * xdim) / 0x10000;
r4135r4136
330330                  break;
331331
332332               case 0x20: // rot 180
333                  copyrozbitmap( tmpbitmap1, tmpbitmap0,
333                  copyrozbitmap_trans( tmpbitmap1, NULL, tmpbitmap0,
334334                     (UINT32)16<<16,
335335                     (UINT32)16<<16,
336336                     -1 << 16,
337337                     0 << 16,
338338                     0 << 16,
339339                     -1 << 16,
340                     0, cliprect, TRANSPARENCY_PEN, 0, 0 );
340                     0, 0 );
341341
342342                     currx = (sx - (x+1) * xdim) / 0x10000;
343343                     curry = (sy - (y+1) * ydim) / 0x10000;
r4135r4136
346346                  break;
347347
348348               case 0x30: // rot 270
349                  copyrozbitmap( tmpbitmap1, tmpbitmap0,
349                  copyrozbitmap_trans( tmpbitmap1, NULL, tmpbitmap0,
350350                     (UINT32)16<<16,
351351                     (UINT32)0<<16,
352352                     0 << 16,
353353                     1 << 16,
354354                     -1 << 16,
355355                     0 << 16,
356                     0, cliprect, TRANSPARENCY_PEN, 0, 0 );
356                     0, 0 );
357357
358358                     currx = (sx + y * ydim) / 0x10000;
359359                     curry = (sy - (x+1) * xdim) / 0x10000;
src/mame/video/bottom9.c
r4135r4136
8484   bitmap_fill(bitmap,cliprect,layer_colorbase[1]);
8585//  if (bottom9_video_enable)
8686   {
87      K051960_sprites_draw(bitmap,cliprect,1,1);
87      K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
8888      K051316_zoom_draw_0(bitmap,cliprect,0,0);
89      K051960_sprites_draw(bitmap,cliprect,0,0);
89      K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
9090      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
9191      /* note that priority 3 is opposite to the basic layer priority! */
9292      /* (it IS used, but hopefully has no effect) */
93      K051960_sprites_draw(bitmap,cliprect,2,3);
93      K051960_sprites_draw(screen->machine,bitmap,cliprect,2,3);
9494      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
9595   }
9696   return 0;
src/mame/video/battlera.c
r4135r4136
1313
1414static int HuC6270_registers[20];
1515static int VDC_register,vram_ptr;
16static UINT8 *HuC6270_vram,*tile_dirty,*sprite_dirty,*vram_dirty;
16static UINT8 *HuC6270_vram,*vram_dirty;
1717static bitmap_t *tile_bitmap,*front_bitmap;
18static UINT32 tile_dirtyseq;
1819
1920static int current_scanline,inc_value;
2021static int irq_enable,rcr_enable,sb_enable,bb_enable,bldwolf_vblank;
2122
23static UINT8 blank_tile[32];
2224
2325
2426/******************************************************************************/
r4135r4136
2628VIDEO_START( battlera )
2729{
2830   HuC6270_vram=auto_malloc(0x20000);
29   tile_dirty=auto_malloc(0x1000);
30   sprite_dirty=auto_malloc(0x400);
3131   vram_dirty=auto_malloc(0x1000);
3232
3333   memset(HuC6270_vram,0,0x20000);
34   memset(tile_dirty,1,0x1000);
35   memset(sprite_dirty,1,0x400);
3634   memset(vram_dirty,1,0x1000);
3735
3836   tile_bitmap=auto_bitmap_alloc(512,512,video_screen_get_format(machine->primary_screen));
r4135r4136
4240   inc_value=1;
4341   current_scanline=0;
4442   irq_enable=rcr_enable=sb_enable=bb_enable=0;
43
44   gfx_element_set_source(machine->gfx[0], HuC6270_vram);
45   gfx_element_set_source(machine->gfx[1], HuC6270_vram);
46   gfx_element_set_source(machine->gfx[2], blank_tile);
4547}
4648
4749/******************************************************************************/
r4135r4136
133135         case 2: /* VRAM */
134136            if (HuC6270_vram[(HuC6270_registers[0]<<1)|1]!=data) {
135137               HuC6270_vram[(HuC6270_registers[0]<<1)|1]=data;
136               tile_dirty[HuC6270_registers[0]>>4]=1;
137               sprite_dirty[HuC6270_registers[0]>>6]=1;
138               gfx_element_mark_dirty(space->machine->gfx[0], HuC6270_registers[0]>>4);
139               gfx_element_mark_dirty(space->machine->gfx[1], HuC6270_registers[0]>>6);
138140            }
139141            if (HuC6270_registers[0]<0x1000) vram_dirty[HuC6270_registers[0]]=1;
140142            return;
r4135r4136
193195         case 2: /* VWR - VRAM */
194196            if (HuC6270_vram[(HuC6270_registers[0]<<1)|0]!=data) {
195197               HuC6270_vram[(HuC6270_registers[0]<<1)|0]=data;
196               tile_dirty[HuC6270_registers[0]>>4]=1;
197               sprite_dirty[HuC6270_registers[0]>>6]=1;
198               gfx_element_mark_dirty(space->machine->gfx[0], HuC6270_registers[0]>>4);
199               gfx_element_mark_dirty(space->machine->gfx[1], HuC6270_registers[0]>>6);
198200               if (HuC6270_registers[0]<0x1000) vram_dirty[HuC6270_registers[0]]=1;
199201            }
200202            HuC6270_registers[0]+=inc_value;
r4135r4136
313315{
314316   int offs,code,scrollx,scrolly,mx,my;
315317
316   /* Dynamically decode chars if dirty */
317   for (code = 0x0000;code < 0x1000;code++)
318      if (tile_dirty[code])
319         decodechar(screen->machine->gfx[0],code,HuC6270_vram);
318   /* if any tiles changed, redraw the VRAM */
319   if (screen->machine->gfx[0]->dirtyseq != tile_dirtyseq)
320   {
321      tile_dirtyseq = screen->machine->gfx[0]->dirtyseq;
322      memset(vram_dirty, 1, 0x1000);
323   }
320324
321   /* Dynamically decode sprites if dirty */
322   for (code = 0x0000;code < 0x400;code++)
323      if (sprite_dirty[code])
324         decodechar(screen->machine->gfx[1],code,HuC6270_vram);
325
326   /* NB: If first 0x1000 byte is always tilemap, no need to decode the first batch of tiles/sprites */
327
328325   mx=-1;
329326   my=0;
330327   for (offs = 0x0000;offs < 0x2000;offs += 2)
r4135r4136
334331      code=HuC6270_vram[offs+1] + ((HuC6270_vram[offs] & 0x0f) << 8);
335332
336333      /* If this tile was changed OR tilemap was changed, redraw */
337      if (tile_dirty[code] || vram_dirty[offs/2]) {
334      if (vram_dirty[offs/2]) {
338335         vram_dirty[offs/2]=0;
339336           drawgfx(tile_bitmap,screen->machine->gfx[0],
340337               code,
r4135r4136
357354         }
358355   }
359356
360   /* Nothing dirty after a screen refresh */
361   for (code = 0x0000;code < 0x1000;code++)
362      tile_dirty[code]=0;
363   for (code = 0x0000;code < 0x400;code++)
364      sprite_dirty[code]=0;
365
366357   /* Render bitmap */
367358   scrollx=-HuC6270_registers[7];
368359   scrolly=-HuC6270_registers[8]+cliprect->min_y-1;
src/mame/video/namcos1.c
r4135r4136
5252static UINT8 *tilemap_maskdata;
5353static int copy_sprites;
5454
55static UINT8 drawmode_table[16];
5556
5657
5758
59
5860/***************************************************************************
5961
6062  Callbacks for the TileMap code
r4135r4136
126128   state_save_register_global_array(machine, namcos1_playfield_control);
127129
128130   /* set table for sprite color == 0x7f */
129   for (i = 0;i <= 15;i++)
130      gfx_drawmode_table[i] = DRAWMODE_SHADOW;
131   for (i = 0;i < 15;i++)
132      drawmode_table[i] = DRAWMODE_SHADOW;
133   drawmode_table[15] = DRAWMODE_NONE;
131134
132135   /* clear paletteram */
133136   memset(namcos1_paletteram, 0, 0x8000);
r4135r4136
278281   const UINT8 *source = &spriteram[0x0800-0x20];   /* the last is NOT a sprite */
279282   const UINT8 *finish = &spriteram[0];
280283   gfx_element *gfx = machine->gfx[1];
281   gfx_element mygfx = *gfx;
282284
283285   int sprite_xoffs = spriteram[0x07f5] + ((spriteram[0x07f4] & 1) << 8);
284286   int sprite_yoffs = spriteram[0x07f7];
r4135r4136
318320
319321      sy++;   /* sprites are buffered and delayed by one scanline */
320322
321      /* change GfxElement parameters to draw only the needed part of the 32x32 tile */
322      mygfx.width = sizex;
323      mygfx.height = sizey;
324      mygfx.gfxdata = gfx->gfxdata + tx + ty * gfx->line_modulo;
323      gfx_element_set_source_clip(gfx, tx, sizex, ty, sizey);
324      if (color != 0x7f)
325         pdrawgfx_transpen( bitmap, cliprect, gfx,
326               sprite,
327               color,
328               flipx,flipy,
329               sx & 0x1ff,
330               ((sy + 16) & 0xff) - 16,
331               priority_bitmap, pri_mask,
332               0xf);
333      else
334         pdrawgfx_transtable( bitmap, cliprect, gfx,
335               sprite,
336               color,
337               flipx,flipy,
338               sx & 0x1ff,
339               ((sy + 16) & 0xff) - 16,
340               priority_bitmap, pri_mask,
341               drawmode_table, machine->shadow_table);
325342
326      pdrawgfx( bitmap, &mygfx,
327            sprite,
328            color,
329            flipx,flipy,
330            sx & 0x1ff,
331            ((sy + 16) & 0xff) - 16,
332            cliprect,(color != 0x7f) ? TRANSPARENCY_PEN : TRANSPARENCY_PEN_TABLE,0xf, pri_mask);
333
334343      source -= 0x10;
335344   }
336345}
src/mame/video/mainevt.c
r4135r4136
9999   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,4);   /* high priority part of layer */
100100   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,8);
101101
102   K051960_sprites_draw(bitmap,cliprect,-1,-1);
102   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
103103   return 0;
104104}
105105
r4135r4136
109109
110110   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,0);
111111   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
112   K051960_sprites_draw(bitmap,cliprect,0,0);
112   K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
113113   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
114114   return 0;
115115}
src/mame/video/8080bw.c
r4135r4136
2222static UINT8 schaser_background_disable;
2323static UINT8 schaser_background_select;
2424
25MACHINE_START( extra_8080bw_vh )
26{
27    state_save_register_global(machine, c8080bw_flip_screen);
28    state_save_register_global(machine, color_map);
29    state_save_register_global(machine, screen_red);
2530
31    // These two only belong to schaser, but for simplicity's sake let's waste
32    // two bytes in other drivers' .sta files.
33    state_save_register_global(machine, schaser_background_disable);
34    state_save_register_global(machine, schaser_background_select);
35}
2636
2737void c8080bw_flip_screen_w(const address_space *space, int data)
2838{
src/mame/video/tail2nos.c
r4135r4136
99
1010static int charbank,charpalette,video_enable;
1111static UINT16 *zoomdata;
12static int dirtygfx;
13static UINT8 *dirtychar;
1412
1513#define TOTAL_CHARS 0x400
1614
r4135r4136
5654
5755   K051316_vh_start_0(machine,"gfx3",-4,TRUE,0,zoom_callback);
5856
59   dirtychar = auto_malloc(TOTAL_CHARS);
60   memset(dirtychar,1,TOTAL_CHARS);
61
6257   tilemap_set_transparent_pen(bg_tilemap,15);
6358
6459   K051316_wraparound_enable(0,1);
r4135r4136
9085   int oldword = zoomdata[offset];
9186   COMBINE_DATA(&zoomdata[offset]);
9287   if (oldword != zoomdata[offset])
93   {
94      dirtygfx = 1;
95      dirtychar[offset / 64] = 1;
96   }
88      gfx_element_mark_dirty(space->machine->gfx[2], offset / 64);
9789}
9890
9991WRITE16_HANDLER( tail2nos_gfxbank_w )
r4135r4136
164156
165157VIDEO_UPDATE( tail2nos )
166158{
167   if (dirtygfx)
168   {
169      int i;
170
171      dirtygfx = 0;
172
173      for (i = 0;i < TOTAL_CHARS;i++)
174      {
175         if (dirtychar[i])
176         {
177            dirtychar[i] = 0;
178            decodechar(screen->machine->gfx[2],i,(UINT8 *)zoomdata);
179         }
180      }
181
182      tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
183   }
184
185
186159   if (video_enable)
187160   {
188161      K051316_zoom_draw_0(bitmap,cliprect,0,0);
src/mame/video/victory.c
r4135r4136
11131113   /* blend the bitmaps and do collision detection */
11141114   for (y = 0; y < 256; y++)
11151115   {
1116      UINT16 *scanline = BITMAP_ADDR16(bitmap, y, 0);
11161117      UINT8 sy = scrolly + y;
11171118      UINT8 *fg = &fgbitmap[y * 256];
11181119      UINT8 *bg = &bgbitmap[sy * 256];
1119      UINT8 scanline[256];
11201120
11211121      /* do the blending */
11221122      for (x = 0; x < 256; x++)
r4135r4136
11271127         if (fpix && (bpix & bgcollmask) && count++ < 128)
11281128            timer_set(screen->machine, video_screen_get_time_until_pos(screen, y, x), NULL, x | (y << 8), bgcoll_irq_callback);
11291129      }
1130
1131      /* draw the scanline */
1132      draw_scanline8(bitmap, 0, y, 256, scanline, NULL, -1);
11331130   }
11341131
11351132   return 0;
src/mame/video/cninja.c
r4135r4136
9393   deco16_set_tilemap_colour_base(1,0x30);
9494   deco16_set_tilemap_colour_base(2,0x20);
9595   deco16_set_tilemap_colour_base(3,0x40);
96
97   alpha_set_level(0x80);
9896}
9997
10098/******************************************************************************/
r4135r4136
325323   while (offs!=end)
326324   {
327325      int x,y,sprite,colour,fx,fy,w,h,sx,sy,x_mult,y_mult;
328      int trans=TRANSPARENCY_PEN;
326      int alpha=0xff;
329327
330328      sprite = spriteptr[offs+3];
331329      if (!sprite) {
r4135r4136
347345      colour = (spriteptr[offs+2] >>0) & 0x1f;
348346
349347      if (gfxbank==4) { /* Seems to be always alpha'd */
350         trans=TRANSPARENCY_ALPHA;
348         alpha=0x80;
351349         colour&=0xf;
352350      }
353351
r4135r4136
380378
381379      for (x=0; x<w; x++) {
382380         for (y=0; y<h; y++) {
383            pdrawgfx(bitmap,machine->gfx[gfxbank],
381            pdrawgfx_alpha(bitmap,cliprect,machine->gfx[gfxbank],
384382                  sprite + y + h * x,
385383                  colour,
386384                  fx,fy,
387385                  sx + x_mult * (w-x),sy + y_mult * (h-y),
388                  cliprect,trans,0,0);
386                  priority_bitmap,0,
387                  0,alpha);
389388         }
390389      }
391390
src/mame/video/taitosj.c
r4135r4136
3636static bitmap_t *sprite_sprite_collbitmap1,*sprite_sprite_collbitmap2;
3737static bitmap_t *sprite_layer_collbitmap1;
3838static bitmap_t *sprite_layer_collbitmap2[3];
39static UINT8 dirtycharacter1[256],dirtycharacter2[256];
40static UINT8 dirtysprite1[64],dirtysprite2[64];
4139
4240static const int layer_enable_mask[3] = { 0x10, 0x20, 0x40 };
4341
r4135r4136
154152   }
155153}
156154
157
158static STATE_POSTLOAD( taitosj_postload )
159{
160   memset(dirtycharacter1, 1, sizeof(dirtycharacter1));
161   memset(dirtycharacter2, 1, sizeof(dirtycharacter2));
162   memset(dirtysprite1, 1, sizeof(dirtysprite1));
163   memset(dirtysprite2, 1, sizeof(dirtysprite2));
164}
165
166155/***************************************************************************
167156
168157  Start the video hardware emulation.
r4135r4136
214203   sprite_sprite_collbitmap1 = auto_bitmap_alloc(32,32,video_screen_get_format(machine->primary_screen));
215204   sprite_sprite_collbitmap2 = auto_bitmap_alloc(32,32,video_screen_get_format(machine->primary_screen));
216205
217   memset(dirtycharacter1, 1, sizeof(dirtycharacter1));
218   memset(dirtycharacter2, 1, sizeof(dirtycharacter2));
219   memset(dirtysprite1, 1, sizeof(dirtysprite1));
220   memset(dirtysprite2, 1, sizeof(dirtysprite2));
206   gfx_element_set_source(machine->gfx[0], taitosj_characterram);
207   gfx_element_set_source(machine->gfx[1], taitosj_characterram);
208   gfx_element_set_source(machine->gfx[2], taitosj_characterram + 0x1800);
209   gfx_element_set_source(machine->gfx[3], taitosj_characterram + 0x1800);
221210
222211   compute_draw_order(machine);
223
224   state_save_register_postload(machine, taitosj_postload, NULL);
225212}
226213
227214
r4135r4136
253240   {
254241      if (offset < 0x1800)
255242      {
256         dirtycharacter1[(offset / 8) & 0xff] = 1;
257         dirtysprite1[(offset / 32) & 0x3f] = 1;
243         gfx_element_mark_dirty(space->machine->gfx[0], (offset / 8) & 0xff);
244         gfx_element_mark_dirty(space->machine->gfx[1], (offset / 32) & 0x3f);
258245      }
259246      else
260247      {
261         dirtycharacter2[(offset / 8) & 0xff] = 1;
262         dirtysprite2[(offset / 32) & 0x3f] = 1;
248         gfx_element_mark_dirty(space->machine->gfx[2], (offset / 8) & 0xff);
249         gfx_element_mark_dirty(space->machine->gfx[3], (offset / 32) & 0x3f);
263250      }
264251
265252      taitosj_characterram[offset] = data;
r4135r4136
537524}
538525
539526
540static void decode_modified(running_machine *machine)
541{
542   offs_t offs;
543
544   /* decode modified characters */
545   for (offs = 0;offs < 256;offs++)
546   {
547      if (dirtycharacter1[offs] == 1)
548      {
549         decodechar(machine->gfx[0], offs, taitosj_characterram);
550         dirtycharacter1[offs] = 0;
551      }
552
553      if (dirtycharacter2[offs] == 1)
554      {
555         decodechar(machine->gfx[2], offs, taitosj_characterram + 0x1800);
556         dirtycharacter2[offs] = 0;
557      }
558   }
559
560   /* decode modified sprites */
561   for (offs = 0;offs < 64;offs++)
562   {
563      if (dirtysprite1[offs] == 1)
564      {
565         decodechar(machine->gfx[1], offs, taitosj_characterram);
566         dirtysprite1[offs] = 0;
567      }
568
569      if (dirtysprite2[offs] == 1)
570      {
571         decodechar(machine->gfx[3], offs, taitosj_characterram + 0x1800);
572         dirtysprite2[offs] = 0;
573      }
574   }
575}
576
577
578527static void draw_layers(running_machine *machine)
579528{
580529   offs_t offs;
r4135r4136
802751
803752   set_pens(machine);
804753
805   decode_modified(machine);
806
807754   draw_layers(machine);
808755
809756   calculate_sprite_areas(machine, sprites_on, sprite_areas);
src/mame/video/esripsys.c
r4135r4136
88#include "cpu/m6809/m6809.h"
99#include "esripsys.h"
1010
11typedef struct _pixel_
11
12/*************************************
13 *
14 *  Statics
15 *
16 *************************************/
17
18struct
1219{
13   UINT8 colour;
14   UINT8 intensity;
15   UINT8 priority;
16} pixel;
20   UINT8 *colour_buf;
21   UINT8 *intensity_buf;
22   UINT8 *priority_buf;
23} line_buffer[2];
1724
1825static emu_timer *hblank_end_timer;
1926static emu_timer *hblank_start_timer;
2027
2128static UINT8 *fig_scale_table;
2229static UINT8 *scale_table;
23static pixel *line_buffer_1;
24static pixel *line_buffer_2;
2530
26static int vcount;
2731static int video_firq;
2832static UINT8 bg_intensity;
2933
34
35/*************************************
36 *
37 *  Globals
38 *
39 *************************************/
40
41int esripsys_hblank;
3042int esripsys_video_firq_en;
3143int esripsys_frame_vbl;
3244int esripsys__12sel;
r4135r4136
4153
4254static TIMER_CALLBACK( hblank_start_callback )
4355{
44   int v = vcount;
56   int v = video_screen_get_vpos(machine->primary_screen);
4557
4658   if (video_firq)
4759   {
r4135r4136
4961      cpu_set_input_line(machine->cpu[ESRIPSYS_GAME_CPU], M6809_FIRQ_LINE, CLEAR_LINE);
5062   }
5163
52   if (!(vcount % 6) && vcount && esripsys_video_firq_en && vcount < ESRIPSYS_VBLANK_START)
64   /* Not sure if this is totally accurate - I couldn't find the circuit that generates the FIRQs! */
65   if (!(v % 6) && v && esripsys_video_firq_en && v < ESRIPSYS_VBLANK_START)
5366   {
5467      video_firq = 1;
5568      cpu_set_input_line(machine->cpu[ESRIPSYS_GAME_CPU], M6809_FIRQ_LINE, ASSERT_LINE);
5669   }
5770
5871   /* Adjust for next scanline */
59   if (++vcount >= ESRIPSYS_VTOTAL)
60      vcount = 0;
72   if (++v >= ESRIPSYS_VTOTAL)
73      v = 0;
6174
6275   /* Set end of HBLANK timer */
63   timer_adjust_oneshot(hblank_end_timer, video_screen_get_time_until_pos(machine->primary_screen, v, ESRIPSYS_HTOTAL-1), v);
76   timer_adjust_oneshot(hblank_end_timer, video_screen_get_time_until_pos(machine->primary_screen, v, ESRIPSYS_HBLANK_END), v);
77   esripsys_hblank = 0;
6478}
6579
6680static TIMER_CALLBACK( hblank_end_callback )
6781{
68   video_screen_update_partial(machine->primary_screen, param);
82   int v = video_screen_get_vpos(machine->primary_screen);
6983
84   if (v > 0)
85      video_screen_update_partial(machine->primary_screen, v - 1);
86
7087   esripsys__12sel ^= 1;
71   timer_adjust_oneshot(hblank_start_timer, video_screen_get_time_until_pos(machine->primary_screen, vcount, ESRIPSYS_HBLANK_START), 0);
88   timer_adjust_oneshot(hblank_start_timer, video_screen_get_time_until_pos(machine->primary_screen, v, ESRIPSYS_HBLANK_START), 0);
89
90   esripsys_hblank = 1;
7291}
7392
7493VIDEO_START( esripsys )
r4135r4136
7695   int i;
7796
7897   /* Allocate memory for the two 512-pixel line buffers */
79   line_buffer_1 = auto_malloc(512 * sizeof(pixel));
80   line_buffer_2 = auto_malloc(512 * sizeof(pixel));
98   line_buffer[0].colour_buf = auto_malloc(512);
99   line_buffer[0].intensity_buf = auto_malloc(512);
100   line_buffer[0].priority_buf = auto_malloc(512);
81101
102   line_buffer[1].colour_buf = auto_malloc(512);
103   line_buffer[1].intensity_buf = auto_malloc(512);
104   line_buffer[1].priority_buf = auto_malloc(512);
105
82106   /* Create and initialise the HBLANK timers */
83107   hblank_start_timer = timer_alloc(machine, hblank_start_callback, NULL);
84108   hblank_end_timer = timer_alloc(machine, hblank_end_callback, NULL);
r4135r4136
140164         fig_scale_table[i * 64 + scale] = scaled_pixels - 1;
141165      }
142166   }
167
168   /* Register stuff for state saving */
169   state_save_register_global_pointer(machine, line_buffer[0].colour_buf, 512);
170   state_save_register_global_pointer(machine, line_buffer[0].intensity_buf, 512);
171   state_save_register_global_pointer(machine, line_buffer[0].priority_buf, 512);
172
173   state_save_register_global_pointer(machine, line_buffer[1].colour_buf, 512);
174   state_save_register_global_pointer(machine, line_buffer[1].intensity_buf, 512);
175   state_save_register_global_pointer(machine, line_buffer[1].priority_buf, 512);
176
177   state_save_register_global(machine, video_firq);
178   state_save_register_global(machine, bg_intensity);
179   state_save_register_global(machine, esripsys_hblank);
180   state_save_register_global(machine, esripsys_video_firq_en);
181   state_save_register_global(machine, esripsys_frame_vbl);
182   state_save_register_global(machine, esripsys__12sel);
143183}
144184
145185VIDEO_UPDATE( esripsys )
146186{
147   int x;
148   int y;
149   pixel *src;
187   int x, y;
150188
151   /* Select line buffer to scan out */
152   if (esripsys__12sel)
153      src = line_buffer_2;
154   else
155      src = line_buffer_1;
189   UINT8 *colour_buf = line_buffer[esripsys__12sel ? 0 : 1].colour_buf;
190   UINT8 *intensity_buf = line_buffer[esripsys__12sel ? 0 : 1].intensity_buf;
191   UINT8 *priority_buf = line_buffer[esripsys__12sel ? 0 : 1].priority_buf;
156192
157193   for (y = cliprect->min_y; y <= cliprect->max_y; ++y)
158194   {
159      UINT32 *dest = BITMAP_ADDR32(bitmap, y, 0);
195      UINT32 *dest = BITMAP_ADDR32(bitmap, y, cliprect->min_x);
160196
161      for (x = cliprect->min_x; x <= cliprect->max_x; ++x)
197      for (x = 0; x < 512; ++x)
162198      {
163         int idx = src[x].colour;
199         int idx = colour_buf[x];
164200         int r = (esripsys_pal_ram[idx] & 0xf);
165201         int g = (esripsys_pal_ram[256 + idx] & 0xf);
166202         int b = (esripsys_pal_ram[512 + idx] & 0xf);
167         int i = src[x].intensity;
203         int i = intensity_buf[x];
168204
169205         *dest++ = MAKE_RGB(r*i, g*i, b*i);
170206
171207         /* Clear the line buffer as we scan out */
172         src[x].colour = 0xff;
173         src[x].intensity = bg_intensity;
174         src[x].priority = 0;
208         colour_buf[x] = 0xff;
209         intensity_buf[x] = bg_intensity;
210         priority_buf[x] = 0;
175211      }
176212   }
177213
r4135r4136
186222/* Draw graphics to a line buffer */
187223int esripsys_draw(running_machine *machine, int l, int r, int fig, int attr, int addr, int col, int x_scale, int line_latch)
188224{
189   pixel *dst;
225   UINT8 *colour_buf = line_buffer[esripsys__12sel ? 1 : 0].colour_buf;
226   UINT8 *intensity_buf = line_buffer[esripsys__12sel ? 1 : 0].intensity_buf;
227   UINT8 *priority_buf = line_buffer[esripsys__12sel ? 1 : 0].priority_buf;
228
190229   UINT8 pri = attr & 0xff;
191230   UINT8 iny = (attr >> 8) & 0xf;
192231   UINT8 pal = col << 4;
r4135r4136
198237   if (xs_typ)
199238      fig = fig_scale_table[fig * 64 + xs_val];
200239
201   if (esripsys__12sel)
202      dst = line_buffer_1;
203   else
204      dst = line_buffer_2;
205
206240   /* 8bpp case */
207241   if (attr & 0x8000)
208242   {
r4135r4136
230264         UINT8 pix1 = rom_l[rom_addr];
231265         UINT8 pix2 = rom_r[rom_addr];
232266
233         if ((UINT32)lpos < 512)
267         if (lpos < 512)
234268         {
235            if ((pri > dst[lpos].priority) && pix1 != 0xff)
269            if ((pri > priority_buf[lpos]) && pix1 != 0xff)
236270            {
237               dst[lpos].colour = pix1;
238               dst[lpos].priority = pri;
239               dst[lpos].intensity = iny;
271               colour_buf[lpos] = pix1;
272               priority_buf[lpos] = pri;
273               intensity_buf[lpos] = iny;
240274            }
241275         }
242276
243         if ((UINT32)rpos < 512)
277         if (rpos < 512)
244278         {
245            if ((pri > dst[rpos].priority) && pix2 != 0xff)
279            if ((pri > priority_buf[rpos]) && pix2 != 0xff)
246280            {
247               dst[rpos].colour = pix2;
248               dst[rpos].priority = pri;
249               dst[rpos].intensity = iny;
281               colour_buf[rpos] = pix2;
282               priority_buf[rpos] = pri;
283               intensity_buf[rpos] = iny;
250284            }
251285         }
252286
r4135r4136
307341            px1 = (px8 >> 4) & 0xf;
308342         }
309343
310         if ((UINT32)lpos < 512)
344         if (lpos < 512)
311345         {
312            if ((pri > dst[lpos].priority) && px1 != 0xf)
346            if (pri > priority_buf[lpos] && px1 != 0xf)
313347            {
314               dst[lpos].colour = pal | px1;
315               dst[lpos].priority = pri;
316               dst[lpos].intensity = iny;
348               colour_buf[lpos] = pal | px1;
349               priority_buf[lpos] = pri;
350               intensity_buf[lpos] = iny;
317351            }
318352         }
319353
320         if ((UINT32)rpos < 512)
354         if (rpos < 512)
321355         {
322            if (pri > dst[rpos].priority && px2 != 0xf)
356            if (pri > priority_buf[rpos] && px2 != 0xf)
323357            {
324               dst[rpos].colour = pal | px2;
325               dst[rpos].priority = pri;
326               dst[rpos].intensity = iny;
358               colour_buf[rpos] = pal | px2;
359               priority_buf[rpos] = pri;
360               intensity_buf[rpos] = iny;
327361            }
328362         }
329363
src/mame/video/f1gp.c
r4135r4136
1010size_t f1gp_spr1cgram_size,f1gp_spr2cgram_size;
1111
1212static UINT16 *zoomdata;
13static int dirtygfx,flipscreen,gfxctrl;
14static UINT8 *dirtychar;
13static int flipscreen,gfxctrl;
1514
1615#define TOTAL_CHARS 0x800
1716
r4135r4136
6362
6463   tilemap_set_transparent_pen(fg_tilemap,0xff);
6564
66   dirtychar = auto_malloc(TOTAL_CHARS);
67   memset(dirtychar,1,TOTAL_CHARS);
68
6965   zoomdata = (UINT16 *)memory_region(machine, "gfx4");
66   gfx_element_set_source(machine->gfx[3], (UINT8 *)zoomdata);
7067}
7168
7269VIDEO_START( f1gpb )
r4135r4136
7673
7774   tilemap_set_transparent_pen(fg_tilemap,0xff);
7875
79   dirtychar = auto_malloc(TOTAL_CHARS);
80   memset(dirtychar,1,TOTAL_CHARS);
81
8276   zoomdata = (UINT16 *)memory_region(machine, "gfx4");
77   gfx_element_set_source(machine->gfx[3], (UINT8 *)zoomdata);
8378}
8479
8580VIDEO_START( f1gp2 )
r4135r4136
9590
9691   tilemap_set_scrolldx(fg_tilemap,-80,0);
9792   tilemap_set_scrolldy(fg_tilemap,-26,0);
98
99   dirtychar = auto_malloc(TOTAL_CHARS);
100   memset(dirtychar,1,TOTAL_CHARS);
101
102   zoomdata = (UINT16 *)memory_region(machine, "gfx4");
10393}
10494
10595
r4135r4136
116106
117107WRITE16_HANDLER( f1gp_zoomdata_w )
118108{
119   int oldword = zoomdata[offset];
120109   COMBINE_DATA(&zoomdata[offset]);
121   if (oldword != zoomdata[offset])
122   {
123      dirtygfx = 1;
124      dirtychar[offset / 64] = 1;
125   }
110   gfx_element_mark_dirty(space->machine->gfx[3], offset / 64);
126111}
127112
128113READ16_HANDLER( f1gp_rozvideoram_r )
r4135r4136
330315
331316VIDEO_UPDATE( f1gp )
332317{
333   if (dirtygfx)
334   {
335      int i;
336
337      dirtygfx = 0;
338
339      for (i = 0;i < TOTAL_CHARS;i++)
340      {
341         if (dirtychar[i])
342         {
343            dirtychar[i] = 0;
344            decodechar(screen->machine->gfx[3],i,(UINT8 *)zoomdata);
345         }
346      }
347
348      tilemap_mark_all_tiles_dirty(roz_tilemap);
349   }
350
351
352
353318   bitmap_fill(priority_bitmap, cliprect, 0);
354319
355320   K053936_0_zoom_draw(bitmap,cliprect,roz_tilemap,0,0);
r4135r4136
375340   UINT32 startx,starty;
376341   int incxx,incxy,incyx,incyy;
377342
378   if (dirtygfx)
379   {
380      int i;
381
382      dirtygfx = 0;
383
384      for (i = 0;i < TOTAL_CHARS;i++)
385      {
386         if (dirtychar[i])
387         {
388            dirtychar[i] = 0;
389            decodechar(screen->machine->gfx[3],i,(UINT8 *)zoomdata);
390         }
391      }
392
393      tilemap_mark_all_tiles_dirty(roz_tilemap);
394   }
395
396343   incxy = (INT16)f1gpb_rozregs[1];
397344   incyx = -incxy;
398345   incxx = incyy = (INT16)f1gpb_rozregs[3];
src/mame/video/namcos2.c
r4135r4136
294294{
295295   int i;
296296   /* set table for sprite color == 0x0f */
297   for(i = 0;i <= 253;i++)
298   {
299      gfx_drawmode_table[i] = DRAWMODE_SOURCE;
300   }
301   gfx_drawmode_table[254] = DRAWMODE_SHADOW;
302   gfx_drawmode_table[255] = DRAWMODE_NONE;
303297   for( i = 0; i<16*256; i++ )
304298   {
305299      machine->shadow_table[i] = i+0x2000;
r4135r4136
334328   clip->min_y = GetPaletteRegister(2) - 0x21;
335329   clip->max_y = GetPaletteRegister(3) - 0x21 - 1;
336330   /* intersect with master clip rectangle */
337   if( clip->min_x < cliprect->min_x ){ clip->min_x = cliprect->min_x; }
338   if( clip->min_y < cliprect->min_y ){ clip->min_y = cliprect->min_y; }
339   if( clip->max_x > cliprect->max_x ){ clip->max_x = cliprect->max_x; }
340   if( clip->max_y > cliprect->max_y ){ clip->max_y = cliprect->max_y; }
331   sect_rect(clip, cliprect);
341332} /* ApplyClip */
342333
343334VIDEO_UPDATE( namcos2_default )
src/mame/video/polyplay.c
r4135r4136
1414
1515
1616UINT8 *polyplay_characterram;
17static UINT8 dirtycharacter[256];
1817
1918
2019
r4135r4136
3837{
3938   if (polyplay_characterram[offset] != data)
4039   {
41      dirtycharacter[((offset >> 3) & 0x7f) | 0x80] = 1;
40      gfx_element_mark_dirty(space->machine->gfx[1], ((offset >> 3) & 0x7f) | 0x80);
4241
4342      polyplay_characterram[offset] = data;
4443   }
4544}
4645
46VIDEO_START( polyplay )
47{
48   gfx_element_set_source(machine->gfx[1], polyplay_characterram);
49}
4750
51
4852VIDEO_UPDATE( polyplay )
4953{
5054   offs_t offs;
r4135r4136
5660      int sy = offs >> 6 << 3;
5761      UINT8 code = videoram[offs];
5862
59      if (dirtycharacter[code])
60      {
61         decodechar(screen->machine->gfx[1], code & 0x7f, polyplay_characterram);
62
63         dirtycharacter[code] = 0;
64      }
65
6663      drawgfx(bitmap,screen->machine->gfx[(code >> 7) & 0x01],
6764            code, 0, 0, 0, sx, sy,
6865            cliprect, TRANSPARENCY_NONE, 0);
src/mame/video/exidy440.c
r4135r4136
420420         sy -= (VBSTART - VBEND);
421421
422422      /* draw line */
423      draw_scanline8(bitmap, 0, y, (HBSTART - HBEND), &local_videoram[sy * 512], NULL, -1);
423      draw_scanline8(bitmap, 0, y, (HBSTART - HBEND), &local_videoram[sy * 512], NULL);
424424   }
425425
426426   /* draw the sprites */
src/mame/video/dassault.c
r4135r4136
2020   {
2121      for (offs = 0x800-4;offs >= 0; offs -= 4)
2222      {
23         int trans=TRANSPARENCY_PEN, pmask=0;
23         int alpha=0xff, pmask=0;
2424
2525         /* Draw the main spritebank after the other one */
2626         if (bank==0)
r4135r4136
4141
4242         /* Alpha on chip 2 only */
4343         if (bank==1 && x&0xc000)
44            trans=TRANSPARENCY_ALPHA;
44            alpha=0x80;
4545
4646         y = spritebase[offs];
4747         flash=y&0x1000;
r4135r4136
134134                  colour,
135135                  fx,fy,
136136                  x,y + mult * multi,
137                  cliprect,trans,0,pmask,1<<bank, 1);
137                  cliprect,0,pmask,1<<bank, 1, alpha);
138138
139139            multi--;
140140         }
r4135r4136
157157   deco16_set_tilemap_bank_callback(1,dassault_bank_callback);
158158   deco16_set_tilemap_bank_callback(2,dassault_bank_callback);
159159   deco16_set_tilemap_bank_callback(3,dassault_bank_callback);
160
161   alpha_set_level(0x80);
162160}
163161
164162/******************************************************************************/
src/mame/video/tatsumi.c
r4135r4136
4848
4949   offset=offset%0xc000;
5050
51   decodechar(space->machine->gfx[1],offset/0x10,(UINT8 *)roundup5_vram);
51   gfx_element_mark_dirty(space->machine->gfx[1],offset/0x10);
5252}
5353
5454
r4135r4136
207207
208208   memset(shadow_pen_array, 0, 8192);
209209   tilemap_set_transparent_pen(tx_layer,0);
210
211   gfx_element_set_source(machine->gfx[1], (UINT8 *)roundup5_vram);
210212}
211213
212214VIDEO_START( cyclwarr )
r4135r4136
271273      {
272274         const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
273275         const UINT8 *shadow_pens = shadow_pen_array + (gfx->color_granularity * (color % gfx->total_colors));
274         int source_base = (code % gfx->total_elements) * gfx->height;
276         const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
275277
276278         int block_size = 8 * scalex;
277279         int sprite_screen_height = ((ssy&0xffff)+block_size)>>16;
r4135r4136
397399                        int x, x_index = x_index_base;
398400                        for( x=sx; x<ex; x++ )
399401                        {
400                           UINT8 *source = gfx->gfxdata + (source_base+((cy>>16))) * gfx->line_modulo;
402                           const UINT8 *source = code_base + (cy>>16) * gfx->line_modulo;
401403                           int c = source[(cx >> 16)];
402404                           if( c != transparent_color )
403405                           {
r4135r4136
421423                  {
422424                     for( y=sy; y<ey; y++ )
423425                     {
424                        UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * gfx->line_modulo;
426                        const UINT8 *source = code_base + (y_index>>16) * gfx->line_modulo;
425427                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
426428                        UINT8 *priority_dest = BITMAP_ADDR8(dest_bmp, y, 0);
427429
src/mame/video/konamiic.c
r4135r4136
12121212
12131213   memcpy(&gl, layout, sizeof(gl));
12141214   gl.total = total;
1215   machine->gfx[gfx_index] = allocgfx(machine, &gl);
1216   decodegfx(machine->gfx[gfx_index], data, 0, machine->gfx[gfx_index]->total_elements);
1217
1218   /* set the color information */
1219   machine->gfx[gfx_index]->total_colors = machine->config->total_colors / (1 << bpp);
1215   machine->gfx[gfx_index] = gfx_element_alloc(machine, &gl, data, machine->config->total_colors >> bpp, 0);
12201216}
12211217
12221218
r4135r4136
24772473void K051960_vh_start(running_machine *machine,const char *gfx_memory_region,int plane_order,
24782474      void (*callback)(int *code,int *color,int *priority,int *shadow))
24792475{
2480   int gfx_index,i;
2476   int gfx_index;
24812477   UINT32 total;
24822478   static const gfx_layout spritelayout =
24832479   {
r4135r4136
25482544   if (VERBOSE && !(machine->config->video_attributes & VIDEO_HAS_SHADOWS))
25492545      popmessage("driver should use VIDEO_HAS_SHADOWS");
25502546
2551   /* prepare shadow draw table */
2552   gfx_drawmode_table[0] = DRAWMODE_NONE;
2553   for (i = 1;i < 15;i++)
2554      gfx_drawmode_table[i] = DRAWMODE_SOURCE;
2555   gfx_drawmode_table[15] = DRAWMODE_SHADOW;
2556
25572547   K051960_dx = K051960_dy = 0;
25582548
25592549   K051960_memory_region = gfx_memory_region;
r4135r4136
27302720 * Note that Aliens also uses the shadow bit to select the second sprite bank.
27312721 */
27322722
2733void K051960_sprites_draw(bitmap_t *bitmap,const rectangle *cliprect,int min_priority,int max_priority)
2723void K051960_sprites_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int min_priority,int max_priority)
27342724{
27352725#define NUM_SPRITES 128
27362726   int offs,pri_code;
27372727   int sortedlist[NUM_SPRITES];
2728   UINT8 drawmode_table[256];
27382729
2730   memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
2731   drawmode_table[0] = DRAWMODE_NONE;
2732
27392733   for (offs = 0;offs < NUM_SPRITES;offs++)
27402734      sortedlist[offs] = -1;
27412735
r4135r4136
28122806         flipy = !flipy;
28132807      }
28142808
2809      drawmode_table[K051960_gfx->color_granularity-1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
2810
28152811      if (zoomx == 0x10000 && zoomy == 0x10000)
28162812      {
28172813         int sx,sy;
r4135r4136
28312827               else c += yoffset[y];
28322828
28332829               if (max_priority == -1)
2834                  pdrawgfx(bitmap,K051960_gfx,
2830                  pdrawgfx_transtable(bitmap,cliprect,K051960_gfx,
28352831                        c,
28362832                        color,
28372833                        flipx,flipy,
28382834                        sx & 0x1ff,sy,
2839                        cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,pri);
2835                        priority_bitmap,pri,
2836                        drawmode_table,machine->shadow_table);
28402837               else
2841                  drawgfx(bitmap,K051960_gfx,
2838                  drawgfx_transtable(bitmap,cliprect,K051960_gfx,
28422839                        c,
28432840                        color,
28442841                        flipx,flipy,
28452842                        sx & 0x1ff,sy,
2846                        cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0);
2843                        drawmode_table,machine->shadow_table);
28472844            }
28482845         }
28492846      }
r4135r4136
28682865               else c += yoffset[y];
28692866
28702867               if (max_priority == -1)
2871                  pdrawgfxzoom(bitmap,K051960_gfx,
2868                  pdrawgfxzoom_transtable(bitmap,cliprect,K051960_gfx,
28722869                        c,
28732870                        color,
28742871                        flipx,flipy,
28752872                        sx & 0x1ff,sy,
2876                        cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
2877                        (zw << 16) / 16,(zh << 16) / 16,pri);
2873                        (zw << 16) / 16,(zh << 16) / 16,
2874                        priority_bitmap,pri,
2875                        drawmode_table,machine->shadow_table);
28782876               else
2879                  drawgfxzoom(bitmap,K051960_gfx,
2877                  drawgfxzoom_transtable(bitmap,cliprect,K051960_gfx,
28802878                        c,
28812879                        color,
28822880                        flipx,flipy,
28832881                        sx & 0x1ff,sy,
2884                        cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
2885                        (zw << 16) / 16,(zh << 16) / 16);
2882                        (zw << 16) / 16,(zh << 16) / 16,
2883                        drawmode_table,machine->shadow_table);
28862884            }
28872885         }
28882886      }
r4135r4136
29992997void K053245_vh_start(running_machine *machine,int chip, const char *gfx_memory_region,int plane_order,
30002998      void (*callback)(int *code,int *color,int *priority))
30012999{
3002   int gfx_index,i;
3000   int gfx_index;
30033001   UINT32 total;
30043002   static const gfx_layout spritelayout =
30053003   {
r4135r4136
30423040      popmessage("driver should use VIDEO_HAS_SHADOWS");
30433041
30443042
3045   /* prepare shadow draw table */
3046   gfx_drawmode_table[0] = DRAWMODE_NONE;
3047   for (i = 1;i < 15;i++)
3048      gfx_drawmode_table[i] = DRAWMODE_SOURCE;
3049   gfx_drawmode_table[15] = DRAWMODE_SHADOW;
30503043   K05324x_z_rejection = -1;
30513044   K053245_memory_region[chip] = gfx_memory_region;
30523045   K053245_gfx[chip] = machine->gfx[gfx_index];
r4135r4136
32443237 * The rest of the sprite remains normal.
32453238 */
32463239
3247void K053245_sprites_draw(int chip, bitmap_t *bitmap,const rectangle *cliprect) //*
3240void K053245_sprites_draw(running_machine *machine, int chip, bitmap_t *bitmap,const rectangle *cliprect) //*
32483241{
32493242#define NUM_SPRITES 128
32503243   int offs,pri_code,i;
32513244   int sortedlist[NUM_SPRITES];
32523245   int flipscreenX, flipscreenY, spriteoffsX, spriteoffsY;
3246   UINT8 drawmode_table[256];
32533247
3248   memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
3249   drawmode_table[0] = DRAWMODE_NONE;
3250
32543251   flipscreenX = K053244_regs[chip][5] & 0x01;
32553252   flipscreenY = K053244_regs[chip][5] & 0x02;
32563253   spriteoffsX = (K053244_regs[chip][0] << 8) | K053244_regs[chip][1];
r4135r4136
33723369      ox -= (zoomx * w) >> 13;
33733370      oy -= (zoomy * h) >> 13;
33743371
3372      drawmode_table[K053245_gfx[chip]->color_granularity-1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
3373
33753374      for (y = 0;y < h;y++)
33763375      {
33773376         int sx,sy,zw,zh;
r4135r4136
34343433
34353434            if (zoomx == 0x10000 && zoomy == 0x10000)
34363435            {
3437               pdrawgfx(bitmap,K053245_gfx[chip],
3436               pdrawgfx_transtable(bitmap,cliprect,K053245_gfx[chip],
34383437                     c,
34393438                     color,
34403439                     fx,fy,
34413440                     sx,sy,
3442                     cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,pri);
3441                     priority_bitmap,pri,
3442                     drawmode_table,machine->shadow_table);
34433443            }
34443444            else
34453445            {
3446               pdrawgfxzoom(bitmap,K053245_gfx[chip],
3446               pdrawgfxzoom_transtable(bitmap,cliprect,K053245_gfx[chip],
34473447                     c,
34483448                     color,
34493449                     fx,fy,
34503450                     sx,sy,
3451                     cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
3452                     (zw << 16) / 16,(zh << 16) / 16,pri);
3451                     (zw << 16) / 16,(zh << 16) / 16,
3452                     priority_bitmap,pri,
3453                     drawmode_table,machine->shadow_table);
34533454
34543455            }
34553456         }
r4135r4136
34793480   int offs,pri_code,i;
34803481   int sortedlist[NUM_SPRITES];
34813482   int flipscreenX, flipscreenY, spriteoffsX, spriteoffsY;
3483   UINT8 drawmode_table[256];
34823484
3485   memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
3486   drawmode_table[0] = DRAWMODE_NONE;
3487
34833488   flipscreenX = K053244_regs[chip][5] & 0x01;
34843489   flipscreenY = K053244_regs[chip][5] & 0x02;
34853490   spriteoffsX = (K053244_regs[chip][0] << 8) | K053244_regs[chip][1];
r4135r4136
36013606      ox -= (zoomx * w) >> 13;
36023607      oy -= (zoomy * h) >> 13;
36033608
3609      drawmode_table[machine->gfx[0]->color_granularity-1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
3610
36043611      for (y = 0;y < h;y++)
36053612      {
36063613         int sx,sy,zw,zh;
r4135r4136
36633670
36643671            if (zoomx == 0x10000 && zoomy == 0x10000)
36653672            {
3666               pdrawgfx(bitmap,machine->gfx[0], /* hardcoded to 0 (decoded 6bpp gfx) for le */
3673               pdrawgfx_transtable(bitmap,cliprect,machine->gfx[0], /* hardcoded to 0 (decoded 6bpp gfx) for le */
36673674                     c,
36683675                     color,
36693676                     fx,fy,
36703677                     sx,sy,
3671                     cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,pri);
3678                     priority_bitmap,pri,
3679                     drawmode_table,machine->shadow_table);
36723680            }
36733681            else
36743682            {
3675               pdrawgfxzoom(bitmap,machine->gfx[0],  /* hardcoded to 0 (decoded 6bpp gfx) for le */
3683               pdrawgfxzoom_transtable(bitmap,cliprect,machine->gfx[0],  /* hardcoded to 0 (decoded 6bpp gfx) for le */
36763684                     c,
36773685                     color,
36783686                     fx,fy,
36793687                     sx,sy,
3680                     cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
3681                     (zw << 16) / 16,(zh << 16) / 16,pri);
3688                     (zw << 16) / 16,(zh << 16) / 16,
3689                     priority_bitmap,pri,
3690                     drawmode_table,machine->shadow_table);
36823691
36833692            }
36843693         }
r4135r4136
37473756void K053247_vh_start(running_machine *machine, const char *gfx_memory_region, int dx, int dy, int plane_order,
37483757                void (*callback)(int *code,int *color,int *priority))
37493758{
3750   int gfx_index,i;
3759   int gfx_index;
37513760   UINT32 total;
37523761   static const gfx_layout spritelayout =
37533762   {
r4135r4136
37953804   }
37963805   }
37973806
3798   /* prepare shadow draw table */
3799   gfx_drawmode_table[0] = DRAWMODE_NONE;
3800   for (i = 1;i < 15;i++)
3801      gfx_drawmode_table[i] = DRAWMODE_SOURCE;
3802   gfx_drawmode_table[15] = DRAWMODE_SHADOW;
3803
38043807   K053247_dx = dx;
38053808   K053247_dy = dy;
38063809   K053247_wraparound = 1;
r4135r4136
38713874      16*16*6
38723875   };
38733876   UINT8 *s1, *s2, *d;
3874   long i, c;
3877   long i;
38753878   UINT16 *K055673_rom;
38763879   int size4;
38773880
r4135r4136
39303933   if (VERBOSE && !(machine->config->video_attributes & VIDEO_HAS_SHADOWS))
39313934      popmessage("driver should use VIDEO_HAS_SHADOWS");
39323935
3933   /* prepare shadow draw table */
3934   c = machine->gfx[gfx_index]->color_granularity-1;
3935   gfx_drawmode_table[0] = DRAWMODE_NONE;
3936   for (i = 1;i < c;i++)
3937      gfx_drawmode_table[i] = DRAWMODE_SOURCE;
3938   gfx_drawmode_table[c] = DRAWMODE_SHADOW;
3939
39403936   K053247_dx = dx;
39413937   K053247_dy = dy;
39423938   K053247_wraparound = 1;
r4135r4136
40354031   {
40364032      case 0:   // 20k / 36u
40374033         return ROM[romofs+2];
4038         break;
40394034      case 1:   // 17k / 36y
40404035         return ROM[romofs+3];
4041         break;
40424036      case 2: // 10k / 32y
40434037      case 3:
40444038         romofs /= 2;
4045                return ROM8[romofs+1];
4046         break;
4039         return ROM8[romofs+1];
40474040      case 4:   // 22k / 34u
40484041         return ROM[romofs];
4049         break;
40504042      case 5:   // 19k / 34y
40514043         return ROM[romofs+1];
4052         break;
40534044      case 6:   // 12k / 29y
40544045      case 7:
40554046         romofs /= 2;
4056                return ROM8[romofs];
4057         break;
4047         return ROM8[romofs];
40584048      default:
40594049         LOG(("55673_rom_word_r: Unknown read offset %x\n", offset));
40604050         break;
r4135r4136
40774067   {
40784068      case 0:
40794069         return ROM[romofs+3];
4080         break;
40814070      case 1:
40824071         return ROM[romofs+4];
4083         break;
40844072      case 2:
40854073      case 3:
4086                return ROM[romofs+5];
4087         break;
4074         return ROM[romofs+5];
40884075      case 4:
40894076         return ROM[romofs];
4090         break;
40914077      case 5:
40924078         return ROM[romofs+1];
4093         break;
40944079      case 6:
40954080      case 7:
4096                return ROM[romofs+2];
4097         break;
4081         return ROM[romofs+2];
40984082      default:
40994083         LOG(("55673_rom_word_r: Unknown read offset %x (PC=%x)\n", offset, cpu_get_pc(space->cpu)));
41004084         break;
r4135r4136
42214205   int offx = (short)((K053246_regs[0] << 8) | K053246_regs[1]);
42224206   int offy = (short)((K053246_regs[2] << 8) | K053246_regs[3]);
42234207
4224   int solidpens = K053247_gfx->color_granularity - 1;
42254208   int screen_width = video_screen_get_width(machine->primary_screen);
4209   UINT8 drawmode_table[256];
4210   UINT8 shadowmode_table[256];
4211   UINT8 *whichtable;
42264212
4213   memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
4214   drawmode_table[0] = DRAWMODE_NONE;
4215   memset(shadowmode_table, DRAWMODE_SHADOW, sizeof(shadowmode_table));
4216   shadowmode_table[0] = DRAWMODE_NONE;
4217
42274218   /*
42284219        safeguard older drivers missing any of the following video attributes:
42294220
r4135r4136
43934384      if (mirrorx) flipx = 0; // documented and confirmed
43944385      mirrory = shadow & 0x8000;
43954386
4387      whichtable = drawmode_table;
43964388      if (color == -1)
43974389      {
43984390         // drop the entire sprite to shadow unconditionally
43994391         if (shdmask < 0) continue;
44004392         color = 0;
44014393         shadow = -1;
4402         for (temp=1; temp<solidpens; temp++) gfx_drawmode_table[temp] = DRAWMODE_SHADOW;
4394         whichtable = shadowmode_table;
44034395         palette_set_shadow_mode(machine, 0);
44044396      }
44054397      else
r4135r4136
44484440      ox -= (zoomx * w) >> 13;
44494441      oy -= (zoomy * h) >> 13;
44504442
4443      drawmode_table[K053247_gfx->color_granularity-1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
4444
44514445      for (y = 0;y < h;y++)
44524446      {
44534447         int sx,sy,zw,zh;
r4135r4136
45054499
45064500            if (nozoom)
45074501            {
4508               pdrawgfx(bitmap,K053247_gfx,
4502               pdrawgfx_transtable(bitmap,cliprect,K053247_gfx,
45094503                     c,
45104504                     color,
45114505                     fx,fy,
45124506                     sx,sy,
4513                     cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,primask);
4507                     priority_bitmap,primask,
4508                     whichtable,machine->shadow_table);
45144509            }
45154510            else
45164511            {
4517               pdrawgfxzoom(bitmap,K053247_gfx,
4512               pdrawgfxzoom_transtable(bitmap,cliprect,K053247_gfx,
45184513                     c,
45194514                     color,
45204515                     fx,fy,
45214516                     sx,sy,
4522                     cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
4523                     (zw << 16) >> 4,(zh << 16) >> 4,primask);
4517                     (zw << 16) >> 4,(zh << 16) >> 4,
4518                     priority_bitmap,primask,
4519                     whichtable,machine->shadow_table);
45244520            }
45254521
45264522            if (mirrory && h == 1)  /* Simpsons shadows */
45274523            {
45284524               if (nozoom)
45294525               {
4530                  pdrawgfx(bitmap,K053247_gfx,
4526                  pdrawgfx_transtable(bitmap,cliprect,K053247_gfx,
45314527                        c,
45324528                        color,
45334529                        fx,!fy,
45344530                        sx,sy,
4535                        cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,primask);
4531                        priority_bitmap,primask,
4532                        whichtable,machine->shadow_table);
45364533               }
45374534               else
45384535               {
4539                  pdrawgfxzoom(bitmap,K053247_gfx,
4536                  pdrawgfxzoom_transtable(bitmap,cliprect,K053247_gfx,
45404537                        c,
45414538                        color,
45424539                        fx,!fy,
45434540                        sx,sy,
4544                        cliprect,shadow ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,0,
4545                        (zw << 16) >> 4,(zh << 16) >> 4,primask);
4541                        (zw << 16) >> 4,(zh << 16) >> 4,
4542                        priority_bitmap,primask,
4543                        whichtable,machine->shadow_table);
45464544               }
45474545            }
45484546         } // end of X loop
45494547      } // end of Y loop
45504548
4551      // reset drawmode_table
4552      if (shadow == -1) for (temp=1; temp<solidpens; temp++) gfx_drawmode_table[temp] = DRAWMODE_SOURCE;
4553
45544549   } // end of sprite-list loop
45554550#undef NUM_SPRITES
45564551}
r4135r4136
64886483
64896484         UINT8 code_transparent, code_opaque;
64906485         const pen_t *pal_ptr;
6491         const UINT8  *src_base, *src_ptr;
6486         const UINT8  *src_ptr;
64926487         UINT8  *xpr_ptr;
64936488         UINT16 *dst_ptr;
64946489         UINT16 pen, basepen;
r4135r4136
65096504         pixmap  = K056832_pixmap[page];
65106505         pal_ptr    = machine->pens;
65116506         src_gfx    = machine->gfx[K056832_gfxnum];
6512         src_base   = src_gfx->gfxdata;
65136507         src_pitch  = src_gfx->line_modulo;
65146508         src_modulo = src_gfx->char_modulo;
65156509         dst_pitch  = pixmap->rowpixels;
r4135r4136
65616555   return(0);
65626556}
65636557
6564void K056832_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int flags, UINT32 priority)
6558void K056832_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, UINT32 flags, UINT32 priority)
65656559{
65666560   static int last_colorbase[K056832_PAGE_COUNT];
65676561
r4135r4136
66206614   } else corr = 0;
66216615   corr -= K056832_LayerOffset[layer][0];
66226616
6623   if (scrollmode == 0 && (flags & TILE_LINE_DISABLED))
6617   if (scrollmode == 0 && (flags & K056382_DRAW_FLAG_FORCE_XYSCROLL))
66246618   {
66256619      scrollmode = 3;
6626      flags &= ~TILE_LINE_DISABLED;
6620      flags &= ~K056382_DRAW_FLAG_FORCE_XYSCROLL;
66276621   }
66286622
66296623   switch( scrollmode )
r4135r4136
68446838
68456839} // end of function
68466840
6847void K056832_tilemap_draw_dj(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int flags, UINT32 priority) //*
6841void K056832_tilemap_draw_dj(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, UINT32 flags, UINT32 priority) //*
68486842{
68496843   static int last_colorbase[K056832_PAGE_COUNT];
68506844
r4135r4136
68996893   } else corr = 0;
69006894   corr -= K056832_LayerOffset[layer][0];
69016895
6902   if (scrollmode == 0 && (flags & TILE_LINE_DISABLED))
6896   if (scrollmode == 0 && (flags & K056382_DRAW_FLAG_FORCE_XYSCROLL))
69036897   {
69046898      scrollmode = 3;
6905      flags &= ~TILE_LINE_DISABLED;
6899      flags &= ~K056382_DRAW_FLAG_FORCE_XYSCROLL;
69066900   }
69076901
69086902   switch( scrollmode )
r4135r4136
74097403
74107404   if (pblend <= 0 || pblend > 3)
74117405   {
7412      alpha_set_level(255);
74137406      return(255);
74147407   }
74157408
r4135r4136
74247417   if (!(mixset & 0x20))
74257418   {
74267419      mixlv = mixlv<<3 | mixlv>>2;
7427      alpha_set_level(mixlv); // source x alpha/255  +  target x (255-alpha)/255
74287420    }
74297421   else
74307422   {
r4135r4136
74407432      // DUMMY
74417433      if (mixlv && mixlv<0x1f) mixlv = 0x10;
74427434      mixlv = mixlv<<3 | mixlv>>2;
7443      alpha_set_level(mixlv);
74447435
74457436      if (VERBOSE)
74467437         popmessage("MIXSET%1d %s addition mode: %02x",pblend,(mixpri)?"dst":"src",mixset&0x1f);
src/mame/video/gbusters.c
r4135r4136
5757   /* sprite priority 3 = disable */
5858   if (gbusters_priority)
5959   {
60//      K051960_sprites_draw(bitmap,cliprect,1,1);  /* are these used? */
60//      K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);  /* are these used? */
6161      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
62      K051960_sprites_draw(bitmap,cliprect,2,2);
62      K051960_sprites_draw(screen->machine,bitmap,cliprect,2,2);
6363      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
64      K051960_sprites_draw(bitmap,cliprect,0,0);
64      K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
6565      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
6666   }
6767   else
6868   {
69//      K051960_sprites_draw(bitmap,cliprect,1,1);  /* are these used? */
69//      K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);  /* are these used? */
7070      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,0);
71      K051960_sprites_draw(bitmap,cliprect,2,2);
71      K051960_sprites_draw(screen->machine,bitmap,cliprect,2,2);
7272      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
73      K051960_sprites_draw(bitmap,cliprect,0,0);
73      K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
7474      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
7575   }
7676   return 0;
src/mame/video/konamiic.h
r4135r4136
104104WRITE8_HANDLER( K051937_w );
105105READ16_HANDLER( K051937_word_r );
106106WRITE16_HANDLER( K051937_word_w );
107void K051960_sprites_draw(bitmap_t *bitmap,const rectangle *cliprect,int min_priority,int max_priority);
107void K051960_sprites_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int min_priority,int max_priority);
108108int K051960_is_IRQ_enabled(void);
109109int K051960_is_NMI_enabled(void);
110110void K051960_set_sprite_offsets(int dx, int dy);
r4135r4136
129129READ16_HANDLER( K053244_word_r );
130130WRITE16_HANDLER( K053244_word_w );
131131void K053244_bankselect(int chip, int bank);   /* used by TMNT2, Asterix and Premier Soccer for ROM testing */
132void K053245_sprites_draw(int chip, bitmap_t *bitmap,const rectangle *cliprect);
132void K053245_sprites_draw(running_machine *machine, int chip, bitmap_t *bitmap,const rectangle *cliprect);
133133void K053245_sprites_draw_lethal(running_machine *machine, int chip, bitmap_t *bitmap,const rectangle *cliprect); /* for lethal enforcers */
134134void K053245_clear_buffer(int chip);
135135void K053245_set_SpriteOffset(int chip,int offsx, int offsy);
r4135r4136
254254
255255void K056832_SetExtLinescroll(void);   /* Lethal Enforcers */
256256
257#define K056382_DRAW_FLAG_FORCE_XYSCROLL      0x00800000
258
257259void K056832_vh_start(running_machine *machine, const char *gfx_memory_region, int bpp, int big,
258260         int (*scrolld)[4][2],
259261         void (*callback)(int layer, int *code, int *color, int *flags),
r4135r4136
284286WRITE8_HANDLER( K056832_b_w );
285287void K056832_mark_plane_dirty(int num);
286288void K056832_MarkAllTilemapsDirty(void);
287void K056832_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int num, int flags, UINT32 priority);
288void K056832_tilemap_draw_dj(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int flags, UINT32 priority);
289void K056832_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int num, UINT32 flags, UINT32 priority);
290void K056832_tilemap_draw_dj(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, UINT32 flags, UINT32 priority);
289291void K056832_set_LayerAssociation(int status);
290292int  K056832_get_LayerAssociation(void);
291293void K056832_set_LayerOffset(int layer, int offsx, int offsy);
src/mame/video/snk68.c
r4135r4136
1919static int sprite_flip_axis;
2020static tilemap *fg_tilemap;
2121static int flipscreen;
22static UINT32 fg_tile_offset;
2223
2324/***************************************************************************
2425
r4135r4136
2829
2930static TILE_GET_INFO( get_pow_tile_info )
3031{
31   int tile = (pow_fg_videoram[2*tile_index] & 0xff);
32   int tile = fg_tile_offset + (pow_fg_videoram[2*tile_index] & 0xff);
3233   int color = pow_fg_videoram[2*tile_index+1] & 0x07;
3334
3435   SET_TILE_INFO(0, tile, color, 0);
r4135r4136
6364VIDEO_START( pow )
6465{
6566   fg_tilemap = tilemap_create(machine, get_pow_tile_info,tilemap_scan_cols,8,8,32,32);
67   fg_tile_offset = 0;
6668
6769   common_video_start(machine);
6870}
r4135r4136
139141
140142      sprite_flip_axis = data & 0x04;   // for streetsm? though might not be present on this board
141143
142      tilemap_set_pen_data_offset(fg_tilemap, ((data & 0x70) << 4) * space->machine->gfx[0]->char_modulo);
144      if (fg_tile_offset != ((data & 0x70) << 4))
145      {
146         fg_tile_offset = (data & 0x70) << 4;
147         tilemap_mark_all_tiles_dirty(fg_tilemap);
148      }
143149   }
144150}
145151
src/mame/video/madalien.c
r4135r4136
127127   SET_TILE_INFO(0, madalien_videoram[tile_index], 0, 0);
128128}
129129
130WRITE8_HANDLER( madalien_videoram_w )
131{
132   madalien_videoram[offset] = data;
133   tilemap_mark_tile_dirty(tilemap_fg, offset);
134}
130135
136
131137static VIDEO_START( madalien )
132138{
133139   int i;
r4135r4136
160166
161167   headlight_bitmap = auto_bitmap_alloc(128, 128, BITMAP_FORMAT_INDEXED16);
162168
169   gfx_element_set_source(machine->gfx[0], madalien_charram);
170
163171   drawgfx(headlight_bitmap, machine->gfx[2], 0, 0, 0, 0, 0x00, 0x00, NULL, TRANSPARENCY_NONE, 0);
164172   drawgfx(headlight_bitmap, machine->gfx[2], 0, 0, 0, 1, 0x00, 0x40, NULL, TRANSPARENCY_NONE, 0);
165173}
r4135r4136
240248
241249static void draw_foreground(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int flip)
242250{
243   int i;
244
245   for (i = 0; i < 256; i++)
246      decodechar(machine->gfx[0], i, madalien_charram);
247
248   tilemap_mark_all_tiles_dirty(tilemap_fg);
249251   tilemap_set_flip(tilemap_fg, flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
250252   tilemap_draw(bitmap, cliprect, tilemap_fg, 0, 0);
251253}
252254
253255
256WRITE8_HANDLER( madalien_charram_w )
257{
258   madalien_charram[offset] = data;
259   gfx_element_mark_dirty(space->machine->gfx[0], (offset/8) & 0xff);
260}
261
262
254263static VIDEO_UPDATE( madalien )
255264{
256265   int flip = BIT(input_port_read(screen->machine, "DSW"), 6) && BIT(*madalien_video_control, 0);
src/mame/video/aeroboto.c
r4135r4136
4848
4949   tilemap_set_scroll_rows(bg_tilemap,64);
5050
51    state_save_register_global(machine, aeroboto_charbank);
52    state_save_register_global(machine, aeroboto_starsoff);
53
5154   #if STARS_LAYOUT
5255   {
5356      UINT8 *rom, *temp;
src/mame/video/mcr68.c
r4135r4136
7373   const UINT8 *colordatabase = (const UINT8 *)memory_region(machine, "gfx3");
7474   gfx_element *gfx0 = machine->gfx[0];
7575   gfx_element *gfx2 = machine->gfx[2];
76   UINT8 *srcdata0, *dest0;
77   UINT8 *srcdata2, *dest2;
7678   int code, y, x;
7779
7880   /* initialize the background tilemap */
r4135r4136
8284   fg_tilemap = tilemap_create(machine, zwackery_get_fg_tile_info, tilemap_scan_rows,  16,16, 32,32);
8385   tilemap_set_transparent_pen(fg_tilemap, 0);
8486
87   /* allocate memory for the assembled gfx data */
88   srcdata0 = auto_malloc(gfx0->total_elements * gfx0->width * gfx0->height);
89   srcdata2 = auto_malloc(gfx2->total_elements * gfx2->width * gfx2->height);
90
8591   /* "colorize" each code */
92   dest0 = srcdata0;
93   dest2 = srcdata2;
8694   for (code = 0; code < gfx0->total_elements; code++)
8795   {
8896      const UINT8 *coldata = colordatabase + code * 32;
89      UINT8 *gfxdata0 = gfx0->gfxdata + code * gfx0->char_modulo;
90      UINT8 *gfxdata2 = gfx2->gfxdata + code * gfx2->char_modulo;
97      const UINT8 *gfxdata0 = gfx_element_get_data(gfx0, code);
98      const UINT8 *gfxdata2 = gfx_element_get_data(gfx2, code);
9199
92100      /* assume 16 rows */
93101      for (y = 0; y < 16; y++)
94102      {
95         UINT8 *gd0 = gfxdata0;
96         UINT8 *gd2 = gfxdata2;
103         const UINT8 *gd0 = gfxdata0;
104         const UINT8 *gd2 = gfxdata2;
97105
98106         /* 16 columns */
99107         for (x = 0; x < 16; x++, gd0++, gd2++)
r4135r4136
104112            int tp0, tp1;
105113
106114            /* every 4 pixels gets its own foreground/background colors */
107            *gd0 = *gd0 ? pen1 : pen0;
115            *dest0++ = *gd0 ? pen1 : pen0;
108116
109117            /* for gfx 2, we convert all low-priority pens to 0 */
110118            tp0 = (pen0 & 0x80) ? pen0 : 0;
111119            tp1 = (pen1 & 0x80) ? pen1 : 0;
112            *gd2 = *gd2 ? tp1 : tp0;
120            *dest2++ = *gd2 ? tp1 : tp0;
113121         }
114122
115123         /* advance */
r4135r4136
117125         gfxdata2 += gfx2->line_modulo;
118126      }
119127   }
128
129   /* create a simple target layout */
130   gfx0->layout.planes = gfx2->layout.planes = 8;
131   for (x = 0; x < 8; x++)
132      gfx0->layout.planeoffset[x] = gfx2->layout.planeoffset[x] = x;
133   for (x = 0; x < gfx0->width; x++)
134      gfx0->layout.xoffset[x] = gfx2->layout.xoffset[x] = 8 * x;
135   for (y = 0; y < gfx0->height; y++)
136      gfx0->layout.yoffset[y] = gfx2->layout.yoffset[y] = 8 * y * gfx0->width;
137   gfx0->layout.charincrement = gfx2->layout.charincrement = 8 * gfx0->width * gfx0->height;
138
139   /* make the assembled data our new source data */
140   gfx_element_set_source(gfx0, srcdata0);
141   gfx_element_set_source(gfx2, srcdata2);
120142}
121143
122144
src/mame/video/thunderx.c
r4135r4136
8686   }
8787   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,4);
8888
89   K051960_sprites_draw(bitmap,cliprect,-1,-1);
89   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
9090   return 0;
9191}
src/mame/video/xmen.c
r4135r4136
124124   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
125125   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
126126
127   pdrawgfx_shadow_lowpri = 1;   /* fix shadows of boulders in front of feet */
127/* this isn't supported anymore and it is unsure if still needed; keeping here for reference
128    pdrawgfx_shadow_lowpri = 1; fix shadows of boulders in front of feet */
128129   K053247_sprites_draw(screen->machine, bitmap,cliprect);
129130   return 0;
130131}
r4135r4136
250251   tilemap_draw(renderbitmap,&cliprect,K052109_tilemap[layer[1]],0,2);
251252   tilemap_draw(renderbitmap,&cliprect,K052109_tilemap[layer[2]],0,4);
252253
253   pdrawgfx_shadow_lowpri = 1;   /* fix shadows of boulders in front of feet */
254/* this isn't supported anymore and it is unsure if still needed; keeping here for reference
255    pdrawgfx_shadow_lowpri = 1; fix shadows of boulders in front of feet */
254256   K053247_sprites_draw(machine, renderbitmap,&cliprect);
255257
256258}
src/mame/video/lethal.c
r4135r4136
4545
4646VIDEO_START(lethalen)
4747{
48   int i;
49
5048   K053251_vh_start(machine);
5149
5250   K056832_vh_start(machine, "gfx1", K056832_BPP_8LE, 1, NULL, lethalen_tile_callback, 0);
5351
5452   K053245_vh_start(machine, 0, "gfx3",NORMAL_PLANE_ORDER, lethalen_sprite_callback);
5553
56   /* the default drawmode table is no good for 6bpp, create a new one */
57   gfx_drawmode_table[0] = DRAWMODE_NONE;
58   for (i = 1;i < 64;i++)
59      gfx_drawmode_table[i] = DRAWMODE_SOURCE;
60
61   gfx_drawmode_table[63] = DRAWMODE_SHADOW;
62
6354   // this game uses external linescroll RAM
6455   K056832_SetExtLinescroll();
6556
src/mame/video/tecmo16.c
r4135r4136
411411                     sx = 256 - (xpos + 8*(!flipx?(sizex-1-x):x) + 8);
412412                     sy = 256 - (ypos + 8*(!flipy?(sizey-1-y):y) + 8);
413413                  }
414                  pdrawgfx(bitmap,machine->gfx[2],
414                  pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
415415                        code + layout[y][x],
416416                        machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
417417                        flipx,flipy,
418418                        sx,sy,
419                        cliprect,TRANSPARENCY_PEN_RAW,0,
420                        priority_mask);
419                        priority_bitmap, priority_mask,0);
421420
422421                  /* wrap around x */
423                  pdrawgfx(bitmap,machine->gfx[2],
422                  pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
424423                        code + layout[y][x],
425424                        machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
426425                        flipx,flipy,
427426                        sx-512,sy,
428                        cliprect,TRANSPARENCY_PEN_RAW,0,
429                        priority_mask);
427                        priority_bitmap, priority_mask,0);
430428
431429                  /* wrap around x */
432                  pdrawgfx(bitmap,machine->gfx[2],
430                  pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
433431                        code + layout[y][x],
434432                        machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
435433                        flipx,flipy,
436434                        sx+512,sy,
437                        cliprect,TRANSPARENCY_PEN_RAW,0,
438                        priority_mask);
435                        priority_bitmap, priority_mask,0);
439436               }
440437            }
441438         }
r4135r4136
457454                     sx = 256 - (xpos + 8*(!flipx?(sizex-1-x):x) + 8);
458455                     sy = 256 - (ypos + 8*(!flipy?(sizey-1-y):y) + 8);
459456                  }
460                  pdrawgfx(bitmap,machine->gfx[2],
457                  pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
461458                        code + layout[y][x],
462459                        machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
463460                        flipx,flipy,
464461                        sx,sy,
465                        cliprect,TRANSPARENCY_PEN_RAW,0,
466                        priority_mask);
462                        priority_bitmap, priority_mask,0);
467463
468464                  /* wrap around x */
469                  pdrawgfx(bitmap,machine->gfx[2],
465                  pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
470466                        code + layout[y][x],
471467                        machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
472468                        flipx,flipy,
473469                        sx-512,sy,
474                        cliprect,TRANSPARENCY_PEN_RAW,0,
475                        priority_mask);
470                        priority_bitmap, priority_mask,0);
476471
477472                  /* wrap around x */
478                  pdrawgfx(bitmap,machine->gfx[2],
473                  pdrawgfx_transpen_raw(bitmap,cliprect,machine->gfx[2],
479474                        code + layout[y][x],
480475                        machine->gfx[2]->color_base + color * machine->gfx[2]->color_granularity,
481476                        flipx,flipy,
482477                        sx+512,sy,
483                        cliprect,TRANSPARENCY_PEN_RAW,0,
484                        priority_mask);
478                        priority_bitmap, priority_mask,0);
485479               }
486480            }
487481         }
src/mame/video/toypop.c
r4135r4136
175175static void draw_background(bitmap_t *bitmap)
176176{
177177   int offs, x, y;
178   UINT16 scanline[288];
179178   pen_t pen_base = 0x300 + 0x10*palettebank;
180179
181180   // copy the background image from RAM (0x190200-0x19FDFF) to bitmap
r4135r4136
184183      offs = 0xFDFE/2;
185184      for (y = 0; y < 224; y++)
186185      {
186         UINT16 *scanline = BITMAP_ADDR16(bitmap, y, 0);
187187         for (x = 0; x < 288; x+=2)
188188         {
189189            UINT16 data = toypop_bg_image[offs];
r4135r4136
191191            scanline[x+1] = pen_base | (data >> 8);
192192            offs--;
193193         }
194         draw_scanline16(bitmap, 0, y, 288, scanline, NULL, -1);
195194      }
196195   }
197196   else
r4135r4136
199198      offs = 0x200/2;
200199      for (y = 0; y < 224; y++)
201200      {
201         UINT16 *scanline = BITMAP_ADDR16(bitmap, y, 0);
202202         for (x = 0; x < 288; x+=2)
203203         {
204204            UINT16 data = toypop_bg_image[offs];
r4135r4136
206206            scanline[x+1] = pen_base | (data & 0x0f);
207207            offs++;
208208         }
209         draw_scanline16(bitmap, 0, y, 288, scanline, NULL, -1);
210209      }
211210   }
212211}
src/mame/video/phoenix.c
r4135r4136
327327   case 0x20:
328328      /* Bit 3 is 0 */
329329      return 0;
330      break;
331330   case 0x0c:
332331   case 0x30:
333332      /* Bit 3 is 1 */
334333      return 1;
335      break;
336334   default:
337335      logerror("%s:Unknown protection question %02X\n", cpuexec_describe_context(field->port->machine), pleiads_protection_question);
338336      return 0;
src/mame/video/dday.c
r4135r4136
99***************************************************************************/
1010
1111#include "driver.h"
12#include "sound/ay8910.h"
1213
1314
1415UINT8 *dday_bgvideoram;
src/mame/video/atari.c
r4135r4136
10511051   dst[2] = antic.color_lookup[PBK] | antic.color_lookup[PBK] << 16;
10521052   dst[3] = antic.color_lookup[PBK] | antic.color_lookup[PBK] << 16;
10531053
1054   draw_scanline8(tmpbitmap, 12, y, sizeof(scanline), (const UINT8 *) scanline, NULL, -1);
1054   draw_scanline8(tmpbitmap, 12, y, MIN(tmpbitmap->width - 12, sizeof(scanline)), (const UINT8 *) scanline, NULL);
10551055}
10561056
10571057static int cycle(running_machine *machine)
src/mame/video/psikyosh.c
r4135r4136
9292#include "driver.h"
9393#include "profiler.h"
9494#include "psikyosh.h"
95#include "drawgfxm.h"
9596
9697/* Needed for psikyosh_drawgfxzoom */
9798static bitmap_t *zoom_bitmap, *z_bitmap;
99static UINT8 alphatable[256];
98100
99101/* Psikyo PS6406B */
100102/* --- BACKGROUNDS --- */
101103
104#define PIXEL_OP_REMAP_TRANS0_ALPHATABLE32(DEST, PRIORITY, SOURCE)               \
105do                                                               \
106{                                                               \
107   UINT32 srcdata = (SOURCE);                                          \
108   if (srcdata != 0)                                                \
109      (DEST) = alpha_blend_r32((DEST), paldata[srcdata], alphatable[srcdata]);   \
110}                                                               \
111while (0)                                                         \
112
113void drawgfx_alphatable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
114      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
115      int fixedalpha)
116{
117   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
118
119   const pen_t *paldata;
120
121   /* if we have a fixed alpha, call the standard drawgfx_alpha */
122   if (fixedalpha >= 0)
123   {
124      drawgfx_alpha(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, 0, fixedalpha);
125      return;
126   }
127
128   assert(dest != NULL);
129   assert(dest->bpp == 32);
130   assert(gfx != NULL);
131   assert(alphatable != NULL);
132
133   /* get final code and color, and grab lookup tables */
134   code %= gfx->total_elements;
135   color %= gfx->total_colors;
136   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
137
138   /* early out if completely transparent */
139   if (gfx->pen_usage != NULL && (gfx->pen_usage[code] & ~(1 << 0)) == 0)
140      return;
141
142   /* render based on dest bitmap depth */
143   DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANS0_ALPHATABLE32, NO_PRIORITY);
144}
145
146
102147/* 'Normal' layers, no line/columnscroll. No per-line effects */
103148static void draw_bglayer(running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect )
104149{
105150   gfx_element *gfx;
106151   int offs=0, sx, sy;
107   int scrollx, scrolly, bank, alpha, alphamap, trans, size, width;
152   int scrollx, scrolly, bank, alpha, alphamap, size, width;
108153
109154   if ( BG_TYPE(layer) == BG_NORMAL_ALT )
110155   {
r4135r4136
130175   width = BG_LARGE(layer) ? 0x200 : 0x100;
131176
132177   if(alphamap) { /* alpha values are per-pen */
133      trans = TRANSPARENCY_ALPHARANGE;
134   } else if(alpha) {
135      trans = TRANSPARENCY_ALPHA;
178      alpha = -1;
179   } else {
136180      alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
137      alpha_set_level(alpha);
138   } else {
139      trans = TRANSPARENCY_PEN;
140181   }
141182
142183   if((bank>=0x0c) && (bank<=0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */
r4135r4136
150191            tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
151192            colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24;
152193
153            drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* normal */
194            drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
154195            if(scrollx)
155               drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* wrap x */
196               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
156197            if(scrolly)
157               drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap y */
198               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
158199            if(scrollx && scrolly)
159               drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap xy */
200               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
160201
161202            offs++;
162203         }
r4135r4136
170211{
171212   gfx_element *gfx;
172213   int offs, sx, sy;
173   int scrollx, scrolly, bank, size, width, scrollbank,trans,alpha,alphamap;
214   int scrollx, scrolly, bank, size, width, scrollbank,alpha,alphamap;
174215
175216   scrollbank = BG_TYPE(layer); /* Scroll bank appears to be same as layer type */
176217
r4135r4136
186227   scrolly = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4] & 0x03ff0000) >> 16;
187228
188229   if(alphamap) { /* alpha values are per-pen */
189      trans = TRANSPARENCY_ALPHARANGE;
190   } else if(alpha) {
191      trans = TRANSPARENCY_ALPHA;
230      alpha = -1;
231   } else {
192232      alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
193      alpha_set_level(alpha);
194   } else {
195      trans = TRANSPARENCY_PEN;
196233   }
197234
198235
r4135r4136
205242            tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
206243            colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24;
207244
208            drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* normal */
245            drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
209246            if(scrollx)
210               drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* wrap x */
247               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
211248            if(scrolly)
212               drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap y */
249               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
213250            if(scrollx && scrolly)
214               drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap xy */
251               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
215252
216253            offs++;
217254   }}}
r4135r4136
224261   scrolly = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4 + 0x20/4] & 0x03ff0000) >> 16;
225262
226263   if(alphamap) { /* alpha values are per-pen */
227      trans = TRANSPARENCY_ALPHARANGE;
228   } else if(alpha) {
229      trans = TRANSPARENCY_ALPHA;
264      alpha = -1;
265   } else {
230266      alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
231      alpha_set_level(alpha);
232   } else {
233      trans = TRANSPARENCY_PEN;
234267   }
235268
236269   if((bank>=0x0c) && (bank<=0x1f)) { /* shouldn't happen, 20 banks of 0x800 bytes */
r4135r4136
242275            tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
243276            colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24;
244277
245            drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* normal */
278            drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
246279            if(scrollx)
247               drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* wrap x */
280               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
248281            if(scrolly)
249               drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap y */
282               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
250283            if(scrollx && scrolly)
251               drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap xy */
284               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
252285
253286            offs++;
254287   }}}
r4135r4136
260293{
261294   gfx_element *gfx;
262295   int offs, sx, sy;
263   int scrollx, scrolly, bank, alpha, alphamap, trans, size, width, scrollbank;
296   int scrollx, scrolly, bank, alpha, alphamap, size, width, scrollbank;
264297
265298   scrollbank = BG_TYPE(layer); /* Scroll bank appears to be same as layer type */
266299
r4135r4136
280313   width = BG_LARGE(layer) ? 0x200 : 0x100;
281314
282315   if(alphamap) { /* alpha values are per-pen */
283      trans = TRANSPARENCY_ALPHARANGE;
284   } else if(alpha) {
285      trans = TRANSPARENCY_ALPHA;
316      alpha = -1;
317   } else {
286318      alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
287      alpha_set_level(alpha);
288   } else {
289      trans = TRANSPARENCY_PEN;
290319   }
291320
292321   if((bank>=0x0c) && (bank<=0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */
r4135r4136
315344
316345//              drawgfx(zoom_bitmap,gfx,tileno,colour,0,0,(16*sx)&0x1ff,((16*sy)&(width-1)),NULL,TRANSPARENCY_PEN,0);
317346
318            drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* normal */
347            drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
319348            if(scrollx)
320               drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),cliprect,trans,0); /* wrap x */
349               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
321350            if(scrolly)
322               drawgfx(bitmap,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap y */
351               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
323352            if(scrollx && scrolly)
324               drawgfx(bitmap,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,cliprect,trans,0); /* wrap xy */
353               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
325354
326355            offs++;
327356         }
r4135r4136
395424static void psikyosh_drawgfxzoom( running_machine *machine,
396425      bitmap_t *dest_bmp,const gfx_element *gfx,
397426      UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
398      const rectangle *clip,int transparency,int transparent_color,
427      const rectangle *clip,int alpha,
399428      int zoomx, int zoomy, int wide, int high, UINT32 z)
400429{
401430   rectangle myclip; /* Clip to screen boundaries */
r4135r4136
406435
407436   profiler_mark(PROFILER_DRAWGFX);
408437
409   assert(transparency == TRANSPARENCY_PEN || transparency == TRANSPARENCY_ALPHA || transparency == TRANSPARENCY_ALPHARANGE);
410438   assert(dest_bmp->bpp == 32);
411439
412440   /* KW 991012 -- Added code to force clip to bitmap boundary */
r4135r4136
444472            for (xtile = xstart; xtile != xend; xtile += xinc )
445473            {
446474               const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
447               int source_base = ((code + code_offset++) % gfx->total_elements) * gfx->height;
475               const UINT8 *code_base = gfx_element_get_data(gfx, (code + code_offset++) % gfx->total_elements);
448476
449477               int x_index_base, y_index, sx, sy, ex, ey;
450478
r4135r4136
494522                  int y;
495523
496524                  /* case 1: TRANSPARENCY_PEN */
497                  if (transparency == TRANSPARENCY_PEN)
525                  if (alpha == 0xff)
498526                  {
499527                     if( z > 0 )
500528                     {
501                        UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
529                        const UINT8 *source = code_base + (y_index)*gfx->line_modulo + x_index_base;
502530                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
503531                        UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx;
504532                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
r4135r4136
512540                              if(z >= *pri)
513541                              {
514542                                 int c = *source;
515                                 if( c != transparent_color )
543                                 if( c != 0 )
516544                                 {
517545                                    *dest = pal[c];
518546                                    *pri = z;
r4135r4136
529557                     }
530558                     else
531559                     {
532                        UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
560                        const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
533561                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
534562                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
535563                        int dst_modulo = dest_bmp->rowpixels - (ex-sx);
r4135r4136
540568                           for( x=sx; x<ex; x++ )
541569                           {
542570                              int c = *source;
543                              if( c != transparent_color ) *dest = pal[c];
571                              if( c != 0 ) *dest = pal[c];
544572
545573                              dest++;
546574                              source += xinc;
r4135r4136
551579                     }
552580                  }
553581
554                  /* case 6: TRANSPARENCY_ALPHA */
555                  if (transparency == TRANSPARENCY_ALPHA)
582                  /* case 6: alpha-blended */
583                  else if (alpha >= 0)
556584                  {
557585                     if ( z > 0 )
558586                     {
559                        UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
587                        const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
560588                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
561589                        UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx;
562590                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
r4135r4136
570598                              if(z >= *pri)
571599                              {
572600                                 int c = *source;
573                                 if( c != transparent_color )
601                                 if( c != 0 )
574602                                 {
575                                    *dest = alpha_blend32(*dest, pal[c]);
603                                    *dest = alpha_blend_r32(*dest, pal[c], alpha);
576604                                    *pri = z;
577605                                 }
578606                              }
r4135r4136
587615                     }
588616                     else
589617                     {
590                        UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
618                        const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
591619                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
592620                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
593621                        int dst_modulo = dest_bmp->rowpixels - (ex-sx);
r4135r4136
598626                           for( x=sx; x<ex; x++ )
599627                           {
600628                              int c = *source;
601                              if( c != transparent_color ) *dest = alpha_blend32(*dest, pal[c]);
629                              if( c != 0 ) *dest = alpha_blend_r32(*dest, pal[c], alpha);
602630
603631                              dest++;
604632                              source += xinc;
r4135r4136
611639
612640                  /* pjp 31/5/02 */
613641                  /* case 7: TRANSPARENCY_ALPHARANGE */
614                  if (transparency == TRANSPARENCY_ALPHARANGE)
642                  else
615643                  {
616644                     if ( z > 0 )
617645                     {
618                        UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
646                        const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
619647                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
620648                        UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx;
621649                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
r4135r4136
629657                              if(z >= *pri)
630658                              {
631659                                 int c = *source;
632                                 if( c != transparent_color )
660                                 if( c != 0 )
633661                                 {
634                                    if( gfx_alpharange_table[c] == 0xff )
662                                    if( alphatable[c] == 0xff )
635663                                       *dest = pal[c];
636664                                    else
637                                       *dest = alpha_blend_r32(*dest, pal[c], gfx_alpharange_table[c]);
665                                       *dest = alpha_blend_r32(*dest, pal[c], alphatable[c]);
638666
639667                                    *pri = z;
640668                                 }
r4135r4136
650678                     }
651679                     else
652680                     {
653                        UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base;
681                        const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
654682                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
655683                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
656684                        int dst_modulo = dest_bmp->rowpixels - (ex-sx);
r4135r4136
661689                           for( x=sx; x<ex; x++ )
662690                           {
663691                              int c = *source;
664                              if( c != transparent_color )
692                              if( c != 0 )
665693                              {
666                                 if( gfx_alpharange_table[c] == 0xff )
694                                 if( alphatable[c] == 0xff )
667695                                    *dest = pal[c];
668696                                 else
669                                    *dest = alpha_blend_r32(*dest, pal[c], gfx_alpharange_table[c]);
697                                    *dest = alpha_blend_r32(*dest, pal[c], alphatable[c]);
670698                              }
671699                              dest++;
672700                              source += xinc;
r4135r4136
690718      {
691719         for(xtile=0; xtile<wide; xtile++)
692720         {
693            int source_base = ((code + code_offset++) % gfx->total_elements) * gfx->height;
721            const UINT8 *code_base = gfx_element_get_data(gfx, (code + code_offset++) % gfx->total_elements);
694722            for( ypixel=0; ypixel<gfx->height; ypixel++ )
695723            {
696               UINT8 *source = gfx->gfxdata + (source_base+ypixel) * gfx->line_modulo;
724               const UINT8 *source = code_base + ypixel * gfx->line_modulo;
697725               UINT8 *dest = BITMAP_ADDR8(zoom_bitmap, ypixel + ytile*gfx->height, 0);
698726
699727               for( xpixel=0; xpixel<gfx->width; xpixel++ )
r4135r4136
766794
767795               /* case 1: TRANSPARENCY_PEN */
768796               /* Note: adjusted to >>10 and draws from zoom_bitmap not gfx */
769               if (transparency == TRANSPARENCY_PEN)
797               if (alpha == 0xff)
770798               {
771799                  if( z > 0 )
772800                  {
r4135r4136
782810                           if(z >= pri[x])
783811                           {
784812                              int c = source[x_index>>10];
785                              if( c != transparent_color )
813                              if( c != 0 )
786814                              {
787815                                 dest[x] = pal[c];
788816                                 pri[x] = z;
r4135r4136
805833                        for( x=sx; x<ex; x++ )
806834                        {
807835                           int c = source[x_index>>10];
808                           if( c != transparent_color ) dest[x] = pal[c];
836                           if( c != 0 ) dest[x] = pal[c];
809837                           x_index += dx;
810838                        }
811839
r4135r4136
814842                  }
815843               }
816844
817               /* case 6: TRANSPARENCY_ALPHA */
818               if (transparency == TRANSPARENCY_ALPHA)
845               /* case 6: alpha-blended */
846               else if (alpha >= 0)
819847               {
820848                  if( z > 0 )
821849                  {
r4135r4136
831859                           if(z >= pri[x])
832860                           {
833861                              int c = source[x_index>>10];
834                              if( c != transparent_color )
862                              if( c != 0 )
835863                              {
836                                 dest[x] = alpha_blend32(dest[x], pal[c]);
864                                 dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
837865                                 pri[x] = z;
838866                              }
839867                           }
r4135r4136
854882                        for( x=sx; x<ex; x++ )
855883                        {
856884                           int c = source[x_index>>10];
857                           if( c != transparent_color ) dest[x] = alpha_blend32(dest[x], pal[c]);
885                           if( c != 0 ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
858886                           x_index += dx;
859887                        }
860888
r4135r4136
864892               }
865893
866894               /* case 7: TRANSPARENCY_ALPHARANGE */
867               if (transparency == TRANSPARENCY_ALPHARANGE)
895               else
868896               {
869897                  if( z > 0 )
870898                  {
r4135r4136
880908                           if(z >= pri[x])
881909                           {
882910                              int c = source[x_index>>10];
883                              if( c != transparent_color )
911                              if( c != 0 )
884912                              {
885                                 if( gfx_alpharange_table[c] == 0xff )
913                                 if( alphatable[c] == 0xff )
886914                                    dest[x] = pal[c];
887915                                 else
888                                    dest[x] = alpha_blend_r32(dest[x], pal[c], gfx_alpharange_table[c]);
916                                    dest[x] = alpha_blend_r32(dest[x], pal[c], alphatable[c]);
889917
890918                                 pri[x] = z;
891919                              }
r4135r4136
907935                        for( x=sx; x<ex; x++ )
908936                        {
909937                           int c = source[x_index>>10];
910                           if( c != transparent_color )
938                           if( c != 0 )
911939                           {
912                              if( gfx_alpharange_table[c] == 0xff )
940                              if( alphatable[c] == 0xff )
913941                                 dest[x] = pal[c];
914942                              else
915                                 dest[x] = alpha_blend_r32(dest[x], pal[c], gfx_alpharange_table[c]);
943                                 dest[x] = alpha_blend_r32(dest[x], pal[c], alphatable[c]);
916944                           }
917945                           x_index += dx;
918946                        }
r4135r4136
9721000   while( listcntr < listlen )
9731001   {
9741002      UINT32 listdat, sprnum, xpos, ypos, high, wide, flpx, flpy, zoomx, zoomy, tnum, colr, dpth;
975      UINT32 pri, alpha, alphamap, trans;
1003      UINT32 pri, alphamap;
1004      int alpha;
9761005
9771006      listdat = list[BYTE_XOR_BE(listcntr)];
9781007      sprnum = (listdat & 0x03ff) * 4;
r4135r4136
10091038         gfx = dpth ? machine->gfx[1] : machine->gfx[0];
10101039
10111040         if(alphamap) { /* alpha values are per-pen */
1012            trans = TRANSPARENCY_ALPHARANGE;
1013         } else if(alpha) {
1041            alpha = -1;
1042         } else {
10141043            alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
1015            trans = TRANSPARENCY_ALPHA;
1016            alpha_set_level(alpha);
1017         } else {
1018            trans = TRANSPARENCY_PEN;
10191044         }
10201045
10211046         /* start drawing */
10221047         if( zoom_table[BYTE_XOR_BE(zoomy)] && zoom_table[BYTE_XOR_BE(zoomx)] ) /* Avoid division-by-zero when table contains 0 (Uninitialised/Bug) */
10231048         {
1024            psikyosh_drawgfxzoom(machine, bitmap,gfx,tnum,colr,flpx,flpy,xpos,ypos,cliprect,trans,0,
1049            psikyosh_drawgfxzoom(machine, bitmap,gfx,tnum,colr,flpx,flpy,xpos,ypos,cliprect,alpha,
10251050                           (UINT32)zoom_table[BYTE_XOR_BE(zoomx)], (UINT32)zoom_table[BYTE_XOR_BE(zoomy)], wide, high, listcntr);
10261051
10271052#if 0
r4135r4136
10661091   { /* Pens 0xc0-0xff have a gradient of alpha values associated with them */
10671092      int i;
10681093      for (i=0; i<0xc0; i++)
1069         gfx_alpharange_table[i] = 0xff;
1094         alphatable[i] = 0xff;
10701095      for (i=0; i<0x40; i++) {
10711096         int alpha = ((0x3f-i)*0xff)/0x3f;
1072         gfx_alpharange_table[i+0xc0] = alpha;
1097         alphatable[i+0xc0] = alpha;
10731098      }
10741099   }
10751100
src/mame/video/kan_pand.c
r4135r4136
171171
172172   pandora_sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
173173   pandora_clear_bitmap = 1;
174
175    state_save_register_global(machine, pandora_clear_bitmap);
176    state_save_register_global_pointer(machine, pandora_spriteram, 0x1000);
177    state_save_register_global_bitmap(machine, pandora_sprites_bitmap);
174178}
175179
176180
src/mame/video/boogwing.c
r4135r4136
99   for (offs = 0x400-4;offs >= 0;offs -= 4)
1010   {
1111      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult,pri=0,spri=0;
12      int trans=TRANSPARENCY_PEN;
12      int alpha = 0xff;
1313
1414      sprite = spriteram_base[offs+1];
1515      if (!sprite) continue;
r4135r4136
3838
3939         // Transparency
4040         if (spriteram_base[offs+2]&0x2000)
41            trans=TRANSPARENCY_ALPHA;
41            alpha = 0x80;
4242
4343         if (deco16_priority==0x2)
4444         {
4545            // Additional sprite alpha in this mode
4646            if (spriteram_base[offs+2]&0x8000)
47               trans=TRANSPARENCY_ALPHA;
47               alpha = 0x80;
4848
4949            // Sprite vs playfield
5050            if ((spriteram_base[offs+2]&0xc000)==0xc000)
r4135r4136
123123               colour,
124124               fx,fy,
125125               x,y + mult * multi,
126               cliprect,trans, 0, pri, spri, 0);
126               cliprect, 0, pri, spri, 0, alpha);
127127
128128         multi--;
129129      }
r4135r4136
152152   deco16_set_tilemap_bank_callback(3,boogwing_bank_callback2);
153153   deco16_set_tilemap_colour_base(1,0);
154154   deco16_set_tilemap_transparency_mask(1, 0x1f); // 5bpp graphics
155
156   alpha_set_level(0x80);
157155}
158156
159157VIDEO_UPDATE(boogwing)
r4135r4136
187185
188186      // This mode uses playfield 3 to shadow sprites & playfield 2 (instead of
189187      // regular alpha-blending, the destination is inverted).  Not yet implemented.
190//      deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_ALPHA,32);
188//      deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_ALPHA(0x80),32);
191189   }
192190   else
193191   {
src/mame/video/equites.c
r4135r4136
351351
352352//      const UINT8 * const xromline = xrom + (scalex << 4);
353353      const UINT8 * const yromline = yrom + (scaley << 4) + (15 - scaley);
354      const UINT8* const srcgfx = gfx->gfxdata + tile * gfx->char_modulo;
354      const UINT8* const srcgfx = gfx_element_get_data(gfx, tile);
355355      const pen_t *paldata = &machine->pens[gfx->color_base + gfx->color_granularity * color];
356356      int x,yy;
357357
src/mame/video/gradius3.c
r4135r4136
88UINT16 *gradius3_gfxram;
99int gradius3_priority;
1010static int layer_colorbase[3],sprite_colorbase;
11static int dirtygfx;
12static UINT8 *dirtychar;
1311
1412
1513
r4135r4136
7775   /* re-decode the sprites because the ROMs are connected to the custom IC differently
7876       from how they are connected to the CPU. */
7977   for (i = 0;i < TOTAL_SPRITES;i++)
80      decodechar(machine->gfx[1],i,memory_region(machine, "gfx2"));
78      gfx_element_mark_dirty(machine->gfx[1],i);
8179
82   dirtychar = auto_malloc(TOTAL_CHARS);
83   memset(dirtychar,1,TOTAL_CHARS);
80   gfx_element_set_source(machine->gfx[0], (UINT8 *)gradius3_gfxram);
8481}
8582
8683
r4135r4136
103100   int oldword = gradius3_gfxram[offset];
104101   COMBINE_DATA(&gradius3_gfxram[offset]);
105102   if (oldword != gradius3_gfxram[offset])
106   {
107      dirtygfx = 1;
108      dirtychar[offset / 16] = 1;
109   }
103      gfx_element_mark_dirty(space->machine->gfx[0], offset / 16);
110104}
111105
112106
r4135r4136
125119   K052109_w(space,0x1d80,0x10);
126120   K052109_w(space,0x1f00,0x32);
127121
128   if (dirtygfx)
129   {
130      int i;
131
132      dirtygfx = 0;
133
134      for (i = 0;i < TOTAL_CHARS;i++)
135      {
136         if (dirtychar[i])
137         {
138            dirtychar[i] = 0;
139            decodechar(screen->machine->gfx[0],i,(UINT8 *)gradius3_gfxram);
140         }
141      }
142
143      tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
144   }
145
146122   K052109_tilemap_update();
147123
148124   bitmap_fill(priority_bitmap,cliprect,0);
r4135r4136
159135      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,4);
160136   }
161137
162   K051960_sprites_draw(bitmap,cliprect,-1,-1);
138   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
163139   return 0;
164140}
src/mame/video/decocass.c
r4135r4136
3535
3636static tilemap *fg_tilemap, *bg_tilemap_l, *bg_tilemap_r;
3737
38static char *sprite_dirty;
39static char *char_dirty;
40static char *tile_dirty;
41static char object_dirty;
42
4338static rectangle bg_tilemap_l_clip;
4439static rectangle bg_tilemap_r_clip;
4540
r4135r4136
215210{
216211   decocass_charram[offset] = data;
217212   /* dirty sprite */
218   sprite_dirty[(offset >> 5) & 255] = 1;
213   gfx_element_mark_dirty(space->machine->gfx[1], (offset >> 5) & 255);
219214   /* dirty char */
220   char_dirty[(offset >> 3) & 1023] = 1;
215   gfx_element_mark_dirty(space->machine->gfx[0], (offset >> 3) & 1023);
221216}
222217
223218
r4135r4136
245240{
246241   decocass_tileram[offset] = data;
247242   /* dirty tile (64 bytes per tile) */
248   tile_dirty[(offset / 64) & 15] = 1;
243   gfx_element_mark_dirty(space->machine->gfx[2], (offset / 64) & 15);
249244   /* first 1KB of tile RAM is shared with tilemap RAM */
250245   if (offset < decocass_bgvideoram_size)
251246      mark_bg_tile_dirty( offset );
r4135r4136
255250{
256251   decocass_objectram[offset] = data;
257252   /* dirty the object */
258   object_dirty = 1;
253   gfx_element_mark_dirty(space->machine->gfx[3], 0);
254   gfx_element_mark_dirty(space->machine->gfx[3], 1);
259255}
260256
261257WRITE8_HANDLER( decocass_bgvideoram_w )
r4135r4136
497493}
498494
499495
500static void decode_modified(running_machine* machine, UINT8 *sprite_ram, int interleave)
501{
502   int i,offs;
503
504   /* decode dirty characters */
505   for (offs = decocass_fgvideoram_size - 1;offs >= 0;offs--)
506   {
507      int code;
508
509      code = decocass_fgvideoram[offs] + 256 * (decocass_colorram[offs] & 3);
510
511      switch (char_dirty[code])
512      {
513      case 1:
514         decodechar(machine->gfx[0],code,decocass_charram);
515         char_dirty[code] = 2;
516         /* fall through */
517      case 2:
518         tilemap_mark_tile_dirty(fg_tilemap, offs);
519         break;
520      default:
521         break;
522      }
523   }
524
525   for (i = 0; i < 1024; i++)
526   {
527      if (char_dirty[i] == 2)
528         char_dirty[i] = 0;
529   }
530
531   /* decode dirty sprites */
532   for (i = 0, offs = 0;i < 8; i++, offs += 4*interleave)
533   {
534      int code;
535
536      code  = sprite_ram[offs + interleave];
537      if (sprite_dirty[code])
538      {
539         sprite_dirty[code] = 0;
540
541         decodechar(machine->gfx[1],code,decocass_charram);
542      }
543   }
544
545   /* decode dirty tiles */
546   for (offs = 0; offs < decocass_bgvideoram_size; offs++)
547   {
548      int code = (decocass_tileram[offs] >> 4) & 15;
549
550      if (tile_dirty[code])
551      {
552         tile_dirty[code] = 0;
553
554         decodechar(machine->gfx[2],code,decocass_tileram);
555
556         /* mark all visible tiles dirty */
557         for (i = offs; i < decocass_bgvideoram_size; i++)
558            if (code == ((decocass_tileram[i] >> 4) & 15))
559               mark_bg_tile_dirty(i);
560      }
561   }
562
563   /* decode object if it is dirty */
564   if (object_dirty)
565   {
566      decodechar(machine->gfx[3], 0, decocass_objectram);
567      decodechar(machine->gfx[3], 1, decocass_objectram);
568      object_dirty = 0;
569   }
570}
571
572496VIDEO_START( decocass )
573497{
574   sprite_dirty = auto_malloc(256);
575   char_dirty = auto_malloc(1024);
576   tile_dirty = auto_malloc(16);
577
578498   bg_tilemap_l = tilemap_create( machine, get_bg_l_tile_info, bgvideoram_scan_cols,  16, 16, 32, 32 );
579499   bg_tilemap_r = tilemap_create( machine, get_bg_r_tile_info, bgvideoram_scan_cols,  16, 16, 32, 32 );
580500   fg_tilemap = tilemap_create( machine, get_fg_tile_info, fgvideoram_scan_cols,   8,  8, 32, 32 );
r4135r4136
584504   tilemap_set_transparent_pen( fg_tilemap, 0 );
585505
586506   bg_tilemap_l_clip = *video_screen_get_visible_area(machine->primary_screen);
587   bg_tilemap_l_clip.max_y = 256 / 2;
507   bg_tilemap_l_clip.max_y = 256 / 2 - 1;
588508
589509   bg_tilemap_r_clip = *video_screen_get_visible_area(machine->primary_screen);
590510   bg_tilemap_r_clip.min_y = 256 / 2;
r4135r4136
592512   /* background videroam bits D0-D3 are shared with the tileram */
593513   decocass_bgvideoram = decocass_tileram;
594514   decocass_bgvideoram_size = 0x0400;   /* d000-d3ff */
515
516   gfx_element_set_source(machine->gfx[0], decocass_charram);
517   gfx_element_set_source(machine->gfx[1], decocass_charram);
518   gfx_element_set_source(machine->gfx[2], decocass_tileram);
519   gfx_element_set_source(machine->gfx[3], decocass_objectram);
595520}
596521
597522VIDEO_UPDATE( decocass )
r4135r4136
629554
630555   bitmap_fill( bitmap, cliprect , 0);
631556
632   decode_modified(screen->machine, decocass_fgvideoram, 0x20 );
633
634557   scrolly_l = back_vl_shift;
635558   scrolly_r = 256 - back_vr_shift;
636559
src/mame/video/mystwarr.c
r4135r4136
1414static int sprite_colorbase, sub1_colorbase, last_psac_colorbase, gametype;
1515static int roz_enable, roz_rombank;
1616static tilemap *ult_936_tilemap;
17static char *orig_roms;
1817
19// do some trickery since we know the graphics decode doesn't touch the source data again
20// and we want the original data
21static void mystwarr_save_orig_tiles(running_machine *machine)
18// create a decoding buffer to hold decodable tiles so that the ROM test will pass by
19// reading the original raw data
20static void mystwarr_decode_tiles(running_machine *machine)
2221{
2322   UINT8 *s = memory_region(machine, "gfx1");
2423   int len = memory_region_length(machine, "gfx1");
2524   UINT8 *pFinish = s+len-3;
25   UINT8 *d, *decoded;
26   int gfxnum;
2627
27   orig_roms = malloc_or_die(len);
28   memcpy(orig_roms, s, len);
28   for (gfxnum = 0; gfxnum < ARRAY_LENGTH(machine->gfx); gfxnum++)
29      if (machine->gfx[gfxnum] != NULL && machine->gfx[gfxnum]->srcdata == s)
30         break;
31   assert(gfxnum != ARRAY_LENGTH(machine->gfx));
2932
33   decoded = auto_malloc(len);
34   d = decoded;
35
3036   // now convert the data into a drawable format so we can decode it
3137   while (s < pFinish)
3238   {
r4135r4136
4349      int d3 = ((s[0]&0x10)<<3)|((s[0]&0x01)<<6)|((s[1]&0x10)<<1)|((s[1]&0x01)<<4)|
4450               ((s[2]&0x10)>>1)|((s[2]&0x01)<<2)|((s[3]&0x10)>>3)|((s[3]&0x01)   );
4551
46      s[0] = d3;
47      s[1] = d1;
48      s[2] = d2;
49      s[3] = d0;
52      d[0] = d3;
53      d[1] = d1;
54      d[2] = d2;
55      d[3] = d0;
56      d[4] = s[4];
5057
5158      s += 5;
59      d += 5;
5260   }
53}
5461
55static void mystwarr_rest_orig_tiles(running_machine *machine)
56{
57   UINT8 *s = memory_region(machine, "gfx1");
58   int len = memory_region_length(machine, "gfx1");
59
60   // restore the original data so the ROM test can pass
61   memcpy(s, orig_roms, len);
62   free(orig_roms);
62   gfx_element_set_source(machine->gfx[gfxnum], decoded);
6363}
6464
6565
r4135r4136
164164
165165   gametype = 0;
166166
167   mystwarr_save_orig_tiles(machine);
168
169167   K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game4bpp_tile_callback, 0);
170168
171   mystwarr_rest_orig_tiles(machine);
169   mystwarr_decode_tiles(machine);
172170
173171   K055673_vh_start(machine, "gfx2", 1, -61, -22, gaiapols_sprite_callback); // stage2 brick walls
174172
r4135r4136
206204
207205   gametype = 1;
208206
209   mystwarr_save_orig_tiles(machine);
210
211207   K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game5bpp_tile_callback, 0);
212208
213   mystwarr_rest_orig_tiles(machine);
209   mystwarr_decode_tiles(machine);
214210
215211   K055673_vh_start(machine, "gfx2", 0, -42, -22, gaiapols_sprite_callback);
216212
r4135r4136
237233
238234   gametype = 0;
239235
240   mystwarr_save_orig_tiles(machine);
241
242236   K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, mystwarr_tile_callback, 0);
243237
244   mystwarr_rest_orig_tiles(machine);
238   mystwarr_decode_tiles(machine);
245239
246240   K055673_vh_start(machine, "gfx2", 0, -48, -24, mystwarr_sprite_callback);
247241
r4135r4136
265259   K054338_vh_start(machine);
266260   K053250_vh_start(machine, 1, &rgn_250);
267261
268   mystwarr_save_orig_tiles(machine);
269
270262   K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game4bpp_tile_callback, 0);
271263
272   mystwarr_rest_orig_tiles(machine);
264   mystwarr_decode_tiles(machine);
273265
274266   K055673_vh_start(machine, "gfx2", 1, -51, -22, metamrph_sprite_callback);
275267
r4135r4136
291283   K055555_vh_start(machine);
292284   K054338_vh_start(machine);
293285
294   mystwarr_save_orig_tiles(machine);
295
296286   K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game4bpp_tile_callback, 0);
297287
298   mystwarr_rest_orig_tiles(machine);
288   mystwarr_decode_tiles(machine);
299289
300290   K055673_vh_start(machine, "gfx2", 1, -62, -23, metamrph_sprite_callback);
301291
r4135r4136
314304   K055555_vh_start(machine);
315305   K054338_vh_start(machine);
316306
317   mystwarr_save_orig_tiles(machine);
318
319307   K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game5bpp_tile_callback, 0);
320308
321   mystwarr_rest_orig_tiles(machine);
309   mystwarr_decode_tiles(machine);
322310
323311   K055673_vh_start(machine, "gfx2", 0, -58, -23, martchmp_sprite_callback);
324312
src/mame/video/irobot.c
r4135r4136
353353
354354   /* copy the polygon bitmap */
355355   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
356      draw_scanline8(bitmap, 0, y, BITMAP_WIDTH, &bitmap_base[y * BITMAP_WIDTH], NULL, -1);
356      draw_scanline8(bitmap, 0, y, BITMAP_WIDTH, &bitmap_base[y * BITMAP_WIDTH], NULL);
357357
358358   /* redraw the non-zero characters in the alpha layer */
359359   for (y = offs = 0; y < 32; y++)
src/mame/video/segas24.c
r4135r4136
3131      return 0;
3232   }
3333
34   sys24_tile_update(screen->machine);
35
3634   bitmap_fill(priority_bitmap, 0, 0);
3735   bitmap_fill(bitmap, cliprect, 0);
3836
src/mame/video/konamigx.c
r4135r4136
296296{
297297   K056832_vh_start(machine, "gfx1", K056832_BPP_6, 1, NULL, konamigx_type2_tile_callback, 0);
298298
299   if (!strcmp(machine->gamedrv->name,"salmndr2"))
299   if (!strcmp(machine->gamedrv->name,"salmndr2") || !strcmp(machine->gamedrv->name,"salmnd2a"))
300300   {
301301      K055673_vh_start(machine, "gfx2", K055673_LAYOUT_GX6, -48, -23, konamigx_salmndr2_sprite_callback);
302302
src/mame/video/ultraman.c
r4135r4136
128128{
129129   K051316_zoom_draw_2(bitmap,cliprect,0,0);
130130   K051316_zoom_draw_1(bitmap,cliprect,0,0);
131   K051960_sprites_draw(bitmap,cliprect,0,0);
131   K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
132132   K051316_zoom_draw_0(bitmap,cliprect,0,0);
133   K051960_sprites_draw(bitmap,cliprect,1,1);
133   K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
134134   return 0;
135135}
src/mame/video/parodius.c
r4135r4136
9393   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
9494   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
9595
96   K053245_sprites_draw(0,bitmap,cliprect);
96   K053245_sprites_draw(screen->machine,0,bitmap,cliprect);
9797   return 0;
9898}
src/mame/video/ppu2c0x.c
r4135r4136
7272   UINT8               *spriteram;            /* sprite ram */
7373   pen_t               *colortable;         /* color table modified at run time */
7474   pen_t               *colortable_mono;      /* monochromatic color table modified at run time */
75   UINT8               *dirtychar;            /* an array flagging dirty characters */
76   int                  chars_are_dirty;      /* master flag to check if theres any dirty character */
7775   emu_timer            *scanline_timer;      /* scanline timer */
7876   emu_timer            *hblank_timer;         /* hblank period at end of each scanline */
7977   emu_timer            *nmi_timer;            /* NMI timer */
r4135r4136
310308      chips[i].videomem = auto_malloc( VIDEOMEM_SIZE );
311309      chips[i].videoram = auto_malloc( VIDEOMEM_SIZE );
312310      chips[i].spriteram = auto_malloc( SPRITERAM_SIZE );
313      chips[i].dirtychar = auto_malloc( CHARGEN_NUM_CHARS );
314311      chips[i].colortable = auto_malloc( sizeof( default_colortable ) );
315312      chips[i].colortable_mono = auto_malloc( sizeof( default_colortable_mono ) );
316313
r4135r4136
320317      memset( chips[i].spriteram, 0, SPRITERAM_SIZE );
321318      memset( chips[i].videoram_banks_indices, 0xff, sizeof(chips[i].videoram_banks_indices) );
322319
323      /* set all characters dirty */
324      memset( chips[i].dirtychar, 1, CHARGEN_NUM_CHARS );
325
326320      if ( intf->vram_enabled[i] )
327321      {
328322         chips[i].has_videoram = 1;
r4135r4136
362356
363357         memcpy(&gl, &ppu_charlayout, sizeof(gl));
364358         gl.total = total;
365         machine->gfx[intf->gfx_layout_number[i]] = allocgfx( machine, &gl );
366         decodegfx( machine->gfx[intf->gfx_layout_number[i]], src, 0, machine->gfx[intf->gfx_layout_number[i]]->total_elements );
367         machine->gfx[intf->gfx_layout_number[i]]->total_colors = 8;
359         machine->gfx[intf->gfx_layout_number[i]] = gfx_element_alloc( machine, &gl, src, 8, 0 );
368360      }
369361
370362      /* setup our videomem handlers based on mirroring */
r4135r4136
412404   const int total_elements = chips[num].machine->gfx[gfx_bank]->total_elements;
413405   const int *nes_vram = &chips[num].nes_vram[0];
414406   const int tile_page = chips[num].tile_page;
415   const int char_modulo = chips[num].machine->gfx[gfx_bank]->char_modulo;
416407   const int line_modulo = chips[num].machine->gfx[gfx_bank]->line_modulo;
417   UINT8 *gfx_data = chips[num].machine->gfx[gfx_bank]->gfxdata;
418408   UINT8 **ppu_page = chips[num].ppu_page;
419409   int   start_x = ( chips[num].x_fine ^ 0x07 ) - 7;
420410   UINT16 back_pen;
r4135r4136
493483      if(start_x < VISIBLE_SCREEN_WIDTH )
494484      {
495485         paldata = &color_table[ 4 * ( ( ( color_byte >> color_bits ) & 0x03 ) ) ];
496         start = ( index2 % total_elements ) * char_modulo + scroll_y_fine * line_modulo;
497         sd = &gfx_data[start];
486         start = scroll_y_fine * line_modulo;
487         sd = gfx_element_get_data(chips[num].machine->gfx[gfx_bank], index2 % total_elements) + start;
498488
499489         /* render the pixel */
500490         for( i = 0; i < 8; i++ )
r4135r4136
548538   const int gfx_bank = intf->gfx_layout_number[num];
549539   const int total_elements = chips[num].machine->gfx[gfx_bank]->total_elements;
550540   const int sprite_page = chips[num].sprite_page;
551   const int char_modulo = chips[num].machine->gfx[gfx_bank]->char_modulo;
552541   const int line_modulo = chips[num].machine->gfx[gfx_bank]->line_modulo;
553542   const UINT8 *sprite_ram = chips[num].spriteram;
554543   pen_t *color_table = chips[num].colortable;
555   UINT8 *gfx_data = chips[num].machine->gfx[gfx_bank]->gfxdata;
556544   int *ppu_regs = &chips[num].regs[0];
557545
558546   int spriteXPos, spriteYPos, spriteIndex;
r4135r4136
637625         sprite_line = ( size - 1 ) - sprite_line;
638626
639627      paldata = &color_table[4 * color];
640      start = ( index1 % total_elements ) * char_modulo + sprite_line * line_modulo;
641      sd = &gfx_data[start];
628      start = sprite_line * line_modulo;
629      sd = gfx_element_get_data(chips[num].machine->gfx[gfx_bank], index1 % total_elements) + start;
630      if (size > 8)
631         gfx_element_get_data(chips[num].machine->gfx[gfx_bank], (index1 + 1) % total_elements);
642632
643633      if ( pri )
644634      {
r4135r4136
859849   int num = param;
860850   ppu2c0x_chip* this_ppu = &chips[num];
861851   int *ppu_regs = &chips[num].regs[0];
862   int i;
863852   int blanked = ( ppu_regs[PPU_CONTROL1] & ( PPU_CONTROL1_BACKGROUND | PPU_CONTROL1_SPRITES ) ) == 0;
864853   int vblank = ((this_ppu->scanline >= PPU_VBLANK_FIRST_SCANLINE-1) && (this_ppu->scanline < this_ppu->scanlines_per_frame-1)) ? 1 : 0;
865854   int next_scanline;
r4135r4136
894883      }
895884   }
896885
897   /* decode any dirty chars if we're using vram */
898
899   /* first, check the master dirty char flag */
900   if ( (!this_ppu->has_videorom || this_ppu->has_videoram) && this_ppu->chars_are_dirty )
901   {
902      /* cache some values */
903      UINT8 *dirtyarray = this_ppu->dirtychar;
904      UINT8 *vram = this_ppu->videomem;
905      gfx_element *gfx = chips[num].machine->gfx[intf->gfx_layout_number[num]];
906
907      /* then iterate and decode */
908      for( i = 0; i < CHARGEN_NUM_CHARS; i++ )
909      {
910         if ( dirtyarray[i] )
911         {
912            decodechar( gfx, i, vram );
913            dirtyarray[i] = 0;
914         }
915      }
916
917      this_ppu->chars_are_dirty = 0;
918   }
919
920886   if ( this_ppu->scanline == this_ppu->scanlines_per_frame - 1 )
921887   {
922888logerror("vlbank ending\n");
r4135r4136
996962   chips[num].tile_page = 0;
997963   chips[num].sprite_page = 0;
998964   chips[num].back_color = 0;
999   chips[num].chars_are_dirty = 1;
1000965
1001966   /* initialize the color tables */
1002967   {
r4135r4136
12441209                  /* store the data */
12451210                  this_ppu->videomem[tempAddr] = data;
12461211
1247                  /* setup the master dirty switch */
1248                  this_ppu->chars_are_dirty = 1;
1249
12501212                  /* mark the char dirty */
1251                  this_ppu->dirtychar[tempAddr >> 4] = 1;
1213                  gfx_element_mark_dirty(this_ppu->machine->gfx[intf->gfx_layout_number[num]], tempAddr >> 4);
12521214               }
12531215            }
12541216
r4135r4136
13971359   {
13981360      for ( i = start_page; i < start_page + num_pages; i++ )
13991361      {
1362         int elemnum;
1363
14001364         if ( chips[num].videoram_banks_indices[i] != -1 )
14011365         {
14021366            memcpy( &chips[num].videoram[chips[num].videoram_banks_indices[i]*0x400], &chips[num].videomem[i*0x400], 0x400);
14031367         }
14041368         chips[num].videoram_banks_indices[i] = -1;
1405         memset( &chips[num].dirtychar[start_page*0x400 >> 4], 1, (num_pages*0x400 >> 4));
1369         for (elemnum = 0; elemnum < (num_pages*0x400 >> 4); elemnum++)
1370            gfx_element_mark_dirty(chips[num].machine->gfx[intf->gfx_layout_number[num]], (start_page*0x400 >> 4) + elemnum);
14061371      }
1407      chips[num].chars_are_dirty = 1;
14081372   }
14091373   else
14101374   {
r4135r4136
14471411
14481412   for ( i = start_page; i < start_page + num_pages; i++ )
14491413   {
1414      int elemnum;
14501415      if ( chips[num].videoram_banks_indices[i] != -1 )
14511416      {
14521417         memcpy( &chips[num].videoram[chips[num].videoram_banks_indices[i]*0x400], &chips[num].videomem[i*0x400], 0x400);
14531418      }
14541419      chips[num].videoram_banks_indices[i] = (bank * bank_size * 16)/0x400 + (i - start_page);
1455      memset( &chips[num].dirtychar[start_page*0x400 >> 4], 1, (num_pages*0x400 >> 4));
1420      for (elemnum = 0; elemnum < (num_pages*0x400 >> 4); elemnum++)
1421         gfx_element_mark_dirty(chips[num].machine->gfx[intf->gfx_layout_number[num]], (start_page*0x400 >> 4) + elemnum);
14561422   }
1457   chips[num].chars_are_dirty = 1;
14581423
14591424   {
14601425      int vram_start = start_page * 0x400;
src/mame/video/buggychl.c
r4135r4136
88static UINT8 buggychl_sprite_lookup[0x2000];
99UINT8 *buggychl_character_ram;
1010
11static int *dirtychar;
12
1311static bitmap_t *tmpbitmap1,*tmpbitmap2;
1412static int sl_bank,bg_on,sky_on,sprite_color_base,bg_scrollx;
1513
r4135r4136
2927
3028VIDEO_START( buggychl )
3129{
32   dirtychar = auto_malloc(256 * sizeof(*dirtychar));
3330   tmpbitmap1 = video_screen_auto_bitmap_alloc(machine->primary_screen);
3431   tmpbitmap2 = video_screen_auto_bitmap_alloc(machine->primary_screen);
3532
36   memset(dirtychar,0xff,256 * sizeof(*dirtychar));
33   gfx_element_set_source(machine->gfx[0], buggychl_character_ram);
3734}
3835
3936
r4135r4136
4340   if (buggychl_character_ram[offset] != data)
4441   {
4542      buggychl_character_ram[offset] = data;
46
47      dirtychar[(offset / 8) & 0xff] = 1;
43      gfx_element_mark_dirty(space->machine->gfx[0], (offset / 8) & 0xff);
4844   }
4945}
5046
r4135r4136
210206               code = 8 * (lookup[pos] | ((lookup[pos+1] & 0x07) << 8));
211207               realflipy = (lookup[pos+1] & 0x80) ? !flipy : flipy;
212208               code += (realflipy ? (charline ^ 7) : charline);
213               pendata = machine->gfx[1]->gfxdata + code*16;
209               pendata = gfx_element_get_data(machine->gfx[1], code);
214210
215211               for (x = 0;x < 16;x++)
216212               {
r4135r4136
239235
240236VIDEO_UPDATE( buggychl )
241237{
242   int code;
243
244
245238   if (sky_on)
246239      draw_sky(bitmap, cliprect);
247240   else
248241      bitmap_fill(bitmap,cliprect,0);
249242
250   /* decode modified characters */
251   for (code = 0;code < 256;code++)
252      if (dirtychar[code])
253         decodechar(screen->machine->gfx[0],code,buggychl_character_ram);
254
255243   if (bg_on)
256244      draw_bg(screen->machine, bitmap, cliprect);
257245
r4135r4136
259247
260248   draw_fg(screen->machine, bitmap, cliprect);
261249
262   for (code = 0;code < 256;code++)
263      dirtychar[code] = 0;
264250   return 0;
265251}
src/mame/video/taito_f2.c
r4135r4136
372372      const rectangle *clip,int scalex, int scaley)
373373{
374374   int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
375   UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
375   const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
376376
377377   int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
378378   int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
r4135r4136
445445
446446         for( y=sy; y<ey; y++ )
447447         {
448            UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
448            const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
449449            UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
450450            UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0);
451451
src/mame/video/gottlieb.c
r4135r4136
122122   if (gottlieb_charram[offset] != data)
123123   {
124124      gottlieb_charram[offset] = data;
125      decodechar(space->machine->gfx[0], offset / 32, gottlieb_charram);
126      tilemap_mark_all_tiles_dirty(bg_tilemap);
125      gfx_element_mark_dirty(space->machine->gfx[0], offset / 32);
127126   }
128127}
129128
r4135r4136
163162   tilemap_set_transparent_pen(bg_tilemap, 0);
164163   tilemap_set_scrolldx(bg_tilemap, 0, 318 - 256);
165164
165   gfx_element_set_source(machine->gfx[0], gottlieb_charram);
166
166167   /* save some state */
167168   state_save_register_global(machine, background_priority);
168169   state_save_register_global(machine, spritebank);
src/mame/video/asterix.c
r4135r4136
123123   K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[1], 0, 2);
124124   K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[2], 0, 4);
125125
126   pdrawgfx_shadow_lowpri = 1;   /* fix shadows in front of feet */
127   K053245_sprites_draw(0, bitmap, cliprect);
126/* this isn't supported anymore and it is unsure if still needed; keeping here for reference
127    pdrawgfx_shadow_lowpri = 1; fix shadows in front of feet */
128   K053245_sprites_draw(screen->machine, 0, bitmap, cliprect);
128129
129130   K056832_tilemap_draw(screen->machine, bitmap, cliprect, 2, 0, 0);
130131   return 0;
src/mame/video/macrossp.c
r4135r4136
166166   machine->gfx[1]->color_granularity=64;
167167   machine->gfx[2]->color_granularity=64;
168168   machine->gfx[3]->color_granularity=64;
169
170   alpha_set_level(0x80); /* guess */
171169}
172170
173171
r4135r4136
209207      int flipx = (source[2] & 0x40000000) >> 30;
210208      int flipy = (source[2] & 0x80000000) >> 31;
211209
212      int trans = (source[2] & 0x20000000)?TRANSPARENCY_ALPHA:TRANSPARENCY_PEN; /* alpha blending enable? */
210      int alpha = (source[2] & 0x20000000)?0x80:0xff; /* alpha blending enable? */
213211
214212      int loopno = 0;
215213
r4135r4136
245243               for (ycnt = 0; ycnt <= high; ycnt++) {
246244                  xoffset = 0;
247245                  for (xcnt = 0; xcnt <= wide; xcnt++) {
248                     drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
246                     drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
249247
250248                     xoffset += ((xzoom*16 + (1<<7)) >> 8);
251249                     loopno++;
r4135r4136
257255               for (ycnt = high; ycnt >= 0; ycnt--) {
258256                  xoffset = 0;
259257                  for (xcnt = 0; xcnt <= wide; xcnt++) {
260                     drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
258                     drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
261259
262260                     xoffset += ((xzoom*16 + (1<<7)) >> 8);
263261                     loopno++;
r4135r4136
271269               for (ycnt = 0; ycnt <= high; ycnt++) {
272270                  xoffset = ((wide*xzoom*16) >> 8);
273271                  for (xcnt = wide; xcnt >= 0; xcnt--) {
274                     drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
272                     drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
275273
276274                     xoffset -= ((xzoom*16 + (1<<7)) >> 8);
277275                     loopno++;
r4135r4136
283281               for (ycnt = high; ycnt >= 0; ycnt--) {
284282                  xoffset = ((wide*xzoom*16) >> 8);
285283                  for (xcnt = wide; xcnt >=0 ; xcnt--) {
286                     drawgfxzoom(bitmap,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,cliprect,trans,0,xzoom*0x100,yzoom*0x100);
284                     drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
287285
288286                     xoffset -= ((xzoom*16 + (1<<7)) >> 8);
289287                     loopno++;
src/mame/video/moo.c
r4135r4136
160160   alpha = (alpha_enabled) ? K054338_set_alpha_level(1) : 255;
161161
162162   if (alpha > 0)
163      K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[2], (alpha >= 255) ? 0 : TILEMAP_DRAW_ALPHA, 4);
163      K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[2], TILEMAP_DRAW_ALPHA(alpha), 4);
164164
165165   K053247_sprites_draw(screen->machine, bitmap,cliprect);
166166
src/mame/video/taito_l.c
r4135r4136
2424
2525static TILE_GET_INFO( get_bg18_tile_info )
2626{
27   int attr = taitol_rambanks[2*tile_index+0x4000+1];
28   int code = taitol_rambanks[2*tile_index+0x4000]
27   int attr = taitol_rambanks[2*tile_index+0x8000+1];
28   int code = taitol_rambanks[2*tile_index+0x8000]
2929         | ((attr & 0x03) << 8)
3030         | ((bankc[(attr & 0xc) >> 2]) << 10)
3131         | (horshoes_gfxbank << 12);
r4135r4136
3939
4040static TILE_GET_INFO( get_bg19_tile_info )
4141{
42   int attr = taitol_rambanks[2*tile_index+0x5000+1];
43   int code = taitol_rambanks[2*tile_index+0x5000]
42   int attr = taitol_rambanks[2*tile_index+0x9000+1];
43   int code = taitol_rambanks[2*tile_index+0x9000]
4444         | ((attr & 0x03) << 8)
4545         | ((bankc[(attr & 0xc) >> 2]) << 10)
4646         | (horshoes_gfxbank << 12);
r4135r4136
5454
5555static TILE_GET_INFO( get_ch1a_tile_info )
5656{
57   int attr = taitol_rambanks[2*tile_index+0x6000+1];
58   int code = taitol_rambanks[2*tile_index+0x6000]|((attr&0x01)<<8)|((attr&0x04)<<7);
57   int attr = taitol_rambanks[2*tile_index+0xa000+1];
58   int code = taitol_rambanks[2*tile_index+0xa000]|((attr&0x01)<<8)|((attr&0x04)<<7);
5959
6060   SET_TILE_INFO(
6161         2,
r4135r4136
158158   return cur_ctrl;
159159}
160160
161INLINE void taitol_chardef(running_machine *machine, int num, int offset)
162{
163   decodechar(machine->gfx[2], num, taitol_rambanks + offset);
164   tilemap_mark_all_tiles_dirty(ch1a_tilemap);
165}
166
167161void taitol_chardef14_m(running_machine *machine, int offset)
168162{
169   taitol_chardef(machine, offset/32, 0);
163   gfx_element_mark_dirty(machine->gfx[2], offset/32 + 0);
170164}
171165
172166void taitol_chardef15_m(running_machine *machine, int offset)
173167{
174   taitol_chardef(machine, offset/32 + 128, 0);
168   gfx_element_mark_dirty(machine->gfx[2], offset/32 + 128);
175169}
176170
177171void taitol_chardef16_m(running_machine *machine, int offset)
178172{
179   taitol_chardef(machine, offset/32+256, 0);
173   gfx_element_mark_dirty(machine->gfx[2], offset/32 + 256);
180174}
181175
182176void taitol_chardef17_m(running_machine *machine, int offset)
183177{
184   taitol_chardef(machine, offset/32+384, 0);
178   gfx_element_mark_dirty(machine->gfx[2], offset/32 + 384);
185179}
186180
187181void taitol_chardef1c_m(running_machine *machine, int offset)
188182{
189   taitol_chardef(machine, offset/32+512, 0x4000);
183   gfx_element_mark_dirty(machine->gfx[2], offset/32 + 512);
190184}
191185
192186void taitol_chardef1d_m(running_machine *machine, int offset)
193187{
194   taitol_chardef(machine, offset/32+640, 0x4000);
188   gfx_element_mark_dirty(machine->gfx[2], offset/32 + 640);
195189}
196190
197191void taitol_chardef1e_m(running_machine *machine, int offset)
198192{
199   taitol_chardef(machine, offset/32+768, 0x4000);
193   gfx_element_mark_dirty(machine->gfx[2], offset/32 + 768);
200194}
201195
202196void taitol_chardef1f_m(running_machine *machine, int offset)
203197{
204   taitol_chardef(machine, offset/32+896, 0x4000);
198   gfx_element_mark_dirty(machine->gfx[2], offset/32 + 896);
205199}
206200
207201void taitol_bg18_m(running_machine *machine, int offset)
r4135r4136
299293   int dx,dy;
300294
301295
302   dx = taitol_rambanks[0x73f4]|(taitol_rambanks[0x73f5]<<8);
296   dx = taitol_rambanks[0xb3f4]|(taitol_rambanks[0xb3f5]<<8);
303297   if (flipscreen)
304298      dx = ((dx & 0xfffc) | ((dx - 3) & 0x0003)) ^ 0xf;
305   dy = taitol_rambanks[0x73f6];
299   dy = taitol_rambanks[0xb3f6];
306300   tilemap_set_scrollx(bg18_tilemap,0,-dx);
307301   tilemap_set_scrolly(bg18_tilemap,0,-dy);
308302
309   dx = taitol_rambanks[0x73fc]|(taitol_rambanks[0x73fd]<<8);
303   dx = taitol_rambanks[0xb3fc]|(taitol_rambanks[0xb3fd]<<8);
310304   if (flipscreen)
311305      dx = ((dx & 0xfffc) | ((dx - 3) & 0x0003)) ^ 0xf;
312   dy = taitol_rambanks[0x73fe];
306   dy = taitol_rambanks[0xb3fe];
313307   tilemap_set_scrollx(bg19_tilemap,0,-dx);
314308   tilemap_set_scrolly(bg19_tilemap,0,-dy);
315309
r4135r4136
337331
338332VIDEO_EOF( taitol )
339333{
340   UINT8 *spriteram = taitol_rambanks + 0x7000;
334   UINT8 *spriteram = taitol_rambanks + 0xb000;
341335
342336   memcpy(buff_spriteram,spriteram,SPRITERAM_SIZE);
343337}
src/mame/video/m58.c
r4135r4136
293293
294294      clip.min_y += visarea->min_y + yoffs;
295295      clip.max_y += visarea->max_y + yoffs;
296      sect_rect(&clip, cliprect);
296297
297298      copybitmap(bitmap, scroll_panel_bitmap, flip_screen_get(machine), flip_screen_get(machine),
298299               sx, visarea->min_y + yoffs, &clip);
src/mame/video/circus.c
r4135r4136
198198static void ripcord_draw_skydiver(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
199199{
200200   const gfx_element *gfx;
201   UINT8  *src_lineptr, *src_pixptr;
201   const UINT8  *src_lineptr, *src_pixptr;
202202   UINT16 *dst_lineptr, *dst_lineend;
203203   UINT32 code;
204204   int sx, sy;
r4135r4136
216216   edx = 1;
217217
218218   gfx = machine->gfx[1];
219   src_lineptr = gfx->gfxdata + code * gfx->char_modulo;
219   src_lineptr = gfx_element_get_data(gfx, code);
220220   src_pitch = gfx->line_modulo;
221221   dst_pitch = bitmap->rowpixels;
222222
src/mame/video/zac2650.c
r4135r4136
3535    else return CollisionSprite;
3636}
3737
38WRITE8_HANDLER( zac_s2636_w )
39{
40   zac2650_s2636_0_ram[offset] = data;
41   gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
42   gfx_element_mark_dirty(space->machine->gfx[2], offset/8);
43}
44
3845READ8_HANDLER( tinvader_port_0_r )
3946{
4047   return input_port_read(space->machine, "1E80") - CollisionBackground;
r4135r4136
137144
138145   spritebitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
139146   tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
147
148   gfx_element_set_source(machine->gfx[1], zac2650_s2636_0_ram);
149   gfx_element_set_source(machine->gfx[2], zac2650_s2636_0_ram);
140150}
141151
142152static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
r4135r4136
170180            int by       = (zac2650_s2636_0_ram[offs+12] * 3) + 3;
171181            int x,y;
172182
173         /* 16x8 version */
174         decodechar(machine->gfx[1],spriteno,zac2650_s2636_0_ram);
175
176         /* 16x16 version */
177         decodechar(machine->gfx[2],spriteno,zac2650_s2636_0_ram);
178
179183            /* Sprite->Background collision detection */
180184         drawgfx(bitmap,machine->gfx[expand],
181185                spriteno,
src/mame/video/shangha3.c
r4135r4136
7070static UINT16 gfxlist_addr;
7171static bitmap_t *rawbitmap;
7272
73static UINT8 drawmode_table[16];
7374
7475
7576VIDEO_START( shangha3 )
7677{
78   int i;
79
7780   rawbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
7881
82   for (i = 0;i < 14;i++)
83      drawmode_table[i] = DRAWMODE_SOURCE;
84   drawmode_table[14] = shangha3_do_shadows ? DRAWMODE_SHADOW : DRAWMODE_NONE;
85   drawmode_table[15] = DRAWMODE_NONE;
86
7987   if (shangha3_do_shadows)
8088   {
81      int i;
82
8389      /* Prepare the shadow table */
84      for (i = 0;i < 14;i++)
85         gfx_drawmode_table[i] = DRAWMODE_SOURCE;
86      gfx_drawmode_table[14] = DRAWMODE_SHADOW;
8790      for (i = 0;i < 128;i++)
8891         machine->shadow_table[i] = i+128;
8992   }
r4135r4136
154157         myclip.max_x = sx + sizex;
155158         myclip.min_y = sy;
156159         myclip.max_y = sy + sizey;
160         sect_rect(&myclip, &rawbitmap->cliprect);
157161
158162         if (shangha3_ram[offs+4] & 0x08)   /* tilemap */
159163         {
r4135r4136
225229            int w;
226230
227231if (zoomx <= 1 && zoomy <= 1)
228   drawgfxzoom(rawbitmap,space->machine->gfx[0],
232   drawgfxzoom_transtable(rawbitmap,&myclip,space->machine->gfx[0],
229233         code,
230234         color,
231235         flipx,flipy,
232236         sx,sy,
233         &myclip,shangha3_do_shadows ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,15,
234         0x1000000,0x1000000);
237         0x1000000,0x1000000,
238         drawmode_table,space->machine->shadow_table);
235239else
236240{
237241            w = (sizex+15)/16;
238242
239243            for (x = 0;x < w;x++)
240244            {
241               drawgfxzoom(rawbitmap,space->machine->gfx[0],
245               drawgfxzoom_transtable(rawbitmap,&myclip,space->machine->gfx[0],
242246                     code,
243247                     color,
244248                     flipx,flipy,
245249                     sx + 16*x,sy,
246                     &myclip,shangha3_do_shadows ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN,15,
247                     (0x200-zoomx)*0x100,(0x200-zoomy)*0x100);
250                     (0x200-zoomx)*0x100,(0x200-zoomy)*0x100,
251                     drawmode_table,space->machine->shadow_table);
248252
249253               if ((code & 0x000f) == 0x0f)
250254                  code = (code + 0x100) & 0xfff0;
src/mame/video/relief.c
r4135r4136
8282      0               /* callback routine for special entries */
8383   };
8484
85   /* blend the MO graphics */
86   atarigen_blend_gfx(machine, 1, 2, 0x0f, 0x10);
85   /* MOs are 5bpp but with a 4-bit color granularity */
86   machine->gfx[1]->color_granularity = 16;
8787
8888   /* initialize the playfield */
8989   atarigen_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_cols,  8,8, 64,64);
src/mame/video/taito_f3.c
r4135r4136
215215static tilemap *pf1_tilemap,*pf2_tilemap,*pf3_tilemap,*pf4_tilemap;
216216static tilemap *pixel_layer,*vram_layer;
217217static UINT32 *spriteram32_buffered;
218static int vram_dirty[256];
219static int pivot_changed,vram_changed;
220218static UINT32 f3_control_0[8];
221219static UINT32 f3_control_1[8];
222220static int flipscreen;
223221static UINT8 sprite_extra_planes;
224222static UINT8 sprite_pen_mask;
225223
226static UINT8 *pivot_dirty;
227
228224static UINT32 *f3_pf_data_1,*f3_pf_data_2,*f3_pf_data_3,*f3_pf_data_4;
229225
230226UINT32 *f3_vram,*f3_line_ram;
r4135r4136
599595VIDEO_START( f3 )
600596{
601597   const struct F3config *pCFG=&f3_config_table[0];
602   int tile, width, height, i;
598   int width, height, i;
603599
604600   f3_alpha_level_2as=127;
605601   f3_alpha_level_2ad=127;
r4135r4136
622618
623619   spritelist=0;
624620   spriteram32_buffered=0;
625   pivot_dirty=0;
626621   pf_line_inf=0;
627622   pri_alp_bitmap=0;
628623   tile_opaque_sp=0;
r4135r4136
674669   sprite_end = spritelist;
675670   vram_layer = tilemap_create(machine, get_tile_info_vram,tilemap_scan_rows,8,8,64,64);
676671   pixel_layer = tilemap_create(machine, get_tile_info_pixel,tilemap_scan_cols,8,8,64,32);
677   pivot_dirty = (UINT8 *)auto_malloc(2048);
678672   pf_line_inf = auto_malloc(5 * sizeof(struct f3_playfield_line_inf));
679673   sa_line_inf = auto_malloc(1 * sizeof(struct f3_spritealpha_line_inf));
680674   width = video_screen_get_width(machine->primary_screen);
r4135r4136
703697   state_save_register_global_array(machine, f3_control_0);
704698   state_save_register_global_array(machine, f3_control_1);
705699
706   for (tile = 0;tile < 256;tile++)
707      vram_dirty[tile]=1;
708   for (tile = 0;tile < 2048;tile++)
709      pivot_dirty[tile]=1;
700   gfx_element_set_source(machine->gfx[0], (UINT8 *)f3_vram);
701   gfx_element_set_source(machine->gfx[3], (UINT8 *)f3_pivot_ram);
710702
711703   f3_skip_this_frame=0;
712704
r4135r4136
722714      {
723715         int x,y;
724716         int chk_trans_or_opa=0;
725         UINT8 *dp = sprite_gfx->gfxdata + c * sprite_gfx->char_modulo;
717         const UINT8 *dp = gfx_element_get_data(sprite_gfx, c);
726718         for (y = 0;y < sprite_gfx->height;y++)
727719         {
728720            for (x = 0;x < sprite_gfx->width;x++)
r4135r4136
751743         {
752744            int chk_trans_or_opa=0;
753745            UINT8 extra_mask = ((extra_planes << 4) | 0x0f);
754            UINT8 *dp = pf_gfx->gfxdata + c * pf_gfx->char_modulo;
746            const UINT8 *dp = gfx_element_get_data(pf_gfx, c);
755747
756748            for (y = 0;y < pf_gfx->height;y++)
757749            {
r4135r4136
819811WRITE32_HANDLER( f3_vram_w )
820812{
821813   COMBINE_DATA(&f3_vram[offset]);
822   vram_dirty[offset/8]=1;
823   vram_changed=1;
814   gfx_element_mark_dirty(space->machine->gfx[0], offset/8);
824815}
825816
826817WRITE32_HANDLER( f3_pivot_w )
827818{
828819   COMBINE_DATA(&f3_pivot_ram[offset]);
829   pivot_dirty[offset/8]=1;
830   pivot_changed=1;
820   gfx_element_mark_dirty(space->machine->gfx[3], offset/8);
831821}
832822
833823WRITE32_HANDLER( f3_lineram_w )
r4135r4136
26682658   if( gfx )
26692659   {
26702660      const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
2671      int source_base = (code % gfx->total_elements) * 16;
2661      const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
26722662
26732663      {
26742664         /* compute sprite increment per screen pixel */
r4135r4136
27342724            {
27352725               int y=ey-sy;
27362726               int x=(ex-sx-1)|(tile_opaque_sp[code % gfx->total_elements]<<4);
2737               UINT8 *source0 = gfx->gfxdata + (source_base+y_index) * 16 + x_index_base;
2727               const UINT8 *source0 = code_base + y_index * 16 + x_index_base;
27382728               UINT32 *dest0 = BITMAP_ADDR32(dest_bmp, sy, sx);
27392729               UINT8 *pri0 = BITMAP_ADDR8(pri_alp_bitmap, sy, sx);
27402730               int yadv = dest_bmp->rowpixels;
27412731               dy=dy*16;
27422732               while(1)
27432733               {
2744                  UINT8 *source = source0;
2734                  const UINT8 *source = source0;
27452735                  UINT32 *dest = dest0;
27462736                  UINT8 *pri = pri0;
27472737
r4135r4136
28332823   if( gfx )
28342824   {
28352825      const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
2836      int source_base = (code % gfx->total_elements) * 16;
2826      const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
28372827
28382828      {
28392829         /* compute sprite increment per screen pixel */
r4135r4136
29002890               int y;
29012891               for( y=sy; y<ey; y++ )
29022892               {
2903                  UINT8 *source = gfx->gfxdata + (source_base+(y_index>>16)) * 16;
2893                  const UINT8 *source = code_base + (y_index>>16) * 16;
29042894                  UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
29052895                  UINT8 *pri = BITMAP_ADDR8(pri_alp_bitmap, y, 0);
29062896
r4135r4136
32483238VIDEO_UPDATE( f3 )
32493239{
32503240   UINT32 sy_fix[5],sx_fix[5];
3251   int tile;
32523241
32533242   f3_skip_this_frame=0;
32543243   tilemap_set_flip(ALL_TILEMAPS,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
32553244
3256   /* Dynamically decode VRAM chars if dirty */
3257   if (vram_changed)
3258      for (tile = 0;tile < 256;tile++)
3259         if (vram_dirty[tile]) {
3260            decodechar(screen->machine->gfx[0],tile,(UINT8 *)f3_vram);
3261            tilemap_mark_all_tiles_dirty(vram_layer); // TODO
3262            //tilemap_mark_tile_dirty(vram_layer,tile);
3263            vram_dirty[tile]=0;
3264         }
3265
3266   /* Decode chars & mark tilemap dirty */
3267   if (pivot_changed)
3268      for (tile = 0;tile < 2048;tile++)
3269         if (pivot_dirty[tile]) {
3270            decodechar(screen->machine->gfx[3],tile,(UINT8 *)f3_pivot_ram);
3271            tilemap_mark_tile_dirty(pixel_layer,tile);
3272            pivot_dirty[tile]=0;
3273         }
3274   pivot_changed=vram_changed=0;
3275
32763245   /* Setup scroll */
32773246   sy_fix[0]=((f3_control_0[2]&0xffff0000)>> 7) + (1<<16);
32783247   sy_fix[1]=((f3_control_0[2]&0x0000ffff)<< 9) + (1<<16);
src/mame/video/gaelco2.c
r4135r4136
392392               } else { /* last palette entry is reserved for shadows and highlights */
393393
394394                  /* get a pointer to the current sprite's gfx data */
395                  UINT8 *gfx_src = gfx->gfxdata + (number % gfx->total_elements)*gfx->char_modulo;
395                  const UINT8 *gfx_src = gfx_element_get_data(gfx, number % gfx->total_elements);
396396
397397                  for (py = 0; py < gfx->height; py++){
398398                     /* get a pointer to the current line in the screen bitmap */
src/mame/video/mcr.c
r4135r4136
275275      for (y = 0; y < 32; y++, sy = (sy + 1) & 0x1ff)
276276         if (sy >= cliprect->min_y && sy <= cliprect->max_y)
277277         {
278            UINT8 *src = gfx->gfxdata + gfx->char_modulo * code + gfx->line_modulo * (y ^ vflip);
278            const UINT8 *src = gfx_element_get_data(gfx, code) + gfx->line_modulo * (y ^ vflip);
279279            UINT16 *dst = BITMAP_ADDR16(bitmap, sy, 0);
280280            UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, 0);
281281
r4135r4136
345345      for (y = 0; y < 32; y++, sy = (sy + 1) & 0x1ff)
346346         if (sy >= 2 && sy >= cliprect->min_y && sy <= cliprect->max_y)
347347         {
348            UINT8 *src = gfx->gfxdata + gfx->char_modulo * code + gfx->line_modulo * (y ^ vflip);
348            const UINT8 *src = gfx_element_get_data(gfx, code) + gfx->line_modulo * (y ^ vflip);
349349            UINT16 *dst = BITMAP_ADDR16(bitmap, sy, 0);
350350            UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, 0);
351351
src/mame/video/segasyse.c
r4135r4136
7474      segae_drawscanline(screen->machine, i-16,0,0);
7575
7676   for (i = miny;i <= maxy;i++)
77      draw_scanline8(bitmap,32,i,256,&cache_bitmap[(i-16) * (16+256+16) +24],&screen->machine->pens[palette_base],0);
77   {
78      UINT16 *dest = BITMAP_ADDR16(bitmap, i, 32);
79      int x;
80      for (x = 0; x < 256; x++)
81         dest[x] = screen->machine->pens[palette_base + cache_bitmap[(i-16) * (16+256+16) + 24 + x]];
82   }
7883
7984   return 0;
8085}
src/mame/video/airbustr.c
r4135r4136
119119   fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
120120
121121   sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
122    state_save_register_global_bitmap(machine, sprites_bitmap);
122123   tilemap_set_transparent_pen(fg_tilemap, 0);
123124   pandora_start(machine,1,0,0);
124125
src/mame/video/chqflag.c
r4135r4136
7979   bitmap_fill(bitmap,cliprect,0);
8080
8181   K051316_zoom_draw_1(bitmap,cliprect,TILEMAP_DRAW_LAYER1,0);
82   K051960_sprites_draw(bitmap,cliprect,0,0);
82   K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
8383   K051316_zoom_draw_1(bitmap,cliprect,TILEMAP_DRAW_LAYER0,0);
84   K051960_sprites_draw(bitmap,cliprect,1,1);
84   K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
8585   K051316_zoom_draw_0(bitmap,cliprect,0,0);
8686   return 0;
8787}
src/mame/video/bwing.c
r4135r4136
8181
8282      tilemap_mark_tile_dirty(scrollmap[offset>>12], offset & 0xfff);
8383   }
84   else
85   {
86      if (offset < 0x1000)
87         gfx_element_mark_dirty(fgfx, offset/32);
88      else
89         gfx_element_mark_dirty(bgfx, offset/32);
90   }
8491
8592   (srbase[srbank])[offset] = data;
8693}
r4135r4136
8895
8996WRITE8_HANDLER( bwing_scrollreg_w )
9097{
91   static unsigned bp_ready=0;
92   unsigned i;
93   UINT8 *src;
94
9598   sreg[offset] = data;
9699
97100   switch (offset)
r4135r4136
103106         mapmask = data;
104107         srbank = data >> 6;
105108
106         if (srbank) bp_ready |= 1<<(srbank-1) & 7;
107
108         if (bp_ready == 7 && !srbank)
109         {
110            src = srbase[1];
111            for (i=0; i<BW_NTILES; i++) decodechar(fgfx, i, src);
112
113            src += 0x1000;
114            for (i=0; i<BW_NTILES; i++) decodechar(bgfx, i, src);
115
116            bp_ready = 0;
117         }
118
119109         #if BW_DEBUG
120110            logerror("(%s)%04x: w=%02x a=%04x f=%d\n", space->cpu->tag, cpu_get_pc(space->cpu),data,0x1b00+offset,video_screen_get_frame_number(space->machine->primary_screen));
121111         #endif
r4135r4136
164154// Initializations
165155
166156#define BW_SET_TILE_INFO(GFX, CODE, COLOR) { \
167   tileinfo->pen_data = GFX->gfxdata + (CODE) * GFX->char_modulo; \
157   tileinfo->pen_data = gfx_element_get_data(GFX, CODE); \
168158   tileinfo->palette_base = GFX->color_base + ((COLOR) << 3); \
169159   }
170160
r4135r4136
215205   for (i=0; i<8; i++) sreg[i] = 0;
216206
217207   fgfx = machine->gfx[2];
208   gfx_element_set_source(fgfx, srbase[1]);
218209   bgfx = machine->gfx[3];
210   gfx_element_set_source(bgfx, srbase[1] + 0x1000);
219211
220212   dwptr = fgfx->pen_usage;
221213   if (dwptr)
src/mame/video/sengokmj.c
r4135r4136
99static tilemap *bg_tilemap,*md_tilemap,*fg_tilemap,*tx_tilemap;
1010UINT16 *sengokmj_bgvram,*sengokmj_mdvram,*sengokmj_fgvram,*sengokmj_txvram;
1111static UINT16 sengokmj_layer_en;
12static UINT16 sengokmj_scrolly;
1213
1314WRITE16_HANDLER( sengokmj_bgvram_w )
1415{
r4135r4136
4142   sengokmj_layer_en = data;
4243}
4344
45WRITE16_HANDLER( sengokmj_bg_scrolly_w )
46{
47   sengokmj_scrolly = data;
48}
49
4450static TILE_GET_INFO( sengoku_bg_tile_info )
4551{
4652   int tile = sengokmj_bgvram[tile_index];
r4135r4136
113119
114120VIDEO_START( sengokmj )
115121{
116   bg_tilemap = tilemap_create(machine, sengoku_bg_tile_info,tilemap_scan_rows,16,16,32,16);
117   md_tilemap = tilemap_create(machine, sengoku_md_tile_info,tilemap_scan_rows,16,16,32,16);
118   fg_tilemap = tilemap_create(machine, sengoku_fg_tile_info,tilemap_scan_rows,16,16,32,16);
122   bg_tilemap = tilemap_create(machine, sengoku_bg_tile_info,tilemap_scan_rows,16,16,32,32);
123   md_tilemap = tilemap_create(machine, sengoku_md_tile_info,tilemap_scan_rows,16,16,32,32);
124   fg_tilemap = tilemap_create(machine, sengoku_fg_tile_info,tilemap_scan_rows,16,16,32,32);
119125   tx_tilemap = tilemap_create(machine, sengoku_tx_tile_info,tilemap_scan_rows, 8, 8,64,32);
120126
121127   tilemap_set_transparent_pen(md_tilemap,15);
r4135r4136
126132VIDEO_UPDATE( sengokmj )
127133{
128134   bitmap_fill(bitmap, cliprect, screen->machine->pens[0x7ff]); //black pen
135   tilemap_set_scrolly( bg_tilemap,0, sengokmj_scrolly );
129136
130   if(!(sengokmj_layer_en & 1))
131      tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
132   draw_sprites(screen->machine, bitmap,cliprect, 2);
133   draw_sprites(screen->machine, bitmap,cliprect, 1);
134   if(!(sengokmj_layer_en & 2))
135      tilemap_draw(bitmap,cliprect,md_tilemap,0,0);
136   if(!(sengokmj_layer_en & 4))
137      tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
138   draw_sprites(screen->machine, bitmap,cliprect, 0);
139   draw_sprites(screen->machine, bitmap,cliprect, 3);
140   if(!(sengokmj_layer_en & 8))
141      tilemap_draw(bitmap,cliprect,tx_tilemap,0,0);
137   if(!(sengokmj_layer_en & 1))    { tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); }
138   if(!(sengokmj_layer_en & 0x10)) { draw_sprites(screen->machine, bitmap,cliprect, 2); }
139   if(!(sengokmj_layer_en & 0x10)) { draw_sprites(screen->machine, bitmap,cliprect, 1); }
140   if(!(sengokmj_layer_en & 2))    { tilemap_draw(bitmap,cliprect,md_tilemap,0,0); }
141   if(!(sengokmj_layer_en & 4))    { tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); }
142   if(!(sengokmj_layer_en & 0x10)) { draw_sprites(screen->machine, bitmap,cliprect, 0); }
143   if(!(sengokmj_layer_en & 0x10)) { draw_sprites(screen->machine, bitmap,cliprect, 3); }
144   if(!(sengokmj_layer_en & 8))   { tilemap_draw(bitmap,cliprect,tx_tilemap,0,0); }
142145
143146//  popmessage("%04x",sengokmj_layer_en);
144147   return 0;
src/mame/video/crimfght.c
r4135r4136
7777   K052109_tilemap_update();
7878
7979   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,0);
80   K051960_sprites_draw(bitmap,cliprect,2,2);
80   K051960_sprites_draw(screen->machine,bitmap,cliprect,2,2);
8181   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
82   K051960_sprites_draw(bitmap,cliprect,1,1);
82   K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
8383   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
84   K051960_sprites_draw(bitmap,cliprect,0,0);
84   K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
8585   return 0;
8686}
src/mame/video/rollerg.c
r4135r4136
7171   bitmap_fill(priority_bitmap,cliprect,0);
7272   bitmap_fill(bitmap,cliprect,16 * bg_colorbase);
7373   K051316_zoom_draw_0(bitmap,cliprect,0,1);
74   K053245_sprites_draw(0,bitmap,cliprect);
74   K053245_sprites_draw(screen->machine,0,bitmap,cliprect);
7575   return 0;
7676}
src/mame/video/exerion.c
r4135r4136
343343      }
344344
345345      /* draw the scanline */
346      draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL, -1);
346      draw_scanline16(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], NULL);
347347   }
348348}
349349
src/mame/video/wrally.c
r4135r4136
137137               cliprect,TRANSPARENCY_PEN,0);
138138      } else {
139139         /* get a pointer to the current sprite's gfx data */
140         UINT8 *gfx_src = gfx->gfxdata + (number % gfx->total_elements)*gfx->char_modulo;
140         const UINT8 *gfx_src = gfx_element_get_data(gfx, number % gfx->total_elements);
141141
142142         for (py = 0; py < gfx->height; py++){
143143            /* get a pointer to the current line in the screen bitmap */
src/mame/video/segas18.c
r4135r4136
218218
219219   /* draw background opaquely first, not setting any priorities */
220220   segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 0 | TILEMAP_DRAW_OPAQUE, 0x00);
221{
222   int x,y;
223   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
224      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
225         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("0: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
226}
227221   segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 1 | TILEMAP_DRAW_OPAQUE, 0x00);
228{
229   int x,y;
230   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
231      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
232         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("1: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
233}
234222   if (vdp_enable && vdplayer == 0) draw_vdp(bitmap, cliprect, vdppri);
235{
236   int x,y;
237   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
238      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
239         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("2: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
240}
241223
242224   /* draw background again to draw non-transparent pixels over the VDP and set the priority */
243225   segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 0, 0x01);
244{
245   int x,y;
246   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
247      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
248         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("3: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
249}
250226   segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_BACKGROUND, 1, 0x02);
251{
252   int x,y;
253   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
254      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
255         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("4: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
256}
257227   if (vdp_enable && vdplayer == 1) draw_vdp(bitmap, cliprect, vdppri);
258{
259   int x,y;
260   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
261      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
262         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("5: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
263}
264228
265229   /* draw foreground */
266230   segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_FOREGROUND, 0, 0x02);
267{
268   int x,y;
269   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
270      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
271         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("6: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
272}
273231   segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_FOREGROUND, 1, 0x04);
274{
275   int x,y;
276   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
277      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
278         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("7: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
279}
280232   if (vdp_enable && vdplayer == 2) draw_vdp(bitmap, cliprect, vdppri);
281{
282   int x,y;
283   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
284      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
285         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("8: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
286}
287233
288234   /* text layer */
289235   segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_TEXT, 0, 0x04);
290{
291   int x,y;
292   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
293      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
294         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("9: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
295}
296236   segaic16_tilemap_draw(screen, bitmap, cliprect, 0, SEGAIC16_TILEMAP_TEXT, 1, 0x08);
297{
298   int x,y;
299   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
300      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
301         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("A: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
302}
303237   if (vdp_enable && vdplayer == 3) draw_vdp(bitmap, cliprect, vdppri);
304{
305   int x,y;
306   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
307      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
308         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("B: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
309}
310238
311239   /* draw the sprites */
312240   segaic16_sprites_draw(screen, bitmap, cliprect, 0);
313{
314   int x,y;
315   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
316      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
317         if (*BITMAP_ADDR16(bitmap, y, x) >= 0x2000) printf("C: pix=%04X\n", *BITMAP_ADDR16(bitmap, y, x));
318}
319241
320242#if DEBUG_VDP
321243   if (vdp_enable && input_code_pressed(KEYCODE_V))
src/mame/video/ajax.c
r4135r4136
7979   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
8080   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
8181   K051316_vh_start_0(machine,"gfx3",7,FALSE,0,zoom_callback);
82    state_save_register_global(machine, ajax_priority);
8283}
8384
8485
r4135r4136
111112   }
112113   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,8);
113114
114   K051960_sprites_draw(bitmap,cliprect,-1,-1);
115   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
115116   return 0;
116117}
src/mame/video/m10.c
r4135r4136
6969   if (state->chargen[offset] != data)
7070   {
7171      state->chargen[offset] = data;
72      /* not very effective ... dirty would be better */
73      decodechar(space->machine->gfx[0],offset >> 3,state->chargen);
72      gfx_element_mark_dirty(space->machine->gfx[0],offset >> 3);
7473   }
7574}
7675
r4135r4136
8887
8988VIDEO_START( m10 )
9089{
91   //m10_state *state = machine->driver_data;
90   m10_state *state = machine->driver_data;
9291   int i;
9392
9493   for (i=0;i<32*8;i++)
r4135r4136
9998   tilemap_set_scrolldx(tx_tilemap, 0, 62);
10099   tilemap_set_scrolldy(tx_tilemap, 0, 0);
101100
102   back_gfx = allocgfx(machine, &backlayout);
103   back_gfx->total_colors = 8;
101   back_gfx = gfx_element_alloc(machine, &backlayout, state->chargen, 8, 0);
104102
105103   machine->gfx[1] = back_gfx;
106104   return ;
r4135r4136
110108{
111109   m10_state *state = machine->driver_data;
112110
113   machine->gfx[0] = allocgfx(machine, &charlayout);
114   machine->gfx[0]->total_colors = 8;
111   machine->gfx[0] = gfx_element_alloc(machine, &charlayout, state->chargen, 8, 0);
115112
116   decodegfx(machine->gfx[0], state->chargen,0,256);
117
118113   tx_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan,8,8,32,32);
119114   tilemap_set_scrolldx(tx_tilemap, 0, 116);
120115   tilemap_set_scrolldy(tx_tilemap, 0, 0);
r4135r4136
137132
138133   bitmap_fill(bitmap,cliprect,0);
139134
140   decodegfx(back_gfx, state->chargen,0,4);
141135   for (i=0;i<4;i++)
142136      if (state->flip)
143137         drawgfx(bitmap, back_gfx, i, color[i], 1, 1, 31*8 - xpos[i], 6, cliprect, 0, 0);
src/mame/drivers/mitchell.c
r4135r4136
303303      case 0:
304304      default:
305305         return input_port_read(space->machine, portnames[offset]);
306         break;
307306      case 1:      /* Mahjong games */
308307         if (offset) return mahjong_input_r(space, offset-1);
309308         else return input_port_read(space->machine, "IN0");
src/mame/drivers/deco_mlc.c
r4135r4136
214214   case 0x10: /* IRQ ack.  Value written doesn't matter */
215215      cpu_set_input_line(space->machine->cpu[0], mainCpuIsArm ? ARM_IRQ_LINE : 1, CLEAR_LINE);
216216      return;
217      break;
218217   case 0x14: /* Prepare scanline interrupt */
219218      timer_adjust_oneshot(raster_irq_timer,video_screen_get_time_until_pos(space->machine->primary_screen, irq_ram[0x14/4], 0),0);
220219      //logerror("prepare scanline to fire at %d (currently on %d)\n", irq_ram[0x14/4], video_screen_get_vpos(space->machine->primary_screen));
221220      return;
222      break;
223221   case 0x18:
224222   case 0x1c:
225223   case 0x20:
src/mame/drivers/rungun.c
r4135r4136
100100            data = input_port_read(space->machine, "P1") & input_port_read(space->machine, "P3");
101101            return(data<<8 | data);
102102         }
103      break;
104103
105104      case 0x02/2:
106105         if (input_port_read(space->machine, "DSW") & 0x20)
r4135r4136
110109            data = input_port_read(space->machine, "P2") & input_port_read(space->machine, "P4");
111110            return(data<<8 | data);
112111         }
113      break;
114112
115113      case 0x04/2:
116114         /*
r4135r4136
119117                bit9 : joysticks layout(auto detect???)
120118            */
121119         return input_port_read(space->machine, "SYSTEM");
122      break;
123120
124121      case 0x06/2:
125122         if (ACCESSING_BITS_0_7)
r4135r4136
133130            }
134131         }
135132         return((rng_sysreg[0x06/2] & 0xff00) | data);
136      break;
137133   }
138134
139135   return(rng_sysreg[offset]);
src/mame/drivers/sfbonus.c
r0r4136
1/* Skill Fruit Bonus
2 -- (unknown) encrypted CPU
3 --  16-bit (program appears interleaved)
4*/
5
6#include "driver.h"
7#include "cpu/m68000/m68000.h"
8#include "sound/okim6295.h"
9
10
11static ADDRESS_MAP_START( sfbonus_map, ADDRESS_SPACE_PROGRAM, 16 )
12   AM_RANGE(0x000000, 0x07ffff) AM_ROM
13ADDRESS_MAP_END
14
15VIDEO_START(sfbonus)
16{
17
18}
19
20VIDEO_UPDATE(sfbonus)
21{
22   return 0;
23}
24
25static INPUT_PORTS_START( sfbonus )
26INPUT_PORTS_END
27
28static const gfx_layout sfbonus_layout =
29{
30   8,8,
31   RGN_FRAC(1,1),
32   8,
33   { 0,1,2,3,4,5,6,7 },
34   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
35   { 0*64,1*64,2*64,3*64,4*64,5*64,6*64,7*64 },
36   8*64
37};
38
39
40static GFXDECODE_START( sfbonus )
41   GFXDECODE_ENTRY( "gfx1", 0, sfbonus_layout,   0x0, 2  )
42   GFXDECODE_ENTRY( "gfx2", 0, sfbonus_layout,   0x0, 2  )
43   GFXDECODE_ENTRY( "gfx3", 0, sfbonus_layout,   0x0, 2  )
44GFXDECODE_END
45
46
47static MACHINE_DRIVER_START( sfbonus )
48   MDRV_CPU_ADD("main", M68000, 16000000) // unknown CPU
49   MDRV_CPU_PROGRAM_MAP(0,sfbonus_map)
50
51   MDRV_GFXDECODE(sfbonus)
52
53   MDRV_SCREEN_ADD("main", RASTER)
54   MDRV_SCREEN_REFRESH_RATE(60)
55   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
56   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
57   MDRV_SCREEN_SIZE(64*8, 32*8)
58   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 0*8, 32*8-1)
59
60   MDRV_PALETTE_LENGTH(0x100)
61
62   MDRV_VIDEO_START(sfbonus)
63   MDRV_VIDEO_UPDATE(sfbonus)
64
65//  MDRV_SPEAKER_STANDARD_STEREO("left", "right")
66//  MDRV_SOUND_ADD("oki", OKIM6295, 1000000)
67//  MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified
68//  MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.47)
69//  MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.47)
70MACHINE_DRIVER_END
71
72ROM_START( sfbonus )
73   ROM_REGION( 0x80000, "main", 0 ) /* 68000 Code */
74   ROM_LOAD16_BYTE( "skfb16.bin", 0x00001, 0x40000, CRC(bfd53646) SHA1(bd58f8c6d5386649a6fc0f4bac46d1b6cd6248b1) )
75   ROM_LOAD16_BYTE( "skfb17.bin", 0x00000, 0x40000, CRC(e28ede82) SHA1(f320c4c9c30ec280ee2437d1ad4d2b6270580916) )
76
77   ROM_REGION( 0x040000, "oki", 0 ) /* Samples */
78   ROM_LOAD( "skfbrom2.bin", 0x00000, 0x20000, CRC(3823a36e) SHA1(4136e380b63546b9490033ad26d776f326eb9290) )
79
80   ROM_REGION( 0x100000, "gfx1", 0 )
81   ROM_LOAD16_BYTE( "skfbrom3.bin", 0x00000, 0x80000, CRC(36119517) SHA1(241bb256ab3ba595dcb0c81fd2e60ed35dd7c197) )
82   ROM_LOAD16_BYTE( "skfbrom4.bin", 0x00001, 0x80000, CRC(a655bac1) SHA1(0faea01c09409f9182f08370dcc0b466a799f17f) )
83
84   ROM_REGION( 0x100000, "gfx2", 0 )
85   ROM_LOAD16_BYTE( "skfbrom5.bin", 0x00000, 0x80000, CRC(752e6e3b) SHA1(46c3a1bbbf1a2afe36fa5333b6e74459e17e9bae) )
86   ROM_LOAD16_BYTE( "skfbrom6.bin", 0x00001, 0x80000, CRC(30df6b6a) SHA1(7a180fa8ee64b9efb0321baffad72f0a9485d568) )
87
88   ROM_REGION( 0x100000, "gfx3", 0 )
89   // these are the same as gfx 2 up to a point, after which they change
90   // maybe different tiles for odd / even tilemap columns, like cps1.c
91   ROM_LOAD16_BYTE( "skfbrom5a.bin", 0x00000, 0x80000, CRC(ed07a635) SHA1(a31ee06d8cb78c43affa9d899e9cec87a0875934) )
92   ROM_LOAD16_BYTE( "skfbrom6a.bin", 0x00001, 0x80000, CRC(b9a39e5a) SHA1(cb875db25d8bccf48542bd6dbecc474b1205563b) )
93ROM_END
94
95GAME( 199?, sfbonus,    0,        sfbonus,    sfbonus,    0, ROT0,  "Amcoe", "Skill Fruit Bonus", GAME_NOT_WORKING|GAME_NO_SOUND )
src/mame/drivers/aerofgt.c
r4135r4136
115115   memory_set_bankptr(space->machine, 1,rom + (data & 0x03) * 0x8000);
116116}
117117
118static MACHINE_START( aerofgt )
119{
120    state_save_register_global(machine, pending_command);
121}
122
118123static MACHINE_RESET( aerofgt )
119124{
120125   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
r4135r4136
12961301   MDRV_CPU_IO_MAP(turbofrc_sound_portmap,0)
12971302                        /* IRQs are triggered by the YM2610 */
12981303
1304    MDRV_MACHINE_START(aerofgt)
12991305   MDRV_MACHINE_RESET(aerofgt)
13001306
13011307   /* video hardware */
r4135r4136
14221428   MDRV_CPU_IO_MAP(turbofrc_sound_portmap,0)
14231429                        /* IRQs are triggered by the YM2610 */
14241430
1431    MDRV_MACHINE_START(aerofgt)
14251432   MDRV_MACHINE_RESET(aerofgt)
14261433
14271434   /* video hardware */
r4135r4136
14601467   MDRV_CPU_IO_MAP(turbofrc_sound_portmap,0)
14611468                        /* IRQs are triggered by the YM2610 */
14621469
1470    MDRV_MACHINE_START(aerofgt)
14631471   MDRV_MACHINE_RESET(aerofgt)
14641472
14651473   /* video hardware */
r4135r4136
14981506   MDRV_CPU_IO_MAP(turbofrc_sound_portmap,0)
14991507                        /* IRQs are triggered by the YM2610 */
15001508
1509    MDRV_MACHINE_START(aerofgt)
15011510   MDRV_MACHINE_RESET(aerofgt)
15021511
15031512   /* video hardware */
r4135r4136
15361545   MDRV_CPU_IO_MAP(aerofgt_sound_portmap,0)
15371546                        /* IRQs are triggered by the YM2610 */
15381547
1548    MDRV_MACHINE_START(aerofgt)
15391549   MDRV_MACHINE_RESET(aerofgt)
15401550
15411551   /* video hardware */
r4135r4136
15751585   MDRV_CPU_IO_MAP(aerofgt_sound_portmap,0)
15761586                        /* IRQs are triggered by the YM2610 */
15771587
1588    MDRV_MACHINE_START(aerofgt)
15781589   MDRV_MACHINE_RESET(aerofgt)
15791590
15801591   /* video hardware */
r4135r4136
16741685   MDRV_CPU_PROGRAM_MAP(wbbc97_sound_map,0)
16751686                        /* IRQs are triggered by the YM3812 */
16761687
1688    MDRV_MACHINE_START(aerofgt)
1689
16771690   /* video hardware */
16781691   MDRV_SCREEN_ADD("main", RASTER)
16791692   MDRV_SCREEN_REFRESH_RATE(60)
r4135r4136
24072420ROM_END
24082421
24092422
2410GAME( 1990, spinlbrk, 0,        spinlbrk, spinlbrk, 0, ROT0,   "V-System Co.",     "Spinal Breakers (World)", GAME_NO_COCKTAIL )
2411GAME( 1990, spinlbru, spinlbrk, spinlbrk, spinlbru, 0, ROT0,   "V-System Co.",     "Spinal Breakers (US)", GAME_NO_COCKTAIL )
2412GAME( 1990, spinlbrj, spinlbrk, spinlbrk, spinlbrk, 0, ROT0,   "V-System Co.",     "Spinal Breakers (Japan)", GAME_NO_COCKTAIL )
2413GAME( 1991, pspikes,  0,        pspikes,  pspikes,  0, ROT0,   "Video System Co.", "Power Spikes (World)", GAME_NO_COCKTAIL )
2414GAME( 1991, pspikesk, pspikes,  pspikes,  pspikes,  0, ROT0,   "Video System Co.", "Power Spikes (Korea)", GAME_NO_COCKTAIL )
2415GAME( 1991, svolly91, pspikes,  pspikes,  pspikes,  0, ROT0,   "Video System Co.", "Super Volley '91 (Japan)", GAME_NO_COCKTAIL )
2416GAME( 1991, pspikesb, pspikes,  pspikesb, pspikesb, 0, ROT0,   "bootleg",          "Power Spikes (bootleg)", GAME_NO_COCKTAIL )
2417GAME( 1991, spikes91, pspikes,  spikes91, pspikes,  0, ROT0,   "bootleg",          "1991 Spikes (Italian bootleg)", GAME_NO_SOUND | GAME_NO_COCKTAIL )
2418GAME( 1991, pspikesc, pspikes,  pspikesc, pspikesc, 0, ROT0,   "bootleg",          "Power Spikes (China)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND )
2419GAME( 1991, karatblz, 0,        karatblz, karatblz, 0, ROT0,   "Video System Co.", "Karate Blazers (World)", GAME_NO_COCKTAIL )
2420GAME( 1991, karatblu, karatblz, karatblz, karatblz, 0, ROT0,   "Video System Co.", "Karate Blazers (US)", GAME_NO_COCKTAIL )
2421GAME( 1991, karatblj, karatblz, karatblz, karatblz, 0, ROT0,   "Video System Co.", "Karate Blazers (Japan)", GAME_NO_COCKTAIL )
2422GAME( 1991, turbofrc, 0,        turbofrc, turbofrc, 0, ROT270, "Video System Co.", "Turbo Force", GAME_NO_COCKTAIL )
2423GAME( 1992, aerofgt,  0,        aerofgt,  aerofgt,  0, ROT270, "Video System Co.", "Aero Fighters", GAME_NO_COCKTAIL )
2424GAME( 1992, aerofgtb, aerofgt,  aerofgtb, aerofgtb, 0, ROT270, "Video System Co.", "Aero Fighters (Turbo Force hardware set 1)", GAME_NO_COCKTAIL )
2425GAME( 1992, aerofgtc, aerofgt,  aerofgtb, aerofgtb, 0, ROT270, "Video System Co.", "Aero Fighters (Turbo Force hardware set 2)", GAME_NO_COCKTAIL )
2426GAME( 1992, sonicwi,  aerofgt,  aerofgtb, aerofgtb, 0, ROT270, "Video System Co.", "Sonic Wings (Japan)", GAME_NO_COCKTAIL )
2427GAME( 1992, aerfboot, aerofgt,  aerfboot, aerofgtb, 0, ROT270, "bootleg",          "Aero Fighters (bootleg set 1)", GAME_NO_COCKTAIL | GAME_NO_SOUND )
2428GAME( 1992, aerfboo2, aerofgt,  aerfboo2, aerofgtb, 0, ROT270, "bootleg",          "Aero Fighters (bootleg set 2)", GAME_NO_COCKTAIL | GAME_NO_SOUND )
2429GAME( 1997, wbbc97,   0,        wbbc97,   wbbc97,   0, ROT0,   "Comad",            "Beach Festival World Championship 1997", GAME_NO_COCKTAIL )
2423GAME( 1990, spinlbrk, 0,        spinlbrk, spinlbrk, 0, ROT0,   "V-System Co.",     "Spinal Breakers (World)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2424GAME( 1990, spinlbru, spinlbrk, spinlbrk, spinlbru, 0, ROT0,   "V-System Co.",     "Spinal Breakers (US)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2425GAME( 1990, spinlbrj, spinlbrk, spinlbrk, spinlbrk, 0, ROT0,   "V-System Co.",     "Spinal Breakers (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2426GAME( 1991, pspikes,  0,        pspikes,  pspikes,  0, ROT0,   "Video System Co.", "Power Spikes (World)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2427GAME( 1991, pspikesk, pspikes,  pspikes,  pspikes,  0, ROT0,   "Video System Co.", "Power Spikes (Korea)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2428GAME( 1991, svolly91, pspikes,  pspikes,  pspikes,  0, ROT0,   "Video System Co.", "Super Volley '91 (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2429GAME( 1991, pspikesb, pspikes,  pspikesb, pspikesb, 0, ROT0,   "bootleg",          "Power Spikes (bootleg)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2430GAME( 1991, spikes91, pspikes,  spikes91, pspikes,  0, ROT0,   "bootleg",          "1991 Spikes (Italian bootleg)", GAME_SUPPORTS_SAVE | GAME_NO_SOUND | GAME_NO_COCKTAIL )
2431GAME( 1991, pspikesc, pspikes,  pspikesc, pspikesc, 0, ROT0,   "bootleg",          "Power Spikes (China)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND )
2432GAME( 1991, karatblz, 0,        karatblz, karatblz, 0, ROT0,   "Video System Co.", "Karate Blazers (World)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2433GAME( 1991, karatblu, karatblz, karatblz, karatblz, 0, ROT0,   "Video System Co.", "Karate Blazers (US)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2434GAME( 1991, karatblj, karatblz, karatblz, karatblz, 0, ROT0,   "Video System Co.", "Karate Blazers (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2435GAME( 1991, turbofrc, 0,        turbofrc, turbofrc, 0, ROT270, "Video System Co.", "Turbo Force", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2436GAME( 1992, aerofgt,  0,        aerofgt,  aerofgt,  0, ROT270, "Video System Co.", "Aero Fighters", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2437GAME( 1992, aerofgtb, aerofgt,  aerofgtb, aerofgtb, 0, ROT270, "Video System Co.", "Aero Fighters (Turbo Force hardware set 1)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2438GAME( 1992, aerofgtc, aerofgt,  aerofgtb, aerofgtb, 0, ROT270, "Video System Co.", "Aero Fighters (Turbo Force hardware set 2)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2439GAME( 1992, sonicwi,  aerofgt,  aerofgtb, aerofgtb, 0, ROT270, "Video System Co.", "Sonic Wings (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
2440GAME( 1992, aerfboot, aerofgt,  aerfboot, aerofgtb, 0, ROT270, "bootleg",          "Aero Fighters (bootleg set 1)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL | GAME_NO_SOUND )
2441GAME( 1992, aerfboo2, aerofgt,  aerfboo2, aerofgtb, 0, ROT270, "bootleg",          "Aero Fighters (bootleg set 2)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL | GAME_NO_SOUND )
2442GAME( 1997, wbbc97,   0,        wbbc97,   wbbc97,   0, ROT0,   "Comad",            "Beach Festival World Championship 1997", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
src/mame/drivers/coinmstr.c
r4135r4136
11/*
2
2x
33  Coinmaster trivia games
44
55  preliminary driver by Pierpaolo Prazzoli
66
77  TODO:
8  - finish video emulation (colors, missing banking bits)
9  - where is palette ?
8  - is there extra colour info in attr3 for suprnudge 2 and pokeroul?
9  - is there colour intensity control?
1010  - finish inputs
1111  - finish question roms reading
1212  - hook up all the PIAs
r4135r4136
2929#include "sound/ay8910.h"
3030
3131
32static UINT8 *attr_ram1, *attr_ram2;
32static UINT8 *attr_ram1, *attr_ram2, *attr_ram3;
3333static tilemap *bg_tilemap;
3434
3535static UINT8 question_adr[4];
r4135r4136
4242      tilemap_mark_tile_dirty(bg_tilemap,offset - 0x0240);
4343}
4444
45
46static void coinmstr_set_pal(running_machine *machine, UINT32 paldat, int col)
47{
48   col = col *4;
49
50   {
51      int r0, r1, r2, r3;
52      int g0, g1, g2, g3;
53      int b0, b1, b2, b3;
54
55      r0 = (paldat & 0x1000) >> 12 ;
56      g0 = (paldat & 0x0800) >> 11 ;
57      b0 = (paldat & 0x0400) >> 10 ;
58      r1 = (paldat & 0x0200) >> 9 ;
59      g1 = (paldat & 0x0100) >> 8 ;
60      b1 = (paldat & 0x0080) >> 7 ;
61
62      r2 = (paldat & 0x0020) >> 5 ;
63      g2 = (paldat & 0x0010) >> 4 ;
64      b2 = (paldat & 0x0008) >> 3 ;
65      r3 = (paldat & 0x0004) >> 2 ;
66      g3 = (paldat & 0x0002) >> 1 ;
67      b3 = (paldat & 0x0001) >> 0 ;
68
69
70      palette_set_color_rgb(machine, col+0, (b0 * 255) << 5, (g0 * 255) << 5, (r0 * 255) << 5);
71      palette_set_color_rgb(machine, col+2, (b1 * 255) << 5, (g1 * 255) << 5, (r1 * 255) << 5);
72      palette_set_color_rgb(machine, col+1, (b2 * 255) << 5, (g2 * 255) << 5, (r2 * 255) << 5);
73      palette_set_color_rgb(machine, col+3, (b3 * 255) << 5, (g3 * 255) << 5, (r3 * 255) << 5);
74
75   }
76}
77
78
4579static WRITE8_HANDLER( quizmstr_attr1_w )
4680{
4781   attr_ram1[offset] = data;
4882
4983   if(offset >= 0x0240)
50      tilemap_mark_tile_dirty(bg_tilemap,offset - 0x0240);
84   {
85      // the later games also use attr3 for something..
86      UINT32    paldata = (attr_ram1[offset] & 0x7f) | ((attr_ram2[offset] & 0x7f) << 7);
87      tilemap_mark_tile_dirty(bg_tilemap, offset - 0x0240);
88
89      coinmstr_set_pal(space->machine, paldata, offset - 0x240);
90
91   }
5192}
5293
5394static WRITE8_HANDLER( quizmstr_attr2_w )
r4135r4136
5596   attr_ram2[offset] = data;
5697
5798   if(offset >= 0x0240)
58      tilemap_mark_tile_dirty(bg_tilemap,offset - 0x0240);
99   {
100      // the later games also use attr3 for something..
101      UINT32    paldata = (attr_ram1[offset] & 0x7f) | ((attr_ram2[offset] & 0x7f) << 7);
102      tilemap_mark_tile_dirty(bg_tilemap, offset - 0x0240);
103
104      coinmstr_set_pal(space->machine, paldata, offset - 0x240);
105
106   }
59107}
60108
109static WRITE8_HANDLER( quizmstr_attr3_w )
110{
111   attr_ram3[offset] = data;
112
113   if(offset >= 0x0240)
114      tilemap_mark_tile_dirty(bg_tilemap, offset - 0x0240);
115
116}
117
118
61119static READ8_HANDLER( question_r )
62120{
63121   int address;
r4135r4136
116174   question_adr[offset] = data;
117175}
118176
177static READ8_HANDLER( ff_r )
178{
179   return 0xff;
180}
181
119182// Common memory map
120183
121184static ADDRESS_MAP_START( coinmstr_map, ADDRESS_SPACE_PROGRAM, 8 )
122185   AM_RANGE(0x0000, 0xbfff) AM_ROM
123   AM_RANGE(0xc000, 0xdfff) AM_RAM // supnudg2 writes here...
186   AM_RANGE(0xc000, 0xdfff) AM_RAM
124187   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(quizmstr_bg_w) AM_BASE(&videoram)
125188   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(quizmstr_attr1_w) AM_BASE(&attr_ram1)
126189   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(quizmstr_attr2_w) AM_BASE(&attr_ram2)
127   AM_RANGE(0xf800, 0xffff) AM_RAM // supnudg2 writes here...
190   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(quizmstr_attr3_w) AM_BASE(&attr_ram3)
128191ADDRESS_MAP_END
129192
130193// Different I/O mappping for every game
r4135r4136
182245   AM_RANGE(0xc0, 0xc3) AM_WRITENOP
183246ADDRESS_MAP_END
184247
248static ADDRESS_MAP_START( pokeroul_io_map, ADDRESS_SPACE_IO, 8 )
249   ADDRESS_MAP_GLOBAL_MASK(0xff)
250   AM_RANGE(0x40, 0x40) AM_DEVWRITE(H46505, "crtc", mc6845_address_w)
251   AM_RANGE(0x41, 0x41) AM_DEVWRITE(H46505, "crtc", mc6845_register_w)
252   AM_RANGE(0x48, 0x48) AM_WRITE(ay8910_control_port_0_w)
253   AM_RANGE(0x49, 0x49) AM_READWRITE(ay8910_read_port_0_r, ay8910_write_port_0_w)
254   AM_RANGE(0x58, 0x5b) AM_READWRITE(pia_0_r, pia_0_w) /* confirmed */
255   AM_RANGE(0x68, 0x6b) AM_READWRITE(pia_1_r, pia_1_w) /* confirmed */
256   AM_RANGE(0x78, 0x7b) AM_READWRITE(pia_2_r, pia_2_w) /* confirmed */
257   AM_RANGE(0xc0, 0xc1) AM_READ(ff_r)   /* needed to boot */
258ADDRESS_MAP_END
259
260
185261static INPUT_PORTS_START( quizmstr )
186262   PORT_START("IN0")
187263   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4135r4136
508584   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
509585INPUT_PORTS_END
510586
587static INPUT_PORTS_START( pokeroul )
588   PORT_START("IN0")
589   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Cancel / Collect")                           PORT_CODE(KEYCODE_N)
590   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 1 & 5 (auto?)")                         PORT_CODE(KEYCODE_Z)
591   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Hold 2 / Bet / Half Gamble / Previous Hand") PORT_CODE(KEYCODE_X)
592   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Deal / Draw / Gamble")                       PORT_CODE(KEYCODE_1)
593   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Auto Hold")                                  PORT_CODE(KEYCODE_M)
594   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Short Term Meters")              PORT_TOGGLE PORT_CODE(KEYCODE_0)
595   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Refill Mode")                    PORT_TOGGLE PORT_CODE(KEYCODE_9)
596   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER )   PORT_NAME("0-8")                                        PORT_CODE(KEYCODE_S)
597
598   PORT_START("IN1")
599   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE (2)
600   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE (2)
601   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
602   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
603   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
604   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
605   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
606   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
607
608   PORT_START("IN2")
609   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
610   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
611   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
612   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
613   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
614   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
615   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
616   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
617
618   PORT_START("IN3")
619   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
620   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
621   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
622   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
623   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
624   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
625   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
626   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
627
628   PORT_START("DSW1")
629   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
630   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
631   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
632   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
633   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
634   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
635   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
636   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
637   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
638   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
639   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
640   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
641   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
642   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
643   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
644   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
645   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
646   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
647   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
648   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
649   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
650   PORT_DIPNAME( 0x80, 0x80, "Factory Install Switch" )
651   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
652   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
653INPUT_PORTS_END
654
511655static const gfx_layout charlayout =
512656{
513657   8,8,
r4135r4136
523667   GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 32 )
524668GFXDECODE_END
525669
670
526671static TILE_GET_INFO( get_bg_tile_info )
527672{
528673   int tile = videoram[tile_index + 0x0240];
529   int color = 0;
674   int color = tile_index;
530675
531676   tile |= (attr_ram1[tile_index + 0x0240] & 0x80) << 1;
532677   tile |= (attr_ram2[tile_index + 0x0240] & 0x80) << 2;
533678
534   SET_TILE_INFO(0,tile,color,0);
679   tile |= (attr_ram3[tile_index + 0x0240] & 0x03) << (6+4);
680
681   SET_TILE_INFO(0, tile, color, 0);
535682}
536683
537684static VIDEO_START( coinmstr )
538685{
539   bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows, 8, 8, 46, 64);
686   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 46, 32);
540687}
541688
542689static VIDEO_UPDATE( coinmstr )
543690{
544   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
691   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
545692   return 0;
546693}
547694
r4135r4136
596743   /*irqs   : A/B             */ 0, 0
597744};
598745
746
747/* PIA 0 */
748static const pia6821_interface pokeroul_pia_0_intf =
749{
750   /*inputs : A/B,CA/B1,CA/B2 */ input_port_0_r, 0, 0, 0, 0, 0,
751   /*outputs: A/B,CA/B2       */ 0, 0, 0, 0,
752   /*irqs   : A/B             */ 0, 0
753};
754
755/* PIA 1 */
756static const pia6821_interface pokeroul_pia_1_intf =
757{
758   /*inputs : A/B,CA/B1,CA/B2 */ input_port_1_r, input_port_2_r, 0, 0, 0, 0,
759   /*outputs: A/B,CA/B2       */ 0, 0, 0, 0,
760   /*irqs   : A/B             */ 0, 0
761};
762
763/* PIA 2 */
764static const pia6821_interface pokeroul_pia_2_intf =
765{
766   /*inputs : A/B,CA/B1,CA/B2 */ input_port_3_r, 0, 0, 0, 0, 0,
767   /*outputs: A/B,CA/B2       */ 0, 0, 0, 0,
768   /*irqs   : A/B             */ 0, 0
769};
770
771
599772static MACHINE_START( quizmstr )
600773{
601774   pia_config(machine, 0, &quizmstr_pia_0_intf);
r4135r4136
620793   pia_reset();
621794}
622795
796static MACHINE_START( pokeroul )
797{
798   pia_config(machine, 0, &pokeroul_pia_0_intf);
799   pia_config(machine, 1, &pokeroul_pia_1_intf);
800   pia_config(machine, 2, &pokeroul_pia_2_intf);
801}
802
803static MACHINE_RESET( pokeroul )
804{
805   pia_reset();
806}
807
623808static const ay8910_interface ay8912_interface =
624809{
625810   AY8910_LEGACY_OUTPUT,
r4135r4136
657842   MDRV_SCREEN_VISIBLE_AREA(0*8, 46*8-1, 0*8, 32*8-1)
658843
659844   MDRV_GFXDECODE(coinmstr)
660   MDRV_PALETTE_LENGTH(256)
845   MDRV_PALETTE_LENGTH(46*32*4)
661846
662847   MDRV_VIDEO_START(coinmstr)
663848   MDRV_VIDEO_UPDATE(coinmstr)
r4135r4136
699884   MDRV_MACHINE_RESET(quizmstr)
700885MACHINE_DRIVER_END
701886
887static MACHINE_DRIVER_START( pokeroul )
888   MDRV_IMPORT_FROM(coinmstr)
889   MDRV_CPU_MODIFY("cpu")
890   MDRV_CPU_IO_MAP(pokeroul_io_map,0)
891
892   MDRV_MACHINE_START(pokeroul)
893   MDRV_MACHINE_RESET(pokeroul)
894MACHINE_DRIVER_END
895
702896/*
703897
704898Quizmaster
r4135r4136
796990   ROM_LOAD( "u4.bin",       0x8000, 0x8000, CRC(0551e859) SHA1(b71640097cc75b78f3013f0e77de328bf1a205b1) )
797991
798992   ROM_REGION( 0x10000, "gfx1", ROMREGION_DISPOSE )
799   ROM_LOAD( "u23.bin",      0x0000, 0x8000, CRC(726a48ac) SHA1(cd17840067294812edf5bfa88d71fc967388df8e) )
800   ROM_LOAD( "u25.bin",      0x8000, 0x8000, CRC(1f7cef5e) SHA1(3abc31d400a0f5dc29c70d8aac42fd6302290cc9) )
993   ROM_LOAD( "u25.bin",      0x0000, 0x8000, CRC(1f7cef5e) SHA1(3abc31d400a0f5dc29c70d8aac42fd6302290cc9) )
994   ROM_LOAD( "u23.bin",      0x8000, 0x8000, CRC(726a48ac) SHA1(cd17840067294812edf5bfa88d71fc967388df8e) )
801995
802996   ROM_REGION( 0xa0000, "user1", 0 ) /* Question roms */
803997   ROM_LOAD( "q1.bin",       0x00000, 0x8000, CRC(245d679a) SHA1(2d3fbed8c1b3d0bffe7f3bd9088e0a5d207654c7) )
r4135r4136
8221016   ROM_LOAD( "q20.bin",      0x98000, 0x8000, CRC(0845b450) SHA1(c373839ee1ad983e2df41cb22f625c14972372b0) )
8231017ROM_END
8241018
1019/*
1020
1021  Poker Roulette (c) 1990 Coinmaster
1022
1023
1024  Hardware notes:
1025
1026  CPU:  1x z80
1027  RAM:  2x 6264
1028  I/O:  3x 6821 PIAs
1029  CRTC: 1x 6845
1030  SND:  1x ay-3-8912
1031  Xtal: 1x 14MHz.
1032
1033
1034  Dev notes:
1035
1036  2x gfx banks, switched by bit4 of attr RAM.
1037
1038*/
1039
1040ROM_START( pokeroul )
1041   ROM_REGION( 0x10000, "cpu", 0 )
1042   ROM_LOAD( "poker1.ic3",   0x0000, 0x8000, CRC(bfe78d09) SHA1(7cc0f57714ff808a41ce20027a283e5dff60f752) )
1043   ROM_LOAD( "poker2.ic4",   0x8000, 0x8000, CRC(34c1b55c) SHA1(fa562d230a57dce3fff176c21c86b461a02749f6) )
1044
1045   ROM_REGION( 0x10000, "gfx1", 0 )
1046   ROM_LOAD( "027c1.00_e14.7.88.ic25",   0x0000, 0x8000, CRC(719f9879) SHA1(122e2689a21a22713f938e3bf6cfb72c60fb9a16) )
1047   ROM_LOAD( "027c1.01_e14.7.88.ic23",   0x8000, 0x8000, CRC(71e5a2fc) SHA1(c28efcea1cf6c9872e70ff191932e3cdb5618917) )
1048ROM_END
1049
1050
8251051static DRIVER_INIT( coinmstr )
8261052{
8271053   UINT8 *rom = memory_region(machine, "user1");
r4135r4136
8411067}
8421068
8431069
844GAME( 1985, quizmstr, 0, quizmstr, quizmstr, coinmstr, ROT0, "Loewen Spielautomaten", "Quizmaster (German)",            GAME_WRONG_COLORS | GAME_UNEMULATED_PROTECTION )
845GAME( 1987, trailblz, 0, trailblz, trailblz, coinmstr, ROT0, "Coinmaster",            "Trail Blazer",                   GAME_WRONG_COLORS | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) // or Trail Blazer 2 ?
846GAME( 1989, supnudg2, 0, supnudg2, supnudg2, coinmstr, ROT0, "Coinmaster",            "Super Nudger II (Version 5.21)", GAME_WRONG_COLORS | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
1070GAME( 1985, quizmstr, 0, quizmstr, quizmstr, coinmstr, ROT0, "Loewen Spielautomaten", "Quizmaster (German)",            GAME_UNEMULATED_PROTECTION )
1071GAME( 1987, trailblz, 0, trailblz, trailblz, coinmstr, ROT0, "Coinmaster",            "Trail Blazer",                   GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) // or Trail Blazer 2 ?
1072GAME( 1989, supnudg2, 0, supnudg2, supnudg2, coinmstr, ROT0, "Coinmaster",            "Super Nudger II (Version 5.21)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
1073GAME( 1990, pokeroul, 0, pokeroul, pokeroul, 0,        ROT0, "Coinmaster",            "Poker Roulette (Version 8.22)",  GAME_NOT_WORKING )
src/mame/drivers/spool99.c
r4135r4136
107107         0);
108108}
109109
110VIDEO_START(spool99)
110static VIDEO_START(spool99)
111111{
112112   sc0_tilemap = tilemap_create(machine, get_spool99_tile_info,tilemap_scan_rows,8,8,64,32);
113113}
114114
115VIDEO_UPDATE(spool99)
115static VIDEO_UPDATE(spool99)
116116{
117117   tilemap_draw(bitmap,cliprect,sc0_tilemap,0,0);
118118   return 0;
src/mame/drivers/arabian.c
r4135r4136
361361 *
362362 *************************************/
363363
364static MACHINE_START( arabian )
365{
366    state_save_register_global(machine, custom_cpu_reset);
367    state_save_register_global(machine, custom_cpu_busy);
368}
369
364370static MACHINE_DRIVER_START( arabian )
365371
366372   /* basic machine hardware */
r4135r4136
369375   MDRV_CPU_IO_MAP(main_io_map,0)
370376   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
371377
378    MDRV_MACHINE_START(arabian)
379
372380   /* video hardware */
373381   MDRV_SCREEN_ADD("main", RASTER)
374382   MDRV_SCREEN_REFRESH_RATE(60)
r4135r4136
449457 *
450458 *************************************/
451459
452GAME( 1983, arabian,  0,        arabian,  arabian,  arabian,  ROT270, "Sun Electronics",                   "Arabian",         0 )
453GAME( 1983, arabiana, arabian,  arabian,  arabiana, arabian,  ROT270, "[Sun Electronics] (Atari license)", "Arabian (Atari)", 0 )
460GAME( 1983, arabian,  0,        arabian,  arabian,  arabian,  ROT270, "Sun Electronics",                   "Arabian",         GAME_SUPPORTS_SAVE )
461GAME( 1983, arabiana, arabian,  arabian,  arabiana, arabian,  ROT270, "[Sun Electronics] (Atari license)", "Arabian (Atari)", GAME_SUPPORTS_SAVE )
src/mame/drivers/hornet.c
r4135r4136
332332
333333static UINT32 *K037122_tile_ram[MAX_K037122_CHIPS];
334334static UINT32 *K037122_char_ram[MAX_K037122_CHIPS];
335static UINT8 *K037122_dirty_map[MAX_K037122_CHIPS];
336static int K037122_gfx_index[MAX_K037122_CHIPS], K037122_char_dirty[MAX_K037122_CHIPS];
335static int K037122_gfx_index[MAX_K037122_CHIPS];
337336static tilemap *K037122_layer[MAX_K037122_CHIPS][2];
338337static UINT32 *K037122_reg[MAX_K037122_CHIPS];
339338
r4135r4136
410409   SET_TILE_INFO(K037122_gfx_index[1], tile, color, flags);
411410}
412411
413static STATE_POSTLOAD( K037122_postload )
414{
415   int chip = (FPTR)param;
416   K037122_char_dirty[chip] = 1;
417   memset(K037122_dirty_map[chip], 1, K037122_NUM_TILES);
418}
419
420412static int K037122_vh_start(running_machine *machine, int chip)
421413{
422414   for(K037122_gfx_index[chip] = 0; K037122_gfx_index[chip] < MAX_GFX_ELEMENTS; K037122_gfx_index[chip]++)
r4135r4136
429421
430422   K037122_tile_ram[chip] = auto_malloc(0x20000);
431423
432   K037122_dirty_map[chip] = auto_malloc(K037122_NUM_TILES);
433
434424   K037122_reg[chip] = auto_malloc(0x400);
435425
436426   if (chip == 0)
r4135r4136
449439
450440   memset(K037122_char_ram[chip], 0, 0x200000);
451441   memset(K037122_tile_ram[chip], 0, 0x20000);
452   memset(K037122_dirty_map[chip], 0, K037122_NUM_TILES);
453442   memset(K037122_reg[chip], 0, 0x400);
454443
455   machine->gfx[K037122_gfx_index[chip]] = allocgfx(machine, &K037122_char_layout);
456   decodegfx(machine->gfx[K037122_gfx_index[chip]], (UINT8*)K037122_char_ram[chip], 0, machine->gfx[K037122_gfx_index[chip]]->total_elements);
444   machine->gfx[K037122_gfx_index[chip]] = gfx_element_alloc(machine, &K037122_char_layout, (UINT8*)K037122_char_ram[chip], machine->config->total_colors / 16, 0);
457445
458   machine->gfx[K037122_gfx_index[chip]]->total_colors = machine->config->total_colors / 16;
459
460446   state_save_register_item_pointer(machine, "K037122", NULL, chip, K037122_reg[chip], 0x400/sizeof(K037122_reg[chip][0]));
461447   state_save_register_item_pointer(machine, "K037122", NULL, chip, K037122_char_ram[chip], 0x200000/sizeof(K037122_char_ram[chip][0]));
462448   state_save_register_item_pointer(machine, "K037122", NULL, chip, K037122_tile_ram[chip], 0x20000/sizeof(K037122_tile_ram[chip][0]));
463   state_save_register_postload(machine, K037122_postload, (void *)(FPTR)chip);
464449
465450   return 0;
466451}
467452
468static void K037122_tile_update(running_machine *machine, int chip)
469{
470   if (K037122_char_dirty[chip])
471   {
472      int i;
473      for (i=0; i < K037122_NUM_TILES; i++)
474      {
475         if (K037122_dirty_map[chip][i])
476         {
477            K037122_dirty_map[chip][i] = 0;
478            decodechar(machine->gfx[K037122_gfx_index[chip]], i, (UINT8 *)K037122_char_ram[chip]);
479         }
480      }
481      tilemap_mark_all_tiles_dirty(K037122_layer[chip][0]);
482      tilemap_mark_all_tiles_dirty(K037122_layer[chip][1]);
483      K037122_char_dirty[chip] = 0;
484   }
485}
486
487453static void K037122_tile_draw(running_machine *machine, int chip, bitmap_t *bitmap, const rectangle *cliprect)
488454{
489455   const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
r4135r4136
576542   addr = offset + (bank * (0x40000/4));
577543
578544   COMBINE_DATA(K037122_char_ram[chip] + addr);
579   K037122_dirty_map[chip][addr / 32] = 1;
580   K037122_char_dirty[chip] = 1;
545   gfx_element_mark_dirty(space->machine->gfx[K037122_gfx_index[chip]], addr / 32);
581546}
582547
583548static READ32_HANDLER(K037122_reg_r)
r4135r4136
629594
630595   voodoo_update(voodoo, bitmap, cliprect);
631596
632   K037122_tile_update(screen->machine, 0);
633597   K037122_tile_draw(screen->machine, 0, bitmap, cliprect);
634598
635599   draw_7segment_led(bitmap, 3, 3, led_reg0);
r4135r4136
645609      voodoo_update(voodoo, bitmap, cliprect);
646610
647611      /* TODO: tilemaps per screen */
648      K037122_tile_update(screen->machine, 0);
649612      K037122_tile_draw(screen->machine, 0, bitmap, cliprect);
650613   }
651614   else if (strcmp(screen->tag, "right") == 0)
r4135r4136
654617      voodoo_update(voodoo, bitmap, cliprect);
655618
656619      /* TODO: tilemaps per screen */
657      K037122_tile_update(screen->machine, 1);
658620      K037122_tile_draw(screen->machine, 1, bitmap, cliprect);
659621   }
660622
src/mame/drivers/86lions.c
r0r4136
1/*******************************************************************************************
2
386 Lions (c) 1985 Aristocrat
4
5driver by Chris Hardy,Angelo Salese & Roberto Fresca
6
7
8NOTES:
9
10  - 2 graphics ROMS by each R, G, B.
11  - 6 bit buffer, goes to 2 resistors each to 3 transistors... 32 colors.
12  - CRTC is using 4 pixels by memory address.
13  - Xtal and crtc CLK are accurate.
14  - Seems to be 1 DSW bank tied to VIA, and another to ay8910.
15
16TODO:
17    - Understand inputs / via mapping properly;
18    - Finish the mc6845 conversion;
19    - Colors? This shoudn't use a color prom.
20
21*******************************************************************************************/
22
23#define MAIN_CLOCK   XTAL_12MHz   /* guess */
24
25#include "driver.h"
26#include "cpu/m6809/m6809.h"
27#include "video/mc6845.h"
28#include "sound/ay8910.h"
29#include "machine/6522via.h"
30
31static UINT8 *lions_vram;
32
33VIDEO_START(lions)
34{
35}
36
37VIDEO_UPDATE(lions)
38{
39   const gfx_element *gfx = screen->machine->gfx[0];
40   int count = 0;
41
42   int y,x;
43
44   for (y=0;y<27;y++)
45   {
46      for (x=0;x<38;x++)
47      {
48         int tile = lions_vram[count+1]|lions_vram[count]<<8;
49         tile&=0x1ff;
50         //int colour = tile>>12;
51         drawgfx(bitmap,gfx,tile,0,0,0,x*8,y*8,cliprect,TRANSPARENCY_NONE,0);
52
53         count+=2;
54      }
55   }
56   return 0;
57}
58
59
60/**********************
61*
62* End of Video Hardware
63*
64**********************/
65
66static READ8_HANDLER( test_r )
67{
68   return mame_rand(space->machine);
69}
70
71
72static READ8_HANDLER(lions_via_r)
73{
74   const device_config *via_0 = device_list_find_by_tag(space->machine->config->devicelist, VIA6522, "via6522_0");
75   return via_r(via_0, offset);
76}
77
78static WRITE8_HANDLER(lions_via_w)
79{
80   const device_config *via_0 = device_list_find_by_tag(space->machine->config->devicelist, VIA6522, "via6522_0");
81   via_w(via_0, offset, data);
82}
83
84
85static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
86   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&lions_vram)
87   AM_RANGE(0x0800, 0x0fff) AM_RAM
88   AM_RANGE(0x1800, 0x1800) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
89   AM_RANGE(0x1801, 0x1801) AM_DEVREADWRITE(MC6845, "crtc", mc6845_register_r, mc6845_register_w)
90   AM_RANGE(0x5000, 0x500f) AM_READWRITE(lions_via_r, lions_via_w)
91   AM_RANGE(0x5300, 0x5300) AM_READ(test_r)//AM_READ_PORT("IN0")
92   AM_RANGE(0x5382, 0x5382) AM_WRITE(ay8910_write_port_0_w)
93   AM_RANGE(0x5383, 0x5383) AM_WRITE(ay8910_control_port_0_w)
94   AM_RANGE(0xe000, 0xffff) AM_ROM
95ADDRESS_MAP_END
96
97static INPUT_PORTS_START( lions )
98
99   PORT_START("IN0")
100   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-1") PORT_CODE(KEYCODE_1)
101   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-2") PORT_CODE(KEYCODE_2)
102   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-3") PORT_CODE(KEYCODE_3)
103   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-4") PORT_CODE(KEYCODE_4)
104   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-5") PORT_CODE(KEYCODE_5)
105   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-6") PORT_CODE(KEYCODE_6)
106   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-7") PORT_CODE(KEYCODE_7)
107   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-8") PORT_CODE(KEYCODE_8)
108
109   PORT_START("IN1")
110   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-1") PORT_CODE(KEYCODE_Q)
111   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-2") PORT_CODE(KEYCODE_W)
112   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-3") PORT_CODE(KEYCODE_E)
113   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-4") PORT_CODE(KEYCODE_R)
114   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-5") PORT_CODE(KEYCODE_T)
115   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-6") PORT_CODE(KEYCODE_Y)
116   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-7") PORT_CODE(KEYCODE_U)
117   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-8") PORT_CODE(KEYCODE_I)
118
119   PORT_START("IN2")
120   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-1") PORT_CODE(KEYCODE_A)
121   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-2") PORT_CODE(KEYCODE_S)
122   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-3") PORT_CODE(KEYCODE_D)
123   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-4") PORT_CODE(KEYCODE_F)
124   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-5") PORT_CODE(KEYCODE_G)
125   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-6") PORT_CODE(KEYCODE_H)
126   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-7") PORT_CODE(KEYCODE_J)
127   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0-8") PORT_CODE(KEYCODE_K)
128
129   PORT_START("IN3")
130   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-1") PORT_CODE(KEYCODE_Z)
131   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-2") PORT_CODE(KEYCODE_X)
132   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-3") PORT_CODE(KEYCODE_C)
133   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-4") PORT_CODE(KEYCODE_V)
134   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-5") PORT_CODE(KEYCODE_B)
135   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-6") PORT_CODE(KEYCODE_N)
136   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-7") PORT_CODE(KEYCODE_M)
137   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1-8") PORT_CODE(KEYCODE_L)
138
139//  PORT_START("DSW1")
140//  PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
141//  PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
142//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
143//  PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
144//  PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
145//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
146//  PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
147//  PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
148//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
149//  PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
150//  PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
151//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
152//  PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
153//  PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
154//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
155//  PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
156//  PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
157//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
158//  PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
159//  PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
160//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
161//  PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
162//  PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
163//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
164
165//  PORT_START("DSW2")
166//  PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
167//  PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
168//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
169//  PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
170//  PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
171//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
172//  PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
173//  PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
174//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
175//  PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
176//  PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
177//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
178//  PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
179//  PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
180//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
181//  PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
182//  PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
183//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
184//  PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
185//  PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
186//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
187//  PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
188//  PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
189//  PORT_DIPSETTING(    0x00, DEF_STR( On ) )
190INPUT_PORTS_END
191
192
193static const gfx_layout layout8x8x3 =
194{
195   8,8,
196   RGN_FRAC(1,3),
197   3,
198   {
199      RGN_FRAC(0,3),
200      RGN_FRAC(1,3),
201      RGN_FRAC(2,3),
202   },
203   { STEP8(0,1) },
204   { STEP8(0,8) },
205   8*8
206};
207
208static GFXDECODE_START( lions )
209   GFXDECODE_ENTRY( "gfx1", 0, layout8x8x3, 0, 1 )
210   GFXDECODE_ENTRY( "gfx2", 0, layout8x8x3, 0, 1 )
211GFXDECODE_END
212
213static const ay8910_interface ay8910_config =
214{
215   AY8910_LEGACY_OUTPUT,
216   AY8910_DEFAULT_LOADS,
217   input_port_2_r,   /* DSW? */
218   input_port_3_r,   /* DSW? */
219   NULL,
220   NULL
221};
222
223//static READ8_DEVICE_HANDLER( input_a )
224//{
225//return input_port_read(machine, "IN0");
226//  return mame_rand(device->machine);
227//return 0xff;
228//}
229
230//static READ8_DEVICE_HANDLER( input_b )
231//{
232//return input_port_read(machine, "IN1");
233//      return mame_rand(device->machine);
234//return 0xff;
235//}
236
237static READ8_DEVICE_HANDLER( input_ca1 )
238{
239//      return mame_rand(device->machine);
240   return 0x00;
241}
242
243static READ8_DEVICE_HANDLER( input_cb1 )
244{
245//      return mame_rand(device->machine);
246   return 0x00;
247}
248
249static READ8_DEVICE_HANDLER( input_ca2 )
250{
251//      return mame_rand(device->machine);
252
253   return 0x00;
254}
255
256static READ8_DEVICE_HANDLER( input_cb2 )
257{
258//      return mame_rand(device->machine);
259
260   return 0x00;
261}
262
263static WRITE8_DEVICE_HANDLER( output_a )
264{
265   popmessage("VIA outa: %02X", data);
266   // ...
267}
268
269static WRITE8_DEVICE_HANDLER( output_b )
270{
271   popmessage("VIA outb: %02X", data);
272   // ...
273}
274
275
276static WRITE8_DEVICE_HANDLER( output_ca1 )
277{
278   // ...
279}
280
281static WRITE8_DEVICE_HANDLER( output_cb1 )
282{
283   // ...
284}
285
286static WRITE8_DEVICE_HANDLER( output_ca2 )
287{
288   // ...
289}
290
291static WRITE8_DEVICE_HANDLER( output_cb2 )
292{
293   // ...
294}
295
296static void via_irq(const device_config *device, int state)
297{
298   cpu_set_input_line(device->machine->cpu[0], M6809_FIRQ_LINE, state);
299}
300
301static const via6522_interface via_interface =
302{
303   /*inputs : A/B         */ DEVICE8_PORT("IN0"), DEVICE8_PORT("IN1"),
304   /*inputs : CA/B1,CA/B2 */ input_ca1, input_cb1, input_ca2, input_cb2,
305   /*outputs: A/B         */ output_a, output_b,
306   /*outputs: CA/B1,CA/B2 */ output_ca1, output_cb1, output_ca2, output_cb2,
307   /*irq                  */ via_irq
308};
309
310static INTERRUPT_GEN( lions_irq )
311{
312}
313
314static const mc6845_interface mc6845_intf =
315{
316   /* in fact is a mc6845 driving 4 pixels by memory address.
317       that's why the big horizontal parameters */
318
319   "main",   /* screen we are acting on */
320   4,      /* number of pixels per video memory address */
321   NULL,   /* before pixel update callback */
322   NULL,   /* row update callback */
323   NULL,   /* after pixel update callback */
324   NULL,   /* callback for display state changes */
325   NULL,   /* HSYNC callback */
326   NULL   /* VSYNC callback */
327};
328
329static MACHINE_DRIVER_START( lions )
330   /* basic machine hardware */
331   MDRV_CPU_ADD("main", M6809, MAIN_CLOCK/4)       /* 3 MHz.(guess) */
332   MDRV_CPU_PROGRAM_MAP(readmem,0)
333   MDRV_CPU_VBLANK_INT("main", lions_irq )
334
335   /* video hardware */
336   MDRV_SCREEN_ADD("main", RASTER)
337   MDRV_SCREEN_REFRESH_RATE(60)
338   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
339   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
340   MDRV_SCREEN_SIZE(304, 256)
341   MDRV_SCREEN_VISIBLE_AREA(0, 304-1, 0, 216-1)   /* from the crtc registers... updated by crtc */
342
343   MDRV_GFXDECODE(lions)
344   MDRV_PALETTE_LENGTH(8)
345
346   MDRV_VIDEO_START(lions)
347   MDRV_VIDEO_UPDATE(lions)
348
349   MDRV_VIA6522_ADD("via6522_0", MAIN_CLOCK/12, via_interface)   /* 1 MHz.(only 1 or 2 MHz.are valid) */
350
351   MDRV_MC6845_ADD("crtc", MC6845, MAIN_CLOCK/8, mc6845_intf)   /* 1.5 MHz.(logical guess to get a decent 59.6374 Hz.) */
352
353   MDRV_SPEAKER_STANDARD_MONO("mono")
354
355   MDRV_SOUND_ADD("ay", AY8910, MAIN_CLOCK/8)   /* 1.5 MHz.(guess) */
356   MDRV_SOUND_CONFIG(ay8910_config)
357   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
358MACHINE_DRIVER_END
359
360
361ROM_START( 86lions )
362   ROM_REGION( 0x10000, "main", 0 )
363   ROM_LOAD( "lion_std.u9", 0xe000, 0x2000, CRC(994842b0) SHA1(72fc31c577ee70b07ce9a4f2e864fe113d32affe) )
364
365   ROM_REGION( 0x3000, "gfx1", 0 )
366   ROM_LOAD( "rd0.u13", 0x00000, 0x1000, CRC(38c57504) SHA1(cc3ac1df644abc4586fc9f0e88531ba146b86b48) )
367   ROM_LOAD( "gn0.u10", 0x01000, 0x1000, CRC(80dce6f4) SHA1(bf953eba9cb270297b0d0efffe15b926e94dfbe7) )
368   ROM_LOAD( "bl0.u8",  0x02000, 0x1000, CRC(00ef4724) SHA1(714fafd035e2befbb35c6d00df52845745e58a93) )
369
370   ROM_REGION( 0x3000, "gfx2", 0 )
371   ROM_LOAD( "rd1.u12", 0x00000, 0x1000, CRC(350dd017) SHA1(ba273d4231e7e4c44922898cf5a70e8b1d6e2f9d) )
372   ROM_LOAD( "gn1.u11", 0x01000, 0x1000, CRC(80dce6f4) SHA1(bf953eba9cb270297b0d0efffe15b926e94dfbe7) )
373   ROM_LOAD( "bl1.u9",  0x02000, 0x1000, CRC(675e164a) SHA1(99346ca70bfe673b31d71dc6b3bbc3b8f961e87f) )
374
375//  ROM_REGION( 0x20, "proms", 0 )
376//  ROM_LOAD( "prom.x", 0x00, 0x20, NO_DUMP )
377ROM_END
378
379
380GAME( 1985, 86lions, 0, lions, lions, 0, ROT0, "Aristocrat",  "86 Lions", GAME_WRONG_COLORS | GAME_NOT_WORKING )
src/mame/drivers/mediagx.c
r4135r4136
181181static void draw_char(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y)
182182{
183183   int i,j;
184   UINT8 *dp;
184   const UINT8 *dp;
185185   int index = 0;
186   dp = gfx->gfxdata + ch * gfx->char_modulo;
186   dp = gfx_element_get_data(gfx, ch);
187187
188188   for (j=y; j < y+8; j++)
189189   {
src/mame/drivers/ambush.c
r4135r4136
294294   ROM_LOAD( "14.bpr",        0x0300, 0x0100, CRC(622a8ce7) SHA1(6834f67874251f2ef3a33aec893311f5d10e496f) )  /* They don't look like color PROMs */
295295ROM_END
296296
297GAME( 1983, ambush,   0,        ambush,   ambush,   0, ROT0, "Nippon Amuse Co-Ltd", "Ambush", 0 )
298GAME( 1983, ambushv,  ambush,   ambush,   ambush,   0, ROT0, "Volt Elec co-ltd", "Ambush (Volt Elec co-ltd)", 0 )
299GAME( 1983, ambusht,  ambush,   ambush,   ambusht,  0, ROT0, "Tecfri", "Ambush (Tecfri)", 0 )
297GAME( 1983, ambush,   0,        ambush,   ambush,   0, ROT0, "Nippon Amuse Co-Ltd", "Ambush", GAME_SUPPORTS_SAVE )
298GAME( 1983, ambushv,  ambush,   ambush,   ambush,   0, ROT0, "Volt Elec co-ltd", "Ambush (Volt Elec co-ltd)", GAME_SUPPORTS_SAVE )
299GAME( 1983, ambusht,  ambush,   ambush,   ambusht,  0, ROT0, "Tecfri", "Ambush (Tecfri)", GAME_SUPPORTS_SAVE )
src/mame/drivers/seibuspi.c
r4135r4136
10501050   AM_RANGE(0x8000, 0xffff) AM_ROMBANK(4)
10511051ADDRESS_MAP_END
10521052
1053static READ8_HANDLER( flashrom_read )
1053static READ8_DEVICE_HANDLER( flashrom_read )
10541054{
10551055   logerror("Flash Read: %08X\n", offset);
10561056   if( offset < 0x100000 )
r4135r4136
10641064   return 0;
10651065}
10661066
1067static WRITE8_HANDLER( flashrom_write )
1067static WRITE8_DEVICE_HANDLER( flashrom_write )
10681068{
10691069   logerror("Flash Write: %08X, %02X\n", offset, data);
10701070   if( offset < 0x100000 )
src/mame/drivers/suprnova.c
r4135r4136
195195UINT32 *skns_palette_ram;
196196UINT32 *skns_pal_regs, *skns_v3_regs, *skns_spc_regs;
197197
198UINT32 skns_v3t_dirty[0x4000]; // allocate this elsewhere?
199UINT32 skns_v3t_4bppdirty[0x8000]; // allocate this elsewhere?
200int skns_v3t_somedirty,skns_v3t_4bpp_somedirty;
201
202198static UINT32 *skns_v3t_ram, *skns_main_ram, *skns_cache_ram;
203199
204200/* hit.c */
r4135r4136
755751
756752   COMBINE_DATA(&skns_v3t_ram[offset]);
757753
758   skns_v3t_dirty[offset/0x40] = 1;
759   skns_v3t_somedirty = 1;
760   skns_v3t_4bppdirty[offset/0x20] = 1;
761   skns_v3t_4bpp_somedirty = 1;
754   gfx_element_mark_dirty(space->machine->gfx[1], offset/0x40);
755   gfx_element_mark_dirty(space->machine->gfx[3], offset/0x20);
762756
763757   data = skns_v3t_ram[offset];
764758// i think we need to swap around to decode .. endian issues?
src/mame/drivers/luckgrln.c
r4135r4136
140140   MDRV_VIDEO_UPDATE(luckgrln)
141141MACHINE_DRIVER_END
142142
143DRIVER_INIT( luckgrln )
143static DRIVER_INIT( luckgrln )
144144{
145145   int i;
146146   UINT8 x,v;
src/mame/drivers/dynax.c
r4135r4136
665665{
666666   dynax_flipscreen_w(space,0,(data&2)?1:0);
667667}
668static WRITE8_HANDLER( yarunara_flipscreen_inv_w )
669{
670   dynax_flipscreen_w(space,0,(data&2)?0:1);
671}
668672
669673static WRITE8_HANDLER( yarunara_blit_romregion_w )
670674{
r4135r4136
14141418   AM_RANGE( 0x10050, 0x10050 ) AM_WRITE( tenkai_priority_w      )   // layer priority and enable
14151419   AM_RANGE( 0x10054, 0x10054 ) AM_WRITE( dynax_blit_backpen_w      )   // Background Color
14161420   AM_RANGE( 0x10058, 0x10058 ) AM_WRITE( tenkai_blit_romregion_w   )   // Blitter ROM bank
1417   AM_RANGE( 0x10060, 0x10060 ) AM_WRITE( yarunara_flipscreen_w   )   // Flip Screen
1421   AM_RANGE( 0x10060, 0x10060 ) AM_WRITE( yarunara_flipscreen_inv_w)   // Flip Screen
14181422   AM_RANGE( 0x10064, 0x10064 ) AM_WRITE( yarunara_layer_half_w   )   // half of the interleaved layer to write to
14191423   AM_RANGE( 0x10068, 0x10068 ) AM_WRITE( yarunara_layer_half2_w   )   //
14201424   AM_RANGE( 0x1006c, 0x1006c ) AM_WRITE( tenkai_6c_w            )   // ?
r4135r4136
41664170   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
41674171   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
41684172   MDRV_SCREEN_SIZE(512, 256)
4169   MDRV_SCREEN_VISIBLE_AREA(0, 512-1, 4, 255-8-4)
4173   MDRV_SCREEN_VISIBLE_AREA(4, 512-1, 4, 255-8-4)   // hide first 4 horizontal pixels (see scroll of gal 4 in test mode)
41704174
41714175   MDRV_PALETTE_LENGTH(16*256)
41724176
r4135r4136
56855689   // Note by Whistler:
56865690   // It appears that the first half of lzc-01.u6 in tenkaibb (as well as the same data in other bootleg versions)
56875691   // does not exist _anywhere_ in this rom dump, and in this way some girls won't show correctly (such as the 3rd one)
5688   ROM_REGION( 0x80000, "gfx1", 0 )   // blitter data
5689   ROM_LOAD( "taicom01.15b", 0x000000, 0x80000, CRC(39e4e6f3) SHA1(5b543a5933446091d7cfd519d5a6f23047d8a9f2) )
5692   ROM_REGION( 0x100000, "gfx1", 0 )   // blitter data
5693   ROM_LOAD( "tydg002.u8",   0x000000, 0x80000, NO_DUMP CRC(b0f08a20) SHA1(5f7083d5caadd77594eaf46efa11a8756cefcf7d) )
5694   ROM_LOAD( "taicom01.15b", 0x080000, 0x80000, CRC(39e4e6f3) SHA1(5b543a5933446091d7cfd519d5a6f23047d8a9f2) )   // either this was dumped half size, or the above rom was missing from the pcb
56905695
56915696   ROM_REGION( 0x100000, "gfx2", 0 )   // blitter data
56925697   ROM_LOAD( "taicom02.11b", 0x000000, 0x80000, CRC(aae8cfb7) SHA1(736c6148aa6e7b22ca19615a27e9a10d41778aa7) )
r4135r4136
57415746
57425747ROM_START( tenkai2b )
57435748   ROM_REGION( 0x50000, "main", 0 )
5749   ROM_LOAD( "mc0.u11",          0x00000, 0x40000, CRC(8488a3ab) SHA1(f367a2dcc65410929db595b3c442d310d50a4940) )
5750   ROM_RELOAD(                   0x10000, 0x40000 )
5751   // tenkai internal rom is incompatible with the code of this set
57445752   ROM_LOAD( "tmp91p640n-10.5b", 0x00000, 0x04000, NO_DUMP )
5745   ROM_LOAD( "mc0.u11",          0x10000, 0x40000, CRC(8488a3ab) SHA1(f367a2dcc65410929db595b3c442d310d50a4940) )
57465753
57475754   ROM_REGION( 0x100000, "gfx1", 0 )   // blitter data
57485755   ROM_LOAD( "mc1.u8",  0x000000, 0x100000, CRC(786698e3) SHA1(9ddf4e31f454fb3c7969b1433771e95a976de741) )
r4135r4136
58735880   ROM_REGION( 0x50000, "main", 0 )
58745881   ROM_LOAD( "rom.u15", 0x00000, 0x40000, CRC(7b877721) SHA1(41bba10ffb3d72af84d6577d4785225fe1ecc640) )
58755882   ROM_RELOAD(          0x10000, 0x40000 )
5883   // it doesn't need the internal rom from tenkai
58765884
58775885   ROM_REGION( 0x100000, "gfx1", 0 )   // blitter data
5878   ROM_LOAD( "rom.u13", 0x00000, 0x80000, CRC(68cb730a) SHA1(7ce90e34fa51d50a7668ac1c5ccbc18bebe8ad84) )
5879   ROM_LOAD( "rom.u12", 0x80000, 0x80000, CRC(39e4e6f3) SHA1(5b543a5933446091d7cfd519d5a6f23047d8a9f2) )
5886   ROM_LOAD( "tydg002.u8", 0x00000, 0x80000, NO_DUMP CRC(b0f08a20) SHA1(5f7083d5caadd77594eaf46efa11a8756cefcf7d) )
5887   ROM_LOAD( "rom.u12",    0x80000, 0x80000, CRC(39e4e6f3) SHA1(5b543a5933446091d7cfd519d5a6f23047d8a9f2) )
58805888
5881   ROM_REGION( 0x100000, "gfx2", ROMREGION_ERASEFF )   // blitter data
5882
5883   ROM_LOAD( "rom.u13", 0x80000, 0x80000, CRC(68cb730a) SHA1(7ce90e34fa51d50a7668ac1c5ccbc18bebe8ad84) )//ok
5889   ROM_REGION( 0x100000, "gfx2", 0 )   // blitter data
5890   ROM_LOAD( "taicom02.11b", 0x00000, 0x80000, NO_DUMP CRC(aae8cfb7) SHA1(736c6148aa6e7b22ca19615a27e9a10d41778aa7) )
5891   ROM_LOAD( "rom.u13",      0x80000, 0x80000, CRC(68cb730a) SHA1(7ce90e34fa51d50a7668ac1c5ccbc18bebe8ad84) )
58845892ROM_END
58855893
58865894/***************************************************************************
r4135r4136
59515959***************************************************************************/
59525960
59535961ROM_START( tenkaid )
5954   ROM_REGION( 0x50000, "main", 0 )
5962   ROM_REGION( 0x90000, "main", 0 )
5963   ROM_LOAD( "tydg001.u11",      0x00000, 0x40000, CRC(4ffa543c) SHA1(ab6ec7bd735358643f5186c6c983fa8b599fe84b) )
5964   ROM_RELOAD(                   0x10000, 0x40000 )
5965   ROM_RELOAD(                   0x50000, 0x40000 )
5966   // tenkai internal rom is incompatible with the code of this set
59555967   ROM_LOAD( "tmp91p640n-10.5b", 0x00000, 0x04000, NO_DUMP )
5956   ROM_LOAD( "tydg001.u11",      0x10000, 0x40000, CRC(4ffa543c) SHA1(ab6ec7bd735358643f5186c6c983fa8b599fe84b) )
59575968
5958   ROM_REGION( 0x200000, "gfx1", 0 )   // blitter data
5959   ROM_LOAD( "tydg002.u8",  0x000000, 0x80000, CRC(b0f08a20) SHA1(5f7083d5caadd77594eaf46efa11a8756cefcf7d) )
5960   ROM_LOAD( "tydg005.u19", 0x080000, 0x80000, CRC(39e4e6f3) SHA1(5b543a5933446091d7cfd519d5a6f23047d8a9f2) )
5961   ROM_LOAD( "tydg003.u6",  0x100000, 0x80000, CRC(60717d91) SHA1(85dbb510d33b36d2255b740ccc4917216dd21497) )
5962   ROM_LOAD( "tydg004.u21", 0x180000, 0x80000, CRC(b7d49d04) SHA1(756c35bbe207b5bfc6e05d6da99a7ad5a3453506) )
5969   ROM_REGION( 0x100000, "gfx1", 0 )   // blitter data
5970   ROM_LOAD( "tydg002.u8",  0x00000, 0x80000, CRC(b0f08a20) SHA1(5f7083d5caadd77594eaf46efa11a8756cefcf7d) )
5971   ROM_LOAD( "tydg003.u6",  0x80000, 0x80000, CRC(60717d91) SHA1(85dbb510d33b36d2255b740ccc4917216dd21497) )
5972
5973   ROM_REGION( 0x100000, "gfx2", 0 )   // blitter data
5974   ROM_LOAD( "tydg004.u21", 0x00000, 0x80000, CRC(b7d49d04) SHA1(756c35bbe207b5bfc6e05d6da99a7ad5a3453506) )
5975   ROM_LOAD( "tydg005.u19", 0x80000, 0x80000, CRC(39e4e6f3) SHA1(5b543a5933446091d7cfd519d5a6f23047d8a9f2) )
59635976ROM_END
59645977
59655978/***************************************************************************
r4135r4136
59795992
59805993ROM_START( tenkaie )
59815994   ROM_REGION( 0x50000, "main", 0 )
5982   ROM_LOAD( "tmp91p640n-10.5b", 0x00000, 0x04000, NO_DUMP )
5983   ROM_LOAD( "epr-a01.rom",      0x10000, 0x40000, CRC(a35e54db) SHA1(247c856e19989fb834e8ed135393927bbd9c0277) )
5995   ROM_LOAD( "epr-a01.rom",      0x00000, 0x40000, CRC(a35e54db) SHA1(247c856e19989fb834e8ed135393927bbd9c0277) )
5996   ROM_RELOAD(                   0x10000, 0x40000 )
5997   ROM_LOAD( "tmp91p640n-10.5b", 0x00000, 0x04000, NO_DUMP CRC(509f1c97) SHA1(08557bea2e924053fd5bc9de5e306f3ecf8e98e6) )
59845998
59855999   ROM_REGION( 0x100000, "gfx1", 0 )   // blitter data
59866000   ROM_LOAD( "lzc-01.rom", 0x000000, 0x100000, CRC(786698e3) SHA1(9ddf4e31f454fb3c7969b1433771e95a976de741) )
r4135r4136
59896003   ROM_LOAD( "lzc-02.rom", 0x000000, 0x100000, CRC(90a19443) SHA1(8f593c00e39dd5acc76b058591019d117967a17b) )
59906004ROM_END
59916005
6006
59926007/***************************************************************************
59936008
59946009Mahjong Comic Gekijou Vol.1
r4135r4136
62426257GAME( 1990, neruton,  0,        neruton,  neruton,  mjelct3,  ROT180, "Dynax / Yukiyoshi Tokoro", "Mahjong Neruton Haikujiradan (Japan)",                         GAME_IMPERFECT_GRAPHICS )
62436258GAME( 1991, hanayara, 0,        yarunara, hanayara, 0,        ROT180, "Dynax",                    "Hana wo Yaraneba! (Japan)",                                    0 )
62446259GAME( 1991, mjcomv1,  0,        yarunara, yarunara, 0,        ROT180, "Dynax",                    "Mahjong Comic Gekijou Vol.1 (Japan)",                          0 )
6245GAME( 1991, tenkai,   0,        tenkai,   tenkai,   0,        ROT180, "Dynax",                    "Mahjong Tenkaigen",                                            GAME_NOT_WORKING )
6246GAME( 1991, tenkai2b, tenkai,   tenkai,   tenkai,   0,        ROT180, "Dynax",                    "Mahjong Tenkaigen Part 2 (bootleg)",                           GAME_NOT_WORKING )
6247GAME( 1991, tenkaibb, tenkai,   tenkai,   tenkai,   0,        ROT180, "Dynax",                    "Mahjong Tenkaigen (bootleg b)",                                0 )
6248GAME( 1991, tenkaicb, tenkai,   tenkai,   tenkai,   0,        ROT180, "Dynax",                    "Mahjong Tenkaigen (bootleg c)",                                GAME_NOT_WORKING )
6249GAME( 1991, tenkaid,  tenkai,   tenkai,   tenkai,   0,        ROT180, "Dynax",                    "Mahjong Tenkaigen (set 1)",                                    GAME_NOT_WORKING )
6250GAME( 1991, tenkaie,  tenkai,   tenkai,   tenkai,   0,        ROT180, "Dynax",                    "Mahjong Tenkaigen (set 2)",                                    GAME_NOT_WORKING )
6260GAME( 1991, tenkai,   0,        tenkai,   tenkai,   0,        ROT0,   "Dynax",                    "Mahjong Tenkaigen",                                            0 )
6261GAME( 1991, tenkai2b, tenkai,   tenkai,   tenkai,   0,        ROT0,   "Dynax",                    "Mahjong Tenkaigen Part 2 (bootleg)",                           GAME_NOT_WORKING )
6262GAME( 1991, tenkaibb, tenkai,   tenkai,   tenkai,   0,        ROT0,   "Dynax",                    "Mahjong Tenkaigen (bootleg b)",                                0 )
6263GAME( 1991, tenkaicb, tenkai,   tenkai,   tenkai,   0,        ROT0,   "Dynax",                    "Mahjong Tenkaigen (bootleg c)",                                0 )
6264GAME( 1991, tenkaid,  tenkai,   tenkai,   tenkai,   0,        ROT0,   "Dynax",                    "Mahjong Tenkaigen (set 1)",                                    GAME_NOT_WORKING )
6265GAME( 1991, tenkaie,  tenkai,   tenkai,   tenkai,   0,        ROT0,   "Dynax",                    "Mahjong Tenkaigen (set 2)",                                    0 )
62516266GAME( 1992, htengoku, 0,        htengoku, htengoku, 0,        ROT180, "Dynax",                    "Hanafuda Hana Tengoku (Japan)",                                0 )
62526267GAME( 1994, mjreach,  0,        tenkai,   mjreach,  mjreach,  ROT0,   "Dynax",                    "Mahjong Reach (bootleg)",                                      0 )
62536268GAME( 1995, shpeng,   0,        sprtmtch, sprtmtch, 0,        ROT0,   "WSAC Systems?",            "Sea Hunter Penguin",                                           GAME_WRONG_COLORS ) // not a dynax board. proms?
src/mame/drivers/zn.c
r4135r4136
19551955            case 0x7f:      // first drive check
19561956            case 0x1c:      // second drive check (causes HDD detected)
19571957               return 1;   // return error
1958               break;
19591958         }
19601959
19611960         return 4;         // return OK
1962         break;
19631961   }
19641962
19651963   return 0;
src/mame/drivers/galpani3.c
r4135r4136
121121}
122122
123123
124extern int suprnova_alt_enable_sprites;
125
126124static VIDEO_START(galpani3)
127125{
128126   /* so we can use suprnova.c */
r4135r4136
535533
536534// might be blitter regs? - there are 3, probably GRAP2 chips
537535
538READ16_HANDLER( galpani3_regs1_r )
536static READ16_HANDLER( galpani3_regs1_r )
539537{
540538   switch (offset)
541539   {
r4135r4136
560558}
561559
562560
563READ16_HANDLER( galpani3_regs2_r )
561static READ16_HANDLER( galpani3_regs2_r )
564562{
565563   switch (offset)
566564   {
r4135r4136
585583}
586584
587585
588READ16_HANDLER( galpani3_regs3_r )
586static READ16_HANDLER( galpani3_regs3_r )
589587{
590588   switch (offset)
591589   {
r4135r4136
610608}
611609
612610
613UINT16 galpani3_regs1_address_regs[0x20];
614UINT16 galpani3_regs2_address_regs[0x20];
615UINT16 galpani3_regs3_address_regs[0x20];
611static UINT16 galpani3_regs1_address_regs[0x20];
612static UINT16 galpani3_regs2_address_regs[0x20];
613static UINT16 galpani3_regs3_address_regs[0x20];
616614
617void gp3_do_rle(UINT32 address, UINT16*framebuffer, UINT8* rledata)
615static void gp3_do_rle(UINT32 address, UINT16*framebuffer, UINT8* rledata)
618616{
619617   int rle_count = 0;
620618   int normal_count = 0;
r4135r4136
664662
665663}
666664
667WRITE16_HANDLER( galpani3_regs1_address_w )
665static WRITE16_HANDLER( galpani3_regs1_address_w )
668666{
669667   logerror("galpani3_regs1_address_w %04x\n",data);
670668   COMBINE_DATA(&galpani3_regs1_address_regs[offset]);
671669}
672670
673WRITE16_HANDLER( galpani3_regs1_go_w )
671static WRITE16_HANDLER( galpani3_regs1_go_w )
674672{
675673   UINT32 address = galpani3_regs1_address_regs[1]| (galpani3_regs1_address_regs[0]<<16);
676674   UINT8* rledata = memory_region(space->machine,"gfx2");
r4135r4136
680678}
681679
682680
683WRITE16_HANDLER( galpani3_regs2_address_w )
681static WRITE16_HANDLER( galpani3_regs2_address_w )
684682{
685683   logerror("galpani3_regs2_address_w %04x\n",data);
686684   COMBINE_DATA(&galpani3_regs2_address_regs[offset]);
687685}
688686
689WRITE16_HANDLER( galpani3_regs2_go_w )
687static WRITE16_HANDLER( galpani3_regs2_go_w )
690688{
691689   UINT32 address = galpani3_regs2_address_regs[1]| (galpani3_regs2_address_regs[0]<<16);
692690   UINT8* rledata = memory_region(space->machine,"gfx2");
r4135r4136
700698
701699
702700
703WRITE16_HANDLER( galpani3_regs3_address_w )
701static WRITE16_HANDLER( galpani3_regs3_address_w )
704702{
705703   logerror("galpani3_regs3_address_w %04x\n",data);
706704   COMBINE_DATA(&galpani3_regs3_address_regs[offset]);
707705}
708706
709WRITE16_HANDLER( galpani3_regs3_go_w )
707static WRITE16_HANDLER( galpani3_regs3_go_w )
710708{
711709   UINT32 address =  galpani3_regs3_address_regs[1]| (galpani3_regs3_address_regs[0]<<16);
712710   UINT8* rledata = memory_region(space->machine,"gfx2");
src/mame/drivers/megadriv.h
r4135r4136
1515MACHINE_DRIVER_EXTERN(megadpal);
1616MACHINE_DRIVER_EXTERN(megdsvp);
1717MACHINE_DRIVER_EXTERN( genesis_32x );
18MACHINE_DRIVER_EXTERN( genesis_32x_pal );
1819MACHINE_DRIVER_EXTERN( genesis_scd );
1920MACHINE_DRIVER_EXTERN( genesis_32x_scd );
2021
src/mame/drivers/brasil.c
r4135r4136
2424#include "driver.h"
2525#include "cpu/nec/nec.h"
2626#include "cpu/i86/i86.h"
27#include "sound/okim6376.h"
2728#include "fashion.lh"
2829
2930static UINT16 *blit_ram;
3031
31VIDEO_START(brasil)
32static VIDEO_START(brasil)
3233{
3334
3435}
3536
36VIDEO_UPDATE(brasil)
37static VIDEO_UPDATE(brasil)
3738{
3839   int x,y,count;
3940
r4135r4136
6364   return 0;
6465}
6566
66VIDEO_UPDATE(vidpokr2)
67static VIDEO_UPDATE(vidpokr2)
6768{
6869   int x,y,count;
6970
r4135r4136
275276
276277static WRITE16_HANDLER( write3_w )
277278{
278   t3 = data;
279   if (t3 != data) {
280      t3 = data;
281      okim6376_data_0_lsb_w(space, 0, t3, mem_mask);
282      okim6376_data_0_lsb_w(space, 0, (1 << 4), mem_mask);
283   }
279284//  popmessage("%04x %04x",t1,t3);
280285}
281286
r4135r4136
588593   MDRV_VIDEO_START(brasil)
589594   MDRV_VIDEO_UPDATE(brasil)
590595
596   /* sound hardware */
597   MDRV_SPEAKER_STANDARD_MONO("mono")
598
591599   //OkiM6376
600   MDRV_SOUND_ADD("samples", OKIM6376, XTAL_12MHz/2/2)
601   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
602
592603MACHINE_DRIVER_END
593604
594605
r4135r4136
610621   MDRV_VIDEO_START(brasil)
611622   MDRV_VIDEO_UPDATE(vidpokr2)
612623
624   /* sound hardware */
625   MDRV_SPEAKER_STANDARD_MONO("mono")
626
613627   //OkiM6376
628   MDRV_SOUND_ADD("samples", OKIM6376, XTAL_12MHz/2/2)
629   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
630
614631MACHINE_DRIVER_END
615632
616633/*
r4135r4136
650667   ROM_COPY( "user1", 0x0c0000, 0x000000, 0x40000 )
651668
652669   ROM_REGION( 0x080000, "samples", 0 ) /* M6376 Samples */
653   ROM_LOAD( "mc33.ic5", 0x00000, 0x80000, CRC(83a855ab) SHA1(7f9384c875b951d17caa91f8a7365edaf7f9afe1) )
670   ROM_LOAD( "mc31.ic15", 0x00000, 0x40000, CRC(8b72ffec) SHA1(fca5cf2594325e0c9fe446ddf2330c669f7f37a9) )
654671ROM_END
655672
656673/*
r4135r4136
709726   memory_install_write16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_IO), 0x0002, 0x0003, 0, 0, fashion_write2_w );
710727}
711728
712GAMEL( 19??, newmcard,  0,      vidpokr2,    brasil,   0,       ROT0,  "New High Video?", "New Magic Card",         GAME_NO_SOUND,                           layout_fashion )
713GAMEL( 2000, brasil,    0,      brasil,      brasil,   0,       ROT0,  "New High Video?", "Bra$il (Version 3)",     GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND, layout_fashion )
714GAMEL( 2000, fashion,   brasil, brasil,      fashion,  fashion, ROT0,  "New High Video?", "Fashion (Version 2.14)", GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND, layout_fashion )
729GAMEL( 19??, newmcard,  0,      vidpokr2,    brasil,   0,       ROT0,  "New High Video?", "New Magic Card",         0,                           layout_fashion )
730GAMEL( 2000, brasil,    0,      brasil,      brasil,   0,       ROT0,  "New High Video?", "Bra$il (Version 3)",     GAME_IMPERFECT_GRAPHICS, layout_fashion )
731GAMEL( 2000, fashion,   brasil, brasil,      fashion,  fashion, ROT0,  "New High Video?", "Fashion (Version 2.14)", GAME_IMPERFECT_GRAPHICS, layout_fashion )
src/mame/drivers/deco32.c
r4135r4136
410410{
411411   /* Ports 0-3 are read, but seem unused */
412412   switch (dragngun_lightgun_port) {
413   case 4: return input_port_read(space->machine, "LIGHT0_X"); break;
414   case 5: return input_port_read(space->machine, "LIGHT1_X"); break;
415   case 6: return input_port_read(space->machine, "LIGHT0_Y"); break;
416   case 7: return input_port_read(space->machine, "LIGHT1_Y"); break;
413   case 4: return input_port_read(space->machine, "LIGHT0_X");
414   case 5: return input_port_read(space->machine, "LIGHT1_X");
415   case 6: return input_port_read(space->machine, "LIGHT0_Y");
416   case 7: return input_port_read(space->machine, "LIGHT1_Y");
417417   }
418418
419419//  logerror("Illegal lightgun port %d read \n",dragngun_lightgun_port);
src/mame/drivers/goodejan.c
r4135r4136
88
99
1010ToDo:
11 BG Banking is wrong.
1211 Inputs are imperfect (missing dips)
13 Sprite glitches in intro
12 Some sprite flickers on attract mode
13 totmejan: Are the "dots" behind the girls in attract mode correct?
1414
15
1615PCB Layout
1716
1817|---------------------------------------------------------------|
r4135r4136
6968WRITE16_HANDLER( goodejan_bg_scrollx_w );
7069WRITE16_HANDLER( goodejan_bg_scrolly_w );
7170WRITE16_HANDLER( goodejan_layer_en_w );
71WRITE16_HANDLER( goodejan_gfxbank_w );
7272
7373VIDEO_START( goodejan );
7474VIDEO_UPDATE( goodejan );
r4135r4136
106106ADDRESS_MAP_END
107107
108108/*totmejan CRT is at 8000-804f,goodejan is at 8040-807f(808f but not tested)*/
109static ADDRESS_MAP_START( goodejan_io_map, ADDRESS_SPACE_IO, 16 )
110   AM_RANGE(0x801c, 0x801d) AM_WRITE(goodejan_layer_en_w )
111
112   AM_RANGE(0x805c, 0x805d) AM_WRITE(goodejan_layer_en_w )
113   AM_RANGE(0x8060, 0x8061) AM_WRITE(goodejan_bg_scrollx_w )
114   AM_RANGE(0x8062, 0x8063) AM_WRITE(goodejan_bg_scrolly_w )
115
109static ADDRESS_MAP_START( common_io_map, ADDRESS_SPACE_IO, 16 )
110   AM_RANGE(0x9000, 0x9001) AM_WRITE(goodejan_gfxbank_w)
111   AM_RANGE(0x8020, 0x8023) AM_WRITENOP
112   AM_RANGE(0xb000, 0xb003) AM_WRITENOP
116113   AM_RANGE(0xb004, 0xb005) AM_WRITE(mahjong_panel_w)
117114
118115   AM_RANGE(0xc000, 0xc001) AM_READ_PORT("DSW1")
119116   AM_RANGE(0xc002, 0xc003) AM_READ(mahjong_panel_r)
120117   AM_RANGE(0xc004, 0xc005) AM_READ_PORT("DSW2") // maybe it's a seibu_main_word mirror?
121//  AM_RANGE(0xc004, 0xc005) AM_READ(random_reading)
122
123118   AM_RANGE(0xd000, 0xd00f) AM_READWRITE(seibu_main_word_r, seibu_main_word_w)
124119ADDRESS_MAP_END
125120
121static ADDRESS_MAP_START( totmejan_io_map, ADDRESS_SPACE_IO, 16 )
122   AM_RANGE(0x801c, 0x801d) AM_WRITE(goodejan_layer_en_w )
123ADDRESS_MAP_END
124
125static ADDRESS_MAP_START( goodejan_io_map, ADDRESS_SPACE_IO, 16 )
126   AM_RANGE(0x805c, 0x805d) AM_WRITE(goodejan_layer_en_w )
127   AM_RANGE(0x8060, 0x8061) AM_WRITE(goodejan_bg_scrollx_w )
128   AM_RANGE(0x8062, 0x8063) AM_WRITE(goodejan_bg_scrolly_w )
129ADDRESS_MAP_END
130
126131static INPUT_PORTS_START( goodejan )
127132   SEIBU_COIN_INPUTS   /* coin inputs read through sound cpu */
128133
r4135r4136
326331   /* basic machine hardware */
327332   MDRV_CPU_ADD("main", V30, GOODEJAN_MHZ2/2)
328333   MDRV_CPU_PROGRAM_MAP(goodejan_map,0)
329   MDRV_CPU_IO_MAP(goodejan_io_map,0)
334   MDRV_CPU_IO_MAP(common_io_map,goodejan_io_map)
330335   MDRV_CPU_VBLANK_INT_HACK(goodejan_interrupt,2)
331336
332337   SEIBU_SOUND_SYSTEM_CPU(GOODEJAN_MHZ1/2)
r4135r4136
351356   SEIBU_SOUND_SYSTEM_YM3812_INTERFACE(GOODEJAN_MHZ1/2,GOODEJAN_MHZ2/16)
352357MACHINE_DRIVER_END
353358
359static MACHINE_DRIVER_START( totmejan )
360   MDRV_IMPORT_FROM( goodejan )
361   MDRV_CPU_MODIFY("main")
362   MDRV_CPU_IO_MAP(common_io_map,totmejan_io_map)
363MACHINE_DRIVER_END
364
354365ROM_START( totmejan )
355366   ROM_REGION( 0x100000, "main", 0 ) /* V30 code */
356367   ROM_LOAD16_BYTE( "1.022",  0xc0000, 0x20000, CRC(63c3c54f) SHA1(3116b73b848a1f7391a47b994951ba1af92ba298) )
r4135r4136
393404   ROM_LOAD16_BYTE( "4.061",  0x00001, 0x10000, CRC(5bdf7225) SHA1(a8eded9dc5be1db20cddbed1ae8c22de1674de2a) )
394405
395406   ROM_REGION( 0x100000, "gfx2", ROMREGION_DISPOSE )
396   ROM_LOAD( "e_jan2scr.064", 0x080000, 0x080000, CRC(71654822) SHA1(fe2a128413999085e321e455aeebda0360d38cb8) )
397   ROM_CONTINUE(             0x000000, 0x080000 )
407   ROM_LOAD( "e_jan2scr.064", 0x000000, 0x100000, CRC(71654822) SHA1(fe2a128413999085e321e455aeebda0360d38cb8) )
398408
399409   ROM_REGION( 0x080000, "gfx3", ROMREGION_DISPOSE )
400410   ROM_LOAD( "e_jan2obj.078", 0x000000, 0x080000, CRC(0f892ef2) SHA1(188ae43db1c48fb6870aa45c64718e901831499b) )
r4135r4136
421431   ROM_LOAD16_BYTE( "4.061",  0x00001, 0x10000, CRC(5bdf7225) SHA1(a8eded9dc5be1db20cddbed1ae8c22de1674de2a) )
422432
423433   ROM_REGION( 0x100000, "gfx2", ROMREGION_DISPOSE )
424   ROM_LOAD( "e_jan2scr.064", 0x080000, 0x080000, CRC(71654822) SHA1(fe2a128413999085e321e455aeebda0360d38cb8) )
425   ROM_CONTINUE(             0x000000, 0x080000 )
434   ROM_LOAD( "e_jan2scr.064", 0x000000, 0x100000, CRC(71654822) SHA1(fe2a128413999085e321e455aeebda0360d38cb8) )
426435
427436   ROM_REGION( 0x080000, "gfx3", ROMREGION_DISPOSE )
428437   ROM_LOAD( "e_jan2obj.078", 0x000000, 0x080000, CRC(0f892ef2) SHA1(188ae43db1c48fb6870aa45c64718e901831499b) )
r4135r4136
434443   ROM_LOAD( "fmj08.083", 0x000, 0x100, CRC(9657b7ad) SHA1(e9b469c2b3534593f7fe0ea19cbbf93b55957e42) )
435444ROM_END
436445
437GAME( 1991, totmejan, 0,        goodejan, goodejan, 0, ROT0, "Seibu (distributed by Tecmo)", "Tottemo E Jong", GAME_IMPERFECT_GRAPHICS )
446GAME( 1991, totmejan, 0,        totmejan, goodejan, 0, ROT0, "Seibu (distributed by Tecmo)", "Tottemo E Jong", GAME_IMPERFECT_GRAPHICS )
438447GAME( 1991, goodejan, 0,        goodejan, goodejan, 0, ROT0, "Seibu (distributed by Tecmo)", "Good E Jong -Kachinuki Mahjong Syoukin Oh!!- (set 1)", GAME_IMPERFECT_GRAPHICS )
439448GAME( 1991, goodejaa, goodejan, goodejan, goodejan, 0, ROT0, "Seibu (distributed by Tecmo)", "Good E Jong -Kachinuki Mahjong Syoukin Oh!!- (set 2)", GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/aleck64.c
r4135r4136
166166*/
167167
168168#include "driver.h"
169#include "streams.h"
169170#include "cpu/rsp/rsp.h"
170171#include "cpu/mips/mips3.h"
171#include "streams.h"
172172#include "sound/custom.h"
173#include "sound/dmadac.h"
173174#include "includes/n64.h"
174175
175176static READ32_HANDLER( aleck_dips_r )
src/mame/drivers/fastfred.c
r4135r4136
118118static UINT16 imago_sprites_address;
119119static UINT8 imago_sprites_bank = 0;
120120
121static MACHINE_START( imago )
122{
123   gfx_element_set_source(machine->gfx[1], imago_sprites);
124}
125
121126static WRITE8_HANDLER( imago_dma_irq_w )
122127{
123128   cpu_set_input_line(space->machine->cpu[0], 0, data & 1 ? ASSERT_LINE : CLEAR_LINE);
r4135r4136
142147   sprites_data = rom[imago_sprites_address + 0x2000*2 + imago_sprites_bank * 0x1000];
143148   imago_sprites[offset + 0x800*2] = sprites_data;
144149
145   decodechar(space->machine->gfx[1], offset/32, imago_sprites);
150   gfx_element_mark_dirty(space->machine->gfx[1], offset/32);
146151}
147152
148153static READ8_HANDLER( imago_sprites_offset_r )
r4135r4136
666671   MDRV_CPU_MODIFY("main")
667672   MDRV_CPU_PROGRAM_MAP(imago_map,0)
668673
674   MDRV_MACHINE_START(imago)
675
669676   /* video hardware */
670677   MDRV_PALETTE_LENGTH(256+64+2) /* 256 for characters, 64 for the stars and 2 for the web */
671678   MDRV_GFXDECODE(imago)
src/mame/drivers/punchout.c
r4135r4136
180180            return memory_read_byte(space, 0xd7c1);
181181
182182         return prot_mem[offset];
183      break;
184183
185184      case 0x01:
186185         if ( prot_mode_sel == 0x08 ) /* PC = 0x0b6a */
r4135r4136
236235         return 0x00;
237236      case 0x0d:
238237         return prot_mode_sel;
239      break;
240238   }
241239
242240   logerror("Read from unknown protection? port %02x ( selector = %02x )\n", offset, prot_mode_sel );
r4135r4136
260258
261259         prot_mem[offset] = data;
262260         return;
263      break;
264261
265262      case 0x02:
266263         if ( prot_mode_sel == 0x09 ) { /* PC = 0x20f7, 0x22d7 */
r4135r4136
294291      case 0x0d: /* PC = all over the code */
295292         prot_mode_sel = data;
296293         return;
294
297295      case 0x0f:
298296         prot_mem[offset] = data;
299297         return;
src/mame/drivers/cowrace.c
r4135r4136
7575{
7676   switch( cowrace_38c2 )
7777   {
78      case 0x02:   return 0x03;   break;
79      case 0x04:   return 0x00;   break;
78      case 0x02:   return 0x03;
79      case 0x04:   return 0x00;
8080   }
8181
8282   return 0xff;
src/mame/drivers/mil4000.c
r4135r4136
133133         0);
134134}
135135
136VIDEO_START(mil4000)
136static VIDEO_START(mil4000)
137137{
138138   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
139139   int i;
r4135r4136
152152   tilemap_set_transparent_pen(sc3_tilemap,0);
153153}
154154
155VIDEO_UPDATE(mil4000)
155static VIDEO_UPDATE(mil4000)
156156{
157157   tilemap_draw(bitmap,cliprect,sc0_tilemap,0,0);
158158   tilemap_draw(bitmap,cliprect,sc1_tilemap,0,0);
src/mame/drivers/gticlub.c
r4135r4136
236236UINT8 gticlub_led_reg1;
237237
238238int K001604_vh_start(running_machine *machine, int chip);
239void K001604_tile_update(running_machine *machine, int chip);
240239void K001604_draw_front_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
241240void K001604_draw_back_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
242241READ32_HANDLER(K001604_tile_r);
r4135r4136
280279   {
281280      const device_config *voodoo = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo0");
282281
283      K001604_tile_update(screen->machine, 0);
284282   //  K001604_draw_back_layer(bitmap, cliprect);
285283
286284      voodoo_update(voodoo, bitmap, cliprect);
r4135r4136
291289   {
292290      const device_config *voodoo = device_list_find_by_tag(screen->machine->config->devicelist, VOODOO_GRAPHICS, "voodoo1");
293291
294      K001604_tile_update(screen->machine, 1);
295292   //  K001604_draw_back_layer(bitmap, cliprect);
296293
297294      voodoo_update(voodoo, bitmap, cliprect);
src/mame/drivers/ilpag.c
r4135r4136
4949static UINT16 *blit_romaddr,*blit_attr1_ram,*blit_dst_ram_loword,*blit_attr2_ram,*blit_dst_ram_hiword;
5050static UINT8 *blit_buffer;
5151
52VIDEO_START(ilpag)
52static VIDEO_START(ilpag)
5353{
5454   blit_buffer = auto_malloc(512*512*4); //just to be sure,number is wrong
5555}
5656
57VIDEO_UPDATE(ilpag)
57static VIDEO_UPDATE(ilpag)
5858{
5959   int x,y;
6060//  static int counter = 0;
src/mame/drivers/namcona1.c
r4135r4136
885885   {
886886      case 0x40:
887887         return input_port_read(space->machine, "P1");
888         break;
889888
890889        case 0x60:
891890         return input_port_read(space->machine, "P2");
892         break;
893891
894892      case 0x20:
895893         return input_port_read(space->machine, "DSW");
896         break;
897894
898895      case 0x00:
899896         return input_port_read(space->machine, "P4");
900         break;
901897   }
902898
903899   return 0xff;
src/mame/drivers/acefruit.c
r4135r4136
9090
9191            for( x = 0; x < 16; x++ )
9292            {
93               int sprite = ( spriteram[ ( spriteindex / 64 ) % 6 ] & 0xf ) ^ 0xf;
94               const UINT8 *gfxdata = gfx_element_get_data(gfx, sprite);
95
9396               for( y = 0; y < 8; y++ )
9497               {
9598                  UINT16 *dst = BITMAP_ADDR16( bitmap, y + ( row * 8 ), x + ( col * 16 ) );
96                  int sprite = ( spriteram[ ( spriteindex / 64 ) % 6 ] & 0xf ) ^ 0xf;
97                  *( dst ) = *( gfx->gfxdata + ( sprite * gfx->char_modulo ) + ( ( spriterow + y ) * gfx->line_modulo ) + ( ( spriteindex % 64 ) >> 1 ) );
99                  *( dst ) = *( gfxdata + ( ( spriterow + y ) * gfx->line_modulo ) + ( ( spriteindex % 64 ) >> 1 ) );
98100               }
99101
100102               spriteindex += spritesize;
r4135r4136
683685   ROM_LOAD( "16-1-101.b11", 0x0200, 0x0100, NO_DUMP )
684686ROM_END
685687
688/* no information about this one */
689ROM_START( acefruit  )
690   ROM_REGION( 0x10000, "main", 0 )
691   ROM_LOAD( "vp-h9.bin",    0x00e000, 0x0800, CRC(f595daf7) SHA1(be5abd34fd06f73cd80f5b15902d158e33705c8f) )
692   ROM_CONTINUE(             0x000000, 0x0800 )
693   ROM_LOAD( "vp-h10.bin",   0x00e800, 0x0800, CRC(b0539100) SHA1(763f31f72f55c3322b24e127b37130d37daa5216) )
694   ROM_CONTINUE(             0x000800, 0x0800 )
695   ROM_LOAD( "vp-h11.bin",   0x00f000, 0x0800, CRC(fa176072) SHA1(18203278bb9c505f07390f7b95ecf9ab6d7b7122) )
696   ROM_CONTINUE(             0x001000, 0x0800 )
697
698   ROM_REGION( 0x2000, "gfx1", ROMREGION_DISPOSE ) /* 8k for graphics */
699   ROM_LOAD( "vp-h5.bin",         0x000000, 0x000800, CRC(dfffe063) SHA1(1b860323fe93b7d010fa35167769555a6bd4a49c) )
700   ROM_LOAD( "vp-h6.bin",         0x000800, 0x000800, CRC(355203b8) SHA1(959f3599a24293f392e8b10061c39d3244f34c05) )
701   ROM_LOAD( "vp-h7.bin",         0x001000, 0x000800, CRC(7784de8a) SHA1(40851724c9b7ef26964462b5e97ad943df4d56e2) )
702   ROM_LOAD( "vp-h8.bin",         0x001800, 0x000800, CRC(d587e541) SHA1(902b6c4673b8b989d034d60d3c47f2499f100ba2) )
703
704   /* there were no proms in the set */
705   ROM_REGION( 0x300, "proms", 0 )
706   ROM_LOAD( "16-1-101.b9",  0x0000, 0x0100, NO_DUMP )
707   ROM_LOAD( "16-1-101.b10", 0x0100, 0x0100, NO_DUMP )
708   ROM_LOAD( "16-1-101.b11", 0x0200, 0x0100, NO_DUMP )
709ROM_END
710
711
686712GAMEL( 1981?, sidewndr, 0,        acefruit, sidewndr, sidewndr, ROT270, "ACE", "Sidewinder", GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND, layout_sidewndr )
687713GAMEL( 1981?, spellbnd, sidewndr, acefruit, spellbnd, 0,        ROT270, "ACE", "Spellbound", GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND, layout_sidewndr )
688714GAME ( 1982?, starspnr, 0,        acefruit, starspnr, 0,        ROT270, "ACE", "Starspinner (Dutch/Nederlands)", GAME_NOT_WORKING | GAME_NO_SOUND )
715// inputs need fixing on this one, no idea what it's called either
716GAME ( 1982?, acefruit, 0,        acefruit, spellbnd, 0,        ROT270, "ACE", "Unknown ACE Fruits Game", GAME_NOT_WORKING | GAME_NO_SOUND )
src/mame/drivers/appoooh.c
r4135r4136
5454#include "sound/msm5205.h"
5555#include "sound/sn76496.h"
5656
57static UINT8 *adpcmptr = 0;
58static int appoooh_adpcm_data;
57static UINT32 appoooh_adpcm_data;
58static UINT32 appoooh_adpcm_address = 0xffffffff;
5959
6060static void appoooh_adpcm_int(const device_config *device)
6161{
62   if( adpcmptr )
62   if(appoooh_adpcm_address != 0xffffffff)
6363   {
64      if( appoooh_adpcm_data==-1)
64      if(appoooh_adpcm_data == 0xffffffff)
6565      {
66         appoooh_adpcm_data = *adpcmptr++;
67         msm5205_data_w(0,appoooh_adpcm_data >> 4);
68         if(appoooh_adpcm_data==0x70)
66            UINT8 *RAM = memory_region(device->machine, "adpcm");
67            appoooh_adpcm_data = RAM[appoooh_adpcm_address++];
68         msm5205_data_w(0, appoooh_adpcm_data >> 4);
69         if(appoooh_adpcm_data == 0x70)
6970         {
70            adpcmptr = 0;
71                appoooh_adpcm_address = 0xffffffff;
7172            msm5205_reset_w(0,1);
7273         }
73      }else{
74      }
75        else
76        {
7477         msm5205_data_w(0,appoooh_adpcm_data & 0x0f );
75         appoooh_adpcm_data =-1;
78         appoooh_adpcm_data = -1;
7679      }
7780   }
7881}
7982/* adpcm address write */
8083static WRITE8_HANDLER( appoooh_adpcm_w )
8184{
82   UINT8 *RAM = memory_region(space->machine, "adpcm");
83   adpcmptr  = &RAM[data*256];
85    appoooh_adpcm_address = data << 8;
8486   msm5205_reset_w(0,0);
85   appoooh_adpcm_data=-1;
87   appoooh_adpcm_data = 0xffffffff;
8688}
8789
8890
r4135r4136
211213
212214
213215
216static MACHINE_START( appoooh )
217{
218    state_save_register_global(machine, appoooh_adpcm_data);
219    state_save_register_global(machine, appoooh_adpcm_address);
220}
221
222
223
214224static MACHINE_DRIVER_START( appoooh )
215225
216226   /* basic machine hardware */
r4135r4136
219229   MDRV_CPU_IO_MAP(main_portmap,0)
220230   MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
221231
232    MDRV_MACHINE_START(appoooh)
233
222234   /* video hardware */
223235   MDRV_SCREEN_ADD("main", RASTER)
224236   MDRV_SCREEN_REFRESH_RATE(60)
r4135r4136
421433   MDRV_CPU_IO_MAP(main_portmap,0)
422434   MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
423435
436    MDRV_MACHINE_START(appoooh)
437
424438   /* video hardware */
425439   MDRV_SCREEN_ADD("main", RASTER)
426440   MDRV_SCREEN_REFRESH_RATE(60)
r4135r4136
560574}
561575
562576
563GAME( 1984, appoooh,  0,        appoooh,  appoooh,  0,        ROT0, "[Sanritsu] Sega", "Appoooh", 0 )
564GAME( 1986, robowres, 0,       robowres, robowres, robowres, ROT0, "Sega", "Robo Wres 2001", 0 )
565GAME( 1986, robowrb,  robowres, robowres, robowres, robowrb,  ROT0, "bootleg", "Robo Wres 2001 (bootleg)", 0 )
577GAME( 1984, appoooh,  0,        appoooh,  appoooh,  0,        ROT0, "[Sanritsu] Sega", "Appoooh", GAME_SUPPORTS_SAVE )
578GAME( 1986, robowres, 0,        robowres, robowres, robowres, ROT0, "Sega", "Robo Wres 2001", GAME_SUPPORTS_SAVE )
579GAME( 1986, robowrb,  robowres, robowres, robowres, robowrb,  ROT0, "bootleg", "Robo Wres 2001 (bootleg)", GAME_SUPPORTS_SAVE )
src/mame/drivers/kaneko16.c
r4135r4136
605605   {
606606      case 0x0000:   // 'Both Sides' = 270deg Wheel
607607         return   (input_port_read(space->machine, "WHEEL0"));
608         break;
609
610608      case 0x1000:   // '1P Side' = 360' Wheel
611609         return   (input_port_read(space->machine, "WHEEL1"));
612         break;
613610      default:
614611         return   (0);
615         break;
616      }
612   }
617613}
618614
619615static WRITE16_HANDLER( gtmr_oki_0_bank_w )
r4135r4136
719715   {
720716      case 0x0000:   // 270' A. Wheel
721717         return   (input_port_read(space->machine, "WHEEL0"));
722         break;
723718      case 0x1000:   // 270' D. Wheel
724719         return   (input_port_read(space->machine, "WHEEL1") << 8);
725         break;
726720      case 0x0800:   // 360' Wheel
727721         return   (input_port_read(space->machine, "WHEEL2") << 8);
728         break;
729722      default:
730723         logerror("gtmr2_wheel_r : read at %06x with joystick\n", cpu_get_pc(space->cpu));
731724         return   (~0);
732         break;
733725   }
734726}
735727
src/mame/drivers/goldstar.c
r4135r4136
4343  Controls Set2 is using reels stop buttons from Controls Set1.
4444
4545
46  * Cherry Master V4 (set 2)
47
48  This set is supposed to be a kind of "stealth".
49  The game is hidden into a Tetris game and could be triggered/switched
50  in some way. Seems that it was designed for locations/countries where
51  gambling games are/were not allowed.
52
53  The game is booting as Cherry Master V4 instead of Tetris ATM...
54
55  Even when the gambling game is working properly, the game is flagged
56  as NOT_WORKING till can figure out how can switch between games.
57
58
59  * Kkoj Noli
60
61  kkuj nol-i / kkoj noli (better romanization).
62
63  kkuj = stab/kill
64  nol-i = bees
65
66  The little red box at bottom of the title translates as "South Korea"
67
68  Seems to be a hack of Lucky 8 Lines.
69
70  - Child'ish graphics.
71  - For Amusement only... There is no payout/keyout line accessed.
72  - No stats or service mode.
73  - No NVRAM.
74  - Two sets of player's controls, as lucky8.
75  - No ay8910, so no extra ports.
76  - Only 1 DIP switches bank.
77
78  Nominated for the *WORST* hacked gambling game EVER!
79
80
4681***************************************************************************/
4782
83
84#define MASTER_CLOCK   XTAL_12MHz
85#define CPU_CLOCK      MASTER_CLOCK / 4
86#define PSG_CLOCK      MASTER_CLOCK / 4
87#define AY_CLOCK      MASTER_CLOCK / 8
88#define OKI_CLOCK      1056000      /* unverified resonator */
89
4890#include "driver.h"
4991#include "cpu/z80/z80.h"
5092#include "sound/ay8910.h"
r4135r4136
73115VIDEO_START( goldstar );
74116VIDEO_START( cherrym );
75117VIDEO_UPDATE( goldstar );
118VIDEO_UPDATE( cmast91 );
76119
77120static UINT8 *nvram;
78121static size_t nvram_size;
r4135r4136
219262static ADDRESS_MAP_START( cm_map, ADDRESS_SPACE_PROGRAM, 8 )
220263   AM_RANGE(0x0000, 0xbfff) AM_ROM AM_WRITENOP
221264
265   AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
266
222267   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_WRITE(goldstar_fg_vidram_w) AM_BASE(&videoram)
223268   AM_RANGE(0xe800, 0xefff) AM_RAM AM_WRITE(goldstar_fg_atrram_w) AM_BASE(&colorram)
224269
225   AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
226
227270   AM_RANGE(0xf000, 0xf1ff) AM_RAM AM_WRITE( goldstar_reel1_ram_w ) AM_BASE(&goldstar_reel1_ram)
228271   AM_RANGE(0xf200, 0xf3ff) AM_RAM AM_WRITE( goldstar_reel2_ram_w ) AM_BASE(&goldstar_reel2_ram)
229272   AM_RANGE(0xf400, 0xf5ff) AM_RAM AM_WRITE( goldstar_reel3_ram_w ) AM_BASE(&goldstar_reel3_ram)
r4135r4136
242285   AM_RANGE(0x01, 0x01) AM_READ(ay8910_read_port_0_r)
243286   AM_RANGE(0x02, 0x02) AM_WRITE(ay8910_write_port_0_w)
244287   AM_RANGE(0x03, 0x03) AM_WRITE(ay8910_control_port_0_w)
245   AM_RANGE(0x04, 0x07) AM_DEVREADWRITE(PPI8255, "cm_ppi8255_0", ppi8255_r, ppi8255_w)   /* Input Ports */
246   AM_RANGE(0x08, 0x0b) AM_DEVREADWRITE(PPI8255, "cm_ppi8255_1", ppi8255_r, ppi8255_w)   /* DIP switches */
288   AM_RANGE(0x04, 0x07) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)   /* Input Ports */
289   AM_RANGE(0x08, 0x0b) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)   /* DIP switches */
247290   AM_RANGE(0x10, 0x10) AM_WRITE (cm_outport0_w)   /* output port */
248291   AM_RANGE(0x11, 0x11) AM_WRITENOP
249292   AM_RANGE(0x12, 0x12) AM_WRITE (cm_outport1_w)   /* output port */
r4135r4136
251294ADDRESS_MAP_END
252295
253296
254static READ8_HANDLER( cm91_r )
255{
256   return 0xff;
257}
258
259297static ADDRESS_MAP_START( cmast91_portmap, ADDRESS_SPACE_IO, 8 )
260298   ADDRESS_MAP_GLOBAL_MASK(0xff)
261   AM_RANGE(0x02, 0x02) AM_READ(cm91_r)
299   AM_RANGE(0x00, 0x03) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)   /* Input Ports */
300   AM_RANGE(0x10, 0x13) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)   /* DIP switches */
262301   AM_RANGE(0x21, 0x21) AM_READ(ay8910_read_port_0_r)
263302   AM_RANGE(0x22, 0x22) AM_WRITE(ay8910_write_port_0_w)
264303   AM_RANGE(0x23, 0x23) AM_WRITE(ay8910_control_port_0_w)
r4135r4136
292331ADDRESS_MAP_END
293332
294333
334static ADDRESS_MAP_START( kkojnoli_map, ADDRESS_SPACE_PROGRAM, 8 )
335   AM_RANGE(0x0000, 0x7fff) AM_ROM
336   AM_RANGE(0x8000, 0x87ff) AM_RAM   /* definitelly no NVRAM */
337   AM_RANGE(0x8800, 0x8fff) AM_RAM AM_WRITE(goldstar_fg_vidram_w) AM_BASE(&videoram)
338   AM_RANGE(0x9000, 0x97ff) AM_RAM AM_WRITE(goldstar_fg_atrram_w) AM_BASE(&colorram)
339   AM_RANGE(0x9800, 0x99ff) AM_RAM AM_WRITE(goldstar_reel1_ram_w) AM_BASE(&goldstar_reel1_ram)
340   AM_RANGE(0xa000, 0xa1ff) AM_RAM AM_WRITE(goldstar_reel2_ram_w) AM_BASE(&goldstar_reel2_ram)
341   AM_RANGE(0xa800, 0xa9ff) AM_RAM AM_WRITE(goldstar_reel3_ram_w) AM_BASE(&goldstar_reel3_ram)
342   AM_RANGE(0xb040, 0xb07f) AM_RAM AM_BASE(&goldstar_reel1_scroll)
343   AM_RANGE(0xb080, 0xb0bf) AM_RAM AM_BASE(&goldstar_reel2_scroll)
344   AM_RANGE(0xb100, 0xb17f) AM_RAM AM_BASE(&goldstar_reel3_scroll)
345
346   AM_RANGE(0xb800, 0xb803) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)   /* Input Ports */
347   AM_RANGE(0xb810, 0xb813) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)   /* Input Ports */
348   AM_RANGE(0xb820, 0xb823) AM_DEVREADWRITE(PPI8255, "ppi8255_2", ppi8255_r, ppi8255_w)   /* Input Port */
349   AM_RANGE(0xb830, 0xb830) AM_WRITENOP      /* no ay8910 */
350   AM_RANGE(0xb840, 0xb840) AM_WRITENOP      /* no ay8910 */
351   AM_RANGE(0xb850, 0xb850) AM_WRITE(lucky8_outport_w)
352   AM_RANGE(0xb870, 0xb870) AM_WRITE(sn76496_0_w)   /* sound */
353   AM_RANGE(0xf800, 0xffff) AM_RAM
354ADDRESS_MAP_END
355
356
357//static WRITE8_HANDLER( ladylinr_outport_w )
358//{
359/* LAMPS (b840)...
360
361   .... ...x
362   .... ..x.
363   .... .x..
364   .... x...  BET
365   ...x ....  SMALL/INFO
366   ..x. ....  START
367   .x.. ....
368   x... ....
369*/
370//  popmessage("Output: %02X", data);
371//}
372
373static ADDRESS_MAP_START( ladylinr_map, ADDRESS_SPACE_PROGRAM, 8 )
374   AM_RANGE(0x0000, 0x7fff) AM_ROM
375   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
376   AM_RANGE(0x8800, 0x8fff) AM_RAM AM_WRITE(goldstar_fg_vidram_w) AM_BASE(&videoram)
377   AM_RANGE(0x9000, 0x97ff) AM_RAM AM_WRITE(goldstar_fg_atrram_w) AM_BASE(&colorram)
378   AM_RANGE(0x9800, 0x99ff) AM_RAM AM_WRITE(goldstar_reel1_ram_w) AM_BASE(&goldstar_reel1_ram)
379   AM_RANGE(0xa000, 0xa1ff) AM_RAM AM_WRITE(goldstar_reel2_ram_w) AM_BASE(&goldstar_reel2_ram)
380   AM_RANGE(0xa800, 0xa9ff) AM_RAM AM_WRITE(goldstar_reel3_ram_w) AM_BASE(&goldstar_reel3_ram)
381   AM_RANGE(0xb040, 0xb07f) AM_RAM AM_BASE(&goldstar_reel1_scroll)
382   AM_RANGE(0xb080, 0xb0bf) AM_RAM AM_BASE(&goldstar_reel2_scroll)
383   AM_RANGE(0xb100, 0xb17f) AM_RAM AM_BASE(&goldstar_reel3_scroll)
384
385   AM_RANGE(0xb800, 0xb803) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)   /* Input Ports */
386   AM_RANGE(0xb810, 0xb813) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)   /* DSW bank */
387   AM_RANGE(0xb830, 0xb830) AM_READWRITE(ay8910_read_port_0_r,ay8910_write_port_0_w)
388   AM_RANGE(0xb840, 0xb840) AM_WRITE(ay8910_control_port_0_w)   /* no sound... only use ports */
389   AM_RANGE(0xb850, 0xb850) AM_WRITENOP   /* just turn off the lamps, if exist */
390   AM_RANGE(0xb870, 0xb870) AM_WRITE(sn76496_0_w)   /* sound */
391   AM_RANGE(0xf800, 0xffff) AM_RAM
392ADDRESS_MAP_END
393
394
295395static INPUT_PORTS_START( cmv801 )
296396   PORT_START("IN0")
297397   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
298398   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
299   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Stop 2 / Big")          PORT_CODE(KEYCODE_X)
300   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Stop 1 / D-UP")         PORT_CODE(KEYCODE_Z)
301   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Stop All / Take")       PORT_CODE(KEYCODE_V)
302   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Bet")                   PORT_CODE(KEYCODE_B)
303   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Stop 3 / Small / Info") PORT_CODE(KEYCODE_C)
304   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Start")                 PORT_CODE(KEYCODE_N)
399   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Stop 2 / Big")
400   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("Stop 1 / D-UP")
401   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Stop All / Take")
402   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Bet")
403   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Stop 3 / Small / Info")
404   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start")
305405
306406   PORT_START("IN1")
307407   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4135r4136
310410   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
311411   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
312412   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
313   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In") PORT_CODE(KEYCODE_Q)
413   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
314414   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
315415
316416   PORT_START("IN2")
r4135r4136
318418   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
319419   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
320420   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
321   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key Out / Attendant") PORT_CODE(KEYCODE_W)
421   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
322422   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
323   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Settings") PORT_CODE(KEYCODE_9)
324   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Stats")    PORT_CODE(KEYCODE_0)
423   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
424   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
325425
326426   PORT_START("DSW1")
327427   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:1")   /* OK */
r4135r4136
458558   PORT_START("IN0")
459559   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
460560   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
461   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Stop 3 / Big")          PORT_CODE(KEYCODE_X)
462   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Stop 1 / D-UP")         PORT_CODE(KEYCODE_Z)
463   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Stop All / Take")       PORT_CODE(KEYCODE_V)
464   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Bet")                   PORT_CODE(KEYCODE_B)
465   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Stop 2 / Small / Info") PORT_CODE(KEYCODE_C)
466   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Start")                 PORT_CODE(KEYCODE_N)
561   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Stop 3 / Big")
562   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("Stop 1 / D-UP")
563   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Stop All / Take")
564   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Bet")
565   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Stop 2 / Small / Info")
566   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start")
467567
468568   PORT_START("IN1")
469569   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4135r4136
472572   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
473573   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
474574   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
475   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In") PORT_CODE(KEYCODE_Q)
575   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
476576   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
477577
478578   PORT_START("IN2")
r4135r4136
480580   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
481581   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
482582   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
483   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key Out / Attendant") PORT_CODE(KEYCODE_W)
583   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
484584   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
485   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Settings") PORT_CODE(KEYCODE_9)
486   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Stats")    PORT_CODE(KEYCODE_0)
585   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
586   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
487587
488588   PORT_START("DSW1")
489589   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:1")   /* OK */
r4135r4136
511611   PORT_DIPSETTING(    0xc0, "64" )
512612
513613   PORT_START("DSW2")
514   PORT_DIPNAME( 0x07, 0x04, "Main Game Pay Rate" )   PORT_DIPLOCATION("DSW2:1,2,3")   /* OK */
614   PORT_DIPNAME( 0x07, 0x03, "Main Game Pay Rate" )   PORT_DIPLOCATION("DSW2:1,2,3")   /* OK */
515615   PORT_DIPSETTING(    0x07, "30%" )
516616   PORT_DIPSETTING(    0x06, "38%" )
517617   PORT_DIPSETTING(    0x05, "46%" )
r4135r4136
620720   PORT_START("IN0")
621721   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
622722   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
623   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Stop 3 / Big")          PORT_CODE(KEYCODE_X)
624   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Stop 1 / D-UP")         PORT_CODE(KEYCODE_Z)
625   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Take")                  PORT_CODE(KEYCODE_V)
626   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Bet / Stop All")        PORT_CODE(KEYCODE_B)
627   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Stop 2 / Small / Info") PORT_CODE(KEYCODE_C)
628   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Start")                 PORT_CODE(KEYCODE_N)
723   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Stop 3 / Big")
724   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("Stop 1 / D-UP")
725   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Take")
726   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Bet / Stop All")
727   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Stop 2 / Small / Info")
728   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start")
629729
630730   PORT_START("IN1")
631731   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4135r4136
634734   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
635735   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
636736   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
637   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In") PORT_CODE(KEYCODE_Q)
737   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
638738   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
639739
640740   PORT_START("IN2")
r4135r4136
642742   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
643743   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
644744   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
645   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key Out / Attendant") PORT_CODE(KEYCODE_W)
745   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
646746   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
647   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Settings") PORT_CODE(KEYCODE_9)
648   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Stats")    PORT_CODE(KEYCODE_0)
747   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
748   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
649749
650750   PORT_START("DSW1")
651751   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:1")   /* OK */
r4135r4136
673773   PORT_DIPSETTING(    0xc0, "64" )
674774
675775   PORT_START("DSW2")
676   PORT_DIPNAME( 0x07, 0x04, "Main Game Pay Rate" )   PORT_DIPLOCATION("DSW2:1,2,3")   /* OK */
776   PORT_DIPNAME( 0x07, 0x03, "Main Game Pay Rate" )   PORT_DIPLOCATION("DSW2:1,2,3")   /* OK */
677777   PORT_DIPSETTING(    0x07, "45%" )
678778   PORT_DIPSETTING(    0x06, "50%" )
679779   PORT_DIPSETTING(    0x05, "55%" )
r4135r4136
754854   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
755855
756856   PORT_START("DSW5")
757   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) PORT_DIPLOCATION("DSW5:1")   /* not checked */
857   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )                 PORT_DIPLOCATION("DSW5:1")   /* not checked */
758858   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
759859   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
760860   PORT_DIPNAME( 0x06, 0x06, "Coin In Limit" )                    PORT_DIPLOCATION("DSW5:2,3")   /* not checked */
r4135r4136
778878   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
779879INPUT_PORTS_END
780880
881static INPUT_PORTS_START( cmasterb )
882   PORT_START("IN0")
883   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
884   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
885   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Big / Stop All")
886   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("D-UP")
887   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Take Score")
888   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Bet")
889   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Small / Info")
890   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start")
781891
892   PORT_START("IN1")
893   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
894   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
895   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2)    PORT_IMPULSE(2)   /* Coin B */
896   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
897   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
898   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
899   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
900   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
901
902   PORT_START("IN2")
903   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
904   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
905   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
906   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
907   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
908   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
909   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
910   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
911
912   PORT_START("DSW1")
913   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:1")   /* OK */
914   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
915   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
916   PORT_DIPNAME( 0x02, 0x02, "Hopper Out Switch" )   PORT_DIPLOCATION("DSW1:2")   /* OK */
917   PORT_DIPSETTING(    0x02, "Active Low" )
918   PORT_DIPSETTING(    0x00, "Active High" )
919   PORT_DIPNAME( 0x04, 0x00, "Payout Mode" )      PORT_DIPLOCATION("DSW1:3")   /* OK */
920   PORT_DIPSETTING(    0x04, "Payout Switch" )
921   PORT_DIPSETTING(    0x00, "Automatic" )
922   PORT_DIPNAME( 0x08, 0x00, "W-UP '7'" )         PORT_DIPLOCATION("DSW1:4")   /* not checked */
923   PORT_DIPSETTING(    0x08, "Loss" )
924   PORT_DIPSETTING(    0x00, "Even" )
925   PORT_DIPNAME( 0x10, 0x00, "W-UP Pay Rate" )      PORT_DIPLOCATION("DSW1:5")   /* OK */
926   PORT_DIPSETTING(    0x00, "80%" )
927   PORT_DIPSETTING(    0x10, "90%" )
928   PORT_DIPNAME( 0x20, 0x00, "W-UP Game" )         PORT_DIPLOCATION("DSW1:6")   /* OK */
929   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
930   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
931   PORT_DIPNAME( 0xc0, 0xc0, "Bet Max" )         PORT_DIPLOCATION("DSW1:7,8")   /* OK */
932   PORT_DIPSETTING(    0x00, "8" )
933   PORT_DIPSETTING(    0x40, "16" )
934   PORT_DIPSETTING(    0x80, "32" )
935   PORT_DIPSETTING(    0xc0, "64" )
936
937   PORT_START("DSW2")
938   PORT_DIPNAME( 0x07, 0x03, "Main Game Pay Rate" )   PORT_DIPLOCATION("DSW2:1,2,3")   /* OK */
939   PORT_DIPSETTING(    0x07, "55%" )
940   PORT_DIPSETTING(    0x06, "60%" )
941   PORT_DIPSETTING(    0x05, "65%" )
942   PORT_DIPSETTING(    0x04, "70%" )
943   PORT_DIPSETTING(    0x03, "75%" )
944   PORT_DIPSETTING(    0x02, "80%" )
945   PORT_DIPSETTING(    0x01, "85%" )
946   PORT_DIPSETTING(    0x00, "90%" )
947   PORT_DIPNAME( 0x18, 0x00, "Hopper Limit" )         PORT_DIPLOCATION("DSW2:4,5")   /* OK */
948   PORT_DIPSETTING(    0x18, "300" )
949   PORT_DIPSETTING(    0x10, "500" )
950   PORT_DIPSETTING(    0x08, "1000" )
951   PORT_DIPSETTING(    0x00, "Unlimited" )
952   PORT_DIPNAME( 0x20, 0x00, "100 Odds Sound" )      PORT_DIPLOCATION("DSW2:6")   /* not checked */
953   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
954   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
955   PORT_DIPNAME( 0x40, 0x40, "Key-In Type" )         PORT_DIPLOCATION("DSW2:7")   /* OK */
956   PORT_DIPSETTING(    0x40, "A-Type" )
957   PORT_DIPSETTING(    0x00, "B-Type" )
958   PORT_DIPNAME( 0x80, 0x00, "Center Super 7 Bet Limit" )   PORT_DIPLOCATION("DSW2:8")   /* related with DSW 4-6 */
959   PORT_DIPSETTING(    0x80, "Unlimited" )
960   PORT_DIPSETTING(    0x00, "Limited" )
961
962   PORT_START("DSW3")
963   PORT_DIPNAME( 0x03, 0x03, "Key In Rate" ) PORT_DIPLOCATION("DSW3:1,2")   /* OK */
964   PORT_DIPSETTING(    0x00, "1 Coin/10 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40) /* A-Type */
965   PORT_DIPSETTING(    0x01, "1 Coin/20 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
966   PORT_DIPSETTING(    0x02, "1 Coin/50 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
967   PORT_DIPSETTING(    0x03, "1 Coin/100 Credits" ) PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
968   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )     PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00) /* B-Type */
969   PORT_DIPSETTING(    0x01, "1 Coin/10 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
970   PORT_DIPSETTING(    0x02, "1 Coin/25 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
971   PORT_DIPSETTING(    0x03, "1 Coin/50 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
972   PORT_DIPNAME( 0x0c, 0x0c, "Coin A Rate" ) PORT_DIPLOCATION("DSW3:3,4")   /* OK */
973   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
974   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
975   PORT_DIPSETTING(    0x08, DEF_STR( 1C_5C ) )
976   PORT_DIPSETTING(    0x0c, "1 Coin/10 Credits" )
977   PORT_DIPNAME( 0x30, 0x30, "Coin D Rate" ) PORT_DIPLOCATION("DSW3:5,6")   /* OK */
978   PORT_DIPSETTING(    0x30, DEF_STR( 5C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10) /* C-Type */
979   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
980   PORT_DIPSETTING(    0x10, DEF_STR( 1C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
981   PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
982   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00) /* D-Type */
983   PORT_DIPSETTING(    0x10, "1 Coin/10 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
984   PORT_DIPSETTING(    0x20, "1 Coin/25 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
985   PORT_DIPSETTING(    0x30, "1 Coin/50 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
986   PORT_DIPNAME( 0xc0, 0xc0, "Coin C Rate" ) PORT_DIPLOCATION("DSW3:7,8")   /* OK */
987   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
988   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
989   PORT_DIPSETTING(    0x80, DEF_STR( 1C_5C ) )
990   PORT_DIPSETTING(    0xc0, "1 Coin/10 Credits" )
991
992   PORT_START("DSW4")
993   PORT_DIPNAME( 0x07, 0x05, "Credit Limit" )            PORT_DIPLOCATION("DSW4:1,2,3")   /* OK */
994   PORT_DIPSETTING(    0x07, "5,000" )
995   PORT_DIPSETTING(    0x06, "10,000" )
996   PORT_DIPSETTING(    0x05, "20,000" )
997   PORT_DIPSETTING(    0x04, "30,000" )
998   PORT_DIPSETTING(    0x03, "40,000" )
999   PORT_DIPSETTING(    0x02, "50,000" )
1000   PORT_DIPSETTING(    0x01, "100,000" )
1001   PORT_DIPSETTING(    0x00, "Unlimited" )
1002   PORT_DIPNAME( 0x08, 0x00, "Display Of Payout Limit" ) PORT_DIPLOCATION("DSW4:4")   /* OK */
1003   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1004   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1005   PORT_DIPNAME( 0x10, 0x10, "Type Of Coin D" )          PORT_DIPLOCATION("DSW4:5")   /* OK */
1006   PORT_DIPSETTING(    0x10, "C-Type" )
1007   PORT_DIPSETTING(    0x00, "D-Type" )
1008   PORT_DIPNAME( 0x20, 0x20, "Min. Bet For Bonus Play" ) PORT_DIPLOCATION("DSW4:6")   /* OK */
1009   PORT_DIPSETTING(    0x20, "16 Bet" )
1010   PORT_DIPSETTING(    0x00, "8 Bet" )
1011   PORT_DIPNAME( 0x40, 0x40, "Reel Speed" )              PORT_DIPLOCATION("DSW4:7")   /* OK */
1012   PORT_DIPSETTING(    0x40, DEF_STR( Low ) )
1013   PORT_DIPSETTING(    0x00, DEF_STR( High ) )
1014   PORT_DIPNAME( 0x80, 0x80, "Hopper Out By Coin A" )    PORT_DIPLOCATION("DSW4:8")   /* not checked */
1015   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1016   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1017
1018   PORT_START("DSW5")
1019   PORT_DIPNAME( 0x01, 0x01, "Display Of Doll On Demo" )          PORT_DIPLOCATION("DSW5:1")   /* not checked */
1020   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1021   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1022   PORT_DIPNAME( 0x06, 0x06, "Coin In Limit" )                    PORT_DIPLOCATION("DSW5:2,3")   /* not checked */
1023   PORT_DIPSETTING(    0x06, "1,000" )
1024   PORT_DIPSETTING(    0x04, "5,000" )
1025   PORT_DIPSETTING(    0x02, "10,000" )
1026   PORT_DIPSETTING(    0x00, "20,000" )
1027   PORT_DIPNAME( 0x18, 0x18, "Condition For 3 Kind Of Bonus" )    PORT_DIPLOCATION("DSW5:4,5")   /* not checked */
1028   PORT_DIPSETTING(    0x18, "12-7-1" )
1029   PORT_DIPSETTING(    0x10, "9-5-1" )
1030   PORT_DIPSETTING(    0x08, "6-3-1" )
1031   PORT_DIPSETTING(    0x00, "3-2-1" )
1032   PORT_DIPNAME( 0x20, 0x20, "Display Of Doll At All Fr. Bonus" ) PORT_DIPLOCATION("DSW5:6")   /* not checked */
1033   PORT_DIPSETTING(    0x20, DEF_STR( Low ) )
1034   PORT_DIPSETTING(    0x00, DEF_STR( High ) )
1035   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )                 PORT_DIPLOCATION("DSW5:7")   /* listed as unused */
1036   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1037   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1038   PORT_DIPNAME( 0x80, 0x80, "Test Mode For Disp. Of Doll" )      PORT_DIPLOCATION("DSW5:8")   /* not checked */
1039   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1040   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1041INPUT_PORTS_END
1042
1043static INPUT_PORTS_START( cmasterc )
1044   PORT_START("IN0")
1045   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1046   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1047   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Big / Stop 1")
1048   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("D-UP / Stop 2")
1049   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Take Score")
1050   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Bet")
1051   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Small / Info / Stop 3")
1052   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start")
1053
1054   PORT_START("IN1")
1055   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1056   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1057   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2)    PORT_IMPULSE(2)   /* Coin B */
1058   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1059   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
1060   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
1061   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
1062   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
1063
1064   PORT_START("IN2")
1065   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1066   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1067   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1068   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1069   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
1070   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
1071   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
1072   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
1073
1074   PORT_START("DSW1")
1075   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:1")   /* OK */
1076   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1077   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1078   PORT_DIPNAME( 0x02, 0x02, "Hopper Out Switch" )   PORT_DIPLOCATION("DSW1:2")   /* OK */
1079   PORT_DIPSETTING(    0x02, "Active Low" )
1080   PORT_DIPSETTING(    0x00, "Active High" )
1081   PORT_DIPNAME( 0x04, 0x00, "Payout Mode" )      PORT_DIPLOCATION("DSW1:3")   /* OK */
1082   PORT_DIPSETTING(    0x04, "Payout Switch" )
1083   PORT_DIPSETTING(    0x00, "Automatic" )
1084   PORT_DIPNAME( 0x08, 0x00, "W-UP '7'" )         PORT_DIPLOCATION("DSW1:4")   /* not checked */
1085   PORT_DIPSETTING(    0x08, "Loss" )
1086   PORT_DIPSETTING(    0x00, "Even" )
1087   PORT_DIPNAME( 0x10, 0x00, "W-UP Pay Rate" )      PORT_DIPLOCATION("DSW1:5")   /* OK */
1088   PORT_DIPSETTING(    0x00, "80%" )
1089   PORT_DIPSETTING(    0x10, "90%" )
1090   PORT_DIPNAME( 0x20, 0x00, "W-UP Game" )         PORT_DIPLOCATION("DSW1:6")   /* OK */
1091   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1092   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1093   PORT_DIPNAME( 0xc0, 0xc0, "Bet Max" )         PORT_DIPLOCATION("DSW1:7,8")   /* OK */
1094   PORT_DIPSETTING(    0x00, "8" )
1095   PORT_DIPSETTING(    0x40, "16" )
1096   PORT_DIPSETTING(    0x80, "32" )
1097   PORT_DIPSETTING(    0xc0, "64" )
1098
1099   PORT_START("DSW2")
1100   PORT_DIPNAME( 0x07, 0x03, "Main Game Pay Rate" )   PORT_DIPLOCATION("DSW2:1,2,3")   /* OK */
1101   PORT_DIPSETTING(    0x07, "55%" )
1102   PORT_DIPSETTING(    0x06, "60%" )
1103   PORT_DIPSETTING(    0x05, "65%" )
1104   PORT_DIPSETTING(    0x04, "70%" )
1105   PORT_DIPSETTING(    0x03, "75%" )
1106   PORT_DIPSETTING(    0x02, "80%" )
1107   PORT_DIPSETTING(    0x01, "85%" )
1108   PORT_DIPSETTING(    0x00, "90%" )
1109   PORT_DIPNAME( 0x18, 0x00, "Hopper Limit" )         PORT_DIPLOCATION("DSW2:4,5")   /* OK */
1110   PORT_DIPSETTING(    0x18, "300" )
1111   PORT_DIPSETTING(    0x10, "500" )
1112   PORT_DIPSETTING(    0x08, "1000" )
1113   PORT_DIPSETTING(    0x00, "Unlimited" )
1114   PORT_DIPNAME( 0x20, 0x00, "100 Odds Sound" )      PORT_DIPLOCATION("DSW2:6")   /* not checked */
1115   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1116   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
1117   PORT_DIPNAME( 0x40, 0x40, "Key-In Type" )         PORT_DIPLOCATION("DSW2:7")   /* OK */
1118   PORT_DIPSETTING(    0x40, "A-Type" )
1119   PORT_DIPSETTING(    0x00, "B-Type" )
1120   PORT_DIPNAME( 0x80, 0x00, "Center Super 7 Bet Limit" )   PORT_DIPLOCATION("DSW2:8")   /* related with DSW 4-6 */
1121   PORT_DIPSETTING(    0x80, "Unlimited" )
1122   PORT_DIPSETTING(    0x00, "Limited" )
1123
1124   PORT_START("DSW3")
1125   PORT_DIPNAME( 0x03, 0x03, "Key In Rate" ) PORT_DIPLOCATION("DSW3:1,2")   /* OK */
1126   PORT_DIPSETTING(    0x00, "1 Coin/10 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40) /* A-Type */
1127   PORT_DIPSETTING(    0x01, "1 Coin/20 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
1128   PORT_DIPSETTING(    0x02, "1 Coin/50 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
1129   PORT_DIPSETTING(    0x03, "1 Coin/100 Credits" ) PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
1130   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )     PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00) /* B-Type */
1131   PORT_DIPSETTING(    0x01, "1 Coin/10 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
1132   PORT_DIPSETTING(    0x02, "1 Coin/25 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
1133   PORT_DIPSETTING(    0x03, "1 Coin/50 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
1134   PORT_DIPNAME( 0x0c, 0x0c, "Coin A Rate" ) PORT_DIPLOCATION("DSW3:3,4")   /* OK */
1135   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
1136   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
1137   PORT_DIPSETTING(    0x08, DEF_STR( 1C_5C ) )
1138   PORT_DIPSETTING(    0x0c, "1 Coin/10 Credits" )
1139   PORT_DIPNAME( 0x30, 0x30, "Coin D Rate" ) PORT_DIPLOCATION("DSW3:5,6")   /* OK */
1140   PORT_DIPSETTING(    0x30, DEF_STR( 5C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10) /* C-Type */
1141   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
1142   PORT_DIPSETTING(    0x10, DEF_STR( 1C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
1143   PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
1144   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00) /* D-Type */
1145   PORT_DIPSETTING(    0x10, "1 Coin/10 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
1146   PORT_DIPSETTING(    0x20, "1 Coin/25 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
1147   PORT_DIPSETTING(    0x30, "1 Coin/50 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
1148   PORT_DIPNAME( 0xc0, 0xc0, "Coin C Rate" ) PORT_DIPLOCATION("DSW3:7,8")   /* OK */
1149   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
1150   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
1151   PORT_DIPSETTING(    0x80, DEF_STR( 1C_5C ) )
1152   PORT_DIPSETTING(    0xc0, "1 Coin/10 Credits" )
1153
1154   PORT_START("DSW4")
1155   PORT_DIPNAME( 0x07, 0x05, "Credit Limit" )            PORT_DIPLOCATION("DSW4:1,2,3")   /* OK */
1156   PORT_DIPSETTING(    0x07, "5,000" )
1157   PORT_DIPSETTING(    0x06, "10,000" )
1158   PORT_DIPSETTING(    0x05, "20,000" )
1159   PORT_DIPSETTING(    0x04, "30,000" )
1160   PORT_DIPSETTING(    0x03, "40,000" )
1161   PORT_DIPSETTING(    0x02, "50,000" )
1162   PORT_DIPSETTING(    0x01, "100,000" )
1163   PORT_DIPSETTING(    0x00, "Unlimited" )
1164   PORT_DIPNAME( 0x08, 0x00, "Display Of Payout Limit" ) PORT_DIPLOCATION("DSW4:4")   /* OK */
1165   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1166   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1167   PORT_DIPNAME( 0x10, 0x10, "Type Of Coin D" )          PORT_DIPLOCATION("DSW4:5")   /* OK */
1168   PORT_DIPSETTING(    0x10, "C-Type" )
1169   PORT_DIPSETTING(    0x00, "D-Type" )
1170   PORT_DIPNAME( 0x20, 0x20, "Min. Bet For Bonus Play" ) PORT_DIPLOCATION("DSW4:6")   /* OK */
1171   PORT_DIPSETTING(    0x20, "16 Bet" )
1172   PORT_DIPSETTING(    0x00, "8 Bet" )
1173   PORT_DIPNAME( 0x40, 0x40, "Reel Speed" )              PORT_DIPLOCATION("DSW4:7")   /* OK */
1174   PORT_DIPSETTING(    0x40, DEF_STR( Low ) )
1175   PORT_DIPSETTING(    0x00, DEF_STR( High ) )
1176   PORT_DIPNAME( 0x80, 0x80, "Hopper Out By Coin A" )    PORT_DIPLOCATION("DSW4:8")   /* not checked */
1177   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1178   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1179
1180   PORT_START("DSW5")
1181   PORT_DIPNAME( 0x01, 0x01, "Display Of Doll On Demo" )          PORT_DIPLOCATION("DSW5:1")   /* not checked */
1182   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1183   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1184   PORT_DIPNAME( 0x06, 0x06, "Coin In Limit" )                    PORT_DIPLOCATION("DSW5:2,3")   /* not checked */
1185   PORT_DIPSETTING(    0x06, "1,000" )
1186   PORT_DIPSETTING(    0x04, "5,000" )
1187   PORT_DIPSETTING(    0x02, "10,000" )
1188   PORT_DIPSETTING(    0x00, "20,000" )
1189   PORT_DIPNAME( 0x18, 0x18, "Condition For 3 Kind Of Bonus" )    PORT_DIPLOCATION("DSW5:4,5")   /* not checked */
1190   PORT_DIPSETTING(    0x18, "12-7-1" )
1191   PORT_DIPSETTING(    0x10, "9-5-1" )
1192   PORT_DIPSETTING(    0x08, "6-3-1" )
1193   PORT_DIPSETTING(    0x00, "3-2-1" )
1194   PORT_DIPNAME( 0x20, 0x20, "Display Of Doll At All Fr. Bonus" ) PORT_DIPLOCATION("DSW5:6")   /* not checked */
1195   PORT_DIPSETTING(    0x20, DEF_STR( Low ) )
1196   PORT_DIPSETTING(    0x00, DEF_STR( High ) )
1197   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )                 PORT_DIPLOCATION("DSW5:7")   /* listed as unused */
1198   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1199   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1200   PORT_DIPNAME( 0x80, 0x80, "Test Mode For Disp. Of Doll" )      PORT_DIPLOCATION("DSW5:8")   /* not checked */
1201   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1202   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1203INPUT_PORTS_END
1204
1205static INPUT_PORTS_START( cmast91 )
1206   PORT_START("IN0")
1207   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1208   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1209   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Big")
1210   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("D-UP")
1211   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Take")
1212   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Bet")
1213   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Small / Info")
1214   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start")
1215
1216   PORT_START("IN1")
1217   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1218   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1219   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2)    PORT_IMPULSE(2)   /* Coin B */
1220   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1221   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
1222   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
1223   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
1224   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
1225
1226   PORT_START("IN2")
1227   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1228   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1229   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1230   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1231   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
1232   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
1233   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
1234   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
1235
1236   PORT_START("DSW1")
1237   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:1")   /* OK */
1238   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1239   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1240   PORT_DIPNAME( 0x02, 0x02, "Hopper Out Switch" )   PORT_DIPLOCATION("DSW1:2")   /* OK */
1241   PORT_DIPSETTING(    0x02, "Active Low" )
1242   PORT_DIPSETTING(    0x00, "Active High" )
1243   PORT_DIPNAME( 0x04, 0x00, "Payout Mode" )      PORT_DIPLOCATION("DSW1:3")   /* OK */
1244   PORT_DIPSETTING(    0x04, "Payout Switch" )
1245   PORT_DIPSETTING(    0x00, "Automatic" )
1246   PORT_DIPNAME( 0x08, 0x00, "W-UP '7'" )         PORT_DIPLOCATION("DSW1:4")   /* not checked */
1247   PORT_DIPSETTING(    0x08, "Loss" )
1248   PORT_DIPSETTING(    0x00, "Even" )
1249   PORT_DIPNAME( 0x10, 0x00, "W-UP Pay Rate" )      PORT_DIPLOCATION("DSW1:5")   /* OK */
1250   PORT_DIPSETTING(    0x00, "80%" )
1251   PORT_DIPSETTING(    0x10, "90%" )
1252   PORT_DIPNAME( 0x20, 0x00, "W-UP Game" )         PORT_DIPLOCATION("DSW1:6")   /* OK */
1253   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1254   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1255   PORT_DIPNAME( 0xc0, 0xc0, "Bet Max" )         PORT_DIPLOCATION("DSW1:7,8")   /* OK */
1256   PORT_DIPSETTING(    0x00, "8" )
1257   PORT_DIPSETTING(    0x40, "16" )
1258   PORT_DIPSETTING(    0x80, "32" )
1259   PORT_DIPSETTING(    0xc0, "64" )
1260
1261   PORT_START("DSW2")
1262   PORT_DIPNAME( 0x07, 0x03, "Main Game Pay Rate" )   PORT_DIPLOCATION("DSW2:1,2,3")   /* OK */
1263   PORT_DIPSETTING(    0x07, "45%" )
1264   PORT_DIPSETTING(    0x06, "50%" )
1265   PORT_DIPSETTING(    0x05, "55%" )
1266   PORT_DIPSETTING(    0x04, "60%" )
1267   PORT_DIPSETTING(    0x03, "65%" )
1268   PORT_DIPSETTING(    0x02, "70%" )
1269   PORT_DIPSETTING(    0x01, "75%" )
1270   PORT_DIPSETTING(    0x00, "80%" )
1271   PORT_DIPNAME( 0x18, 0x00, "Hopper Limit" )         PORT_DIPLOCATION("DSW2:4,5")   /* OK */
1272   PORT_DIPSETTING(    0x18, "300" )
1273   PORT_DIPSETTING(    0x10, "500" )
1274   PORT_DIPSETTING(    0x08, "1000" )
1275   PORT_DIPSETTING(    0x00, "Unlimited" )
1276   PORT_DIPNAME( 0x20, 0x00, "100 Odds Sound" )      PORT_DIPLOCATION("DSW2:6")   /* not checked */
1277   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1278   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
1279   PORT_DIPNAME( 0x40, 0x40, "Key-In Type" )         PORT_DIPLOCATION("DSW2:7")   /* OK */
1280   PORT_DIPSETTING(    0x40, "A-Type" )
1281   PORT_DIPSETTING(    0x00, "B-Type" )
1282   PORT_DIPNAME( 0x80, 0x00, "Center Super 7 Bet Limit" )   PORT_DIPLOCATION("DSW2:8")   /* related with DSW 4-6 */
1283   PORT_DIPSETTING(    0x80, "Unlimited" )
1284   PORT_DIPSETTING(    0x00, "Limited" )
1285
1286   PORT_START("DSW3")
1287   PORT_DIPNAME( 0x03, 0x03, "Key In Rate" ) PORT_DIPLOCATION("DSW3:1,2")   /* OK */
1288   PORT_DIPSETTING(    0x00, "1 Coin/10 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40) /* A-Type */
1289   PORT_DIPSETTING(    0x01, "1 Coin/20 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
1290   PORT_DIPSETTING(    0x02, "1 Coin/50 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
1291   PORT_DIPSETTING(    0x03, "1 Coin/100 Credits" ) PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
1292   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )     PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00) /* B-Type */
1293   PORT_DIPSETTING(    0x01, "1 Coin/10 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
1294   PORT_DIPSETTING(    0x02, "1 Coin/25 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
1295   PORT_DIPSETTING(    0x03, "1 Coin/50 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
1296   PORT_DIPNAME( 0x0c, 0x0c, "Coin A Rate" ) PORT_DIPLOCATION("DSW3:3,4")   /* OK */
1297   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
1298   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
1299   PORT_DIPSETTING(    0x08, DEF_STR( 1C_5C ) )
1300   PORT_DIPSETTING(    0x0c, "1 Coin/10 Credits" )
1301   PORT_DIPNAME( 0x30, 0x30, "Coin D Rate" ) PORT_DIPLOCATION("DSW3:5,6")   /* OK */
1302   PORT_DIPSETTING(    0x30, DEF_STR( 5C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10) /* C-Type */
1303   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
1304   PORT_DIPSETTING(    0x10, DEF_STR( 1C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
1305   PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
1306   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00) /* D-Type */
1307   PORT_DIPSETTING(    0x10, "1 Coin/10 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
1308   PORT_DIPSETTING(    0x20, "1 Coin/25 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
1309   PORT_DIPSETTING(    0x30, "1 Coin/50 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
1310   PORT_DIPNAME( 0xc0, 0xc0, "Coin C Rate" ) PORT_DIPLOCATION("DSW3:7,8")   /* OK */
1311   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
1312   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
1313   PORT_DIPSETTING(    0x80, DEF_STR( 1C_5C ) )
1314   PORT_DIPSETTING(    0xc0, "1 Coin/10 Credits" )
1315
1316   PORT_START("DSW4")
1317   PORT_DIPNAME( 0x07, 0x06, "Credit Limit" )            PORT_DIPLOCATION("DSW4:1,2,3")   /* OK */
1318   PORT_DIPSETTING(    0x07, "5,000" )
1319   PORT_DIPSETTING(    0x06, "10,000" )
1320   PORT_DIPSETTING(    0x05, "20,000" )
1321   PORT_DIPSETTING(    0x04, "30,000" )
1322   PORT_DIPSETTING(    0x03, "40,000" )
1323   PORT_DIPSETTING(    0x02, "50,000" )
1324   PORT_DIPSETTING(    0x01, "100,000" )
1325   PORT_DIPSETTING(    0x00, "Unlimited" )
1326   PORT_DIPNAME( 0x08, 0x00, "Display Of Payout Limit" ) PORT_DIPLOCATION("DSW4:4")   /* OK */
1327   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1328   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1329   PORT_DIPNAME( 0x10, 0x10, "Type Of Coin D" )          PORT_DIPLOCATION("DSW4:5")   /* OK */
1330   PORT_DIPSETTING(    0x10, "C-Type" )
1331   PORT_DIPSETTING(    0x00, "D-Type" )
1332   PORT_DIPNAME( 0x20, 0x20, "Min. Bet For Bonus Play" ) PORT_DIPLOCATION("DSW4:6")   /* OK */
1333   PORT_DIPSETTING(    0x20, "16 Bet" )
1334   PORT_DIPSETTING(    0x00, "8 Bet" )
1335   PORT_DIPNAME( 0x40, 0x00, "Reel Speed" )              PORT_DIPLOCATION("DSW4:7")   /* OK */
1336   PORT_DIPSETTING(    0x40, DEF_STR( Low ) )
1337   PORT_DIPSETTING(    0x00, DEF_STR( High ) )
1338   PORT_DIPNAME( 0x80, 0x80, "Hopper Out By Coin A" )    PORT_DIPLOCATION("DSW4:8")   /* not checked */
1339   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1340   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1341
1342   PORT_START("DSW5")
1343   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )              PORT_DIPLOCATION("DSW5:1")   /* no whores here */
1344   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1345   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1346   PORT_DIPNAME( 0x06, 0x06, "Coin In Limit" )                 PORT_DIPLOCATION("DSW5:2,3")   /* not checked */
1347   PORT_DIPSETTING(    0x06, "1,000" )
1348   PORT_DIPSETTING(    0x04, "5,000" )
1349   PORT_DIPSETTING(    0x02, "10,000" )
1350   PORT_DIPSETTING(    0x00, "20,000" )
1351   PORT_DIPNAME( 0x18, 0x18, "Condition For 3 Kind Of Bonus" ) PORT_DIPLOCATION("DSW5:4,5")   /* not checked */
1352   PORT_DIPSETTING(    0x18, "12-7-1" )
1353   PORT_DIPSETTING(    0x10, "9-5-1" )
1354   PORT_DIPSETTING(    0x08, "6-3-1" )
1355   PORT_DIPSETTING(    0x00, "3-2-1" )
1356   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )              PORT_DIPLOCATION("DSW5:6")   /* not checked */
1357   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1358   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1359   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )              PORT_DIPLOCATION("DSW5:7")   /* listed as unused */
1360   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1361   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1362   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )              PORT_DIPLOCATION("DSW5:8")   /* no whores in demo */
1363   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1364   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1365INPUT_PORTS_END
1366
1367
7821368static INPUT_PORTS_START( goldstar )
7831369   PORT_START("IN0")
7841370   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
7851371   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
786   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Bet Red/2")
787   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Stop 3/Small/1/Info")
788   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Bet Blue/Double/3")
789   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("Stop 1/Take")
790   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Stop 2/Big/Ticket")
791   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start/Stop All/4")
1372   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Bet Red / 2")
1373   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Stop 3 / Small / 1 / Info")
1374   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Bet Blue / D-UP / 3")
1375   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("Stop 1 / Take")
1376   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Stop 2 / Big / Ticket")
1377   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start / Stop All / 4")
7921378
7931379   PORT_START("IN1")
7941380   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
r4135r4136
9091495   PORT_START("IN0")
9101496   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
9111497   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
912   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Stop 2 / Big / Bonus Game")      PORT_CODE(KEYCODE_X)
913   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Blue Bet / D-UP / Card 3")       PORT_CODE(KEYCODE_B)
914   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Stop 1 / Take")                  PORT_CODE(KEYCODE_Z)
915   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Red Bet / Card 2")               PORT_CODE(KEYCODE_V)
916   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Stop 3 / Small / Info / Card 1") PORT_CODE(KEYCODE_C)
917   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Start / Stop All / Card 4")      PORT_CODE(KEYCODE_N)
1498   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Stop 2 / Big / Bonus Game")
1499   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Blue Bet / D-UP / Card 3")
1500   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("Stop 1 / Take")
1501   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Red Bet / Card 2")
1502   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Stop 3 / Small / Info / Card 1")
1503   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start / Stop All / Card 4")
9181504
9191505   PORT_START("IN1")
9201506   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4135r4136
9231509   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
9241510   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
9251511   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
926   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In") PORT_CODE(KEYCODE_Q)
1512   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
9271513   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
9281514
9291515   PORT_START("IN2")
r4135r4136
9311517   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
9321518   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
9331519   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
934   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key Out / Attendant") PORT_CODE(KEYCODE_W)
1520   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
9351521   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
936   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Settings") PORT_CODE(KEYCODE_9)
937   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Stats")    PORT_CODE(KEYCODE_0)
1522   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
1523   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
9381524
9391525   PORT_START("IN3")
9401526   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4135r4136
9961582   PORT_DIPSETTING(    0x80, "Unlimited" )
9971583   PORT_DIPSETTING(    0x00, "Limited" )
9981584
999   PORT_START("DSW3")   /* some of these are wrong */
1585   PORT_START("DSW3")   /* some of these could be wrong */
10001586   PORT_DIPNAME( 0x03, 0x03, "Key In Rate" ) PORT_DIPLOCATION("DSW3:1,2")
10011587   PORT_DIPSETTING(    0x00, "1 Coin/10 Credits" )      PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00) // A-Type
10021588   PORT_DIPSETTING(    0x01, "1 Coin/20 Credits" )      PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
r4135r4136
10771663   PORT_DIPSETTING(    0x00, "100 Credits / 100 Pulses" )
10781664INPUT_PORTS_END
10791665
1666static INPUT_PORTS_START( chry10 )
1667   PORT_START("IN0")
1668   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1669   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1670   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Stop 2 / Big / Bonus Game")
1671   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Blue Bet / D-UP / Card 3")
1672   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("Stop 1 / Take")
1673   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Red Bet / Card 2")
1674   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Stop 3 / Small / Info / Card 1")
1675   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start / Stop All / Card 4")
1676
1677   PORT_START("IN1")
1678   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1679   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1680   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2)    PORT_IMPULSE(2)   /* Coin B */
1681   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1682   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
1683   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
1684   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
1685   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
1686
1687   PORT_START("IN2")
1688   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1689   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1690   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1691   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1692   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
1693   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
1694   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
1695   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
1696
1697   PORT_START("IN3")
1698   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1699   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1700   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1701   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1702   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
1703   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
1704   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1705   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1706
1707   PORT_START("DSW1")
1708   PORT_DIPNAME( 0x01, 0x00, "Game Style" )      PORT_DIPLOCATION("DSW1:1")   /* OK */
1709   PORT_DIPSETTING(    0x01, "Tokens" )
1710   PORT_DIPSETTING(    0x00, "Ticket" )
1711   PORT_DIPNAME( 0x02, 0x02, "Hopper Out Switch" )   PORT_DIPLOCATION("DSW1:2")   /* OK */
1712   PORT_DIPSETTING(    0x02, "Active Low" )
1713   PORT_DIPSETTING(    0x00, "Active High" )
1714   PORT_DIPNAME( 0x04, 0x04, "Payout Mode" )      PORT_DIPLOCATION("DSW1:3")   /* OK */
1715   PORT_DIPSETTING(    0x04, "Payout Switch" )
1716   PORT_DIPSETTING(    0x00, "Automatic" )
1717   PORT_DIPNAME( 0x08, 0x00, "W-UP '7'" )         PORT_DIPLOCATION("DSW1:4")
1718   PORT_DIPSETTING(    0x08, "Loss" )
1719   PORT_DIPSETTING(    0x00, "Even" )
1720   PORT_DIPNAME( 0x10, 0x10, "W-UP Pay Rate" )      PORT_DIPLOCATION("DSW1:5")   /* OK */
1721   PORT_DIPSETTING(    0x10, "80%" )
1722   PORT_DIPSETTING(    0x00, "90%" )
1723   PORT_DIPNAME( 0x20, 0x20, "W-UP Game" )         PORT_DIPLOCATION("DSW1:6")   /* OK */
1724   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1725   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
1726   PORT_DIPNAME( 0xc0, 0x00, "Bet Max" )         PORT_DIPLOCATION("DSW1:7,8")   /* OK */
1727   PORT_DIPSETTING(    0xc0, "8" )
1728   PORT_DIPSETTING(    0x80, "16" )
1729   PORT_DIPSETTING(    0x40, "32" )
1730   PORT_DIPSETTING(    0x00, "64" )
1731
1732   PORT_START("DSW2")
1733   PORT_DIPNAME( 0x07, 0x04, "Main Game Pay Rate" )   PORT_DIPLOCATION("DSW2:1,2,3")   /* OK */
1734   PORT_DIPSETTING(    0x00, "40%" )
1735   PORT_DIPSETTING(    0x01, "45%" )
1736   PORT_DIPSETTING(    0x02, "50%" )
1737   PORT_DIPSETTING(    0x03, "55%" )
1738   PORT_DIPSETTING(    0x04, "60%" )
1739   PORT_DIPSETTING(    0x05, "65%" )
1740   PORT_DIPSETTING(    0x06, "70%" )
1741   PORT_DIPSETTING(    0x07, "80%" )
1742   PORT_DIPNAME( 0x18, 0x00, "Hopper Limit" )         PORT_DIPLOCATION("DSW2:4,5")
1743   PORT_DIPSETTING(    0x18, "300" )
1744   PORT_DIPSETTING(    0x10, "500" )
1745   PORT_DIPSETTING(    0x08, "1000" )
1746   PORT_DIPSETTING(    0x00, "Unlimited" )
1747   PORT_DIPNAME( 0x20, 0x00, "100 Odds Sound" )      PORT_DIPLOCATION("DSW2:6")
1748   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1749   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
1750   PORT_DIPNAME( 0x40, 0x00, "Key-In Type" )         PORT_DIPLOCATION("DSW2:7")   /* OK */
1751   PORT_DIPSETTING(    0x40, "B-Type" )
1752   PORT_DIPSETTING(    0x00, "A-Type" )
1753   PORT_DIPNAME( 0x80, 0x00, "Center Super 7 Bet Limit" )   PORT_DIPLOCATION("DSW2:8")   /* related with DSW 4-6 */
1754   PORT_DIPSETTING(    0x80, "Unlimited" )
1755   PORT_DIPSETTING(    0x00, "Limited" )
1756
1757   PORT_START("DSW3")   /* seems ok */
1758   PORT_DIPNAME( 0x03, 0x03, "Key In Rate" ) PORT_DIPLOCATION("DSW3:1,2")   /* OK */
1759   PORT_DIPSETTING(    0x00, "1 Coin/10 Credits" )      PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00) // A-Type
1760   PORT_DIPSETTING(    0x01, "1 Coin/20 Credits" )      PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
1761   PORT_DIPSETTING(    0x02, "1 Coin/50 Credits" )      PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
1762   PORT_DIPSETTING(    0x03, "1 Coin/100 Credits" )   PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
1763   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )      PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40) // B-Type
1764   PORT_DIPSETTING(    0x01, "1 Coin/10 Credits" )      PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
1765   PORT_DIPSETTING(    0x02, "1 Coin/25 Credits" )      PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
1766   PORT_DIPSETTING(    0x03, "1 Coin/50 Credits" )      PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
1767   PORT_DIPNAME( 0x0c, 0x0c, "Coin A Rate" ) PORT_DIPLOCATION("DSW3:3,4")   /* OK */
1768   PORT_DIPSETTING(    0x00, "1 Coin/10 Credits" )
1769   PORT_DIPSETTING(    0x04, "1 Coin/20 Credits" )
1770   PORT_DIPSETTING(    0x08, "1 Coin/50 Credits" )
1771   PORT_DIPSETTING(    0x0c, "1 Coin/100 Credits" )
1772   PORT_DIPNAME( 0x30, 0x30, "Coin D Rate" ) PORT_DIPLOCATION("DSW3:5,6")   /* OK */
1773   PORT_DIPSETTING(    0x30, "5 Coin/10 Credits" )            PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10) // C-Type
1774   PORT_DIPSETTING(    0x20, "2 Coin/10 Credits" )            PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
1775   PORT_DIPSETTING(    0x10, "1 Coin/10 Credits" )            PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
1776   PORT_DIPSETTING(    0x00, "1 Coin/20 Credits" )            PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
1777   PORT_DIPSETTING(    0x00, "1 Ticket/Coin / 50 Credits" )   PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
1778   PORT_DIPSETTING(    0x10, "1 Ticket/Coin / 100 Credits" )   PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
1779   PORT_DIPSETTING(    0x20, "1 Ticket/Coin / 200 Credits" )   PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
1780   PORT_DIPSETTING(    0x30, "1 Ticket/Coin / 500 Credits" )   PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00) // D-Type
1781   PORT_DIPNAME( 0xc0, 0xc0, "Coin C Rate" ) PORT_DIPLOCATION("DSW3:7,8")   /* OK */
1782   PORT_DIPSETTING(    0x00, "1 Coin/10 Credits" )
1783   PORT_DIPSETTING(    0x40, "1 Coin/20 Credits" )
1784   PORT_DIPSETTING(    0x80, "1 Coin/50 Credits" )
1785   PORT_DIPSETTING(    0xc0, "1 Coin/100 Credits" )
1786
1787   PORT_START("DSW4")
1788   PORT_DIPNAME( 0x07, 0x06, "Credit Limit" )            PORT_DIPLOCATION("DSW4:1,2,3")   /* OK */
1789   PORT_DIPSETTING(    0x07, "5,000" )
1790   PORT_DIPSETTING(    0x06, "10,000" )
1791   PORT_DIPSETTING(    0x05, "20,000" )
1792   PORT_DIPSETTING(    0x04, "30,000" )
1793   PORT_DIPSETTING(    0x03, "40,000" )
1794   PORT_DIPSETTING(    0x02, "50,000" )
1795   PORT_DIPSETTING(    0x01, "100,000" )
1796   PORT_DIPSETTING(    0x00, "Unlimited" )
1797   PORT_DIPNAME( 0x08, 0x00, "Display Of Credit Limit" )   PORT_DIPLOCATION("DSW4:4")   /* OK */
1798   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1799   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1800   PORT_DIPNAME( 0x10, 0x10, "Type Of Coin D" )         PORT_DIPLOCATION("DSW4:5")   /* OK */
1801   PORT_DIPSETTING(    0x10, "D-Type (Tokens)" )
1802   PORT_DIPSETTING(    0x00, "C-Type (Ticket)" )
1803   PORT_DIPNAME( 0x20, 0x00, "Bonus Play Min.Bet" )      PORT_DIPLOCATION("DSW4:6")   /* OK */
1804   PORT_DIPSETTING(    0x20, "16 Bet" )
1805   PORT_DIPSETTING(    0x00, "8 Bet" )
1806   PORT_DIPNAME( 0x40, 0x00, "Reel Speed" )            PORT_DIPLOCATION("DSW4:7")   /* OK */
1807   PORT_DIPSETTING(    0x40, DEF_STR( Low ) )
1808   PORT_DIPSETTING(    0x00, DEF_STR( High ) )
1809   PORT_DIPNAME( 0x80, 0x80, "Coin A Mode" )            PORT_DIPLOCATION("DSW4:8")   /* OK */
1810   PORT_DIPSETTING(    0x80, "Unexchange" )
1811   PORT_DIPSETTING(    0x00, "Exchange" )
1812
1813   PORT_START("DSW5")
1814   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )      PORT_DIPLOCATION("DSW5:1")
1815   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1816   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1817   PORT_DIPNAME( 0x06, 0x00, "Coin In Limit" )         PORT_DIPLOCATION("DSW5:2,3")
1818   PORT_DIPSETTING(    0x06, "1000" )
1819   PORT_DIPSETTING(    0x04, "5000" )
1820   PORT_DIPSETTING(    0x02, "10000" )
1821   PORT_DIPSETTING(    0x00, "20000" )
1822   PORT_DIPNAME( 0x18, 0x10, "Coin Out Rate" )         PORT_DIPLOCATION("DSW5:4,5")
1823   PORT_DIPSETTING(    0x00, "100 Credits / 1 Pulse" )
1824   PORT_DIPSETTING(    0x08, "100 Credits / 5 Pulses" )
1825   PORT_DIPSETTING(    0x10, "100 Credits / 10 Pulses" )
1826   PORT_DIPSETTING(    0x18, "100 Credits / 100 Pulses" )
1827   PORT_DIPNAME( 0x20, 0x00, "W-UP Girl" )            PORT_DIPLOCATION("DSW5:6")
1828   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1829   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1830   PORT_DIPNAME( 0xc0, 0x40, "Coin In Rate" )         PORT_DIPLOCATION("DSW5:7,8")
1831   PORT_DIPSETTING(    0xc0, "100 Credits / 1 Pulse" )
1832   PORT_DIPSETTING(    0x40, "100 Credits / 5 Pulses" )
1833   PORT_DIPSETTING(    0x80, "100 Credits / 10 Pulses" )
1834   PORT_DIPSETTING(    0x00, "100 Credits / 100 Pulses" )
1835INPUT_PORTS_END
1836
10801837static INPUT_PORTS_START( ncb3 )
10811838   PORT_START("IN0")
10821839   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
10831840   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1084   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 - Stop 2 / Big / Bonus Game / Switch Controls") PORT_CODE(KEYCODE_X)
1085   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("P1 - Blue Bet / D-UP / Card 3")       PORT_CODE(KEYCODE_B)
1086   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P1 - Stop 1 / Take")                  PORT_CODE(KEYCODE_Z)
1087   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("P1 - Red Bet / Card 2")               PORT_CODE(KEYCODE_V)
1088   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("P1 - Stop 3 / Small / Info / Card 1") PORT_CODE(KEYCODE_C)
1089   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("P1 - Start / Stop All / Card 4")      PORT_CODE(KEYCODE_N)
1841   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("P1 - Stop 2 / Big / Bonus Game / Switch Controls")
1842   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("P1 - Blue Bet / D-UP / Card 3")
1843   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("P1 - Stop 1 / Take")
1844   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("P1 - Red Bet / Card 2")
1845   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("P1 - Stop 3 / Small / Info / Card 1")
1846   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("P1 - Start / Stop All / Card 4")
10901847
10911848   PORT_START("IN1")
10921849   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4135r4136
10951852   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
10961853   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
10971854   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
1098   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In") PORT_CODE(KEYCODE_Q)
1855   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
10991856   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
11001857
11011858   PORT_START("IN2")
r4135r4136
11031860   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
11041861   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
11051862   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1106   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key Out / Attendant") PORT_CODE(KEYCODE_W)
1863   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
11071864   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
1108   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Settings") PORT_CODE(KEYCODE_9)
1109   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Stats")    PORT_CODE(KEYCODE_0)
1865   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
1866   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
11101867
11111868   PORT_START("IN3")
11121869   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
11131870   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1114   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON8 )  PORT_NAME("P2 - Stop 2 / Big / Bonus Game / Switch Controls") PORT_CODE(KEYCODE_S)
1115   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_NAME("P2 - Blue Bet / D-UP / Card 3")       PORT_CODE(KEYCODE_G)
1116   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON7 )  PORT_NAME("P2 - Stop 1 / Take")                  PORT_CODE(KEYCODE_A)
1117   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("P2 - Red Bet / Card 2")               PORT_CODE(KEYCODE_F)
1118   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON9 )  PORT_NAME("P2 - Stop 3 / Small / Info / Card 1") PORT_CODE(KEYCODE_D)
1119   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_NAME("P2 - Start / Stop All / Card 4")      PORT_CODE(KEYCODE_H)
1871   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON8 )  PORT_CODE(KEYCODE_S) PORT_NAME("P2 - Stop 2 / Big / Bonus Game / Switch Controls")
1872   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_CODE(KEYCODE_G) PORT_NAME("P2 - Blue Bet / D-UP / Card 3")
1873   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON7 )  PORT_CODE(KEYCODE_A) PORT_NAME("P2 - Stop 1 / Take")
1874   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_CODE(KEYCODE_F) PORT_NAME("P2 - Red Bet / Card 2")
1875   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON9 )  PORT_CODE(KEYCODE_D) PORT_NAME("P2 - Stop 3 / Small / Info / Card 1")
1876   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_CODE(KEYCODE_H) PORT_NAME("P2 - Start / Stop All / Card 4")
11201877
11211878   /* to check DIP switches... */
11221879   PORT_START("DSW1")
r4135r4136
12532010   PORT_START("IN0")
12542011   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
12552012   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1256   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 - Stop 2 / Big / Bonus Game / Switch Controls") PORT_CODE(KEYCODE_X)
1257   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("P1 - Blue Bet / D-UP / Card 3")       PORT_CODE(KEYCODE_B)
1258   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P1 - Stop 1 / Take")                  PORT_CODE(KEYCODE_Z)
1259   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("P1 - Red Bet / Card 2")               PORT_CODE(KEYCODE_V)
1260   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("P1 - Stop 3 / Small / Info / Card 1") PORT_CODE(KEYCODE_C)
1261   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("P1 - Start / Stop All / Card 4")      PORT_CODE(KEYCODE_N)
2013   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("P1 - Stop 2 / Big / Bonus Game / Switch Controls")
2014   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("P1 - Blue Bet / D-UP / Card 3")
2015   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("P1 - Stop 1 / Take")
2016   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("P1 - Red Bet / Card 2")
2017   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("P1 - Stop 3 / Small / Info / Card 1")
2018   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("P1 - Start / Stop All / Card 4")
12622019
12632020   PORT_START("IN1")
12642021   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4135r4136
12672024   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
12682025   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
12692026   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
1270   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In") PORT_CODE(KEYCODE_Q)
2027   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
12712028   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
12722029
12732030   PORT_START("IN2")
r4135r4136
12752032   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
12762033   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
12772034   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1278   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key Out / Attendant") PORT_CODE(KEYCODE_W)
2035   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
12792036   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
1280   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Settings") PORT_CODE(KEYCODE_9)
1281   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Stats")    PORT_CODE(KEYCODE_0)
2037   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
2038   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
12822039
12832040   PORT_START("IN3")
12842041   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
12852042   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1286   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON8 )  PORT_NAME("P2 - Stop 2 / Big / Bonus Game / Switch Controls") PORT_CODE(KEYCODE_S)
1287   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_NAME("P2 - Blue Bet / D-UP / Card 3")       PORT_CODE(KEYCODE_G)
1288   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON7 )  PORT_NAME("P2 - Stop 1 / Take")                  PORT_CODE(KEYCODE_A)
1289   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("P2 - Red Bet / Card 2")               PORT_CODE(KEYCODE_F)
1290   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON9 )  PORT_NAME("P2 - Stop 3 / Small / Info / Card 1") PORT_CODE(KEYCODE_D)
1291   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_NAME("P2 - Start / Stop All / Card 4")      PORT_CODE(KEYCODE_H)
2043   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON8 )  PORT_CODE(KEYCODE_S) PORT_NAME("P2 - Stop 2 / Big / Bonus Game / Switch Controls")
2044   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_CODE(KEYCODE_G) PORT_NAME("P2 - Blue Bet / D-UP / Card 3")
2045   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON7 )  PORT_CODE(KEYCODE_A) PORT_NAME("P2 - Stop 1 / Take")
2046   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_CODE(KEYCODE_F) PORT_NAME("P2 - Red Bet / Card 2")
2047   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON9 )  PORT_CODE(KEYCODE_D) PORT_NAME("P2 - Stop 3 / Small / Info / Card 1")
2048   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_CODE(KEYCODE_H) PORT_NAME("P2 - Start / Stop All / Card 4")
12922049
12932050   /* to check DIP switches... */
12942051   PORT_START("DSW1")
r4135r4136
14252182   PORT_START("IN0")   /* d800 */
14262183   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
14272184   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1428   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("P1 - Big / Switch Controls") PORT_CODE(KEYCODE_X)
1429   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("P1 - Double-Up")             PORT_CODE(KEYCODE_B)
1430   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("P1 - Take Score")            PORT_CODE(KEYCODE_Z)
1431   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P1 - Bet")                   PORT_CODE(KEYCODE_V)
1432   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("P1 - Small / Info")          PORT_CODE(KEYCODE_C)
1433   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 - Start")                 PORT_CODE(KEYCODE_N)
2185   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_X) PORT_NAME("P1 - Big / Switch Controls")
2186   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_B) PORT_NAME("P1 - Double-Up")
2187   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_Z) PORT_NAME("P1 - Take Score")
2188   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_V) PORT_NAME("P1 - Bet")
2189   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("P1 - Small / Info")
2190   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_N) PORT_NAME("P1 - Start")
14342191
14352192   PORT_START("IN1")   /* d801 */
14362193   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
14372194   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1438   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_NAME("P2 - Big / Switch Controls") PORT_CODE(KEYCODE_S)
1439   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("P2 - Double-Up")             PORT_CODE(KEYCODE_G)
1440   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_NAME("P2 - Take Score")            PORT_CODE(KEYCODE_A)
1441   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON13 ) PORT_NAME("P2 - Bet")                   PORT_CODE(KEYCODE_F)
1442   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON15 ) PORT_NAME("P2 - Small / Info")          PORT_CODE(KEYCODE_D)
1443   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON14 ) PORT_NAME("P2 - Start")                 PORT_CODE(KEYCODE_H)
2195   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_CODE(KEYCODE_S) PORT_NAME("P2 - Big / Switch Controls")
2196   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_CODE(KEYCODE_G) PORT_NAME("P2 - Double-Up")
2197   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_CODE(KEYCODE_A) PORT_NAME("P2 - Take Score")
2198   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON13 ) PORT_CODE(KEYCODE_F) PORT_NAME("P2 - Bet")
2199   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON15 ) PORT_CODE(KEYCODE_D) PORT_NAME("P2 - Small / Info")
2200   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON14 ) PORT_CODE(KEYCODE_H) PORT_NAME("P2 - Start")
14442201
14452202   PORT_START("IN2")   /* d802 */
14462203   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4135r4136
14592216   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
14602217   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN2)    PORT_IMPULSE(2)   // Coin2?
14612218   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   // Coin3?
1462   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In") PORT_CODE(KEYCODE_Q)
2219   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
14632220   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   // Coin4?
14642221
14652222   PORT_START("IN4")   /* d811 */
r4135r4136
14672224   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
14682225   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
14692226   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1470   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key Out / Attendant") PORT_CODE(KEYCODE_W)
2227   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
14712228   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
1472   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Settings") PORT_CODE(KEYCODE_9)
1473   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Stats")    PORT_CODE(KEYCODE_0)
2229   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
2230   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
14742231
14752232   PORT_START("DSW1")
14762233   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:1")
r4135r4136
15812338   PORT_START("IN0")   /* d800 */
15822339   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
15832340   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1584   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("P1 - Big / Switch Controls") PORT_CODE(KEYCODE_X)
1585   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("P1 - Double-Up")             PORT_CODE(KEYCODE_B)
1586   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("P1 - Take Score")            PORT_CODE(KEYCODE_Z)
1587   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P1 - Bet")                   PORT_CODE(KEYCODE_V)
1588   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("P1 - Small / Info")          PORT_CODE(KEYCODE_C)
1589   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 - Start")                 PORT_CODE(KEYCODE_N)
2341   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_X) PORT_NAME("P1 - Big / Switch Controls")
2342   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_B) PORT_NAME("P1 - Double-Up")
2343   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_Z) PORT_NAME("P1 - Take Score")
2344   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_V) PORT_NAME("P1 - Bet")
2345   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("P1 - Small / Info")
2346   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_N) PORT_NAME("P1 - Start")
15902347
15912348   PORT_START("IN1")   /* d801 */
15922349   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
15932350   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1594   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_NAME("P2 - Big / Switch Controls") PORT_CODE(KEYCODE_S)
1595   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("P2 - Double-Up")             PORT_CODE(KEYCODE_G)
1596   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_NAME("P2 - Take Score")            PORT_CODE(KEYCODE_A)
1597   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON13 ) PORT_NAME("P2 - Bet")                   PORT_CODE(KEYCODE_F)
1598   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON15 ) PORT_NAME("P2 - Small / Info")          PORT_CODE(KEYCODE_D)
1599   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON14 ) PORT_NAME("P2 - Start")                 PORT_CODE(KEYCODE_H)
2351   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_CODE(KEYCODE_S) PORT_NAME("P2 - Big / Switch Controls")
2352   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_CODE(KEYCODE_G) PORT_NAME("P2 - Double-Up")
2353   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_CODE(KEYCODE_A) PORT_NAME("P2 - Take Score")
2354   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON13 ) PORT_CODE(KEYCODE_F) PORT_NAME("P2 - Bet")
2355   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON15 ) PORT_CODE(KEYCODE_D) PORT_NAME("P2 - Small / Info")
2356   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON14 ) PORT_CODE(KEYCODE_H) PORT_NAME("P2 - Start")
16002357
16012358   PORT_START("IN2")   /* d802 */
16022359   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4135r4136
16152372   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
16162373   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN2)    PORT_IMPULSE(2)   // Coin2?
16172374   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   // Coin3?
1618   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In") PORT_CODE(KEYCODE_Q)
2375   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
16192376   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   // Coin4?
16202377
16212378   PORT_START("IN4")   /* d811 */
r4135r4136
16232380   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
16242381   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
16252382   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1626   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key Out / Attendant") PORT_CODE(KEYCODE_W)
2383   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out / Attendant")
16272384   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
1628   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Settings") PORT_CODE(KEYCODE_9)
1629   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Stats")    PORT_CODE(KEYCODE_0)
2385   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
2386   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
16302387
16312388   PORT_START("DSW1")
16322389   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:1")
r4135r4136
16762433   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW2:7")
16772434   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
16782435   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1679   PORT_DIPNAME( 0x80, 0x80, "W-UP Type" )   PORT_DIPLOCATION("DSW2:8")
2436   PORT_DIPNAME( 0x80, 0x80, "W-UP Type" )         PORT_DIPLOCATION("DSW2:8")
16802437   PORT_DIPSETTING(    0x80, "Reels (automatic)" )
16812438   PORT_DIPSETTING(    0x00, "Cards (Big/Small)" )
16822439
r4135r4136
17332490   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
17342491INPUT_PORTS_END
17352492
2493static INPUT_PORTS_START( ladylinr )
2494   PORT_START("IN0")
2495   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
2496   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
2497   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
2498   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
2499   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN2 )   PORT_IMPULSE(2)
2500   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3 )   PORT_IMPULSE(2)
2501   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In") PORT_CODE(KEYCODE_Q)
2502   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )   PORT_IMPULSE(2)
17362503
2504   PORT_START("IN1")
2505   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
2506   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
2507   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_H) PORT_NAME("Hopper Muenze (Hopper Coin")
2508   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_J) PORT_NAME("Hopper Voll (Hopper Fill)")
2509   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
2510   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Abschreib (Payout)")
2511   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Aufsteller (Supervisor)")
2512   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Buchhaltung (Bookkeeping)")
17372513
2514   PORT_START("IN2")
2515   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
2516   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
2517   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Hoch (High) / Stop 3")
2518   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Gamble (D-UP)")
2519   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_N) PORT_NAME("Nehmen (Take)")
2520   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("Setzen (Bet)")
2521   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Tief (Low) / Stop 1 / Info")
2522   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Start / Stop 2")
2523
2524   PORT_START("DSW1")
2525   PORT_DIPNAME( 0x03, 0x03, "Remote Credits" )   PORT_DIPLOCATION("DSW1:1,2")   /* OK */
2526   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
2527   PORT_DIPSETTING(    0x01, "10" )
2528   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2529   PORT_DIPSETTING(    0x03, "100" )
2530   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:3")
2531   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
2532   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2533   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:4")
2534   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2535   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2536   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Coin_A ) )   PORT_DIPLOCATION("DSW1:5")   /* OK */
2537   PORT_DIPSETTING(    0x00, "20 credits" )
2538   PORT_DIPSETTING(    0x10, "50 Credits" )
2539   PORT_DIPNAME( 0x20, 0x20, "Coin B & C" )      PORT_DIPLOCATION("DSW1:6")   /* OK */
2540   PORT_DIPSETTING(    0x00, "10 credits" )
2541   PORT_DIPSETTING(    0x20, "20 credits" )
2542   PORT_DIPNAME( 0x40, 0x40, "Reels Speed" )      PORT_DIPLOCATION("DSW1:7")   /* OK */
2543   PORT_DIPSETTING(    0x40, DEF_STR( Normal ) )
2544   PORT_DIPSETTING(    0x00, DEF_STR( High ) )
2545   PORT_DIPNAME( 0x80, 0x00, "Input Test Mode" )   PORT_DIPLOCATION("DSW1:8")   /* OK */
2546   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
2547   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
2548
2549/*  there are 2 extra DSW banks...
2550    both are tied to a daughterboard, maybe hooked to a device.
2551    they are not related to the original hardware, and are not
2552    listed in the Input Test Mode.
2553*/
2554INPUT_PORTS_END
2555
2556static INPUT_PORTS_START( kkojnoli )
2557   PORT_START("IN0")   /* d800 */
2558   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
2559   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
2560   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_X) PORT_NAME("P1 - Big / Switch Controls")
2561   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_B) PORT_NAME("P1 - Double-Up")
2562   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_Z) PORT_NAME("P1 - Take Score")
2563   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_V) PORT_NAME("P1 - Bet")
2564   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("P1 - Small / Info")
2565   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_N) PORT_NAME("P1 - Start")
2566
2567   PORT_START("IN1")   /* d801 */
2568   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
2569   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
2570   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_CODE(KEYCODE_S) PORT_NAME("P2 - Big / Switch Controls")
2571   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_CODE(KEYCODE_G) PORT_NAME("P2 - Double-Up")
2572   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_CODE(KEYCODE_A) PORT_NAME("P2 - Take Score")
2573   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON13 ) PORT_CODE(KEYCODE_F) PORT_NAME("P2 - Bet")
2574   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON15 ) PORT_CODE(KEYCODE_D) PORT_NAME("P2 - Small / Info")
2575   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON14 ) PORT_CODE(KEYCODE_H) PORT_NAME("P2 - Start")
2576
2577   PORT_START("IN2")   /* d802 */
2578   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
2579   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
2580   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
2581   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
2582   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
2583   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
2584   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2585   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2586
2587   PORT_START("IN3")   /* d810 */
2588   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
2589   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
2590   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   // Coin1?
2591   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
2592   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN2)    PORT_IMPULSE(2)   // Coin2?
2593   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   // Coin3?
2594   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
2595   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   // Coin4?
2596
2597   PORT_START("IN4")   /* d811 */
2598   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
2599   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
2600   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
2601   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
2602   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
2603   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
2604   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2605   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2606
2607   PORT_START("DSW1")
2608   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:1")
2609   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
2610   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2611   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:2")
2612   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2613   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2614   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:3")
2615   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
2616   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2617   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:4")
2618   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2619   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2620   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:5")
2621   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2622   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2623   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:6")
2624   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2625   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2626   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:7")
2627   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2628   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2629   PORT_DIPNAME( 0x80, 0x00, "W-UP Type" )         PORT_DIPLOCATION("DSW1:8")
2630   PORT_DIPSETTING(    0x80, "Reels (automatic)" )
2631   PORT_DIPSETTING(    0x00, "Flowers (Big/Small)" )
2632
2633INPUT_PORTS_END
2634
2635
2636
17382637static const gfx_layout charlayout =
17392638{
17402639   8,8,    /* 8*8 characters */
r4135r4136
18292728   32*8
18302729};
18312730
2731static const UINT32 layout_xoffset[128] =
2732{
2733   STEP32(0*128,4),STEP32(1*128,4),STEP32(2*128,4),STEP32(3*128,4)
2734};
2735
2736static const UINT32 layout_yoffset[128] =
2737{
2738   STEP32(0*16384, 512),STEP32(1*16384,512),STEP32(2*16384,512),STEP32(3*16384,512)
2739};
2740
2741static const gfx_layout tiles128x128x4_layout =
2742{
2743   128,128,
2744   RGN_FRAC(1,1),
2745   4,
2746   { 0, 1, 2, 3 },
2747   EXTENDED_XOFFS,
2748   EXTENDED_YOFFS,
2749   4 * 16384, /* object takes 8 consecutive bytes */
2750   layout_xoffset,
2751   layout_yoffset
2752};
2753
2754
2755static const UINT32 layout_xoffset256[256] =
2756{
2757   STEP32(0*128,4),STEP32(1*128,4),STEP32(2*128,4),STEP32(3*128,4), STEP32(4*128,4), STEP32(5*128,4), STEP32(6*128,4), STEP32(7*128,4)
2758};
2759
2760static const UINT32 layout_yoffset256[256] =
2761{
2762   STEP32(0*32768, 1024),STEP32(1*32768,1024),STEP32(2*32768,1024),STEP32(3*32768,1024),STEP32(4*32768,1024), STEP32(5*32768,1024),STEP32(6*32768,1024),STEP32(7*32768,1024)
2763};
2764
2765
2766static const gfx_layout tiles256x128x4_layout =
2767{
2768   256,256,
2769   RGN_FRAC(1,1),
2770   4,
2771   { 0, 1, 2, 3 },
2772   EXTENDED_XOFFS,
2773   EXTENDED_YOFFS,
2774   8 * 32768, /* object takes 8 consecutive bytes */
2775   layout_xoffset256,
2776   layout_yoffset256
2777};
2778
18322779#if 0 // decodes an extra plane for cmv4 / cmasterb, not sure if we need to
18332780static const gfx_layout tiles8x32x5_layout =
18342781{
r4135r4136
18712818   GFXDECODE_ENTRY( "gfx2", 0, tiles8x32x4_layout, 128, 4 )
18722819GFXDECODE_END
18732820
1874static GFXDECODE_START( cmv801 )
2821static GFXDECODE_START( cm )
18752822   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8x3_layout, 0, 16 )
18762823   GFXDECODE_ENTRY( "gfx2", 0, tiles8x32x4_layout, 128+64, 4 ) // or is there a register for the +64?
18772824GFXDECODE_END
18782825
2826static GFXDECODE_START( cmbitmap )
2827   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8x3_layout, 0, 16 )
2828   GFXDECODE_ENTRY( "gfx2", 0, tiles8x32x4_layout, 128+64, 4 ) // or is there a register for the +64?
2829   GFXDECODE_ENTRY( "user1", 0, tiles128x128x4_layout, 128, 4 )
2830GFXDECODE_END
2831
2832static GFXDECODE_START( cmast91 )
2833   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8x3_layout, 0, 16 )
2834   GFXDECODE_ENTRY( "gfx2", 0, tiles8x32x4_layout, 128+64, 4 ) // or is there a register for the +64?
2835   GFXDECODE_ENTRY( "user1", 0, tiles256x128x4_layout, 128, 4 ) // wrong... FIXME.
2836GFXDECODE_END
2837
18792838#if 0 // decodes an extra plane for cmv4 / cmasterb, not sure if we need to
18802839static GFXDECODE_START( cmasterb )
18812840   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8x3_layout, 0, 16 )
r4135r4136
19642923   }
19652924};
19662925
2926static const ppi8255_interface kkojnoli_ppi8255_intf[3] =
2927{
2928   {   /* A, B & C set as input */
2929      DEVICE8_PORT("IN0"),   /* Port A read */
2930      DEVICE8_PORT("IN1"),   /* Port B read */
2931      DEVICE8_PORT("IN2"),   /* Port C read */
2932      NULL,               /* Port A write */
2933      NULL,               /* Port B write */
2934      NULL               /* Port C write */
2935   },
2936   {   /* A, B & C set as input */
2937      DEVICE8_PORT("IN3"),   /* Port A read */
2938      DEVICE8_PORT("IN4"),   /* Port B read */
2939      NULL,               /* Port C read */
2940      NULL,               /* Port A write */
2941      NULL,               /* Port B write */
2942      NULL               /* Port C write */
2943   },
2944   {   /* A set as input */
2945      DEVICE8_PORT("DSW1"),   /* Port A read */
2946      NULL,               /* Port B read */
2947      NULL,               /* Port C read */
2948      NULL,               /* Port A write */
2949      NULL,               /* Port B write */
2950      NULL               /* Port C write */
2951   }
2952};
2953
2954static const ppi8255_interface ladylinr_ppi8255_intf[2] =
2955{
2956   {   /* A, B & C set as input */
2957      DEVICE8_PORT("IN0"),   /* Port A read */
2958      DEVICE8_PORT("IN1"),   /* Port B read */
2959      DEVICE8_PORT("IN2"),   /* Port C read */
2960      NULL,               /* Port A write */
2961      NULL,               /* Port B write */
2962      NULL               /* Port C write */
2963   },
2964   {   /* A set as input */
2965      DEVICE8_PORT("DSW1"),   /* Port A read */
2966      NULL,               /* Port B read */
2967      NULL,               /* Port C read */
2968      NULL,               /* Port A write */
2969      NULL,               /* Port B write */
2970      NULL               /* Port C write */
2971   }
2972};
2973
19672974static const ay8910_interface ay8910_config =
19682975{
19692976   AY8910_LEGACY_OUTPUT,
r4135r4136
19943001   NULL
19953002};
19963003
3004static const ay8910_interface ladylinr_ay8910_config =
3005{
3006   AY8910_LEGACY_OUTPUT,
3007   AY8910_DEFAULT_LOADS,
3008   NULL,
3009   NULL,
3010   NULL,
3011   NULL
3012};
3013
19973014static MACHINE_DRIVER_START( goldstar )
19983015
19993016   /* basic machine hardware */
2000   MDRV_CPU_ADD("main", Z80, 3579545)//(4000000?)
3017   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
20013018   MDRV_CPU_PROGRAM_MAP(goldstar_map,0)
20023019   MDRV_CPU_IO_MAP(goldstar_readport,0)
20033020   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
r4135r4136
20183035   MDRV_VIDEO_UPDATE(goldstar)
20193036
20203037   /* sound hardware */
2021   MDRV_SPEAKER_STANDARD_MONO("mono")//set up a standard mono speaker called 'mono'
2022   MDRV_SOUND_ADD("ay", AY8910,1500000)//1 AY8910, at clock 150000Hz
2023   MDRV_SOUND_CONFIG(ay8910_config)//read extra data from interface
2024   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)//all sound goes to the 'mono' speaker, at 0.50 X maximum
3038   MDRV_SPEAKER_STANDARD_MONO("mono")
3039   MDRV_SOUND_ADD("ay", AY8910, AY_CLOCK)
3040   MDRV_SOUND_CONFIG(ay8910_config)
3041   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
20253042
2026   MDRV_SOUND_ADD("oki", OKIM6295, 1056000)//clock
2027   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified //"oki"
2028   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)//all sound goes to the 'mono' speaker, at 1.0 X maximum
3043   MDRV_SOUND_ADD("oki", OKIM6295, OKI_CLOCK)
3044   MDRV_SOUND_CONFIG(okim6295_interface_pin7high)   /* clock frequency & pin 7 not verified */
3045   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
20293046
20303047MACHINE_DRIVER_END
20313048
r4135r4136
20333050static MACHINE_DRIVER_START( goldstbl )
20343051
20353052   /* basic machine hardware */
2036   MDRV_CPU_ADD("main", Z80, 3579545)//(4000000?)
3053   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
20373054   MDRV_CPU_PROGRAM_MAP(goldstar_map,0)
20383055   MDRV_CPU_IO_MAP(goldstar_readport,0)
20393056   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
r4135r4136
20543071   MDRV_VIDEO_UPDATE(goldstar)
20553072
20563073   /* sound hardware */
2057   MDRV_SPEAKER_STANDARD_MONO("mono")//set up a standard mono speaker called 'mono'
2058   MDRV_SOUND_ADD("ay", AY8910,1500000)//1 AY8910, at clock 150000Hz
2059   MDRV_SOUND_CONFIG(ay8910_config)//read extra data from interface
2060   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)//all sound goes to the 'mono' speaker, at 0.50 X maximum
3074   MDRV_SPEAKER_STANDARD_MONO("mono")
3075   MDRV_SOUND_ADD("ay", AY8910, AY_CLOCK)
3076   MDRV_SOUND_CONFIG(ay8910_config)
3077   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
20613078
2062   MDRV_SOUND_ADD("oki", OKIM6295, 1056000)//clock
2063   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified //"oki"
2064   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)//all sound goes to the 'mono' speaker, at 1.0 X maximum
3079   MDRV_SOUND_ADD("oki", OKIM6295, OKI_CLOCK)
3080   MDRV_SOUND_CONFIG(okim6295_interface_pin7high)   /* clock frequency & pin 7 not verified */
3081   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
20653082MACHINE_DRIVER_END
20663083
20673084
20683085static MACHINE_DRIVER_START( moonlght )
20693086
20703087   /* basic machine hardware */
2071   MDRV_CPU_ADD("main", Z80, 3579545)//(4000000?)
3088   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
20723089   MDRV_CPU_PROGRAM_MAP(goldstar_map,0)
20733090   MDRV_CPU_IO_MAP(goldstar_readport,0)
20743091   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
r4135r4136
20893106   MDRV_VIDEO_UPDATE(goldstar)
20903107
20913108   /* sound hardware */
2092   MDRV_SPEAKER_STANDARD_MONO("mono")//set up a standard mono speaker called 'mono'
2093   MDRV_SOUND_ADD("ay", AY8910,1500000)//1 AY8910, at clock 150000Hz
2094   MDRV_SOUND_CONFIG(ay8910_config)//read extra data from interface
2095   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)//all sound goes to the 'mono' speaker, at 0.50 X maximum
3109   MDRV_SPEAKER_STANDARD_MONO("mono")
3110   MDRV_SOUND_ADD("ay", AY8910, AY_CLOCK)
3111   MDRV_SOUND_CONFIG(ay8910_config)
3112   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
20963113
2097   MDRV_SOUND_ADD("oki", OKIM6295, 1056000)//clock
2098   MDRV_SOUND_CONFIG(okim6295_interface_pin7high)// clock frequency & pin 7 not verified //"oki"
2099   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)//all sound goes to the 'mono' speaker, at 1.0 X maximum
3114   MDRV_SOUND_ADD("oki", OKIM6295, OKI_CLOCK)
3115   MDRV_SOUND_CONFIG(okim6295_interface_pin7high)   /* clock frequency & pin 7 not verified */
3116   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
21003117MACHINE_DRIVER_END
21013118
21023119
21033120static PALETTE_INIT(cm)
21043121{
3122   /* BBGGGRRR */
3123
21053124   int i;
2106   for (i=0;i<0x100;i++)
3125
3126   for (i = 0; i < 0x100; i++)
21073127   {
2108      int r,g,b;
2109      UINT8 dat;
2110
3128      UINT8 data;
21113129      UINT8*proms = memory_region(machine, "proms");
21123130
2113      dat = proms[0x000+i] | (proms[0x100+i]<<4);
3131      data = proms[0x000 + i] | (proms[0x100 + i] << 4);
21143132
2115      r = (dat & 0x07) << 5;
2116      g = (dat & 0x38) << 2;
2117      b = (dat & 0xc0) << 0;
3133      palette_set_color_rgb(machine, i, pal3bit(data >> 0), pal3bit(data >> 3), pal2bit(data >> 6));
21183134
2119      palette_set_color(machine, i, MAKE_RGB(r, g, b));
2120
21213135   }
21223136}
21233137
21243138static PALETTE_INIT(cmast91)
21253139{
21263140   int i;
2127   for (i=0;i<0x100;i++)
3141   for (i = 0; i < 0x100; i++)
21283142   {
21293143      int r,g,b;
21303144
21313145      UINT8*proms = memory_region(machine, "proms");
21323146
2133      b = proms[0x000+i]<<4;
2134      g = proms[0x100+i]<<4;
2135      r = proms[0x200+i]<<4;
3147      b = proms[0x000 + i] << 4;
3148      g = proms[0x100 + i] << 4;
3149      r = proms[0x200 + i] << 4;
21363150
21373151      palette_set_color(machine, i, MAKE_RGB(r, g, b));
2138
21393152   }
21403153}
21413154
21423155static PALETTE_INIT(lucky8)
21433156{
3157   /* BBGGGRRR */
3158
21443159   int i;
2145   int r,g,b;
2146   UINT8 dat;
3160   UINT8 data;
21473161   UINT8 *proms;
21483162
21493163   proms = memory_region(machine, "proms");
2150   for (i=0;i<0x100;i++)
3164   for (i = 0; i < 0x100; i++)
21513165   {
21523166
2153      dat = proms[0x000+i] | (proms[0x100+i]<<4);
3167      data = proms[0x000 + i] | (proms[0x100 + i] << 4);
21543168
2155      r = (dat & 0x07) << 5;
2156      g = (dat & 0x38) << 2;
2157      b = (dat & 0xc0) << 0;
2158
2159      palette_set_color(machine, i, MAKE_RGB(r, g, b));
2160
3169      palette_set_color_rgb(machine, i, pal3bit(data >> 0), pal3bit(data >> 3), pal2bit(data >> 6));
21613170   }
21623171
21633172   proms = memory_region(machine, "proms2");
2164   for (i=0;i<0x20;i++)
3173   for (i=0; i < 0x20; i++)
21653174   {
2166      dat = proms[i];
3175      data = proms[i];
21673176
2168      r = (dat & 0x07) << 5;
2169      g = (dat & 0x38) << 2;
2170      b = (dat & 0xc0) << 0;
2171
2172      palette_set_color(machine, i+0x80, MAKE_RGB(r, g, b));
3177      palette_set_color_rgb(machine, i + 0x80, pal3bit(data >> 0), pal3bit(data >> 3), pal2bit(data >> 6));
21733178   }
2174
21753179}
21763180
21773181
21783182static MACHINE_DRIVER_START( chrygld )
21793183
21803184   /* basic machine hardware */
2181   MDRV_CPU_ADD("main", Z80, 3579545)//(4000000?)
3185   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
21823186   MDRV_CPU_PROGRAM_MAP(ncb3_map,0)
21833187   MDRV_CPU_IO_MAP(ncb3_readwriteport,0)
21843188   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
r4135r4136
22073211   /* sound hardware */
22083212   MDRV_SPEAKER_STANDARD_MONO("mono")
22093213
2210   MDRV_SOUND_ADD("sn1", SN76489, 3000000)   /* 3 MHz. */
3214   MDRV_SOUND_ADD("sn1", SN76489, PSG_CLOCK)
22113215   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
22123216
2213   MDRV_SOUND_ADD("ay", AY8910,1500000)
3217   MDRV_SOUND_ADD("ay", AY8910, AY_CLOCK)
22143218   MDRV_SOUND_CONFIG(ay8910_config)
22153219   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
22163220MACHINE_DRIVER_END
r4135r4136
22203224static MACHINE_DRIVER_START( ncb3 )
22213225
22223226   /* basic machine hardware */
2223   MDRV_CPU_ADD("main", Z80, 3579545)//(4000000?)
3227   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
22243228   MDRV_CPU_PROGRAM_MAP(ncb3_map,0)
22253229   MDRV_CPU_IO_MAP(ncb3_readwriteport,0)
22263230   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
r4135r4136
22503254   /* sound hardware */
22513255   MDRV_SPEAKER_STANDARD_MONO("mono")
22523256
2253   MDRV_SOUND_ADD("sn1", SN76489, 3000000)   /* 3 MHz. */
3257   MDRV_SOUND_ADD("sn1", SN76489, PSG_CLOCK)
22543258   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
22553259
2256   MDRV_SOUND_ADD("ay", AY8910,1500000)
3260   MDRV_SOUND_ADD("ay", AY8910, AY_CLOCK)
22573261   MDRV_SOUND_CONFIG(ay8910_config)
22583262   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
22593263MACHINE_DRIVER_END
r4135r4136
22623266static MACHINE_DRIVER_START( cm )
22633267
22643268   /* basic machine hardware */
2265   MDRV_CPU_ADD("main", Z80, 3579545)//(4000000?)
3269   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
22663270   MDRV_CPU_PROGRAM_MAP(cm_map,0)
22673271   MDRV_CPU_IO_MAP(cm_portmap,0)
22683272   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
22693273
22703274   /* 2x 8255 */
2271   MDRV_PPI8255_ADD( "cm_ppi8255_0", cm_ppi8255_intf[0] )
2272   MDRV_PPI8255_ADD( "cm_ppi8255_1", cm_ppi8255_intf[1] )
3275   MDRV_PPI8255_ADD( "ppi8255_0", cm_ppi8255_intf[0] )
3276   MDRV_PPI8255_ADD( "ppi8255_1", cm_ppi8255_intf[1] )
22733277
22743278   /* video hardware */
22753279   MDRV_SCREEN_ADD("main", RASTER)
r4135r4136
22793283   MDRV_SCREEN_SIZE(64*8, 32*8)
22803284   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 2*8, 30*8-1)
22813285
2282   MDRV_GFXDECODE(cmv801)
3286   MDRV_GFXDECODE(cmbitmap)
22833287   MDRV_PALETTE_LENGTH(256)
22843288   MDRV_PALETTE_INIT(cm)
22853289   MDRV_NVRAM_HANDLER(goldstar)
r4135r4136
22893293
22903294   /* sound hardware */
22913295   MDRV_SPEAKER_STANDARD_MONO("mono")
2292   MDRV_SOUND_ADD("ay", AY8910,1500000)
3296   MDRV_SOUND_ADD("ay", AY8910, AY_CLOCK)
22933297   MDRV_SOUND_CONFIG(cm_ay8910_config)
22943298   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
22953299MACHINE_DRIVER_END
22963300
2297static MACHINE_DRIVER_START( cmast91 )
3301static MACHINE_DRIVER_START( cmnobmp )
22983302
22993303   /* basic machine hardware */
2300   MDRV_CPU_ADD("main", Z80, 3000000)//(4000000?)
3304   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
23013305   MDRV_CPU_PROGRAM_MAP(cm_map,0)
2302   MDRV_CPU_IO_MAP(cmast91_portmap,0)
3306   MDRV_CPU_IO_MAP(cm_portmap,0)
23033307   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
23043308
23053309   /* 2x 8255 */
2306   MDRV_PPI8255_ADD( "cm_ppi8255_0", cm_ppi8255_intf[0] )
2307   MDRV_PPI8255_ADD( "cm_ppi8255_1", cm_ppi8255_intf[1] )
3310   MDRV_PPI8255_ADD( "ppi8255_0", cm_ppi8255_intf[0] )
3311   MDRV_PPI8255_ADD( "ppi8255_1", cm_ppi8255_intf[1] )
23083312
23093313   /* video hardware */
23103314   MDRV_SCREEN_ADD("main", RASTER)
r4135r4136
23123316//  MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
23133317   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
23143318   MDRV_SCREEN_SIZE(64*8, 32*8)
2315   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 1*8, 31*8-1)
3319   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 2*8, 30*8-1)
23163320
2317   MDRV_GFXDECODE(cmv801)
3321   MDRV_GFXDECODE(cm)
23183322   MDRV_PALETTE_LENGTH(256)
2319   MDRV_PALETTE_INIT(cmast91)
3323   MDRV_PALETTE_INIT(cm)
23203324   MDRV_NVRAM_HANDLER(goldstar)
23213325
23223326   MDRV_VIDEO_START(cherrym)
23233327   MDRV_VIDEO_UPDATE(goldstar)
23243328
23253329   /* sound hardware */
2326   MDRV_SPEAKER_STANDARD_MONO("mono")//set up a standard mono speaker called 'mono'
2327   MDRV_SOUND_ADD("ay", AY8910,1500000)//1 AY8910, at clock 150000Hz
2328   MDRV_SOUND_CONFIG(ay8910_config)//read extra data from interface
2329   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)//all sound goes to the 'mono' speaker, at 0.50 X maximum
3330   MDRV_SPEAKER_STANDARD_MONO("mono")
3331   MDRV_SOUND_ADD("ay", AY8910, AY_CLOCK)
3332   MDRV_SOUND_CONFIG(cm_ay8910_config)
3333   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
23303334MACHINE_DRIVER_END
23313335
2332#if 0 // not currently used, might be needed later
2333static MACHINE_DRIVER_START( cmb )
3336static MACHINE_DRIVER_START( cmast91 )
23343337
23353338   /* basic machine hardware */
2336   MDRV_CPU_ADD("main", Z80, 3579545)//(4000000?)
3339   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
23373340   MDRV_CPU_PROGRAM_MAP(cm_map,0)
2338   MDRV_CPU_IO_MAP(cm_portmap,0)
3341   MDRV_CPU_IO_MAP(cmast91_portmap,0)
23393342   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
23403343
3344   /* 2x 8255 */
3345   MDRV_PPI8255_ADD( "ppi8255_0", cm_ppi8255_intf[0] )
3346   MDRV_PPI8255_ADD( "ppi8255_1", cm_ppi8255_intf[1] )
3347
23413348   /* video hardware */
23423349   MDRV_SCREEN_ADD("main", RASTER)
23433350   MDRV_SCREEN_REFRESH_RATE(60)
23443351//  MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
23453352   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
23463353   MDRV_SCREEN_SIZE(64*8, 32*8)
2347   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 2*8, 30*8-1)
3354   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 1*8, 31*8-1)
23483355
2349   MDRV_GFXDECODE(cmasterb)
3356   MDRV_GFXDECODE(cmast91)
23503357   MDRV_PALETTE_LENGTH(256)
2351   MDRV_PALETTE_INIT(cm)
2352//  MDRV_NVRAM_HANDLER(goldstar)
3358   MDRV_PALETTE_INIT(cmast91)
3359   MDRV_NVRAM_HANDLER(goldstar)
23533360
23543361   MDRV_VIDEO_START(cherrym)
2355   MDRV_VIDEO_UPDATE(goldstar)
3362   MDRV_VIDEO_UPDATE(cmast91)
23563363
23573364   /* sound hardware */
2358   MDRV_SPEAKER_STANDARD_MONO("mono")//set up a standard mono speaker called 'mono'
2359   MDRV_SOUND_ADD("ay", AY8910,1500000)//1 AY8910, at clock 150000Hz
2360   MDRV_SOUND_CONFIG(ay8910_config)//read extra data from interface
2361   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)//all sound goes to the 'mono' speaker, at 0.50 X maximum
2362
2363   MDRV_SOUND_ADD("oki", OKIM6295, 1056000)//clock
2364   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified //"oki"
2365   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)//all sound goes to the 'mono' speaker, at 1.0 X maximum
3365   MDRV_SPEAKER_STANDARD_MONO("mono")
3366   MDRV_SOUND_ADD("ay", AY8910, AY_CLOCK)
3367   MDRV_SOUND_CONFIG(cm_ay8910_config)
3368   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
23663369MACHINE_DRIVER_END
2367#endif
23683370
2369
23703371static MACHINE_DRIVER_START( lucky8 )
23713372
23723373   /* basic machine hardware */
2373   MDRV_CPU_ADD("main", Z80, 12000000/3) // ?? Mhz
3374   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
23743375   MDRV_CPU_PROGRAM_MAP(lucky8_map,0)
23753376   //MDRV_CPU_IO_MAP(goldstar_readport,0)
23763377   MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
r4135r4136
23973398   MDRV_VIDEO_UPDATE(goldstar)
23983399
23993400   /* sound hardware */
2400   MDRV_SPEAKER_STANDARD_MONO("mono")//set up a standard mono speaker called 'mono'
3401   MDRV_SPEAKER_STANDARD_MONO("mono")
24013402
2402   MDRV_SOUND_ADD("sn1", SN76489, 3000000)   /* 3 MHz. */
3403   MDRV_SOUND_ADD("sn1", SN76489, PSG_CLOCK)
24033404   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
24043405
2405   MDRV_SOUND_ADD("ay", AY8910,1500000)
3406   MDRV_SOUND_ADD("ay", AY8910, AY_CLOCK)
24063407   MDRV_SOUND_CONFIG(lucky8_ay8910_config)
24073408   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
24083409
24093410MACHINE_DRIVER_END
24103411
24113412
3413static MACHINE_DRIVER_START( kkojnoli )
24123414
3415   /* basic machine hardware */
3416   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
3417   MDRV_CPU_PROGRAM_MAP(kkojnoli_map,0)
3418   //MDRV_CPU_IO_MAP(goldstar_readport,0)
3419   MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
3420
3421   /* 3x 8255 */
3422   MDRV_PPI8255_ADD( "ppi8255_0", kkojnoli_ppi8255_intf[0] )
3423   MDRV_PPI8255_ADD( "ppi8255_1", kkojnoli_ppi8255_intf[1] )
3424   MDRV_PPI8255_ADD( "ppi8255_2", kkojnoli_ppi8255_intf[2] )
3425
3426   /* video hardware */
3427   MDRV_SCREEN_ADD("main", RASTER)
3428   MDRV_SCREEN_REFRESH_RATE(60)
3429//  MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
3430   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
3431   MDRV_SCREEN_SIZE(64*8, 32*8)
3432   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 2*8, 30*8-1)
3433   MDRV_PALETTE_INIT(lucky8)
3434
3435   MDRV_GFXDECODE(ncb3)
3436   MDRV_PALETTE_LENGTH(256)
3437
3438   MDRV_VIDEO_START(goldstar)
3439   MDRV_VIDEO_UPDATE(goldstar)
3440
3441   /* sound hardware */
3442   MDRV_SPEAKER_STANDARD_MONO("mono")
3443
3444   MDRV_SOUND_ADD("sn1", SN76489, PSG_CLOCK)
3445   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
3446
3447MACHINE_DRIVER_END
3448
3449
3450static MACHINE_DRIVER_START( ladylinr )
3451
3452   /* basic machine hardware */
3453   MDRV_CPU_ADD("main", Z80, CPU_CLOCK)
3454   MDRV_CPU_PROGRAM_MAP(ladylinr_map,0)
3455   //MDRV_CPU_IO_MAP(goldstar_readport,0)
3456   MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
3457
3458   /* 2x 8255 */
3459   MDRV_PPI8255_ADD( "ppi8255_0", ladylinr_ppi8255_intf[0] )
3460   MDRV_PPI8255_ADD( "ppi8255_1", ladylinr_ppi8255_intf[1] )
3461
3462   /* video hardware */
3463   MDRV_SCREEN_ADD("main", RASTER)
3464   MDRV_SCREEN_REFRESH_RATE(60)
3465//  MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
3466   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
3467   MDRV_SCREEN_SIZE(64*8, 32*8)
3468   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 2*8, 30*8-1)
3469   MDRV_PALETTE_INIT(lucky8)
3470
3471   MDRV_GFXDECODE(ncb3)
3472   MDRV_PALETTE_LENGTH(256)
3473   MDRV_NVRAM_HANDLER(goldstar)
3474
3475   MDRV_VIDEO_START(goldstar)
3476   MDRV_VIDEO_UPDATE(goldstar)
3477
3478   /* sound hardware */
3479   MDRV_SPEAKER_STANDARD_MONO("mono")//set up a standard mono speaker called 'mono'
3480
3481   MDRV_SOUND_ADD("sn1", SN76489, PSG_CLOCK)
3482   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
3483
3484   MDRV_SOUND_ADD("ay", AY8910, AY_CLOCK)
3485   MDRV_SOUND_CONFIG(ladylinr_ay8910_config)
3486   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
3487
3488MACHINE_DRIVER_END
3489
3490
3491
24133492/***************************************************************************
24143493
24153494  Game driver(s)
r4135r4136
26843763   ROM_LOAD( "m1.64",     0x4000, 0x2000, CRC(6dfcb188) SHA1(22430429c798954d9d979e62699b58feae7fdbf4) )
26853764   ROM_LOAD( "m2.64",     0x6000, 0x2000, CRC(9678ead2) SHA1(e80aefa98b2363fe9e6b2415762695ace272e4d3) )
26863765
3766   ROM_REGION( 0x10000, "user1", ROMREGION_DISPOSE )
3767   ROM_LOAD( "27512.u53",  0x0000, 0x10000, NO_DUMP )
3768
26873769   ROM_REGION( 0x200, "proms", 0 ) // pal
26883770   ROM_LOAD( "prom2.287", 0x0000, 0x0100, CRC(0489b760) SHA1(78f8632b17a76335183c5c204cdec856988368b0) )
26893771   ROM_LOAD( "prom3.287", 0x0100, 0x0100, CRC(21eb5b19) SHA1(9b8425bdb97f11f4855c998c7792c3291fd07470) )
r4135r4136
27693851   ROM_LOAD( "82s129.u46", 0x0000, 0x0100, CRC(50ec383b) SHA1(ae95b92bd3946b40134bcdc22708d5c6b0f4c23e) )
27703852ROM_END
27713853
3854/*
27723855
3856cmv4 vs. fruit2
3857
385812 and 12 files
385982s129.u46                                      FIXED BITS (0000x0xx)
386082s129.u46                                      BADADDR                xxxxxxx-
386182s129.u70                                      FIXED BITS (0000xxxx)
386282s129.u84                                      FIXED BITS (0000xxxx)
3863                        HOLD8_PR1.U46           FIXED BITS (0000x0xx)
3864                        HOLD8_PR1.U46           BADADDR                xxxxxxx-
3865                        HOLD8_PR2.U84           FIXED BITS (0000xxxx)
3866                        HOLD8_PR3.U79           FIXED BITS (0000xxxx)
3867                        TETRIS_5.U4             1ST AND 2ND HALF IDENTICAL
3868                        TETRIS_6.U11            1ST AND 2ND HALF IDENTICAL
3869                        TETRIS_7.U16            1ST AND 2ND HALF IDENTICAL
38702764.u10                HOLDX8_3.U10            IDENTICAL
38712764.u14                HOLDX8_2.U14            IDENTICAL
38722764.u15                HOLDX8_4.U15            IDENTICAL
387382s129.u46              HOLD8_PR1.U46            IDENTICAL
387427512.u53               HOLDX8_8.U53            IDENTICAL
387582s129.u70              HOLD8_PR3.U79            IDENTICAL
387682s129.u84              HOLD8_PR2.U84            IDENTICAL
38772764.u9                 HOLDX8_1.U9             IDENTICAL
387827256.u81               HOLDX8.U81              25.512695%
387927256.u11                                       NO MATCH
388027256.u16                                       NO MATCH
388127256.u4                                        NO MATCH
3882                        TETRIS_5.U4             NO MATCH
3883                        TETRIS_6.U11            NO MATCH
3884                        TETRIS_7.U16            NO MATCH
3885*/
3886
3887ROM_START( cmv4a )
3888   ROM_REGION( 0x10000, "main", 0 )
3889   ROM_LOAD( "holdx8.u81",   0x0000, 0x2000, CRC(2da4d267) SHA1(3deb6ce4703bb1cca2b58409a6fc5ba7cf601011) )
3890   ROM_CONTINUE(0x4000,0x2000)
3891   ROM_CONTINUE(0x2000,0x2000)
3892   ROM_CONTINUE(0x6000,0x2000)
3893
3894   ROM_REGION( 0x30000, "gfx1", ROMREGION_DISPOSE )   /* double size... tetris gfx inside. */
3895   ROM_LOAD( "tetris_7.u16",  0x00000, 0x10000, CRC(a9e61fac) SHA1(a4093868b570af52f1cd816d523dbb6a750bc1af) )
3896   ROM_LOAD( "tetris_6.u11",  0x10000, 0x10000, CRC(f3e15b41) SHA1(6c44bcdcf7b29d201018e2c2cc0b6b0b62cbaf12) )
3897   ROM_LOAD( "tetris_5.u4",   0x20000, 0x10000, CRC(79a85560) SHA1(b028345ac2d01c643230c6e6c28189c11734aaf5) )
3898
3899   ROM_REGION( 0x8000, "gfx2", ROMREGION_DISPOSE )
3900   ROM_LOAD( "holdx8_4.u15",   0x0000, 0x2000, CRC(8607ffd9) SHA1(9bc94715554aa2473ae2ed249a47f29c7886b3dc) )
3901   ROM_LOAD( "holdx8_3.u10",   0x2000, 0x2000, CRC(c32367be) SHA1(ff217021b9c58e23b2226f8b0a7f5da966225715) )
3902   ROM_LOAD( "holdx8_2.u14",   0x4000, 0x2000, CRC(6dfcb188) SHA1(22430429c798954d9d979e62699b58feae7fdbf4) )
3903   ROM_LOAD( "holdx8_1.u9",    0x6000, 0x2000, CRC(9678ead2) SHA1(e80aefa98b2363fe9e6b2415762695ace272e4d3) )
3904
3905   ROM_REGION( 0x10000, "user1", 0 )
3906   // contains a bitmap? and an extra plane for gfx2, should it be used?
3907   ROM_LOAD( "holdx8_8.u53",  0x0000, 0x10000, CRC(e92443d3) SHA1(4b6ca4521841610054165f085ae05510e77af191) )
3908
3909   ROM_REGION( 0x200, "proms", 0 )
3910   ROM_LOAD( "hold8_pr2.u84", 0x0000, 0x0100, CRC(0489b760) SHA1(78f8632b17a76335183c5c204cdec856988368b0) )
3911   ROM_LOAD( "hold8_pr3.u79", 0x0100, 0x0100, CRC(21eb5b19) SHA1(9b8425bdb97f11f4855c998c7792c3291fd07470) )
3912
3913   ROM_REGION( 0x100, "proms2", 0 )
3914   ROM_LOAD( "hold8_pr1.u46", 0x0000, 0x0100, CRC(50ec383b) SHA1(ae95b92bd3946b40134bcdc22708d5c6b0f4c23e) )
3915ROM_END
3916
3917
27733918/* looks like a bootleg of cmv4 */
27743919ROM_START( cmaster )
27753920   ROM_REGION( 0x10000, "main", 0 )
r4135r4136
28183963ROM_END
28193964
28203965
2821/* doesn't seem to have 'cherry master 2' anywhere on the screen.. */
2822/*
3966/*  cmasterb & cmasterc
28233967
28243968    Cherry Master II ver 8.41
28253969
r4135r4136
28403984    4x8 dip + 1 Switch (main test ???)
28413985*/
28423986
2843ROM_START( cm2v841 )
3987ROM_START( cmasterb )
28443988   ROM_REGION( 0x10000, "main", 0 )
28453989   ROM_LOAD( "u81.9",  0x0000,  0x1000, CRC(09e44314) SHA1(dbb7e9afc9a1dc0d4ce7b150324077f3f3579c02) )
28463990   ROM_CONTINUE(0x4000,0x1000)
r4135r4136
28523996   ROM_CONTINUE(0x5000,0x1000)
28533997
28543998   ROM_REGION( 0x18000, "gfx1", ROMREGION_DISPOSE )
3999   ROM_LOAD( "u16.7", 0x00000,  0x8000, CRC(19cc1d67) SHA1(47487f9362bfb36a32100ed772960628844462bf) )
4000   ROM_LOAD( "u11.6", 0x08000,  0x8000, CRC(63b3df4e) SHA1(9bacd23da598805ec18ec5ad15cab95d71eb9262) )
28554001   ROM_LOAD( "u4.5",  0x10000,  0x8000, CRC(e39fff9c) SHA1(22fdc517fa478441622c6245cecb5728c5595757) )
2856   ROM_LOAD( "u11.6", 0x08000,  0x8000, CRC(63b3df4e) SHA1(9bacd23da598805ec18ec5ad15cab95d71eb9262) )
2857   ROM_LOAD( "u16.7", 0x00000,  0x8000, CRC(19cc1d67) SHA1(47487f9362bfb36a32100ed772960628844462bf) )
28584002
28594003   ROM_REGION( 0x8000, "gfx2", ROMREGION_DISPOSE )
28604004   ROM_LOAD( "u15.4",  0x0000,  0x2000, CRC(8607ffd9) SHA1(9bc94715554aa2473ae2ed249a47f29c7886b3dc) )
r4135r4136
28744018   ROM_LOAD( "82s129.u46", 0x0000, 0x0100, CRC(50ec383b) SHA1(ae95b92bd3946b40134bcdc22708d5c6b0f4c23e) )
28754019ROM_END
28764020
2877ROM_START( cm2841a )
4021ROM_START( cmasterc )
28784022   ROM_REGION( 0x10000, "main", 0 )
28794023   ROM_LOAD( "msii841.u81",  0x3000,  0x1000, CRC(977db602) SHA1(0fd3d6781b654ac6befdc9278f84ca708d5d448c) )
28804024   ROM_CONTINUE(0x2000,0x1000)
r4135r4136
28864030   ROM_CONTINUE(0x7000,0x1000)
28874031
28884032   ROM_REGION( 0x18000, "gfx1", ROMREGION_DISPOSE )
4033   ROM_LOAD( "msii841.u16", 0x00000,  0x8000, CRC(19cc1d67) SHA1(47487f9362bfb36a32100ed772960628844462bf) )
4034   ROM_LOAD( "msii841.u11", 0x08000,  0x8000, CRC(63b3df4e) SHA1(9bacd23da598805ec18ec5ad15cab95d71eb9262) )
28894035   ROM_LOAD( "msii841.u4",  0x10000,  0x8000, CRC(e39fff9c) SHA1(22fdc517fa478441622c6245cecb5728c5595757) )
2890   ROM_LOAD( "msii841.u11", 0x08000,  0x8000, CRC(63b3df4e) SHA1(9bacd23da598805ec18ec5ad15cab95d71eb9262) )
2891   ROM_LOAD( "msii841.u16", 0x00000,  0x8000, CRC(19cc1d67) SHA1(47487f9362bfb36a32100ed772960628844462bf) )
28924036
28934037   /* these gfx are in a different format to usual */
28944038   ROM_REGION( 0x8000, "gfx2", ROMREGION_DISPOSE )
r4135r4136
29074051   ROM_LOAD( "82s129.u46", 0x0000, 0x0100, CRC(50ec383b) SHA1(ae95b92bd3946b40134bcdc22708d5c6b0f4c23e) )
29084052ROM_END
29094053
4054/*
29104055
4056Cherry Master '91
4057-----------------
4058
4059CPU: z8400
4060other chips: NEC D71055C, WB5300
4061Dips 5 x 8 position
4062
4063OSC: 12.000mhz
4064
4065all pals are type 16L8
4066all proms are type s129
4067
4068*/
4069
29114070ROM_START( cmast91 )
29124071   ROM_REGION( 0x10000, "main", 0 )
29134072   ROM_LOAD( "8.bin",   0x00000, 0x01000, CRC(31a16d9f) SHA1(f007148449d66954b780f12a9f910968a4052482) )
r4135r4136
29274086   ROM_CONTINUE(0xe000,0x1000)
29284087   ROM_CONTINUE(0xf000,0x1000)
29294088
2930   ROM_REGION( 0x40000, "user1", 0 ) // unknown, bitmaps, or sound?
2931   ROM_LOAD( "9.bin",   0x00000, 0x40000, CRC(92342276) SHA1(f9436752f2ec67cf873fd01c729c7c113dc18be0) ) // ?
2932
29334089   ROM_REGION( 0x18000, "gfx1", ROMREGION_DISPOSE )
2934   ROM_LOAD( "5.bin",   0x10000, 0x8000, CRC(28ff88cc) SHA1(46bc0407be857e8348159735b60cfb660f047a56) )
2935   ROM_LOAD( "6.bin",   0x08000, 0x8000, CRC(13582e74) SHA1(27e318542606b8e8d38250749ba996402d314abd) )
2936   ROM_LOAD( "7.bin",   0x00000, 0x8000, CRC(1edf1f1d) SHA1(558fa01f1efd7f6541047d3930bdce0974bae5b0))
4090   ROM_LOAD( "7.bin",   0x00000, 0x8000, CRC(1edf1f1d) SHA1(558fa01f1efd7f6541047d3930bdce0974bae5b0))
4091   ROM_LOAD( "6.bin",   0x08000, 0x8000, CRC(13582e74) SHA1(27e318542606b8e8d38250749ba996402d314abd) )
4092   ROM_LOAD( "5.bin",   0x10000, 0x8000, CRC(28ff88cc) SHA1(46bc0407be857e8348159735b60cfb660f047a56) )
29374093
29384094   ROM_REGION( 0x20000, "gfx2", ROMREGION_DISPOSE )
2939   ROM_LOAD( "1.bin",     0x0000, 0x8000, CRC(71bdab69) SHA1(d2c594ed88d6368df15b623c48eecc1c219b839e) )
2940   ROM_LOAD( "2.bin",     0x8000, 0x8000, CRC(fccd48d7) SHA1(af564f5ef9ff5b6363897ce6bdf0b21123911fd4) )
2941   ROM_LOAD( "3.bin",     0x10000, 0x8000, CRC(dc77d04a) SHA1(d8656130cde54d4bb96307899f6d607867e49e6c) )
2942   ROM_LOAD( "4.bin",      0x18000, 0x8000, CRC(0dbabaa2) SHA1(44235b19dac1c996e2166672b03f6e3888ecbefa) )
4095   ROM_LOAD( "4.bin",   0x00000, 0x8000, CRC(0dbabaa2) SHA1(44235b19dac1c996e2166672b03f6e3888ecbefa) )
4096   ROM_LOAD( "3.bin",   0x08000, 0x8000, CRC(dc77d04a) SHA1(d8656130cde54d4bb96307899f6d607867e49e6c) )
4097   ROM_LOAD( "1.bin",   0x10000, 0x8000, CRC(71bdab69) SHA1(d2c594ed88d6368df15b623c48eecc1c219b839e) )
4098   ROM_LOAD( "2.bin",   0x18000, 0x8000, CRC(fccd48d7) SHA1(af564f5ef9ff5b6363897ce6bdf0b21123911fd4) )
29434099
4100   ROM_REGION( 0x40000, "user1", 0 ) /* unknown, bitmaps, or sound? */
4101   ROM_LOAD( "9.bin",   0x00000, 0x40000, CRC(92342276) SHA1(f9436752f2ec67cf873fd01c729c7c113dc18be0) ) // ?
4102
29444103   ROM_REGION( 0x300, "proms", 0 )
29454104   ROM_LOAD( "p1.bin", 0x0000, 0x0100, CRC(ac529f04) SHA1(5bc92e50c85bb23e609172cc15c430ddea7fdcb5) )
29464105   ROM_LOAD( "p2.bin", 0x0100, 0x0100, CRC(3febce95) SHA1(c7c0fec0fb024ebf7d7365a09d28ba3d0037b0b4) )
29474106   ROM_LOAD( "p3.bin", 0x0200, 0x0100, CRC(99dbdf19) SHA1(3680335406f63289f8d9a81b4cd163e4aa0c14d4) )
29484107
2949   ROM_REGION( 0x100, "proms2", 0 ) // screen layout?
4108   ROM_REGION( 0x100, "proms2", 0 ) /* screen layout? */
29504109   ROM_LOAD( "p4.bin", 0x0000, 0x0100, CRC(72212427) SHA1(e87a91f28284313c706ebb8175a3586780636e31) )
4110
4111   ROM_REGION( 0x800, "plds", 0 ) /* all 16L8 type, protected */
4112   ROM_LOAD( "pld1.bin", 0x0000, 0x0104, NO_DUMP )
4113   ROM_LOAD( "pld2.bin", 0x0200, 0x0104, NO_DUMP )
4114   ROM_LOAD( "pld3.bin", 0x0400, 0x0104, NO_DUMP )
4115   ROM_LOAD( "pld4.bin", 0x0600, 0x0104, NO_DUMP )
29514116ROM_END
29524117
29534118/*
r4135r4136
30044169ROM_END
30054170
30064171/*
4172
30074173unknown koren or chinese bootleg of something?
30084174
30094175XTAL 12MHz
r4135r4136
30814247   ROM_LOAD( "prom2", 0x0000, 0x0020, CRC(7b1a769f) SHA1(788b3573df17d398c74662fec4fd7693fc27e2ef) )
30824248ROM_END
30834249
4250/*
4251    LADY LINER - TAB Austria
30844252
4253    Hardware Notes:
4254    ---------------
4255
4256    CPU:   1x Z80.
4257    Sound: 1x AY8930.
4258    I/O:   2x P8255A.
4259
4260    Clock: 1x Xtal @ 12.0000MHz.
4261
4262    ROMs:  1x NM27C256Q (ladybrd)
4263           7x M27C64A (1,2,3,4,71,72,73)
4264           2x PROM AM27S19PC (39,73)
4265           3x PROM AM27S21PC (37,38,96)
4266
4267    RAM:   4x HY6116ALP-10 (near graphics ROMs)
4268           1x HY6116ALP-10 (near program ROM)
4269
4270    1x 8 DIP Switches.
4271    1x trimmer (volume).
4272
4273    Connectors:  1x 18x2 edge connector.
4274                 1x 22x2 edge connector.
4275
4276    Both connectors are wired to a strange small PCB with:
4277    1x 6x2 edge connector + 1x 60x2 edge connector (with smaller spacing) + 2x 8 DIP Switches.
4278
4279    Silkscreened on PCB:
4280    "TAB AUSTRIA"
4281
4282    Sticker on PCB:
4283    "TAB Austria" & "LL 2690"
4284
4285*/
4286
4287ROM_START( ladylinr )
4288   ROM_REGION( 0x8000, "main", 0 )
4289   ROM_LOAD( "ladybrd.bin",   0x0000, 0x8000, CRC(44d2aed0) SHA1(1afe6178d1bf4ad0b623f33be879ed5180ad2db1) )
4290
4291   ROM_REGION( 0x18000, "gfx1", ROMREGION_DISPOSE )
4292   ROM_LOAD( "ll73.bin",   0x00000, 0x8000, CRC(afa4a705) SHA1(779340713df7029553cfc1c57997dfdd96a0f0cc) )
4293   ROM_LOAD( "ll72.bin",   0x08000, 0x8000, CRC(bd1d8a39) SHA1(01e37704c753352024e79b0b83b040f8288b9aed) )
4294   ROM_LOAD( "ll71.bin",   0x10000, 0x8000, CRC(1c417efa) SHA1(491579a76d80c4f488ef94393d12a190571ae285) )
4295
4296   ROM_REGION( 0x8000, "gfx2", ROMREGION_DISPOSE )
4297   ROM_LOAD( "1.bin",   0x0000, 0x2000, CRC(29d6f197) SHA1(1542ca457594f6b7fe8f28f7d78023edd7021bc8) )
4298   ROM_LOAD( "2.bin",   0x2000, 0x2000, CRC(5f812e65) SHA1(70d9ea82f9337936bf21f82b6961768d436f3a6f) )
4299   ROM_LOAD( "3.bin",   0x4000, 0x2000, CRC(898b9ed5) SHA1(11b7d1cfcf425d00d086c74e0dbcb72068dda9fe) )
4300   ROM_LOAD( "4.bin",   0x6000, 0x2000, CRC(4f7cfb35) SHA1(0617cf4419be00d9bacc78724089cb8af4104d68) )
4301
4302   ROM_REGION( 0x200, "proms", 0 )
4303   ROM_LOAD( "am27s21pc.38",   0x0000, 0x0100, CRC(06a0ee6f) SHA1(e793fbb9e14e4e6c6d6783a36edee74f28e7e214) )
4304   ROM_LOAD( "am27s21pc.37",   0x0100, 0x0100, CRC(8589d23c) SHA1(9629c0d8af3cce47ef376898a4be84c0752a265b) )
4305
4306   ROM_REGION( 0x40, "proms2", 0 )
4307   ROM_LOAD( "am27s19pc.39",   0x0000, 0x0020, CRC(c6b41352) SHA1(d7c3b5aa32e4e456c9432a13bede1db6d62eb270) )
4308
4309   ROM_REGION( 0x100, "unkprom", 0 )
4310   ROM_LOAD( "am27s21pc.96",   0x0000, 0x0100, CRC(1d668d4a) SHA1(459117f78323ea264d3a29f1da2889bbabe9e4be) )
4311
4312   ROM_REGION( 0x40, "unkprom2", 0 )
4313   ROM_LOAD( "am27s19pc.73",   0x0000, 0x0020, CRC(b48d0b41) SHA1(01d2d0fd5e79c17043e97146001150b4b32ac86c) )
4314ROM_END
4315
4316/*
4317
4318  Board had a sticker that said MODEL 9006
4319
4320  .u22  2764
4321  .u21  2764
4322  .u20  2764
4323  .u19  2764
4324  .u18  27256
4325  .u17  27256
4326  .u16  27256
4327  .u66  27256
4328
4329  HM6116P
4330  D4016C-2 x3
4331  D4016C-5
4332  12Mhz Crystal
4333  D780C
4334  UM82C55A-PC
4335  M5L8255AP-5
4336  D8255AC-2
4337
4338*/
4339ROM_START( kkojnoli )
4340   ROM_REGION( 0x8000, "main", 0 )
4341   ROM_LOAD( "9006.u66",   0x0000, 0x8000, CRC(5807a005) SHA1(9c7156656cd651c7785c42ce25e96aadd8e3d9ff) )
4342
4343   ROM_REGION( 0x18000, "gfx1", ROMREGION_DISPOSE )
4344   ROM_LOAD( "9006.u18",   0x00000, 0x8000, CRC(b83e304f) SHA1(1022518928d8cb094340927a65b8fb72b0f3c640) )
4345   ROM_LOAD( "9006.u17",   0x08000, 0x8000, CRC(13a3258b) SHA1(605555ae48012ca4b1829d1c835b33ddeec17da6) )
4346   ROM_LOAD( "9006.u16",   0x10000, 0x8000, CRC(84d09be4) SHA1(09a9e491a9a5fc7882c88d46ae2a6e7e99d082f4) )
4347
4348   ROM_REGION( 0x8000, "gfx2", ROMREGION_DISPOSE ) /* redumped */
4349   ROM_LOAD( "9006.u22",   0x0000, 0x2000, CRC(4e93130d) SHA1(faaaf51844da8d3bdb908fb8ce0f2442e26b5f62) )
4350   ROM_LOAD( "9006.u20",   0x2000, 0x2000, CRC(717fe736) SHA1(04e578c1992bbdb312bb6bc12137bd96522a50e6) )
4351   ROM_LOAD( "9006.u21",   0x4000, 0x2000, CRC(f5314f3f) SHA1(0423dc545fce0322377f1934894a999427709b33) )
4352   ROM_LOAD( "9006.u19",   0x6000, 0x2000, CRC(c321d50b) SHA1(8c132d8fcc812bcec5966c8a3960dfbe5d9f8c36) )
4353
4354   /* proper proms recent dumped */
4355   ROM_REGION( 0x200, "proms", 0 )
4356   ROM_LOAD( "9006.u24", 0x0000, 0x0100, CRC(23e81049) SHA1(78071dae70fad870e972d944642fb3a2374be5e4) )
4357   ROM_LOAD( "9006.u23", 0x0100, 0x0100, CRC(526cf9d3) SHA1(eb779d70f2507d0f26d225ac8f5de8f2243599ca) )
4358
4359   /* this one seems bitrotten (bits 3 and 7), except for this issue,
4360       the prom have concordance with prom1 from lucky8 */
4361   ROM_REGION( 0x40, "proms2", 0 )
4362   ROM_LOAD( "prom1", 0x0000, 0x0020, CRC(c6b41352) SHA1(d7c3b5aa32e4e456c9432a13bede1db6d62eb270) )
4363//  ROM_LOAD( "9006.u57", 0x0000, 0x0020, CRC(8a37416a) SHA1(696b46db2ff2bb9ef471ff925977e8a186b17de8) )
4364
4365   ROM_REGION( 0x100, "unkprom", 0 )
4366   ROM_LOAD( "9006.u41", 0x0000, 0x0100, CRC(1d668d4a) SHA1(459117f78323ea264d3a29f1da2889bbabe9e4be) )
4367
4368   ROM_REGION( 0x20, "unkprom2", 0 )
4369   ROM_LOAD( "9006.u58", 0x0000, 0x0020, CRC(6df3f972) SHA1(0096a7f7452b70cac6c0752cb62e24b643015b5c) )
4370ROM_END
4371
4372/*
4373
4374Magical Tonic
4375
4376unknown, 40 pin cpu (plastic box, with "Tonic" sticker on it)
43778255 x3
4378YM2203
437912 MHz
4380
43814x DSW
4382
4383*/
4384
4385ROM_START( mtonic )
4386   ROM_REGION( 0x10000, "main", 0 )
4387   ROM_LOAD( "8.e6",   0x0000, 0x8000, CRC(01daf2af) SHA1(cb9b12c79dce3c9123510a49dffc9f3cee056cf6) )
4388   ROM_LOAD( "9.e6",   0x8000, 0x8000, CRC(1770ac79) SHA1(cadfd00ae75b90b1d202d741828e0afbd5ba0bec) )
4389
4390   ROM_REGION( 0x30000, "gfx1", ROMREGION_DISPOSE )
4391   ROM_LOAD( "5.j10",   0x00000, 0x10000, CRC(b8032ea3) SHA1(15e5335a583d8e7a5422cd4d1d7342874a4962ab) )
4392   ROM_LOAD( "6.j11",   0x10000, 0x10000, CRC(ff38ff30) SHA1(8fef6e1fe7c307c69c9dcafa69ecf66467b9cb41) )
4393   ROM_LOAD( "7.j12",   0x20000, 0x10000, CRC(8f1d2db9) SHA1(200de01334905079dca542541e442d4194ecd913) )
4394
4395   ROM_REGION( 0x10000, "gfx2", ROMREGION_DISPOSE )
4396   ROM_LOAD( "1.l10",   0x0000, 0x4000, CRC(746588db) SHA1(2a0af552011246d4cc0cd0b670907cf8685ce8ef) )
4397   ROM_LOAD( "2.l11",   0x4000, 0x4000, CRC(8b7dd248) SHA1(a3ebde9fd0b6b1e42aa9b6d8e30c225abf2f80ce) )
4398   ROM_LOAD( "3.l12",   0x8000, 0x4000, CRC(de05e678) SHA1(8b9fcb9f912075a20a9ae38100006b57d508e0e7) )
4399   ROM_LOAD( "4.l13",   0xc000, 0x4000, CRC(8c542eee) SHA1(cb424e2a67c6d39302beca7cd5244bcad4a91189) )
4400
4401   ROM_REGION( 0x200, "proms", 0 )
4402   ROM_LOAD( "prom1",   0x0000, 0x0100, NO_DUMP )
4403   ROM_LOAD( "prom2",   0x0100, 0x0100, NO_DUMP )
4404
4405   ROM_REGION( 0x40, "proms2", 0 )
4406   ROM_LOAD( "prom3",   0x0000, 0x0020, NO_DUMP )
4407ROM_END
4408
4409
4410/* these 'Amcoe' games look like bootlegs of cherry master
4411  the z80 roms are encrypted */
4412ROM_START( schery98 )
4413   ROM_REGION( 0x10000, "main", 0 )
4414   ROM_LOAD( "sk98133.bin",    0x0000, 0x10000, CRC(77a5dd54) SHA1(e693f477b42b83f1f5e45fb7c56486119bf91856) )
4415
4416   ROM_REGION( 0x20000, "graphics", ROMREGION_DISPOSE )
4417   ROM_LOAD( "sk98h.bin",  0x00000, 0x10000, CRC(0574357b) SHA1(96a846f6d49dd67ad078ad9240e632f79ae1b437) )
4418   ROM_LOAD( "sk98l.bin",  0x10000, 0x10000, CRC(ebe802a4) SHA1(178542c204fd1027874e6d2c099edaa7878c993f) )
4419
4420   ROM_REGION( 0x18000, "gfx1", ROMREGION_DISPOSE )
4421   ROM_COPY( "graphics", 0x04000, 0x00000, 0x4000 ) // 1
4422   ROM_COPY( "graphics", 0x0c000, 0x04000, 0x4000 ) // 2
4423   ROM_COPY( "graphics", 0x08000, 0x08000, 0x4000 ) // 1
4424   ROM_COPY( "graphics", 0x14000, 0x0c000, 0x4000 ) // 2
4425   ROM_COPY( "graphics", 0x18000, 0x10000, 0x4000 ) // 1
4426   ROM_COPY( "graphics", 0x1c000, 0x14000, 0x4000 ) // 2
4427
4428   ROM_REGION( 0x8000, "gfx2", ROMREGION_DISPOSE )
4429   ROM_COPY( "graphics", 0x00000, 0x04000, 0x4000 )
4430   ROM_COPY( "graphics", 0x10000, 0x00000, 0x4000 )
4431
4432   ROM_REGION( 0x200, "proms", 0 ) // palette
4433   ROM_LOAD( "sk98u19.bin", 0x0000, 0x0100, CRC(796c7960) SHA1(0f64a8119fd4809a5ac79585b415b34b2a83e9dc) )
4434   ROM_LOAD( "sk98u20.bin", 0x0100, 0x0100, CRC(a0862663) SHA1(e27c3bba5f87b51a19ea8068f2ce7b82a6f0eedb) )
4435
4436   ROM_REGION( 0x100, "sku1920.bin", 0 ) // colours again?
4437   ROM_LOAD( "sku1920.bin", 0x0000, 0x0100, CRC(a8c86d5e) SHA1(d19cd5e57ac8fdd685540c1bb2e1474d1326362b) )
4438
4439   ROM_REGION( 0x80000, "oki", 0 ) // samples
4440   ROM_LOAD( "sk98t.bin", 0x00000, 0x20000, CRC(8598b059) SHA1(9e031e30e58a9c1b3d029004ee0f1616711fa2ae) )
4441ROM_END
4442
4443
4444
4445ROM_START( schery97 )
4446   ROM_REGION( 0x20000, "main", 0 )
4447   ROM_LOAD( "sc352.bin",    0x00000, 0x10000, CRC(d3857d85) SHA1(e97b2634f0993631023c08f6baf800461abfad12) )
4448   ROM_LOAD( "sc352c4.bin", 0x10000, 0x10000, CRC(44f55f6e) SHA1(8b6e8618281de480979de37c7b36a0e68a524f47) ) // ?? alt program?
4449
4450   ROM_REGION( 0x20000, "graphics", ROMREGION_DISPOSE )
4451   ROM_LOAD( "sc97h.bin",  0x00000, 0x10000, CRC(def39ee2) SHA1(5e6817bd947ebf16d0313285a00876b796b71cab) )
4452   ROM_LOAD( "sc97l.bin",  0x10000, 0x10000, CRC(6f4d6aea) SHA1(6809c26e6975cac97b0f8c01a508d4e022859b1a) )
4453
4454   ROM_REGION( 0x18000, "gfx1", ROMREGION_DISPOSE )
4455   ROM_COPY( "graphics", 0x04000, 0x00000, 0x4000 ) // 1
4456   ROM_COPY( "graphics", 0x0c000, 0x04000, 0x4000 ) // 2
4457   ROM_COPY( "graphics", 0x08000, 0x08000, 0x4000 ) // 1
4458   ROM_COPY( "graphics", 0x14000, 0x0c000, 0x4000 ) // 2
4459   ROM_COPY( "graphics", 0x18000, 0x10000, 0x4000 ) // 1
4460   ROM_COPY( "graphics", 0x1c000, 0x14000, 0x4000 ) // 2
4461
4462   ROM_REGION( 0x8000, "gfx2", ROMREGION_DISPOSE )
4463   ROM_COPY( "graphics", 0x00000, 0x04000, 0x4000 )
4464   ROM_COPY( "graphics", 0x10000, 0x00000, 0x4000 )
4465
4466   ROM_REGION( 0x200, "proms", 0 ) // palette
4467   ROM_LOAD( "sc97u19.bin", 0x0000, 0x0100, CRC(6a01caca) SHA1(9b3e9eebb9fcc8770f7e92f0f1c0434516ee613d) )
4468   ROM_LOAD( "sc97u20.bin", 0x0100, 0x0100, CRC(5899c1d5) SHA1(c335b99bb58da3a11005a8952a15d9f43bdff157) )
4469
4470   ROM_REGION( 0x100, "sku1920.bin", 0 ) // colours again?
4471   ROM_LOAD( "scu1920.bin", 0x0000, 0x0100, CRC(3aa291dd) SHA1(f35c916b5463ff9ec6e57048af29a746148a13af) )
4472
4473   ROM_REGION( 0x80000, "oki", 0 ) // samples
4474   ROM_LOAD( "sc97t.bin", 0x00000, 0x20000, CRC(8598b059) SHA1(9e031e30e58a9c1b3d029004ee0f1616711fa2ae) )
4475ROM_END
4476
4477
30854478static DRIVER_INIT(goldstar)
30864479{
30874480   int A;
r4135r4136
31034496   int A;
31044497   UINT8 *buffer;
31054498
3106   static UINT16 cherry_swaptables[32] = {
4499   static const UINT16 cherry_swaptables[32] = {
31074500      /* to align with goldstar */
31084501      0x0800, 0x4000, 0x2800, 0x5800,
31094502      0x1800, 0x3000, 0x6800, 0x7000,
r4135r4136
31464539   #endif
31474540}
31484541
3149UINT8 decrypt(UINT8 cipherText, UINT16 address)
4542static UINT8 decrypt(UINT8 cipherText, UINT16 address)
31504543{
31514544   int idx;
31524545   UINT8 output;
r4135r4136
31634556   return output ^ sbox[idx];
31644557}
31654558
3166UINT8 chry10_decrypt(UINT8 cipherText)
4559static UINT8 chry10_decrypt(UINT8 cipherText)
31674560{
31684561   return cipherText ^ (BIT(cipherText, 4) << 3) ^ (BIT(cipherText, 1) << 5) ^ (BIT(cipherText, 6) << 7);
31694562}
r4135r4136
31884581   free(buffer);
31894582
31904583   do_blockswaps(ROM);
4584
4585   /* The game has a PIC for protection.
4586       If the code enter to this sub, just
4587       keeps looping eternally...
4588    */
4589   ROM[0xA5DC] = 0xc9;
4590
31914591   dump_to_file(machine, ROM);
31924592}
31934593
r4135r4136
32824682GAME( 199?, goldstbl, goldstar, goldstbl, goldstar, 0,        ROT0, "IGS",               "Golden Star (Blue version)",             0 )
32834683GAME( 199?, moonlght, goldstar, moonlght, goldstar, 0,        ROT0, "bootleg",           "Moon Light (bootleg of Golden Star)",    0 )
32844684GAME( 199?, chrygld,  0,        chrygld,  chrygld,  chrygld,  ROT0, "bootleg",           "Cherry Gold I",                          0 )
3285GAME( 199?, chry10,   0,        chrygld,  ncb3,     chry10,   ROT0, "bootleg",           "Cherry 10 (bootleg of Golden Star)",     GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4685GAME( 199?, chry10,   0,        chrygld,  chry10,   chry10,   ROT0, "bootleg",           "Cherry 10 (bootleg with PIC16F84)",      0 )
32864686
32874687// are these really dyna, or bootlegs?
32884688GAME( 199?, ncb3,     0,        ncb3,     ncb3,     0,        ROT0, "Dyna",              "Cherry Bonus III (ver.1.40, set 1)",     0 )
r4135r4136
32924692// cherry master hardware has a rather different mem map, but is basically the same
32934693GAME( 198?, cmv801,   0,        cm,       cmv801,   cm,       ROT0, "Corsica",           "Cherry Master (Corsica, ver.8.01)",      0 ) /* says ED-96 where the manufacturer is on some games.. */
32944694
3295GAME( 1992, cmv4,     0,        cm,       cmv4,     cmv4,     ROT0, "Dyna",              "Cherry Master (ver.4)",                  0 )
3296GAME( 1991, cmaster,  cmv4,     cm,       cmaster,  0,        ROT0, "Dyna",              "Cherry Master I (ver.1.01)",             0 )
3297GAME( 198?, cm2v841,  cmv4,     cm,       cmv801,   0,        ROT0, "Dyna",              "Cherry Master (II?) (ver.8.41, set 1)",  GAME_NOT_WORKING )
3298GAME( 198?, cm2841a,  cmv4,     cm,       cmv801,   0,        ROT0, "Dyna",              "Cherry Master (II?) (ver.8.41, set 2)",  GAME_NOT_WORKING )
4695GAME( 1992, cmv4,     0,        cm,       cmv4,     cmv4,     ROT0, "Dyna",              "Cherry Master (ver.4, set 1)",           0 )
4696GAME( 1992, cmv4a,    cmv4,     cm,       cmv4,     cmv4,     ROT0, "Dyna",              "Cherry Master (ver.4, set 2)",           GAME_NOT_WORKING )   /* stealth game? */
4697GAME( 1991, cmaster,  0,        cm,       cmaster,  0,        ROT0, "Dyna",              "Cherry Master I (ver.1.01, set 1)",      0 )
4698GAME( 1991, cmasterb, cmaster,  cm,       cmasterb, cmv4,     ROT0, "Dyna",              "Cherry Master I (ver.1.01, set 2)",      0 )
4699GAME( 1991, cmasterc, cmaster,  cm,       cmasterc, cmv4,     ROT0, "Dyna",              "Cherry Master I (ver.1.01, set 3)",      GAME_IMPERFECT_GRAPHICS )
4700GAME( 1991, cmast91,  0,        cmast91,  cmast91,  cmast91,  ROT0, "Dyna",              "Cherry Master '91 (ver.1.30)",           0 )
32994701
3300GAME( 1991, cmast91,  0,        cmast91,  cmv801,   cmast91,  ROT0, "Dyna",              "Cherry Master '91 (ver.1.30)",           GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS | GAME_NOT_WORKING )
33014702
3302GAME( 1989, lucky8,   0,        lucky8,   lucky8,   0,        ROT0, "Wing Co.Ltd / GEI", "New Lucky 8 Lines (set 1)",              GAME_IMPERFECT_COLORS )
3303GAME( 1989, lucky8a,  lucky8,   lucky8,   lucky8a,  lucky8a,  ROT0, "Wing Co.Ltd / GEI", "New Lucky 8 Lines (set 2)",              GAME_IMPERFECT_COLORS )
4703GAME( 1989, lucky8,   0,        lucky8,   lucky8,   0,        ROT0, "Wing Co.Ltd / GEI", "New Lucky 8 Lines (set 1)",              0 )
4704GAME( 1989, lucky8a,  lucky8,   lucky8,   lucky8a,  lucky8a,  ROT0, "Wing Co.Ltd / GEI", "New Lucky 8 Lines (set 2)",              0 )
4705GAME( 198?, ladylinr, 0,        ladylinr, ladylinr, 0,        ROT0, "TAB Austria",       "Lady Liner",                             0 )
4706GAME( 198?, kkojnoli, 0,        kkojnoli, kkojnoli, 0,        ROT0, "south korean hack", "Kkoj Noli (Kill the Bees)",              GAME_IMPERFECT_COLORS )
4707
4708GAME( 198?, mtonic,   0,        ncb3,     cmv801,   0,        ROT0, "Tonic",             "Magical Tonic?",                         GAME_WRONG_COLORS | GAME_NOT_WORKING )
4709
4710// bootlegs of cherry master?
4711GAME( 1998, schery98, 0,        cmnobmp,  cmv801,   0,        ROT0, "Amcoe",             "Skill Cherry '98",                       GAME_NOT_WORKING )
4712GAME( 1998, schery97, 0,        cmnobmp,  cmv801,   0,        ROT0, "Amcoe",             "Skill Cherry '97",                       GAME_NOT_WORKING )
4713
4714/* possible stealth sets:
4715
4716 - cmaster
4717 - cmv4
4718 - cmv4a    ---> see the 1fxx zone. put a bp in 1f9f to see the loop.
4719 - cm2v841
4720 - cm2841a
4721 - cmast91
4722
4723*/
src/mame/drivers/skylncr.c
r4135r4136
2424
2525    TODO:
2626
27    - Hook the PPI 8255 devices and rework the I/O based on them.
28    - Proper M5M82C255 emulation.
27    - Proper M5M82C255 device emulation.
2928
3029
3130*************************************************************************************************************/
r4135r4136
3635#include "driver.h"
3736#include "cpu/z80/z80.h"
3837#include "sound/ay8910.h"
38#include "machine/8255ppi.h"
3939
4040static tilemap *tmap;
4141
r4135r4136
5858static UINT8* reelscroll3;
5959static UINT8* reelscroll4;
6060
61static UINT8 skylncr_nmi_enable;
6162
63
64/**************************************
65*           Video Hardware            *
66**************************************/
67
6268static WRITE8_HANDLER( skylncr_videoram_w )
6369{
6470   skylncr_videoram[offset] = data;
r4135r4136
106112static VIDEO_START( skylncr )
107113{
108114
109   tmap = tilemap_create(   machine, get_tile_info, tilemap_scan_rows,
110                     8,8, 0x40,0x20   );
115   tmap = tilemap_create(   machine, get_tile_info, tilemap_scan_rows, 8, 8, 0x40, 0x20   );
111116
112   reel_1_tilemap = tilemap_create(machine, get_reel_1_tile_info, tilemap_scan_rows, 8,32, 64,8 );
113   reel_2_tilemap = tilemap_create(machine, get_reel_2_tile_info, tilemap_scan_rows, 8,32, 64,8 );
114   reel_3_tilemap = tilemap_create(machine, get_reel_3_tile_info, tilemap_scan_rows, 8,32, 64,8 );
115   reel_4_tilemap = tilemap_create(machine, get_reel_4_tile_info, tilemap_scan_rows, 8,32, 64,8 );
117   reel_1_tilemap = tilemap_create(machine, get_reel_1_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
118   reel_2_tilemap = tilemap_create(machine, get_reel_2_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
119   reel_3_tilemap = tilemap_create(machine, get_reel_3_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
120   reel_4_tilemap = tilemap_create(machine, get_reel_4_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
116121
117122   tilemap_set_scroll_cols(reel_2_tilemap, 0x40);
118123   tilemap_set_scroll_cols(reel_3_tilemap, 0x40);
r4135r4136
127132}
128133
129134// are these hardcoded, or registers?
130static const rectangle visible1 = { 0*8, (14+48)*8-1,  4*8,  (4+7)*8-1 };
131static const rectangle visible2 = { 0*8, (14+48)*8-1, 12*8, (12+7)*8-1 };
132static const rectangle visible3 = { 0*8, (14+48)*8-1, 20*8, (20+7)*8-1 };
135static const rectangle visible1 = { 0*8, (20+48)*8-1,  4*8,  (4+7)*8-1 };
136static const rectangle visible2 = { 0*8, (20+48)*8-1, 12*8, (12+7)*8-1 };
137static const rectangle visible3 = { 0*8, (20+48)*8-1, 20*8, (20+7)*8-1 };
133138
134139
135140static VIDEO_UPDATE( skylncr )
r4135r4136
146151      tilemap_set_scrolly(reel_4_tilemap, i, reelscroll4[i]);
147152   }
148153
149   tilemap_draw(bitmap,&visible1,reel_2_tilemap,0,0);
150   tilemap_draw(bitmap,&visible2,reel_3_tilemap,0,0);
151   tilemap_draw(bitmap,&visible3,reel_4_tilemap,0,0);
154   tilemap_draw(bitmap,&visible1,reel_2_tilemap, 0, 0);
155   tilemap_draw(bitmap,&visible2,reel_3_tilemap, 0, 0);
156   tilemap_draw(bitmap,&visible3,reel_4_tilemap, 0, 0);
152157
153158
154159   tilemap_draw(bitmap,cliprect, tmap, 0, 0);
155160   return 0;
156161}
157162
158WRITE8_HANDLER( reeltiles_1_w )
163static WRITE8_HANDLER( reeltiles_1_w )
159164{
160165   reeltiles_1_ram[offset] = data;
161166   tilemap_mark_tile_dirty(reel_1_tilemap, offset);
162167}
163168
164WRITE8_HANDLER( reeltiles_2_w )
169static WRITE8_HANDLER( reeltiles_2_w )
165170{
166171   reeltiles_2_ram[offset] = data;
167172   tilemap_mark_tile_dirty(reel_2_tilemap, offset);
168173}
169174
170WRITE8_HANDLER( reeltiles_3_w )
175static WRITE8_HANDLER( reeltiles_3_w )
171176{
172177   reeltiles_3_ram[offset] = data;
173178   tilemap_mark_tile_dirty(reel_3_tilemap, offset);
174179}
175180
176WRITE8_HANDLER( reeltiles_4_w )
181static WRITE8_HANDLER( reeltiles_4_w )
177182{
178183   reeltiles_4_ram[offset] = data;
179184   tilemap_mark_tile_dirty(reel_4_tilemap, offset);
180185}
181186
182WRITE8_HANDLER( reeltileshigh_1_w )
187static WRITE8_HANDLER( reeltileshigh_1_w )
183188{
184189   reeltileshigh_1_ram[offset] = data;
185190   tilemap_mark_tile_dirty(reel_1_tilemap, offset);
186191}
187192
188WRITE8_HANDLER( reeltileshigh_2_w )
193static WRITE8_HANDLER( reeltileshigh_2_w )
189194{
190195   reeltileshigh_2_ram[offset] = data;
191196   tilemap_mark_tile_dirty(reel_2_tilemap, offset);
192197}
193198
194WRITE8_HANDLER( reeltileshigh_3_w )
199static WRITE8_HANDLER( reeltileshigh_3_w )
195200{
196201   reeltileshigh_3_ram[offset] = data;
197202   tilemap_mark_tile_dirty(reel_3_tilemap, offset);
198203}
199204
200WRITE8_HANDLER( reeltileshigh_4_w )
205static WRITE8_HANDLER( reeltileshigh_4_w )
201206{
202207   reeltileshigh_4_ram[offset] = data;
203208   tilemap_mark_tile_dirty(reel_4_tilemap, offset);
204209}
205210
206211
207static READ8_HANDLER( ret_ff )
208{
209   return 0xff;
210}
211
212#ifdef UNUSED_FUNCTION
213static READ8_HANDLER( ret_00 )
214{
215   return 0x00;
216}
217#endif
218
219static UINT8 skylncr_nmi_enable;
220
221static WRITE8_HANDLER( skylncr_nmi_enable_w )
222{
223   skylncr_nmi_enable = data & 0x10;
224}
225
226212static WRITE8_HANDLER( skylncr_paletteram_w )
227213{
228214   static int color;
r4135r4136
235221   {
236222      int r,g,b;
237223      paletteram[color] = data;
238      r = paletteram[(color/3*3)+0];   g = paletteram[(color/3*3)+1];   b = paletteram[(color/3*3)+2];
239      r = (r << 2) | (r >> 4);      g = (g << 2) | (g >> 4);      b = (b << 2) | (b >> 4);
240      palette_set_color(space->machine,color/3,MAKE_RGB(r,g,b));
241      color = (color + 1) % (0x100*3);
224
225      r = paletteram[(color/3 * 3) + 0];
226      g = paletteram[(color/3 * 3) + 1];
227      b = paletteram[(color/3 * 3) + 2];
228      r = (r << 2) | (r >> 4);
229      g = (g << 2) | (g >> 4);
230      b = (b << 2) | (b >> 4);
231
232      palette_set_color(space->machine, color / 3, MAKE_RGB(r, g, b));
233      color = (color + 1) % (0x100 * 3);
242234   }
243235}
244236
r4135r4136
254246   {
255247      int r,g,b;
256248      paletteram_2[color] = data;
257      r = paletteram_2[(color/3*3)+0];   g = paletteram_2[(color/3*3)+1];   b = paletteram_2[(color/3*3)+2];
258      r = (r << 2) | (r >> 4);         g = (g << 2) | (g >> 4);         b = (b << 2) | (b >> 4);
259      palette_set_color(space->machine,0x100 + color/3,MAKE_RGB(r,g,b));
260      color = (color + 1) % (0x100*3);
249
250      r = paletteram_2[(color/3 * 3) + 0];
251      g = paletteram_2[(color/3 * 3) + 1];
252      b = paletteram_2[(color/3 * 3) + 2];
253      r = (r << 2) | (r >> 4);
254      g = (g << 2) | (g >> 4);
255      b = (b << 2) | (b >> 4);
256
257      palette_set_color(space->machine, 0x100 + color / 3, MAKE_RGB(r, g, b));
258      color = (color + 1) % (0x100 * 3);
261259   }
262260}
263261
r4135r4136
282280}
283281
284282
283/************************************
284*         Other Handlers            *
285************************************/
286
287static WRITE8_HANDLER( skylncr_coin_w )
288{
289   coin_counter_w( 0, data & 0x04 );
290}
291
292static READ8_HANDLER( ret_ff )
293{
294   return 0xff;
295}
296
297#ifdef UNUSED_FUNCTION
298static READ8_HANDLER( ret_00 )
299{
300   return 0x00;
301}
302#endif
303
304static WRITE8_HANDLER( skylncr_nmi_enable_w )
305{
306   skylncr_nmi_enable = data & 0x10;
307}
308
309
310/**************************************
311*             Memory Map              *
312**************************************/
313
285314static ADDRESS_MAP_START( mem_map_skylncr, ADDRESS_SPACE_PROGRAM, 8 )
286315   AM_RANGE(0x0000, 0x7fff) AM_ROM
287316   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
r4135r4136
340369ADDRESS_MAP_END
341370
342371
343static WRITE8_HANDLER( skylncr_coin_w )
344{
345   coin_counter_w( 0, data & 0x04 );
346//  popmessage("%02x",data);
347}
348
349372static ADDRESS_MAP_START( io_map_skylncr, ADDRESS_SPACE_IO, 8 )
350373   ADDRESS_MAP_GLOBAL_MASK(0xff)
351374
352   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN1")
353   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN2")
354   AM_RANGE(0x02, 0x02) AM_READ_PORT("DSW1")
355   AM_RANGE(0x10, 0x10) AM_READ_PORT("DSW2")
356   AM_RANGE(0x11, 0x11) AM_READ_PORT("IN3")
357   AM_RANGE(0x12, 0x12) AM_READ_PORT("IN4")
375   AM_RANGE(0x00, 0x03) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)   /* Input Ports */
376   AM_RANGE(0x10, 0x13) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)   /* Input Ports */
358377
359378   AM_RANGE(0x20, 0x20) AM_WRITE( skylncr_coin_w )
360379
r4135r4136
368387ADDRESS_MAP_END
369388
370389
390/***************************************
391*           Graphics Layouts           *
392***************************************/
393
371394static const gfx_layout layout8x8x8 =
372395{
373396   8,8,
r4135r4136
424447   8*32*8/2
425448};
426449
450
451/**************************************
452*           Graphics Decode           *
453**************************************/
454
427455static GFXDECODE_START( skylncr )
428456   GFXDECODE_ENTRY( "gfx1", 0, layout8x8x8,      0, 2 )
429457   GFXDECODE_ENTRY( "gfx2", 0, layout8x32x8,      0, 2 )
r4135r4136
431459GFXDECODE_END
432460
433461
462/***********************************
463*           Input Ports            *
464***********************************/
465
434466static INPUT_PORTS_START( skylncr )
435   PORT_START("IN1")   /* $0 "PORT0 A" */
436   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON6) PORT_NAME("Stop 2") PORT_CODE(KEYCODE_X)
467   PORT_START("IN1")   /* $00 (PPI0 port A) */
468   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON6) PORT_CODE(KEYCODE_X) PORT_NAME("Stop 2")
437469   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
438   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON5) PORT_NAME("Stop 1") PORT_CODE(KEYCODE_Z)
470   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON5) PORT_CODE(KEYCODE_Z) PORT_NAME("Stop 1")
439471   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
440   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON7) PORT_NAME("Stop 3") PORT_CODE(KEYCODE_C)
472   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON7) PORT_CODE(KEYCODE_C) PORT_NAME("Stop 3")
441473   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
442474   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
443475   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
444476
445   PORT_START("IN2")   /* $1 "PORT0 B" */
446   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_NAME("Bet")             PORT_CODE(KEYCODE_2)
477   PORT_START("IN2")   /* $01 (PPI0 port B) */
478   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CODE(KEYCODE_2) PORT_NAME("Bet")
447479   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
448   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON9) PORT_NAME("Option 2 (D-UP)") PORT_CODE(KEYCODE_S)
480   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON9) PORT_CODE(KEYCODE_S) PORT_NAME("Option 2 (D-UP)")
449481   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
450   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Start")           PORT_CODE(KEYCODE_1)
482   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CODE(KEYCODE_1) PORT_NAME("Start")
451483   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
452484   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
453485   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
454486
455   PORT_START("IN3")   /* $11 "PORT1 B" */
456   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2)
457   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2)
458   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_IMPULSE(2)
459   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In")          PORT_CODE(KEYCODE_Q)
460   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Option 1 (D-UP)") PORT_CODE(KEYCODE_A)
461   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("D-UP")            PORT_CODE(KEYCODE_3)
487   PORT_START("IN3")   /* $11 (PPI1 port B) */
488   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )   PORT_IMPULSE(2)
489   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )   PORT_IMPULSE(2)
490   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )   PORT_IMPULSE(2)
491   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
492   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_CODE(KEYCODE_A) PORT_NAME("Option 1 (D-UP)")
493   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_3) PORT_NAME("D-UP")
462494   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
463   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Take Score")      PORT_CODE(KEYCODE_4)
495   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_4) PORT_NAME("Take Score")
464496
465   PORT_START("IN4")   /* $12 "PORT1 C" */
497   PORT_START("IN4")   /* $12 (PPI1 port C) */
466498   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
467   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Reset")    PORT_CODE(KEYCODE_R)
468   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Stats")    PORT_CODE(KEYCODE_0)
499   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_R) PORT_NAME("Reset")
500   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
469501   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )   /* Settings */
470502   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
471503   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
472504   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
473   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key Out") PORT_CODE(KEYCODE_W)
505   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Key Out")
474506
475   PORT_START("DSW1")   /* $2 "DSW1" */
507   PORT_START("DSW1")   /* $02 (PPI0 port C) */
476508   PORT_DIPNAME( 0x11, 0x01, "D-UP Percentage" )
477509   PORT_DIPSETTING(    0x11, "60%" )
478510   PORT_DIPSETTING(    0x01, "70%" )
r4135r4136
497529   PORT_DIPSETTING(    0x80, "x100" )
498530   PORT_DIPSETTING(    0x00, "x1" )
499531
500   PORT_START("DSW2")   /* $10 "DSW2" */
501   PORT_DIPNAME( 0x01, 0x01, "DSW2" )
532   PORT_START("DSW2")   /* $10 (PPI1 port A) */
533   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
502534   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
503535   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
504536   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
r4135r4136
573605INPUT_PORTS_END
574606
575607
608/**************************************
609*       PPI 8255 (x2) Interface       *
610**************************************/
611
612static const ppi8255_interface ppi8255_intf[2] =
613{
614   {   /* A, B & C set as input */
615      DEVICE8_PORT("IN1"),   /* Port A read */
616      DEVICE8_PORT("IN2"),   /* Port B read */
617      DEVICE8_PORT("DSW1"),   /* Port C read */
618      NULL,               /* Port A write */
619      NULL,               /* Port B write */
620      NULL               /* Port C write */
621   },
622   {   /* A, B & C set as input */
623      DEVICE8_PORT("DSW2"),   /* Port A read */
624      DEVICE8_PORT("IN3"),   /* Port B read */
625      DEVICE8_PORT("IN4"),   /* Port C read */
626      NULL,               /* Port A write */
627      NULL,               /* Port B write */
628      NULL               /* Port C write */
629   }
630};
631
632
633/**********************************
634*       AY-3-8910 Interface       *
635**********************************/
636
576637static const ay8910_interface ay8910_config =
577638{
578639   AY8910_LEGACY_OUTPUT,
r4135r4136
590651   if (skylncr_nmi_enable) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
591652}
592653
654
655/*************************************
656*           Machine Driver           *
657*************************************/
658
593659static MACHINE_DRIVER_START( skylncr )
594660
595661   /* basic machine hardware */
r4135r4136
600666
601667   MDRV_NVRAM_HANDLER(generic_0fill)
602668
669   /* 1x M5M82C255, or 2x PPI8255 */
670   MDRV_PPI8255_ADD( "ppi8255_0", ppi8255_intf[0] )
671   MDRV_PPI8255_ADD( "ppi8255_1", ppi8255_intf[1] )
672
603673   /* video hardware */
604674   MDRV_SCREEN_ADD("main", RASTER)
605675   MDRV_SCREEN_REFRESH_RATE(60)
r4135r4136
621691   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
622692MACHINE_DRIVER_END
623693
694
695/**********************************
696*            ROM Load             *
697**********************************/
624698/*
625699
626700Sky Lancer PCB Layout
r4135r4136
744818ROM_END
745819
746820
821/**********************************
822*           Driver Init           *
823**********************************/
824
747825static DRIVER_INIT( skylncr )
748826{
749   paletteram   = auto_malloc(0x100*3);
750   paletteram_2 = auto_malloc(0x100*3);
827   paletteram   = auto_malloc(0x100 * 3);
828   paletteram_2 = auto_malloc(0x100 * 3);
751829}
752830
753831
754/*****************************************************
755                   Game Drivers
756*****************************************************/
832/****************************************************
833*                  Game Drivers                     *
834****************************************************/
757835
758836/*    YEAR  NAME      PARENT   MACHINE   INPUT     INIT     ROT    COMPANY                 FULLNAME                            FLAGS  */
759837GAME( 1995, skylncr,  0,       skylncr,  skylncr,  skylncr, ROT0, "Bordun International", "Sky Lancer (Bordun, ver.U450C)",    0 )
src/mame/drivers/limenko.c
r4135r4136
246246      const rectangle *clip,int priority)
247247{
248248   int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
249   UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
249   const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
250250
251251   int sprite_screen_height = ((1<<16)*gfx->height+0x8000)>>16;
252252   int sprite_screen_width = ((1<<16)*gfx->width+0x8000)>>16;
r4135r4136
316316
317317         for( y=sy; y<ey; y++ )
318318         {
319            UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
319            const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
320320            UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
321321            UINT8 *pri = BITMAP_ADDR8(sprites_bitmap_pri, y, 0);
322322
r4135r4136
380380
381381      gfxdata   = base_gfx + 64 * code;
382382
383      /* prepare GfxElement on the fly */
384      gfx.machine = machine;
385      gfx.width = width;
386      gfx.height = height;
387      gfx.total_elements = 1;
388      gfx.color_depth = 256;
389      gfx.color_granularity = 256;
390      gfx.color_base = 0;
391      gfx.total_colors = 0x10;
392      gfx.pen_usage = NULL;
393      gfx.gfxdata = gfxdata;
394      gfx.line_modulo = width;
395      gfx.char_modulo = 0;   /* doesn't matter */
396      gfx.flags = 0;
397
398383      /* Bounds checking */
399384      if ( (gfxdata + width * height - 1) >= gfx_max )
400385         continue;
401386
387      /* prepare GfxElement on the fly */
388      gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width, 0, 256, 0);
389
402390      draw_single_sprite(sprites_bitmap,&gfx,0,color,flipx,flipy,x,y,cliprect,pri);
403391
404392      // wrap around x
src/mame/drivers/actfancr.c
r4135r4136
288288
289289/******************************************************************************/
290290
291static MACHINE_START( triothep )
292{
293    state_save_register_global(machine, trio_control_select);
294}
295
296/******************************************************************************/
297
291298static MACHINE_DRIVER_START( actfancr )
292299
293300   /* basic machine hardware */
r4135r4136
341348   MDRV_CPU_ADD("audio",M6502, XTAL_12MHz/8) /* verified on pcb */
342349   MDRV_CPU_PROGRAM_MAP(dec0_s_map,0)
343350
351    MDRV_MACHINE_START(triothep)
352
344353   /* video hardware */
345354   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
346355
r4135r4136
586595
587596
588597
589GAME( 1989, actfancr, 0,        actfancr, actfancr, actfancr, ROT0, "Data East Corporation", "Act-Fancer Cybernetick Hyper Weapon (World revision 2)", 0 )
590GAME( 1989, actfanc1, actfancr, actfancr, actfancr, actfancr, ROT0, "Data East Corporation", "Act-Fancer Cybernetick Hyper Weapon (World revision 1)", 0 )
591GAME( 1989, actfancj, actfancr, actfancr, actfancr, actfancj, ROT0, "Data East Corporation", "Act-Fancer Cybernetick Hyper Weapon (Japan revision 1)", 0 )
592GAME( 1989, triothep, 0,        triothep, triothep, 0,        ROT0, "Data East Corporation", "Trio The Punch - Never Forget Me... (World)", 0 )
593GAME( 1989, triothej, triothep, triothep, triothep, 0,        ROT0, "Data East Corporation", "Trio The Punch - Never Forget Me... (Japan)", 0 )
598GAME( 1989, actfancr, 0,        actfancr, actfancr, actfancr, ROT0, "Data East Corporation", "Act-Fancer Cybernetick Hyper Weapon (World revision 2)", GAME_SUPPORTS_SAVE )
599GAME( 1989, actfanc1, actfancr, actfancr, actfancr, actfancr, ROT0, "Data East Corporation", "Act-Fancer Cybernetick Hyper Weapon (World revision 1)", GAME_SUPPORTS_SAVE )
600GAME( 1989, actfancj, actfancr, actfancr, actfancr, actfancj, ROT0, "Data East Corporation", "Act-Fancer Cybernetick Hyper Weapon (Japan revision 1)", GAME_SUPPORTS_SAVE )
601GAME( 1989, triothep, 0,        triothep, triothep, 0,        ROT0, "Data East Corporation", "Trio The Punch - Never Forget Me... (World)", GAME_SUPPORTS_SAVE )
602GAME( 1989, triothej, triothep, triothep, triothep, 0,        ROT0, "Data East Corporation", "Trio The Punch - Never Forget Me... (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/taito_b.c
r4135r4136
1212The palette resolution is 12 bits in some games and 15 bits in others.
1313
1414TODO:
15- hitice: ice trails might not be 100% correct (I'm doubling them horizontally)
15- hitice: ice trails are incorrect.
1616- hitice: the pixel bitmap is not cleared on startup nor during attract mode. There's a
1717  kludge to fix it in the first case.
1818- rambo3a: has a lot of unmapped writes in the VCU area (log up to end of
r4135r4136
33543354
33553355ROM_START( hitice )
33563356   ROM_REGION( 0x80000, "main", 0 )     /* 512k for 68000 code */
3357   ROM_LOAD16_BYTE( "c59-10", 0x00000, 0x20000, CRC(e4ffad15) SHA1(87da85e1489fe57bd012177a70434152e5475009) )
3358   ROM_LOAD16_BYTE( "c59-12", 0x00001, 0x20000, CRC(a080d7af) SHA1(9c68b78fbcc42a2f748d1b7f84f138be79f7c0c9) )
3359   ROM_LOAD16_BYTE( "c59-09", 0x40000, 0x10000, CRC(e243e3b0) SHA1(a7daf96ef70e9a92bb3ee4a151ce674a187c15a2) )
3360   ROM_LOAD16_BYTE( "c59-11", 0x40001, 0x10000, CRC(4d4dfa52) SHA1(8ecd62dc2a2f35850340469afa54862b46053ce0) )
3357   ROM_LOAD16_BYTE( "c59-10.42", 0x00000, 0x20000, CRC(e4ffad15) SHA1(87da85e1489fe57bd012177a70434152e5475009) )
3358   ROM_LOAD16_BYTE( "c59-12.64", 0x00001, 0x20000, CRC(a080d7af) SHA1(9c68b78fbcc42a2f748d1b7f84f138be79f7c0c9) )
3359   ROM_LOAD16_BYTE( "c59-09.41", 0x40000, 0x10000, CRC(e243e3b0) SHA1(a7daf96ef70e9a92bb3ee4a151ce674a187c15a2) )
3360   ROM_LOAD16_BYTE( "c59-11.63", 0x40001, 0x10000, CRC(4d4dfa52) SHA1(8ecd62dc2a2f35850340469afa54862b46053ce0) )
33613361
33623362   ROM_REGION( 0x1c000, "audio", 0 )     /* 64k for Z80 code */
3363   ROM_LOAD( "c59-08",  0x00000, 0x4000, CRC(d3cbc10b) SHA1(75305e264300e0ebd15ada45a6d222fee75bd8e4) )
3363   ROM_LOAD( "c59-08.50",  0x00000, 0x4000, CRC(d3cbc10b) SHA1(75305e264300e0ebd15ada45a6d222fee75bd8e4) )
33643364   ROM_CONTINUE(        0x10000, 0xc000 ) /* banked stuff */
33653365
33663366   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
3367   ROM_LOAD( "c59-03",  0x00000, 0x80000, CRC(9e513048) SHA1(4ffa63c01a25e912dd218b7b2deaf5ad1a53659a) )
3368   ROM_LOAD( "c59-02",  0x80000, 0x80000, CRC(affb5e07) SHA1(afe92268c78ab5565d2913672e25f3136a15f534) )
3367   ROM_LOAD( "c59-03.12",  0x00000, 0x80000, CRC(9e513048) SHA1(4ffa63c01a25e912dd218b7b2deaf5ad1a53659a) )
3368   ROM_LOAD( "c59-02.13",  0x80000, 0x80000, CRC(affb5e07) SHA1(afe92268c78ab5565d2913672e25f3136a15f534) )
33693369
33703370   ROM_REGION( 0x80000, "oki", 0 )
3371   ROM_LOAD( "c59-01",  0x00000, 0x20000, CRC(46ae291d) SHA1(d36ab48cfa393a6a1eae5caa2a397087eb098f7f) )
3371   ROM_LOAD( "c59-01.30",  0x00000, 0x20000, CRC(46ae291d) SHA1(d36ab48cfa393a6a1eae5caa2a397087eb098f7f) )
3372
3373   ROM_REGION( 0x800, "plds", ROMREGION_DISPOSE )
3374   ROM_LOAD( "pal20l8b-c59-04.25", 0x000, 0x144, CRC(2ebcf07c) SHA1(b73396fff8cde51e8a429843cd6dc3386f777f3b) )
3375   ROM_LOAD( "pal16l8b-c59-05.26", 0x200, 0x104, CRC(37b67c5c) SHA1(a4bf3532774bcd285a6e0e24a9e9a3b28684f724) )
3376   ROM_LOAD( "pal20l8b-c59-06.53", 0x400, 0x144, CRC(bf176875) SHA1(d7073ff7bf8f905dc8a6d3cf51543a572fa87f2f) )
3377   ROM_LOAD( "pal16r4b-c59-07.61", 0x600, 0x104, CRC(cf64bd95) SHA1(5acada8bd6da40b5342bdd7ec494ee0e615492f0) )
33723378ROM_END
33733379
3380ROM_START( hiticej )
3381   ROM_REGION( 0x80000, "main", 0 )     /* 512k for 68000 code */
3382   ROM_LOAD16_BYTE( "c59-23.42", 0x00000, 0x20000, CRC(01958fcc) SHA1(adaf9b0a4658d4d8eb8cdd343b40643b4c05d09e) )
3383   ROM_LOAD16_BYTE( "c59-25.64", 0x00001, 0x20000, CRC(71984c76) SHA1(2e8bbfd01b0f229db5f10563a0864e8a2d1a515f) )
3384   ROM_LOAD16_BYTE( "c59-22.41", 0x40000, 0x10000, CRC(c2c86140) SHA1(8d285a50786c91d28004a30854bbc40cf7d0de4b) )
3385   ROM_LOAD16_BYTE( "c59-24.63", 0x40001, 0x10000, CRC(26c8f409) SHA1(c10f5504e4521c64e2410cef504ff7079c7d4e70) )
3386
3387   ROM_REGION( 0x1c000, "audio", 0 )     /* 64k for Z80 code */
3388   ROM_LOAD( "c59-08.50",  0x00000, 0x4000, CRC(d3cbc10b) SHA1(75305e264300e0ebd15ada45a6d222fee75bd8e4) )
3389   ROM_CONTINUE(        0x10000, 0xc000 ) /* banked stuff */
3390
3391   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
3392   ROM_LOAD( "c59-03.12",  0x00000, 0x80000, CRC(9e513048) SHA1(4ffa63c01a25e912dd218b7b2deaf5ad1a53659a) )
3393   ROM_LOAD( "c59-02.13",  0x80000, 0x80000, CRC(affb5e07) SHA1(afe92268c78ab5565d2913672e25f3136a15f534) )
3394
3395   ROM_REGION( 0x80000, "oki", 0 )
3396   ROM_LOAD( "c59-01.30",  0x00000, 0x20000, CRC(46ae291d) SHA1(d36ab48cfa393a6a1eae5caa2a397087eb098f7f) )
3397
3398   ROM_REGION( 0x800, "plds", ROMREGION_DISPOSE )
3399   ROM_LOAD( "pal20l8b-c59-04.25", 0x000, 0x144, CRC(2ebcf07c) SHA1(b73396fff8cde51e8a429843cd6dc3386f777f3b) )
3400   ROM_LOAD( "pal16l8b-c59-05.26", 0x200, 0x104, CRC(37b67c5c) SHA1(a4bf3532774bcd285a6e0e24a9e9a3b28684f724) )
3401   ROM_LOAD( "pal20l8b-c59-06.53", 0x400, 0x144, CRC(bf176875) SHA1(d7073ff7bf8f905dc8a6d3cf51543a572fa87f2f) )
3402   ROM_LOAD( "pal16r4b-c59-07.61", 0x600, 0x104, CRC(cf64bd95) SHA1(5acada8bd6da40b5342bdd7ec494ee0e615492f0) )
3403ROM_END
3404
33743405ROM_START( rambo3 )
33753406   ROM_REGION( 0x80000, "main", 0 )     /* 512k for 68000 code */
33763407   ROM_LOAD16_BYTE( "r3-0e.rom",  0x00000, 0x10000, CRC(3efa4177) SHA1(5e4995e34b92f625f7825238dfbc9e76d4090871) )
r4135r4136
37933824GAME( 1989, viofighu, viofight,viofight, viofight, taito_b, ROT0,   "Taito America Corporation", "Violence Fight (US)", GAME_SUPPORTS_SAVE )
37943825GAME( 1990, ashura,   0,       ashura,   ashura,   taito_b, ROT270, "Taito Corporation", "Ashura Blaster (Japan)", GAME_SUPPORTS_SAVE )
37953826GAME( 1990, ashurau,  ashura,  ashura,   ashurau,  taito_b, ROT270, "Taito America Corporation", "Ashura Blaster (US)", GAME_SUPPORTS_SAVE )
3796GAME( 1990, hitice,   0,       hitice,   hitice,   taito_b, ROT0,   "Williams", "Hit the Ice (US)", GAME_SUPPORTS_SAVE )
3827GAME( 1990, hitice,   0,       hitice,   hitice,   taito_b, ROT0,   "Williams", "Hit the Ice (US)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
3828GAME( 1990, hiticej,  hitice,  hitice,   hitice,   taito_b, ROT0,   "Midway/Taito Corporation", "Hit the Ice (Japan)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
37973829GAME( 1991, selfeena, 0,       selfeena, selfeena, taito_b, ROT0,   "East Technology", "Sel Feena", GAME_SUPPORTS_SAVE )
37983830GAME( 1992, silentd,  0,       silentd,  silentd,  taito_b, ROT0,   "Taito Corporation Japan", "Silent Dragon (World)", GAME_SUPPORTS_SAVE )
37993831GAME( 1992, silentdj, silentd, silentd,  silentdj, taito_b, ROT0,   "Taito Corporation", "Silent Dragon (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/btime.c
r4135r4136
11551155   8*8
11561156};
11571157
1158static const gfx_layout disco_tile8layout =
1159{
1160   8,8,
1161   0x6000/3/8,
1162   3,
1163   { 0x4000*8, 0x2000*8, 0x0000*8 },
1164   { STEP8(0,1) },
1165   { STEP8(0,8) },
1166   8*8
1167};
11581168
11591169
11601170static const gfx_layout tile16layout =
r4135r4136
11681178   32*8
11691179};
11701180
1181static const gfx_layout disco_tile16layout =
1182{
1183   16,16,
1184   0x6000/3/32,
1185   3,
1186   { 0x4000*8, 0x2000*8, 0x0000*8 },
1187   { STEP8(16*8,1), STEP8(0,1) },
1188   { STEP16(0,8) },
1189   32*8
1190};
11711191
1172
11731192static const gfx_layout bnj_tile16layout =
11741193{
11751194   16,16,
r4135r4136
12111230GFXDECODE_END
12121231
12131232static GFXDECODE_START( disco )
1214   GFXDECODE_ENTRY( "gfx1", 0, tile8layout,  0, 4 ) /* char set #1 */
1215   GFXDECODE_ENTRY( "gfx1", 0, tile16layout, 0, 4 ) /* sprites */
1233   GFXDECODE_ENTRY( NULL, 0, disco_tile8layout,  0, 4 ) /* char set #1 */
1234   GFXDECODE_ENTRY( NULL, 0, disco_tile16layout, 0, 4 ) /* sprites */
12161235GFXDECODE_END
12171236
12181237
r4135r4136
17361755   ROM_REGION( 0x10000, "audio", 0 )
17371756   ROM_LOAD( "disco.w6",     0xf000, 0x1000, CRC(d81e781e) SHA1(bde510bfed06a13bd56bf7ddbf220e7cf82f79b6) )
17381757
1739   ROM_REGION( 0x6000, "gfx1", ROMREGION_ERASE00 )
1740   /* dynamically allocated */
1741
17421758   ROM_REGION( 0x0020, "proms", 0 )
17431759   ROM_LOAD( "disco.clr",    0x0000, 0x0020, CRC(a393f913) SHA1(42dce159283427064b3f5ce3a6e2189744ecd943) )
17441760ROM_END
r4135r4136
17551771   ROM_REGION( 0x10000, "audio", 0 )
17561772   ROM_LOAD( "disco.w6",     0xf000, 0x1000, CRC(d81e781e) SHA1(bde510bfed06a13bd56bf7ddbf220e7cf82f79b6) )
17571773
1758   ROM_REGION( 0x6000, "gfx1", ROMREGION_ERASE00 )
1759   /* dynamically allocated */
1760
17611774   ROM_REGION( 0x0020, "proms", 0 )
17621775   ROM_LOAD( "disco.clr",    0x0000, 0x0020, CRC(a393f913) SHA1(42dce159283427064b3f5ce3a6e2189744ecd943) )
17631776ROM_END
src/mame/drivers/cps1.c
r4135r4136
82858285   /* The mapping is handled by a PAL on the B-board */
82868286   memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x800140, 0x80017f, 0, 0, SMH_UNMAP, SMH_UNMAP);
82878287   memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8001c0, 0x8001ff, 0, 0, cps1_cps_b_r, cps1_cps_b_w);
8288
8289   DRIVER_INIT_CALL(cps1);
82888290}
82898291
82908292static DRIVER_INIT( sf2hack )
src/mame/drivers/jantotsu.c
r4135r4136
6969static UINT8 vram_bank,col_bank;
7070static UINT8 mux_data;
7171
72VIDEO_START(jantotsu)
72static VIDEO_START(jantotsu)
7373{
7474   jan_bitmap_1 = auto_malloc(0x2000);
7575   jan_bitmap_2 = auto_malloc(0x2000);
r4135r4136
7878   vram_bank = 0;
7979}
8080
81VIDEO_UPDATE(jantotsu)
81static VIDEO_UPDATE(jantotsu)
8282{
8383   int x,y,i;
8484   int count;
src/mame/drivers/galaxian.c
r4135r4136
232232#include "sound/ay8910.h"
233233#include "sound/sn76496.h"
234234#include "sound/dac.h"
235#include "sound/digitalk.h"
235236#include "includes/cclimber.h"
236237#include "sound/discrete.h"
237238
r4135r4136
251252static UINT8 kingball_speech_dip;
252253static UINT8 kingball_sound;
253254static UINT8 mshuttle_ay8910_cs;
254static UINT8 scorpion_sound_data;
255255
256256static UINT16 protection_state;
257257static UINT8 protection_result;
r4135r4136
799799   }
800800}
801801
802
803static READ8_HANDLER( scorpion_sound_status_r )
802static READ8_HANDLER( scorpion_digitalker_intr_r )
804803{
805   logerror("%04X:scorpion_sound_status_r()\n", cpu_get_pc(space->cpu));
806   return 1;
804   return digitalker_0_intr_r();
807805}
808806
809
810static WRITE8_HANDLER( scorpion_sound_data_w )
807static WRITE8_HANDLER( scorpion_digitalker_control_w )
811808{
812   scorpion_sound_data = data;
813//  logerror("%04X:scorpion_sound_data_w(%02X)\n", cpu_get_pc(space->cpu), data);
809   digitalker_0_cs_w(data & 1 ? ASSERT_LINE : CLEAR_LINE);
810   digitalker_0_cms_w(data & 2 ? ASSERT_LINE : CLEAR_LINE);
811   digitalker_0_wr_w(data & 4 ? ASSERT_LINE : CLEAR_LINE);
814812}
815813
816
817static WRITE8_HANDLER( scorpion_sound_control_w )
818{
819   if (!(data & 0x04))
820      mame_printf_debug("Secondary sound = %02X\n", scorpion_sound_data);
821//  logerror("%04X:scorpion_sound_control_w(%02X)\n", cpu_get_pc(space->cpu), data);
822}
823
824
825814static const ppi8255_interface scorpion_ppi8255_1_intf =
826815{
827816   NULL,                     /* Port A read */
r4135r4136
16521641   AY8910_DEFAULT_LOADS,
16531642   NULL,
16541643   NULL,
1655   scorpion_sound_data_w,
1656   scorpion_sound_control_w,
1644   digitalker_0_data_w,
1645   scorpion_digitalker_control_w,
16571646};
16581647
16591648static const ay8910_interface checkmaj_ay8910_interface =
r4135r4136
16661655   NULL
16671656};
16681657
1669
16701658static const discrete_mixer_desc konami_sound_mixer_desc =
16711659   {DISC_MIXER_IS_OP_AMP,
16721660      {RES_K(5.1), RES_K(5.1), RES_K(5.1), RES_K(5.1), RES_K(5.1), RES_K(5.1)},
r4135r4136
20522040   MDRV_SOUND_ADD("8910.2", AY8910, KONAMI_SOUND_CLOCK/8)
20532041   MDRV_SOUND_CONFIG(scorpion_ay8910_interface)
20542042   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
2043
2044   MDRV_SOUND_ADD("digitalker", DIGITALKER, 4000000)
2045   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.16)
20552046MACHINE_DRIVER_END
20562047
20572048
r4135r4136
28822873   /* no background related */
28832874//  memory_install_write8_handler(space, 0x6803, 0x6803, 0, 0, SMH_NOP);
28842875
2885   memory_install_read8_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), 0x3000, 0x3000, 0, 0, scorpion_sound_status_r);
2876   memory_install_read8_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), 0x3000, 0x3000, 0, 0, scorpion_digitalker_intr_r);
28862877/*
28872878{
28882879    const UINT8 *rom = memory_region(machine, "speech");
src/mame/drivers/bbusters.c
r4135r4136
649649/******************************************************************************/
650650
651651// default eeprom with reasonable calibration for MAME
652unsigned char bbusters_default_eeprom[128] = {
652static const unsigned char bbusters_default_eeprom[128] = {
653653                                       /*y*/                   /*y*/
654654   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0xEE, 0x00,
655655   0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0xFE, 0x00,
src/mame/drivers/highvdeo.c
r0r4136
1/*************************************************************************************************
2
3High Video Tour 4000
4
5driver by Mirko Buffoni
6
7
8Memory layout:
9
10000000-0003FF   Interrupt table
11000400-003FFF   NVRAM and main ram
12040000-04FFFF   VGA 320x200 address space
13080000-0BFFFF   Banked ROM
140C0000-0FFFFF   Program ROM
15
16
17Port layout:
18
190x0008 R    Input port -> Keyboard
200x000A R    Input port -> Coin and Service
210x000C R    Input port -> Reset
22
230x0030 R    Read continuously... maybe watchdog?
24
250x0000 W    Keyboard Lights control port
260x0002 W    \ Hopper or ticket related
270x0004 W    /
280x0006 W    OKI6395 ADPCM command:  need to be latched
290x0010 W    Like 0x3c8 in VGA
300x0014 W    Like 0x3c9 in VGA
31
320x0030 W    Bankswitch select
33
34----
35
36INT 2 (NMI) called every Vblank
37
38----
39
40Interesting locations.  255 = YES
41
423E23-24     Valore Moneta   (5)  (1,5,10)
433E25-26     Valore Gettone  (5)  (1-20)
443E27-28     Valore Servizio (10) (5-500)
453E29-2A     Banconote 1     (5)  (5-500)
46
473E33        Replay          (255) (0,255)
483E34        Double          (0)   (0,255)
493E35        BloccaBanconote (255) (0,255)
503E36        Accumulo        (0)   (0,255)
513E37        Vincita 10      (255) (0,255)
523E38        Numeroni        (255) (0,255)
533E39        Palline         (255) (0,255)
543E3B        Lattine         (255) (0,255)
553E3D        Premio          (10)  (X,10)
563E3E        Bet Max Credit  (20)  (1-50)
573E3F        Bet Max Points  (20)  (1-50)
58
593E40-41     Blocco Getton.  (100) (10-1000)
603E42        Cambio Carte    (0)   (Veloce=0, Normale=1, Lento=2)
613E45-46     Valore ticket   (100) (1-500)
623E4B        Bet Min Gioco   (1)   (1-10)
633E4C        Bet Min Fever   (1)   (1-10)
64
653E59        Tickets         (10)  (Tutti=0, 10=F, 1=FF)
66
67----
68
69Initial High Video releases have roms named 'vcf'...
70They have low resolution 320x200x256 colors.
71Game is V30 based, with rom banking
72
73Next, they released new board with roms named 'ncf'...
74Same resolution, but different mapping for memory and input ports, plus a check for vblank (protection?)
75Game is V30 based, without banking
76
77Newer boards instead have roms named 'tcf'...
78Resolution is higher as 400x300x256 colors, and graphic is fancier.
79There is a simple protection check, tied on an input port.
80Game is V30 based, with rom banking (2Mb)
81
82*************************************************************************************************/
83
84#include "driver.h"
85#include "cpu/nec/nec.h"
86#include "sound/okim6376.h"
87
88static UINT16 *blit_ram;
89
90
91VIDEO_START(tourvisn)
92{
93
94}
95
96VIDEO_UPDATE(tourvisn)
97{
98   int x,y,count;
99
100   count = (0/2);
101
102   for(y=0;y<(video_screen_get_visible_area(screen)->max_y+1);y++)
103   {
104      for(x=0;x<(video_screen_get_visible_area(screen)->max_x+1)/2;x++)
105      {
106         UINT32 color;
107
108         color = ((blit_ram[count]) & 0x00ff)>>0;
109
110         if((x*2)<video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y)
111            *BITMAP_ADDR32(bitmap, y, (x*2)+0) = screen->machine->pens[color];
112
113         color = ((blit_ram[count]) & 0xff00)>>8;
114
115         if(((x*2)+1)<video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y)
116            *BITMAP_ADDR32(bitmap, y, (x*2)+1) = screen->machine->pens[color];
117
118         count++;
119      }
120   }
121
122   return 0;
123}
124
125
126
127static READ16_HANDLER( read1_r )
128{
129   return input_port_read(space->machine, "IN0");
130}
131
132static READ16_HANDLER( read2_r )
133{
134   return input_port_read(space->machine, "IN1");
135}
136
137static READ16_HANDLER( read3_r )
138{
139   return input_port_read(space->machine, "IN2");
140}
141
142static WRITE16_HANDLER( tv_vcf_paletteram_w )
143{
144   static int pal_offs,r,g,b,internal_pal_offs;
145
146   switch(offset*2)
147   {
148      case 0:
149         pal_offs = 0;
150         break;
151      case 2:
152         internal_pal_offs = 0;
153         break;
154      case 4:
155         switch(internal_pal_offs)
156         {
157            case 0:
158               r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
159               internal_pal_offs++;
160               break;
161            case 1:
162               g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
163               internal_pal_offs++;
164               break;
165            case 2:
166               b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
167               palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b));
168               internal_pal_offs = 0;
169               pal_offs++;
170               break;
171         }
172
173         break;
174   }
175}
176
177static WRITE16_HANDLER( tv_vcf_bankselect_w )
178{
179   static UINT32 bankaddress;
180   UINT8 *ROM = memory_region(space->machine, "user1");
181
182   /* bits 0, 1 select the ROM bank */
183   bankaddress = (data & 0x03) * 0x40000;
184
185   memory_set_bankptr(space->machine, 1, &ROM[bankaddress]);
186}
187
188
189static WRITE16_HANDLER( tv_oki6395_w )
190{
191   static int okidata;
192   if (okidata != data) {
193      okidata = data;
194      okim6376_data_0_lsb_w(space, 0, data, mem_mask);
195      okim6376_data_0_lsb_w(space, 0, (1 << 4), mem_mask);
196   }
197}
198
199
200static ADDRESS_MAP_START( tv_vcf_map, ADDRESS_SPACE_PROGRAM, 16 )
201   AM_RANGE(0x00000, 0x003ff) AM_RAM /*irq vector area*/
202   AM_RANGE(0x00400, 0x03fff) AM_RAM AM_BASE( &generic_nvram16 ) AM_SIZE( &generic_nvram_size )
203   AM_RANGE(0x40000, 0x4ffff) AM_RAM AM_BASE(&blit_ram) /*blitter ram*/
204   AM_RANGE(0x80000, 0xbffff) AM_ROMBANK(1)
205   AM_RANGE(0xc0000, 0xfffff) AM_ROM AM_REGION("boot_prg",0)
206ADDRESS_MAP_END
207
208static ADDRESS_MAP_START( tv_vcf_io, ADDRESS_SPACE_IO, 16 )
209    AM_RANGE(0x0006, 0x0007) AM_WRITE( tv_oki6395_w )
210    AM_RANGE(0x0008, 0x0009) AM_READ( read1_r )
211   AM_RANGE(0x000a, 0x000b) AM_READ( read2_r )
212   AM_RANGE(0x000c, 0x000d) AM_READ( read3_r )
213    AM_RANGE(0x0010, 0x0015) AM_WRITE( tv_vcf_paletteram_w )
214    AM_RANGE(0x0030, 0x0031) AM_WRITE( tv_vcf_bankselect_w ) AM_READ( okim6376_status_0_lsb_r )
215ADDRESS_MAP_END
216
217
218static READ16_HANDLER( tv_ncf_read2_r )
219{
220   static int resetpulse = 0;
221
222   // Bit 6 of port 1 is connected to clock impulse, as heartbeat.  If impulse cease
223   // machine resets itself.
224   resetpulse ^= 0x40;
225
226   return (input_port_read(space->machine, "IN1") & 0xbf) | resetpulse;
227}
228
229static WRITE16_HANDLER( tv_ncf_oki6395_w )
230{
231   static int okidata;
232   if (okidata != data) {
233      okidata = data;
234      okim6376_data_0_lsb_w(space, 0, data | 0x80, mem_mask);
235      okim6376_data_0_lsb_w(space, 0, (1 << 4), mem_mask);
236   }
237}
238static ADDRESS_MAP_START( tv_ncf_map, ADDRESS_SPACE_PROGRAM, 16 )
239   AM_RANGE(0x00000, 0x003ff) AM_RAM /*irq vector area*/
240   AM_RANGE(0x00400, 0x03fff) AM_RAM AM_BASE( &generic_nvram16 ) AM_SIZE( &generic_nvram_size )
241   AM_RANGE(0x20000, 0x2ffff) AM_RAM AM_BASE(&blit_ram) /*blitter ram*/
242   AM_RANGE(0x40000, 0xbffff) AM_ROM AM_REGION("user1",0x40000)
243   AM_RANGE(0xc0000, 0xfffff) AM_ROM AM_REGION("boot_prg",0)
244ADDRESS_MAP_END
245
246static ADDRESS_MAP_START( tv_ncf_io, ADDRESS_SPACE_IO, 16 )
247    AM_RANGE(0x0008, 0x0009) AM_WRITE( tv_ncf_oki6395_w )
248    AM_RANGE(0x000c, 0x000d) AM_READ( read1_r )
249   AM_RANGE(0x0010, 0x0011) AM_READ( tv_ncf_read2_r )
250   AM_RANGE(0x0012, 0x0013) AM_READ( read3_r )
251    AM_RANGE(0x0030, 0x0035) AM_WRITE( tv_vcf_paletteram_w )
252ADDRESS_MAP_END
253
254
255static WRITE16_HANDLER( tv_tcf_paletteram_w )
256{
257   int r, g, b, color;
258
259   COMBINE_DATA(&paletteram16[offset]);
260
261   color = paletteram16[offset];
262   r = (color >> 8) & 0xf8;
263   g = (color >> 3) & 0xf8;
264   b = (color << 3) & 0xf8;
265
266   palette_set_color_rgb(space->machine, offset, r, g, b);
267}
268
269static WRITE16_HANDLER( tv_tcf_bankselect_w )
270{
271   static UINT32 bankaddress;
272   UINT8 *ROM = memory_region(space->machine, "user1");
273
274   /* bits 0, 1, 2 select the ROM bank */
275   bankaddress = (data & 0x07) * 0x40000;
276
277   memory_set_bankptr(space->machine, 1, &ROM[bankaddress]);
278}
279
280static ADDRESS_MAP_START( tv_tcf_map, ADDRESS_SPACE_PROGRAM, 16 )
281   AM_RANGE(0x00000, 0x003ff) AM_RAM /*irq vector area*/
282   AM_RANGE(0x00400, 0x03fff) AM_RAM AM_BASE( &generic_nvram16 ) AM_SIZE( &generic_nvram_size )
283   AM_RANGE(0x40000, 0x5d4bf) AM_RAM AM_BASE(&blit_ram) /*blitter ram*/
284   AM_RANGE(0x7fe00, 0x7ffff) AM_RAM_WRITE( tv_tcf_paletteram_w ) AM_BASE(&paletteram16)
285   AM_RANGE(0x80000, 0xbffff) AM_ROMBANK(1)
286   AM_RANGE(0xc0000, 0xfffff) AM_ROM AM_REGION("boot_prg",0)
287ADDRESS_MAP_END
288
289static ADDRESS_MAP_START( tv_tcf_io, ADDRESS_SPACE_IO, 16 )
290    AM_RANGE(0x0006, 0x0007) AM_WRITE( tv_oki6395_w )
291    AM_RANGE(0x0008, 0x0009) AM_READ( read1_r )
292   AM_RANGE(0x000a, 0x000b) AM_READ( read2_r )
293   AM_RANGE(0x0030, 0x0031) AM_READ( read3_r ) AM_WRITE( tv_tcf_bankselect_w )
294ADDRESS_MAP_END
295
296static INPUT_PORTS_START( tv_vcf )
297   PORT_START("IN0")
298   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Take Button") PORT_CODE(KEYCODE_A)
299   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Start") PORT_CODE(KEYCODE_N)
300   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Hold 2") PORT_CODE(KEYCODE_X)
301   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 4") PORT_CODE(KEYCODE_V)
302   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Risk Button") PORT_CODE(KEYCODE_S)
303   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Hold 3") PORT_CODE(KEYCODE_C)
304   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Hold 5") PORT_CODE(KEYCODE_B)
305   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z)
306
307   PORT_START("IN1")
308   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
309   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
310   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN3 )
311   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN4 ) // Note 1
312   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START1 ) PORT_NAME("Ticket")
313   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Diagnostics") PORT_CODE(KEYCODE_F2)
314   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_START2 ) PORT_NAME("Hopper")
315   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START3 )
316
317   PORT_START("IN2")
318   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_NAME("Key") PORT_CODE(KEYCODE_9)
319   PORT_DIPNAME( 0x0002, 0x0000, "Reset NVRAM" )
320   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
321   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
322   PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Reset") PORT_CODE(KEYCODE_F1)
323   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
324   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
325   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
326   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
327   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
328   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
329   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
330   PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
331   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
332   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
333   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
334   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
335   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
336   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
337   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
338INPUT_PORTS_END
339
340static INPUT_PORTS_START( tv_ncf )
341   PORT_START("IN0")
342   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Take Button") PORT_CODE(KEYCODE_A)
343   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Start") PORT_CODE(KEYCODE_N)
344   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Hold 2") PORT_CODE(KEYCODE_X)
345   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 4") PORT_CODE(KEYCODE_V)
346   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Risk Button") PORT_CODE(KEYCODE_S)
347   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Hold 3") PORT_CODE(KEYCODE_C)
348   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Hold 5") PORT_CODE(KEYCODE_B)
349   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z)
350
351   PORT_START("IN1")
352   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
353   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
354   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN3 )
355   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN4 ) // Note 1
356   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START1 )
357   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_START2 )
358   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_OTHER )      /* connected to the clock signal, to signal heartbeat */
359   PORT_DIPNAME( 0x0080, 0x0000, "Reset NVRAM" )
360   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
361   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
362
363   PORT_START("IN2")
364   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Diagnostics") PORT_CODE(KEYCODE_F2)
365   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
366   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
367   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
368   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
369   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
370   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
371   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
372   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
373   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
374   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
375   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
376   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
377   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
378   PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
379   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
380   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
381   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
382   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
383   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Reset") PORT_CODE(KEYCODE_F1)
384INPUT_PORTS_END
385
386static INPUT_PORTS_START( tv_tcf )
387   PORT_START("IN0")
388   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Take Button") PORT_CODE(KEYCODE_A)
389   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Start") PORT_CODE(KEYCODE_N)
390   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Hold 2") PORT_CODE(KEYCODE_X)
391   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 4") PORT_CODE(KEYCODE_V)
392   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Risk Button") PORT_CODE(KEYCODE_S)
393   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Hold 3") PORT_CODE(KEYCODE_C)
394   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Hold 5") PORT_CODE(KEYCODE_B)
395   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z)
396
397   PORT_START("IN1")
398   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
399   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
400   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN3 )
401   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN4 ) // Note 1
402   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START1 ) PORT_NAME("Ticket")
403   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Diagnostics") PORT_CODE(KEYCODE_F2)
404   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_START2 ) PORT_NAME("Hopper")
405   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START3 )
406
407   PORT_START("IN2")
408   PORT_BIT( 0x0003, 0x0002, IPT_OTHER ) // Protection
409   PORT_DIPNAME( 0x0004, 0x0000, "Reset NVRAM" )
410   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
411   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
412   PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Reset") PORT_CODE(KEYCODE_F1)
413   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
414   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
415   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
416   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
417   PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
418   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
419   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
420   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
421   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
422   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
423   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
424   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
425INPUT_PORTS_END
426
427static INTERRUPT_GEN( vblank_irq )
428{
429   cpu_set_input_line_and_vector(device,0,HOLD_LINE,0x08/4);
430}
431
432static MACHINE_DRIVER_START( tv_vcf )
433   MDRV_CPU_ADD("main", V30, XTAL_12MHz/2 )   // ?
434   MDRV_CPU_PROGRAM_MAP(tv_vcf_map,0)
435   MDRV_CPU_IO_MAP(tv_vcf_io,0)
436   MDRV_CPU_VBLANK_INT("main", vblank_irq)
437
438   MDRV_NVRAM_HANDLER(generic_0fill)
439
440   MDRV_SCREEN_ADD("main", RASTER)
441   MDRV_SCREEN_REFRESH_RATE(60)
442   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
443   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
444   MDRV_SCREEN_SIZE(400, 300)
445   MDRV_SCREEN_VISIBLE_AREA(0, 320-1, 0, 200-1)
446
447   MDRV_PALETTE_LENGTH(0x100)
448
449   MDRV_VIDEO_START(tourvisn)
450   MDRV_VIDEO_UPDATE(tourvisn)
451
452   /* sound hardware */
453   MDRV_SPEAKER_STANDARD_MONO("mono")
454
455   //OkiM6376
456   MDRV_SOUND_ADD("oki", OKIM6376, XTAL_12MHz/2/2)
457   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
458
459MACHINE_DRIVER_END
460
461static MACHINE_DRIVER_START( tv_ncf )
462   MDRV_IMPORT_FROM(tv_vcf)
463
464   MDRV_CPU_MODIFY("main")
465   MDRV_CPU_PROGRAM_MAP(tv_ncf_map,0)
466   MDRV_CPU_IO_MAP(tv_ncf_io,0)
467
468MACHINE_DRIVER_END
469
470static MACHINE_DRIVER_START( tv_tcf )
471   MDRV_IMPORT_FROM(tv_vcf)
472
473   MDRV_CPU_MODIFY("main")
474   MDRV_CPU_PROGRAM_MAP(tv_tcf_map,0)
475   MDRV_CPU_IO_MAP(tv_tcf_io,0)
476
477   MDRV_SCREEN_MODIFY("main")
478   MDRV_SCREEN_VISIBLE_AREA(0, 400-1, 0, 300-1)
479MACHINE_DRIVER_END
480
481
482ROM_START( tour4000 )
483   ROM_REGION( 0x100000, "user1", 0 ) /* V30 Code */
484   ROM_LOAD16_BYTE( "vcfi18.bin", 0x00001, 0x80000, CRC(8c83cd34) SHA1(a94bdfdb74d047ac3851f2aef295a37c93b091f2) )
485   ROM_LOAD16_BYTE( "vcfi17.bin", 0x00000, 0x80000, CRC(bcae57ed) SHA1(13c02cae59ed5cc0847a7827a315902066b03190) )
486
487   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
488   ROM_COPY( "user1", 0x0c0000, 0x000000, 0x40000 )
489
490   ROM_REGION( 0x080000, "oki", 0 ) /* M6376 Samples */
491   ROM_LOAD( "ic25.bin", 0x00000, 0x80000, CRC(d71a5566) SHA1(2f7aefc06e39ce211e31b15aadf6338b679e7a31) )
492ROM_END
493
494ROM_START( cfever40 )
495   ROM_REGION( 0x100000, "user1", 0 ) /* V30 Code */
496   ROM_LOAD16_BYTE( "vcfi48.bin", 0x00001, 0x80000, CRC(5a86a642) SHA1(fd927bc393242ff0aca87a0e3c2127f6f1df09cd) )
497   ROM_LOAD16_BYTE( "vcfi47.bin", 0x00000, 0x80000, CRC(e7adc4d8) SHA1(862041c2c5d260727e525ab85fde18994484db16) )
498
499   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
500   ROM_COPY( "user1", 0x0c0000, 0x000000, 0x40000 )
501
502   ROM_REGION( 0x080000, "oki", 0 ) /* M6376 Samples */
503   ROM_LOAD( "ic25.bin", 0x00000, 0x80000, CRC(d71a5566) SHA1(2f7aefc06e39ce211e31b15aadf6338b679e7a31) )
504ROM_END
505
506ROM_START( cfever50 )
507   ROM_REGION( 0x100000, "user1", 0 ) /* V30 Code */
508   ROM_LOAD16_BYTE( "vcfi58.bin", 0x00001, 0x80000, CRC(c3464934) SHA1(1672c34d9ca250769973f7bc739137f153552eb9) )
509   ROM_LOAD16_BYTE( "vcfi57.bin", 0x00000, 0x80000, CRC(2b789acb) SHA1(782ad3a6e0eacbf9adec4afd20a309215913e505) )
510
511   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
512   ROM_COPY( "user1", 0x0c0000, 0x000000, 0x40000 )
513
514   ROM_REGION( 0x080000, "oki", 0 ) /* M6376 Samples */
515   ROM_LOAD( "ic25.bin", 0x00000, 0x80000, CRC(d71a5566) SHA1(2f7aefc06e39ce211e31b15aadf6338b679e7a31) )
516ROM_END
517
518ROM_START( tour4010 )
519   ROM_REGION( 0x100000, "user1", 0 ) /* V30 Code */
520   ROM_LOAD16_BYTE( "ncfi18.bin", 0x00001, 0x80000, CRC(294929d9) SHA1(712926cf1f78197fce838a4e76d70082182214eb) )
521   ROM_LOAD16_BYTE( "ncfi17.bin", 0x00000, 0x80000, CRC(4a8ac279) SHA1(41b0de4444466700ef2de2e926c8fa6f0bda280d) )
522
523   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
524   ROM_COPY( "user1", 0x0c0000, 0x000000, 0x40000 )
525
526   ROM_REGION( 0x080000, "oki", 0 ) /* M6376 Samples */
527   ROM_LOAD( "ic25.bin", 0x00000, 0x80000, CRC(d71a5566) SHA1(2f7aefc06e39ce211e31b15aadf6338b679e7a31) )
528ROM_END
529
530ROM_START( cfever51 )
531   ROM_REGION( 0x100000, "user1", 0 ) /* V30 Code */
532   ROM_LOAD16_BYTE( "ncfi58.bin", 0x00001, 0x80000, CRC(cdf9c2f0) SHA1(94f9cf6b1856becd74971022ded6db5ae927fb54) )
533   ROM_LOAD16_BYTE( "ncfi57.bin", 0x00000, 0x80000, CRC(5005cf2b) SHA1(468ccd27fcb8bdb7d6ccf423542e1d4773930b88) )
534
535   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
536   ROM_COPY( "user1", 0x0c0000, 0x000000, 0x40000 )
537
538   ROM_REGION( 0x080000, "oki", 0 ) /* M6376 Samples */
539   ROM_LOAD( "ic25.bin", 0x00000, 0x80000, CRC(d71a5566) SHA1(2f7aefc06e39ce211e31b15aadf6338b679e7a31) )
540ROM_END
541
542ROM_START( cfever61 )
543   ROM_REGION( 0x100000, "user1", 0 ) /* V30 Code */
544   ROM_LOAD16_BYTE( "ncfi68.bin", 0x00001, 0x80000, CRC(51fe839f) SHA1(e4d9bce4a995cb407faaf36b2c1e10409a2e94da) )
545   ROM_LOAD16_BYTE( "ncfi67.bin", 0x00000, 0x80000, CRC(d889d6b6) SHA1(791d9b9fc2d0a128ab07a9ae18a32f2838a5ea3f) )
546
547   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
548   ROM_COPY( "user1", 0x0c0000, 0x000000, 0x40000 )
549
550   ROM_REGION( 0x080000, "oki", 0 ) /* M6376 Samples */
551   ROM_LOAD( "ic25.bin", 0x00000, 0x80000, CRC(d71a5566) SHA1(2f7aefc06e39ce211e31b15aadf6338b679e7a31) )
552ROM_END
553
554ROM_START( cfever1k )
555   ROM_REGION( 0x200000, "user1", 0 ) /* V30 Code */
556   ROM_LOAD16_BYTE( "tcfi28.bin", 0x00001, 0x100000, CRC(e38d115a) SHA1(7fec94ddcdb07e483ed2f0d7d667c35ceb7a1f44) )
557   ROM_LOAD16_BYTE( "tcfi27.bin", 0x00000, 0x100000, CRC(32f884e6) SHA1(cc74a4c6313654bbd363a89fe7757a05c74de45b) )
558
559   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
560   ROM_COPY( "user1", 0x1C0000, 0x000000, 0x40000 )
561
562   ROM_REGION( 0x080000, "oki", 0 ) /* M6376 Samples */
563   ROM_LOAD( "ic25.bin", 0x00000, 0x80000, CRC(d71a5566) SHA1(2f7aefc06e39ce211e31b15aadf6338b679e7a31) )
564ROM_END
565
566ROM_START( girotutt )
567   ROM_REGION( 0x200000, "user1", 0 ) /* V30 Code */
568   ROM_LOAD16_BYTE( "tcfi18.bin", 0x00001, 0x100000, CRC(822ab6a1) SHA1(04f4254da46cf67ea17587fde4a0fdd39c658b3b) )
569   ROM_LOAD16_BYTE( "tcfi17.bin", 0x00000, 0x100000, CRC(b326a0ee) SHA1(c96b7578c112a97ba1d8de4d3d0ae68fef846cad) )
570
571   ROM_REGION( 0x040000, "boot_prg", 0 ) /*copy for program code*/
572   ROM_COPY( "user1", 0x1C0000, 0x000000, 0x40000 )
573
574   ROM_REGION( 0x080000, "oki", 0 ) /* M6376 Samples */
575   ROM_LOAD( "t41.bin", 0x00000, 0x80000, CRC(6f694406) SHA1(ec8b8baba0ee1bfe8986ce978412ee4de06f1906) )
576ROM_END
577
578GAME( 2000, tour4000,  0,      tv_vcf,   tv_vcf,   0,       ROT0,  "High Video", "Tour 4000",         0 )
579GAME( 2000, cfever40,  0,      tv_vcf,   tv_vcf,   0,       ROT0,  "High Video", "Casino Fever 4.0",  0 )
580GAME( 2000, cfever50,  0,      tv_vcf,   tv_vcf,   0,       ROT0,  "High Video", "Casino Fever 5.0",  0 )
581GAME( 2000, tour4010,  0,      tv_ncf,   tv_ncf,   0,       ROT0,  "High Video", "Tour 4010",         0 )
582GAME( 2000, cfever51,  0,      tv_ncf,   tv_ncf,   0,       ROT0,  "High Video", "Casino Fever 5.1",  0 )
583GAME( 2000, cfever61,  0,      tv_ncf,   tv_ncf,   0,       ROT0,  "High Video", "Casino Fever 6.1",  0 )
584GAME( 2000, cfever1k,  0,      tv_tcf,   tv_tcf,   0,       ROT0,  "High Video", "Casino Fever 1k",   0 )
585GAME( 2000, girotutt,  0,      tv_tcf,   tv_tcf,   0,       ROT0,  "High Video", "GiroTutto",         0 )
src/mame/drivers/arcadecl.c
r4135r4136
427427 *
428428 *************************************/
429429
430GAME( 1992, arcadecl, 0, arcadecl, arcadecl, arcadecl, ROT0, "Atari Games", "Arcade Classics (prototype)", 0 )
431GAME( 1992, sparkz,   0, arcadecl, sparkz,   sparkz,   ROT0, "Atari Games", "Sparkz (prototype)", 0 )
430GAME( 1992, arcadecl, 0, arcadecl, arcadecl, arcadecl, ROT0, "Atari Games", "Arcade Classics (prototype)", GAME_SUPPORTS_SAVE )
431GAME( 1992, sparkz,   0, arcadecl, sparkz,   sparkz,   ROT0, "Atari Games", "Sparkz (prototype)", GAME_SUPPORTS_SAVE )
src/mame/drivers/namconb1.c
r4135r4136
923923   {
924924      case 0x00:
925925         return input_port_read_safe(space->machine, "P4", 0xff);
926         break;
927926
928927      case 0x20:
929928         return input_port_read(space->machine, "MISC");
930         break;
931929
932930      case 0x40:
933931         return input_port_read(space->machine, "P1");
934         break;
935932
936933      case 0x60:
937934         return input_port_read(space->machine, "P2");
938         break;
939935
940936      default:
941937         break;
src/mame/drivers/sfkick.c
r4135r4136
8484   return 0xff;
8585}
8686
87void sfkick_remap_banks(running_machine *machine)
87static void sfkick_remap_banks(running_machine *machine)
8888{
8989   /* 0000-3ffff */
9090   switch(sfkick_bank_cfg&3)
r4135r4136
417417   cpu_set_input_line (machine->cpu[0], 0, (i ? HOLD_LINE : CLEAR_LINE));
418418}
419419
420VIDEO_START( sfkick )
420static VIDEO_START( sfkick )
421421{
422422   VIDEO_START_CALL(generic_bitmapped);
423423   v9938_init (machine, 0, machine->primary_screen, tmpbitmap, MODEL_V9938, 0x80000, sfkick_vdp_interrupt);
src/mame/drivers/igs017.c
r4135r4136
174174   // prepare GfxElement on the fly
175175   gfx_element gfx;
176176
177   gfx.machine = machine;
178   gfx.width = dimx;
179   gfx.height = dimy;
180   gfx.total_elements = 1;
181   gfx.color_depth = 32;
182   gfx.color_granularity = 32;
183   gfx.color_base = 0x100;
184   gfx.total_colors = 8;
185   gfx.pen_usage = NULL;
186   gfx.gfxdata = sprites_gfx + addr;
187   gfx.line_modulo = dimx;
188   gfx.char_modulo = 0;   // doesn't matter
189   gfx.flags = 0;
190
191177   // Bounds checking
192178   if ( addr + dimx * dimy >= sprites_gfx_size )
193179      return;
194180
181   gfx_element_build_temporary(&gfx, machine, sprites_gfx + addr, dimx, dimy, dimx, 0x100, 32, 0);
182
195183   drawgfx(   bitmap,&gfx,
196184            0, color,
197185            flipx, flipy,
src/mame/drivers/lemmings.c
r4135r4136
3434static READ16_HANDLER( lemmings_trackball_r )
3535{
3636   switch (offset) {
37   case 0: return input_port_read(space->machine, "AN0"); break;
38   case 1: return input_port_read(space->machine, "AN1"); break;
39   case 4: return input_port_read(space->machine, "AN2"); break;
40   case 5: return input_port_read(space->machine, "AN3"); break;
37   case 0: return input_port_read(space->machine, "AN0");
38   case 1: return input_port_read(space->machine, "AN1");
39   case 4: return input_port_read(space->machine, "AN2");
40   case 5: return input_port_read(space->machine, "AN3");
4141   }
4242   return 0;
4343}
src/mame/drivers/hyperspt.c
r4135r4136
66
77#include "driver.h"
88#include "cpu/z80/z80.h"
9#include "machine/konami1.h"
109#include "cpu/m6809/m6809.h"
10#include "sound/dac.h"
11#include "sound/sn76496.h"
1112#include "sound/vlm5030.h"
12#include "sound/dac.h"
13#include "machine/konami1.h"
1314
1415
1516extern UINT8 *hyperspt_scroll;
src/mame/drivers/tiamc1.c
r4135r4136
118118#include "cpu/i8085/i8085.h"
119119#include "includes/tiamc1.h"
120120
121static UINT8 *video_ram;
122
123static DRIVER_INIT( tiamc1 )
124{
125   video_ram = auto_malloc(0x3040);
126}
127
128121static MACHINE_RESET( tiamc1 )
129122{
130123   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
131
132   memset(video_ram, 0, 0x3040);
133
134        tiamc1_charram = video_ram + 0x0800;     /* Ram is banked */
135        tiamc1_tileram = video_ram + 0x0000;
136
137   tiamc1_spriteram_y = video_ram + 0x3000;
138   tiamc1_spriteram_x = video_ram + 0x3010;
139   tiamc1_spriteram_n = video_ram + 0x3020;
140   tiamc1_spriteram_a = video_ram + 0x3030;
141
142124   tiamc1_bankswitch_w(space, 0, 0);
143
144   state_save_register_global_pointer(machine, video_ram, 0x3040);
145125}
146126
147127static WRITE8_HANDLER( tiamc1_control_w )
r4135r4136
342322
343323ROM_END
344324
345GAME( 1988, konek, 0, tiamc1, tiamc1, tiamc1, ROT0, "Terminal", "Konek-Gorbunok", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
346GAME( 1988, sosterm, 0, tiamc1, tiamc1, tiamc1, ROT0, "Terminal", "S.O.S.", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
347GAME( 1988, koroleva, 0, tiamc1, tiamc1, tiamc1, ROT0, "Terminal", "Snezhnaja Koroleva", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
325GAME( 1988, konek, 0, tiamc1, tiamc1, 0, ROT0, "Terminal", "Konek-Gorbunok", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
326GAME( 1988, sosterm, 0, tiamc1, tiamc1, 0, ROT0, "Terminal", "S.O.S.", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
327GAME( 1988, koroleva, 0, tiamc1, tiamc1, 0, ROT0, "Terminal", "Snezhnaja Koroleva", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
348328
src/mame/drivers/namcos12.c
r4135r4136
1010    not all games work due to either banking, dma or protection issues.
1111    graphics are glitchy in some games.
1212
13    - day, date, and year from the RTC appear to be ignored (hour/min/sec are fine). H8 core bug or BIOS doesn't care?
1413    - golgo13 assumes the test switch is a switch, not a button - must hold down F2 to stay in test mode
1514
1615
r4135r4136
13111310         ret = make_bcd(systime.local_time.hour);   // hour (BCD, 0-23)
13121311         break;
13131312      case 3:
1314         ret = make_bcd(weekday[systime.local_time.weekday]); // day of the week (1 = Monday, 7 = Sunday)
1313         ret = make_bcd(weekday[systime.local_time.weekday]);   // low nibble = day of the week
1314         ret |= (make_bcd(systime.local_time.mday) & 0x0f)<<4;   // high nibble = low digit of day
13151315         break;
13161316      case 4:
1317         ret = make_bcd(systime.local_time.mday);   // day (BCD, 1-31)
1317         ret = (make_bcd(systime.local_time.mday) >> 4);         // low nibble = high digit of day
1318         ret |= (make_bcd(systime.local_time.month + 1) & 0x0f)<<4;   // high nibble = low digit of month
13181319         break;
13191320      case 5:
1320         ret = make_bcd(systime.local_time.month + 1);   // month (BCD, 1-12)
1321         ret = make_bcd(systime.local_time.month + 1) >> 4;   // low nibble = high digit of month
1322         ret |= (make_bcd(systime.local_time.year % 10) << 4);   // high nibble = low digit of year
13211323         break;
13221324      case 6:
1323         ret = make_bcd(systime.local_time.year % 100);   // year (BCD, 0-99)
1325         ret = make_bcd(systime.local_time.year % 100) >> 4;   // low nibble = tens digit of year (BCD, 0-9)
13241326         break;
13251327   }
13261328
src/mame/drivers/scramble.c
r4135r4136
2828#include "driver.h"
2929#include "cpu/z80/z80.h"
3030#include "cpu/s2650/s2650.h"
31#include "machine/8255ppi.h"
3231#include "sound/ay8910.h"
3332#include "sound/dac.h"
33#include "sound/flt_rc.h"
34#include "machine/8255ppi.h"
3435#include "galaxold.h"
3536
3637
src/mame/drivers/mogura.c
r4135r4136
5555
5656static VIDEO_START( mogura )
5757{
58   gfx_element_set_source(machine->gfx[0], mogura_gfxram);
5859   mogura_tilemap = tilemap_create(machine, get_mogura_tile_info,tilemap_scan_rows,8,8,64, 32);
5960}
6061
r4135r4136
110111{
111112   mogura_gfxram[offset] = data ;
112113
113   decodechar(space->machine->gfx[0], offset/16, mogura_gfxram);
114
115   tilemap_mark_all_tiles_dirty(mogura_tilemap);
114   gfx_element_mark_dirty(space->machine->gfx[0], offset/16);
116115}
117116
118117
src/mame/drivers/taitojc.c
r4135r4136
14611461   ROM_LOAD( "e17-23.65",  0x000000, 0x010000, CRC(80ac1428) SHA1(5a2a1e60a11ecdb8743c20ddacfb61f9fd00f01c) )
14621462
14631463   ROM_REGION( 0x00080, "user2", 0 )      /* eeprom */
1464   ROM_LOAD( "93c46.87",  0x000000, 0x000080, CRC(50fdcce0) SHA1(6e901856755ccdcf478a457c510c0de58683216a) )
1464   ROM_LOAD( "japan-93c46.87",  0x000000, 0x000080, CRC(50fdcce0) SHA1(6e901856755ccdcf478a457c510c0de58683216a) ) /* No specific label but different defaults */
14651465
14661466   ROM_REGION( 0x1800000, "gfx1", 0 )
14671467   ROM_LOAD32_WORD( "e38-05.9",  0x0800002, 0x200000, CRC(bda366bf) SHA1(a7558e6d5e4583a2d8e3d2bfa8cabcc459d3ee83) )
src/mame/drivers/igs009.c
r4135r4136
2727
2828
2929static tilemap *gp98_reel1_tilemap;
30UINT8 *gp98_reel1_ram;
30static UINT8 *gp98_reel1_ram;
3131
32WRITE8_HANDLER( gp98_reel1_ram_w )
32static WRITE8_HANDLER( gp98_reel1_ram_w )
3333{
3434   gp98_reel1_ram[offset] = data;
3535   tilemap_mark_tile_dirty(gp98_reel1_tilemap,offset);
r4135r4136
5959}
6060
6161static tilemap *gp98_reel2_tilemap;
62UINT8 *gp98_reel2_ram;
62static UINT8 *gp98_reel2_ram;
6363
64WRITE8_HANDLER( gp98_reel2_ram_w )
64static WRITE8_HANDLER( gp98_reel2_ram_w )
6565{
6666   gp98_reel2_ram[offset] = data;
6767   tilemap_mark_tile_dirty(gp98_reel2_tilemap,offset);
r4135r4136
9191
9292
9393static tilemap *gp98_reel3_tilemap;
94UINT8 *gp98_reel3_ram;
94static UINT8 *gp98_reel3_ram;
9595
96WRITE8_HANDLER( gp98_reel3_ram_w )
96static WRITE8_HANDLER( gp98_reel3_ram_w )
9797{
9898   gp98_reel3_ram[offset] = data;
9999   tilemap_mark_tile_dirty(gp98_reel3_tilemap,offset);
r4135r4136
123123
124124
125125static tilemap *gp98_reel4_tilemap;
126UINT8 *gp98_reel4_ram;
126static UINT8 *gp98_reel4_ram;
127127
128WRITE8_HANDLER( gp98_reel4_ram_w )
128static WRITE8_HANDLER( gp98_reel4_ram_w )
129129{
130130   gp98_reel4_ram[offset] = data;
131131   tilemap_mark_tile_dirty(gp98_reel4_tilemap,offset);
src/mame/drivers/ampoker2.c
r4135r4136
11761176*************************/
11771177
11781178/*     YEAR  NAME      PARENT    MACHINE   INPUT     INIT  ROT    COMPANY       FULLNAME                             FLAGS  LAYOUT      */
1179GAMEL( 1990, ampoker2, 0,        ampoker2, ampoker2, 0,    ROT0, "Novomatic",  "American Poker II",                  0,     layout_ampoker2 )
1180GAMEL( 1990, ampkr2b1, ampoker2, ampoker2, ampoker2, 0,    ROT0, "Bootleg",    "American Poker II (bootleg, set 1)", 0,     layout_ampoker2 )
1181GAMEL( 1990, ampkr2b2, ampoker2, ampoker2, ampoker2, 0,    ROT0, "Bootleg",    "American Poker II (bootleg, set 2)", 0,     layout_ampoker2 )
1182GAMEL( 1994, ampkr2b3, ampoker2, ampoker2, ampoker2, 0,    ROT0, "Bootleg",    "American Poker II (bootleg, set 3)", 0,     layout_ampoker2 )
1183GAMEL( 1995, ampkr95,  ampoker2, ampoker2, ampkr95,  0,    ROT0, "Bootleg",    "American Poker 95",                  0,     layout_ampoker2 )
1184GAMEL( 1990, pkrdewin, ampoker2, ampoker2, ampoker2, 0,    ROT0, "Bootleg",    "Poker De Win",                       0,     layout_ampoker2 )
1185GAMEL( 1990, videomat, ampoker2, ampoker2, ampoker2, 0,    ROT0, "Bootleg",    "Videomat (polish bootleg)",          0,     layout_ampoker2 )
1186GAMEL( 1995, sigmapkr, 0,        ampoker2, sigmapkr, 0,    ROT0, "Sigma Inc.", "Sigma Poker",                        0,     layout_sigmapkr )
1187GAMEL( 1998, sigma2k,  0,        sigma2k,  sigma2k,  0,    ROT0, "Sigma Inc.", "Sigma Poker 2000",                   0,     layout_sigmapkr )
1179GAMEL( 1990, ampoker2, 0,        ampoker2, ampoker2, 0,    ROT0, "Novomatic",  "American Poker II",                  GAME_SUPPORTS_SAVE,     layout_ampoker2 )
1180GAMEL( 1990, ampkr2b1, ampoker2, ampoker2, ampoker2, 0,    ROT0, "Bootleg",    "American Poker II (bootleg, set 1)", GAME_SUPPORTS_SAVE,     layout_ampoker2 )
1181GAMEL( 1990, ampkr2b2, ampoker2, ampoker2, ampoker2, 0,    ROT0, "Bootleg",    "American Poker II (bootleg, set 2)", GAME_SUPPORTS_SAVE,     layout_ampoker2 )
1182GAMEL( 1994, ampkr2b3, ampoker2, ampoker2, ampoker2, 0,    ROT0, "Bootleg",    "American Poker II (bootleg, set 3)", GAME_SUPPORTS_SAVE,     layout_ampoker2 )
1183GAMEL( 1995, ampkr95,  ampoker2, ampoker2, ampkr95,  0,    ROT0, "Bootleg",    "American Poker 95",                  GAME_SUPPORTS_SAVE,     layout_ampoker2 )
1184GAMEL( 1990, pkrdewin, ampoker2, ampoker2, ampoker2, 0,    ROT0, "Bootleg",    "Poker De Win",                       GAME_SUPPORTS_SAVE,     layout_ampoker2 )
1185GAMEL( 1990, videomat, ampoker2, ampoker2, ampoker2, 0,    ROT0, "Bootleg",    "Videomat (polish bootleg)",          GAME_SUPPORTS_SAVE,     layout_ampoker2 )
1186GAMEL( 1995, sigmapkr, 0,        ampoker2, sigmapkr, 0,    ROT0, "Sigma Inc.", "Sigma Poker",                        GAME_SUPPORTS_SAVE,     layout_sigmapkr )
1187GAMEL( 1998, sigma2k,  0,        sigma2k,  sigma2k,  0,    ROT0, "Sigma Inc.", "Sigma Poker 2000",                   GAME_SUPPORTS_SAVE,     layout_sigmapkr )
src/mame/drivers/jangou.c
r4135r4136
5656   int   bit0, bit1, bit2 , r, g, b;
5757   int   i;
5858
59   for (i = 0; i < 0x10; ++i)
59   for (i = 0; i < 0x20; ++i)
6060   {
6161      bit0 = (color_prom[0] >> 0) & 0x01;
6262      bit1 = (color_prom[0] >> 1) & 0x01;
r4135r4136
659659   MDRV_SCREEN_SIZE(256, 256)
660660   MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 16, 240-1)
661661
662   MDRV_PALETTE_LENGTH(16)
662   MDRV_PALETTE_LENGTH(32)
663663
664664   MDRV_VIDEO_START(jangou)
665665   MDRV_VIDEO_UPDATE(jangou)
r4135r4136
809809   ROM_LOAD( "rom5.bin", 0x02000, 0x02000, CRC(24d210ed) SHA1(6a0eae9d459975fbaad75bf21284baac3ba4f872) )
810810
811811   /*wtf,these 2 roms are next to the CPU roms, one is a CPU rom from Moon Quasar, the other a GFX rom from Crazy Climber,
812      I dunno what's going on,game doesn't appear to need these two....*/
812      I dunno what's going on,the game doesn't appear to need these two....*/
813813   ROM_REGION( 0x1000, "user1", 0 )
814814   ROM_LOAD( "rom6.bin", 0x00000, 0x0800, CRC(33965a89) SHA1(92912cea76a472d9b709c664d9818844a07fcc32)  ) // = mq3    Moon Quasar
815815   ROM_LOAD( "rom7.bin", 0x00800, 0x0800, CRC(481b64cc) SHA1(3f35c545fc784ed4f969aba2d7be6e13a5ae32b7)  ) // = cc06   Crazy Climber (US)
r4135r4136
823823   ROM_LOAD( "countrygirl_prom.bin", 0x00, 0x20, CRC(dc54dc52) SHA1(db91a7ae05eb6b6e4b42f91dfe20ac0da6680b46)  )
824824ROM_END
825825
826ROM_START( luckygrl )
827   ROM_REGION( 0x10000, "cpu0", 0 ) //encrypted z80 cpu
828   ROM_LOAD( "5.9c", 0x00000, 0x01000, CRC(79b34eb2) SHA1(4b4916e09bfd6573fd2c7a7254fa4419164e0c4d) )
829   ROM_LOAD( "7.9f", 0x01000, 0x01000, CRC(14a44d23) SHA1(4f84a8f986a8fd9d5ac0636be1bb036c3b2746c2) )
830   ROM_LOAD( "6.9e", 0x02000, 0x01000, CRC(06850aa8) SHA1(c23cb6b7b26d5586b1a095dee88228d1613ae7d0) )
831
832   ROM_REGION( 0x80000, "gfx", 0 )
833   ROM_LOAD( "1.5r",      0x00000, 0x2000, CRC(fb429678) SHA1(00e37e90550d9190d06977a5f5ed75b691750cc1) )
834   ROM_LOAD( "piggy2.5r", 0x02000, 0x2000, CRC(a3919845) SHA1(45fffe34b7a29ecf8c8feb4152b5c7330ea3ad83) )
835   ROM_LOAD( "3.5n",      0x04000, 0x2000, CRC(130cfb89) SHA1(86b2a2142675cbd69d7cccab9b00f4c8863cdcbc) )
836   ROM_LOAD( "piggy4.5r", 0x06000, 0x2000, CRC(f5641c95) SHA1(e824b95c80d00789f07391aa5dcc02505bb8e141) )
837
838   ROM_REGION( 0x20, "proms", 0 )
839   ROM_LOAD( "prom_mb7051.3h", 0x00, 0x20, CRC(dff9f7a1) SHA1(593c99434df5dfd900ec57e3efa459903b589d96) )
840ROM_END
841
842
826843/*Temporary kludge for make the RNG work*/
827844static READ8_HANDLER( jngolady_rng_r )
828845{
r4135r4136
834851   memory_install_read8_handler(cpu_get_address_space(machine->cpu[2], ADDRESS_SPACE_PROGRAM), 0x08, 0x08, 0, 0, jngolady_rng_r );
835852}
836853
854static DRIVER_INIT (luckygrl)
855{
856   // this is WRONG
857   int A;
858   UINT8 *ROM = memory_region(machine, "cpu0");
837859
838860
861   unsigned char patn1[32] = {
862      0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0,
863      0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28,
864   };
865
866   unsigned char patn2[32] = {
867      0x28, 0x20, 0x28, 0x20, 0x28, 0x20, 0x28, 0x20, 0x28, 0x20, 0x28, 0x20, 0x28, 0x20, 0x28, 0x20,
868      0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88,   0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88
869   };
870
871   for (A = 0;A < 0x3000;A++)
872   {
873      UINT8 dat = ROM[A];
874      if (A&0x100) dat = dat ^ patn2[A&0x1f];
875      else dat = dat ^ patn1[A&0x1f];
876
877      ROM[A] = dat;
878   }
879
880
881   #if 0
882   {
883      FILE *fp;
884      char filename[256];
885      sprintf(filename,"decrypted_%s", machine->gamedrv->name);
886      fp=fopen(filename, "w+b");
887      if (fp)
888      {
889         fwrite(ROM, 0x3000, 1, fp);
890         fclose(fp);
891      }
892   }
893   #endif
894
895}
896
897
839898/* flyer shows a bet version of Jangou Lady too,does it truly exists?*/
840899GAME( 1983, jangou,    0,    jangou,   jangou,    0,        ROT0, "Nichibutsu",   "Jangou [BET] (Japan)", GAME_NO_COCKTAIL )
841900/* Jangou Night */
842901GAME( 1984, jngolady,  0,    jngolady, jngolady,  jngolady, ROT0, "Nichibutsu",   "Jangou Lady (Japan)", GAME_NO_COCKTAIL )
843902GAME( 1984, cntrygrl,  0,    cntrygrl, cntrygrl,  0,        ROT0, "Royal Denshi", "Country Girl (Japan)",  GAME_NO_COCKTAIL )
903GAME( 1984?,luckygrl,  0,    cntrygrl, cntrygrl,  luckygrl, ROT0, "Wing",         "Lucky Girl? (Wing)", GAME_NOT_WORKING )
src/mame/drivers/model3.c
r4135r4136
867867            return;
868868         }
869869         return;
870         break;
871870   }
872871   fatalerror("real3d_dma_w: %08X, %08X%08X, %08X%08X", offset, (UINT32)(data >> 32), (UINT32)(data), (UINT32)(mem_mask >> 32), (UINT32)(mem_mask));
873872}
src/mame/drivers/cb2001.c
r4135r4136
3636
3737------------------------------
3838
39
4039*************************************************************************************************/
4140
4241#include "driver.h"
r4135r4136
127126*/
128127
129128
130VIDEO_START(cb2001)
129static VIDEO_START(cb2001)
131130{
132131
133132}
134133
135VIDEO_UPDATE(cb2001)
134static VIDEO_UPDATE(cb2001)
136135{
137136   return 0;
138137}
r4135r4136
153152//  cpu_set_input_line_and_vector(device,0,HOLD_LINE,0x08/4);
154153}
155154
155static const gfx_layout cb2001_layout =
156{
157   8,8,
158   RGN_FRAC(1,1),
159   4,
160   { 0,1,2,3 },
161   { 8,12,0,4,24,28, 16,20 },
162   { 0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32 },
163   8*32
164};
165
166static const gfx_layout cb2001_layout32 =
167   {
168   8,32,
169   RGN_FRAC(1,1),
170   4,
171   { 0,1,2,3 },
172   { 8,12,0,4,24,28, 16,20 },
173   { 0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32, 8*32, 9*32, 10*32, 11*32, 12*32, 13*32,14*32,15*32,16*32,17*32,18*32,19*32,20*32,21*32,22*32,23*32,24*32,25*32,26*32,27*32,28*32,29*32,30*32,31*32 },
174   32*32
175};
176
177static GFXDECODE_START( cb2001 )
178   GFXDECODE_ENTRY( "gfx", 0, cb2001_layout,   0x0, 2  )
179   GFXDECODE_ENTRY( "gfx", 0, cb2001_layout32, 0x0, 2  )
180GFXDECODE_END
181
156182static const nec_config cb2001_config = { cb2001_decryption_table, };
157183static MACHINE_DRIVER_START( cb2001 )
158184   MDRV_CPU_ADD("main", V30, 20000000) // CPU91A-011-0016JK004; encrypted cpu like nec v25/35 used in some irem game
r4135r4136
161187   MDRV_CPU_IO_MAP(cb2001_io,0)
162188   MDRV_CPU_VBLANK_INT("main", vblank_irq)
163189
190   MDRV_GFXDECODE(cb2001)
191
164192   MDRV_SCREEN_ADD("main", RASTER)
165193   MDRV_SCREEN_REFRESH_RATE(60)
166194   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
src/mame/drivers/mpoker.c
r4135r4136
1010static UINT8* mpoker_video;
1111
1212
13VIDEO_START(mpoker)
13static VIDEO_START(mpoker)
1414{
1515
1616}
1717
18VIDEO_UPDATE(mpoker)
18static VIDEO_UPDATE(mpoker)
1919{
2020   int y,x;
2121   int count;
src/mame/drivers/st0016.c
r4135r4136
55
66Todo:
77- find NMI source, and NMI enable/disable (timer ? video hw ?)
8
9Dips verified for Neratte Chu (nratechu) from manual
810*/
911
1012#include "driver.h"
r4135r4136
191193   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* unused ? */
192194
193195   PORT_START("DSW1")
194   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
196   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:1")
195197   PORT_DIPSETTING(   0x01, DEF_STR( Off ) )
196198   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
197   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
199   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:2")
198200   PORT_DIPSETTING(   0x02, DEF_STR( Off ) )
199201   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
200   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
202   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:3")
201203   PORT_DIPSETTING(   0x04, DEF_STR( Off ) )
202204   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
203   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
205   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:4")
204206   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
205207   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
206   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
208   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:5")
207209   PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
208210   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
209   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
211   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:6")
210212   PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
211213   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
212   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
214   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:7")
213215   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
214216   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
215   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
217   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:8")
216218   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
217219   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
218220
219221   PORT_START("DSW2")
220   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
222   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:1")
221223   PORT_DIPSETTING(   0x01, DEF_STR( Off ) )
222224   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
223   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
225   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:2")
224226   PORT_DIPSETTING(   0x02, DEF_STR( Off ) )
225227   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
226   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
228   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:3")
227229   PORT_DIPSETTING(   0x04, DEF_STR( Off ) )
228230   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
229   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
231   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:4")
230232   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
231233   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
232   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
234   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:5")
233235   PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
234236   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
235   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
237   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:6")
236238   PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
237239   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
238   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
240   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:7")
239241   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
240242   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
241   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
243   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:8")
242244   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
243245   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
244246INPUT_PORTS_END
r4135r4136
257259   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
258260
259261   PORT_MODIFY("DSW1")   /* Dip switch A  */
260   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
261   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
262   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW1:2")
262263   PORT_DIPSETTING(   0x02, DEF_STR( Off ) )
263264   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
264   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
265   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
265   PORT_SERVICE( 0x04, IP_ACTIVE_LOW ) PORT_DIPLOCATION("SW1:3")
266   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW1:4")
266267   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
267268   PORT_DIPSETTING(   0x08, DEF_STR( On ) )
268   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) )
269   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:5,6")
269270   PORT_DIPSETTING(   0x20, DEF_STR( 2C_1C ) )
270271   PORT_DIPSETTING(   0x30, DEF_STR( 1C_1C ) )
271272   PORT_DIPSETTING(   0x00, DEF_STR( 2C_3C ) )
272273   PORT_DIPSETTING(   0x10, DEF_STR( 1C_2C ) )
273   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) )
274   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW1:7,8")
274275   PORT_DIPSETTING(   0x80, DEF_STR( 2C_1C ) )
275276   PORT_DIPSETTING(   0xc0, DEF_STR( 1C_1C ) )
276277   PORT_DIPSETTING(   0x00, DEF_STR( 2C_3C ) )
277278   PORT_DIPSETTING(   0x80, DEF_STR( 1C_2C ) )
278279
279280   PORT_MODIFY("DSW2")   /* Dip switch B */
280   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
281   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:1,2")
281282   PORT_DIPSETTING(   0x00, DEF_STR( Very_Hard ) )
282283   PORT_DIPSETTING(   0x01, DEF_STR( Hard ) )
283284   PORT_DIPSETTING(   0x02, DEF_STR( Easy ) )
r4135r4136
297298   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
298299
299300   PORT_MODIFY("DSW1")   /* Dip switch A  */
300   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
301   PORT_DIPNAME( 0x02, 0x02, "Crt Mode" ) //flip screen ?
301   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:1")
302   PORT_DIPSETTING(   0x01, DEF_STR( Off ) )
303   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
304   PORT_DIPNAME( 0x02, 0x02, "Crt Mode" ) PORT_DIPLOCATION("SW1:2") // flip screen ?
302305   PORT_DIPSETTING(   0x02, DEF_STR( Off ) )
303306   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
304   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
305   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
307   PORT_SERVICE( 0x04, IP_ACTIVE_LOW ) PORT_DIPLOCATION("SW1:3")
308   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW1:4")
306309   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
307310   PORT_DIPSETTING(   0x08, DEF_STR( On ) )
308   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) )
311   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:5,6")
309312   PORT_DIPSETTING(   0x10, DEF_STR( 2C_1C ) )
310313   PORT_DIPSETTING(   0x30, DEF_STR( 1C_1C ) )
311314   PORT_DIPSETTING(   0x00, DEF_STR( 2C_3C ) )
312315   PORT_DIPSETTING(   0x20, DEF_STR( 1C_2C ) )
313   PORT_DIPNAME( 0x40, 0x40,  DEF_STR( Controls ) )
316   PORT_DIPNAME( 0x40, 0x40,  DEF_STR( Controls ) ) PORT_DIPLOCATION("SW1:7")
314317   PORT_DIPSETTING(   0x00, "Majyan Panel" )
315318   PORT_DIPSETTING(   0x40, DEF_STR( Joystick ) )
316319
317320   PORT_MODIFY("DSW2")   /* Dip switch B */
318   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
321   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:1,2")
319322   PORT_DIPSETTING(   0x00, DEF_STR( Very_Hard ) )
320323   PORT_DIPSETTING(   0x01, DEF_STR( Hard ) )
321324   PORT_DIPSETTING(   0x02, DEF_STR( Easy ) )
r4135r4136
325328static INPUT_PORTS_START( nratechu )
326329   PORT_INCLUDE( st0016 )
327330
331   PORT_MODIFY("SYSTEM")
332   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
333   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
334
328335   PORT_MODIFY("DSW1")   /* Dip switch A  */
329   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
336   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW1:1,2,3")
337   PORT_DIPSETTING(   0x00, DEF_STR( 5C_1C ) )
330338   PORT_DIPSETTING(   0x01, DEF_STR( 4C_1C ) )
331339   PORT_DIPSETTING(   0x02, DEF_STR( 3C_1C ) )
332340   PORT_DIPSETTING(   0x03, DEF_STR( 2C_1C ) )
r4135r4136
334342   PORT_DIPSETTING(   0x06, DEF_STR( 1C_2C ) )
335343   PORT_DIPSETTING(   0x05, DEF_STR( 1C_3C ) )
336344   PORT_DIPSETTING(   0x04, DEF_STR( 1C_4C ) )
337   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Language ) )
345   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW1:4" )
346   PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "SW1:5" )
347   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW1:6" )
348   PORT_DIPNAME( 0x40, 0x40, "How To Play" ) PORT_DIPLOCATION("SW1:7")
349   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
350   PORT_DIPSETTING(   0x40, DEF_STR( Yes ) )
351   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Language ) ) PORT_DIPLOCATION("SW1:8")
338352   PORT_DIPSETTING(   0x00, DEF_STR( English ) )
339353   PORT_DIPSETTING(   0x80, DEF_STR( Japanese ) )
340354
341355   PORT_MODIFY("DSW2")   /* Dip switch B */
342   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) //  speed / time..
356   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:1,2") //  speed / time..
343357   PORT_DIPSETTING(   0x02, DEF_STR( Easy ) )
344358   PORT_DIPSETTING(   0x03, DEF_STR( Normal ))
345359   PORT_DIPSETTING(   0x01, DEF_STR( Hard ) )
346360   PORT_DIPSETTING(   0x00, DEF_STR( Hardest ) )
347   PORT_DIPNAME( 0x0C, 0x0C, "VS Round" )
348   PORT_DIPSETTING(   0x00, "1" )
349   PORT_DIPSETTING(   0x0C, "2" )
350   PORT_DIPSETTING(   0x08, "3" )
351   PORT_DIPSETTING(   0x04, "4" )
352   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
361   PORT_DIPNAME( 0x0C, 0x0c, "VS Round" ) PORT_DIPLOCATION("SW2:3,4")
362   PORT_DIPSETTING(   0x00, "First one to win" )
363   PORT_DIPSETTING(   0x04, "Best 4 out of 7" )
364   PORT_DIPSETTING(   0x08, "Best 3 out of 5" )
365   PORT_DIPSETTING(   0x0C, "Best 2 out of 3" )
366   PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "SW2:5" )
367   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:6") // Manual has this Defaulted OFF
353368   PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
354369   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
355   PORT_DIPNAME( 0x80, 0x80, "Test Mode" )
356   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
370   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW2:7")
371   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
357372   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
373   PORT_SERVICE( 0x80, IP_ACTIVE_LOW ) PORT_DIPLOCATION("SW2:8")
358374INPUT_PORTS_END
359375
360376static INPUT_PORTS_START( mayjisn2 )
361377   PORT_INCLUDE( st0016 )
362378
379   PORT_MODIFY("SYSTEM")
380   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
381
363382   PORT_MODIFY("DSW1")   /* Dip switch A  */
364   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
383   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW1:1,2,3")
365384   PORT_DIPSETTING(   0x01, DEF_STR( 4C_1C ) )
366385   PORT_DIPSETTING(   0x02, DEF_STR( 3C_1C ) )
367386   PORT_DIPSETTING(   0x03, DEF_STR( 2C_1C ) )
r4135r4136
369388   PORT_DIPSETTING(   0x06, DEF_STR( 1C_2C ) )
370389   PORT_DIPSETTING(   0x05, DEF_STR( 1C_3C ) )
371390   PORT_DIPSETTING(   0x04, DEF_STR( 1C_4C ) )
372   PORT_DIPNAME( 0x18, 0x18, "Timer" )
391   PORT_DIPNAME( 0x18, 0x18, "Timer" ) PORT_DIPLOCATION("SW1:4,5")
373392   PORT_DIPSETTING(   0x00, "6:00" )
374393   PORT_DIPSETTING(   0x08, "5:00" )
375394   PORT_DIPSETTING(   0x18, "4:00" )
376395   PORT_DIPSETTING(   0x10, "3:00" )
377396
378397   PORT_MODIFY("DSW2")   /* Dip switch B */
379   PORT_DIPNAME( 0x18, 0x18, "Music in Game"  )
398   PORT_DIPNAME( 0x18, 0x18, "Music in Game"  ) PORT_DIPLOCATION("SW2:4,5")
380399   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
381400   PORT_DIPSETTING(   0x08, "Remixed" )
382401   PORT_DIPSETTING(   0x18, "Only Intro" )
383402   PORT_DIPSETTING(   0x10, "Classic" )
384   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
403   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:6")
385404   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
386405   PORT_DIPSETTING(   0x20, DEF_STR( On ) )
387   PORT_DIPNAME( 0x40, 0x40, "Position of Title" )
406   PORT_DIPNAME( 0x40, 0x40, "Position of Title" ) PORT_DIPLOCATION("SW2:7")
388407   PORT_DIPSETTING(   0x00, "B" )
389408   PORT_DIPSETTING(   0x40, "A" )
390   PORT_DIPNAME( 0x80, 0x80, "Test mode" )
391   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
392   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
393409INPUT_PORTS_END
394410
395411static GFXDECODE_START( st0016 )
src/mame/drivers/cchasm.c
r4135r4136
1414
1515#include "driver.h"
1616#include "cpu/z80/z80.h"
17#include "cpu/z80/z80daisy.h"
1718#include "cpu/m68000/m68000.h"
19#include "sound/ay8910.h"
20#include "sound/custom.h"
21#include "sound/dac.h"
1822#include "video/vector.h"
1923#include "machine/6840ptm.h"
2024#include "machine/z80ctc.h"
2125#include "cchasm.h"
22#include "sound/custom.h"
23#include "sound/ay8910.h"
24#include "cpu/z80/z80daisy.h"
2526
2627#define CCHASM_68K_CLOCK (XTAL_8MHz)
2728
src/mame/drivers/sbasketb.c
r4135r4136
4040
4141#include "driver.h"
4242#include "cpu/z80/z80.h"
43#include "machine/konami1.h"
4443#include "cpu/m6809/m6809.h"
44#include "sound/dac.h"
45#include "sound/sn76496.h"
4546#include "sound/vlm5030.h"
46#include "sound/dac.h"
47#include "machine/konami1.h"
4748
4849
4950extern UINT8 *sbasketb_scroll;
src/mame/drivers/qix.c
r4135r4136
10291029 *************************************/
10301030
10311031// 99 means the value is unknown
1032static int xor1_table[] =
1032static const UINT8 xor1_table[] =
10331033{
10341034   99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
10351035   99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
r4135r4136
10971097   99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
10981098};
10991099
1100static int xor2_table[] =
1100static const UINT8 xor2_table[] =
11011101{
11021102   99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
11031103   99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,
r4135r4136
11771177   }
11781178}
11791179
1180static int kram3_permut2(int tbl_index, int idx, int *xor_table)
1180static int kram3_permut2(int tbl_index, int idx, const UINT8 *xor_table)
11811181{
11821182   int xor = 0;
11831183
src/mame/drivers/adp.c
r4135r4136
350350   if (input_code_pressed(KEYCODE_8)) return 0x0080 ^ 0xffff;
351351
352352   return 0x0004 ^ 0xffff; // 0x0004
353
354   // FIXME: this code is never executed
353355   switch (mame_rand(space->machine) & 3)
354356   {
355357      case 0:
src/mame/drivers/cps3.c
r4135r4136
428428//          const pen_t *pal = &gfx->colortable[gfx->color_granularity * (color % gfx->total_colors)];
429429         UINT32 palbase = (gfx->color_granularity * color) & 0x1ffff;
430430         const pen_t *pal = &cps3_mame_colours[palbase];
431         UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
431         const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
432432
433433         int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
434434         int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
r4135r4136
501501                  {
502502                     for( y=sy; y<ey; y++ )
503503                     {
504                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
504                        const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
505505                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
506506
507507                        int x, x_index = x_index_base;
r4135r4136
520520                  {
521521                     for( y=sy; y<ey; y++ )
522522                     {
523                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
523                        const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
524524                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
525525
526526                        int x, x_index = x_index_base;
r4135r4136
540540                  {
541541                     for( y=sy; y<ey; y++ )
542542                     {
543                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
543                        const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
544544                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
545545
546546                        int x, x_index = x_index_base;
r4135r4136
560560                  {
561561                     for( y=sy; y<ey; y++ )
562562                     {
563                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
563                        const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
564564                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
565565
566566                        int x, x_index = x_index_base;
r4135r4136
797797};
798798
799799static UINT32* cps3_ss_ram;
800static UINT8* cps3_ss_ram_dirty;
801static int cps3_ss_ram_is_dirty;
802800
803static UINT8* cps3_char_ram_dirty;
804static int cps3_char_ram_is_dirty;
805
806801static void cps3_set_mame_colours(running_machine *machine, int colournum, UINT16 data, UINT32 fadeval )
807802{
808803   int r,g,b;
r4135r4136
845840static VIDEO_START(cps3)
846841{
847842   cps3_ss_ram       = auto_malloc(0x10000);
848   cps3_ss_ram_dirty = auto_malloc(0x400);
849   cps3_ss_ram_is_dirty = 1;
850843   memset(cps3_ss_ram, 0x00, 0x10000);
851   memset(cps3_ss_ram_dirty, 1, 0x400);
852844   state_save_register_global_pointer(machine, cps3_ss_ram, 0x10000/4);
853845
854846   cps3_char_ram = auto_malloc(0x800000);
855   cps3_char_ram_dirty = auto_malloc(0x800000/256);
856   cps3_char_ram_is_dirty = 1;
857847   memset(cps3_char_ram, 0x00, 0x800000);
858   memset(cps3_char_ram_dirty, 1, 0x8000);
859848   state_save_register_global_pointer(machine, cps3_char_ram, 0x800000 /4);
860849
861850   /* create the char set (gfx will then be updated dynamically from RAM) */
862   machine->gfx[0] = allocgfx(machine, &cps3_tiles8x8_layout);
863   machine->gfx[0]->total_colors = machine->config->total_colors / 16;
851   machine->gfx[0] = gfx_element_alloc(machine, &cps3_tiles8x8_layout, (UINT8 *)cps3_ss_ram, machine->config->total_colors / 16, 0);
864852
865853   //decode_ssram();
866854
867855   /* create the char set (gfx will then be updated dynamically from RAM) */
868   machine->gfx[1] = allocgfx(machine, &cps3_tiles16x16_layout);
869   machine->gfx[1]->total_colors = machine->config->total_colors / 64;
870   machine->gfx[1]->color_granularity=64;
856   machine->gfx[1] = gfx_element_alloc(machine, &cps3_tiles16x16_layout, (UINT8 *)cps3_char_ram, machine->config->total_colors / 64, 0);
857   machine->gfx[1]->color_granularity = 64;
871858
872859   //decode_charram();
873860
r4135r4136
968955         if (!bpp) machine->gfx[1]->color_granularity=256;
969956         else machine->gfx[1]->color_granularity=64;
970957
971         if (cps3_char_ram_dirty[tileno])
972         {
973            decodechar(machine->gfx[1], tileno, (UINT8*)cps3_char_ram);
974            cps3_char_ram_dirty[tileno] = 0;
975         }
976958         cps3_drawgfxzoom(machine, bitmap, machine->gfx[1],tileno,colour,xflip,yflip,(x*16)-scrollx%16,drawline-tilesubline,&clip,CPS3_TRANSPARENCY_PEN_INDEX,0, 0x10000, 0x10000, NULL, 0);
977
978959      }
979960   }
980961}
r4135r4136
12151196                        {
12161197                           int realtileno = tileno+count;
12171198
1218                           if (cps3_char_ram_dirty[realtileno])
1219                           {
1220                              decodechar(screen->machine->gfx[1], realtileno, (UINT8*)cps3_char_ram);
1221                              cps3_char_ram_dirty[realtileno] = 0;
1222                           }
1223
12241199                           if (global_alpha || alpha)
12251200                           {
12261201                              cps3_drawgfxzoom(screen->machine, renderbuffer_bitmap, screen->machine->gfx[1],realtileno,actualpal,0^flipx,0^flipy,current_xpos,current_ypos,&renderbuffer_clip,CPS3_TRANSPARENCY_PEN_INDEX_BLEND,0,xinc,yinc, NULL, 0);
r4135r4136
12931268            pal += cps3_ss_pal_base << 5;
12941269            tile+=0x200;
12951270
1296
1297            if (cps3_ss_ram_dirty[tile])
1298            {
1299               decodechar(screen->machine->gfx[0], tile, (UINT8*)cps3_ss_ram);
1300               cps3_ss_ram_dirty[tile] = 0;
1301            }
1302
13031271            cps3_drawgfxzoom(screen->machine, bitmap, screen->machine->gfx[0],tile,pal,flipx,flipy,x*8,y*8,cliprect,CPS3_TRANSPARENCY_PEN,0,0x10000,0x10000,NULL,0);
13041272            count++;
13051273         }
r4135r4136
13231291      // we only want to endian-flip the character data, the tilemap info is fine
13241292      data = LITTLE_ENDIANIZE_INT32(data);
13251293      mem_mask = LITTLE_ENDIANIZE_INT32(mem_mask);
1326
1327      cps3_ss_ram_dirty[offset/16] = 1;
1328      cps3_ss_ram_is_dirty = 1;
1294      gfx_element_mark_dirty(space->machine->gfx[0], offset/16);
13291295   }
13301296
13311297   COMBINE_DATA(&cps3_ss_ram[offset]);
r4135r4136
14191385   mem_mask = LITTLE_ENDIANIZE_INT32(mem_mask);
14201386   data = LITTLE_ENDIANIZE_INT32(data);
14211387   COMBINE_DATA(&cps3_char_ram[fulloffset]);
1422   cps3_char_ram_dirty[fulloffset/0x40] = 1;
1423   cps3_char_ram_is_dirty = 1;
1388   gfx_element_mark_dirty(space->machine->gfx[1], fulloffset/0x40);
14241389}
14251390
14261391/* FLASH ROM ACCESS */
r4135r4136
19041869static int last_normal_byte = 0;
19051870
19061871
1907static UINT32 process_byte( UINT8 real_byte, UINT32 destination, int max_length )
1872static UINT32 process_byte( running_machine *machine, UINT8 real_byte, UINT32 destination, int max_length )
19081873{
19091874   UINT8* dest       = (UINT8*)cps3_char_ram;
19101875
r4135r4136
19241889      while (cps3_rle_length)
19251890      {
19261891         dest[((destination+tranfercount)&0x7fffff)^3] = (last_normal_byte&0x3f);
1927         cps3_char_ram_dirty[((destination+tranfercount)&0x7fffff)/0x100] = 1;
1928         cps3_char_ram_is_dirty = 1;
1892         gfx_element_mark_dirty(machine->gfx[1], ((destination+tranfercount)&0x7fffff)/0x100);
19291893         //printf("RLE WRite Byte %08x, %02x\n", destination+tranfercount, real_byte);
19301894
19311895         tranfercount++;
r4135r4136
19441908      //printf("Write Normal Data\n");
19451909      dest[(destination&0x7fffff)^3] = real_byte;
19461910      last_normal_byte = real_byte;
1947      cps3_char_ram_dirty[(destination&0x7fffff)/0x100] = 1;
1948      cps3_char_ram_is_dirty = 1;
1911      gfx_element_mark_dirty(machine->gfx[1], (destination&0x7fffff)/0x100);
19491912      return 1;
19501913   }
19511914}
r4135r4136
19731936
19741937         real_byte = sourcedata[DMA_XOR((current_table_address+current_byte*2+0))];
19751938         //if (real_byte&0x80) return;
1976         length_processed = process_byte( real_byte, real_destination, length_remaining );
1939         length_processed = process_byte( machine, real_byte, real_destination, length_remaining );
19771940         length_remaining-=length_processed; // subtract the number of bytes the operation has taken
19781941         real_destination+=length_processed; // add it onto the destination
19791942         if (real_destination>0x7fffff) return;
r4135r4136
19811944
19821945         real_byte = sourcedata[DMA_XOR((current_table_address+current_byte*2+1))];
19831946         //if (real_byte&0x80) return;
1984         length_processed = process_byte( real_byte, real_destination, length_remaining );
1947         length_processed = process_byte( machine, real_byte, real_destination, length_remaining );
19851948         length_remaining-=length_processed; // subtract the number of bytes the operation has taken
19861949         real_destination+=length_processed; // add it onto the destination
19871950         if (real_destination>0x7fffff) return;
r4135r4136
19901953      else
19911954      {
19921955         UINT32 length_processed;
1993         length_processed = process_byte( current_byte, real_destination, length_remaining );
1956         length_processed = process_byte( machine, current_byte, real_destination, length_remaining );
19941957         length_remaining-=length_processed; // subtract the number of bytes the operation has taken
19951958         real_destination+=length_processed; // add it onto the destination
19961959         if (real_destination>0x7fffff) return;
r4135r4136
20031966
20041967static unsigned short lastb;
20051968static unsigned short lastb2;
2006static UINT32 ProcessByte8(UINT8 b,UINT32 dst_offset)
1969static UINT32 ProcessByte8(running_machine *machine,UINT8 b,UINT32 dst_offset)
20071970{
20081971   UINT8* destRAM = (UINT8*)cps3_char_ram;
20091972    int l=0;
r4135r4136
20161979       for(i=0;i<rle;++i)
20171980       {
20181981         destRAM[(dst_offset&0x7fffff)^3] = lastb;
2019         cps3_char_ram_dirty[(dst_offset&0x7fffff)/0x100] = 1;
2020         cps3_char_ram_is_dirty = 1;
1982         gfx_element_mark_dirty(machine->gfx[1], (dst_offset&0x7fffff)/0x100);
20211983
20221984         dst_offset++;
20231985          ++l;
r4135r4136
20311993       lastb2=lastb;
20321994       lastb=b;
20331995      destRAM[(dst_offset&0x7fffff)^3] = b;
2034      cps3_char_ram_dirty[(dst_offset&0x7fffff)/0x100] = 1;
2035      cps3_char_ram_is_dirty = 1;
1996      gfx_element_mark_dirty(machine->gfx[1], (dst_offset&0x7fffff)/0x100);
20361997       return 1;
20371998    }
20381999 }
r4135r4136
20612022            UINT8 real_byte;
20622023            p&=0x7f;
20632024            real_byte = px[DMA_XOR((current_table_address+p*2+0))];
2064            ds+=ProcessByte8(real_byte,ds);
2025            ds+=ProcessByte8(machine,real_byte,ds);
20652026            real_byte = px[DMA_XOR((current_table_address+p*2+1))];
2066            ds+=ProcessByte8(real_byte,ds);
2027            ds+=ProcessByte8(machine,real_byte,ds);
20672028          }
20682029          else
20692030          {
2070             ds+=ProcessByte8(p,ds);
2031             ds+=ProcessByte8(machine,p,ds);
20712032          }
20722033          ++src;
20732034          ctrl<<=1;
src/mame/drivers/3super8.c
r0r4136
1/*
2
33 Super 8
4
5this dump is bad
6
7
8Produttore  ?Italy?
9N.revisione
10CPU
11
121x 24mhz osc
132x fpga
141x z840006
151x PIC16c65a-20/p
161x 6295 oki
17
18ROMs
19
20Note
21
224x 8 dipswitch
231x 4 dispwitch
24
25*/
26
27#include "driver.h"
28#include "cpu/z80/z80.h"
29#include "sound/okim6295.h"
30
31static VIDEO_START(3super8)
32{
33
34}
35
36static VIDEO_UPDATE(3super8)
37{
38   return 0;
39}
40
41static ADDRESS_MAP_START( map, ADDRESS_SPACE_PROGRAM, 8 )
42   AM_RANGE(0x0000, 0x7fff) AM_ROM
43ADDRESS_MAP_END
44
45
46static INPUT_PORTS_START( 3super8 )
47INPUT_PORTS_END
48
49
50static const gfx_layout tiles8x8_layout =
51{
52   8,8,
53   RGN_FRAC(1,3),
54   6,
55   { RGN_FRAC(2,3)+0, RGN_FRAC(2,3)+2*8, RGN_FRAC(1,3)+0, RGN_FRAC(1,3)+2*8,RGN_FRAC(0,3)+0, RGN_FRAC(0,3)+2*8 },
56   { 0, 1,2,3,4,5,6,7 },
57   { 0*8, 1*8, 4*8, 5*8, 8*8, 9*8,  12*8, 13*8,},
58   16*8
59};
60
61static GFXDECODE_START( 3super8 )
62   GFXDECODE_ENTRY( "gfx", 0, tiles8x8_layout, 0, 16 )
63GFXDECODE_END
64
65
66
67static MACHINE_DRIVER_START( 3super8 )
68   /* basic machine hardware */
69   MDRV_CPU_ADD("main", Z80,24000000/4)       /* 6 MHz */
70   MDRV_CPU_PROGRAM_MAP(0,map)
71   //MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
72
73   /* video hardware */
74   MDRV_SCREEN_ADD("main", RASTER)
75   MDRV_SCREEN_REFRESH_RATE(60)
76   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
77   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
78   MDRV_SCREEN_SIZE(512, 256)
79   MDRV_SCREEN_VISIBLE_AREA(0, 512-1, 0, 256-0-1)
80
81   MDRV_GFXDECODE(3super8)
82   MDRV_PALETTE_LENGTH(0x100)
83
84   MDRV_VIDEO_START(3super8)
85   MDRV_VIDEO_UPDATE(3super8)
86
87   /* sound hardware */
88   MDRV_SPEAKER_STANDARD_MONO("mono")
89
90   MDRV_SOUND_ADD("oki", OKIM6295, 1056000)
91   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified
92   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
93MACHINE_DRIVER_END
94
95
96
97// all gfx / sound roms are bad.  they're definitely meant to have different data
98//  in each half, and maybe even be twice the size.
99//  in all cases the first half is missing (the sample table in the samples rom for example)
100//1.bin                                           1ST AND 2ND HALF IDENTICAL
101//2.bin                                           1ST AND 2ND HALF IDENTICAL
102//3.bin                                           1ST AND 2ND HALF IDENTICAL
103//sound.bin                                       1ST AND 2ND HALF IDENTICAL
104
105
106ROM_START( 3super8 )
107   ROM_REGION( 0x20000, "main", 0 )
108   ROM_LOAD( "prgrom.bin", 0x00000, 0x20000, CRC(37c85dfe) SHA1(56bd2fb859b17dda1e675a385b6bcd6867ecceb0)  )
109
110   ROM_REGION( 0x1000, "pic", 0 )
111   ROM_LOAD( "pic16c65a-20-p", 0x0000, 0x1000, NO_DUMP )
112
113   ROM_REGION( 0xc0000, "gfx", 0 )
114   ROM_LOAD( "1.bin", 0x00000, 0x40000, BAD_DUMP CRC(d9d3e21e) SHA1(2f3f07ca427d9f56f0ff143d15d95cbf15255e33) )
115   ROM_LOAD( "2.bin", 0x40000, 0x40000, BAD_DUMP CRC(fbb50ab1) SHA1(50a7ef9219c38d59117c510fe6d53fb3ba1fa456) )
116   ROM_LOAD( "3.bin", 0x80000, 0x40000, BAD_DUMP CRC(545aa4e6) SHA1(3348d4b692900c9e9cd4a52b20922a84e596cd35) )
117
118   ROM_REGION( 0x40000, "oki", 0 )
119   ROM_LOAD( "sound.bin", 0x00000, 0x40000, BAD_DUMP CRC(230b31c3) SHA1(38c107325d3a4e9781912078b1317dc9ba3e1ced) )
120ROM_END
121
122GAME( 199?, 3super8,  0,    3super8, 3super8,  0, ROT0, "unknown", "3 Super 8 (Italy)", GAME_NOT_WORKING|GAME_NO_SOUND )
src/mame/drivers/pcxt.c
r0r4136
1/******************************************************************************************
2
3PC-XT (c) 1987 IBM
4
5(Actually Arcade games running on more or less modified PC-XT HW)
6
7driver by Angelo Salese & Chris Hardy
8original tetriunk.c by David Haywood & Tomasz Slanina
9
10Notes:
11- The Korean Tetris is a blantant rip-off of the Mirrorsoft/Andromeda Software Tetris PC
12  version;
13
14TODO:
15- EGA/CGA/VGA emulation uses the bare minimum for these games,there are still a lot of
16  features that needs to be added;
17- Filetto: Add a proper FDC device,if you enable it will give a boot error,probably because it
18  expects that in the floppy drive shouldn't be anything,there's currently a kludge that
19  does the trick;
20- Filetto: Add sound,"buzzer" PC sound plus the UM5100 sound chip ,might be connected to the
21  prototyping card;
22- Korean Tetris: Add the aforementioned "buzzer" plus identify if there's any kind of sound
23  chip on it;
24
25********************************************************************************************
26Filetto HW notes:
27The PCB is a un-modified IBM-PC with a CGA adapter & a prototyping card that controls the
28interface between the pc and the Jamma connectors.Additionally there's also a UM5100 sound
29chip for the sound.
30PCB Part Number: S/N 90289764 NOVARXT
31PCB Contents:
321x UMC 8923S-UM5100 voice processor (upper board)
331x MMI PAL16L8ACN-940CRK9 (upper board)
341x AMD AMPAL16R8APC-8804DM (upper board)
351x AMD P8088-1 main processor 8.000MHz (lower board)
361x Proton PT8010AF PLCC 28.636MHz (lower board)
371x UMC 8928LP-UM8272A floppy disk controller (lower board)
381x UMC 8935CS-UM82C11 Printer Adapter Interface (lower board)
391x UMC 8936CS-UM8250B Programmable asynchronous communications element (lower board)
40There isn't any keyboard found connected to the pcb.
41********************************************************************************************
42Filetto SW notes:
43The software of this game can be extracted with a normal Windows program extractor.
44The files names are:
45-command.com  (1)
46-ibmbio.com   (1)
47-ibmdos.com   (1)
48-ansi.sys     (1)
49-config.sys   (2)
50-autoexec.bat (3)
51-x.exe        (4)
52(1)This is an old Italian version of MS-DOS (v3.30 18th March 1987).
53(2)Contains "device=ansi.sys",it's an hook-up for the graphics used by the BIOS.
54(3)It has an Echo off (as you can notice from the game itself) and then the loading of the
55main program (x.exe).
56(4)The main program,done in plain Basic with several Italian comments in it.The date of
57the main program is 9th October 1990.
58
59******************************************************************************************/
60
61#include "driver.h"
62#include "cpu/i86/i86.h"
63#include "video/generic.h"
64#include "machine/pit8253.h"
65#include "machine/8255ppi.h"
66#include "machine/8237dma.h"
67#include "machine/pic8259.h"
68#include "machine/mc146818.h"
69#include "sound/hc55516.h"
70#include "sound/beep.h"
71
72#define SET_VISIBLE_AREA(_x_,_y_) \
73   { \
74   rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); \
75   visarea.min_x = 0; \
76   visarea.max_x = _x_-1; \
77   visarea.min_y = 0; \
78   visarea.max_y = _y_-1; \
79   video_screen_configure(machine->primary_screen, _x_, _y_, &visarea, video_screen_get_frame_period(machine->primary_screen).attoseconds ); \
80   } \
81
82
83static UINT8 *vga_vram,*work_ram;
84static UINT8 video_regs[0x19];
85static UINT8 *vga_mode;
86static UINT8 hv_blank;
87static UINT8 *vga_bg_bank;
88
89static int bank;
90static int lastvalue;
91
92/*Add here Video regs defines...*/
93
94
95#define RES_320x200 0
96#define RES_640x200 1
97
98static void cga_alphanumeric_tilemap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,UINT16 size,UINT32 map_offs,UINT8 gfx_num);
99
100static VIDEO_START( filetto )
101{
102}
103
104static VIDEO_START( tetriskr )
105{
106}
107
108static READ8_HANDLER( vga_hvretrace_r )
109{
110   /*
111    Read-Only lower 8 bits,TRUSTED
112    ---- x--- Vertical Retrace
113    ---- ---x Horizontal Retrace
114    */
115   static UINT8 res;
116   static int h,w;
117   res = 0;
118   h = video_screen_get_height(space->machine->primary_screen);
119   w = video_screen_get_width(space->machine->primary_screen);
120
121//  popmessage("%d %d",h,w);
122
123   if (video_screen_get_hpos(space->machine->primary_screen) > h)
124      res|= 1;
125
126   if (video_screen_get_vpos(space->machine->primary_screen) > w)
127      res|= 8;
128
129   return res;
130}
131
132/*Basic Graphic mode */
133/*TODO: non-black colours should use the bright versions*/
134static void cga_graphic_bitmap(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,UINT16 size,UINT32 map_offs)
135{
136   static UINT16 x,y;
137   static UINT32 offs;
138
139   SET_VISIBLE_AREA(320,200);
140   offs = map_offs;
141   for(y=0;y<200;y+=2)
142      for(x=0;x<320;x+=4)
143      {
144         *BITMAP_ADDR16(bitmap, y, x+0) = machine->pens[0x200+(((vga_vram[offs] & 0xc0)>>6)<<1)];
145         *BITMAP_ADDR16(bitmap, y, x+1) = machine->pens[0x200+(((vga_vram[offs] & 0x30)>>4)<<1)];
146         *BITMAP_ADDR16(bitmap, y, x+2) = machine->pens[0x200+(((vga_vram[offs] & 0x0c)>>2)<<1)];
147         *BITMAP_ADDR16(bitmap, y, x+3) = machine->pens[0x200+(((vga_vram[offs] & 0x03)>>0)<<1)];
148         offs++;
149      }
150
151   offs = 0x2000+map_offs;
152   for(y=1;y<200;y+=2)
153      for(x=0;x<320;x+=4)
154      {
155         *BITMAP_ADDR16(bitmap, y, x+0) = machine->pens[0x200+(((vga_vram[offs] & 0xc0)>>6)<<1)];
156         *BITMAP_ADDR16(bitmap, y, x+1) = machine->pens[0x200+(((vga_vram[offs] & 0x30)>>4)<<1)];
157         *BITMAP_ADDR16(bitmap, y, x+2) = machine->pens[0x200+(((vga_vram[offs] & 0x0c)>>2)<<1)];
158         *BITMAP_ADDR16(bitmap, y, x+3) = machine->pens[0x200+(((vga_vram[offs] & 0x03)>>0)<<1)];
159         offs++;
160      }
161
162}
163
164
165
166static void cga_alphanumeric_tilemap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,UINT16 size,UINT32 map_offs,UINT8 gfx_num)
167{
168   static UINT32 offs,x,y,max_x,max_y;
169
170   /*define the visible area*/
171   switch(size)
172   {
173      case RES_320x200:
174         SET_VISIBLE_AREA(320,200);
175         max_x = 40;
176         max_y = 25;
177         break;
178      case RES_640x200:
179         SET_VISIBLE_AREA(640,200);
180         max_x = 80;
181         max_y = 25;
182         break;
183   }
184
185   offs = map_offs;
186
187   for(y=0;y<max_y;y++)
188      for(x=0;x<max_x;x++)
189      {
190         int tile =  vga_vram[offs] & 0xff;
191         int color = vga_vram[offs+1] & 0xff;
192
193         drawgfx(bitmap,machine->gfx[gfx_num],
194               tile,
195               color,
196               0,0,
197               x*8,y*8,
198               cliprect,((color & 0xf0) != 0) ? TRANSPARENCY_NONE : TRANSPARENCY_PEN,0);
199
200         offs+=2;
201      }
202}
203
204
205static VIDEO_UPDATE( filetto )
206{
207/*          xx1x xxxx  Attribute bit 7. 0=blink, 1=Intesity
208            xxx1 xxxx  640x200 mode
209            xxxx 1xxx  Enable video signal
210            xxxx x1xx  Select B/W mode
211            xxxx xx1x  Select graphics
212            xxxx xxx1  80x25 text
213            */
214   bitmap_fill(bitmap, cliprect, 0);
215
216   if(vga_mode[0] & 8)
217   {
218      if(vga_mode[0] & 2)
219         cga_graphic_bitmap(screen->machine,bitmap,cliprect,0,0x18000);
220      else
221      {
222         switch(vga_mode[0] & 1)
223         {
224            case 0x00:
225               cga_alphanumeric_tilemap(screen->machine,bitmap,cliprect,RES_320x200,0x18000,2);
226               break;
227            case 0x01:
228               cga_alphanumeric_tilemap(screen->machine,bitmap,cliprect,RES_640x200,0x18000,2);
229               break;
230         }
231      }
232   }
233
234   return 0;
235}
236
237static void vga_bitmap_layer(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
238{
239   int x,y,z;
240   UINT8 *region = memory_region(machine, "user1");
241   static UINT32 cur_bank;
242
243   /*TODO: might be a different descramble algorythm plus plain bg bank*/
244   cur_bank = (((8-vga_bg_bank[0]) & 0x1f)*0x10000);
245
246   for(y=0;y<200;y+=8)
247   {
248      for(z=0;z<8;z++)
249      for(x=0;x<320;x++)
250      {
251         *BITMAP_ADDR16(bitmap, y+z, x) = 0x200+(region[(y*320/8)+x+z*0x2000+cur_bank+8] & 0xf);
252      }
253   }
254}
255
256/*S3 Video card,VGA*/
257static VIDEO_UPDATE( tetriskr )
258{
259   bitmap_fill(bitmap, cliprect, 0);
260
261   if(vga_mode[0] & 8)
262   {
263      if(vga_mode[0] & 2)
264         cga_graphic_bitmap(screen->machine,bitmap,cliprect,0,0x18000);
265      else
266      {
267         vga_bitmap_layer(screen->machine,bitmap,cliprect);
268
269         switch(vga_mode[0] & 1)
270         {
271            case 0x00:
272               cga_alphanumeric_tilemap(screen->machine,bitmap,cliprect,RES_320x200,0x18000,0);
273               break;
274            case 0x01:
275               cga_alphanumeric_tilemap(screen->machine,bitmap,cliprect,RES_640x200,0x18000,0);
276               break;
277         }
278      }
279   }
280
281   return 0;
282}
283
284static READ8_HANDLER( vga_regs_r )
285{
286   logerror("(PC=%05x) Warning: VGA reg port read\n",cpu_get_pc(space->cpu));
287   return 0xff;
288}
289
290static WRITE8_HANDLER( vga_regs_w )
291{
292   static UINT8 video_index;
293
294   if(offset == 0)
295   {
296      video_index = data;
297   }
298   if(offset == 1)
299   {
300      if(video_index <= 0x18)
301      {
302         video_regs[video_index] = data;
303         //logerror("write %02x to video register [%02x]",data,video_index);
304      }
305      else
306         logerror("(PC=%05x) Warning: Undefined VGA reg port write (I=%02x D=%02x)\n",cpu_get_pc(space->cpu),video_index,data);
307   }
308}
309
310static WRITE8_HANDLER( vga_vram_w )
311{
312   vga_vram[offset] = data;
313}
314
315/*end of Video HW file*/
316
317static struct {
318   const device_config   *pit8253;
319   const device_config   *pic8259_1;
320   const device_config   *pic8259_2;
321   const device_config   *dma8237_1;
322   const device_config   *dma8237_2;
323} filetto_devices;
324
325
326static UINT8 disk_data[2];
327
328static READ8_HANDLER( disk_iobank_r )
329{
330   //printf("Read Prototyping card [%02x] @ PC=%05x\n",offset,cpu_get_pc(space->cpu));
331   //if(offset == 0) return input_port_read(space->machine, "DSW");
332   if(offset == 1) return input_port_read(space->machine, "IN1");
333
334   return disk_data[offset];
335}
336
337static WRITE8_HANDLER( disk_iobank_w )
338{
339/*
340    BIOS does a single out $0310,$F0 on reset
341
342    Then does 2 outs to set the bank..
343
344        X1  X2
345
346        $F0 $F2 = m0
347        $F1 $F2 = m1
348        $F0 $F3 = m2
349        $F1 $F3 = m3
350
351    The sequence of
352
353    out $0310,X1
354    out $0310,X2
355
356    sets the selected rom that appears in $C0000-$CFFFF
357
358*/
359   int newbank = 0;
360
361//  printf("bank %d set to %02X\n", offset,data);
362
363   if (data == 0xF0)
364   {
365      newbank = 0;
366   }
367   else
368   {
369      if((lastvalue == 0xF0) && (data == 0xF2))
370         newbank = 0;
371      else if ((lastvalue == 0xF1) && (data == 0xF2))
372         newbank = 1;
373      else if ((lastvalue == 0xF0) && (data == 0xF3))
374         newbank = 2;
375      else if ((lastvalue == 0xF1) && (data == 0xF3))
376         newbank = 3;
377   }
378
379//  printf("newbank = %d\n", newbank);
380
381   if (newbank != bank)
382   {
383      bank = newbank;
384      memory_set_bankptr(space->machine,  1,memory_region(space->machine, "user1") + 0x10000 * bank );
385   }
386
387   lastvalue = data;
388
389   disk_data[offset] = data;
390}
391
392/*********************************
393Pit8253
394*********************************/
395
396static PIT8253_OUTPUT_CHANGED( pc_timer0_w )
397{
398    pic8259_set_irq_line(filetto_devices.pic8259_1, 0, state);
399}
400
401static const struct pit8253_config pc_pit8253_config =
402{
403   {
404      {
405         4772720/4,            /* heartbeat IRQ */
406         pc_timer0_w
407      }, {
408         4772720/4,            /* dram refresh */
409         NULL
410      }, {
411         4772720/4,            /* pio port c pin 4, and speaker polling enough */
412         NULL
413      }
414   }
415};
416
417static UINT8 port_b_data;
418static UINT8 wss1_data,wss2_data;
419
420static READ8_DEVICE_HANDLER( port_a_r )
421{
422   if(!(port_b_data & 0x80))//???
423   {
424      /*
425        x--- ---- Undefined (Always 0)
426        -x-- ---- B: Floppy disk drive installed.
427        --xx ---- Default Display Mode
428        ---- xx-- Undefined (Always 1)
429        ---- --x- 8087 NDP installed
430        ---- ---x Undefined (Always 1)
431        */
432      return wss1_data;
433   }
434   else//keyboard emulation
435   {
436      //cpu_set_input_line(device->machine->cpu[0],1,PULSE_LINE);
437      return 0x00;//Keyboard is disconnected
438      //return 0xaa;//Keyboard code
439   }
440}
441
442static READ8_DEVICE_HANDLER( port_b_r )
443{
444   return port_b_data;
445}
446
447static READ8_DEVICE_HANDLER( port_c_r )
448{
449   return wss2_data;//???
450}
451
452/*'buzzer' sound routes here*/
453/* Filetto uses this for either beep and um5100 sound routing,probably there's a mux somewhere.*/
454/* The Korean Tetris uses it as a regular buzzer,probably the sound is all in there...*/
455static WRITE8_DEVICE_HANDLER( port_b_w )
456{
457   port_b_data = data;
458//  hc55516_digit_w(0, data);
459//  popmessage("%02x\n",data);
460//  beep_set_state(0, 0);
461//  beep_set_state(0, 1);
462//  beep_set_frequency(0, port_b_data);
463}
464
465static WRITE8_DEVICE_HANDLER( wss_1_w )
466{
467   wss1_data = data;
468}
469
470static WRITE8_DEVICE_HANDLER( wss_2_w )
471{
472   wss2_data = data;
473}
474
475static WRITE8_DEVICE_HANDLER( sys_reset_w )
476{
477   cpu_set_input_line(device->machine->cpu[0],INPUT_LINE_RESET,PULSE_LINE);
478}
479
480
481static const ppi8255_interface filetto_ppi8255_intf[2] =
482{
483   {
484      port_a_r,         /* Port A read */
485      port_b_r,         /* Port B read */
486      port_c_r,           /* Port C read */
487      NULL,            /* Port A write */
488      port_b_w,            /* Port B write */
489      NULL            /* Port C write */
490   },
491   {
492      NULL,            /* Port A read */
493      NULL,            /* Port B read */
494      NULL,            /* Port C read */
495      wss_1_w,         /* Port A write */
496      wss_2_w,         /* Port B write */
497      sys_reset_w         /* Port C write */
498   }
499};
500
501/*Floppy Disk Controller 765 device*/
502/*Currently we only emulate it at a point that the BIOS will pass the checks*/
503static UINT8 status;
504
505#define FDC_BUSY 0x10
506#define FDC_WRITE 0x40
507#define FDC_READ 0x00 /*~0x40*/
508
509static READ8_HANDLER( fdc765_status_r )
510{
511   static UINT8 tmp,clr_status;
512//  popmessage("Read FDC status @ PC=%05x",cpu_get_pc(space->cpu));
513   tmp = status | 0x80;
514   clr_status++;
515   if(clr_status == 0x10)
516   {
517      status = 0;
518      clr_status = 0;
519   }
520   return tmp;
521}
522
523static READ8_HANDLER( fdc765_data_r )
524{
525   status = (FDC_READ);
526   return 0xc0;
527}
528
529static WRITE8_HANDLER( fdc765_data_w )
530{
531   status = (FDC_WRITE);
532}
533
534static UINT8 drive_data;
535
536static WRITE8_HANDLER( drive_selection_w )
537{
538   drive_data = data;
539   /*write to this area then expects that location [43e] has the bit 7 activated*/
540   work_ram[0x3e] = 0x80;
541}
542
543/******************
544DMA8237 Controller
545******************/
546
547static UINT8 dma_offset[2][4];
548static UINT8 at_pages[0x10];
549
550static DMA8237_MEM_READ( pc_dma_read_byte )
551{
552   const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
553   offs_t page_offset = (((offs_t) dma_offset[0][channel]) << 16)
554      & 0xFF0000;
555
556   return memory_read_byte(space, page_offset + offset);
557}
558
559
560static DMA8237_MEM_WRITE( pc_dma_write_byte )
561{
562   const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
563   offs_t page_offset = (((offs_t) dma_offset[0][channel]) << 16)
564      & 0xFF0000;
565
566   memory_write_byte(space, page_offset + offset, data);
567}
568
569static READ8_HANDLER(dma_page_select_r)
570{
571   UINT8 data = at_pages[offset % 0x10];
572
573   switch(offset % 8) {
574   case 1:
575      data = dma_offset[(offset / 8) & 1][2];
576      break;
577   case 2:
578      data = dma_offset[(offset / 8) & 1][3];
579      break;
580   case 3:
581      data = dma_offset[(offset / 8) & 1][1];
582      break;
583   case 7:
584      data = dma_offset[(offset / 8) & 1][0];
585      break;
586   }
587   return data;
588}
589
590
591static WRITE8_HANDLER(dma_page_select_w)
592{
593   at_pages[offset % 0x10] = data;
594
595   switch(offset % 8) {
596   case 1:
597      dma_offset[(offset / 8) & 1][2] = data;
598      break;
599   case 2:
600      dma_offset[(offset / 8) & 1][3] = data;
601      break;
602   case 3:
603      dma_offset[(offset / 8) & 1][1] = data;
604      break;
605   case 7:
606      dma_offset[(offset / 8) & 1][0] = data;
607      break;
608   }
609}
610
611
612static const struct dma8237_interface dma8237_1_config =
613{
614   "main",
615   1.0e-6, // 1us
616
617   pc_dma_read_byte,
618   pc_dma_write_byte,
619
620   { 0, 0, NULL, NULL },
621   { 0, 0, NULL, NULL },
622   NULL
623};
624
625/******************
6268259 IRQ controller
627******************/
628
629static PIC8259_SET_INT_LINE( pic8259_1_set_int_line ) {
630   cpu_set_input_line(device->machine->cpu[0], 0, interrupt ? HOLD_LINE : CLEAR_LINE);
631}
632
633static const struct pic8259_interface pic8259_1_config = {
634   pic8259_1_set_int_line
635};
636
637static PIC8259_SET_INT_LINE( pic8259_2_set_int_line ) {
638   pic8259_set_irq_line( filetto_devices.pic8259_1, 2, interrupt);
639}
640
641static const struct pic8259_interface pic8259_2_config = {
642   pic8259_2_set_int_line
643};
644
645static IRQ_CALLBACK(irq_callback)
646{
647   int r = 0;
648   r = pic8259_acknowledge(filetto_devices.pic8259_2);
649   if (r==0)
650   {
651      r = pic8259_acknowledge(filetto_devices.pic8259_1);
652   }
653   return r;
654}
655
656static ADDRESS_MAP_START( filetto_map, ADDRESS_SPACE_PROGRAM, 8 )
657   AM_RANGE(0x00000, 0x003ff) AM_RAM //irq vectors
658   AM_RANGE(0x00400, 0x007ff) AM_RAM AM_BASE(&work_ram)
659   AM_RANGE(0x00800, 0x9ffff) AM_RAM //work RAM 640KB
660   AM_RANGE(0xa0000, 0xbffff) AM_RAM_WRITE(vga_vram_w) AM_BASE(&vga_vram)//VGA RAM
661   AM_RANGE(0xc0000, 0xcffff) AM_READ(SMH_BANK1)
662   AM_RANGE(0xf0000, 0xfffff) AM_ROM
663ADDRESS_MAP_END
664
665static ADDRESS_MAP_START( filetto_io, ADDRESS_SPACE_IO, 8 )
666   ADDRESS_MAP_GLOBAL_MASK(0x3ff)
667   AM_RANGE(0x0000, 0x000f) AM_DEVREADWRITE(DMA8237, "dma8237_1", dma8237_r, dma8237_w ) //8237 DMA Controller
668   AM_RANGE(0x0020, 0x002f) AM_DEVREADWRITE(PIC8259, "pic8259_1", pic8259_r, pic8259_w ) //8259 Interrupt control
669   AM_RANGE(0x0040, 0x0043) AM_DEVREADWRITE(PIT8253, "pit8253", pit8253_r, pit8253_w)    //8253 PIT
670   AM_RANGE(0x0060, 0x0063) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)  //PPI 8255
671   AM_RANGE(0x0064, 0x0066) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)  //PPI 8255
672   AM_RANGE(0x0070, 0x007f) AM_READWRITE(mc146818_port_r,mc146818_port_w)
673   AM_RANGE(0x0080, 0x0087) AM_READWRITE(dma_page_select_r,dma_page_select_w)
674   AM_RANGE(0x00a0, 0x00af) AM_DEVREADWRITE(PIC8259, "pic8259_2", pic8259_r, pic8259_w )
675//  AM_RANGE(0x0200, 0x020f) AM_RAM //game port
676   AM_RANGE(0x0201, 0x0201) AM_READ_PORT("COIN") //game port
677   AM_RANGE(0x0278, 0x027f) AM_RAM //printer (parallel) port latch
678   AM_RANGE(0x02f8, 0x02ff) AM_RAM //Modem port
679   AM_RANGE(0x0310, 0x0311) AM_READWRITE(disk_iobank_r,disk_iobank_w) //Prototyping card
680   AM_RANGE(0x0312, 0x0312) AM_READ_PORT("IN0") //Prototyping card,read only
681   AM_RANGE(0x0378, 0x037f) AM_RAM //printer (parallel) port
682   AM_RANGE(0x03bc, 0x03bf) AM_RAM //printer port
683   AM_RANGE(0x03b4, 0x03b5) AM_READWRITE(vga_regs_r,vga_regs_w) //various VGA/CGA/EGA regs
684   AM_RANGE(0x03d4, 0x03d5) AM_READWRITE(vga_regs_r,vga_regs_w) //mirror of above
685   AM_RANGE(0x03d8, 0x03d9) AM_RAM AM_BASE(&vga_mode)
686   AM_RANGE(0x03ba, 0x03bb) AM_READ(vga_hvretrace_r)//Controls H-Blank/V-Blank
687   AM_RANGE(0x03da, 0x03db) AM_READ(vga_hvretrace_r)//mirror of above
688   AM_RANGE(0x03f2, 0x03f2) AM_WRITE(drive_selection_w)
689   AM_RANGE(0x03f4, 0x03f4) AM_READ(fdc765_status_r) //765 Floppy Disk Controller (FDC) Status
690   AM_RANGE(0x03f5, 0x03f5) AM_READWRITE(fdc765_data_r,fdc765_data_w)//FDC Data
691   AM_RANGE(0x03f8, 0x03ff) AM_RAM //rs232c (serial) port
692ADDRESS_MAP_END
693
694static ADDRESS_MAP_START( tetriskr_io, ADDRESS_SPACE_IO, 8 )
695   ADDRESS_MAP_GLOBAL_MASK(0x3ff)
696   AM_RANGE(0x0000, 0x000f) AM_DEVREADWRITE(DMA8237, "dma8237_1", dma8237_r, dma8237_w ) //8237 DMA Controller
697   AM_RANGE(0x0020, 0x002f) AM_DEVREADWRITE(PIC8259, "pic8259_1", pic8259_r, pic8259_w ) //8259 Interrupt control
698   AM_RANGE(0x0040, 0x0043) AM_DEVREADWRITE(PIT8253, "pit8253", pit8253_r, pit8253_w)    //8253 PIT
699   AM_RANGE(0x0060, 0x0063) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)  //PPI 8255
700   AM_RANGE(0x0064, 0x0066) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)  //PPI 8255
701   AM_RANGE(0x0070, 0x007f) AM_READWRITE(mc146818_port_r,mc146818_port_w)
702   AM_RANGE(0x0080, 0x0087) AM_READWRITE(dma_page_select_r,dma_page_select_w)
703   AM_RANGE(0x00a0, 0x00af) AM_DEVREADWRITE(PIC8259, "pic8259_2", pic8259_r, pic8259_w )
704     AM_RANGE(0x0200, 0x020f) AM_RAM //game port
705//  AM_RANGE(0x0201, 0x0201) AM_READ_PORT("IN1") //game port
706   AM_RANGE(0x0278, 0x027f) AM_RAM //printer (parallel) port latch
707   AM_RANGE(0x02f8, 0x02ff) AM_RAM //Modem port
708//  AM_RANGE(0x0310, 0x0311) AM_READWRITE(disk_iobank_r,disk_iobank_w) //Prototyping card
709//  AM_RANGE(0x0312, 0x0312) AM_READ_PORT("IN0") //Prototyping card,read only
710   AM_RANGE(0x0378, 0x037f) AM_RAM //printer (parallel) port
711   AM_RANGE(0x03c0, 0x03c0) AM_RAM AM_BASE(&vga_bg_bank)
712   AM_RANGE(0x03c8, 0x03c8) AM_READ_PORT("IN0")
713   AM_RANGE(0x03c9, 0x03c9) AM_READ_PORT("IN1")
714//  AM_RANGE(0x03ce, 0x03ce) AM_READ_PORT("IN1")
715   AM_RANGE(0x03bc, 0x03bf) AM_RAM //printer port
716   AM_RANGE(0x03b4, 0x03b5) AM_READWRITE(vga_regs_r,vga_regs_w) //various VGA/CGA/EGA regs
717   AM_RANGE(0x03d4, 0x03d5) AM_READWRITE(vga_regs_r,vga_regs_w) //mirror of above
718   AM_RANGE(0x03d8, 0x03d9) AM_RAM AM_BASE(&vga_mode)
719   AM_RANGE(0x03ba, 0x03bb) AM_READ(vga_hvretrace_r)//Controls H-Blank/V-Blank
720   AM_RANGE(0x03da, 0x03db) AM_READ(vga_hvretrace_r)//mirror of above
721   AM_RANGE(0x03f2, 0x03f2) AM_WRITE(drive_selection_w)
722   AM_RANGE(0x03f4, 0x03f4) AM_READ(fdc765_status_r) //765 Floppy Disk Controller (FDC) Status
723   AM_RANGE(0x03f5, 0x03f5) AM_READWRITE(fdc765_data_r,fdc765_data_w)//FDC Data
724   AM_RANGE(0x03f8, 0x03ff) AM_RAM //rs232c (serial) port
725ADDRESS_MAP_END
726
727static INPUT_PORTS_START( filetto )
728   PORT_START("IN0")
729   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(1)
730   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_PLAYER(1)
731   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_PLAYER(1)
732   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
733   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(2)
734   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_PLAYER(2)
735   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_PLAYER(2)
736   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
737
738   PORT_START("IN1")
739   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Coinage ) )
740   PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
741   PORT_DIPSETTING(    0x01, DEF_STR( 1C_1C ) )
742   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) )
743   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
744   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
745   PORT_DIPNAME( 0x04, 0x04, "Extra Play" )
746   PORT_DIPSETTING(    0x04, DEF_STR( No ) )
747   PORT_DIPSETTING(    0x00, "Play at 6th match reached" )
748   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Difficulty ) )
749   PORT_DIPSETTING(    0x00, DEF_STR( Normal ) )
750   PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )
751   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
752   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
753   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
754
755   PORT_START("COIN")
756   PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
757   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 )
758   PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED )
759INPUT_PORTS_END
760
761static INPUT_PORTS_START( tetriskr )
762   PORT_START("IN0")
763   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
764   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) ) //probably unused
765   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
766   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
767   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
768   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(1)
769   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_PLAYER(1)
770   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_PLAYER(1)
771   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
772   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
773   PORT_START("IN1") //dip-switches?
774   PORT_DIPNAME( 0x01, 0x01, "IN1" )
775   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
776   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
777   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
778   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
779   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
780   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
781   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
782   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
783   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
784   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
785   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
786   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
787   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
788   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
789   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
790   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
791   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
792   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
793   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
794   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
795   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
796   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
797   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
798INPUT_PORTS_END
799
800
801static const gfx_layout dos_chars =
802{
803   8,16,
804   256,
805   1,
806   { 0 },
807   { 0, 1, 2, 3, 4, 5, 6, 7 },
808   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
809   (0x4000)+(0*8),(0x4000)+(1*8),(0x4000)+(2*8),(0x4000)+(3*8),(0x4000)+(4*8),(0x4000)+(5*8),(0x4000)+(6*8),(0x4000)+(7*8) },
810   8*8
811};
812
813static const gfx_layout dos_chars2 =
814{
815   8,8,
816   256,
817   1,
818   { 0 },
819   { 0, 1, 2, 3, 4, 5, 6, 7 },
820   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
821   8*8
822};
823
824static GFXDECODE_START( filetto )
825   GFXDECODE_ENTRY( "gfx1", 0x0000, dos_chars,    0, 0x100 )
826   GFXDECODE_ENTRY( "gfx1", 0x1000, dos_chars2,   0, 0x100 )
827   GFXDECODE_ENTRY( "gfx1", 0x1800, dos_chars2,   0, 0x100 )
828GFXDECODE_END
829
830static GFXDECODE_START( tetriskr )
831   GFXDECODE_ENTRY( "gfx1", 0x0000, dos_chars2,   0, 0x100 )
832GFXDECODE_END
833
834
835/*
836BLACK = 0
837BLUE = 1
838GREEN = 2
839CYAN = 3
840RED = 4
841MAGENTA = 5
842BROWN = 6
843LIGHT GRAY = 7
844*/
845
846static const rgb_t defcolors[]=
847{
848   MAKE_RGB(0x00,0x00,0x00),
849   MAKE_RGB(0x00,0x00,0xaa),
850   MAKE_RGB(0x00,0xaa,0x00),
851   MAKE_RGB(0x00,0xaa,0xaa),
852   MAKE_RGB(0xaa,0x00,0x00),
853   MAKE_RGB(0xaa,0x00,0xaa),
854   MAKE_RGB(0xaa,0xaa,0x00),
855   MAKE_RGB(0xaa,0xaa,0xaa),
856   MAKE_RGB(0x55,0x55,0x55),
857   MAKE_RGB(0x55,0x55,0xff),
858   MAKE_RGB(0x55,0xff,0x55),
859   MAKE_RGB(0x55,0xff,0xff),
860   MAKE_RGB(0xff,0x55,0x55),
861   MAKE_RGB(0xff,0x55,0xff),
862   MAKE_RGB(0xff,0xff,0x55),
863   MAKE_RGB(0xff,0xff,0xff)
864};
865
866static PALETTE_INIT(filetto)
867{
868   /*Note:palette colors are 6bpp...
869    xxxx xx--
870    */
871   int ix,iy;
872
873   for(ix=0;ix<0x300;ix++)
874      palette_set_color(machine, ix,MAKE_RGB(0x00,0x00,0x00));
875
876   //regular colors
877   for(iy=0;iy<0x10;iy++)
878   {
879      for(ix=0;ix<0x10;ix++)
880      {
881         palette_set_color(machine,(ix*2)+1+(iy*0x20),defcolors[ix]);
882         palette_set_color(machine,(ix*2)+0+(iy*0x20),defcolors[iy]);
883      }
884   }
885
886   //bitmap mode
887   for(ix=0;ix<0x10;ix++)
888      palette_set_color(machine, 0x200+ix,defcolors[ix]);
889   //todo: 256 colors
890}
891
892static MACHINE_RESET( filetto )
893{
894   bank = -1;
895   lastvalue = -1;
896   hv_blank = 0;
897   cpu_set_irq_callback(machine->cpu[0], irq_callback);
898   filetto_devices.pit8253 = device_list_find_by_tag( machine->config->devicelist, PIT8253, "pit8253" );
899   filetto_devices.pic8259_1 = device_list_find_by_tag( machine->config->devicelist, PIC8259, "pic8259_1" );
900   filetto_devices.pic8259_2 = device_list_find_by_tag( machine->config->devicelist, PIC8259, "pic8259_2" );
901   filetto_devices.dma8237_1 = device_list_find_by_tag( machine->config->devicelist, DMA8237, "dma8237_1" );
902   filetto_devices.dma8237_2 = device_list_find_by_tag( machine->config->devicelist, DMA8237, "dma8237_2" );
903}
904
905static MACHINE_DRIVER_START( filetto )
906   MDRV_CPU_ADD("main", I8088, 8000000) //or regular PC-XT 14318180/3 clock?
907   MDRV_CPU_PROGRAM_MAP(filetto_map,0)
908   MDRV_CPU_IO_MAP(filetto_io,0)
909
910   MDRV_MACHINE_RESET( filetto )
911
912   MDRV_PIT8253_ADD( "pit8253", pc_pit8253_config )
913
914   MDRV_PPI8255_ADD( "ppi8255_0", filetto_ppi8255_intf[0] )
915   MDRV_PPI8255_ADD( "ppi8255_1", filetto_ppi8255_intf[1] )
916
917   MDRV_DMA8237_ADD( "dma8237_1", dma8237_1_config )
918
919   MDRV_PIC8259_ADD( "pic8259_1", pic8259_1_config )
920
921   MDRV_PIC8259_ADD( "pic8259_2", pic8259_2_config )
922
923   MDRV_GFXDECODE(filetto)
924
925   MDRV_SCREEN_ADD("main", RASTER)
926   MDRV_SCREEN_REFRESH_RATE(60)
927   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
928   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
929   MDRV_SCREEN_SIZE(640, 480)
930   MDRV_SCREEN_VISIBLE_AREA(0*8, 640-1, 0*8, 480-1)
931
932   MDRV_PALETTE_LENGTH(0x300)
933
934   MDRV_PALETTE_INIT(filetto)
935
936   MDRV_VIDEO_START(filetto)
937   MDRV_VIDEO_UPDATE(filetto)
938
939   /*Sound Hardware*/
940   MDRV_SPEAKER_STANDARD_MONO("mono")
941
942   MDRV_SOUND_ADD("voice", HC55516, 8000000/4)//8923S-UM5100 is a HC55536 with ROM hook-up
943   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60)
944
945//  PC "buzzer" sound
946   MDRV_SOUND_ADD("beep", BEEP, 0)
947   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.33)
948MACHINE_DRIVER_END
949
950static MACHINE_DRIVER_START( tetriskr )
951   MDRV_CPU_ADD("main", I8088, 14318180/3)
952   MDRV_CPU_PROGRAM_MAP(filetto_map,0)
953   MDRV_CPU_IO_MAP(tetriskr_io,0)
954
955   MDRV_MACHINE_RESET( filetto )
956
957   MDRV_PIT8253_ADD( "pit8253", pc_pit8253_config )
958
959   MDRV_PPI8255_ADD( "ppi8255_0", filetto_ppi8255_intf[0] )
960   MDRV_PPI8255_ADD( "ppi8255_1", filetto_ppi8255_intf[1] )
961
962   MDRV_DMA8237_ADD( "dma8237_1", dma8237_1_config )
963
964   MDRV_PIC8259_ADD( "pic8259_1", pic8259_1_config )
965
966   MDRV_PIC8259_ADD( "pic8259_2", pic8259_2_config )
967
968   MDRV_GFXDECODE(tetriskr)
969
970   MDRV_SCREEN_ADD("main", RASTER)
971   MDRV_SCREEN_REFRESH_RATE(60)
972   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
973   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
974   MDRV_SCREEN_SIZE(640, 480)
975   MDRV_SCREEN_VISIBLE_AREA(0*8, 640-1, 0*8, 480-1)
976
977   MDRV_PALETTE_LENGTH(0x300)
978
979   MDRV_PALETTE_INIT(filetto)
980
981   MDRV_VIDEO_START(tetriskr)
982   MDRV_VIDEO_UPDATE(tetriskr)
983
984   /*Sound Hardware*/
985   MDRV_SPEAKER_STANDARD_MONO("mono")
986
987//  PC "buzzer" sound
988   MDRV_SOUND_ADD("beep", BEEP, 0)
989   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.33)
990MACHINE_DRIVER_END
991
992ROM_START( filetto )
993   ROM_REGION( 0x100000, "main", 0 )
994   ROM_LOAD("u49.bin", 0xfc000, 0x2000, CRC(1be6948a) SHA1(9c433f63d347c211ee4663f133e8417221bc4bf0))
995   ROM_RELOAD(         0xf8000, 0x2000 )
996   ROM_RELOAD(         0xf4000, 0x2000 )
997   ROM_RELOAD(         0xf0000, 0x2000 )
998   ROM_LOAD("u55.bin", 0xfe000, 0x2000, CRC(1e455ed7) SHA1(786d18ce0ab1af45fc538a2300853e497488f0d4) )
999   ROM_RELOAD(         0xfa000, 0x2000 )
1000   ROM_RELOAD(         0xf6000, 0x2000 )
1001   ROM_RELOAD(         0xf2000, 0x2000 )
1002
1003   ROM_REGION( 0x40000, "user1", 0 ) // program data
1004   ROM_LOAD( "m0.u1", 0x00000, 0x10000, CRC(2408289d) SHA1(eafc144a557a79b58bcb48545cb9c9778e61fcd3) )
1005   ROM_LOAD( "m1.u2", 0x10000, 0x10000, CRC(5b623114) SHA1(0d9a14e6b7f57ce4fa09762343b610a973910f58) )
1006   ROM_LOAD( "m2.u3", 0x20000, 0x10000, CRC(abc64869) SHA1(564fc9d90d241a7b7776160b3fd036fb08037355) )
1007   ROM_LOAD( "m3.u4", 0x30000, 0x10000, CRC(0c1e8a67) SHA1(f1b9280c65fcfcb5ec481cae48eb6f52d6cdbc9d) )
1008
1009   ROM_REGION( 0x2000, "gfx1", ROMREGION_DISPOSE )
1010   ROM_LOAD("u67.bin", 0x0000, 0x2000, CRC(09710122) SHA1(de84bdd9245df287bbd3bb808f0c3531d13a3545) )
1011
1012   ROM_REGION( 0x40000, "user2", ROMREGION_DISPOSE ) // UM5100 sample roms?
1013   ROM_LOAD16_BYTE("v1.u15",  0x00000, 0x20000, CRC(613ddd07) SHA1(ebda3d559315879819cb7034b5696f8e7861fe42) )
1014   ROM_LOAD16_BYTE("v2.u14",  0x00001, 0x20000, CRC(427e012e) SHA1(50514a6307e63078fe7444a96e39d834684db7df) )
1015ROM_END
1016
1017ROM_START( tetriskr )
1018   ROM_REGION( 0x100000, "main", 0 ) /* code */
1019   ROM_LOAD( "b-10.u10", 0xf0000, 0x10000, CRC(efc2a0f6) SHA1(5f0f1e90237bee9b78184035a32055b059a91eb3) )
1020
1021   ROM_REGION( 0x10000, "gfx1",0 ) /* gfx - 1bpp font*/
1022   ROM_LOAD( "b-3.u36", 0x00000, 0x2000, CRC(1a636f9a) SHA1(a356cc57914d0c9b9127670b55d1f340e64b1ac9) )
1023
1024   ROM_REGION( 0x80000, "gfx2",ROMREGION_INVERT )
1025   ROM_LOAD( "b-1.u59", 0x00000, 0x10000, CRC(4719d986) SHA1(6e0499944b968d96fbbfa3ead6237d69c769d634))
1026   ROM_LOAD( "b-2.u58", 0x10000, 0x10000, CRC(599e1154) SHA1(14d99f90b4fedeab0ac24ffa9b1fd9ad0f0ba699))
1027   ROM_LOAD( "b-4.u54", 0x20000, 0x10000, CRC(e112c450) SHA1(dfdecfc6bd617ec520b7563b7caf44b79d498bd3))
1028   ROM_LOAD( "b-5.u53", 0x30000, 0x10000, CRC(050b7650) SHA1(5981dda4ed43b6e81fbe48bfba90a8775d5ecddf))
1029   ROM_LOAD( "b-6.u49", 0x40000, 0x10000, CRC(d596ceb0) SHA1(8c82fb638688971ef11159a6b240253e63f0949d))
1030   ROM_LOAD( "b-7.u48", 0x50000, 0x10000, CRC(79336b6c) SHA1(7a95875f3071bdc3ee25c0e6a5a3c00ef02dc977))
1031   ROM_LOAD( "b-8.u44", 0x60000, 0x10000, CRC(1f82121a) SHA1(106da0f39f1260d0761217ed0a24c1611bfd7f05))
1032   ROM_LOAD( "b-9.u43", 0x70000, 0x10000, CRC(4ea22349) SHA1(14dfd3dbd51f8bd6f3290293b8ea1c165e8cf7fd))
1033
1034   ROM_REGION( 0x180000, "user1", ROMREGION_ERASEFF )
1035   // copy for the gfx2,to be made with the DRIVER_INIT
1036ROM_END
1037
1038static DRIVER_INIT( filetto )
1039{
1040   //...
1041}
1042
1043/*Descramble the background gfx data.*/
1044static DRIVER_INIT( tetriskr )
1045{
1046   int i,j,k;
1047   int index=0;
1048   UINT8 *region = memory_region(machine, "user1");
1049   UINT8 *gfx = memory_region(machine, "gfx2");
1050
1051   for(i=0;i<0x20000;i++)
1052   {
1053      //8 pixels/byte
1054      for(j=0;j<8;j++)
1055      {
1056         int mask=(1<<(7-j));
1057         int pixel=0;
1058         for(k=0;k<4;k++)
1059         {
1060            if(gfx[k*0x20000+i]&mask)
1061            {
1062               pixel|=(1<<k);
1063            }
1064         }
1065         region[index++]=pixel;
1066      }
1067   }
1068}
1069
1070GAME( 1990, filetto,  0, filetto,  filetto,  filetto,  ROT0,  "Novarmatic", "Filetto (v1.05 901009)",GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS)
1071GAME( 1988?,tetriskr, 0, tetriskr, tetriskr, tetriskr, ROT0,  "bootleg",    "Tetris  (bootleg of Mirrorsoft PC-XT Tetris version)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS)
src/mame/drivers/jchan.c
r4135r4136
189189static UINT16 *jchan_spriteram_2;
190190static UINT16* jchan_sprregs_2;
191191
192extern int suprnova_alt_enable_sprites;
193192static UINT16 *mainsub_shared_ram;
194193
195194/***************************************************************************
src/mame/drivers/mlanding.c
r4135r4136
1717static UINT16 * ml_unk;
1818static bitmap_t *ml_bitmap[8];
1919#define ML_CHARS 0x2000
20static UINT8 dirtychar[ML_CHARS];
2120static int status_bit;
2221static int adpcm_pos;
2322static int adpcm_data;
r4135r4136
3534   32*8
3635};
3736
38static void updateChars(running_machine *machine)
39{
40   int i;
41   for(i=0;i<ML_CHARS;i++)
42   {
43      if(dirtychar[i])
44      {
45         dirtychar[i]=0;
46         decodechar(machine->gfx[0], i,(UINT8 *) ml_tileram);
47      }
48   }
49}
50
5137static WRITE16_HANDLER(ml_tileram_w)
5238{
5339   COMBINE_DATA(&ml_tileram[offset]);
54   dirtychar[offset>>4]=1;
40   gfx_element_mark_dirty(space->machine->gfx[0], offset>>4);
5541}
5642
5743static READ16_HANDLER(ml_tileram_r)
r4135r4136
200186static VIDEO_START(mlanding)
201187{
202188   int i;
203   for(i=0;i<ML_CHARS;i++)
204   {
205      dirtychar[i]=0;
206   }
207189
190   gfx_element_set_source(machine->gfx[0], (UINT8 *) ml_tileram);
191
208192   for   (i=0;i<8;i++)
209193      ml_bitmap[i] = video_screen_auto_bitmap_alloc(machine->primary_screen);
210194}
r4135r4136
213197{
214198   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
215199
216   updateChars(screen->machine);
217
218200   {
219201      int i,dx,dy,j,k,num;
220202      for(i=0;i<0x1000;i+=4)
src/mame/drivers/pastelg.c
r4135r4136
218218INPUT_PORTS_END
219219
220220// stops the game hanging..
221CUSTOM_INPUT( nb1413m3_hackbusyflag_r )
221static CUSTOM_INPUT( nb1413m3_hackbusyflag_r )
222222{
223223   static int i = 0;
224224   i ^= 1;
src/mame/drivers/alpha68k.c
r4135r4136
196196
197197PALETTE_INIT( kyros );
198198PALETTE_INIT( paddlem );
199VIDEO_START( alpha68k_common_vh );
199200VIDEO_START( alpha68k );
200201VIDEO_UPDATE( kyros );
201202VIDEO_UPDATE( sstingry );
r4135r4136
238239   alpha68k_flipscreen_w(0);
239240}
240241
242static MACHINE_START( common )
243{
244    state_save_register_global(machine, trigstate);
245    state_save_register_global(machine, deposits1);
246    state_save_register_global(machine, deposits2);
247    state_save_register_global(machine, credits);
248}
249
241250/******************************************************************************/
242251
243252static WRITE16_HANDLER( tnexspce_coin_counters_w )
r4135r4136
362371//ZT
363372/******************************************************************************/
364373
374static unsigned coinvalue = 0;
375static unsigned microcontroller_data = 0;
376static int latch;
377
365378/* Kyros, Super Stingray, Mahjong Block Jongbou */
379static MACHINE_START( kyros )
380{
381    state_save_register_global(machine, coinvalue);
382    state_save_register_global(machine, microcontroller_data);
383    state_save_register_global(machine, latch);
384
385    MACHINE_START_CALL( common );
386}
387
366388static READ16_HANDLER( kyros_alpha_trigger_r )
367389{
368390   /* possible jump codes:
369391         - Kyros          : 0x22
370392         - Super Stingray : 0x21,0x22,0x23,0x24,0x34,0x37,0x3a,0x3d,0x40,0x43,0x46,0x49
371393    */
372   static unsigned coinvalue = 0, microcontroller_data = 0;
373394   static const UINT8 coinage1[8][2]={{1,1}, {1,5}, {1,3}, {2,3}, {1,2}, {1,6}, {1,4}, {3,2}};
374395   static const UINT8 coinage2[8][2]={{1,1}, {5,1}, {3,1}, {7,1}, {2,1}, {6,1}, {4,1}, {8,1}};
375396
376   static int latch;
377397   int source = shared_ram[offset];
378398
379399   switch (offset) {
r4135r4136
451471         - Sky Soldiers  : 0x21,0x22,0x23,0x24,0x34,0x37,0x3a,0x3d,0x40,0x43,0x46,0x49
452472         - Gold Medalist : 0x21,0x23,0x24,0x5b
453473    */
454   static unsigned coinvalue = 0, microcontroller_data = 0;
455474   static const UINT8 coinage1[8][2] = {{1,1}, {1,2}, {1,3}, {1,4}, {1,5}, {1,6}, {2,3}, {3,2}};
456475   static const UINT8 coinage2[8][2] = {{1,1}, {2,1}, {3,1}, {4,1}, {5,1}, {6,1}, {7,1}, {8,1}};
457476
458   static int latch;
459477   int source = shared_ram[offset];
460478
461479   switch (offset)
r4135r4136
547565         - Gang Wars               : 0x21,0x23,0x24,0x54
548566         - Super Champion Baseball : 0x21,0x23,0x24
549567    */
550   static unsigned coinvalue = 0, microcontroller_data = 0;
551568   static const UINT8 coinage1[8][2] = {{1,1}, {1,5}, {1,3}, {2,3}, {1,2}, {1,6}, {1,4}, {3,2}};
552569   static const UINT8 coinage2[8][2] = {{1,1}, {5,1}, {3,1}, {7,1}, {2,1}, {6,1}, {4,1}, {8,1}};
553570
554   static int latch;
555571   int source = shared_ram[offset];
556572
557573   switch (offset)
r4135r4136
19121928   MDRV_CPU_PERIODIC_INT(nmi_line_pulse, 4000)
19131929//ZT
19141930
1931    MDRV_MACHINE_START(kyros)
19151932   MDRV_MACHINE_RESET(common)
19161933
19171934   /* video hardware */
r4135r4136
19261943//AT
19271944   MDRV_PALETTE_INIT(kyros)
19281945//ZT
1946    MDRV_VIDEO_START(alpha68k_common_vh)
19291947   MDRV_VIDEO_UPDATE(sstingry)
19301948
19311949   /* sound hardware */
r4135r4136
19611979   MDRV_CPU_PERIODIC_INT(nmi_line_pulse, 4000)
19621980//ZT
19631981
1982    MDRV_MACHINE_START(kyros)
19641983   MDRV_MACHINE_RESET(common)
19651984
19661985   /* video hardware */
r4135r4136
19741993   MDRV_PALETTE_LENGTH(256 + 1)
19751994
19761995   MDRV_PALETTE_INIT(kyros)
1996    MDRV_VIDEO_START(alpha68k_common_vh)
19771997   MDRV_VIDEO_UPDATE(kyros)
19781998
19791999   /* sound hardware */
r4135r4136
20062026   MDRV_CPU_IO_MAP(jongbou_sound_portmap,0)
20072027   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold, 160) // guess, controls sound speed
20082028
2029    MDRV_MACHINE_START(kyros)
20092030   MDRV_MACHINE_RESET(common)
20102031
20112032   /* video hardware */
r4135r4136
20192040   MDRV_PALETTE_LENGTH(256 + 1)
20202041
20212042   MDRV_PALETTE_INIT(kyros)
2043    MDRV_VIDEO_START(alpha68k_common_vh)
20222044   MDRV_VIDEO_UPDATE(kyros)
20232045
20242046   /* sound hardware */
r4135r4136
20512073   MDRV_PALETTE_LENGTH(1024)
20522074   MDRV_PALETTE_INIT(paddlem)
20532075//ZT
2076    MDRV_VIDEO_START(alpha68k_common_vh)
20542077   MDRV_VIDEO_UPDATE(alpha68k_I)
20552078
20562079   /* sound hardware */
r4135r4136
22572280
22582281   MDRV_PALETTE_LENGTH(1024)
22592282   MDRV_PALETTE_INIT(paddlem)
2283    MDRV_VIDEO_START(alpha68k_common_vh)
22602284   MDRV_VIDEO_UPDATE(alpha68k_I)
22612285
22622286   /* sound hardware */
r4135r4136
32663290
32673291/******************************************************************************/
32683292
3269GAME( 1986, sstingry, 0,        sstingry,      sstingry, sstingry, ROT90, "Alpha Denshi Co.",   "Super Stingray", 0 )
3270GAME( 1987, kyros,    0,        kyros,         kyros,    kyros,    ROT90, "World Games Inc",    "Kyros", 0 )
3271GAME( 1986, kyrosj,   kyros,    kyros,         kyros,    kyros,    ROT90, "Alpha Denshi Co.",   "Kyros No Yakata (Japan)", 0 )
3272GAME( 1987, jongbou,  0,        jongbou,       jongbou,  jongbou,  ROT90, "SNK",                "Mahjong Block Jongbou (Japan)", 0 )
3273GAME( 1988, paddlema, 0,        alpha68k_I,    paddlema, paddlema, ROT90, "SNK",                "Paddle Mania", 0 )
3274GAME( 1987, timesold, 0,        alpha68k_II,   timesold, timesold, ROT90, "[Alpha Denshi Co.] (SNK/Romstar license)", "Time Soldiers (US Rev 3)", 0 )
3275GAME( 1987, timesol1, timesold, alpha68k_II,   timesold, timesol1, ROT90, "[Alpha Denshi Co.] (SNK/Romstar license)", "Time Soldiers (US Rev 1)", 0 )
3276GAME( 1987, btlfield, timesold, alpha68k_II,   btlfield, btlfield, ROT90, "[Alpha Denshi Co.] (SNK license)", "Battle Field (Japan)", 0 )
3277GAME( 1987, btlfildb, timesold, btlfildb,      btlfildb, btlfildb, ROT90, "bootleg",            "Battle Field (bootleg)", 0 )
3278GAME( 1988, skysoldr, 0,        alpha68k_II,   skysoldr, skysoldr, ROT90, "[Alpha Denshi Co.] (SNK of America/Romstar license)", "Sky Soldiers (US)", 0 )
3279GAME( 1988, goldmedl, 0,        alpha68k_II_gm,goldmedl, goldmedl, ROT0,  "SNK",                "Gold Medalist", 0 )
3280GAME( 1988, goldmeda, goldmedl, alpha68k_II_gm,goldmedl, goldmeda, ROT0,  "SNK",                "Gold Medalist (alt)", 0 )
3293GAME( 1986, sstingry, 0,        sstingry,      sstingry, sstingry, ROT90, "Alpha Denshi Co.",   "Super Stingray", GAME_SUPPORTS_SAVE )
3294GAME( 1987, kyros,    0,        kyros,         kyros,    kyros,    ROT90, "World Games Inc",    "Kyros", GAME_SUPPORTS_SAVE )
3295GAME( 1986, kyrosj,   kyros,    kyros,         kyros,    kyros,    ROT90, "Alpha Denshi Co.",   "Kyros No Yakata (Japan)", GAME_SUPPORTS_SAVE )
3296GAME( 1987, jongbou,  0,        jongbou,       jongbou,  jongbou,  ROT90, "SNK",                "Mahjong Block Jongbou (Japan)", GAME_SUPPORTS_SAVE )
3297GAME( 1988, paddlema, 0,        alpha68k_I,    paddlema, paddlema, ROT90, "SNK",                "Paddle Mania", GAME_SUPPORTS_SAVE )
3298GAME( 1987, timesold, 0,        alpha68k_II,   timesold, timesold, ROT90, "[Alpha Denshi Co.] (SNK/Romstar license)", "Time Soldiers (US Rev 3)", GAME_SUPPORTS_SAVE )
3299GAME( 1987, timesol1, timesold, alpha68k_II,   timesold, timesol1, ROT90, "[Alpha Denshi Co.] (SNK/Romstar license)", "Time Soldiers (US Rev 1)", GAME_SUPPORTS_SAVE )
3300GAME( 1987, btlfield, timesold, alpha68k_II,   btlfield, btlfield, ROT90, "[Alpha Denshi Co.] (SNK license)", "Battle Field (Japan)", GAME_SUPPORTS_SAVE )
3301GAME( 1987, btlfildb, timesold, btlfildb,      btlfildb, btlfildb, ROT90, "bootleg",            "Battle Field (bootleg)", GAME_SUPPORTS_SAVE )
3302GAME( 1988, skysoldr, 0,        alpha68k_II,   skysoldr, skysoldr, ROT90, "[Alpha Denshi Co.] (SNK of America/Romstar license)", "Sky Soldiers (US)", GAME_SUPPORTS_SAVE )
3303GAME( 1988, goldmedl, 0,        alpha68k_II_gm,goldmedl, goldmedl, ROT0,  "SNK",                "Gold Medalist", GAME_SUPPORTS_SAVE )
3304GAME( 1988, goldmeda, goldmedl, alpha68k_II_gm,goldmedl, goldmeda, ROT0,  "SNK",                "Gold Medalist (alt)", GAME_SUPPORTS_SAVE )
32813305GAME( 1988, goldmedb, goldmedl, alpha68k_II_gm,goldmedl, goldmeda, ROT0,  "bootleg",            "Gold Medalist (bootleg)", GAME_NOT_WORKING )
3282GAME( 1989, skyadvnt, 0,        alpha68k_V,    skyadvnt, skyadvnt, ROT90, "Alpha Denshi Co.",   "Sky Adventure (World)", 0 )
3283GAME( 1989, skyadvnu, skyadvnt, alpha68k_V,    skyadvnu, skyadvnu, ROT90, "Alpha Denshi Co. (SNK of America license)", "Sky Adventure (US)", 0 )
3284GAME( 1989, skyadvnj, skyadvnt, alpha68k_V,    skyadvnt, skyadvnt, ROT90, "Alpha Denshi Co.",   "Sky Adventure (Japan)", 0 )
3285GAME( 1989, gangwars, 0,        alpha68k_V,    gangwars, gangwars, ROT0,  "Alpha Denshi Co.",   "Gang Wars (US)", 0 )
3286GAME( 1989, gangwarb, gangwars, alpha68k_V,    gangwarb, gangwarb, ROT0,  "bootleg",            "Gang Wars (bootleg)", 0 )
3306GAME( 1989, skyadvnt, 0,        alpha68k_V,    skyadvnt, skyadvnt, ROT90, "Alpha Denshi Co.",   "Sky Adventure (World)", GAME_SUPPORTS_SAVE )
3307GAME( 1989, skyadvnu, skyadvnt, alpha68k_V,    skyadvnu, skyadvnu, ROT90, "Alpha Denshi Co. (SNK of America license)", "Sky Adventure (US)", GAME_SUPPORTS_SAVE )
3308GAME( 1989, skyadvnj, skyadvnt, alpha68k_V,    skyadvnt, skyadvnt, ROT90, "Alpha Denshi Co.",   "Sky Adventure (Japan)", GAME_SUPPORTS_SAVE )
3309GAME( 1989, gangwars, 0,        alpha68k_V,    gangwars, gangwars, ROT0,  "Alpha Denshi Co.",   "Gang Wars (US)", GAME_SUPPORTS_SAVE )
3310GAME( 1989, gangwarb, gangwars, alpha68k_V,    gangwarb, gangwarb, ROT0,  "bootleg",            "Gang Wars (bootleg)", GAME_SUPPORTS_SAVE )
32873311#if SBASEBAL_HACK
3288GAME( 1989, sbasebal, 0,        alpha68k_V_sb, sbasebal, sbasebal, ROT0,  "Alpha Denshi Co.",   "Super Champion Baseball (Japan)", 0 )
3312GAME( 1989, sbasebal, 0,        alpha68k_V_sb, sbasebal, sbasebal, ROT0,  "Alpha Denshi Co.",   "Super Champion Baseball (Japan)", GAME_SUPPORTS_SAVE )
32893313#else
3290GAME( 1989, sbasebal, 0,        alpha68k_V_sb, sbasebal, sbasebal, ROT0,  "Alpha Denshi Co. (SNK of America license)", "Super Champion Baseball (US)", 0 )
3314GAME( 1989, sbasebal, 0,        alpha68k_V_sb, sbasebal, sbasebal, ROT0,  "Alpha Denshi Co. (SNK of America license)", "Super Champion Baseball (US)", GAME_SUPPORTS_SAVE )
32913315#endif
3292GAME( 1989, tnexspce, 0,        tnexspce,      tnexspce, tnexspce, ROT90, "SNK",                "The Next Space", GAME_NO_COCKTAIL )
3316GAME( 1989, tnexspce, 0,        tnexspce,      tnexspce, tnexspce, ROT90, "SNK",                "The Next Space", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
src/mame/drivers/namcos22.c
r4135r4136
26062606         }
26072607
26082608         return (ddx & 0xff);
2609         break;
26102609      case 1:
26112610         return (ddx>>8);
2612         break;
26132611      case 2:
26142612         return (ddy & 0xff);
2615         break;
26162613      case 3:
26172614         return (ddy>>8);
2618         break;
26192615      default:
26202616         return 0;
2621         break;
26222617   }
26232618}
26242619
r4135r4136
26362631   {
26372632      case 0:
26382633         return swing & 0xff;
2639         break;
26402634
26412635      case 1:
26422636         return (swing>>8);
2643         break;
26442637
26452638      case 2:
26462639         return edge & 0xff;
2647         break;
26482640
26492641      case 3:
26502642         return (edge>>8);
2651         break;
26522643
26532644      default:
26542645         return 0;
2655         break;
26562646   }
26572647}
26582648
r4135r4136
26692659   {
26702660      case 0:
26712661         return steer & 0xff;
2672         break;
26732662
26742663      case 1:
26752664         return (steer>>8);
2676         break;
26772665
26782666      case 2:
26792667         return gas & 0xff;
2680         break;
26812668
26822669      case 3:
26832670         return (gas>>8);
2684         break;
26852671
26862672      case 4:
26872673         return brake & 0xff;
2688         break;
26892674
26902675      case 5:
26912676         return (brake>>8);
2692         break;
26932677
26942678      default:
26952679         return 0;
2696         break;
26972680   }
26982681}
26992682
r4135r4136
27102693   {
27112694      case 0:
27122695         return x & 0xff;
2713         break;
27142696
27152697      case 1:
27162698         return (x>>8);
2717         break;
27182699
27192700      case 2:
27202701         return y & 0xff;
2721         break;
27222702
27232703      case 3:
27242704         return (y>>8);
2725         break;
27262705
27272706      case 4:
27282707         return pedal & 0xff;
2729         break;
27302708
27312709      case 5:
27322710         return (pedal>>8);
2733         break;
27342711
27352712      default:
27362713         return 0;
2737         break;
27382714   }
27392715}
27402716
src/mame/drivers/magicfly.c
r4135r4136
518518{
519519   switch( input_selector )
520520   {
521      case 0x01: return input_port_read(space->machine, "IN0-0"); break;
522      case 0x02: return input_port_read(space->machine, "IN0-1"); break;
523      case 0x04: return input_port_read(space->machine, "IN0-2"); break;
524      case 0x08: return input_port_read(space->machine, "IN0-3"); break;
525      case 0x00: return input_port_read(space->machine, "DSW0"); break;
521      case 0x01: return input_port_read(space->machine, "IN0-0");
522      case 0x02: return input_port_read(space->machine, "IN0-1");
523      case 0x04: return input_port_read(space->machine, "IN0-2");
524      case 0x08: return input_port_read(space->machine, "IN0-3");
525      case 0x00: return input_port_read(space->machine, "DSW0");
526526   }
527527   return 0xff;
528528}
src/mame/drivers/centiped.c
r4135r4136
20042004GAME( 1980, millpac,  centiped, centipdb, centiped, 0,        ROT270, "Valadon Automation", "Millpac", GAME_SUPPORTS_SAVE )
20052005GAME( 1980, magworm,  centiped, magworm,  magworm,  magworm,  ROT270, "bootleg", "Magic Worm (bootleg)", GAME_SUPPORTS_SAVE )
20062006GAME( 1982, milliped, 0,        milliped, milliped, 0,        ROT270, "Atari",   "Millipede", GAME_SUPPORTS_SAVE )
2007GAME( 1982, millipdd, milliped, milliped, milliped, 0,        ROT270, "Atari",   "Millipede Dux (hack)", GAME_SUPPORTS_SAVE )
2007GAME( 1982, millipdd, milliped, milliped, milliped, 0,        ROT270, "hack",    "Millipede Dux (hack)", GAME_SUPPORTS_SAVE )
20082008
20092009GAME( 1980, warlords, 0,        warlords, warlords, 0,        ROT0,   "Atari",   "Warlords", GAME_SUPPORTS_SAVE )
20102010GAME( 1981, mazeinv,  0,        mazeinv,  mazeinv,  0,        ROT270, "Atari",   "Maze Invaders (prototype)", 0 )
src/mame/drivers/ssv.c
r4135r4136
536536{
537537   offset += gdfs_gfxram_bank * 0x100000/2;
538538   COMBINE_DATA(&eaglshot_gfxram[offset]);
539
540   eaglshot_dirty = 1;
541   eaglshot_dirty_tile[offset / (16*8/2)] = 1;
539   gfx_element_mark_dirty(space->machine->gfx[2], offset / (16*8/2));
542540}
543541
544542static READ16_HANDLER( gdfs_blitram_r )
r4135r4136
588586
589587         if ( (src+len <= size) && (dst+len <= 4 * 0x100000) )
590588         {
591            eaglshot_dirty = 1;
592
593589            memcpy( &eaglshot_gfxram[dst/2], &rom[src], len );
594590
595591            if (len % (16*8))   len = len / (16*8) + 1;
596592            else            len = len / (16*8);
597593
598            memset( &eaglshot_dirty_tile[dst / (16*8)], 1, len );
594            dst /= 16*8;
595            while (len--)
596            {
597               gfx_element_mark_dirty(space->machine->gfx[2], dst);
598               dst++;
599            }
599600         }
600601         else
601602         {
r4135r4136
11011102{
11021103   offset += (ssv_scroll[0x76/2] & 0xf) * 0x40000/2;
11031104   COMBINE_DATA(&eaglshot_gfxram[offset]);
1104
1105   eaglshot_dirty = 1;
1106   eaglshot_dirty_tile[offset / (16*8/2)] = 1;
1105   gfx_element_mark_dirty(space->machine->gfx[0], offset / (16*8/2));
1106   gfx_element_mark_dirty(space->machine->gfx[1], offset / (16*8/2));
11071107}
11081108
11091109
r4135r4136
27162716   ssv_enable_video(1);
27172717   ssv_special = 0;
27182718   interrupt_ultrax = 0;
2719   eaglshot_dirty = 0;
27202719}
27212720
27222721static void init_ssv_hypreac2(void)
src/mame/drivers/janshi.c
r4135r4136
3737   AM_RANGE(0x0000, 0x3fff) AM_ROM
3838ADDRESS_MAP_END
3939
40VIDEO_START(janshi)
40static VIDEO_START(janshi)
4141{
4242
4343}
4444
45VIDEO_UPDATE(janshi)
45static VIDEO_UPDATE(janshi)
4646{
4747   return 0;
4848}
src/mame/drivers/mpu4drvr.c
r4135r4136
212212/* SCN2674 AVDC stuff */
213213static int mpu4_gfx_index;
214214static UINT16 * mpu4_vid_vidram;
215static UINT8  * mpu4_vid_vidram_is_dirty;
216215static UINT16 * mpu4_vid_mainram;
217216
218217static UINT8 scn2674_IR[16];
r4135r4136
452451
453452   bitmap_fill(bitmap,cliprect,0);
454453
455   for (i = 0; i < 0x1000; i++)
456   {
457      if (mpu4_vid_vidram_is_dirty[i]==1)
458      {
459         decodechar(screen->machine->gfx[mpu4_gfx_index+0], i, (UINT8 *)mpu4_vid_vidram);
460         decodechar(screen->machine->gfx[mpu4_gfx_index+1], i, (UINT8 *)mpu4_vid_vidram);
461         decodechar(screen->machine->gfx[mpu4_gfx_index+2], i, (UINT8 *)mpu4_vid_vidram);
462         decodechar(screen->machine->gfx[mpu4_gfx_index+3], i, (UINT8 *)mpu4_vid_vidram);
463         mpu4_vid_vidram_is_dirty[i]=0;
464      }
465   }
466
467454   /* this is in main ram.. i think it must transfer it out of here??? */
468455   /* count = 0x0018b6/2; - crmaze count = 0x004950/2; - turnover */
469456
r4135r4136
517504{
518505   COMBINE_DATA(&mpu4_vid_vidram[offset]);
519506   offset <<= 1;
520   mpu4_vid_vidram_is_dirty[offset/0x20]=1;
507   gfx_element_mark_dirty(space->machine->gfx[mpu4_gfx_index+0], offset/0x20);
508   gfx_element_mark_dirty(space->machine->gfx[mpu4_gfx_index+1], offset/0x20);
509   gfx_element_mark_dirty(space->machine->gfx[mpu4_gfx_index+2], offset/0x20);
510   gfx_element_mark_dirty(space->machine->gfx[mpu4_gfx_index+3], offset/0x20);
521511}
522512
523513
r4135r4136
983973      maybe we will anyway, but for now we don't need to */
984974
985975   mpu4_vid_vidram = auto_malloc (0x20000);
986   mpu4_vid_vidram_is_dirty = auto_malloc(0x1000);
987976
988   memset(mpu4_vid_vidram_is_dirty,1,0x1000);
989977   memset(mpu4_vid_vidram,0,0x20000);
990978
991979    /* find first empty slot to decode gfx */
r4135r4136
996984   assert(mpu4_gfx_index != MAX_GFX_ELEMENTS);
997985
998986   /* create the char set (gfx will then be updated dynamically from RAM) */
999   machine->gfx[mpu4_gfx_index+0] = allocgfx(machine, &mpu4_vid_char_8x8_layout);
1000   machine->gfx[mpu4_gfx_index+1] = allocgfx(machine, &mpu4_vid_char_8x16_layout);
1001   machine->gfx[mpu4_gfx_index+2] = allocgfx(machine, &mpu4_vid_char_16x8_layout);
1002   machine->gfx[mpu4_gfx_index+3] = allocgfx(machine, &mpu4_vid_char_16x16_layout);
987   machine->gfx[mpu4_gfx_index+0] = gfx_element_alloc(machine, &mpu4_vid_char_8x8_layout, (UINT8 *)mpu4_vid_vidram, machine->config->total_colors / 16, 0);
988   machine->gfx[mpu4_gfx_index+1] = gfx_element_alloc(machine, &mpu4_vid_char_8x16_layout, (UINT8 *)mpu4_vid_vidram, machine->config->total_colors / 16, 0);
989   machine->gfx[mpu4_gfx_index+2] = gfx_element_alloc(machine, &mpu4_vid_char_16x8_layout, (UINT8 *)mpu4_vid_vidram, machine->config->total_colors / 16, 0);
990   machine->gfx[mpu4_gfx_index+3] = gfx_element_alloc(machine, &mpu4_vid_char_16x16_layout, (UINT8 *)mpu4_vid_vidram, machine->config->total_colors / 16, 0);
1003991
1004   /* set the color information */
1005   machine->gfx[mpu4_gfx_index+0]->total_colors = machine->config->total_colors / 16;
1006   machine->gfx[mpu4_gfx_index+1]->total_colors = machine->config->total_colors / 16;
1007   machine->gfx[mpu4_gfx_index+2]->total_colors = machine->config->total_colors / 16;
1008   machine->gfx[mpu4_gfx_index+3]->total_colors = machine->config->total_colors / 16;
1009
1010992   scn2675_IR_pointer = 0;
1011993}
1012994
src/mame/drivers/aquarium.c
r4135r4136
341341};
342342
343343
344static MACHINE_START( aquarium )
345{
346    state_save_register_global(machine, aquarium_snd_ack);
347}
348
344349static MACHINE_DRIVER_START( aquarium )
345350
346351   /* basic machine hardware */
r4135r4136
352357   MDRV_CPU_PROGRAM_MAP(snd_map,0)
353358   MDRV_CPU_IO_MAP(snd_portmap,0)
354359
360    MDRV_MACHINE_START(aquarium)
355361#if AQUARIUS_HACK
356362   MDRV_MACHINE_RESET(aquarium)
357363#endif
r4135r4136
414420ROM_END
415421
416422#if !AQUARIUS_HACK
417GAME( 1996, aquarium, 0, aquarium, aquarium, aquarium, ROT0, "Excellent System", "Aquarium (Japan)", GAME_NO_COCKTAIL )
423GAME( 1996, aquarium, 0, aquarium, aquarium, aquarium, ROT0, "Excellent System", "Aquarium (Japan)", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
418424#else
419GAME( 1996, aquarium, 0, aquarium, aquarium, aquarium, ROT0, "Excellent System", "Aquarium", GAME_NO_COCKTAIL )
425GAME( 1996, aquarium, 0, aquarium, aquarium, aquarium, ROT0, "Excellent System", "Aquarium", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL )
420426#endif
src/mame/drivers/gal3.c
r4135r4136
7070#include "driver.h"
7171#include "cpu/m68000/m68000.h"
7272
73VIDEO_START(gal3)
73static VIDEO_START(gal3)
7474{
7575
7676}
7777
78VIDEO_UPDATE(gal3)
78static VIDEO_UPDATE(gal3)
7979{
8080   return 0;
8181}
src/mame/drivers/angelkds.c
r4135r4136
208208game it doesn't, so maybe it wasn't really hooked up and instead
209209only one of the register (f001) is used for both part?
210210
211* update, it is correct, the screen is meant to split in two when
211 update, it is correct, the screen is meant to split in two when
212212 the kid goes what would be offscreen, just looked kinda odd
213213
214214Interesting note, each Bank in the 0x8000 - 0xbfff appears to
r4135r4136
598598
599599*/
600600
601static MACHINE_START( angelkds )
602{
603    state_save_register_global_array(machine, angelkds_sound);
604    state_save_register_global_array(machine, angelkds_sound2);
605}
606
601607static MACHINE_DRIVER_START( angelkds )
602608   MDRV_CPU_ADD("main", Z80, 8000000) /* 8MHz? 6 seems too slow? */
603609   MDRV_CPU_PROGRAM_MAP(main_map,0)
r4135r4136
608614   MDRV_CPU_PROGRAM_MAP(sub_map,0)
609615   MDRV_CPU_IO_MAP(sub_portmap,0)
610616
617    MDRV_MACHINE_START(angelkds)
618
611619   MDRV_QUANTUM_TIME(HZ(6000))
612620
613621   /* video hardware */
r4135r4136
740748static DRIVER_INIT( spcpostn )   { spcpostn_decode(machine, "main"); }
741749
742750
743GAME( 1988, angelkds, 0, angelkds, angelkds,        0,  ROT90,  "Sega / Nasco?", "Angel Kids (Japan)" , 0) /* Nasco not displayed but 'Exa Planning' is */
744GAME( 1986, spcpostn, 0, angelkds, spcpostn, spcpostn,  ROT90,  "Sega / Nasco", "Space Position (Japan)" , 0) /* encrypted */
751GAME( 1988, angelkds, 0, angelkds, angelkds,        0,  ROT90,  "Sega / Nasco?", "Angel Kids (Japan)" , GAME_SUPPORTS_SAVE) /* Nasco not displayed but 'Exa Planning' is */
752GAME( 1986, spcpostn, 0, angelkds, spcpostn, spcpostn,  ROT90,  "Sega / Nasco", "Space Position (Japan)" , GAME_SUPPORTS_SAVE) /* encrypted */
src/mame/drivers/firebeat.c
r4135r4136
18041804
18051805/*****************************************************************************/
18061806
1807static READ8_HANDLER( soundram_r )
1807static READ8_DEVICE_HANDLER( soundram_r )
18081808{
18091809   if (offset >= 0 && offset < 0x200000)
18101810   {
r4135r4136
18171817   return 0;
18181818}
18191819
1820static WRITE8_HANDLER( soundram_w )
1820static WRITE8_DEVICE_HANDLER( soundram_w )
18211821{
18221822}
18231823
src/mame/drivers/namcos23.c
r4135r4136
775775
776776static VIDEO_START( ss23 )
777777{
778   gfx_element_set_source(machine->gfx[0], (UINT8 *)namcos23_charram);
778779   bgtilemap = tilemap_create(machine, TextTilemapGetInfo, tilemap_scan_rows, 16, 16, 64, 64);
779780   tilemap_set_transparent_pen(bgtilemap, 0xf);
780781}
r4135r4136
936937
937938static WRITE32_HANDLER( s23_txtchar_w )
938939{
939   COMBINE_DATA(&namcos23_charram[offset]   );
940
941   decodechar( space->machine->gfx[0],offset/32,(UINT8 *)namcos23_charram );
942
943   tilemap_mark_all_tiles_dirty(bgtilemap);
940   COMBINE_DATA(&namcos23_charram[offset]);
941   gfx_element_mark_dirty(space->machine->gfx[0], offset/32);
944942}
945943
946944static READ32_HANDLER( ss23_vstat_r )
r4135r4136
11521150         ret = make_bcd(systime.local_time.hour);   // hour (BCD, 0-23)
11531151         break;
11541152      case 3:
1155         ret = make_bcd(weekday[systime.local_time.weekday]); // day of the week (1 = Monday, 7 = Sunday)
1153         ret = make_bcd(weekday[systime.local_time.weekday]);   // low nibble = day of the week
1154         ret |= (make_bcd(systime.local_time.mday) & 0x0f)<<4;   // high nibble = low digit of day
11561155         break;
11571156      case 4:
1158         ret = make_bcd(systime.local_time.mday);   // day (BCD, 1-31)
1157         ret = (make_bcd(systime.local_time.mday) >> 4);         // low nibble = high digit of day
1158         ret |= (make_bcd(systime.local_time.month + 1) & 0x0f)<<4;   // high nibble = low digit of month
11591159         break;
11601160      case 5:
1161         ret = make_bcd(systime.local_time.month + 1);   // month (BCD, 1-12)
1161         ret = make_bcd(systime.local_time.month + 1) >> 4;   // low nibble = high digit of month
1162         ret |= (make_bcd(systime.local_time.year % 10) << 4);   // high nibble = low digit of year
11621163         break;
11631164      case 6:
1164         ret = make_bcd(systime.local_time.year % 100);   // year (BCD, 0-99)
1165         ret = make_bcd(systime.local_time.year % 100) >> 4;   // low nibble = tens digit of year (BCD, 0-9)
11651166         break;
11661167   }
11671168
src/mame/drivers/cubocd32.c
r4135r4136
4747#include "driver.h"
4848#include "cpu/m68000/m68000.h"
4949#include "sound/custom.h"
50#include "sound/cdda.h"
5051#include "includes/amiga.h"
5152#include "includes/cubocd32.h"
5253#include "machine/6526cia.h"
src/mame/drivers/cvs.c
r4135r4136
195195WRITE8_HANDLER( cvs_s2636_0_or_character_ram_w )
196196{
197197   if (cpu_get_reg(space->cpu, S2650_FO))
198      cvs_character_ram[(0 * 0x800) | 0x400 | character_ram_page_start | offset] = data;
198   {
199      offset |= (0 * 0x800) | 0x400 | character_ram_page_start;
200      cvs_character_ram[offset] = data;
201      gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
202   }
199203   else
200204      cvs_s2636_0_ram[offset] = data;
201205}
r4135r4136
212216WRITE8_HANDLER( cvs_s2636_1_or_character_ram_w )
213217{
214218   if (cpu_get_reg(space->cpu, S2650_FO))
215      cvs_character_ram[(1 * 0x800) | 0x400 | character_ram_page_start | offset] = data;
219   {
220      offset |= (1 * 0x800) | 0x400 | character_ram_page_start;
221      cvs_character_ram[offset] = data;
222      gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
223   }
216224   else
217225      cvs_s2636_1_ram[offset] = data;
218226}
r4135r4136
229237WRITE8_HANDLER( cvs_s2636_2_or_character_ram_w )
230238{
231239   if (cpu_get_reg(space->cpu, S2650_FO))
232      cvs_character_ram[(2 * 0x800) | 0x400 | character_ram_page_start | offset] = data;
240   {
241      offset |= (2 * 0x800) | 0x400 | character_ram_page_start;
242      cvs_character_ram[offset] = data;
243      gfx_element_mark_dirty(space->machine->gfx[1], offset/8);
244   }
233245   else
234246      cvs_s2636_2_ram[offset] = data;
235247}
r4135r4136
497509   cvs_character_ram = auto_malloc(3 * 0x800);  /* only half is used, but
498510                                                    by allocating twice the amount,
499511                                                    we can use the same gfx_layout */
512
513   if (machine->gfx[1] != NULL)
514      gfx_element_set_source(machine->gfx[1], cvs_character_ram);
515
500516   start_393hz_timer(machine);
501517
502518   /* register state save */
r4135r4136
9961012
9971013static GFXDECODE_START( cvs )
9981014   GFXDECODE_ENTRY( "gfx1", 0x0000, charlayout, 0, 256+4 )
1015   GFXDECODE_ENTRY( NULL,   0x0000, charlayout, 0, 256+4 )
9991016GFXDECODE_END
10001017
10011018
src/mame/drivers/turbo.c
r4135r4136
14241424
14251425ROM_START( buckrogn )
14261426   ROM_REGION( 0xc000, "main", 0 )
1427   ROM_LOAD( "cpu-ic3", 0x0000, 0x4000, CRC(7f1910af) SHA1(22d37750282676d8fd1f602e928c174f823245c9) )
1428   ROM_LOAD( "cpu-ic4", 0x4000, 0x4000, CRC(5ecd393b) SHA1(d069f12326644f2c685e516d91d33b97ec162c56) )
1427   ROM_LOAD( "cpu-ic3.bin", 0x0000, 0x4000, CRC(7f1910af) SHA1(22d37750282676d8fd1f602e928c174f823245c9) )
1428   ROM_LOAD( "cpu-ic4.bin", 0x4000, 0x4000, CRC(5ecd393b) SHA1(d069f12326644f2c685e516d91d33b97ec162c56) )
14291429
14301430   ROM_REGION( 0x2000, "sub", 0 )
14311431   ROM_LOAD( "epr-5200.cpu-ic66", 0x0000, 0x1000, CRC(0d58b154) SHA1(9f3951eb7ea1fa9ff914738462e4b4f755d60802) )
src/mame/drivers/plygonet.c
r4135r4136
309309}
310310
311311
312WRITE32_HANDLER( plygonet_palette_w )
312static WRITE32_HANDLER( plygonet_palette_w )
313313{
314314   int r,g,b;
315315
src/mame/drivers/naomi.c
r4135r4136
806806
807807static const aica_interface aica_config =
808808{
809   TRUE,
809810   0,
810811   aica_irq
811812};
src/mame/drivers/nemesis.c
r4135r4136
19181918static const gfx_layout charlayout =
19191919{
19201920   8,8,   /* 8*8 characters */
1921   2048+1,   /* 2048 characters (+ blank one) */
1921   2048,   /* 2048 characters (+ blank one) */
19221922   4,   /* 4 bits per pixel */
19231923   { 0, 1, 2, 3 }, /* the two bitplanes are merged in the same nibble */
19241924   { XOR(0*4), XOR(1*4), XOR(2*4), XOR(3*4), XOR(4*4), XOR(5*4), XOR(6*4), XOR(7*4) },
src/mame/drivers/stv.c
r4135r4136
222222           scu_size_1,      /* lv 1*/
223223           scu_size_2;      /* lv 2*/
224224
225struct
225static struct
226226{
227227   UINT8 vblank_out;
228228   UINT8 vblank_in;
r4135r4136
24262426static const gfx_layout tiles8x8x8_layout =
24272427{
24282428   8,8,
2429   0x100000/(64*8/8),
2429   0x100000/(32*8/8),
24302430   8,
24312431   { 0, 1, 2, 3, 4, 5, 6, 7 },
24322432   { 0, 8, 16, 24, 32, 40, 48, 56 },
24332433   { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64 },
2434   64*8
2434   32*8   /* really 64*8, but granularity is 32 bytes */
24352435};
24362436
24372437static const gfx_layout tiles16x16x8_layout =
24382438{
24392439   16,16,
2440   0x100000/(128*16/8),
2440   0x100000/(64*16/8),
24412441   8,
24422442   { 0, 1, 2, 3, 4, 5, 6, 7 },
24432443   { 0, 8, 16, 24, 32, 40, 48, 56,
r4135r4136
24472447   { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
24482448   64*16, 64*17, 64*18, 64*19, 64*20, 64*21, 64*22, 64*23
24492449   },
2450   128*16
2450   64*16   /* really 128*16, but granularity is 32 bytes */
24512451};
24522452
24532453
r4135r4136
29472947
29482948ROM_START( diehard ) /* must use USA, Europe or Taiwan BIOS */
29492949   STV_BIOS
2950   ROM_DEFAULT_BIOS( "us" )
29502951
29512952   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
29522953
r4135r4136
34003401
34013402ROM_START( smleague ) /* only runs with the USA bios */
34023403   STV_BIOS
3404   ROM_DEFAULT_BIOS( "us" )
34033405
34043406   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
34053407   ROM_LOAD16_BYTE( "epr18777.13",               0x0000001, 0x0080000, CRC(8d180866) SHA1(d47ebabab6e06400312d39f68cd818852e496b96) )
r4135r4136
36223624
36233625ROM_START( critcrsh ) /* Must use Europe or Asia BIOS */
36243626   STV_BIOS
3627   ROM_DEFAULT_BIOS( "euro" )
36253628
36263629   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
36273630   ROM_LOAD16_BYTE( "epr-18821.ic13",  0x0000001, 0x0080000, CRC(9a6658e2) SHA1(16dbae3d9ab584713afcb403f89fe71049609245) )
src/mame/drivers/queen.c
r4135r4136
1919#include "driver.h"
2020#include "cpu/i386/i386.h"
2121
22VIDEO_START(queen)
22static VIDEO_START(queen)
2323{
2424
2525}
2626
27VIDEO_UPDATE(queen)
27static VIDEO_UPDATE(queen)
2828{
2929   return 0;
3030}
src/mame/drivers/bnstars.c
r4135r4136
370370   int xsize, ysize, xzoom, yzoom;
371371   int code, attr, color, size, pri, pri_mask, trans;
372372   gfx_element *gfx = machine->gfx[region];
373   gfx_element mygfx = *gfx;
374373
375374   UINT32      *source   = sprram_top;
376375   const UINT32   *finish   = sprram_top + (sprram_size - 0x10) / 4;
r4135r4136
433432         flipy = !flipy;
434433      }
435434
436      /* change GfxElement parameters to draw only the needed part of the 256x256 tile */
437      mygfx.width = xsize;
438      mygfx.height = ysize;
439      mygfx.gfxdata = gfx->gfxdata + tx + ty * gfx->line_modulo;
440
441435      /* TODO: priority handling is completely wrong, but better than nothing */
442436      if (pri == 0x0)
443437         pri_mask = 0x00;
r4135r4136
448442      else
449443         pri_mask = 0xfe;
450444
451      pdrawgfxzoom(bitmap, &mygfx,
445      gfx_element_set_source_clip(gfx, tx, xsize, ty, ysize);
446      pdrawgfxzoom(bitmap, gfx,
452447            code,
453448            color,
454449            flipx, flipy,
src/mame/drivers/gcpinbal.c
r4135r4136
9292      case 0x50:
9393      case 0x51:
9494         return okim6295_status_0_r(space,0)<<8;
95         break;
9695
9796   }
9897
src/mame/drivers/ace.c
r4135r4136
6161}
6262#endif
6363
64static VIDEO_START( ace )
65{
66   gfx_element_set_source(machine->gfx[1], ace_characterram);
67   gfx_element_set_source(machine->gfx[2], ace_characterram);
68   gfx_element_set_source(machine->gfx[3], ace_characterram);
69   gfx_element_set_source(machine->gfx[4], ace_scoreram);
70}
71
6472static VIDEO_UPDATE( ace )
6573{
6674   int offs;
6775
68   decodechar(screen->machine->gfx[1], 0, ace_characterram);
69   decodechar(screen->machine->gfx[2], 0, ace_characterram);
70   decodechar(screen->machine->gfx[3], 0, ace_characterram);
71
72   for (offs = 0; offs < 8; offs++)
73   {
74      decodechar(screen->machine->gfx[4], offs, ace_scoreram);
75   }
76
7776   /* first of all, fill the screen with the background color */
7877   bitmap_fill(bitmap, cliprect, 0);
7978
r4135r4136
119118}
120119
121120
122static READ8_HANDLER( ace_characterram_r )
123{
124   return ace_characterram[offset];
125}
126
127121static WRITE8_HANDLER( ace_characterram_w )
128122{
129123   if (ace_characterram[offset] != data)
r4135r4136
134128         popmessage("write to %04x data=%02x\n", 0x8000+offset, data);
135129      }
136130      ace_characterram[offset] = data;
131      gfx_element_mark_dirty(space->machine->gfx[1], 0);
132      gfx_element_mark_dirty(space->machine->gfx[2], 0);
133      gfx_element_mark_dirty(space->machine->gfx[3], 0);
137134   }
138135}
139136
137static WRITE8_HANDLER( ace_scoreram_w )
138{
139   ace_scoreram[offset] = data;
140   gfx_element_mark_dirty(space->machine->gfx[4], offset / 32);
141}
140142
141143static READ8_HANDLER( unk_r )
142144{
r4135r4136
152154
153155   AM_RANGE(0x0000, 0x09ff) AM_ROM
154156
155   AM_RANGE(0x2000, 0x20ff) AM_RAM AM_BASE(&ace_scoreram)   /* 2x2101 */
157   AM_RANGE(0x2000, 0x20ff) AM_RAM_WRITE(ace_scoreram_w) AM_BASE(&ace_scoreram)   /* 2x2101 */
156158   AM_RANGE(0x8300, 0x83ff) AM_RAM AM_BASE(&ace_ram2)      /* 2x2101 */
157   AM_RANGE(0x8000, 0x80ff) AM_READWRITE(ace_characterram_r, ace_characterram_w) AM_BASE(&ace_characterram)   /* 3x3101 (3bits: 0, 1, 2) */
159   AM_RANGE(0x8000, 0x80ff) AM_RAM_WRITE(ace_characterram_w) AM_BASE(&ace_characterram)   /* 3x3101 (3bits: 0, 1, 2) */
158160
159161   AM_RANGE(0xc000, 0xc005) AM_WRITE(ace_objpos_w)
160162
r4135r4136
303305   GFXDECODE_ENTRY( NULL          , 0x8000, scorelayout, 0, 2 )    /* the game dynamically modifies this */
304306GFXDECODE_END
305307
308static MACHINE_START( ace )
309{
310    state_save_register_global_array(machine, objpos);
311}
306312
307
308313static MACHINE_DRIVER_START( ace )
309314
310315   /* basic machine hardware */
311316   MDRV_CPU_ADD("main", 8080, MASTER_CLOCK/9)   /* 2 MHz ? */
312317   MDRV_CPU_PROGRAM_MAP(main_map,0)
318    MDRV_MACHINE_START(ace)
313319
314320   /* video hardware */
315321   MDRV_SCREEN_ADD("main", RASTER)
r4135r4136
322328   MDRV_PALETTE_LENGTH(2)
323329
324330   MDRV_PALETTE_INIT(ace)
331   MDRV_VIDEO_START(ace)
325332   MDRV_VIDEO_UPDATE(ace)
326333
327334   /* sound hardware */
r4135r4136
349356
350357ROM_END
351358
352GAME( 1976, ace, 0, ace, ace, 0, ROT0, "Allied Leisure", "Ace", GAME_NO_SOUND | GAME_IMPERFECT_COLORS )
359GAME( 1976, ace, 0, ace, ace, 0, ROT0, "Allied Leisure", "Ace", GAME_SUPPORTS_SAVE | GAME_NO_SOUND | GAME_IMPERFECT_COLORS )
src/mame/drivers/galdrvr.c
r4135r4136
43754375   ROM_LOAD( "32_f5.5f",     0x0000, 0x1000, CRC(1e5da9d6) SHA1(ca8b27e6dd40e4ca13e7e6b5f813bafca78b62f4) )
43764376   ROM_LOAD( "32_h5.5h",     0x1000, 0x1000, CRC(a57adb0a) SHA1(d97c7dc4a6c5efb59cc0148e2498156c682c6714) )
43774377
4378   ROM_REGION( 0x3000, "speech", 0 ) /* Samples? / Speech? */
4378   ROM_REGION( 0x3000, "digitalker", 0 ) /* Digitalker speech samples */
43794379   ROM_LOAD( "32_a3.6e",     0x0000, 0x1000, CRC(279ae6f9) SHA1(a93b1d68c9f4b6ad62fdb8816285e61bd3b4b884) )
43804380   ROM_LOAD( "32_a2.6d",     0x1000, 0x1000, CRC(90352dd4) SHA1(62c261a2f2fbd8eff31d5c72cf532d5e43d86dd3) )
43814381   ROM_LOAD( "32_a1.6c",     0x2000, 0x1000, CRC(3bf2452d) SHA1(7a163e0ef108dd40d3beab5e9805886e45be744b) )
r4135r4136
44024402   ROM_LOAD( "scor_f5.bin",  0x0000, 0x1000, CRC(60180a38) SHA1(518c1267523139aa4e27860012a722b67fe25b6d) )
44034403   ROM_LOAD( "32_h5.5h",     0x1000, 0x1000, CRC(a57adb0a) SHA1(d97c7dc4a6c5efb59cc0148e2498156c682c6714) )
44044404
4405   ROM_REGION( 0x3000, "speech", 0 ) /* Samples? / Speech? */
4405   ROM_REGION( 0x3000, "digitalker", 0 ) /* Digitalker speech samples */
44064406   ROM_LOAD( "scor_a3.bin",  0x0000, 0x1000, CRC(04abf178) SHA1(2e7f231413d9ec461ca21840f31d1d6b8b17c4d5) )
44074407   ROM_LOAD( "scor_a2.bin",  0x1000, 0x1000, CRC(452d6354) SHA1(3d5397fddcc17b4d03b9cdc53a6439f159d1bfcc) )
44084408   ROM_LOAD( "32_a1.6c",     0x2000, 0x1000, CRC(3bf2452d) SHA1(7a163e0ef108dd40d3beab5e9805886e45be744b) )
r4135r4136
44284428   ROM_LOAD( "ic72.5f",     0x0000, 0x1000, CRC(1e5da9d6) SHA1(ca8b27e6dd40e4ca13e7e6b5f813bafca78b62f4) )
44294429   ROM_LOAD( "ic73.5h",     0x1000, 0x1000, CRC(a57adb0a) SHA1(d97c7dc4a6c5efb59cc0148e2498156c682c6714) )
44304430
4431   ROM_REGION( 0x3000, "speech", 0 ) /* Samples? / Speech? */
4431   ROM_REGION( 0x3000, "digitalker", 0 ) /* Digitalker speech samples */
44324432   ROM_LOAD( "ic25.6e",     0x0000, 0x1000, CRC(04abf178) SHA1(2e7f231413d9ec461ca21840f31d1d6b8b17c4d5) )
44334433   ROM_LOAD( "ic24.6d",     0x1000, 0x1000, CRC(90352dd4) SHA1(62c261a2f2fbd8eff31d5c72cf532d5e43d86dd3) )
44344434   ROM_LOAD( "ic23.6c",     0x2000, 0x1000, CRC(3bf2452d) SHA1(7a163e0ef108dd40d3beab5e9805886e45be744b) )
src/mame/drivers/caswin.c
r4135r4136
3131         0);
3232}
3333
34VIDEO_START(vvillage)
34static VIDEO_START(vvillage)
3535{
3636   sc0_tilemap = tilemap_create(machine, get_sc0_tile_info,tilemap_scan_rows,8,8,32,32);
3737}
3838
39VIDEO_UPDATE(vvillage)
39static VIDEO_UPDATE(vvillage)
4040{
4141   tilemap_draw(bitmap,cliprect,sc0_tilemap,0,0);
4242   return 0;
src/mame/drivers/8080bw.c
r4135r4136
8989#include "driver.h"
9090#include "cpu/m6800/m6800.h"
9191#include "cpu/i8085/i8085.h"
92#include "sound/speaker.h"
9293#include "deprecat.h"
9394#include "8080bw.h"
9495#include "mw8080bw.h"
r4135r4136
99100
100101/*******************************************************/
101102/*                                                     */
103/* Games with additional sound / video hardware        */
104/*                                                     */
105/*******************************************************/
106
107static MACHINE_START( extra_8080bw )
108{
109    MACHINE_START_CALL(extra_8080bw_sh);
110    MACHINE_START_CALL(extra_8080bw_vh);
111    MACHINE_START_CALL(mw8080bw);
112}
113
114/*******************************************************/
115/*                                                     */
102116/* Space Invaders CV Version (Taito)                   */
103117/*                                                     */
104118/*******************************************************/
r4135r4136
230244    MDRV_IMPORT_FROM(mw8080bw_root)
231245    MDRV_CPU_MODIFY("main")
232246    MDRV_CPU_IO_MAP(invadpt2_io_map,0)
247    MDRV_MACHINE_START(extra_8080bw)
233248
234249    /* 60 Hz signal clocks two LS161. Ripple carry will */
235250    /* reset circuit, if LS161 not cleared before.      */
r4135r4136
285300   MDRV_IMPORT_FROM(mw8080bw_root)
286301   MDRV_CPU_MODIFY("main")
287302   MDRV_CPU_IO_MAP(spcewars_io_map,0)
303    MDRV_MACHINE_START(extra_8080bw)
288304
289305   /* sound hardware */
290306   MDRV_IMPORT_FROM(invaders_samples_audio)
r4135r4136
407423    MDRV_CPU_MODIFY("main")
408424   MDRV_CPU_PROGRAM_MAP(cosmo_map, 0)
409425   MDRV_CPU_IO_MAP(cosmo_io_map, 0)
426    MDRV_MACHINE_START(extra_8080bw)
410427
411428    /* video hardware */
412429   MDRV_VIDEO_UPDATE(cosmo)
r4135r4136
631648   MDRV_IMPORT_FROM(mw8080bw_root)
632649   MDRV_CPU_MODIFY("main")
633650   MDRV_CPU_IO_MAP(lrescue_io_map,0)
651    MDRV_MACHINE_START(extra_8080bw)
634652
635653   /* video hardware */
636654   MDRV_VIDEO_UPDATE(invadpt2)
r4135r4136
943961   MDRV_CPU_MODIFY("main")
944962   MDRV_CPU_PROGRAM_MAP(schaser_map,0)
945963   MDRV_CPU_IO_MAP(schasrcv_io_map,0)
964    MDRV_MACHINE_START(extra_8080bw)
946965
947966   /* video hardware */
948967   MDRV_VIDEO_UPDATE(schasrcv)
r4135r4136
971990   return sfl_int;
972991}
973992
993static MACHINE_START( sflush )
994{
995    state_save_register_global(machine, sfl_int);
996
997    MACHINE_START_CALL(mw8080bw);
998}
999
9741000static ADDRESS_MAP_START( sflush_map, ADDRESS_SPACE_PROGRAM, 8 )
9751001   AM_RANGE(0x0000, 0x1fff) AM_RAM
9761002   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size)
r4135r4136
9941020   MDRV_CPU_REPLACE("main",M6800,2000000)        /* ?? */
9951021   MDRV_CPU_PROGRAM_MAP(sflush_map,0)
9961022   MDRV_CPU_VBLANK_INT_HACK(irq0_line_pulse,2)
1023    MDRV_MACHINE_START(sflush)
9971024
9981025   /* video hardware */
9991026   MDRV_VIDEO_UPDATE(sflush)
r4135r4136
10951122   MDRV_CPU_MODIFY("main")
10961123   MDRV_CPU_PROGRAM_MAP(schaser_map,0)
10971124   MDRV_CPU_IO_MAP(lupin3_io_map,0)
1125    MDRV_MACHINE_START(extra_8080bw)
10981126
10991127   /* video hardware */
11001128   MDRV_VIDEO_UPDATE(lupin3)
r4135r4136
11331161   return polaris_cloud_pos;
11341162}
11351163
1164static MACHINE_START( polaris )
1165{
1166    state_save_register_global(machine, polaris_cloud_speed);
1167    state_save_register_global(machine, polaris_cloud_pos);
11361168
1169    MACHINE_START_CALL(mw8080bw);
1170}
1171
11371172// Port 5 is used to reset the watchdog timer.
11381173// This port is also written to when the boss plane is going up and down.
11391174// If you write this value to a note ciruit similar to the music,
r4135r4136
12141249   MDRV_CPU_IO_MAP(polaris_io_map,0)
12151250   MDRV_WATCHDOG_VBLANK_INIT(255)
12161251   MDRV_CPU_VBLANK_INT("main", polaris_interrupt)
1252    MDRV_MACHINE_START(polaris)
12171253
12181254   /* video hardware */
12191255   MDRV_VIDEO_UPDATE(polaris)
r4135r4136
13361372   MDRV_IMPORT_FROM(mw8080bw_root)
13371373   MDRV_CPU_MODIFY("main")
13381374   MDRV_CPU_IO_MAP(ballbomb_io_map,0)
1375    MDRV_MACHINE_START(extra_8080bw)
13391376
13401377   /* video hardware */
13411378   MDRV_VIDEO_UPDATE(ballbomb)
r4135r4136
14101447   MDRV_CPU_MODIFY("main")
14111448   MDRV_CPU_PROGRAM_MAP(yosakdon_map,0)
14121449   MDRV_CPU_IO_MAP(yosakdon_io_map,0)
1450    MDRV_MACHINE_START(extra_8080bw)
14131451
14141452   /* sound hardware */
14151453   MDRV_IMPORT_FROM(invaders_samples_audio)
r4135r4136
15061544   MDRV_IMPORT_FROM(mw8080bw_root)
15071545   MDRV_CPU_MODIFY("main")
15081546   MDRV_CPU_IO_MAP(indianbt_io_map,0)
1547    MDRV_MACHINE_START(extra_8080bw)
15091548
15101549   /* video hardware */
15111550   MDRV_VIDEO_UPDATE(indianbt)
r4135r4136
16031642   MDRV_CPU_MODIFY("main")
16041643   MDRV_CPU_PROGRAM_MAP(shuttlei_map,0)
16051644   MDRV_CPU_IO_MAP(shuttlei_io_map,0)
1645    MDRV_MACHINE_START(extra_8080bw)
16061646
16071647   /* video hardware */
16081648   MDRV_SCREEN_MODIFY("main")
r4135r4136
24922532/* board #  rom       parent    machine   inp */
24932533
24942534/* Taito games */
2495GAMEL(1978, sitv,     invaders, invaders, sitv,     0, ROT270, "Taito", "Space Invaders (TV Version)", 0, layout_invaders )
2496GAME( 1979, sicv,     invaders, invadpt2, sicv,     0, ROT270, "Taito", "Space Invaders (CV Version)", 0 )
2497GAME( 1978, sisv,     invaders, invadpt2, sicv,     0, ROT270, "Taito", "Space Invaders (SV Version)", 0 )
2498GAME( 1978, sisv2,    invaders, invadpt2, sicv,     0, ROT270, "Taito", "Space Invaders (SV Version 2)", 0 )
2499GAMEL(1979, galxwars, 0,        invaders, galxwars, 0, ROT270, "Universal", "Galaxy Wars (Universal set 1)", 0, layout_invaders )
2500GAMEL(1979, galxwar2, galxwars, invaders, galxwars, 0, ROT270, "Universal", "Galaxy Wars (Universal set 2)", 0, layout_invaders )
2501GAMEL(1979, galxwart, galxwars, invaders, galxwars, 0, ROT270, "Taito?", "Galaxy Wars (Taito?)" , 0, layout_invaders) /* Copyright Not Displayed */
2502GAMEL(1979, starw,    galxwars, invaders, galxwars, 0, ROT270, "bootleg", "Star Wars", 0, layout_invaders )
2503GAME( 1979, lrescue,  0,        lrescue,  lrescue,  0, ROT270, "Taito", "Lunar Rescue", 0 )
2504GAME( 1980, mlander,  lrescue,  invaders, lrescue,  0, ROT270, "[Taito] (Leisure Time Electronics bootleg)", "Moon Lander (bootleg of Lunar Rescue)", 0 )
2505GAME( 1978, lrescuem, lrescue,  lrescue,  lrescue,  0, ROT270, "Taito (Model Racing bootleg)", "Lunar Rescue (Model Racing bootleg)", 0 )
2506GAME( 1979, grescue,  lrescue,  lrescue,  lrescue,  0, ROT270, "Taito (Universal license?)", "Galaxy Rescue", 0 )
2507GAME( 1979, desterth, lrescue,  lrescue,  invrvnge, 0, ROT270, "bootleg", "Destination Earth", 0 )
2508GAME( 1979, invadpt2, 0,        invadpt2, invadpt2, 0, ROT270, "Taito", "Space Invaders Part II (Taito)", 0 )
2509GAME( 1980, invaddlx, invadpt2, invaders, invadpt2, 0, ROT270, "Midway", "Space Invaders Deluxe", 0 )
2510GAME( 1979, cosmo,    0,        cosmo,    cosmo,    0, ROT90,  "TDS & Mints", "Cosmo", GAME_IMPERFECT_SOUND )
2511GAME( 1979, schaser,  0,        schaser,  schaser,  0, ROT270, "Taito", "Space Chaser", GAME_IMPERFECT_COLORS )
2512GAME( 1979, schasrcv, schaser,  schasrcv, schasrcv, 0, ROT270, "Taito", "Space Chaser (CV version)", GAME_IMPERFECT_COLORS )
2513GAME( 1979, sflush,   0,        sflush,   sflush,   0, ROT270, "Taito", "Straight Flush",GAME_NO_SOUND| GAME_IMPERFECT_COLORS | GAME_NO_COCKTAIL)
2514GAME( 1980, lupin3,   0,        lupin3,   lupin3,   0, ROT270, "Taito", "Lupin III", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
2515GAME( 1980, polaris,  0,        polaris,  polaris,  0, ROT270, "Taito", "Polaris (set 1)", 0 )
2516GAME( 1980, polarisa, polaris,  polaris,  polaris,  0, ROT270, "Taito", "Polaris (set 2)", 0 )
2517GAME( 1980, ballbomb, 0,        ballbomb, ballbomb, 0, ROT270, "Taito", "Balloon Bomber", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )   /* missing clouds */
2518GAME( 1980, indianbt, 0,        indianbt, indianbt, 0, ROT270, "Taito", "Indian Battle", 0 )
2535GAMEL(1978, sitv,     invaders, invaders, sitv,     0, ROT270, "Taito", "Space Invaders (TV Version)", GAME_SUPPORTS_SAVE, layout_invaders )
2536GAME( 1979, sicv,     invaders, invadpt2, sicv,     0, ROT270, "Taito", "Space Invaders (CV Version)", GAME_SUPPORTS_SAVE )
2537GAME( 1978, sisv,     invaders, invadpt2, sicv,     0, ROT270, "Taito", "Space Invaders (SV Version)", GAME_SUPPORTS_SAVE )
2538GAME( 1978, sisv2,    invaders, invadpt2, sicv,     0, ROT270, "Taito", "Space Invaders (SV Version 2)", GAME_SUPPORTS_SAVE )
2539GAMEL(1979, galxwars, 0,        invaders, galxwars, 0, ROT270, "Universal", "Galaxy Wars (Universal set 1)", GAME_SUPPORTS_SAVE, layout_invaders )
2540GAMEL(1979, galxwar2, galxwars, invaders, galxwars, 0, ROT270, "Universal", "Galaxy Wars (Universal set 2)", GAME_SUPPORTS_SAVE, layout_invaders )
2541GAMEL(1979, galxwart, galxwars, invaders, galxwars, 0, ROT270, "Taito?", "Galaxy Wars (Taito?)" , GAME_SUPPORTS_SAVE, layout_invaders) /* Copyright Not Displayed */
2542GAMEL(1979, starw,    galxwars, invaders, galxwars, 0, ROT270, "bootleg", "Star Wars", GAME_SUPPORTS_SAVE, layout_invaders )
2543GAME( 1979, lrescue,  0,        lrescue,  lrescue,  0, ROT270, "Taito", "Lunar Rescue", GAME_SUPPORTS_SAVE )
2544GAME( 1980, mlander,  lrescue,  invaders, lrescue,  0, ROT270, "[Taito] (Leisure Time Electronics bootleg)", "Moon Lander (bootleg of Lunar Rescue)", GAME_SUPPORTS_SAVE )
2545GAME( 1978, lrescuem, lrescue,  lrescue,  lrescue,  0, ROT270, "Taito (Model Racing bootleg)", "Lunar Rescue (Model Racing bootleg)", GAME_SUPPORTS_SAVE )
2546GAME( 1979, grescue,  lrescue,  lrescue,  lrescue,  0, ROT270, "Taito (Universal license?)", "Galaxy Rescue", GAME_SUPPORTS_SAVE )
2547GAME( 1979, desterth, lrescue,  lrescue,  invrvnge, 0, ROT270, "bootleg", "Destination Earth", GAME_SUPPORTS_SAVE )
2548GAME( 1979, invadpt2, 0,        invadpt2, invadpt2, 0, ROT270, "Taito", "Space Invaders Part II (Taito)", GAME_SUPPORTS_SAVE )
2549GAME( 1980, invaddlx, invadpt2, invaders, invadpt2, 0, ROT270, "Midway", "Space Invaders Deluxe", GAME_SUPPORTS_SAVE )
2550GAME( 1979, cosmo,    0,        cosmo,    cosmo,    0, ROT90,  "TDS & Mints", "Cosmo", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
2551GAME( 1979, schaser,  0,        schaser,  schaser,  0, ROT270, "Taito", "Space Chaser", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_COLORS )
2552GAME( 1979, schasrcv, schaser,  schasrcv, schasrcv, 0, ROT270, "Taito", "Space Chaser (CV version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_COLORS )
2553GAME( 1979, sflush,   0,        sflush,   sflush,   0, ROT270, "Taito", "Straight Flush",GAME_SUPPORTS_SAVE | GAME_NO_SOUND | GAME_IMPERFECT_COLORS | GAME_NO_COCKTAIL)
2554GAME( 1980, lupin3,   0,        lupin3,   lupin3,   0, ROT270, "Taito", "Lupin III", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
2555GAME( 1980, polaris,  0,        polaris,  polaris,  0, ROT270, "Taito", "Polaris (set 1)", GAME_SUPPORTS_SAVE )
2556GAME( 1980, polarisa, polaris,  polaris,  polaris,  0, ROT270, "Taito", "Polaris (set 2)", GAME_SUPPORTS_SAVE )
2557GAME( 1980, ballbomb, 0,        ballbomb, ballbomb, 0, ROT270, "Taito", "Balloon Bomber", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )    /* missing clouds */
2558GAME( 1980, indianbt, 0,        indianbt, indianbt, 0, ROT270, "Taito", "Indian Battle", GAME_SUPPORTS_SAVE )
25192559
25202560/* Misc. manufacturers */
25212561
2522GAMEL(1980, searthin, invaders, invaders, searthin, 0, ROT270, "bootleg", "Super Earth Invasion (set 1)", 0, layout_invaders )
2523GAMEL(1980, searthia, invaders, invaders, searthin, 0, ROT270, "bootleg", "Super Earth Invasion (set 2)", 0, layout_invaders )
2524GAMEL(1978, invadrmr, invaders, invaders, invadrmr, 0, ROT270, "Model Racing", "Space Invaders (Model Racing)", 0, layout_invaders )
2525GAMEL(1978, spaceatt, invaders, invaders, sicv,     0, ROT270, "Video Games GMBH", "Space Attack", 0, layout_invaders )
2526GAMEL(1980, spaceat2, invaders, invaders, spaceatt, 0, ROT270, "Zenitone-Microsec Ltd", "Space Attack II", 0, layout_invaders )
2527GAMEL(19??, sinvzen,  invaders, invaders, spaceatt, 0, ROT270, "Zenitone-Microsec Ltd", "Super Invaders (Zenitone-Microsec)", 0, layout_invaders )
2528GAMEL(19??, sinvemag, invaders, invaders, sinvemag, 0, ROT270, "bootleg", "Super Invaders (EMAG)", 0, layout_invaders )
2529GAMEL(19??, tst_invd, invaders, invaders, sicv,     0, ROT0,   "Test ROM", "Space Invaders Test ROM", 0, layout_invaders )
2530GAMEL(19??, alieninv, invaders, invaders, searthin, 0, ROT270, "bootleg", "Alien Invasion Part II", 0, layout_invaders )
2531GAMEL(1978, spceking, invaders, invaders, sicv,     0, ROT270, "Leijac Corporation (Konami)","Space King", 0, layout_invaders )
2532GAMEL(1978, spcewars, invaders, spcewars, spcewars, 0, ROT270, "Sanritsu", "Space War (Sanritsu)", 0, layout_invaders )
2533GAME (19??, astropal, 0,        astropal, astropal, 0, ROT0,   "Sidam?", "Astropal", GAME_IMPERFECT_SOUND )
2534GAMEL(1978, spacewr3, invaders, spcewars, sicv,     0, ROT270, "bootleg", "Space War Part 3", 0, layout_invaders )
2535GAMEL(1978, invaderl, invaders, invaders, sicv,     0, ROT270, "Logitec", "Space Invaders (Logitec)", 0, layout_invaders )
2536GAMEL(1978, invader4, invaders, invaders, sicv,     0, ROT270, "bootleg", "Space Invaders Part Four", 0, layout_invaders )
2537GAMEL(1979, jspecter, invaders, invaders, jspecter, 0, ROT270, "Jatre", "Jatre Specter (set 1)", 0, layout_invaders )
2538GAMEL(1979, jspectr2, invaders, invaders, jspecter, 0, ROT270, "Jatre", "Jatre Specter (set 2)", 0, layout_invaders )
2539GAMEL(1979, cosmicmo, invaders, invaders, cosmicmo, 0, ROT270, "Universal", "Cosmic Monsters", 0, layout_invaders )
2540GAMEL(1979, cosmicm2, invaders, invaders, cosmicmo, 0, ROT270, "Universal", "Cosmic Monsters 2", 0, layout_invaders )
2541GAMEL(19??, superinv, invaders, invaders, superinv, 0, ROT270, "bootleg", "Super Invaders", 0, layout_invaders )
2542GAMEL(19??, invasion, invaders, invaders, invasion, 0, ROT270, "Sidam", "Invasion", 0, layout_invaders )
2543GAME( 19??, darthvdr, invaders, darthvdr, darthvdr, 0, ROT270, "bootleg", "Darth Vader", GAME_NO_SOUND )
2544GAME( 1979, moonbase, invadpt2, invadpt2, invadpt2, 0, ROT270, "Nichibutsu", "Moon Base", 0 )
2545GAMEL(19??, invrvnge, 0,        invrvnge, invrvnge, 0, ROT270, "Zenitone-Microsec Ltd.", "Invader's Revenge",  GAME_IMPERFECT_SOUND, layout_invrvnge )
2546GAMEL(19??, invrvnga, invrvnge, invrvnge, invrvnge, 0, ROT270, "Zenitone-Microsec Ltd. (Dutchford license)", "Invader's Revenge (Dutchford)", GAME_IMPERFECT_SOUND, layout_invrvnge )
2547GAME( 1980, spclaser, 0,        invaders, spclaser, 0, ROT270, "GamePlan (Taito)", "Space Laser", 0 )
2548GAME( 1980, laser,    spclaser, invaders, spclaser, 0, ROT270, "Leisure Time Electronics Inc.", "Astro Laser", 0 )
2549GAME( 1979, spcewarl, spclaser, invaders, spclaser, 0, ROT270, "Leijac Corporation (Konami)","Space War (Leijac Corporation)", 0 )
2550GAME( 1979, rollingc, 0,        rollingc, rollingc, 0, ROT270, "Nichibutsu", "Rolling Crash / Moon Base", 0 )
2551GAME( 1979, ozmawars, 0,        invaders, ozmawars, 0, ROT270, "SNK", "Ozma Wars (set 1)", 0 )
2552GAME( 1979, ozmawar2, ozmawars, invaders, ozmawars, 0, ROT270, "SNK", "Ozma Wars (set 2)" , 0) /* Uses Taito's three board color version of Space Invaders PCB */
2553GAME( 1979, solfight, ozmawars, invaders, ozmawars, 0, ROT270, "bootleg", "Solar Fight", 0 )
2554GAME( 1979, spaceph,  ozmawars, invaders, spaceph,  0, ROT270, "Zilec Games", "Space Phantoms", 0 )
2555GAME( 1979, yosakdon, 0,        yosakdon, yosakdon, 0, ROT270, "Wing", "Yosaku To Donbei (set 1)", GAME_IMPERFECT_SOUND ) /* bootleg? */
2556GAME( 1979, yosakdoa, yosakdon, yosakdon, yosakdon, 0, ROT270, "Wing", "Yosaku To Donbei (set 2)", GAME_IMPERFECT_SOUND ) /* bootleg? */
2557GAMEL(197?, shuttlei, 0,        shuttlei, shuttlei, 0, ROT270, "Omori", "Shuttle Invader", GAME_NO_COCKTAIL, layout_shuttlei )
2562GAMEL(1980, searthin, invaders, invaders, searthin, 0, ROT270, "bootleg", "Super Earth Invasion (set 1)", GAME_SUPPORTS_SAVE, layout_invaders )
2563GAMEL(1980, searthia, invaders, invaders, searthin, 0, ROT270, "bootleg", "Super Earth Invasion (set 2)", GAME_SUPPORTS_SAVE, layout_invaders )
2564GAMEL(1978, invadrmr, invaders, invaders, invadrmr, 0, ROT270, "Model Racing", "Space Invaders (Model Racing)", GAME_SUPPORTS_SAVE, layout_invaders )
2565GAMEL(1978, spaceatt, invaders, invaders, sicv,     0, ROT270, "Video Games GMBH", "Space Attack", GAME_SUPPORTS_SAVE, layout_invaders )
2566GAMEL(1980, spaceat2, invaders, invaders, spaceatt, 0, ROT270, "Zenitone-Microsec Ltd", "Space Attack II", GAME_SUPPORTS_SAVE, layout_invaders )
2567GAMEL(19??, sinvzen,  invaders, invaders, spaceatt, 0, ROT270, "Zenitone-Microsec Ltd", "Super Invaders (Zenitone-Microsec)", GAME_SUPPORTS_SAVE, layout_invaders )
2568GAMEL(19??, sinvemag, invaders, invaders, sinvemag, 0, ROT270, "bootleg", "Super Invaders (EMAG)", GAME_SUPPORTS_SAVE, layout_invaders )
2569GAMEL(19??, tst_invd, invaders, invaders, sicv,     0, ROT0,   "Test ROM", "Space Invaders Test ROM", GAME_SUPPORTS_SAVE, layout_invaders )
2570GAMEL(19??, alieninv, invaders, invaders, searthin, 0, ROT270, "bootleg", "Alien Invasion Part II", GAME_SUPPORTS_SAVE, layout_invaders )
2571GAMEL(1978, spceking, invaders, invaders, sicv,     0, ROT270, "Leijac Corporation (Konami)","Space King", GAME_SUPPORTS_SAVE, layout_invaders )
2572GAMEL(1978, spcewars, invaders, spcewars, spcewars, 0, ROT270, "Sanritsu", "Space War (Sanritsu)", GAME_SUPPORTS_SAVE, layout_invaders )
2573GAME (19??, astropal, 0,        astropal, astropal, 0, ROT0,   "Sidam?", "Astropal", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
2574GAMEL(1978, spacewr3, invaders, spcewars, sicv,     0, ROT270, "bootleg", "Space War Part 3", GAME_SUPPORTS_SAVE, layout_invaders )
2575GAMEL(1978, invaderl, invaders, invaders, sicv,     0, ROT270, "Logitec", "Space Invaders (Logitec)", GAME_SUPPORTS_SAVE, layout_invaders )
2576GAMEL(1978, invader4, invaders, invaders, sicv,     0, ROT270, "bootleg", "Space Invaders Part Four", GAME_SUPPORTS_SAVE, layout_invaders )
2577GAMEL(1979, jspecter, invaders, invaders, jspecter, 0, ROT270, "Jatre", "Jatre Specter (set 1)", GAME_SUPPORTS_SAVE, layout_invaders )
2578GAMEL(1979, jspectr2, invaders, invaders, jspecter, 0, ROT270, "Jatre", "Jatre Specter (set 2)", GAME_SUPPORTS_SAVE, layout_invaders )
2579GAMEL(1979, cosmicmo, invaders, invaders, cosmicmo, 0, ROT270, "Universal", "Cosmic Monsters", GAME_SUPPORTS_SAVE, layout_invaders )
2580GAMEL(1979, cosmicm2, invaders, invaders, cosmicmo, 0, ROT270, "Universal", "Cosmic Monsters 2", GAME_SUPPORTS_SAVE, layout_invaders )
2581GAMEL(19??, superinv, invaders, invaders, superinv, 0, ROT270, "bootleg", "Super Invaders", GAME_SUPPORTS_SAVE, layout_invaders )
2582GAMEL(19??, invasion, invaders, invaders, invasion, 0, ROT270, "Sidam", "Invasion", GAME_SUPPORTS_SAVE, layout_invaders )
2583GAME( 19??, darthvdr, invaders, darthvdr, darthvdr, 0, ROT270, "bootleg", "Darth Vader", GAME_SUPPORTS_SAVE | GAME_NO_SOUND )
2584GAME( 1979, moonbase, invadpt2, invadpt2, invadpt2, 0, ROT270, "Nichibutsu", "Moon Base", GAME_SUPPORTS_SAVE )
2585GAMEL(19??, invrvnge, 0,        invrvnge, invrvnge, 0, ROT270, "Zenitone-Microsec Ltd.", "Invader's Revenge",  GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND, layout_invrvnge )
2586GAMEL(19??, invrvnga, invrvnge, invrvnge, invrvnge, 0, ROT270, "Zenitone-Microsec Ltd. (Dutchford license)", "Invader's Revenge (Dutchford)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND, layout_invrvnge )
2587GAME( 1980, spclaser, 0,        invaders, spclaser, 0, ROT270, "GamePlan (Taito)", "Space Laser", GAME_SUPPORTS_SAVE )
2588GAME( 1980, laser,    spclaser, invaders, spclaser, 0, ROT270, "Leisure Time Electronics Inc.", "Astro Laser", GAME_SUPPORTS_SAVE )
2589GAME( 1979, spcewarl, spclaser, invaders, spclaser, 0, ROT270, "Leijac Corporation (Konami)","Space War (Leijac Corporation)", GAME_SUPPORTS_SAVE )
2590GAME( 1979, rollingc, 0,        rollingc, rollingc, 0, ROT270, "Nichibutsu", "Rolling Crash / Moon Base", GAME_SUPPORTS_SAVE )
2591GAME( 1979, ozmawars, 0,        invaders, ozmawars, 0, ROT270, "SNK", "Ozma Wars (set 1)", GAME_SUPPORTS_SAVE )
2592GAME( 1979, ozmawar2, ozmawars, invaders, ozmawars, 0, ROT270, "SNK", "Ozma Wars (set 2)", GAME_SUPPORTS_SAVE ) /* Uses Taito's three board color version of Space Invaders PCB */
2593GAME( 1979, solfight, ozmawars, invaders, ozmawars, 0, ROT270, "bootleg", "Solar Fight", GAME_SUPPORTS_SAVE )
2594GAME( 1979, spaceph,  ozmawars, invaders, spaceph,  0, ROT270, "Zilec Games", "Space Phantoms", GAME_SUPPORTS_SAVE )
2595GAME( 1979, yosakdon, 0,        yosakdon, yosakdon, 0, ROT270, "Wing", "Yosaku To Donbei (set 1)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) /* bootleg? */
2596GAME( 1979, yosakdoa, yosakdon, yosakdon, yosakdon, 0, ROT270, "Wing", "Yosaku To Donbei (set 2)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND ) /* bootleg? */
2597GAMEL(197?, shuttlei, 0,        shuttlei, shuttlei, 0, ROT270, "Omori", "Shuttle Invader", GAME_SUPPORTS_SAVE | GAME_NO_COCKTAIL, layout_shuttlei )
src/mame/drivers/xyonix.c
r4135r4136
9999      {
100100         case 0x81 :
101101            return input_port_read(space->machine, "P1") & 0x7f;
102            break;
103102         case 0x82 :
104103            return input_port_read(space->machine, "P2") & 0x7f;
105            break;
106104         case 0x91:
107105            /* check coin inputs */
108106            coin = ((input_port_read(space->machine, "P1") & 0x80) >> 7) | ((input_port_read(space->machine, "P2") & 0x80) >> 6);
r4135r4136
112110            }
113111            prev_coin = coin;
114112            return credits;
115            break;
116113         case 0x92:
117114            return ((input_port_read(space->machine, "P1") & 0x80) >> 7) | ((input_port_read(space->machine, "P2") & 0x80) >> 6);
118            break;
119115         case 0xe0:   /* reset? */
120116            coins = 0;
121117            credits = 0;
122118            return 0xff;
123            break;
124119         case 0xe1:
125120            credits--;
126121            return 0xff;
127            break;
128122         case 0xfe:   /* Dip Switches 1 to 4 */
129123            return input_port_read(space->machine, "DSW") & 0x0f;
130            break;
131124         case 0xff:   /* Dip Switches 5 to 8 */
132125            return input_port_read(space->machine, "DSW") >> 4;
133            break;
134126      }
135127   }
136128
src/mame/drivers/esripsys.c
r4135r4136
99
1010    ROMs wanted:
1111        * Bouncer
12        * Turbo Sub [later version] (uses 512kbit graphics ROMs)
12        * Turbo Sub [later version] (improved gameplay, uses 27512 ROMs)
1313
1414    Notes:
1515        * 'turbosub' executes a series of hardware tests on startup.
1616        To skip, hold down keypad '*' on reset.
1717        * Hold '*' during the game to access the operator menu.
1818
19    Todo:
19    To do:
2020        * TMS5220 speech. The game is sending speech play commands to
2121        the sound CPU but any speech code greater than 2 is ignored (see $EC26).
2222        I think most of the speech data is stored in the upper half of the
2323        banked sound data ROMs but I don't know how or when the ROM
2424        bank is switched :/
2525
26        * Determine if line drop outs occur on real hardware. Overclocking
27        the RIP CPU eliminates them.
26        * Confirm that occasional line drop outs do occur on real hardware.
27        14 sprites seems to be the maximum number that the RIP CPU can safely
28        process per line.
2829
29        * Implement collision detection hardware (not used by Turbo Sub).
30        * Implement collision detection hardware (unused by Turbo Sub).
3031
3132****************************************************************************/
3233
r4135r4136
238239 *
239240 *************************************/
240241
241READ16_DEVICE_HANDLER( fdt_rip_r )
242static READ16_DEVICE_HANDLER( fdt_rip_r )
242243{
243244   offset = (offset & 0x7ff) << 1;
244245
r4135r4136
248249      return (fdt_b[offset] << 8) | fdt_b[offset + 1];
249250}
250251
251WRITE16_DEVICE_HANDLER( fdt_rip_w )
252static WRITE16_DEVICE_HANDLER( fdt_rip_w )
252253{
253254   offset = (offset & 0x7ff) << 1;
254255
r4135r4136
275276   D7 = /FDONE
276277*/
277278
278UINT8 rip_status_in(running_machine *machine)
279static UINT8 rip_status_in(running_machine *machine)
279280{
280   UINT8 _vblank = !video_screen_get_vblank(machine->primary_screen);
281   UINT8 _hblank = !video_screen_get_hblank(machine->primary_screen);
282   UINT8 v0 =  video_screen_get_vpos(machine->primary_screen) & 1;
281   int vpos =  video_screen_get_vpos(machine->primary_screen);
282   UINT8 _vblank = !(vpos >= ESRIPSYS_VBLANK_START);
283//  UINT8 _hblank = !video_screen_get_hblank(machine->primary_screen);
283284
284285   return   _vblank
285         | (_hblank << 1)
286         | (esripsys_hblank << 1)
286287         | (esripsys__12sel << 2)
287288         | (_fbsel << 4)
288         | (v0 << 5)
289         | ((vpos & 1) << 5)
289290         | (f_status & 0x80);
290291}
291292
r4135r4136
464465 *
465466 *************************************/
466467
467INPUT_PORTS_START( turbosub )
468static INPUT_PORTS_START( turbosub )
468469   PORT_START("KEYPAD_A")
469470   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )  PORT_PLAYER(3) PORT_CODE(KEYCODE_0_PAD) PORT_NAME("Keypad 0") PORT_CHANGED(keypad_interrupt, 0)
470471   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )  PORT_PLAYER(3) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("Keypad 1") PORT_CHANGED(keypad_interrupt, 0)
r4135r4136
529530{
530531   /* Bit 6 -> Reset latch U56A */
531532   /* Bit 7 -> Clock latch U56B */
532
533533   if (s_to_g_latch2 & 0x40)
534534   {
535535      u56a = 0;
r4135r4136
679679
680680   ptm6840_config(machine, 0, &ptm_intf);
681681
682   memory_set_bankptr(machine, 2, &ROM[0x0000+0x0000]);
683   memory_set_bankptr(machine, 3, &ROM[0x0000+0x4000]);
684   memory_set_bankptr(machine, 4, &ROM[0x0000+0x8000]);
682   memory_set_bankptr(machine, 2, &ROM[0x0000]);
683   memory_set_bankptr(machine, 3, &ROM[0x4000]);
684   memory_set_bankptr(machine, 4, &ROM[0x8000]);
685685
686   /* TODO: Finish me! */
687//  state_save_register_global_pointer(fdt_a, FDT_RAM_SIZE);
688//  state_save_register_global_pointer(fdt_b, FDT_RAM_SIZE);
686   /* Register stuff for state saving */
687   state_save_register_global_pointer(machine, fdt_a, FDT_RAM_SIZE);
688   state_save_register_global_pointer(machine, fdt_b, FDT_RAM_SIZE);
689   state_save_register_global_pointer(machine, cmos_ram, CMOS_RAM_SIZE);
690
691   state_save_register_global(machine, g_iodata);
692   state_save_register_global(machine, g_ioaddr);
693   state_save_register_global(machine, coin_latch);
694   state_save_register_global(machine, keypad_status);
695   state_save_register_global(machine, g_status);
696   state_save_register_global(machine, f_status);
697   state_save_register_global(machine, io_firq_status);
698   state_save_register_global(machine, cmos_ram_a2_0);
699   state_save_register_global(machine, cmos_ram_a10_3);
700
701   state_save_register_global(machine, u56a);
702   state_save_register_global(machine, u56b);
703   state_save_register_global(machine, g_to_s_latch1);
704   state_save_register_global(machine, g_to_s_latch2);
705   state_save_register_global(machine, s_to_g_latch1);
706   state_save_register_global(machine, s_to_g_latch2);
707   state_save_register_global(machine, dac_msb);
708   state_save_register_global(machine, dac_vol);
709   state_save_register_global(machine, tms_data);
710
711   state_save_register_global(machine, _fasel);
712   state_save_register_global(machine, _fbsel);
689713}
690714
691715static NVRAM_HANDLER( esripsys )
r4135r4136
698722      memset(cmos_ram, 0x00, CMOS_RAM_SIZE);
699723}
700724
701static esrip_config rip_config =
725static const esrip_config rip_config =
702726{
703727   fdt_rip_r,
704728   fdt_rip_w,
r4135r4136
729753   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
730754   MDRV_SCREEN_RAW_PARAMS(ESRIPSYS_PIXEL_CLOCK, ESRIPSYS_HTOTAL, ESRIPSYS_HBLANK_END, ESRIPSYS_HBLANK_START, ESRIPSYS_VTOTAL, ESRIPSYS_VBLANK_END, ESRIPSYS_VBLANK_START)
731755
756   MDRV_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
732757   MDRV_VIDEO_START(esripsys)
733758   MDRV_VIDEO_UPDATE(esripsys)
734759
r4135r4136
9881013 *
9891014 *************************************/
9901015
991GAME( 1985, turbosub, 0,        esripsys, turbosub, esripsys, ROT0, "Entertainment Sciences", "Turbo Sub (prototype rev. TSCA)", GAME_IMPERFECT_SOUND )
992GAME( 1985, turbosba, turbosub, esripsys, turbosub, esripsys, ROT0, "Entertainment Sciences", "Turbo Sub (prototype rev. TSC6)", GAME_IMPERFECT_SOUND )
1016GAME( 1985, turbosub, 0,        esripsys, turbosub, esripsys, ROT0, "Entertainment Sciences", "Turbo Sub (prototype rev. TSCA)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
1017GAME( 1985, turbosba, turbosub, esripsys, turbosub, esripsys, ROT0, "Entertainment Sciences", "Turbo Sub (prototype rev. TSC6)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
src/mame/drivers/deshoros.c
r4135r4136
1919/*Temporary,to show something on screen...*/
2020static char led_array[21];
2121
22VIDEO_START( deshoros )
22static VIDEO_START( deshoros )
2323{
2424   static UINT8 i;
2525   for(i=0;i<20;i++)
r4135r4136
2727   led_array[20] = 0;
2828}
2929
30VIDEO_UPDATE( deshoros )
30static VIDEO_UPDATE( deshoros )
3131{
3232   popmessage("%s",led_array);
3333   return 0;
src/mame/drivers/buster.c
r0r4136
1/*
2
3Buster
4
5Video Fruit Machine
6
7*/
8
9#include "driver.h"
10#include "cpu/z80/z80.h"
11#include "sound/ay8910.h"
12
13static UINT8 *buster_rom;
14static UINT8 *buster_vram;
15
16static VIDEO_START(buster)
17{
18
19}
20
21static VIDEO_UPDATE(buster)
22{
23   const gfx_element *gfx = screen->machine->gfx[0];
24   int count = 0x0000;
25
26   int y,x;
27
28
29   for (y=0;y<64;y++)
30   {
31      for (x=0;x<32;x++)
32      {
33         int tile = (buster_vram[count+1])|(buster_vram[count]<<8);
34         //int colour = tile>>12;
35         drawgfx(bitmap,gfx,tile,0,0,0,x*8,y*4,cliprect,TRANSPARENCY_NONE,0);
36
37         count+=2;
38      }
39   }
40   return 0;
41}
42
43static ADDRESS_MAP_START( mainmap, ADDRESS_SPACE_PROGRAM, 8 )
44   AM_RANGE(0x0000, 0x3fff) AM_RAM AM_BASE(&buster_rom)
45   AM_RANGE(0x4000, 0x47ff) AM_RAM
46   AM_RANGE(0x5000, 0x5fff) AM_RAM AM_BASE(&buster_vram)
47//  AM_RANGE(0x6000, 0x6000) MC6845 address
48//  AM_RANGE(0x6001, 0x6001) MC6845 data
49   AM_RANGE(0x7000, 0xafff) AM_ROM
50ADDRESS_MAP_END
51
52
53
54static INPUT_PORTS_START( buster )
55INPUT_PORTS_END
56
57static const gfx_layout tiles8x8_layout =
58{
59   8,4,
60   RGN_FRAC(1,3),
61   3,
62   { RGN_FRAC(0,3),RGN_FRAC(1,3),RGN_FRAC(2,3) },
63   { 0,1,2,3,4,5,6,7 },
64   { 0*8, 1*8, 2*8, 3*8 },
65   8*4
66};
67
68static GFXDECODE_START( buster )
69   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8_layout, 0, 16 )
70GFXDECODE_END
71
72static MACHINE_DRIVER_START( buster )
73   /* basic machine hardware */
74   MDRV_CPU_ADD("main", Z80,8000000)       /* ? MHz */
75   MDRV_CPU_PROGRAM_MAP(mainmap,0)
76   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
77
78   /* video hardware */
79   MDRV_SCREEN_ADD("main", RASTER)
80   MDRV_SCREEN_REFRESH_RATE(60)
81   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
82   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
83   MDRV_SCREEN_SIZE(256, 256)
84   MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 16, 256-16-1)
85
86   MDRV_GFXDECODE(buster)
87   MDRV_PALETTE_LENGTH(0x100)
88
89   MDRV_VIDEO_START(buster)
90   MDRV_VIDEO_UPDATE(buster)
91
92   MDRV_SPEAKER_STANDARD_MONO("mono")
93
94   MDRV_SOUND_ADD("ay", AY8910, 1500000/2)
95//  MDRV_SOUND_CONFIG(ay8910_config)
96   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
97MACHINE_DRIVER_END
98
99
100ROM_START( buster )
101   ROM_REGION( 0x10000, "main", 0 )
102   ROM_LOAD( "vf-1.bin", 0x00000, 0x1000, CRC(571c32fe) SHA1(a61a052a4caf4430be5c5377934295bb90bb903a) )
103   ROM_LOAD( "vf-2.bin", 0x01000, 0x1000, CRC(fefe8783) SHA1(aed2bae4cf531dc994b50be9968fa5e10b61f2b8) )
104   ROM_LOAD( "vf-3.bin", 0x02000, 0x1000, CRC(9dd9be43) SHA1(5319ef3b43236abd38138adef87a7701f91afd1d))
105   ROM_LOAD( "vf-4.bin", 0x03000, 0x1000, CRC(90dd550b) SHA1(a0a26031aada35f6d6c4fa5af9b75e594d8039d0) )
106   ROM_COPY( "main",     0x00000, 0x7000, 0x4000 )
107
108   ROM_REGION( 0x6000, "gfx1", 0 )
109   ROM_LOAD( "b-red.bin", 0x00000, 0x2000, CRC(6e3ea232) SHA1(dcf76a1ee12517bd00c7b10aaeda0fa2fcec941e) )
110   ROM_LOAD( "b-grn.bin", 0x02000, 0x2000, CRC(acdbb44f) SHA1(41f6a2d4a6b12f506588379f2ed3df48fbc8184e) )
111   ROM_LOAD( "b-blu.bin", 0x04000, 0x2000, CRC(3b6bfe7b) SHA1(1888149a2ef85db59845d7e6e9227449f80c8f22) )
112ROM_END
113
114static DRIVER_INIT( buster )
115{
116   UINT8 *ROM = memory_region(machine, "main");
117//  vram = auto_malloc(0x2000);
118   memcpy(buster_rom, ROM, 0x4000);
119}
120
121GAME( 1987, buster,  0,    buster, buster,  buster, ROT0, "Marian Electronics Ltd.", "Buster", GAME_NOT_WORKING|GAME_NO_SOUND )
src/mame/drivers/polyplay.c
r4135r4136
298298   MDRV_PALETTE_LENGTH(10)
299299
300300   MDRV_PALETTE_INIT(polyplay)
301   MDRV_VIDEO_START(polyplay)
301302   MDRV_VIDEO_UPDATE(polyplay)
302303
303304   /* sound hardware */
src/mame/drivers/sms.c
r0r4136
1/*
2    SMS Manufacturing Corp hardware
3
4    Driver by Mariusz Wojcieszek
5
6    Preliminary driver by Reip
7    Schematics provided by Exodus
8    Sure Shot board provided by ranger_lennier
9    Notes by Lord Nightmare
10
11    Notes/ToDo:
12    - pit8254 is not accessed by z80 (and there is no interrupt service routine), so
13      it is not fitted in the driver
14    - video registers can be read (to read framebuffer contents), this is not emulated
15      as software does not use this feature
16    - I8088 clock may be incorrect
17    - Video Blanking Zone input - probably hblank or vblank
18    - game speed may be not 100% correct - software does not use interrupts and
19      Video Blanking Zone is not emulated (which is required to get proper timings)
20    - implement video raw parameters
21
22*/
23
24/*
25smssshot (Lord Nightmare)
26SMS Sure Shot (poker?)
27* Same exact board as sms trivia, but "COMPONENT SIDE REV 01"
28  instead of rev 02.
29* 3 chips were removed from the board; two are shown as removed
30  in the schematic, one was removed later (an apparently
31  unnecessary data buffer on one of the z80 external latches)
32* Does NOT have a daughterboard with additional roms; in fact,
33  connector J1 for the ribbon cable to the daughterboard isn't
34  populated with pins at all
35* Serial Number A-108 etched in board, on back.
36
37
38smsbingo (Lord Nightmare)
39SMS Bingo
40Someone on the MW forums has this iirc, but it isn't dumped yet - LN
41
42
43
44**** Notes from schematics (applies to all drivers):
45Framebuffer is six tms4416 16384*4 chips; chips are arranged as three
46planes of 16384*8 bits per plane, one plane per color channel.
47Screen resolution is probably either 212x256 (two bits per plane, per
48pixel) or 424x256 (one bit per plane per pixel), depending on the pals
49installed. See schematics on page 6. The counters at U137 and U139
50compare against binary 0b110101 (53) in comparitor at U138, and as soon
51as it hits that, HDONE is pulled high on the next MCLR clock.
52This means there will be 53 (0-52) counts in the X counter before HDONE;
53as each count refers to one 8 bit address, and the addressed 4416 rams
54have between all of them 24 bits of output (8 per plane), the minimum
55horizontal displayed resolution is 53x256 (8 bits per color per pixel),
56and maximum is 8 times that. With proper pals (and proper mixing
57resistors or other PWM fun) it should be possible to get:
5853x256 8,8,8 RGB
59106x256 4,4,4 RGB
60212x256 2,2,2 RGB <- this seems the most likely to me (LN)
61424x256 1,1,1 RGB
62
63
64* The socket at U50 and the 3 pin connector J3 is for an
65  undumped intel 8050 MCU used for rs232 serial communication,
66  for either linking together machines, or more likely for factory
67  testing. The function of this internal rom is probably simple
68  enough to HLE or to even rewrite from scratch, but I doubt the code
69  on any of the dumped games even touches it, it was probably for use
70  with a specific game or for a set of hardware test roms to report
71  errors.
72  (schematic page 4)
73  The pinout of J3 is:
74     pin 1 (toward bottom of pcb): rs232 input to pcb
75     (pre-level shifted to 5v i.e. with a max232 or mc1489)
76     pin 2 : ground
77     pin 3 : rs232 output to elsewhere (to be sent to a max232 or
78     mc1488 to shift to rs232 voltage levels)
79
80* The 8255 PPI at U13 (connected to the 8088) is connected to 75451
81  drivers on all pins EXCEPT pins PC3 thru PC0.
82  (schematic page 3)
83  PA7 - Display Light 1
84  PA6 - Display Light 2
85  PA5 - Display Light 3
86  PA4 - Display Light 4
87  PA3 - Display Light 5
88  PA2 - Bet Light
89  PA1 - Deal Light
90  PA0 - Draw Light
91  PB7 - Stand Light
92  PB6 - Cancel Light
93  PB5 - Coin Lock out A
94  PB4 - Coin Lock out B
95  PB3 - Setup Light
96  PB2 - Hopper Motor
97  PB1 - Coin in Counter (mechanical counter inside the machine)
98  PB0 - Knock off Counter (tilt? probably also a mechanical counter)
99  PC7 - unused
100  PC6 - unused
101  PC5 - unused
102  PC4 - Battery Charge control (for 8088 ram backup 3.6v Nicad)
103  PC3 - (pulled high externally, input) - unused? possibly for an ABC hopper
104  PC2 - (pulled high externally, input) - unused? possibly for an ABC hopper
105  PC1 - (pulled high externally, input) - "Hopper Count",
106      probably a beam to check the hopper coin out
107  PC0 - "Video BZ" (Video Blanking Zone, is an input)
108
109* The 8255 PPI at U2 (connected to the z80) is unused and not populated.
110  (All 3 ports have +5V pullups on all pins)
111
112* The 8255 PPI at U1 (connected to the z80) is used as follows:
113  (All 3 ports have +5V pullups on all pins)
114  PA7 - Lighted Button 1 (input)
115  PA6 - Lighted Button 2 (input)
116  PA5 - Lighted Button 3 (input)
117  PA4 - Lighted Button 4 (input)
118  PA3 - Lighted Button 5 (input)
119  PA2 - Bet Button (input)
120  PA1 - Deal Button (input)
121  PA0 - Draw Button (input)
122  PB7 - Stand Button (input)
123  PB6 - Cancel Button (input)
124  PB5 - Alt Coin (input)
125  PB4 - Remote Knockoff (tilt? input)
126  PB3 - Operator Mode (input)
127  PB2 - Coin Error reset (input)
128  PB1 - unused
129  PB0 - unused
130  PC7 - unused
131  PC6 - unused
132  PC5 - unused
133  PC4 - unused
134  PC3 - unused
135  PC2 - unused
136  PC1 - unused
137  PC0 - Coin (input)
138
139
140* The function of the pals is:
141LOCATION    DOTS        TYPE        PURPOSE
142U32         1Green      DMPAL10L8NC Decodes the gated by U33/U34)
143   high address lines of the 8088, for mainboard ROM mapping. A
144   different pal is probably used depending on whether the
145   mainboard has 2764 or 27128 roms installed.
146   SMS Sure Shot: dumped ok as truth table, mainboard has 4 2764s
147   SMS Trivia: bad (chip shorted internally), mainboard has 2 27128s
148   SMS Bingo: not dumped
149   (schematic page 2)
150U38         3Blue           PAL10L8CN   Decodes the (gated by U36)
151   high address lines of the z80 address bus, for mapping of the z80
152   ROM, RAM, Counter control, 4 z80-to-8088 ports (2 one direction,
153   2 the other), the ay-3-8910, and the two 8255 PPIs.
154   (schematic page 10)
155U39         3Green          PAL10L8CN   Accessory decoder to U38, helps
156   with the 4 z80-to-8088 ports.
157   (schematic page 10)
158U40         1Red              PAL10L8CN   Connects to the low bits of the
159   8088 address bus for decoding writing to/reading from the 8088 side of
160   the 4 z80-to-8088 ports.
161   (schematic page 10, note this chip is mismarked as U9 on the page,
162    it is the chip in the lower left)
163U52         1Blue           PAL10L8CN   Decodes the (gated by U33/U34)
164   high address lines of the 8088, for main memory mapping of ram,
165   z80 communication, video, serial I/O (to U50), and the output-only
166   8255 at U13 (which controls button lights and the coin hopper)
167   SMS Sure Shot: dumped ok as truth table
168   SMS Trivia: checksum 0, probably bad
169   SMS Bingo: not dumped
170   (schematic page 1)
171U58         3Brown          DMPAL10H8NC Controls BDIR and BC1 on the
172   ay-3-8910 given the low two address bits of the z80 bits, the
173   ay-3-8910 enable line, and the buffered z80 RD and WR lines.
174   (schematic page 12)
175U80         2Blue           PAL10H8CN   State machine which controls StartH,
176   StartV, and the related functions involving the shifters for framebuffer
177   address and framebuffer output. Also lets framebuffer know when in hblank
178   or vblank. Is separate from the other "Video BZ" thing.
179   (schematic page 6)
180U94         2Green          PAL14H4CN   State machine controls the
181   read-modify-write logic for accessing the frame buffer (while outside
182   of vblank and hblank?), may allow writing red green and blue plane bytes
183   all to one address, one after the other
184   (schematic page 7)
185U109        2Brown          PAL14H4CN   Determines next state of the
186   'Pixel control' hardware, i.e. H and V current line counters
187   Also determines VBLANK/"Video BZ"
188   (schematic page 5)
189U110        2Red            PAL10L8CN   Translates output of U109
190   before being sent to counters/color reg latch/etc.
191   (schematic page 5)
192U128        Blue-Brown-Blue PAL10H8CN   One of three 'sync' pals which
193   control the memory and other timing subsystem, fed by a 4 bit counter.
194   this particular pal has one external feedback bit.
195   (schematic page 6)
196U129        Red-Green-Red   DMPAL10H8NC Second of three 'sync' pals
197   This one has 2 external feedback bits.
198   (schematic page 6)
199U130        3Red            PAL10H8CN   Third of three 'sync' pals'
200   This one has 3 external feedback bits plus three extra inputs from elsewhere
201   which are not readable on the schematic. Will trace them later.
202   (schematic page 6)
203U140        1Brown          PAL14H4CN   This and the next 5 pals are used
204   to shift the framebuffer data, 4 bits at a time. This is done in parallel
205   (8 bits per channel) for output. all 6 pals are the same.
206   (schematic page 7)
207U141        1Brown          PAL14H4CN
208U142        1Brown          PAL14H4CN
209U143        1Brown          PAL14H4CN
210U144        1Brown          PAL14H4CN
211U145        1Brown          PAL14H4CN
212
213
214*/
215#include "driver.h"
216#include "cpu/i86/i86.h"
217#include "cpu/z80/z80.h"
218#include "sound/ay8910.h"
219#include "machine/8255ppi.h"
220
221/*************************************
222 *
223 *  Bankswitching (for trivia question roms)
224 *
225 *************************************/
226
227static WRITE8_HANDLER(bankswitch_w)
228{
229   memory_set_bank(space->machine, 1, data);
230}
231
232/*************************************
233 *
234 *  8088 <-> Z80 communication
235 *
236 *************************************/
237
238static UINT8 communication_port[4];
239static UINT8 communication_port_status = 0;
240
241static READ8_HANDLER(link_r)
242{
243   switch(offset)
244   {
245      case 0:
246         communication_port_status &= ~0x01;
247         return communication_port[0];
248      case 1:
249         communication_port_status &= ~0x02;
250         return communication_port[1];
251      case 2:
252         return communication_port_status;
253   }
254   return 0;
255};
256
257static WRITE8_HANDLER(link_w)
258{
259   switch(offset)
260   {
261      case 0:
262         communication_port_status |= 0x08;
263         communication_port[3] = data;
264         break;
265      case 1:
266         communication_port_status |= 0x04;
267         communication_port[2] = data;
268         break;
269   }
270}
271
272static READ8_HANDLER(z80_8088_r)
273{
274   return communication_port_status;
275}
276
277static READ8_HANDLER(p03_r)
278{
279   switch(offset)
280   {
281      case 0:
282         communication_port_status &= ~0x08;
283         return communication_port[3];
284      case 1:
285         communication_port_status &= ~0x04;
286         return communication_port[2];
287   }
288   return 0;
289}
290
291static WRITE8_HANDLER(p03_w)
292{
293   switch(offset)
294   {
295      case 0:
296         communication_port_status |= 0x01;
297         communication_port[0] = data;
298         break;
299      case 1:
300         communication_port_status |= 0x02;
301         communication_port[1] = data;
302         break;
303   }
304}
305
306
307/*************************************
308 *
309 *  Input ports
310 *
311 *************************************/
312
313INPUT_PORTS_START(sms)
314   PORT_START("IN0")
315   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Draw")   /* Draw Button */
316   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Deal")   /* Deal Button */
317   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Bet")   /* Bet Button */
318   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 )   /* Lighted Button 5 */
319   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 )   /* Lighted Button 4 */
320   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 )   /* Lighted Button 3 */
321   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )   /* Lighted Button 2 */
322   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )   /* Lighted Button 1 */
323
324   PORT_START("IN1")
325   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
326   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
327   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* Coin Error reset */
328   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE )   /* Operator Mode */
329   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* Remote Knockoff */
330   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(1)
331   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("Cancel")   /* Cancel Button */
332   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_NAME("Stand")      /* Stand Button */
333
334   PORT_START("IN2")
335   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )   PORT_IMPULSE(1) /* Coin */
336   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
337   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
338   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
339   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
340   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
341   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
342   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
343INPUT_PORTS_END
344
345/*************************************
346 *
347 *  8255 PPIs
348 *
349 *************************************/
350
351static READ8_DEVICE_HANDLER(ppi0_c_r)
352{
353/*
354  PC7 - unused
355  PC6 - unused
356  PC5 - unused
357  PC4 - Battery Charge control (for 8088 ram backup 3.6v Nicad)
358  PC3 - (pulled high externally, input) - unused? possibly for an ABC hopper
359  PC2 - (pulled high externally, input) - unused? possibly for an ABC hopper
360  PC1 - (pulled high externally, input) - "Hopper Count",
361      probably a beam to check the hopper coin out
362  PC0 - "Video BZ" (Video Blanking Zone, is an input)
363      it's probably vblank or hblank, 0 is always returned, games wait for this bit
364      to become 0 before accesing video
365*/
366   return 0;
367}
368
369static WRITE8_DEVICE_HANDLER(ppi0_a_w)
370{
371   //popmessage("Lamps: %d %d %d %d %d %d %d", BIT(data,7), BIT(data,6), BIT(data,5), BIT(data,4), BIT(data,3), BIT(data,2), BIT(data,1) );
372   output_set_lamp_value(0, !BIT(data,7));   /* Display Light 1 */
373   output_set_lamp_value(1, !BIT(data,6)); /* Display Light 2 */
374   output_set_lamp_value(2, !BIT(data,5)); /* Display Light 3 */
375   output_set_lamp_value(3, !BIT(data,4)); /* Display Light 4 */
376   output_set_lamp_value(4, !BIT(data,3)); /* Display Light 5 */
377   output_set_lamp_value(5, !BIT(data,2)); /* Bet Light */
378   output_set_lamp_value(6, !BIT(data,1)); /* Deal Light */
379   output_set_lamp_value(7, !BIT(data,0)); /* Draw Light */
380}
381
382static WRITE8_DEVICE_HANDLER(ppi0_b_w)
383{
384   output_set_lamp_value(8, !BIT(data,7)); /* Stand Light */
385   output_set_lamp_value(9, !BIT(data,6)); /* Cancel Light */
386
387   coin_counter_w(0, BIT(data,1));
388   coin_lockout_w(0, BIT(data,5));
389   coin_lockout_w(1, BIT(data,4));
390}
391
392static const ppi8255_interface ppi8255_intf[2] =
393{
394   {
395      0,         /* Port A read */
396      0,         /* Port B read */
397      ppi0_c_r,   /* Port C read */
398      ppi0_a_w,   /* Port A write */
399      ppi0_b_w,   /* Port B write */
400      0         /* Port C write */
401   },
402   {
403      DEVICE8_PORT("IN0"),   /* Port A read */
404      DEVICE8_PORT("IN1"),   /* Port B read */
405      DEVICE8_PORT("IN2"),   /* Port C read */
406      0,         /* Port A write */
407      0,         /* Port B write */
408      0         /* Port C write */
409   }
410};
411
412/*************************************
413 *
414 *  Video
415 *
416 *************************************/
417
418static bitmap_t *sms_bitmap;
419
420static UINT8 vid_regs[7];
421
422WRITE8_HANDLER(video_w)
423{
424   vid_regs[offset] = data;
425   if ( offset == 5 )
426   {
427      int x,y;
428      int xstart = vid_regs[0] + vid_regs[1]*256;
429      int width = vid_regs[2];
430      int ystart = vid_regs[3];
431      int height = vid_regs[4];
432      int color = vid_regs[5];
433
434      if ( height == 0 )
435         height = 256;
436
437      if ( width == 0 )
438         width = 256;
439
440      for ( y = ystart; y < ystart + height; y++ )
441      {
442         for ( x = xstart; x < xstart + width; x++ )
443         {
444            if ( y < 256 )
445            *BITMAP_ADDR16(sms_bitmap, y, x) = color;
446         }
447      }
448   }
449}
450
451static VIDEO_START( sms )
452{
453   sms_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
454
455   state_save_register_global_array(machine, vid_regs);
456   state_save_register_global_bitmap(machine, sms_bitmap);
457}
458
459static VIDEO_UPDATE( sms )
460{
461   copybitmap(bitmap, sms_bitmap, 0, 0, 0, 0, cliprect);
462   return 0;
463}
464
465static PALETTE_INIT( sms )
466{
467   int i;
468
469   for (i = 0; i < 8; i++ )
470   {
471      palette_set_color(machine, i, MAKE_RGB(pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i)));
472   }
473}
474
475/*************************************
476 *
477 *  Memory maps
478 *
479 *************************************/
480
481static ADDRESS_MAP_START( sms_map, ADDRESS_SPACE_PROGRAM, 8 )
482   AM_RANGE(0x00000, 0x007ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
483   AM_RANGE(0x00800, 0x00803) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
484   AM_RANGE(0x01000, 0x01007) AM_WRITE(video_w)
485   AM_RANGE(0x01800, 0x01803) AM_READWRITE(link_r, link_w)
486   AM_RANGE(0x04000, 0x07fff) AM_ROMBANK(1)
487   AM_RANGE(0x04000, 0x04000) AM_WRITE(bankswitch_w)
488   AM_RANGE(0x08000, 0x0ffff) AM_ROM
489   AM_RANGE(0xf8000, 0xfffff) AM_ROM // mirror for vectors
490ADDRESS_MAP_END
491
492static ADDRESS_MAP_START( sureshot_map, ADDRESS_SPACE_PROGRAM, 8 )
493   AM_RANGE(0x00000, 0x007ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
494   AM_RANGE(0x02000, 0x02007) AM_WRITE(video_w)
495   AM_RANGE(0x03000, 0x03003) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
496   AM_RANGE(0x03800, 0x03803) AM_READWRITE(link_r, link_w)
497   AM_RANGE(0x08000, 0x0ffff) AM_ROM
498   AM_RANGE(0xf8000, 0xfffff) AM_ROM // mirror for vectors
499ADDRESS_MAP_END
500
501static ADDRESS_MAP_START( sub_map, ADDRESS_SPACE_PROGRAM, 8 )
502   AM_RANGE(0x0000, 0x1fff) AM_ROM
503   AM_RANGE(0x2000, 0x27ff) AM_RAM
504   AM_RANGE(0x3100, 0x3103) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)
505   AM_RANGE(0x3381, 0x3381) AM_WRITE(ay8910_write_port_0_w)
506   AM_RANGE(0x3382, 0x3382) AM_WRITE(ay8910_control_port_0_w)
507   AM_RANGE(0x3400, 0x3400) AM_READ(z80_8088_r)
508   AM_RANGE(0x3500, 0x3501) AM_READWRITE(p03_r, p03_w)
509ADDRESS_MAP_END
510
511/*************************************
512 *
513 *  Machine
514 *
515 *************************************/
516
517static MACHINE_START( sms )
518{
519   memory_configure_bank(machine, 1, 0, 16, memory_region(machine, "questions"), 0x4000);
520}
521
522static MACHINE_START( sureshot )
523{
524}
525
526static MACHINE_RESET( sms )
527{
528   communication_port_status = 0;
529
530   state_save_register_global(machine, communication_port_status);
531   state_save_register_global_array(machine, communication_port);
532}
533
534static MACHINE_DRIVER_START( sms )
535   MDRV_CPU_ADD("main", I8088, XTAL_24MHz/8)
536   MDRV_CPU_PROGRAM_MAP(sms_map,0)
537
538   MDRV_CPU_ADD("sound", Z80, XTAL_16MHz/8)
539   MDRV_CPU_PROGRAM_MAP(sub_map, 0)
540
541   MDRV_QUANTUM_TIME(HZ(6000))
542
543   MDRV_MACHINE_START(sms)
544   MDRV_MACHINE_RESET(sms)
545
546   MDRV_PPI8255_ADD( "ppi8255_0", ppi8255_intf[0] )
547   MDRV_PPI8255_ADD( "ppi8255_1", ppi8255_intf[1] )
548
549   MDRV_NVRAM_HANDLER(generic_0fill)
550
551   /* video hardware */
552   MDRV_SCREEN_ADD("main", RASTER)
553   MDRV_SCREEN_REFRESH_RATE(60)
554   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
555   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
556   MDRV_SCREEN_SIZE(0x1b0, 0x100)
557   MDRV_SCREEN_VISIBLE_AREA(0, 0x1af, 0, 0xff)
558
559   MDRV_PALETTE_LENGTH(8)
560
561   MDRV_PALETTE_INIT(sms)
562   MDRV_VIDEO_START(sms)
563   MDRV_VIDEO_UPDATE(sms)
564
565   /* sound hardware */
566   MDRV_SPEAKER_STANDARD_MONO("mono")
567
568   MDRV_SOUND_ADD("ay", AY8910, XTAL_16MHz/8)
569   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
570MACHINE_DRIVER_END
571
572static MACHINE_DRIVER_START(sureshot)
573   MDRV_IMPORT_FROM(sms)
574
575   MDRV_CPU_MODIFY("main")
576   MDRV_CPU_PROGRAM_MAP(sureshot_map,0)
577
578   MDRV_MACHINE_START(sureshot)
579MACHINE_DRIVER_END
580
581/*************************************
582 *
583 *  ROM definitions
584 *
585 *************************************/
586
587/*
588Triva looking board
589Silk screened on front...
590    P/N 1001
591Etched in copper on font...
592    COMPONENT SIDE REV 02
593Etched in copper on back...
594    COPYRIGHT SMS 1983 S/N      MADE IN USA
595                mfg corp
596
597Serial number A4675 etched in board
598
599Large chips
600    P8088
601    AY-3-8910
602    CDM6116 x2
603    P8255A-5
604    P8254
605    D8255AC-5
606    D780C-1
607
60816 Mhz crystal by D780C (U21)
60924 Mhz crystal by P8088 (u53)
610
611Open sockets at U50 (40 pin), U15 (24 pin), U2 (40 pin), U25 (24 pin)
612
613Bottom Board
614.U17 - 27128
615.U16 - 27128
616.U26 - 2732 - stickered #26 073184
617.U38 - DMPAL10L8NC - 3 blue dots on it - saved in jedec format
618.U39 - DMPAL10L8NC - 3 green dots on it - saved in jedec format
619.U40 - DMPAL10L8NC - 1 pink dot on it - saved in jedec format
620.U110 - DMPAL10L8NC - 2 pink dots on it - saved in jedec format
621.U52 - DMPAL10L8NC - not labeled - checksum was 0
622.U32 - DMPAL10L8NC - stickered trivia U32 - couldn't read "device overcurrent"
623.U58 - DMPAL10H8NC - 3 brown dots on it - saved in jedec format
624.U80 - DMPAL10H8NC - 2 blue dots on it - saved in jedec format
625.U130 - DMPAL10H8NC - 3 pink dots on it - saved in jedec format
626.U129 - DMPAL10H8NC - pink-green-pink dots on it - saved in jedec format
627.U128 - DMPAL10H8NC - blue-brown-blue dots on it - saved in jedec format
628.U145 - DMPAL14H4NC - brown dot on it - saved in jedec format
629.U144 - DMPAL14H4NC - brown dot on it - saved in jedec format
630.U143 - DMPAL14H4NC - brown dot on it - saved in jedec format
631.U142 - DMPAL14H4NC - brown dot on it - saved in jedec format
632.U141 - DMPAL14H4NC - brown dot on it - saved in jedec format
633.U140 - DMPAL14H4NC - brown dot on it - saved in jedec format
634    U.145-U.140 had the same checksum
635
636.U94 - DMPAL14H4NC - 2 green dots on it - saved in jedec format
637.U109 - DMPAL14H4NC - 2 brown dots on it - saved in jedec format
638
639Daughter Board
640Etched in copper on top...
641    SMS MFG M?I 2685        ? = a cage looking symbol
642
643Read starting at top row, closest to connector to main board
644.D0 - DMPAL10L8NC - 1 orange dot on it - saved in jedec format
645.D1 - 27128 - couldn't read sticker -
646.D2 - 27128 - couldn't read sticker -
647.D3 - 27128 - couldn't read sticker -
648.D4 - 27128 - stickered 4 MOVIES .1 ?2485   ? = can't read
649.D5 - 27128 - stickered 3 ANYTHING .4 042485
650.D6 - 27128 - stickered 2 ANYTHING .3 042485
651.D7 - 27128 - stickered 1 ANYTHING .2 042485
652.D8 - 27128 - stickered 0 ANYTHING .1 042485
653
6542nd row - left to right
655.D9 - 27128 - stickered 12 MUSIC .1 042485
656.D10 - 27128 - stickered 13 MUSIC .1 042485
657.D11 - 27128 - stickered 14 MUSIC .1 042485
658.D12 - 27128 - stickered 15 MUSIC .1 042485
659
6603rd row - left to right
661.D13 - 27128 - stickered 11 SPORTS .4 042485
662.D14 - 27128 - stickered 10 SPORTS .3 042485
663.D15 - 27128 - stickered 9 SPORTS .2 042485
664.D16 - 27128 - stickered 8 SPORTS .1 042485
665.D17 - DMPAL10L8NC - 1 white dot on it - saved in jedec format
666
667
668ROM text showed...
669    COPYRIGHT 1984 SMS MFG CORP
670    TRIVIA HANGUP
671    SMART ALECS
672*/
673
674ROM_START( trvhang )
675   ROM_REGION( 0x100000, "main", 0 )
676   ROM_LOAD( "sms.17",       0xf8000, 0x04000, CRC(af6ef980) SHA1(f0f98d1f91de718a63b87c5f1c6ee3bd854d1c1b) )
677   ROM_LOAD( "sms.16",       0xfc000, 0x04000, CRC(b827d883) SHA1(68d6c2127ef9e537471c414ca7baa89c63997bbb) )
678   ROM_COPY( "main",    0xf8000, 0x08000, 0x8000 )
679
680   ROM_REGION( 0x10000, "sound", 0 )
681   ROM_LOAD( "sms.26",       0x0000, 0x1000, CRC(e04bb922) SHA1(1df90720f11a5b736273f43272d7727b3020f848) )
682   ROM_RELOAD(               0x1000, 0x1000 )
683
684   ROM_REGION( 0x40000, "questions", 0 )
685   // anything
686   ROM_LOAD( "0anything1.d8", 0x00000, 0x4000, CRC(80096807) SHA1(a38b1b13365577c0c588b8e196ee1a6c774ce3a3) )
687   ROM_LOAD( "1anything2.d7", 0x04000, 0x4000, CRC(d09946b6) SHA1(b5827945ce380f09ee758c4296f06f00ef3cbd0a) )
688   ROM_LOAD( "2anything3.d6", 0x08000, 0x4000, CRC(5b12fd09) SHA1(15804480e65bfb3207d24a1679bb78d1ad491d70) )
689   ROM_LOAD( "3anything4.d5", 0x0c000, 0x4000, CRC(f1a37ed7) SHA1(687a610319b21091cbc53232b47eb99dabe12f02) )
690   // movies
691   ROM_LOAD( "4movies1.d4",   0x10000, 0x4000, CRC(76993bd1) SHA1(b9a97ab7c6d35f5fdda04342e0b3773618deedef) )
692   ROM_LOAD( "5movies1.d3",   0x14000, 0x4000, CRC(8c5f62ef) SHA1(34ac235358a71620a6619dbb16255c363f34df53) )
693   ROM_LOAD( "6movies1.d2",   0x18000, 0x4000, CRC(13c9fe08) SHA1(6b7d055621ce578446d320f98f7a4cd095e756b0) )
694   ROM_LOAD( "7movies1.d1",   0x1c000, 0x4000, CRC(04f627c0) SHA1(c656b66c60059a1b068c4a7262f07f4c136c34c1) )
695   // sports
696   ROM_LOAD( "8sports1.d16",  0x20000, 0x4000, CRC(b700e7e6) SHA1(42b2c12c6af5f15d909e15ee3e7ca2e13e0142c2) )
697   ROM_LOAD( "9sports2.d15",  0x24000, 0x4000, CRC(bec225fe) SHA1(13252894eca30e06354885a21ecad43965cfd3ef) )
698   ROM_LOAD( "10sports3.d14", 0x28000, 0x4000, CRC(3bfe9b52) SHA1(0cdd9ec6ed784fab9272d50821994be5b0fd0532) )
699   ROM_LOAD( "11sports4.d13", 0x2c000, 0x4000, CRC(9bb8dbad) SHA1(0dd9ed23e6794a86a12906b326e984a2d58cc4c6) )
700   // music
701   ROM_LOAD( "12music1.d9",   0x30000, 0x4000, CRC(c1691ec9) SHA1(95725fa315944c0786e2a32d483703173eb2e730) )
702   ROM_LOAD( "13music1.d10",  0x34000, 0x4000, CRC(df0da39f) SHA1(29103dca8b0c1967791e8ddd722153874e16bbda) )
703   ROM_LOAD( "14music1.d11",  0x38000, 0x4000, CRC(114b4aa6) SHA1(2621d1042b0774d60be88cc8d62613aa07c12552) )
704   ROM_LOAD( "15music1.d12",  0x3c000, 0x4000, CRC(59a40e4f) SHA1(e726ce624c76ee527edc51c1e5757b7d433dcf8c) )
705
706
707   ROM_REGION( 0x1000, "plds", 0 )
708   ROM_LOAD( "dmpal10l8nc.d17.bin", 0x000000, 0x0001f3, CRC(e9eb78e7) SHA1(688e854e82c230d367c211f611e9a8298ab64399) )
709   ROM_LOAD( "dmpal10l8nc.38.bin",  0x000000, 0x0001f3, CRC(be17ebde) SHA1(22c05eeafeadc8f55b55951c2060fb4873146cba) )
710   ROM_LOAD( "dmpal10l8nc.39.bin",  0x000000, 0x0001f3, CRC(3299e803) SHA1(12f361d27497f6347ee26838fa9f675f6aac12c2) )
711   ROM_LOAD( "dmpal10l8nc.40.bin",  0x000000, 0x0001f3, CRC(22881f1c) SHA1(646fdc4e4a423e1432b448140f2d92dd2304ff71) )
712   ROM_LOAD( "dmpal10l8nc.52.bin",  0x000000, 0x0001f3, CRC(2e43ba5f) SHA1(8b87ee8ce21f5241260f2d0de4878096d8ecb5f5) )
713   ROM_LOAD( "dmpal10h8nc.58.bin",  0x000000, 0x0001f3, CRC(020b5108) SHA1(f3221fbce40a9d6fdc2eece606e4eded3faf5f02) )
714   ROM_LOAD( "dmpal10h8nc.80.bin",  0x000000, 0x0001f3, CRC(66e21ee5) SHA1(31c29a250f50dcdf531810e59068adfea4d2d9a3) )
715   ROM_LOAD( "dmpal14h4nc.94.bin",  0x000000, 0x000283, CRC(c5fda3df) SHA1(4fdd597d25ed893cb005165b68e48567fbd2b1ce) )
716   ROM_LOAD( "dmpal14h4nc.109.bin", 0x000000, 0x000283, CRC(15d05aaa) SHA1(57500b4825a1da943d79ee7df657efed56c4320e) )
717   ROM_LOAD( "dmpal10l8nc.110.bin", 0x000000, 0x0001f3, CRC(6263b1e1) SHA1(6c8d92bcbbc2d196b5ac7765888eaf171671d651) )
718   ROM_LOAD( "dmpal10h8nc.128.bin", 0x000000, 0x0001f3, CRC(fbaea5b0) SHA1(85a757485c26304d4ce718fd954aa4736cdc4752) )
719   ROM_LOAD( "dmpal10h8nc.129.bin", 0x000000, 0x0001f3, CRC(4722fb3b) SHA1(adc0a3c0721acaa5b447c7aee771703caab80dd9) )
720   ROM_LOAD( "dmpal10h8nc.130.bin", 0x000000, 0x0001f3, CRC(d3f0a6a5) SHA1(5e08b6104dfd3e463031b2b12619589a8f7b453c) )
721   ROM_LOAD( "dmpal14h4nc.140.bin", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) )
722   ROM_LOAD( "dmpal14h4nc.141.bin", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) )
723   ROM_LOAD( "dmpal14h4nc.142.bin", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) )
724   ROM_LOAD( "dmpal14h4nc.143.bin", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) )
725   ROM_LOAD( "dmpal14h4nc.144.bin", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) )
726   ROM_LOAD( "dmpal14h4nc.145.bin", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) )
727   ROM_LOAD( "dmpal10l8nc.d0.bin",  0x000000, 0x0001f3, CRC(b1c221a7) SHA1(f63a022199a2d7b52c4c4827b170d49aae85e4e3) )
728ROM_END
729
730/*
731Etched in copper on back    COPYRIGHT SMS 1983
732                    mfg corp. S/N   A-2043
733                            A-2043 was hand etched
734
73516MHz Crystal
73624MHz Crystal
737D780C
738D8255AC-5
739P8255A-5
740P8088
741AY-3-8910
7426116    x2
743P8254
744
745Empty 40 pin socket at U2 and U50
746Empty 24 pin socket at U25
747Empty 28 pin socket at U18
748
749
750
751.u16    28128   stickered   U-16
752                TRIVIA -2
753                011586
754
755.u17    28128   stickered   U-16
756                TRIVIA -2
757                011586
758
759.u19    28128   stickered   U-16
760                TRIVIA DLXE
761                021281
762
763.u26    2732    stickered   #26
764                073184
765
766
767the pal's had colored dots on them
768saved in JEDEC format
769.32 dmpal10l8nc red red blue
770.52 dmpal10l8nc red red white
771.38 dmpal10l8nc blue    blue    blue
772.39 dmpal10l8nc green   green   green
773.40 dmpal10l8nc pink
774.110    dmpal10l8nc pink    pink
775.58 dmpal10h8nc brown   brown   brown
776.80 dmpal10h8nc blue    blue
777.128    dmpal10h8nc blue    brown   blue
778.129    dmpal10h8nc pink    green   pink
779.130    dmpal10h8nc pink    scratched off
780.94 dmpal14h4nc green   green
781.109    dmpal14h4nc brown   brown
782.140    dmpal14h4nc brown
783.141    dmpal14h4nc brown
784.142    dmpal14h4nc brown
785.143    dmpal14h4nc brown
786.144    dmpal14h4nc brown
787.145    dmpal14h4nc brown
788*/
789
790ROM_START( trvhanga )
791   ROM_REGION( 0x100000, "main", 0 )
792   ROM_LOAD( "sms2.u17",   0xf8000, 0x04000, CRC(e5c880a1) SHA1(da777c4e126da2f03a663f8c8f565bda8520c883) )
793   ROM_LOAD( "sms2.16",    0xfc000, 0x04000, CRC(85484aee) SHA1(7c282bd208bd644d5d57ac399942c95211e87bf4) )
794   ROM_COPY( "main",    0xf8000, 0x08000, 0x8000 )
795
796   ROM_REGION( 0x10000, "sound", 0 )
797   ROM_LOAD( "sms2.26",       0x0000, 0x1000, CRC(e04bb922) SHA1(1df90720f11a5b736273f43272d7727b3020f848) )
798   ROM_RELOAD(               0x1000, 0x1000 )
799
800   ROM_REGION( 0x4000, "user", 0 )
801   ROM_LOAD( "sms2.u19",    0x00000, 0x04000, CRC(5e10059b) SHA1(f0eb490d41009ffe1c80216f699557480110954b) ) // unknown rom (leftover from conversion?)
802
803   ROM_REGION( 0x40000, "questions", 0 )
804   // sex
805   ROM_LOAD( "0sex1.d8", 0x00000, 0x4000, NO_DUMP )
806   ROM_LOAD( "1sex2.d7", 0x04000, 0x4000, NO_DUMP )
807   ROM_LOAD( "2sex3.d6", 0x08000, 0x4000, NO_DUMP )
808   ROM_LOAD( "3sex4.d5", 0x0c000, 0x4000, NO_DUMP )
809   // movies
810   ROM_LOAD( "4movies1.d4",   0x10000, 0x4000, NO_DUMP )
811   ROM_LOAD( "5movies1.d3",   0x14000, 0x4000, NO_DUMP )
812   ROM_LOAD( "6movies1.d2",   0x18000, 0x4000, NO_DUMP )
813   ROM_LOAD( "7movies1.d1",   0x1c000, 0x4000, NO_DUMP )
814   // sports
815   ROM_LOAD( "8sports1.d16",  0x20000, 0x4000, NO_DUMP )
816   ROM_LOAD( "9sports2.d15",  0x24000, 0x4000, NO_DUMP )
817   ROM_LOAD( "10sports3.d14", 0x28000, 0x4000, NO_DUMP )
818   ROM_LOAD( "11sports4.d13", 0x2c000, 0x4000, NO_DUMP )
819   // music
820   ROM_LOAD( "12music1.d9",   0x30000, 0x4000, NO_DUMP )
821   ROM_LOAD( "13music1.d10",  0x34000, 0x4000, NO_DUMP )
822   ROM_LOAD( "14music1.d11",  0x38000, 0x4000, NO_DUMP )
823   ROM_LOAD( "15music1.d12",  0x3c000, 0x4000, NO_DUMP )
824
825   ROM_REGION( 0x1000, "plds", 0 )
826   ROM_LOAD( "dmpal10l8nc.32.bin",  0x000000, 0x00002c, CRC(558ca47e) SHA1(4612e5dd9832bcbf6d7b3bce803f92ea2ee03b98) )
827   ROM_LOAD( "dmpal10l8nc.38.bin",  0x000000, 0x00002c, CRC(84c39631) SHA1(8aa28be5418dd119883a9d400f23927e0cf8d7b4) )
828   ROM_LOAD( "dmpal10l8nc.39.bin",  0x000000, 0x00002c, CRC(ab950780) SHA1(73e8eb8050ca337e58b34513a9cf522e4fb43b5d) )
829   ROM_LOAD( "dmpal10l8nc.40.bin",  0x000000, 0x00002c, CRC(a2de5f30) SHA1(ea2293f6b979aa16ccf1c8d6c88ea484ef45ea6b) )
830   ROM_LOAD( "dmpal10l8nc.52.bin",  0x000000, 0x00002c, CRC(5d09ff76) SHA1(0b977db9dc465a36975b935d3585f404b86de293) )
831   ROM_LOAD( "dmpal10h8nc.58.bin",  0x000000, 0x00002c, CRC(3df46d79) SHA1(606040b69908635ab5166193c53557ffa524c9d3) )
832   ROM_LOAD( "dmpal10h8nc.80.bin",  0x000000, 0x00002c, CRC(7bd4fbf5) SHA1(a2951bcf6af2a6d0211070c2dc49b8c1e9b78b9b) )
833   ROM_LOAD( "dmpal14h4nc.94.bin",  0x000000, 0x00003c, CRC(43a4e3f1) SHA1(afc530cc52ac04abce33b7c61e256da1cb30eb23) )
834   ROM_LOAD( "dmpal14h4nc.109.bin", 0x000000, 0x00003c, CRC(98542c78) SHA1(282d06701da1130d9ca0fcbd81ea89f1462693e2) )
835   ROM_LOAD( "dmpal10l8nc.110.bin", 0x000000, 0x00002c, CRC(f59c1868) SHA1(cc75ce71057360e62ea3ea929f241dc6105f1362) )
836   ROM_LOAD( "dmpal10h8nc.128.bin", 0x000000, 0x00002c, CRC(083cd773) SHA1(70a49a53d549b90c7a036f4afaf92759bf8e20c9) )
837   ROM_LOAD( "dmpal10h8nc.129.bin", 0x000000, 0x00002c, CRC(c5841a1a) SHA1(f2929321b041114f771e9fba4cbe2fb36c26a053) )
838   ROM_LOAD( "dmpal10h8nc.130.bin", 0x000000, 0x00002c, CRC(a4051372) SHA1(23b200f3950e583cc40b3cc82d62e274294e5593) )
839   ROM_LOAD( "dmpal14h4nc.140.bin", 0x000000, 0x00003c, CRC(c921d183) SHA1(db7be592058456e83a8603cf839f5664ea0a0f76) )
840   ROM_LOAD( "dmpal14h4nc.141.bin", 0x000000, 0x00003c, CRC(c921d183) SHA1(db7be592058456e83a8603cf839f5664ea0a0f76) )
841   ROM_LOAD( "dmpal14h4nc.142.bin", 0x000000, 0x00003c, CRC(c921d183) SHA1(db7be592058456e83a8603cf839f5664ea0a0f76) )
842   ROM_LOAD( "dmpal14h4nc.143.bin", 0x000000, 0x00003c, CRC(c921d183) SHA1(db7be592058456e83a8603cf839f5664ea0a0f76) )
843   ROM_LOAD( "dmpal14h4nc.144.bin", 0x000000, 0x00003c, CRC(c921d183) SHA1(db7be592058456e83a8603cf839f5664ea0a0f76) )
844   ROM_LOAD( "dmpal14h4nc.145.bin", 0x000000, 0x00003c, CRC(ab2af8de) SHA1(775495d47435c23eecf3defba15f5ca890836354) )
845ROM_END
846
847ROM_START( sureshot )
848   ROM_REGION( 0x100000, "main", 0 )
849   ROM_LOAD( "u-19 hldly s.shot 020687.u19.a12.bin", 0xf8000, 0x02000, CRC(028bdb61) SHA1(e39c27cc6dec12de5a5e60d544f35448e49baee1) )
850   ROM_LOAD( "u-18 hldly s.shot 020687.u18.a11.bin", 0xfa000, 0x02000, CRC(5aa083f1) SHA1(3eed1a7421e7abcc41a1bddf655b1e777d843898) )
851   ROM_LOAD( "u-17 hldly s.shot 020687.u17.a10.bin", 0xfc000, 0x02000, CRC(a37432d6) SHA1(398462642ab0b34efdb6ff4756758057b9833e10) )
852   ROM_LOAD( "u-16 hldly s.shot 020687.u16.a9.bin",  0xfe000, 0x02000, CRC(d7f756d5) SHA1(5c7f62b02b4d4836881c3da0604448c34ede674b) )
853   ROM_COPY( "main",    0xf8000, 0x08000, 0x8000 )
854
855   ROM_REGION( 0x10000, "sound", 0 )
856   ROM_LOAD( "26 404 073184.u26.b5.bin", 0x0000, 0x1000, CRC(e04bb922) SHA1(1df90720f11a5b736273f43272d7727b3020f848) )
857   ROM_RELOAD(               0x1000, 0x1000 )
858ROM_END
859
860GAME( 1984, trvhang,  0, sms,      sms, 0, ROT0, "SMS MFG CORP", "Trivia Hangup (Question Set 1)", GAME_SUPPORTS_SAVE ) /* Version Trivia-1-050185 */
861GAME( 1984, trvhanga, 0, sms,      sms, 0, ROT0, "SMS MFG CORP", "Trivia Hangup (Question Set 2)", GAME_NOT_WORKING ) /* Version Trivia-2-011586 */
862GAME( 1985, sureshot, 0, sureshot, sms, 0, ROT0, "SMS MFG CORP", "Sure Shot", GAME_SUPPORTS_SAVE )
src/mame/drivers/madalien.c
r4135r4136
8383static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
8484   AM_RANGE(0x0000, 0x03ff) AM_RAM
8585
86   AM_RANGE(0x6000, 0x63ff) AM_RAM AM_BASE(&madalien_videoram)
86   AM_RANGE(0x6000, 0x63ff) AM_RAM_WRITE(madalien_videoram_w) AM_BASE(&madalien_videoram)
8787   AM_RANGE(0x6400, 0x67ff) AM_RAM
88   AM_RANGE(0x6800, 0x7fff) AM_RAM AM_BASE(&madalien_charram)
88   AM_RANGE(0x6800, 0x7fff) AM_RAM_WRITE(madalien_charram_w) AM_BASE(&madalien_charram)
8989
9090   AM_RANGE(0x8000, 0x8000) AM_MIRROR(0x0ff0) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
9191   AM_RANGE(0x8001, 0x8001) AM_MIRROR(0x0ff0) AM_DEVREADWRITE(MC6845, "crtc", mc6845_register_r, mc6845_register_w)
src/mame/drivers/aeroboto.c
r4135r4136
229229   NULL
230230};
231231
232static MACHINE_START( formatz )
233{
234    state_save_register_global(machine, disable_irq);
235}
236
232237static MACHINE_DRIVER_START( formatz )
233238
234239   /* basic machine hardware */
r4135r4136
240245   MDRV_CPU_PROGRAM_MAP(sound_map,0)
241246   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
242247
248    MDRV_MACHINE_START(formatz)
249
243250   /* video hardware */
244251   MDRV_SCREEN_ADD("main", RASTER)
245252   MDRV_SCREEN_REFRESH_RATE(60)
r4135r4136
329336
330337
331338
332GAME( 1984, formatz,  0,       formatz, formatz, 0, ROT0, "Jaleco", "Formation Z", GAME_IMPERFECT_GRAPHICS )
333GAME( 1984, aeroboto, formatz, formatz, formatz, 0, ROT0, "[Jaleco] (Williams license)", "Aeroboto", GAME_IMPERFECT_GRAPHICS )
339GAME( 1984, formatz,  0,       formatz, formatz, 0, ROT0, "Jaleco", "Formation Z", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS )
340GAME( 1984, aeroboto, formatz, formatz, formatz, 0, ROT0, "[Jaleco] (Williams license)", "Aeroboto", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/mastboy.c
r4135r4136
460460
461461static VIDEO_START(mastboy)
462462{
463   gfx_element_set_source(machine->gfx[0], mastboy_vram);
463464}
464465
465466static VIDEO_UPDATE(mastboy)
r4135r4136
563564         mastboy_vram[offs] = data^0xff;
564565
565566         /* Decode the new tile */
566         decodechar(space->machine->gfx[0], offs/32, mastboy_vram);
567         gfx_element_mark_dirty(space->machine->gfx[0], offs/32);
567568      }
568569   }
569570   else
src/mame/drivers/zr107.c
r4135r4136
199199
200200// defined in drivers/nwk-tr.c
201201int K001604_vh_start(running_machine *machine, int chip);
202void K001604_tile_update(running_machine *machine, int chip);
203202void K001604_draw_front_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
204203void K001604_draw_back_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect);
205204READ32_HANDLER(K001604_tile_r);
r4135r4136
224223{
225224   bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
226225
227   K001604_tile_update(screen->machine, 0);
228226   K001005_draw(bitmap, cliprect);
229227
230228   K001604_draw_front_layer(0, bitmap, cliprect);
r4135r4136
505503   AM_RANGE(0x780c0000, 0x780c0007) AM_MIRROR(0x80000000) AM_READWRITE(cgboard_dsp_comm_r_ppc, cgboard_dsp_comm_w_ppc)
506504   AM_RANGE(0x7e000000, 0x7e003fff) AM_MIRROR(0x80000000) AM_READWRITE8(sysreg_r, sysreg_w, 0xffffffff)
507505   AM_RANGE(0x7e008000, 0x7e009fff) AM_MIRROR(0x80000000) AM_READWRITE8(K056230_r, K056230_w, 0xffffffff)            /* LANC registers */
508   AM_RANGE(0x7e00a000, 0x7e00bfff) AM_MIRROR(0x80000000) AM_READWRITE(lanc_ram_r, lanc_ram_w)      /* LANC Buffer RAM (27E) */
506   AM_RANGE(0x7e00a000, 0x7e00bfff) AM_MIRROR(0x80000000) AM_READWRITE(lanc_ram_r, lanc_ram_w)    AM_BASE(&lanc_ram)   /* LANC Buffer RAM (27E) */
509507   AM_RANGE(0x7e00c000, 0x7e00c007) AM_MIRROR(0x80000000) AM_WRITE(K056800_host_w)
510508   AM_RANGE(0x7e00c008, 0x7e00c00f) AM_MIRROR(0x80000000) AM_READ(K056800_host_r)
511509   AM_RANGE(0x7f000000, 0x7f3fffff) AM_MIRROR(0x80000000) AM_ROM AM_REGION("user2", 0)
src/mame/drivers/amspdwy.c
r4135r4136
4343
4444    Or last value when wheel delta = 0
4545*/
46#define AMSPDWY_WHEEL_R( _n_ ) \
47static READ8_HANDLER( amspdwy_wheel_##_n_##_r ) \
48{ \
49   static UINT8 wheel_old, ret; \
50   static const char *const portnames[] = { "WHEEL1", "WHEEL2", "AN1", "AN2" };\
51   UINT8 wheel; \
52   wheel = input_port_read(space->machine, portnames[2 + _n_]); \
53   if (wheel != wheel_old) \
54   { \
55      wheel = (wheel & 0x7fff) - (wheel & 0x8000); \
56      if (wheel > wheel_old)   ret = ((+wheel) & 0xf) | 0x00; \
57      else               ret = ((-wheel) & 0xf) | 0x10; \
58      wheel_old = wheel; \
59   } \
60   return ret | input_port_read(space->machine, portnames[_n_]); \
46
47static UINT8 wheel_old[2];
48static UINT8 wheel_return[2];
49
50static UINT8 amspdwy_wheel_r(running_machine *machine, int index)
51{
52    static const char *const portnames[] = { "WHEEL1", "WHEEL2", "AN1", "AN2" };
53    UINT8 wheel;
54    wheel = input_port_read(machine, portnames[2 + index]);
55    if (wheel != wheel_old[index])
56    {
57        wheel = (wheel & 0x7fff) - (wheel & 0x8000);
58        if (wheel > wheel_old[index])  wheel_return[index] = ((+wheel) & 0xf) | 0x00;
59        else                           wheel_return[index] = ((-wheel) & 0xf) | 0x10;
60        wheel_old[index] = wheel;
61    }
62    return wheel_return[index] | input_port_read(machine, portnames[index]);
6163}
62AMSPDWY_WHEEL_R( 0 )
63AMSPDWY_WHEEL_R( 1 )
6464
65static READ8_HANDLER( amspdwy_wheel_0_r )
66{
67    return amspdwy_wheel_r(space->machine, 0);
68}
6569
70static READ8_HANDLER( amspdwy_wheel_1_r )
71{
72    return amspdwy_wheel_r(space->machine, 0);
73}
74
6675static READ8_HANDLER( amspdwy_sound_r )
6776{
6877   return (ym2151_status_port_0_r(space,0) & ~ 0x30) | input_port_read(space->machine, "IN0");
r4135r4136
250259   irq_handler
251260};
252261
262static MACHINE_START( amspdwy )
263{
264    wheel_old[0]    = wheel_old[1]    = 0;
265    wheel_return[0] = wheel_return[1] = 0;
266    state_save_register_global_array(machine, wheel_old);
267    state_save_register_global_array(machine, wheel_return);
268}
253269
254270static MACHINE_DRIVER_START( amspdwy )
255271
r4135r4136
262278   MDRV_CPU_ADD("audio", Z80,3000000)   /* Can't be disabled: the YM2151 timers must work */
263279   MDRV_CPU_PROGRAM_MAP(amspdwy_sound_map,0)
264280
281    MDRV_MACHINE_START(amspdwy)
282
265283   /* video hardware */
266284   MDRV_SCREEN_ADD("main", RASTER)
267285   MDRV_SCREEN_REFRESH_RATE(60)
r4135r4136
376394
377395/* (C) 1987 ETI 8402 MAGNOLIA ST. #C SANTEE, CA 92071 */
378396
379GAME( 1987, amspdwy,  0,       amspdwy, amspdwy,  0, ROT0, "Enerdyne Technologies, Inc.", "American Speedway (set 1)", 0 )
380GAME( 1987, amspdwya, amspdwy, amspdwy, amspdwya, 0, ROT0, "Enerdyne Technologies, Inc.", "American Speedway (set 2)", 0 )
397GAME( 1987, amspdwy,  0,       amspdwy, amspdwy,  0, ROT0, "Enerdyne Technologies, Inc.", "American Speedway (set 1)", GAME_SUPPORTS_SAVE )
398GAME( 1987, amspdwya, amspdwy, amspdwy, amspdwya, 0, ROT0, "Enerdyne Technologies, Inc.", "American Speedway (set 2)", GAME_SUPPORTS_SAVE )
src/mame/drivers/igs_ncs.c
r0r4136
1/* New Champion Skill by IGS
2 -- the dump MAY be incomplete, there were 3 empty positions on the PCB near
3    the gfx roms
4
5Chips of Note
6
7IGS 003C (near chip with TEST OK E0069281 label)
8IGS 002
9IGA 001A
10
11
12'file'
13KC8255A
149941
15(near CPU roms)
16
17UM3567 9946
18
195x 8 switch dips
20
21Clocks
223.579545Mhz (near sound)
2312Mhz
24
25
26--- what is the CPU, it looks like either Z80 or Z180 based
27 -- CPU rom is lightly encrypted (usual IGS style, some xors)
28
29*/
30
31#include "driver.h"
32#include "cpu/z180/z180.h"
33#include "sound/2413intf.h"
34#include "deprecat.h"
35
36static UINT8*ncs_video;
37static UINT8*ncs_video2;
38
39VIDEO_START(igs_ncs)
40{
41
42}
43
44VIDEO_UPDATE(igs_ncs)
45{
46   const gfx_element *gfx = screen->machine->gfx[0];
47   int count = 0;
48
49   int y,x;
50
51
52   for (y=0;y<32;y++)
53   {
54      for (x=0;x<64;x++)
55      {
56         int tile = ncs_video[count] | (ncs_video[count+0x800]<<8);
57         int colour = (tile >> 12) & 0x7;
58
59         drawgfx(bitmap,gfx,tile&0x1fff,colour+1,0,0,x*8,y*8,cliprect,TRANSPARENCY_NONE,0);
60
61         count++;
62      }
63   }
64
65
66   return 0;
67}
68
69static const gfx_layout layout_8x8x6 =
70{
71   8, 8,
72   RGN_FRAC(1, 3),
73   6,
74   { RGN_FRAC(0,3)+8,RGN_FRAC(0,3)+0,
75     RGN_FRAC(1,3)+8,RGN_FRAC(1,3)+0,
76     RGN_FRAC(2,3)+8,RGN_FRAC(2,3)+0 },
77   { STEP8(0,1) },
78   { STEP8(0,2*8) },
79   8*8*2
80};
81
82static GFXDECODE_START( igs_ncs )
83   GFXDECODE_ENTRY( "gfx1", 0, layout_8x8x6,  0, 16 )
84GFXDECODE_END
85
86static INPUT_PORTS_START( igs_ncs )
87INPUT_PORTS_END
88
89static ADDRESS_MAP_START( igs_ncs_map, ADDRESS_SPACE_PROGRAM, 8 )
90   AM_RANGE( 0x00000, 0x0efff ) AM_ROM
91   AM_RANGE( 0x0f000, 0x0ffff ) AM_RAM
92ADDRESS_MAP_END
93
94static READ8_HANDLER( ncs_random_r )
95{
96   return 0xff;// mame_rand(space->machine);
97}
98
99static ADDRESS_MAP_START( igs_ncs_portmap, ADDRESS_SPACE_IO, 8 )
100   AM_RANGE( 0x2000, 0x23ff ) AM_RAM_WRITE( paletteram_xBBBBBGGGGGRRRRR_split1_w ) AM_BASE( &paletteram )
101   AM_RANGE( 0x2800, 0x2cff ) AM_RAM_WRITE( paletteram_xBBBBBGGGGGRRRRR_split2_w ) AM_BASE( &paletteram_2 )
102
103
104   AM_RANGE( 0x4000, 0x4000 ) AM_READ(ncs_random_r)
105   AM_RANGE( 0x4001, 0x4001 ) AM_READ(ncs_random_r)
106   AM_RANGE( 0x4002, 0x4002 ) AM_READ(ncs_random_r)
107   AM_RANGE( 0x4003, 0x4003 ) AM_READ(ncs_random_r)
108   AM_RANGE( 0x4004, 0x4004 ) AM_READ(ncs_random_r)
109
110
111   AM_RANGE( 0x5081, 0x5081 ) AM_READ(ncs_random_r)
112   AM_RANGE( 0x5082, 0x5082 ) AM_READ(ncs_random_r)
113
114   AM_RANGE( 0x5082, 0x5091 ) AM_READ(ncs_random_r)
115
116   AM_RANGE( 0x50a0, 0x50a0 ) AM_READ(ncs_random_r)
117   AM_RANGE( 0x50c0, 0x50c0 ) AM_READ(ncs_random_r)
118
119   AM_RANGE( 0x6000, 0x6fff ) AM_RAM AM_BASE(&ncs_video2) // 'reels' layer -- we're missing the gfx
120
121   AM_RANGE( 0x7000, 0x7fff ) AM_RAM AM_BASE(&ncs_video)
122
123
124   AM_RANGE( 0x8000, 0xffff ) AM_ROM AM_REGION("data", 0)
125
126ADDRESS_MAP_END
127
128static INTERRUPT_GEN( igs_ncs_interrupt )
129{
130   // wrong!!
131   if (cpu_getiloops(device)&1)
132      cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
133   else
134      cpu_set_input_line(device, INPUT_LINE_IRQ0, HOLD_LINE);
135}
136
137
138static MACHINE_DRIVER_START( igs_ncs )
139   /* basic machine hardware */
140   MDRV_CPU_ADD("main", Z180, XTAL_12MHz / 2)   /* CPU is..?? 6 MHz? */
141   MDRV_CPU_PROGRAM_MAP(igs_ncs_map,0)
142   MDRV_CPU_IO_MAP(igs_ncs_portmap,0)
143   MDRV_CPU_VBLANK_INT_HACK(igs_ncs_interrupt,2)
144//  MDRV_CPU_VBLANK_INT("main",igs_ncs_interrupt)
145
146   /* video hardware */
147   MDRV_SCREEN_ADD("main", RASTER)
148   MDRV_SCREEN_REFRESH_RATE(60)
149   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
150   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
151   MDRV_SCREEN_SIZE(512, 256)
152   MDRV_SCREEN_VISIBLE_AREA(0, 512-1, 0, 256-1)
153
154   MDRV_GFXDECODE(igs_ncs)
155   MDRV_PALETTE_LENGTH(0x400)
156
157   MDRV_VIDEO_START(igs_ncs)
158   MDRV_VIDEO_UPDATE(igs_ncs)
159
160   /* sound hardware */
161   MDRV_SPEAKER_STANDARD_MONO("mono")
162   MDRV_SOUND_ADD("ym", YM2413, XTAL_3_579545MHz)
163   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
164
165MACHINE_DRIVER_END
166
167
168
169ROM_START( igs_ncs )
170   ROM_REGION( 0x10000, "main", 0 )
171   ROM_LOAD( "ncs_v100n.u20", 0x00000, 0x10000, CRC(2bb91de5) SHA1(b0b7b3b9cee1ce4da10cf78ef1c8079f3d9cafbf) )
172
173   ROM_REGION( 0x10000, "data", 0 )
174   ROM_LOAD( "ncs_v100n.u21", 0x00000, 0x10000, CRC(678e412c) SHA1(dba031d3576d098d314d6589dd1aeda44d17c650) )
175
176   ROM_REGION( 0xc0000, "gfx1", ROMREGION_DISPOSE )
177   ROM_LOAD( "ncs_v100n.u50", 0x00000, 0x40000, CRC(ff2bb3dc) SHA1(364c948504003b4230fbdac74227842c802d4c12) )
178   ROM_LOAD( "ncs_v100n.u51", 0x40000, 0x40000, CRC(f8530313) SHA1(b21d6de7d5d4b902008ceea7e1227545e0d1701b) )
179   ROM_LOAD( "ncs_v100n.u52", 0x80000, 0x40000, CRC(2fa5b6df) SHA1(5bfc651297440f73692079f1806b1e40b457b7b8) )
180
181   ROM_REGION( 0x30000, "gfx2", ROMREGION_ERASEFF | ROMREGION_DISPOSE )
182   // looks like these are needed for pre-game screens, sockets were empty
183   ROM_LOAD( "ncs_v100n.u55", 0x00000, 0x10000, NO_DUMP )
184   ROM_LOAD( "ncs_v100n.u56", 0x10000, 0x10000, NO_DUMP )
185   ROM_LOAD( "ncs_v100n.u57", 0x20000, 0x10000, NO_DUMP )
186ROM_END
187
188
189DRIVER_INIT( igs_ncs )
190{
191   UINT8 *src = (UINT8 *) (memory_region(machine, "main"));
192   int i;
193
194   for(i = 0; i < 0x10000; i++)
195   {
196      /* bit 0 xor layer */
197      if(i & 0x200)
198      {
199         if(i & 0x80)
200         {
201            if(~i & 0x02)
202            {
203               src[i] ^= 0x01;
204            }
205         }
206         else
207         {
208            src[i] ^= 0x01;
209         }
210      }
211      else
212      {
213         src[i] ^= 0x01;
214      }
215
216      /* bit 1 xor layer */
217      if(i & 0x800)
218      {
219         if(i & 0x100)
220         {
221            if(i & 0x40)
222            {
223               src[i] ^= 0x02;
224            }
225         }
226      }
227
228      /* bit 5 xor layer */
229      if(i & 0x100)
230      {
231         if(i & 0x40)
232         {
233            src[i] ^= 0x20;
234         }
235      }
236      else
237      {
238         src[i] ^= 0x20;
239      }
240   }
241
242}
243
244GAME( 2000, igs_ncs, 0, igs_ncs, igs_ncs, igs_ncs, ROT0, "IGS", "New Champion Skill (v100n)", GAME_NOT_WORKING )
245
src/mame/drivers/atarig1.c
r4135r4136
370370   5,
371371   { 0, 0, 1, 2, 3 },
372372   { RGN_FRAC(2,5)+0, RGN_FRAC(2,5)+4, 0, 4, RGN_FRAC(2,5)+8, RGN_FRAC(2,5)+12, 8, 12 },
373   { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
373   { STEP8(0,16) },
374374   16*8
375375};
376376
r4135r4136
381381   5,
382382   { RGN_FRAC(4,5), RGN_FRAC(4,5), RGN_FRAC(4,5), RGN_FRAC(4,5), RGN_FRAC(4,5) },
383383   { 0, 1, 2, 3, 4, 5, 6, 7 },
384   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
384   { STEP8(0,8) },
385385   8*8
386386};
387387
r4135r4136
390390   8,8,
391391   RGN_FRAC(1,1),
392392   4,
393   { 0, 1, 2, 3 },
394   { 0, 4, 8, 12, 16, 20, 24, 28 },
395   { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
393   { STEP4(0,1) },
394   { STEP8(0,4) },
395   { STEP8(0,32) },
396396   32*8
397397};
398398
src/mame/drivers/re900.c
r4135r4136
247247*      Input ports      *
248248************************/
249249
250INPUT_PORTS_START( re900 )
250static INPUT_PORTS_START( re900 )
251251
252252   PORT_START("IN0")
253253   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Operator Key") PORT_TOGGLE PORT_CODE(KEYCODE_0)
r4135r4136
334334   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
335335INPUT_PORTS_END
336336
337INPUT_PORTS_START( bs94 )
337static INPUT_PORTS_START( bs94 )
338338   PORT_START("IN0")
339339   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Bet")       PORT_CODE(KEYCODE_2)
340340   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Double")    PORT_CODE(KEYCODE_3)
src/mame/drivers/jackpool.c
r4135r4136
1/*
1/*******************************************************************************************
22
3Poker game
3Jackpot Cards / Jackpot Pool (c) 1997 Electronic Projects
44
5Copyright (C) 1992 HI-TECH Software..Brisbane, QLD Australia
6 is present in the ROMs, although the game is in Italian
7 and has a 1997 copyright, its probably a bootleg
5driver by David Haywood & Angelo Salese
86
9*/
7Notes:
8-There's a "(c) 1992 HI-TECH Software..Brisbane, QLD Australia" string in the program roms,
9 this is actually the m68k C compiler used for doing this game.
1010
11TODO:
12-Correct NVRAM emulation (and default eeprom too?);
13-Doesn't accept coins? (might be related to the eeprom);
14-Transparent pen issue on the text layer? (might be a btanb);
15-Understand master-slave comms properly;
16
17*******************************************************************************************/
18
1119#include "driver.h"
1220#include "cpu/m68000/m68000.h"
13#include "deprecat.h"
1421#include "sound/okim6295.h"
22#include "machine/eeprom.h"
23#include "rendlay.h"
1524
1625
17static tilemap *jackpool_layer0_tilemap;
18static UINT16 *jackpool_layer0_videoram;
19static tilemap *jackpool_layer1_tilemap;
20static UINT16 *jackpool_layer1_videoram;
21static tilemap *jackpool_layer2_tilemap;
22static UINT16 *jackpool_layer2_videoram;
26static UINT16 *sc0_vram;
27static UINT16 *sc1_vram;
28static UINT16 *sc2_vram;
29static UINT16 *sc3_vram;
2330
31static UINT16 *jackpool_io;
2432
25static TILE_GET_INFO( get_jackpool_layer0_tile_info )
33static VIDEO_START(jackpool)
2634{
27   int tileno,attr;
28
29   tileno = jackpool_layer0_videoram[tile_index]&0x7fff;
30   attr = jackpool_layer0_videoram[tile_index+0x800]&0x1f;
31
32   SET_TILE_INFO(0,tileno,attr,0);
3335}
3436
35static WRITE16_HANDLER( jackpool_layer0_videoram_w )
37static VIDEO_UPDATE(jackpool)
3638{
37   COMBINE_DATA(&jackpool_layer0_videoram[offset]);
39   const device_config *left_screen  = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "left");
40   const device_config *right_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "right");
41   const gfx_element *gfx = screen->machine->gfx[0];
42   int count;// = 0x00000/2;
3843
39   tilemap_mark_tile_dirty(jackpool_layer0_tilemap,offset&0x07ff);
40}
44   int y,x;
4145
42static TILE_GET_INFO( get_jackpool_layer1_tile_info )
43{
44   int tileno,attr;
46   if(screen == left_screen)
47   {
48      count = 0x0000/2;
49      for (y=0;y<32;y++)
50      {
51         for (x=0;x<64;x++)
52         {
53            int tile = (sc1_vram[count] & 0x7fff);
54            int attr = (sc1_vram[count+0x800] & 0x1f00)>>8;
55            //int t_pen = (sc1_vram[count+0x800] & 0x2000);
56            //int colour = tile>>12;
57            drawgfx(bitmap,gfx,tile,attr,0,0,x*8,y*8,cliprect,TRANSPARENCY_NONE,0);
4558
46   tileno = jackpool_layer1_videoram[tile_index]&0x7fff;
47   attr = jackpool_layer1_videoram[tile_index+0x800]&0x1f;
59            count++;
60         }
61      }
4862
49   SET_TILE_INFO(0,tileno,attr,0);
50}
63      count = 0x0000/2;
64      for (y=0;y<32;y++)
65      {
66         for (x=0;x<64;x++)
67         {
68            int tile = (sc0_vram[count] & 0x7fff);
69            int attr = (sc0_vram[count+0x800] & 0x1f00)>>8;
70            /*might just be sloppy coding,colors are enabled as 0x20-0x3f*/
71            int t_pen = (sc0_vram[count+0x800] & 0x2000);
72            //int colour = tile>>12;
73            drawgfx(bitmap,gfx,tile,attr,0,0,x*8,y*8,cliprect,(t_pen) ? TRANSPARENCY_NONE : TRANSPARENCY_PEN,0);
74            count++;
75         }
76      }
77   }
5178
52static WRITE16_HANDLER( jackpool_layer1_videoram_w )
53{
54   COMBINE_DATA(&jackpool_layer1_videoram[offset]);
79   if(screen == right_screen)
80   {
81      count = 0x0000/2;
82      for (y=0;y<32;y++)
83      {
84         for (x=0;x<64;x++)
85         {
86            int tile = (sc2_vram[count] & 0x7fff);
87            int attr = (sc2_vram[count+0x800] & 0x1f00)>>8;
88            //int t_pen = (sc1_vram[count+0x800] & 0x2000);
89            //int colour = tile>>12;
90            drawgfx(bitmap,gfx,tile,attr,0,0,x*8,y*8,cliprect,TRANSPARENCY_NONE,0);
5591
56   tilemap_mark_tile_dirty(jackpool_layer1_tilemap,offset&0x07ff);
57}
92            count++;
93         }
94      }
5895
59static TILE_GET_INFO( get_jackpool_layer2_tile_info )
60{
61   int tileno,attr;
96      count = 0x0000/2;
97      for (y=0;y<32;y++)
98      {
99         for (x=0;x<64;x++)
100         {
101            int tile = (sc3_vram[count] & 0x7fff);
102            int attr = (sc3_vram[count+0x800] & 0x1f00)>>8;
103            /*might just be sloppy coding,colors are enabled as 0x20-0x3f*/
104            int t_pen = (sc3_vram[count+0x800] & 0x2000);
105            //int colour = tile>>12;
106            drawgfx(bitmap,gfx,tile,attr,0,0,x*8,y*8,cliprect,(t_pen) ? TRANSPARENCY_NONE : TRANSPARENCY_PEN,0);
107            count++;
108         }
109      }
110   }
62111
63   tileno = jackpool_layer2_videoram[tile_index]&0x7fff;
64   attr = jackpool_layer2_videoram[tile_index+0x800]&0x1f;
65
66   SET_TILE_INFO(0,tileno,attr,0);
112   return 0;
67113}
68114
69static WRITE16_HANDLER( jackpool_layer2_videoram_w )
115/*Communication ram*/
116static READ16_HANDLER( jackpool_ff_r )
70117{
71   COMBINE_DATA(&jackpool_layer2_videoram[offset]);
72
73   tilemap_mark_tile_dirty(jackpool_layer2_tilemap,offset&0x07ff);
118   return 0xffff;
74119}
75120
76
77
78121static READ16_HANDLER( jackpool_io_r )
79122{
80   return 0xffff;
123   switch(offset*2)
124   {
125      case 0x0: return input_port_read(space->machine,"COIN1");
126      case 0x8: return input_port_read(space->machine,"SERVICE1");
127      case 0xa: return input_port_read(space->machine,"SERVICE2");//probably not a button
128      case 0xc: return input_port_read(space->machine,"PAYOUT");
129      case 0xe: return input_port_read(space->machine,"START2");
130      case 0x10: return input_port_read(space->machine,"HOLD3");
131      case 0x12: return input_port_read(space->machine,"HOLD4");
132      case 0x14: return input_port_read(space->machine,"HOLD2");
133      case 0x16: return input_port_read(space->machine,"HOLD1");
134      case 0x18: return input_port_read(space->machine,"HOLD5");
135      case 0x1a: return input_port_read(space->machine,"START1");
136      case 0x1c: return input_port_read(space->machine,"BET");
137//      case 0x2c: eeprom 1 r?
138//      case 0x2e: eeprom 2 r?
139   }
140
141//  printf("R %02x\n",offset*2);
142   return jackpool_io[offset];
81143}
82144
83static ADDRESS_MAP_START( jackpool_readmem, ADDRESS_SPACE_PROGRAM, 16 )
84   AM_RANGE(0x000000, 0x03ffff) AM_READ(SMH_ROM)
85   AM_RANGE(0x100000, 0x10ffff) AM_READ(SMH_RAM)
145static WRITE16_HANDLER( jackpool_io_w )
146{
147//  printf("W %02x %02x\n",offset*2,data);
148   COMBINE_DATA(&jackpool_io[offset]);
86149
87   AM_RANGE(0x120000, 0x1200ff) AM_READ(SMH_RAM) // maybe nvram?
150   #if 0
151   if(offset*2 == 0x54)
152   {
153      printf("Write bit %02x\n",data);
154      eeprom_write_bit(data & 1);
155   }
156   if(offset*2 == 0x52)
157   {
158      printf("Clock bit %02x\n",data);
159      eeprom_set_clock_line((data & 1) ? ASSERT_LINE : CLEAR_LINE );
160   }
161   if(offset*2 == 0x50)
162   {
163      printf("chip select bit %02x\n",data);
164      eeprom_set_cs_line((data & 1) ? CLEAR_LINE : ASSERT_LINE );
165   }
166   #endif
167}
88168
89   AM_RANGE(0x340000, 0x34ffff) AM_READ(SMH_RAM)
90   AM_RANGE(0x360000, 0x3603ff) AM_READ(SMH_RAM)
91   AM_RANGE(0x380000, 0x38005f) AM_READ(SMH_RAM)
92
93   AM_RANGE(0x800000, 0x80000f) AM_READ(jackpool_io_r)
94
95
96ADDRESS_MAP_END
97
98static ADDRESS_MAP_START( jackpool_writemem, ADDRESS_SPACE_PROGRAM, 16 )
99   AM_RANGE(0x000000, 0x03ffff) AM_WRITE(SMH_ROM)
100   AM_RANGE(0x100000, 0x10ffff) AM_WRITE(SMH_RAM)
101
102   AM_RANGE(0x120000, 0x1200ff) AM_WRITE(SMH_RAM)
103
104   AM_RANGE(0x340000, 0x341fff) AM_WRITE(jackpool_layer0_videoram_w) AM_BASE(&jackpool_layer0_videoram)
105   AM_RANGE(0x342000, 0x343fff) AM_WRITE(jackpool_layer1_videoram_w) AM_BASE(&jackpool_layer1_videoram)
106   AM_RANGE(0x344000, 0x345fff) AM_WRITE(jackpool_layer2_videoram_w) AM_BASE(&jackpool_layer2_videoram) // is this the same screen?
169static ADDRESS_MAP_START( jackpool_mem, ADDRESS_SPACE_PROGRAM, 16 )
170   AM_RANGE(0x000000, 0x03ffff) AM_ROM
171   AM_RANGE(0x100000, 0x10ffff) AM_RAM
172   AM_RANGE(0x120000, 0x1200ff) AM_RAM
173   AM_RANGE(0x340000, 0x341fff) AM_RAM AM_BASE(&sc0_vram)
174   AM_RANGE(0x342000, 0x343fff) AM_RAM AM_BASE(&sc1_vram)
175   AM_RANGE(0x344000, 0x345fff) AM_RAM AM_BASE(&sc2_vram)
176   AM_RANGE(0x346000, 0x347fff) AM_RAM AM_BASE(&sc3_vram)
107177   /* are the ones below used? */
108   AM_RANGE(0x346000, 0x347fff) AM_WRITE(SMH_RAM)
109   AM_RANGE(0x348000, 0x349fff) AM_WRITE(SMH_RAM)
110   AM_RANGE(0x34a000, 0x34bfff) AM_WRITE(SMH_RAM)
111   AM_RANGE(0x34c000, 0x34dfff) AM_WRITE(SMH_RAM)
112   AM_RANGE(0x34e000, 0x34ffff) AM_WRITE(SMH_RAM)
178   AM_RANGE(0x348000, 0x349fff) AM_RAM
179   AM_RANGE(0x34a000, 0x34bfff) AM_RAM
180   AM_RANGE(0x34c000, 0x34dfff) AM_RAM
181   AM_RANGE(0x34e000, 0x34ffff) AM_RAM
113182
114   AM_RANGE(0x360000, 0x3603ff) AM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE(&paletteram16)
115   AM_RANGE(0x380000, 0x38005f) AM_WRITE(SMH_RAM)
116ADDRESS_MAP_END
183   AM_RANGE(0x360000, 0x3603ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE(&paletteram16)
184   AM_RANGE(0x380000, 0x380061) AM_READWRITE(jackpool_io_r,jackpool_io_w) AM_BASE(&jackpool_io)//AM_READ(jackpool_io_r)
117185
118#if 0
119static ADDRESS_MAP_START( roulette_map, ADDRESS_SPACE_PROGRAM, 16 )
120   AM_RANGE(0x000000, 0x03ffff) AM_ROM
186   AM_RANGE(0x800000, 0x80000f) AM_READ(jackpool_ff_r) AM_WRITENOP
187   AM_RANGE(0xa00000, 0xa00001) AM_READWRITE(okim6295_status_0_lsb_r, okim6295_data_0_lsb_w)
121188ADDRESS_MAP_END
122#endif
123189
124190
125
126191static INPUT_PORTS_START( jackpool )
192   PORT_START("COIN1")
193   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
194   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
195   PORT_START("SERVICE1")
196   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )
197   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
198   PORT_START("SERVICE2") //toggle this to change game to Jackpot Pool,with different gfxs for cards.
199   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE2 )
200   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
201   PORT_START("PAYOUT")
202   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Payout") PORT_CODE(KEYCODE_W)
203   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
204   PORT_START("START1")
205   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
206   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
207   PORT_START("START2")
208   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START2 )
209   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
210   PORT_START("BET")
211   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Bet / Cancel") PORT_CODE(KEYCODE_A)
212   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
213   PORT_START("HOLD1")
214   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z)
215   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
216   PORT_START("HOLD2")
217   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Hold 2") PORT_CODE(KEYCODE_X)
218   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
219   PORT_START("HOLD3")
220   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Hold 3") PORT_CODE(KEYCODE_C)
221   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
222   PORT_START("HOLD4")
223   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 4") PORT_CODE(KEYCODE_V)
224   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
225   PORT_START("HOLD5")
226   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Hold 5") PORT_CODE(KEYCODE_B)
227   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED )
127228INPUT_PORTS_END
128229
129230
r4135r4136
132233   8,8,
133234   RGN_FRAC(1,4),
134235   4,
135   { RGN_FRAC(3,4),RGN_FRAC(2,4),RGN_FRAC(1,4),RGN_FRAC(0,4) },
236   { RGN_FRAC(0,4),RGN_FRAC(1,4),RGN_FRAC(2,4),RGN_FRAC(3,4) },
136237   { 0, 1, 2, 3, 4, 5, 6, 7 },
137238   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
138239   8*8
139240};
140241
141
142
143
144static VIDEO_START(jackpool)
145{
146   jackpool_layer0_tilemap = tilemap_create(machine, get_jackpool_layer0_tile_info,tilemap_scan_rows, 8, 8,64,32);
147   jackpool_layer1_tilemap = tilemap_create(machine, get_jackpool_layer1_tile_info,tilemap_scan_rows, 8, 8,64,32);
148   jackpool_layer2_tilemap = tilemap_create(machine, get_jackpool_layer2_tile_info,tilemap_scan_rows, 8, 8,64,32);
149
150   tilemap_set_transparent_pen(jackpool_layer0_tilemap,0);
151   tilemap_set_transparent_pen(jackpool_layer2_tilemap,0);
152}
153
154static VIDEO_UPDATE(jackpool)
155{
156   tilemap_draw(bitmap,cliprect,jackpool_layer1_tilemap,0,0);
157   tilemap_draw(bitmap,cliprect,jackpool_layer0_tilemap,0,0);
158
159//  tilemap_draw(bitmap,cliprect,jackpool_layer2_tilemap,0,0); // is this actually a second display?
160
161   return 0;
162}
163
164
165242static GFXDECODE_START( jackpool )
166   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8_layout,   0x000, 256  ) /* sprites */
243   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8_layout,   0x000, 0x20  ) /* sprites */
167244GFXDECODE_END
168245
169/* verify */
246
247/*irq 2 used for communication stuff.3 is just a rte*/
170248static INTERRUPT_GEN( jackpool_interrupt )
171249{
172   cpu_set_input_line(device, cpu_getiloops(device)+1, HOLD_LINE);   /* IRQs 3, 2, and 1 */
250   cpu_set_input_line(device, 1, HOLD_LINE);
173251}
174252
175253
176254static MACHINE_DRIVER_START( jackpool )
177255   MDRV_CPU_ADD("main", M68000, 12000000) // ?
178   MDRV_CPU_PROGRAM_MAP(jackpool_readmem,jackpool_writemem)
179   MDRV_CPU_VBLANK_INT_HACK(jackpool_interrupt,3)  // ?
256   MDRV_CPU_PROGRAM_MAP(jackpool_mem,0)
257   MDRV_CPU_VBLANK_INT("left",jackpool_interrupt)  // ?
180258
181259   MDRV_GFXDECODE(jackpool)
260   MDRV_DEFAULT_LAYOUT(layout_dualhsxs)
182261
262   MDRV_SCREEN_ADD("left", RASTER)
263   MDRV_SCREEN_REFRESH_RATE(60)
264   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
265   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
266   MDRV_SCREEN_SIZE(64*8, 64*8)
267   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 0*8, 32*8-1)
183268
184   MDRV_SCREEN_ADD("main", RASTER)
269   MDRV_SCREEN_ADD("right", RASTER)
185270   MDRV_SCREEN_REFRESH_RATE(60)
186271   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
187272   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
188273   MDRV_SCREEN_SIZE(64*8, 64*8)
189274   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 0*8, 32*8-1)
190275
276   MDRV_NVRAM_HANDLER(93C46)
277
191278   MDRV_PALETTE_LENGTH(0x200)
192279
193280   MDRV_VIDEO_START(jackpool)
r4135r4136
198285   MDRV_SOUND_ADD("oki", OKIM6295, 1056000)
199286   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified
200287   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
201
202288MACHINE_DRIVER_END
203289
204290
r4135r4136
217303   ROM_LOAD( "jpc7", 0xc0000, 0x40000,  CRC(b1d40623) SHA1(fb76ae6b53474bd4bee19dbce9537da0f2b63ff4) )
218304ROM_END
219305
220GAME( 1997, jackpool, 0, jackpool, jackpool, 0, ROT0, "Electronic Projects", "Jackpot Pool (Italy, bootleg)",GAME_NOT_WORKING )
306GAME( 1997, jackpool, 0, jackpool, jackpool, 0, ROT0, "Electronic Projects", "Jackpot Cards / Jackpot Pool (Italy)",GAME_NOT_WORKING )
src/mame/drivers/lethal.c
r4135r4136
299299            case 0x45:
300300            case 0x46:
301301               return K053244_r(space,offset-0x40);
302               break;
303302
304303            case 0x80:
305304            case 0x81:
r4135r4136
334333            case 0x9e:
335334            case 0x9f:
336335               return K054000_r(space,offset-0x80);
337               break;
338336
339337            case 0xca:
340338               return sound_status_r(space,0);
341               break;
342339         }
343340      }
344341      else if (offset < 0x1800)
r4135r4136
454451   {
455452      case 0:
456453         return GUNX(1)>>1;
457         break;
458454      case 1:
459455         if ((240-GUNY(1)) == 7)
460456            return 0;
r4135r4136
463459         break;
464460      case 2:
465461         return GUNX(2)>>1;
466         break;
467462      case 3:
468463         if ((240-GUNY(2)) == 7)
469464            return 0;
src/mame/drivers/2mindril.c
r4135r4136
8181
8282static VIDEO_UPDATE( drill )
8383{
84   int i;
8584   bitmap_fill(bitmap,NULL,0);
8685
87   for (i=0; i<256; i++)
88   {
89      decodechar(screen->machine->gfx[1],i,(UINT8*)&charram[0]);
90   }
91
9286   DRAW_MAP(map1ram,0)
9387   DRAW_MAP(map2ram,1)
9488   DRAW_MAP(map3ram,2)
r4135r4136
117111static VIDEO_START( drill )
118112{
119113   machine->gfx[0]->color_granularity=16;
114   gfx_element_set_source(machine->gfx[1], (UINT8 *)charram);
120115}
121116
122117static UINT16 *iodata;
r4135r4136
220215   }
221216}
222217
218static WRITE16_HANDLER( charram_w )
219{
220   COMBINE_DATA(&charram[offset]);
221   gfx_element_mark_dirty(space->machine->gfx[1], offset/16);
222}
223
223224static ADDRESS_MAP_START( drill_map, ADDRESS_SPACE_PROGRAM, 16 )
224225   AM_RANGE(0x000000, 0x07ffff) AM_ROM
225226   AM_RANGE(0x200000, 0x20ffff) AM_RAM
r4135r4136
229230   AM_RANGE(0x414000, 0x415fff) AM_RAM AM_BASE(&map3ram)
230231   AM_RANGE(0x416000, 0x417fff) AM_RAM AM_BASE(&map4ram)
231232   AM_RANGE(0x41c000, 0x41dfff) AM_RAM AM_BASE(&textram)
232   AM_RANGE(0x41e000, 0x41ffff) AM_RAM AM_BASE(&charram)
233   AM_RANGE(0x41e000, 0x41ffff) AM_RAM_WRITE(charram_w) AM_BASE(&charram)
233234   AM_RANGE(0x400000, 0x4fffff) AM_RAM AM_BASE(&unkram)// video stuff, 460000 - video regs ?
234235   AM_RANGE(0x500000, 0x501fff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE(&paletteram16)
235236   AM_RANGE(0x502000, 0x503fff) AM_RAM
src/mame/drivers/taitowlf.c
r4135r4136
5151static void draw_char(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y)
5252{
5353   int i,j;
54   UINT8 *dp;
54   const UINT8 *dp;
5555   int index = 0;
56   dp = gfx->gfxdata + ch * gfx->char_modulo;
56   dp = gfx_element_get_data(gfx, ch);
5757
5858   for (j=y; j < y+8; j++)
5959   {
src/mame/drivers/msisaac.c
r4135r4136
129129      case 0x41:
130130       case 0x42:
131131          return 0;
132       break;
133132
134133       /*With this command the MCU controls body direction  */
135134       case 0x02:
r4135r4136
167166
168167          return direction;
169168       }
170       break;
171169
172170      /*This controls the arms when they return to the player.            */
173171       case 0x07:
174172          return 0x45;
175       break;
176173
177174       default:
178175          logerror("CPU#0 read from MCU pc=%4x, mcu_val=%2x\n", cpu_get_pc(space->cpu), mcu_val );
179176             return mcu_val;
180       break;
181177   }
182178#endif
183179}
src/mame/drivers/cyberbal.c
r4135r4136
2222#include "driver.h"
2323#include "cpu/m68000/m68000.h"
2424#include "cpu/m6502/m6502.h"
25#include "sound/2151intf.h"
26#include "sound/dac.h"
2527#include "rendlay.h"
2628#include "machine/atarigen.h"
2729#include "audio/atarijsa.h"
2830#include "cyberbal.h"
29#include "sound/2151intf.h"
3031
3132
32
3333/*************************************
3434 *
3535 *  Initialization
src/mame/drivers/spaceg.c
r4135r4136
228228      logerror("mode =%02x pc=%04x\n",*io9401,cpu_get_pc(space->cpu) );
229229      popmessage("mode =%02x pc=%04x\n",*io9401,cpu_get_pc(space->cpu) );
230230      return;
231      break;
232231   }
233232
234233
src/mame/drivers/skykid.c
r4135r4136
5353   switch (inputport_selected)
5454   {
5555      case 0x00:   /* DSW B (bits 0-4) */
56         return (input_port_read(space->machine, "DSWB") & 0xf8) >> 3; break;
56         return (input_port_read(space->machine, "DSWB") & 0xf8) >> 3;
5757      case 0x01:   /* DSW B (bits 5-7), DSW A (bits 0-1) */
58         return ((input_port_read(space->machine, "DSWB") & 0x07) << 2) | ((input_port_read(space->machine, "DSWA") & 0xc0) >> 6); break;
58         return ((input_port_read(space->machine, "DSWB") & 0x07) << 2) | ((input_port_read(space->machine, "DSWA") & 0xc0) >> 6);
5959      case 0x02:   /* DSW A (bits 2-6) */
60         return (input_port_read(space->machine, "DSWA") & 0x3e) >> 1; break;
60         return (input_port_read(space->machine, "DSWA") & 0x3e) >> 1;
6161      case 0x03:   /* DSW A (bit 7), DSW C (bits 0-3) */
62         return ((input_port_read(space->machine, "DSWA") & 0x01) << 4) | (input_port_read(space->machine, "BUTTON2") & 0x0f); break;
62         return ((input_port_read(space->machine, "DSWA") & 0x01) << 4) | (input_port_read(space->machine, "BUTTON2") & 0x0f);
6363      case 0x04:   /* coins, start */
64         return input_port_read(space->machine, "SYSTEM"); break;
64         return input_port_read(space->machine, "SYSTEM");
6565      case 0x05:   /* 2P controls */
66         return input_port_read(space->machine, "P2"); break;
66         return input_port_read(space->machine, "P2");
6767      case 0x06:   /* 1P controls */
68         return input_port_read(space->machine, "P1"); break;
68         return input_port_read(space->machine, "P1");
6969      default:
7070         return 0xff;
7171   }
src/mame/drivers/tarzan.c
r4135r4136
11
22/* Old IGS game called Tarzan, don't know much about it, could be gambling */
3/* CPU might not be z80 */
3/* CPU might not be z80 (maybe z180)
44
5#include "driver.h"
6#include "cpu/z80/z80.h"
5  decryption is incomplete?, first part of code doesn't seem right?
76
8#if 0
9static UINT16 *file1_data;
10static int file1_size;
7  graphics area also encrypted
118
12static UINT16 *result_data;
9*/
1310
14static int decrypt_tarzan()
15{
16  int fd;
17  int i;
18  char msg[512];
11#include "driver.h"
12#include "cpu/z80/z80.h"
1913
20  if(argc != 3) {
21    fprintf(stderr, "Usage:\n%s <file1.bin> <result.bin>\n", argv[0]);
22    exit(1);
23  }
2414
25  sprintf(msg, "Open %s", argv[1]);
26  fd = open(argv[1], O_RDONLY);
27  if(fd<0) {
28    perror(msg);
29    exit(2);
30  }
31
32  file1_size = lseek(fd, 0, SEEK_END);
33  lseek(fd, 0, SEEK_SET);
34
35  file1_data = malloc_or_die(file1_size);
36  read(fd, file1_data, file1_size);
37  close(fd);
38
39  result_data = malloc_or_die(file1_size);
40  for(i=0; i<file1_size/2; i++) {
41    UINT16 x = file1_data[i];
42
43    if((i & 0x10c0) == 0x0000)
44      x ^= 0x0001;
45
46    if((i & 0x0010) == 0x0010 || (i & 0x0130) == 0x0020)
47      x ^= 0x0404;
48
49    if((i & 0x00d0) != 0x0010)
50      x ^= 0x1010;
51
52    if(((i & 0x0008) == 0x0008)^((i & 0x10c0) == 0x0000))
53      x ^= 0x0100;
54
55    result_data[i] = x;
56  }
57
58  sprintf(msg, "Open %s", argv[2]);
59  fd = open(argv[2], O_RDWR|O_CREAT|O_TRUNC, 0666);
60  if(fd<0) {
61    perror(msg);
62    exit(2);
63  }
64
65  write(fd, result_data, file1_size);
66  close(fd);
67
68  return 0;
69}
70#endif
71
72
7315static VIDEO_START(tarzan)
7416{
7517}
r4135r4136
8931INPUT_PORTS_END
9032
9133
34static const gfx_layout tarzan_layout =
35{
36   8,8,
37   RGN_FRAC(1,1),
38   4,
39   { 0*8,1*8,2*8,3*8 },
40   { 0,1,2,3,4,5,6,7 },
41   { 0*8, 4*8, 8*8,12*8,16*8,20*8,24*8,28*8},
42   32*8
43};
44
45
46static GFXDECODE_START( tarzan )
47   GFXDECODE_ENTRY( "gfx1", 0, tarzan_layout,   0x0, 2  )
48   GFXDECODE_ENTRY( "gfx2", 0, tarzan_layout,  0x0, 2  )
49GFXDECODE_END
50
51
52
53
9254static MACHINE_DRIVER_START( tarzan )
9355   /* basic machine hardware */
9456   MDRV_CPU_ADD("main", Z80,8000000)       /* ? */
r4135r4136
10365   MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 0, 256-1)
10466
10567   MDRV_PALETTE_LENGTH(0x100)
68   MDRV_GFXDECODE(tarzan)
10669
10770   MDRV_VIDEO_START(tarzan)
10871   MDRV_VIDEO_UPDATE(tarzan)
10972MACHINE_DRIVER_END
11073
74DRIVER_INIT( tarzan )
75{
76   UINT16* ROM = (UINT16*)memory_region(machine,"main");
77   int i;
78   int size = 0x040000;
11179
80   for(i=0; i<size/2; i++)
81   {
82      UINT16 x = ROM[i];
11283
84      if((i & 0x10c0) == 0x0000)
85         x ^= 0x0001;
86
87      if((i & 0x0010) == 0x0010 || (i & 0x0130) == 0x0020)
88         x ^= 0x0404;
89
90      if((i & 0x00d0) != 0x0010)
91         x ^= 0x1010;
92
93      if(((i & 0x0008) == 0x0008)^((i & 0x10c0) == 0x0000))
94         x ^= 0x0100;
95
96      ROM[i] = x;
97   }
98
99   #if 0
100   {
101      FILE *fp;
102      char filename[256];
103      sprintf(filename,"decrypted_%s", machine->gamedrv->name);
104      fp=fopen(filename, "w+b");
105      if (fp)
106      {
107         fwrite(ROM, 0x40000, 1, fp);
108         fclose(fp);
109      }
110   }
111   #endif
112}
113
113114ROM_START( tarzan )
114115   ROM_REGION( 0x040000, "main", 0 )
115116   ROM_LOAD( "0228-u16.bin", 0x00000, 0x040000, CRC(e6c552a5) SHA1(f156de9459833474c85a1f5b35917881b390d34c)  )
116117
117   ROM_REGION( 0x080000, "user1", 0 )
118   ROM_REGION( 0x080000, "gfx1", 0 )
118119   ROM_LOAD( "0228-u21.bin", 0x00000, 0x080000, CRC(80aaece4) SHA1(07cad92492c5de36c3915867ed4c6544b1a30c07)  )
119120
120   ROM_REGION( 0x080000, "user2", 0 )
121   ROM_REGION( 0x080000, "gfx2", 0 )
121122   ROM_LOAD( "0228-u6.bin", 0x00000, 0x080000, CRC(55e94832) SHA1(b15409f4f1264b6d1218d5dc51c5bd1de2e40284)  )
122123
123124ROM_END
124125
125126
126GAME( 199?, tarzan, 0, tarzan, tarzan, 0, ROT0, "IGS", "Tarzan",GAME_NOT_WORKING|GAME_NO_SOUND )
127GAME( 199?, tarzan, 0, tarzan, tarzan, tarzan, ROT0, "IGS", "Tarzan",GAME_NOT_WORKING|GAME_NO_SOUND )
src/mame/drivers/ssfindo.c
r4135r4136
316316   {
317317      case MSECR:
318318         return mame_rand(space->machine);
319      break;
320319
321320      case IOLINES: //TODO: eeprom  24c01
322321#if 0
src/mame/drivers/peplus.c
r4135r4136
103103          pexp0112     2
104104          pexs0006     2
105105          pexmp006     2
106          pexmp017     2
106107
107108
1081092) Configuration
r4135r4136
173174#define MASTER_CLOCK       XTAL_20MHz
174175#define CPU_CLOCK         ((MASTER_CLOCK)/2)      /* divided by 2 - 7474 */
175176#define MC6845_CLOCK      ((MASTER_CLOCK)/8/3)
177#define SOUND_CLOCK         ((MASTER_CLOCK)/12)
176178
177179static UINT16 autohold_addr; /* address to patch in program RAM to enable autohold feature */
178180
179181static tilemap *bg_tilemap;
182static UINT8 wingboard;
183static UINT8 jumper_e16_e17; /* Set this to TRUE when CG chips are 27c512 instead of 27c256 */
180184
181185/* Pointers to External RAM */
182186static UINT8 *program_ram;
r4135r4136
191195/* Variables used instead of CRTC6845 system */
192196static UINT16 vid_address = 0;
193197
194/* Holds upper video address and palette number */
198/* Holds upper video address, palette number and jumper_e16_e17 flag */
195199static UINT8 *palette_ram;
200static UINT8 *palette_ram2;
196201
197202/* IO Ports */
198203static UINT8 *io_port;
r4135r4136
227232   crtc_addr            /* update address callback */
228233};
229234
235
236/**************
237* Memory Copy *
238***************/
239
240static void peplus_load_superdata(running_machine *machine, const char *bank_name)
241{
242    UINT8 *super_data = memory_region(machine, bank_name);
243
244    /* Distribute Superboard Data */
245    memcpy(s3000_ram, &super_data[0x3000], 0x1000);
246    memcpy(s5000_ram, &super_data[0x5000], 0x1000);
247    memcpy(s7000_ram, &super_data[0x7000], 0x1000);
248    memcpy(sb000_ram, &super_data[0xb000], 0x1000);
249    memcpy(sd000_ram, &super_data[0xd000], 0x1000);
250    memcpy(sf000_ram, &super_data[0xf000], 0x1000);
251}
252
253
230254/*****************
231255* NVRAM Handlers *
232256******************/
r4135r4136
252276   NVRAM_HANDLER_CALL(i2cmem_0);
253277}
254278
279
255280/*****************
256281* Write Handlers *
257282******************/
r4135r4136
260285{
261286   int i;
262287
263   for (i = 0; i < 16; i++)
288   for (i = 0; i < space->machine->config->total_colors; i++)
264289   {
265290      int bit0, bit1, bit2, r, g, b;
266291
r4135r4136
286311   }
287312}
288313
289/*
290    ROCKWELL 6545 - Transparent Memory Addressing
291    The current CRTC6845 driver does not support these
292    additional registers (R18, R19, R31)
293*/
294314
315/* ROCKWELL 6545 - Transparent Memory Addressing */
316
295317static MC6845_ON_UPDATE_ADDR_CHANGED(crtc_addr)
296318{
297319   vid_address = address;
298320}
299321
300
301322static WRITE8_DEVICE_HANDLER( peplus_crtc_mode_w )
302323{
303324   /* Reset timing logic */
r4135r4136
327348   handle_lightpen(device);
328349}
329350
330
331351static WRITE8_DEVICE_HANDLER( peplus_crtc_display_w )
332352{
333353   videoram[vid_address] = data;
334354   palette_ram[vid_address] = io_port[1];
355   palette_ram2[vid_address] = io_port[3];
356
335357   tilemap_mark_tile_dirty(bg_tilemap, vid_address);
336358
337359   /* An access here triggers a device read !*/
r4135r4136
350372
351373static WRITE8_HANDLER( peplus_cmos_w )
352374{
375   char bank_name[5];
376
377   /* Test for Wingboard PAL Trigger Condition */
378   if (offset == 0x1fff && wingboard && data < 5)
379   {
380      sprintf(bank_name, "user%d", data + 1);
381      peplus_load_superdata(space->machine, bank_name);
382   }
383
353384   cmos_ram[offset] = data;
354385}
355386
r4135r4136
513544   UINT8 coin_optics = 0x00;
514545    UINT8 coin_out = 0x00;
515546   UINT64 curr_cycles = cpu_get_total_cycles(space->cpu);
547   UINT16 door_wait = 500;
516548
517549   UINT8 sda = 0;
518550   if(!sda_dir)
r4135r4136
555587         break;
556588   }
557589
558   if (curr_cycles - last_door > 6000/12) { // Guessing with 6000
590   if (wingboard)
591      door_wait = 12345;
592
593   if (curr_cycles - last_door > door_wait) {
559594      if ((input_port_read_safe(space->machine, "DOOR",0xff) & 0x01) == 0x01) {
560595         door_open = (!door_open & 0x01);
561596      } else {
r4135r4136
603638static TILE_GET_INFO( get_bg_tile_info )
604639{
605640   int pr = palette_ram[tile_index];
641   int pr2 = palette_ram2[tile_index];
606642   int vr = videoram[tile_index];
607643
608644   int code = ((pr & 0x0f)*256) | vr;
609645   int color = (pr>>4) & 0x0f;
610646
647   // Access 2nd Half of CGs and CAP
648   if (jumper_e16_e17 && (pr2 & 0x10) == 0x10)
649   {
650      code += 0x1000;
651      color += 0x10;
652   }
653
611654   SET_TILE_INFO(0, code, color, 0);
612655}
613656
r4135r4136
616659   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 40, 25);
617660   palette_ram = auto_malloc(0x3000);
618661   memset(palette_ram, 0, 0x3000);
662   palette_ram2 = auto_malloc(0x3000);
663   memset(palette_ram2, 0, 0x3000);
619664}
620665
621666static VIDEO_UPDATE( peplus )
r4135r4136
662707}
663708
664709
665/*************************
666*    Graphics Layouts    *
667*************************/
668
669static const gfx_layout charlayout =
670{
671   8,8,    /* 8x8 characters */
672   0x1000, /* 4096 characters */
673   4,  /* 4 bitplanes */
674   { 0x1000*8*8*3, 0x1000*8*8*2, 0x1000*8*8*1, 0x1000*8*8*0 }, /* bitplane offsets */
675   { 0, 1, 2, 3, 4, 5, 6, 7 },
676   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
677   8*8
678};
679
680
681710/******************************
682711* Graphics Decode Information *
683712******************************/
684713
685714static GFXDECODE_START( peplus )
686   GFXDECODE_ENTRY( "gfx1", 0x00000, charlayout, 0, 16 )
715         GFXDECODE_ENTRY( "gfx1", 0x00000, gfx_8x8x4_planar, 0, 16 )
687716GFXDECODE_END
688717
689718
r4135r4136
752781   AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P3) AM_READ(peplus_io_r) AM_WRITE(peplus_io_w) AM_BASE(&io_port)
753782ADDRESS_MAP_END
754783
784
755785/*************************
756786*      Input ports       *
757787*************************/
r4135r4136
9951025   MDRV_NVRAM_HANDLER(peplus)
9961026
9971027   // video hardware
998
9991028   MDRV_SCREEN_ADD("main", RASTER)
10001029   MDRV_SCREEN_REFRESH_RATE(60)
10011030   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
r4135r4136
10031032   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 25*8-1)
10041033
10051034   MDRV_GFXDECODE(peplus)
1006   MDRV_PALETTE_LENGTH(16*16)
1035   MDRV_PALETTE_LENGTH(16*16*2)
10071036
10081037   MDRV_MC6845_ADD("crtc", R6545_1, MC6845_CLOCK, mc6845_intf)
10091038
r4135r4136
10121041   MDRV_VIDEO_UPDATE(peplus)
10131042
10141043   // sound hardware
1015   MDRV_SOUND_ADD("ay", AY8912, 20000000/12)
1044   MDRV_SOUND_ADD("ay", AY8912, SOUND_CLOCK)
10161045   MDRV_SPEAKER_STANDARD_MONO("mono")
10171046   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
10181047MACHINE_DRIVER_END
r4135r4136
10401069/* Normal board */
10411070static DRIVER_INIT( peplus )
10421071{
1072   wingboard = FALSE;
1073   jumper_e16_e17 = FALSE;
10431074   peplus_init(machine);
10441075}
10451076
10461077/* Superboard */
10471078static DRIVER_INIT( peplussb )
10481079{
1049    UINT8 *super_data = memory_region(machine, "user1");
1080   wingboard = FALSE;
1081   jumper_e16_e17 = FALSE;
1082   peplus_load_superdata(machine, "user1");
10501083
1051    /* Distribute Superboard Data */
1052    memcpy(s3000_ram, &super_data[0x3000], 0x1000);
1053    memcpy(s5000_ram, &super_data[0x5000], 0x1000);
1054    memcpy(s7000_ram, &super_data[0x7000], 0x1000);
1055    memcpy(sb000_ram, &super_data[0xb000], 0x1000);
1056    memcpy(sd000_ram, &super_data[0xd000], 0x1000);
1057    memcpy(sf000_ram, &super_data[0xf000], 0x1000);
1084   peplus_init(machine);
1085}
10581086
1087/* Superboard with Attached Wingboard */
1088static DRIVER_INIT( peplussbw )
1089{
1090   wingboard = TRUE;
1091   jumper_e16_e17 = TRUE;
1092   peplus_load_superdata(machine, "user1");
1093
10591094   peplus_init(machine);
10601095}
10611096
1097
10621098/*************************
10631099*        Rom Load        *
10641100*************************/
r4135r4136
10671103   ROM_REGION( 0x10000, "main", 0 )
10681104   ROM_LOAD( "set038.u68",   0x00000, 0x10000, CRC(9c4b1d1a) SHA1(8a65cd1d8e2d74c7b66f4dfc73e7afca8458e979) )
10691105
1070   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1106   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
10711107   ROM_LOAD( "mro-cg740.u72",    0x00000, 0x8000, CRC(72667f6c) SHA1(89843f472cc0329317cfc643c63bdfd11234b194) )
10721108   ROM_LOAD( "mgo-cg740.u73",    0x08000, 0x8000, CRC(7437254a) SHA1(bba166dece8af58da217796f81117d0b05752b87) )
10731109   ROM_LOAD( "mbo-cg740.u74",    0x10000, 0x8000, CRC(92e8c33e) SHA1(05344664d6fdd3f4205c50fa4ca76fc46c18cf8f) )
10741110   ROM_LOAD( "mxo-cg740.u75",    0x18000, 0x8000, CRC(ce4cbe0b) SHA1(4bafcd68be94a5deaae9661584fa0fc940b834bb) )
10751111
1076   ROM_REGION( 0x100, "proms", 0 )
1077   ROM_LOAD( "cap740.u50", 0x0000, 0x0100, CRC(6fe619c4) SHA1(49e43dafd010ce0fe9b2a63b96a4ddedcb933c6d) )
1112   ROM_REGION( 0x200, "proms", 0 )
1113   ROM_LOAD( "cap740.u50", 0x0000, 0x0200, CRC(8020b65f) SHA1(e280b11315acba88799d8875fb2980bee9d5e687) )
10781114ROM_END
10791115
10801116ROM_START( pepp0065 ) /* Normal board : Jokers Wild Poker (PP0065) */
10811117   ROM_REGION( 0x10000, "main", 0 )
10821118   ROM_LOAD( "pp0065.u68",   0x00000, 0x10000, CRC(76c1a367) SHA1(ea8be9241e9925b5a4206db6875e1572f85fa5fe) )
10831119
1084   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1120   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
10851121   ROM_LOAD( "mro-cg740.u72",    0x00000, 0x8000, CRC(72667f6c) SHA1(89843f472cc0329317cfc643c63bdfd11234b194) )
10861122   ROM_LOAD( "mgo-cg740.u73",    0x08000, 0x8000, CRC(7437254a) SHA1(bba166dece8af58da217796f81117d0b05752b87) )
10871123   ROM_LOAD( "mbo-cg740.u74",    0x10000, 0x8000, CRC(92e8c33e) SHA1(05344664d6fdd3f4205c50fa4ca76fc46c18cf8f) )
10881124   ROM_LOAD( "mxo-cg740.u75",    0x18000, 0x8000, CRC(ce4cbe0b) SHA1(4bafcd68be94a5deaae9661584fa0fc940b834bb) )
10891125
1090   ROM_REGION( 0x100, "proms", 0 )
1091   ROM_LOAD( "cap740.u50", 0x0000, 0x0100, CRC(6fe619c4) SHA1(49e43dafd010ce0fe9b2a63b96a4ddedcb933c6d) )
1126   ROM_REGION( 0x200, "proms", 0 )
1127   ROM_LOAD( "cap740.u50", 0x0000, 0x0200, CRC(8020b65f) SHA1(e280b11315acba88799d8875fb2980bee9d5e687) )
10921128ROM_END
10931129
10941130ROM_START( pepp0158 ) /* Normal board : 4 of a Kind Bonus Poker (PP0158) */
10951131   ROM_REGION( 0x10000, "main", 0 )
10961132   ROM_LOAD( "pp0158.u68",   0x00000, 0x10000, CRC(5976cd19) SHA1(6a461ea9ddf78dffa3cf8b65903ebf3127f23d45) )
10971133
1098   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1134   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
10991135   ROM_LOAD( "mro-cg740.u72",    0x00000, 0x8000, CRC(72667f6c) SHA1(89843f472cc0329317cfc643c63bdfd11234b194) )
11001136   ROM_LOAD( "mgo-cg740.u73",    0x08000, 0x8000, CRC(7437254a) SHA1(bba166dece8af58da217796f81117d0b05752b87) )
11011137   ROM_LOAD( "mbo-cg740.u74",    0x10000, 0x8000, CRC(92e8c33e) SHA1(05344664d6fdd3f4205c50fa4ca76fc46c18cf8f) )
11021138   ROM_LOAD( "mxo-cg740.u75",    0x18000, 0x8000, CRC(ce4cbe0b) SHA1(4bafcd68be94a5deaae9661584fa0fc940b834bb) )
11031139
1104   ROM_REGION( 0x100, "proms", 0 )
1105   ROM_LOAD( "cap740.u50", 0x0000, 0x0100, CRC(6fe619c4) SHA1(49e43dafd010ce0fe9b2a63b96a4ddedcb933c6d) )
1140   ROM_REGION( 0x200, "proms", 0 )
1141   ROM_LOAD( "cap740.u50", 0x0000, 0x0200, CRC(8020b65f) SHA1(e280b11315acba88799d8875fb2980bee9d5e687) )
11061142ROM_END
11071143
11081144ROM_START( pepp0188 ) /* Normal board : Standard Draw Poker (PP0188) */
11091145   ROM_REGION( 0x10000, "main", 0 )
11101146   ROM_LOAD( "pp0188.u68",   0x00000, 0x10000, CRC(cf36a53c) SHA1(99b578538ab24d9ff91971b1f77599272d1dbfc6) )
11111147
1112   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1148   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
11131149   ROM_LOAD( "mro-cg740.u72",    0x00000, 0x8000, CRC(72667f6c) SHA1(89843f472cc0329317cfc643c63bdfd11234b194) )
11141150   ROM_LOAD( "mgo-cg740.u73",    0x08000, 0x8000, CRC(7437254a) SHA1(bba166dece8af58da217796f81117d0b05752b87) )
11151151   ROM_LOAD( "mbo-cg740.u74",    0x10000, 0x8000, CRC(92e8c33e) SHA1(05344664d6fdd3f4205c50fa4ca76fc46c18cf8f) )
11161152   ROM_LOAD( "mxo-cg740.u75",    0x18000, 0x8000, CRC(ce4cbe0b) SHA1(4bafcd68be94a5deaae9661584fa0fc940b834bb) )
11171153
1118   ROM_REGION( 0x100, "proms", 0 )
1119   ROM_LOAD( "cap740.u50", 0x0000, 0x0100, CRC(6fe619c4) SHA1(49e43dafd010ce0fe9b2a63b96a4ddedcb933c6d) )
1154   ROM_REGION( 0x200, "proms", 0 )
1155   ROM_LOAD( "cap740.u50", 0x0000, 0x0200, CRC(8020b65f) SHA1(e280b11315acba88799d8875fb2980bee9d5e687) )
11201156ROM_END
11211157
11221158ROM_START( pepp0250 ) /* Normal board : Double Down Stud Poker (PP0250) */
11231159   ROM_REGION( 0x10000, "main", 0 )
11241160   ROM_LOAD( "pp0250.u68",   0x00000, 0x10000, CRC(4c919598) SHA1(fe73503c6ccb3c5746fb96be58cd5b740c819713) )
11251161
1126   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1162   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
11271163   ROM_LOAD( "mro-cg740.u72",    0x00000, 0x8000, CRC(72667f6c) SHA1(89843f472cc0329317cfc643c63bdfd11234b194) )
11281164   ROM_LOAD( "mgo-cg740.u73",    0x08000, 0x8000, CRC(7437254a) SHA1(bba166dece8af58da217796f81117d0b05752b87) )
11291165   ROM_LOAD( "mbo-cg740.u74",    0x10000, 0x8000, CRC(92e8c33e) SHA1(05344664d6fdd3f4205c50fa4ca76fc46c18cf8f) )
11301166   ROM_LOAD( "mxo-cg740.u75",    0x18000, 0x8000, CRC(ce4cbe0b) SHA1(4bafcd68be94a5deaae9661584fa0fc940b834bb) )
11311167
1132   ROM_REGION( 0x100, "proms", 0 )
1133   ROM_LOAD( "cap740.u50", 0x0000, 0x0100, CRC(6fe619c4) SHA1(49e43dafd010ce0fe9b2a63b96a4ddedcb933c6d) )
1168   ROM_REGION( 0x200, "proms", 0 )
1169   ROM_LOAD( "cap740.u50", 0x0000, 0x0200, CRC(8020b65f) SHA1(e280b11315acba88799d8875fb2980bee9d5e687) )
11341170ROM_END
11351171
11361172ROM_START( pepp0447 ) /* Normal board : Standard Draw Poker (PP0447) */
11371173   ROM_REGION( 0x10000, "main", 0 )
11381174   ROM_LOAD( "pp0447.u68",   0x00000, 0x10000, CRC(0ef0bb6c) SHA1(d0ef7a83417054f05d32d0a93ed0d5d618f4dfb9) )
11391175
1140   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1176   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
11411177   ROM_LOAD( "mro-cg740.u72",    0x00000, 0x8000, CRC(72667f6c) SHA1(89843f472cc0329317cfc643c63bdfd11234b194) )
11421178   ROM_LOAD( "mgo-cg740.u73",    0x08000, 0x8000, CRC(7437254a) SHA1(bba166dece8af58da217796f81117d0b05752b87) )
11431179   ROM_LOAD( "mbo-cg740.u74",    0x10000, 0x8000, CRC(92e8c33e) SHA1(05344664d6fdd3f4205c50fa4ca76fc46c18cf8f) )
11441180   ROM_LOAD( "mxo-cg740.u75",    0x18000, 0x8000, CRC(ce4cbe0b) SHA1(4bafcd68be94a5deaae9661584fa0fc940b834bb) )
11451181
1146   ROM_REGION( 0x100, "proms", 0 )
1147   ROM_LOAD( "cap740.u50", 0x0000, 0x0100, CRC(6fe619c4) SHA1(49e43dafd010ce0fe9b2a63b96a4ddedcb933c6d) )
1182   ROM_REGION( 0x200, "proms", 0 )
1183   ROM_LOAD( "cap740.u50", 0x0000, 0x0200, CRC(8020b65f) SHA1(e280b11315acba88799d8875fb2980bee9d5e687) )
11481184ROM_END
11491185
11501186ROM_START( pepp0516 ) /* Normal board : Double Bonus Poker (PP0516) */
11511187   ROM_REGION( 0x10000, "main", 0 )
11521188   ROM_LOAD( "pp0516.u68",   0x00000, 0x10000, CRC(d9da6e13) SHA1(421678d9cb42daaf5b21074cc3900db914dd26cf) )
11531189
1154   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1190   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
11551191   ROM_LOAD( "mro-cg740.u72",    0x00000, 0x8000, CRC(72667f6c) SHA1(89843f472cc0329317cfc643c63bdfd11234b194) )
11561192   ROM_LOAD( "mgo-cg740.u73",    0x08000, 0x8000, CRC(7437254a) SHA1(bba166dece8af58da217796f81117d0b05752b87) )
11571193   ROM_LOAD( "mbo-cg740.u74",    0x10000, 0x8000, CRC(92e8c33e) SHA1(05344664d6fdd3f4205c50fa4ca76fc46c18cf8f) )
11581194   ROM_LOAD( "mxo-cg740.u75",    0x18000, 0x8000, CRC(ce4cbe0b) SHA1(4bafcd68be94a5deaae9661584fa0fc940b834bb) )
11591195
1160   ROM_REGION( 0x100, "proms", 0 )
1161   ROM_LOAD( "cap740.u50", 0x0000, 0x0100, CRC(6fe619c4) SHA1(49e43dafd010ce0fe9b2a63b96a4ddedcb933c6d) )
1196   ROM_REGION( 0x200, "proms", 0 )
1197   ROM_LOAD( "cap740.u50", 0x0000, 0x0200, CRC(8020b65f) SHA1(e280b11315acba88799d8875fb2980bee9d5e687) )
11621198ROM_END
11631199
11641200ROM_START( pebe0014 ) /* Normal board : Blackjack (BE0014) */
11651201   ROM_REGION( 0x10000, "main", 0 )
11661202   ROM_LOAD( "be0014.u68",   0x00000, 0x10000, CRC(232b32b7) SHA1(a3af9414577642fedc23b4c1911901cd31e9d6e0) )
11671203
1168   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1204   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
11691205   ROM_LOAD( "mro-cg2036.u72",    0x00000, 0x8000, CRC(0a168d06) SHA1(7ed4fb5c7bcacab077bcec030f0465c6eaf3ce1c) )
11701206   ROM_LOAD( "mgo-cg2036.u73",    0x08000, 0x8000, CRC(826b4090) SHA1(34390484c0faffe9340fd93d273b9292d09f97fd) )
11711207   ROM_LOAD( "mbo-cg2036.u74",    0x10000, 0x8000, CRC(46aac851) SHA1(28d84b49c6cebcf2894b5a15d935618f84093caa) )
11721208   ROM_LOAD( "mxo-cg2036.u75",    0x18000, 0x8000, CRC(60204a56) SHA1(2e3420da9e79ba304ca866d124788f84861380a7) )
11731209
1174   ROM_REGION( 0x100, "proms", 0 )
1175   ROM_LOAD( "cap707.u50", 0x0000, 0x0100, CRC(9851ba36) SHA1(5a0a43c1e212ae8c173102ede9c57a3d95752f99) )
1210   ROM_REGION( 0x200, "proms", 0 )
1211   ROM_LOAD( "cap707.u50", 0x0000, 0x0200, CRC(5bfeed62) SHA1(df47a2723a70a7c16fbf03b9f614e9b98751a59e) )
11761212ROM_END
11771213
11781214ROM_START( peke1012 ) /* Normal board : Keno (KE1012) */
11791215   ROM_REGION( 0x10000, "main", 0 )
11801216   ROM_LOAD( "ke1012.u68",   0x00000, 0x10000, CRC(470e8c10) SHA1(f8a65a3a73477e9e9d2f582eeefa93b470497dfa) )
11811217
1182   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE ) // BAD DUMPS
1218   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE ) // BAD DUMPS
11831219   ROM_LOAD( "mro-cg1267.u72",    0x00000, 0x8000, CRC(16498b57) SHA1(9c22726299af7204c4be1c6d8afc4c1b512ad918) )
11841220   ROM_LOAD( "mgo-cg1267.u73",    0x08000, 0x8000, CRC(80847c5a) SHA1(8422cd13a91c3c462af5efcfca8615e7eeaa2e52) )
11851221   ROM_LOAD( "mbo-cg1267.u74",    0x10000, 0x8000, CRC(ce7af8a7) SHA1(38675122c764b8fa9260246ea99ac0f0750da277) )
11861222   ROM_LOAD( "mxo-cg1267.u75",    0x18000, 0x8000, CRC(3aac0d4a) SHA1(764da54bdb2f2c49551cf1d10286de9450abad2f) )
11871223
1188   ROM_REGION( 0x100, "proms", 0 )
1189   ROM_LOAD( "cap1267.u50", 0x0000, 0x0100, CRC(7051db57) SHA1(76751a3cc47d506983205decb07e99ca0c178a42) )
1224   ROM_REGION( 0x200, "proms", 0 )
1225   ROM_LOAD( "cap1267.u50", 0x0000, 0x0200, CRC(3dac264f) SHA1(e9c9de42ffd64d4463bee6fa10886a53bc062ff8) )
11901226ROM_END
11911227
11921228ROM_START( peps0014 ) /* Normal board : Super Joker Slots (PS0014) */
11931229   ROM_REGION( 0x10000, "main", 0 )
11941230   ROM_LOAD( "ps0014.u68",   0x00000, 0x10000, CRC(368c3f58) SHA1(ebefcefbb5386659680719936bff72ad61087343) )
11951231
1196   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1232   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
11971233   ROM_LOAD( "mro-cg0916.u72",    0x00000, 0x8000, CRC(d97049d9) SHA1(78f7bb33866ca92922a8b83d5f9ac459edd39176) )
11981234   ROM_LOAD( "mgo-cg0916.u73",    0x08000, 0x8000, CRC(6e075788) SHA1(e8e9d8b7943d62e31d1d58f870bc765cba65c203) )
11991235   ROM_LOAD( "mbo-cg0916.u74",    0x10000, 0x8000, CRC(a5cdf0f3) SHA1(23b2749fd2cb5b8462ce7c912005779b611f32f9) )
12001236   ROM_LOAD( "mxo-cg0916.u75",    0x18000, 0x8000, CRC(1f3a2d72) SHA1(8e07324d436980b628e007d30a835757c1f70f6d) )
12011237
1202   ROM_REGION( 0x100, "proms", 0 )
1203   ROM_LOAD( "cap0916.u50", 0x0000, 0x0100, CRC(b9a5ee21) SHA1(d3c952f594baca9dc234602d90c506dd537c4dcc) )
1238   ROM_REGION( 0x200, "proms", 0 )
1239   ROM_LOAD( "cap0916.u50", 0x0000, 0x0200, CRC(c9a4f87c) SHA1(3c7c53fbf7573f07b334e0529bfd7ccf8d5339b5) )
12041240ROM_END
12051241
12061242ROM_START( peps0022 ) /* Normal board : Red White & Blue Slots (PS0022) */
12071243   ROM_REGION( 0x10000, "main", 0 )
12081244   ROM_LOAD( "ps0022.u68",   0x00000, 0x10000, CRC(d65c0939) SHA1(d91f472a43f77f9df8845e97561540f988e522e3) )
12091245
1210   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1246   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
12111247   ROM_LOAD( "mro-cg0960.u72",    0x00000, 0x8000, CRC(8c38c6fd) SHA1(5d6e9ac18b9b3f1253bba080bef1c067b2fdd7a8) )
12121248   ROM_LOAD( "mgo-cg0960.u73",    0x08000, 0x8000, CRC(b4f44163) SHA1(1bc635a5160fdff2882c8362644aebf983a1a427) )
12131249   ROM_LOAD( "mbo-cg0960.u74",    0x10000, 0x8000, CRC(8057e3a8) SHA1(5510872b1607daaf890603e76a8a47680e639e8e) )
12141250   ROM_LOAD( "mxo-cg0960.u75",    0x18000, 0x8000, CRC(d57b4c25) SHA1(6ddfbaae87f9958642ddb95e581ac31e1dd55608) )
12151251
1216   ROM_REGION( 0x100, "proms", 0 )
1217   ROM_LOAD( "cap0960.u50", 0x0000, 0x0100, CRC(00dd8d0a) SHA1(542763b12aeb0aec2b410f7c075c52907f45d171) )
1252   ROM_REGION( 0x200, "proms", 0 )
1253   ROM_LOAD( "cap0960.u50", 0x0000, 0x0200, CRC(83d67070) SHA1(4c50abbe750dbd4a461084b0bfc51e38df97e421) )
12181254ROM_END
12191255
12201256ROM_START( peps0043 ) /* Normal board : Double Diamond Slots (PS0043) */
12211257   ROM_REGION( 0x10000, "main", 0 )
12221258   ROM_LOAD( "ps0043.u68",   0x00000, 0x10000, CRC(d612429c) SHA1(95eb4774482a930066456d517fb2e4f67d4df4cb) )
12231259
1224   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1260   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
12251261   ROM_LOAD( "mro-cg1003.u72",    0x00000, 0x8000, CRC(41ce0395) SHA1(ae90dbae30e4efed33f83ee7038fb2e5171c1945) )
12261262   ROM_LOAD( "mgo-cg1003.u73",    0x08000, 0x8000, CRC(5a383fa1) SHA1(27b1febbdda7332e8d474fc0cca683f451a07090) )
12271263   ROM_LOAD( "mbo-cg1003.u74",    0x10000, 0x8000, CRC(5ec00224) SHA1(bb70a4326cd1810b200e193a449061df62085f37) )
12281264   ROM_LOAD( "mxo-cg1003.u75",    0x18000, 0x8000, CRC(2ffacd52) SHA1(38126ac4998806a1ddd55e6aa1942044240d41d0) )
12291265
1230   ROM_REGION( 0x100, "proms", 0 )
1231   ROM_LOAD( "cap1003.u50", 0x0000, 0x0100, CRC(cc400805) SHA1(f5ac48ad2a5df64da150f09f2ea5d910230bde56) )
1266   ROM_REGION( 0x200, "proms", 0 )
1267   ROM_LOAD( "cap1003.u50", 0x0000, 0x0200, CRC(1fb7b69f) SHA1(cdb609f39ef1ca0ddf389a599f799c269c7163f9) )
12321268ROM_END
12331269
12341270ROM_START( peps0045 ) /* Normal board : Red White & Blue Slots (PS0045) */
12351271   ROM_REGION( 0x10000, "main", 0 )
12361272   ROM_LOAD( "ps0045.u68",   0x00000, 0x10000, CRC(de180b84) SHA1(0d592d7d535b0aacbd62c18ac222da770fab7b85) )
12371273
1238   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1274   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
12391275   ROM_LOAD( "mro-cg0960.u72",    0x00000, 0x8000, CRC(8c38c6fd) SHA1(5d6e9ac18b9b3f1253bba080bef1c067b2fdd7a8) )
12401276   ROM_LOAD( "mgo-cg0960.u73",    0x08000, 0x8000, CRC(b4f44163) SHA1(1bc635a5160fdff2882c8362644aebf983a1a427) )
12411277   ROM_LOAD( "mbo-cg0960.u74",    0x10000, 0x8000, CRC(8057e3a8) SHA1(5510872b1607daaf890603e76a8a47680e639e8e) )
12421278   ROM_LOAD( "mxo-cg0960.u75",    0x18000, 0x8000, CRC(d57b4c25) SHA1(6ddfbaae87f9958642ddb95e581ac31e1dd55608) )
12431279
1244   ROM_REGION( 0x100, "proms", 0 )
1245   ROM_LOAD( "cap0960.u50", 0x0000, 0x0100, CRC(00dd8d0a) SHA1(542763b12aeb0aec2b410f7c075c52907f45d171) )
1280   ROM_REGION( 0x200, "proms", 0 )
1281   ROM_LOAD( "cap0960.u50", 0x0000, 0x0200, CRC(83d67070) SHA1(4c50abbe750dbd4a461084b0bfc51e38df97e421) )
12461282ROM_END
12471283
12481284ROM_START( peps0308 ) /* Normal board : Double Jackpot Slots (PS0308) */
12491285   ROM_REGION( 0x10000, "main", 0 )
12501286   ROM_LOAD( "ps0308.u68",   0x00000, 0x10000, CRC(fe30e081) SHA1(d216cbc6336727caf359e6b178c856ab2659cabd) )
12511287
1252   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1288   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
12531289   ROM_LOAD( "mro-cg0911.u72",    0x00000, 0x8000, CRC(48491b50) SHA1(9ec6d3ff34a08d40082a1347a46635838fd31afc) )
12541290   ROM_LOAD( "mgo-cg0911.u73",    0x08000, 0x8000, CRC(c1ff7d97) SHA1(78ab138ae9c7f9b3352f9b1ef5fbc473993bb8c8) )
12551291   ROM_LOAD( "mbo-cg0911.u74",    0x10000, 0x8000, CRC(202e0f9e) SHA1(51421dfd1b00a9e3b1e938d5bffaa3b7cd4c2b5e) )
12561292   ROM_LOAD( "mxo-cg0911.u75",    0x18000, 0x8000, CRC(d97740a2) SHA1(d76926d7fbbc24d2384a1079cb97e654600b134b) )
12571293
1258   ROM_REGION( 0x100, "proms", 0 )
1259   ROM_LOAD( "cap0911.u50", 0x0000, 0x0100, CRC(f117e781) SHA1(ba9d850c93e5f3abc26b0ba51f67fa7c07e05f59) )
1294   ROM_REGION( 0x200, "proms", 0 )
1295   ROM_LOAD( "cap0911.u50", 0x0000, 0x0200, CRC(79dc19c0) SHA1(9ebf998b73c3390cbb957b3dd3fec57b3c70a06d) )
12601296ROM_END
12611297
12621298ROM_START( peps0615 ) /* Normal board : Chaos Slots (PS0615) */
12631299   ROM_REGION( 0x10000, "main", 0 )
12641300   ROM_LOAD( "ps0615.u68",   0x00000, 0x10000, CRC(d27dd6ab) SHA1(b3f065f507191682edbd93b07b72ed87bf6ae9b1) )
12651301
1266   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1302   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
12671303   ROM_LOAD( "mro-cg2246.u72",    0x00000, 0x8000, CRC(7c08c355) SHA1(2a154b81c6d9671cea55a924bffb7f5461747142) )
12681304   ROM_LOAD( "mgo-cg2246.u73",    0x08000, 0x8000, CRC(b3c16487) SHA1(c97232fadd086f604eaeb3cd3c2d1c8fe0dcfa70) )
12691305   ROM_LOAD( "mbo-cg2246.u74",    0x10000, 0x8000, CRC(e61331f5) SHA1(4364edc625d64151cbae40780b54cb1981086647) )
12701306   ROM_LOAD( "mxo-cg2246.u75",    0x18000, 0x8000, CRC(f0f4a27d) SHA1(3a10ab196aeaa5b50d47b9d3c5b378cfadd6fe96) )
12711307
1272   ROM_REGION( 0x100, "proms", 0 ) // WRONG CAP
1273    ROM_LOAD( "cap0960.u50", 0x0000, 0x0100, CRC(00dd8d0a) SHA1(542763b12aeb0aec2b410f7c075c52907f45d171) )
1308   ROM_REGION( 0x200, "proms", 0 ) // WRONG CAP
1309    ROM_LOAD( "cap0960.u50", 0x0000, 0x0200, CRC(83d67070) SHA1(4c50abbe750dbd4a461084b0bfc51e38df97e421) )
12741310ROM_END
12751311
12761312ROM_START( peps0716 ) /* Normal board : River Gambler Slots (PS0716) */
12771313   ROM_REGION( 0x10000, "main", 0 )
12781314   ROM_LOAD( "ps0716.u68",   0x00000, 0x10000, CRC(7615d7b6) SHA1(91fe62eec720a0dc2ebf48835065148f19499d16) )
12791315
1280   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1316   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
12811317   ROM_LOAD( "mro-cg2266.u72",    0x00000, 0x8000, CRC(590accd8) SHA1(4e1c963c50799eaa49970e25ecf9cb01eb6b09e1) )
12821318   ROM_LOAD( "mgo-cg2266.u73",    0x08000, 0x8000, CRC(b87ffa05) SHA1(92126b670b9cabeb5e2cc35b6e9c458088b18eea) )
12831319   ROM_LOAD( "mbo-cg2266.u74",    0x10000, 0x8000, CRC(e3df30e1) SHA1(c7d2ae9a7c7e53bfb6197b635efcb5dc231e4fe0) )
12841320   ROM_LOAD( "mxo-cg2266.u75",    0x18000, 0x8000, CRC(56271442) SHA1(61ad0756b9f6412516e46ef6625a4c3899104d4e) )
12851321
1286   ROM_REGION( 0x100, "proms", 0 )
1287   ROM_LOAD( "cap2266.u50", 0x0000, 0x0100, CRC(5aaff103) SHA1(9cfda9c095cb77a8bb761c131a0f358e79b97abc) )
1322   ROM_REGION( 0x200, "proms", 0 )
1323   ROM_LOAD( "cap2266.u50", 0x0000, 0x0200, CRC(ae8b52ac) SHA1(f58d40ee77d7f432dfe5f37954e43cab654c9a4c) )
12881324ROM_END
12891325
12901326ROM_START( pex2069p ) /* Superboard : Double Double Bonus Poker (X002069P) */
r4135r4136
12941330   ROM_REGION( 0x10000, "user1", 0 )
12951331   ROM_LOAD( "x002069p.u66",   0x00000, 0x10000, CRC(875ecfcf) SHA1(80472cb43b36e518216e60a9b4883a81163718a2) )
12961332
1297   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1333   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
12981334   ROM_LOAD( "mro-cg2185.u77",    0x00000, 0x8000, CRC(7e64bd1a) SHA1(e988a380ee58078bf5bdc7747e83aed1393cfad8) )
12991335   ROM_LOAD( "mgo-cg2185.u78",    0x08000, 0x8000, CRC(d4127893) SHA1(75039c45ba6fd171a66876c91abc3191c7feddfc) )
13001336   ROM_LOAD( "mbo-cg2185.u79",    0x10000, 0x8000, CRC(17dba955) SHA1(5f77379c88839b3a04e235e4fb0120c77e17b60e) )
13011337   ROM_LOAD( "mxo-cg2185.u80",    0x18000, 0x8000, CRC(583eb3b1) SHA1(4a2952424969917fb1594698a779fe5a1e99bff5) )
13021338
1303   ROM_REGION( 0x100, "proms", 0 )
1304   ROM_LOAD( "cap1321.u43", 0x0000, 0x0100, CRC(1e19c0ff) SHA1(e48ebc4a3c88e8b8c9740841dac919e9bb2c4b7f) )
1339   ROM_REGION( 0x200, "proms", 0 )
1340   ROM_LOAD( "capx1321.u43", 0x0000, 0x0200, CRC(4b57569f) SHA1(fa29c0f627e7ce79951ec6dadec114864144f37d) )
13051341ROM_END
13061342
13071343ROM_START( pexp0019 ) /* Superboard : Deuces Wild Poker (XP000019) */
r4135r4136
13111347   ROM_REGION( 0x10000, "user1", 0 )
13121348   ROM_LOAD( "x002025p.u66",   0x00000, 0x10000, CRC(f3dac423) SHA1(e9394d330deb3b8a1001e57e72a506cd9098f161) )
13131349
1314   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1350   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
13151351   ROM_LOAD( "mro-cg2185.u77",    0x00000, 0x8000, CRC(7e64bd1a) SHA1(e988a380ee58078bf5bdc7747e83aed1393cfad8) )
13161352   ROM_LOAD( "mgo-cg2185.u78",    0x08000, 0x8000, CRC(d4127893) SHA1(75039c45ba6fd171a66876c91abc3191c7feddfc) )
13171353   ROM_LOAD( "mbo-cg2185.u79",    0x10000, 0x8000, CRC(17dba955) SHA1(5f77379c88839b3a04e235e4fb0120c77e17b60e) )
13181354   ROM_LOAD( "mxo-cg2185.u80",    0x18000, 0x8000, CRC(583eb3b1) SHA1(4a2952424969917fb1594698a779fe5a1e99bff5) )
13191355
1320   ROM_REGION( 0x100, "proms", 0 ) // WRONG CAP
1321   ROM_LOAD( "cap2234.u43", 0x0000, 0x0100, CRC(a930e283) SHA1(61bce50fa13b3e980ece3e72d068835e19bd5049) )
1356   ROM_REGION( 0x200, "proms", 0 ) // WRONG CAP
1357   ROM_LOAD( "capx2234.u43", 0x0000, 0x0200, CRC(519000fa) SHA1(31cd72643ca74a778418f944045e9e03937143d6) )
13221358ROM_END
13231359
13241360ROM_START( pexp0112 ) /* Superboard : White Hot Aces Poker (XP000112) */
r4135r4136
13281364   ROM_REGION( 0x10000, "user1", 0 )
13291365   ROM_LOAD( "x002035p.u66",   0x00000, 0x10000, CRC(dc3f0742) SHA1(d57cf3353b81f41895458019e47203f98645f17a) )
13301366
1331   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1367   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
13321368   ROM_LOAD( "mro-cg2324.u77",    0x00000, 0x8000, CRC(6eceef42) SHA1(a2ddd2a3290c41e510f483c6b633fe0002694d0b) )
13331369   ROM_LOAD( "mgo-cg2324.u78",    0x08000, 0x8000, CRC(26d0acbe) SHA1(09a9127deb88185cd5b748bac657461eadb2f48f) )
13341370   ROM_LOAD( "mbo-cg2324.u79",    0x10000, 0x8000, CRC(47baee32) SHA1(d8af09022ccb5fc06aa3aa4c200a734b66cbee00) )
13351371   ROM_LOAD( "mxo-cg2324.u80",    0x18000, 0x8000, CRC(60449fc0) SHA1(251d1e04786b70c1d2bc7b02f3b69cd58ac76398) )
13361372
1337   ROM_REGION( 0x100, "proms", 0 )
1338   ROM_LOAD( "cap2174.u43", 0x0000, 0x0100, CRC(cbff3f26) SHA1(9e145676f2871c2369042a13cbeabb7efe2728e1) )
1373   ROM_REGION( 0x200, "proms", 0 )
1374   ROM_LOAD( "capx2174.u43", 0x0000, 0x0200, CRC(50bdad55) SHA1(958d463c7effb3457c1f9c44c9b7822339c04e8b) )
13391375ROM_END
13401376
13411377ROM_START( pexs0006 ) /* Superboard : Triple Triple Diamond Slots (XS000006) */
r4135r4136
13451381   ROM_REGION( 0x10000, "user1", 0 )
13461382   ROM_LOAD( "x000998s.u66",   0x00000, 0x10000, CRC(e29d4346) SHA1(93901ff65c8973e34ac1f0dd68bb4c4973da5621) )
13471383
1348   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1384   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
13491385   ROM_LOAD( "mro-cg2361.u77",    0x00000, 0x8000, CRC(c0eba866) SHA1(8f217aeb3e8028a5633d95e5612f1b55e601650f) )
13501386   ROM_LOAD( "mgo-cg2361.u78",    0x08000, 0x8000, CRC(345eaea2) SHA1(18ebb94a323e1cf671201db8b9f85d4f30d8b5ec) )
13511387   ROM_LOAD( "mbo-cg2361.u79",    0x10000, 0x8000, CRC(fa130af6) SHA1(aca5e52e00bc75a4801fd3f6c564e62ed4251d8e) )
13521388   ROM_LOAD( "mxo-cg2361.u80",    0x18000, 0x8000, CRC(7de1812c) SHA1(c7e23a10f20fc8b618df21dd33ac456e1d2cfe33) )
13531389
1354   ROM_REGION( 0x100, "proms", 0 )
1355   ROM_LOAD( "cap2361.u43", 0x0000, 0x0100, CRC(051aea66) SHA1(2abf32caaeb821ca50a6398581de69bbfe5930e9) )
1390   ROM_REGION( 0x200, "proms", 0 )
1391   ROM_LOAD( "capx2361.u43", 0x0000, 0x0200, CRC(93057296) SHA1(534bbf8ee80a22822d577f6685501f4c929987ef) )
13561392ROM_END
13571393
13581394ROM_START( pexmp006 ) /* Superboard : Multi-Poker (XMP00006) */
r4135r4136
13621398   ROM_REGION( 0x10000, "user1", 0 )
13631399   ROM_LOAD( "xm00002p.u66",   0x00000, 0x10000, CRC(96cf471c) SHA1(9597bf6a80c392ee22dc4606db610fdaf032377f) )
13641400
1365   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
1401   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
13661402   ROM_LOAD( "mro-cg2174.u77",    0x00000, 0x8000, CRC(bb666733) SHA1(dcaa1980b051a554cb0f443b1183a680edc9ad3f) )
13671403   ROM_LOAD( "mgo-cg2174.u78",    0x08000, 0x8000, CRC(cc46adb0) SHA1(6065aa5dcb9091ad80e499c7ee6dc629e79c865a) )
13681404   ROM_LOAD( "mbo-cg2174.u79",    0x10000, 0x8000, CRC(7291a0c8) SHA1(1068f35e6ef5fd88c584922860231840a90fb623) )
13691405   ROM_LOAD( "mxo-cg2174.u80",    0x18000, 0x8000, CRC(14f9480c) SHA1(59323f9fc5995277aea86d088893b6eb95b4e89b) )
13701406
1371   ROM_REGION( 0x100, "proms", 0 )
1372   ROM_LOAD( "cap2174.u43", 0x0000, 0x0100, CRC(cbff3f26) SHA1(9e145676f2871c2369042a13cbeabb7efe2728e1) )
1407   ROM_REGION( 0x200, "proms", 0 )
1408   ROM_LOAD( "capx2174.u43", 0x0000, 0x0200, CRC(50bdad55) SHA1(958d463c7effb3457c1f9c44c9b7822339c04e8b) )
13731409ROM_END
13741410
1411ROM_START( pexmp017 ) /* Superboard : 5-in-1 Wingboard (XMP00017) */
1412   ROM_REGION( 0x10000, "main", 0 )
1413   ROM_LOAD( "xmp00017.u67",   0x00000, 0x10000, CRC(129e6eaa) SHA1(1dd2b83a672a618f338b553a6cbd598b6d4ce672) )
1414
1415   ROM_REGION( 0x10000, "user1", 0 )
1416   ROM_LOAD( "x000055p.u66",   0x00000, 0x10000, CRC(e06819df) SHA1(36590c4588b8036908e63714fbb3e77d23e60eae) )
1417   ROM_REGION( 0x10000, "user2", 0 )
1418   ROM_LOAD( "x000188p.u66",   0x00000, 0x10000, CRC(3eb7580e) SHA1(86f2280542fb8a55767efd391d0fb04a12ed9408) )
1419   ROM_REGION( 0x10000, "user3", 0 )
1420   ROM_LOAD( "x000581p.u66",   0x00000, 0x10000, CRC(a4cfecc3) SHA1(b2c805781ba43bda9e208d8c16578dc96b6f58f7) )
1421   ROM_REGION( 0x10000, "user4", 0 )
1422   ROM_LOAD( "x000727p.u66",   0x00000, 0x10000, CRC(4828474c) SHA1(9836b76113a71802df30ca15f7c9a5790e6f1c5b) )
1423   ROM_REGION( 0x10000, "user5", 0 )
1424   ROM_LOAD( "x002036p.u66",   0x00000, 0x10000, CRC(69207baf) SHA1(fe038b969106ae5cdc8dde1c06497be9c7b5b8bf) )
1425
1426   ROM_REGION( 0x040000, "gfx1", ROMREGION_DISPOSE )
1427   ROM_LOAD( "mro-cg2298.u77",    0x00000, 0x10000, CRC(8c35dc7f) SHA1(90e9566e816287e6248d7cab318dee3ad6fac871) )
1428   ROM_LOAD( "mgo-cg2298.u78",    0x10000, 0x10000, CRC(3663174a) SHA1(c203a4a59f6bc1625d47f35426ffc5b4d279251a) )
1429   ROM_LOAD( "mbo-cg2298.u79",    0x20000, 0x10000, CRC(9088cdbe) SHA1(dc62951c584463a1e795a774f5752f890d8e3f65) )
1430   ROM_LOAD( "mxo-cg2298.u80",    0x30000, 0x10000, CRC(8d3aafc8) SHA1(931bc82398b94c63ed9f6f1bd95723aa801894cc) )
1431
1432   ROM_REGION( 0x200, "proms", 0 )
1433   ROM_LOAD( "capx2298.u43", 0x0000, 0x0200, CRC(77856036) SHA1(820487c8494965408402ddee6a54511906218e66) )
1434ROM_END
1435
1436
13751437/*************************
13761438*      Game Drivers      *
13771439*************************/
r4135r4136
14121474/* Superboard : multi-poker */
14131475GAMEL(1995, pexmp006, 0,      peplus,  peplus_poker, peplussb, ROT0,  "IGT - International Gaming Technology", "Player's Edge Plus (XMP00006) Multi-Poker",                 0,   layout_pe_poker )
14141476
1477/* Superboard : multi-poker (wingboard) */
1478GAMEL(1995, pexmp017, 0,      peplus,  peplus_poker, peplussbw,ROT0,  "IGT - International Gaming Technology", "Player's Edge Plus (XMP00017) 5-in-1 Wingboard",            0,   layout_pe_poker )
1479
14151480/* Superboard : slots machine */
14161481GAMEL(1997, pexs0006, 0,      peplus,  peplus_slots, peplussb, ROT0,  "IGT - International Gaming Technology", "Player's Edge Plus (XS000006) Triple Triple Diamond Slots", 0,   layout_pe_slots )
src/mame/drivers/namcoic.c
r4135r4136
278278      {
279279         int shadow_offset = (machine->config->video_attributes&VIDEO_HAS_SHADOWS)?machine->config->total_colors:0;
280280         const pen_t *pal = &machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
281         UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
281         const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
282282         int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
283283         int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
284284         if (sprite_screen_width && sprite_screen_height)
r4135r4136
348348                  {
349349                     for( y=sy; y<ey; y++ )
350350                     {
351                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
351                        const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
352352                        UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
353353                        UINT8 *pri = BITMAP_ADDR8(priority_bitmap, y, 0);
354354                        int x, x_index = x_index_base;
r4135r4136
470470            int scaley = (sizey<<16)/((word0&0x0200)?0x20:0x10);
471471            if(scalex && scaley)
472472            {
473               gfx_element gfx = *machine->gfx[rgn];
473               gfx_element *gfx = machine->gfx[rgn];
474
474475               if( (word0&0x0200)==0 )
475               {
476                  gfx.width = 16;
477                  gfx.height = 16;
478                  if( word1&0x0001 ) gfx.gfxdata += 16;
479                  if( word1&0x0002 ) gfx.gfxdata += 16*gfx.line_modulo;
480               }
476                  gfx_element_set_source_clip(gfx, (word1&0x0001) ? 16 : 0, 16, (word1&0x0002) ? 16 : 0, 16);
477               else
478                  gfx_element_set_source_clip(gfx, 0, 32, 0, 32);
479
481480               zdrawgfxzoom(
482481                  machine,
483482                  bitmap,
484                  &gfx,
483                  gfx,
485484                  sprn,
486485                  color,
487486                  flipx,flipy,
488487                  xpos,ypos,
489488                  cliprect,
490489                  TRANSPARENCY_PEN,0xff,
491                  //(color==0x0f ? TRANSPARENCY_PEN_TABLE : TRANSPARENCY_PEN),0xff,
492490                  scalex,scaley,
493491                  loop );
494492            }
r4135r4136
15081506 *      0x1fffd             always 0xffff 0xffff?
15091507 */
15101508static UINT16 *mpRoadRAM; /* at 0x880000 in Final Lap; at 0xa00000 in Lucky&Wild */
1511static UINT8 *mpRoadDirty;
1512static int mbRoadSomethingIsDirty;
15131509static int mRoadGfxBank;
15141510static tilemap *mpRoadTilemap;
15151511static pen_t mRoadTransparentColor;
r4135r4136
15721568   else
15731569   {
15741570      offset -= 0x10000/2;
1575      if( offset<ROAD_TILE_COUNT_MAX*WORDS_PER_ROAD_TILE )
1576      {
1577         mpRoadDirty[offset/WORDS_PER_ROAD_TILE] = 1;
1578         mbRoadSomethingIsDirty = 1;
1579      }
1571      gfx_element_mark_dirty(space->machine->gfx[mRoadGfxBank], offset/WORDS_PER_ROAD_TILE);
15801572   }
15811573}
15821574
1583static void
1584UpdateRoad(running_machine *machine)
1585{
1586   int i;
1587   if( mbRoadSomethingIsDirty )
1588   {
1589      for( i=0; i<ROAD_TILE_COUNT_MAX; i++ )
1590      {
1591         if( mpRoadDirty[i] )
1592         {
1593            decodechar(
1594               machine->gfx[mRoadGfxBank],
1595               i,
1596               0x10000+(UINT8 *)mpRoadRAM);
1597            mpRoadDirty[i] = 0;
1598         }
1599      }
1600      tilemap_mark_all_tiles_dirty( mpRoadTilemap );
1601      mbRoadSomethingIsDirty = 0;
1602   }
1603}
1604
1605static STATE_POSTLOAD( RoadMarkAllDirty )
1606{
1607   memset( mpRoadDirty,0x01,ROAD_TILE_COUNT_MAX );
1608   mbRoadSomethingIsDirty = 1;
1609}
1610
16111575void
16121576namco_road_init(running_machine *machine, int gfxbank )
16131577{
1578   gfx_element *pGfx;
1579
16141580   mbRoadNeedTransparent = 0;
16151581   mRoadGfxBank = gfxbank;
1616   mpRoadDirty = auto_malloc(ROAD_TILE_COUNT_MAX);
1617   {
1618      memset( mpRoadDirty,0x00,ROAD_TILE_COUNT_MAX );
1619      mbRoadSomethingIsDirty = 0;
1620      mpRoadRAM = auto_malloc(0x20000);
1621      {
1622         gfx_element *pGfx = allocgfx( machine, &RoadTileLayout );
1623            decodegfx(pGfx, 0x10000+(UINT8 *)mpRoadRAM, 0, pGfx->total_elements);
1624            pGfx->color_base = 0xf00;
1625            pGfx->total_colors = 0x3f;
16261582
1627            machine->gfx[gfxbank] = pGfx;
1628            mpRoadTilemap = tilemap_create(machine,
1629               get_road_info,tilemap_scan_rows,
1630               ROAD_TILE_SIZE,ROAD_TILE_SIZE,
1631               ROAD_COLS,ROAD_ROWS);
1583   mpRoadRAM = auto_malloc(0x20000);
16321584
1633               state_save_register_global_pointer(machine, mpRoadDirty, ROAD_TILE_COUNT_MAX);
1634               state_save_register_global_pointer(machine, mpRoadRAM,   0x20000 / 2);
1635               state_save_register_postload(machine, RoadMarkAllDirty, NULL);
1585   pGfx = gfx_element_alloc( machine, &RoadTileLayout, 0x10000+(UINT8 *)mpRoadRAM, 0x3f, 0xf00);
16361586
1637      }
1638   }
1587   machine->gfx[gfxbank] = pGfx;
1588   mpRoadTilemap = tilemap_create(machine,
1589      get_road_info,tilemap_scan_rows,
1590      ROAD_TILE_SIZE,ROAD_TILE_SIZE,
1591      ROAD_COLS,ROAD_ROWS);
1592
1593   state_save_register_global_pointer(machine, mpRoadRAM,   0x20000 / 2);
16391594} /* namco_road_init */
16401595
16411596void
r4135r4136
16531608   unsigned yscroll;
16541609   int i;
16551610
1656   UpdateRoad(machine);
1657
16581611   pSourceBitmap = tilemap_get_pixmap(mpRoadTilemap);
16591612   yscroll = mpRoadRAM[0x1fdfe/2];
16601613
src/mame/drivers/neogeo.c
r4135r4136
11051105 *
11061106 *************************************/
11071107
1108static ym2610_interface ym2610_config =
1108static const ym2610_interface ym2610_config =
11091109{
11101110   audio_cpu_irq
11111111};
src/mame/drivers/konamigx.c
r4135r4136
18661866   ROM_LOAD( "321b18.7g", 0x200000, 2*1024*1024, CRC(2c561ad0) SHA1(6265054072ba1c2837dd96e0259b20bc50457160) )
18671867ROM_END
18681868
1869/* Salamander 2 */
1869/* Salamander 2 (ver JAA) */
18701870ROM_START( salmndr2 )
18711871   /* main program */
18721872   ROM_REGION( 0x800000, "main", 0 )
r4135r4136
18971897   ROM_LOAD( "521-a13.7g", 0x200000, 1*1024*1024, CRC(c3322475) SHA1(1774524ff031e0c4a7f3432810e968d37f9c6331) )
18981898ROM_END
18991899
1900/* Salamander 2 (ver AAB) */
1901ROM_START( salmnd2a )
1902   /* main program */
1903   ROM_REGION( 0x800000, "main", 0 )
1904   GX_BIOS
1905   ROM_LOAD32_WORD_SWAP( "521aab02.bin", 0x200002, 512*1024, CRC(ac9d151f) SHA1(aabd17a41a42cbbe9b62a9751cdb264e714cac6a) )
1906   ROM_LOAD32_WORD_SWAP( "521aab03.bin", 0x200000, 512*1024, CRC(feecf34d) SHA1(c37959199afedd3deee9d4c248ec83ccccf9a401) )
1907
1908   /* sound program */
1909   ROM_REGION( 0x40000, "sound", 0 )
1910   ROM_LOAD16_BYTE("521-a04.9c", 0x000000, 64*1024, CRC(efddca7a) SHA1(ac6b45044b6abeb2455ec21a61322185bf1c7219) )
1911   ROM_LOAD16_BYTE("521-a05.7c", 0x000001, 64*1024, CRC(51a3af2c) SHA1(94d220ae619d53747bd3e762000ed59cf1b4d305) )
1912
1913   /* tiles */
1914   ROM_REGION( 0x800000, "gfx1", ROMREGION_ERASE00 )
1915   TILE_WORDS2_ROM_LOAD("521-a09.17h", 0x000000, 2*1024*1024, CRC(fb9e2f5e) SHA1(acb41616625d6976ad50e184787ab74e29f86039) )
1916   TILE_WORDS2_ROM_LOAD("521-a11.15h", 0x300000, 1*1024*1024, CRC(25e0a6e5) SHA1(592e9f183f077e9272a4f0ead441b5bfd8029816) )
1917   TILE_BYTES2_ROM_LOAD("521-a13.13c", 0x000004, 2*1024*1024, CRC(3ed7441b) SHA1(57e3e8035c056cf46a383d228c76a7da7def134f) )
1918
1919   /* sprites */
1920   ROM_REGION( 0x600000, "gfx2", ROMREGION_ERASE00 )
1921   _48_WORD_ROM_LOAD( "521-a08.25g", 0x000000, 2*1024*1024, CRC(f24f76bd) SHA1(823f614d436901241743c923206cb61d8bbb5c58) )
1922   _48_WORD_ROM_LOAD( "521-a07.28g", 0x000002, 2*1024*1024, CRC(50ef9b7a) SHA1(104eac2bce43e99d4adc208145afe7be9156628e) )
1923   _48_WORD_ROM_LOAD( "521-a06.30g", 0x000004, 2*1024*1024, CRC(cba5db2c) SHA1(505efdf8571ae28d8788dcafbfffcfb67e3189ce) )
1924
1925   /* sound data */
1926   ROM_REGION( 0x400000, "shared", 0 )
1927   ROM_LOAD( "521-a12.9g", 0x000000, 2*1024*1024, CRC(66614d3b) SHA1(e1e5ebe546bced6ab74b0af500acf0f3308902a4) )
1928   ROM_LOAD( "521-a13.7g", 0x200000, 1*1024*1024, CRC(c3322475) SHA1(1774524ff031e0c4a7f3432810e968d37f9c6331) )
1929ROM_END
1930
19001931/* Twinbee Yahoo! */
19011932ROM_START( tbyahhoo )
19021933   /* main program */
r4135r4136
33103341   { "daiskiss",  7, 0, 5, BPP5 },
33113342   { "tokkae",    7, 0, 0, BPP5 },
33123343   { "salmndr2",  7, 0, 6, BPP66 },
3344   { "salmnd2a",  7, 0, 6, BPP66 },
33133345   { "winspike",  8, 2, 7, BPP4 },
33143346   { "winspikj",  8, 2, 7, BPP4 },
33153347   { "soccerss",  7, 0, 0, BPP4 },
r4135r4136
34583490GAME( 1996, tokkae,   konamigx, konamigx_6bpp, puzldama, konamigx, ROT0, "Konami", "Taisen Tokkae-dama (ver JAA)", GAME_IMPERFECT_GRAPHICS )
34593491/* protection controls player ship direction in attract mode - doesn't impact playability */
34603492GAME( 1996, salmndr2, konamigx, konamigx_6bpp_2, gokuparo, konamigx, ROT0, "Konami", "Salamander 2 (ver JAA)", GAME_IMPERFECT_GRAPHICS|GAME_UNEMULATED_PROTECTION )
3493GAME( 1996, salmnd2a, salmndr2, konamigx_6bpp_2, gokuparo, konamigx, ROT0, "Konami", "Salamander 2 (ver AAB)", GAME_IMPERFECT_GRAPHICS|GAME_UNEMULATED_PROTECTION )
34613494/* bad sprite colours, part of tilemap gets blanked out when a game starts (might be more protection) */
34623495GAME( 1997, winspike, konamigx, winspike, konamigx, konamigx, ROT0, "Konami", "Winning Spike (ver EAA)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_GRAPHICS )
34633496GAME( 1997, winspikj, winspike, winspike, konamigx, konamigx, ROT0, "Konami", "Winning Spike (ver JAA)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/segac2.c
r4135r4136
247247   return paletteram16[offset + palbank * 0x200];
248248}
249249
250UINT16* megadrive_vdp_palette_lookup_segac2;
251UINT16* megadrive_vdp_palette_lookup_sprite_segac2;
252UINT16* megadrive_vdp_palette_lookup_shadow_segac2;
253UINT16* megadrive_vdp_palette_lookup_highlight_segac2;
254
255
256250/* handle writes to the paletteram */
257251static WRITE16_HANDLER( palette_w )
258252{
r4135r4136
277271   /* set the color */
278272   palette_set_color_rgb(space->machine, offset, pal5bit(r), pal5bit(g), pal5bit(b));
279273
280   megadrive_vdp_palette_lookup_segac2[offset] = (b) | (g<<5) | (r<<10);
281   megadrive_vdp_palette_lookup_sprite_segac2[offset] = (b) | (g<<5) | (r<<10);
274   megadrive_vdp_palette_lookup[offset] = (b) | (g<<5) | (r<<10);
275   megadrive_vdp_palette_lookup_sprite[offset] = (b) | (g<<5) | (r<<10);
282276
283277   tmpr = r>>1;tmpg=g>>1;tmpb=b>>1;
284   megadrive_vdp_palette_lookup_shadow_segac2[offset] = (tmpb) | (tmpg<<5) | (tmpr<<10);
278   megadrive_vdp_palette_lookup_shadow[offset] = (tmpb) | (tmpg<<5) | (tmpr<<10);
285279
286280   // how is it calculated on c2?
287281   tmpr = tmpr|0x10;    tmpg = tmpg|0x10;    tmpb = tmpb|0x10;
288   megadrive_vdp_palette_lookup_highlight_segac2[offset] = (tmpb) | (tmpg<<5) | (tmpr<<10);
282   megadrive_vdp_palette_lookup_highlight[offset] = (tmpb) | (tmpg<<5) | (tmpr<<10);
289283}
290284
291285
r4135r4136
13471341    Sound interfaces
13481342******************************************************************************/
13491343
1350void  segac2_irq2_interrupt(running_machine *machine, int state)
1344static void  segac2_irq2_interrupt(running_machine *machine, int state)
13511345{
13521346   //printf("sound irq %d\n", state);
13531347   cpu_set_input_line(machine->cpu[0], 2, state ? ASSERT_LINE : CLEAR_LINE);
r4135r4136
13711365
13721366******************************************************************************/
13731367
1374VIDEO_START(segac2_new)
1368static VIDEO_START(segac2_new)
13751369{
13761370   VIDEO_START_CALL(megadriv);
13771371
13781372
1379   megadrive_vdp_palette_lookup_segac2 = auto_malloc(0x1000);
1380   megadrive_vdp_palette_lookup_sprite_segac2 = auto_malloc(0x1000);
1381   megadrive_vdp_palette_lookup_shadow_segac2 = auto_malloc(0x1000);
1382   megadrive_vdp_palette_lookup_highlight_segac2 = auto_malloc(0x1000);
1383
1384   megadrive_vdp_palette_lookup = megadrive_vdp_palette_lookup_segac2;
1385   megadrive_vdp_palette_lookup_sprite = megadrive_vdp_palette_lookup_sprite_segac2;
1386   megadrive_vdp_palette_lookup_shadow = megadrive_vdp_palette_lookup_shadow_segac2;
1387   megadrive_vdp_palette_lookup_highlight = megadrive_vdp_palette_lookup_highlight_segac2;
1388
1373   megadrive_vdp_palette_lookup = auto_malloc(0x1000);
1374   megadrive_vdp_palette_lookup_sprite = auto_malloc(0x1000);
1375   megadrive_vdp_palette_lookup_shadow = auto_malloc(0x1000);
1376   megadrive_vdp_palette_lookup_highlight = auto_malloc(0x1000);
13891377}
13901378
1391VIDEO_UPDATE(segac2_new)
1379static VIDEO_UPDATE(segac2_new)
13921380{
13931381   if (!segac2_enable_display)
13941382   {
src/mame/drivers/hng64.c
r4135r4136
622622   a = ((paletteram32[offset] & 0xff000000) >>24);
623623
624624   // a sure ain't alpha.
625   // alpha_set_level(mame_rand(space->machine)) ;
626625   // mame_printf_debug("Alpha : %d %d %d %d\n", a, b, g, r) ;
627626
628627   //if (a != 0)
src/mame/drivers/taito_l.c
r4135r4136
6060#include "includes/taito_l.h"
6161
6262
63static void (*const rambank_modify_notifiers[12])(running_machine *, int) =
63static const struct
6464{
65   taitol_chardef14_m,   // 14
66   taitol_chardef15_m,   // 15
67   taitol_chardef16_m,   // 16
68   taitol_chardef17_m,   // 17
65   void (*notifier)(running_machine *, int);
66   UINT32 offset;
67} rambank_modify_notifiers[12] =
68{
69   { taitol_chardef14_m, 0x0000 },   // 14
70   { taitol_chardef15_m, 0x1000 },   // 15
71   { taitol_chardef16_m, 0x2000 },   // 16
72   { taitol_chardef17_m, 0x3000 },   // 17
6973
70   taitol_bg18_m,      // 18
71   taitol_bg19_m,      // 19
72   taitol_char1a_m,   // 1a
73   taitol_obj1b_m,      // 1b
74   { taitol_bg18_m, 0x8000 },      // 18
75   { taitol_bg19_m, 0x9000 },      // 19
76   { taitol_char1a_m, 0xa000 },   // 1a
77   { taitol_obj1b_m, 0xb000 },      // 1b
7478
75   taitol_chardef1c_m,   // 1c
76   taitol_chardef1d_m,   // 1d
77   taitol_chardef1e_m,   // 1e
78   taitol_chardef1f_m,   // 1f
79   { taitol_chardef1c_m, 0x4000 },   // 1c
80   { taitol_chardef1d_m, 0x5000 },   // 1d
81   { taitol_chardef1e_m, 0x6000 },   // 1e
82   { taitol_chardef1f_m, 0x7000 },   // 1f
7983};
8084
8185static void (*current_notifier[4])(running_machine *, int);
r4135r4136
152156   cur_rombank = cur_rombank2 = 0;
153157   memory_set_bankptr(machine, 1, memory_region(machine, "main") + 0x10000);
154158
155   for(i=0;i<512;i++)
156   {
157      decodechar(machine->gfx[2], i, taitol_rambanks);
158      decodechar(machine->gfx[2], i+512, taitol_rambanks + 0x4000);
159   }
159   gfx_element_set_source(machine->gfx[2], taitol_rambanks);
160160
161161   adpcm_pos = 0;
162162   adpcm_data = -1;
r4135r4136
377377      if(data>=0x14 && data<=0x1f)
378378      {
379379         data -= 0x14;
380         current_notifier[offset] = rambank_modify_notifiers[data];
381         current_base[offset] = taitol_rambanks+0x1000*data;
380         current_notifier[offset] = rambank_modify_notifiers[data].notifier;
381         current_base[offset] = taitol_rambanks+rambank_modify_notifiers[data].offset;
382382      }
383383      else if (data == 0x80)
384384      {
src/mame/drivers/gamecstl.c
r4135r4136
105105static void draw_char(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y)
106106{
107107   int i,j;
108   UINT8 *dp;
108   const UINT8 *dp;
109109   int index = 0;
110   dp = gfx->gfxdata + ch * gfx->char_modulo;
110   dp = gfx_element_get_data(gfx, ch);
111111
112112   for (j=y; j < y+8; j++)
113113   {
src/mame/drivers/multigam.c
r4135r4136
4040*/
4141
4242#include "driver.h"
43#include "cpu/m6502/m6502.h"
44#include "sound/dac.h"
45#include "sound/nes_apu.h"
4346#include "video/ppu2c0x.h"
44#include "sound/nes_apu.h"
45#include "cpu/m6502/m6502.h"
4647
4748/******************************************************
4849
src/mame/drivers/nwk-tr.c
r4135r4136
243243
244244static UINT32 *K001604_tile_ram[MAX_K001604_CHIPS];
245245static UINT32 *K001604_char_ram[MAX_K001604_CHIPS];
246static UINT8 *K001604_dirty_map[MAX_K001604_CHIPS][2];
247static int K001604_gfx_index[MAX_K001604_CHIPS][2], K001604_char_dirty[MAX_K001604_CHIPS][2];
246static int K001604_gfx_index[MAX_K001604_CHIPS][2];
248247static tilemap *K001604_layer_8x8[MAX_K001604_CHIPS][2];
249248static int K001604_tilemap_offset;
250249static tilemap *K001604_layer_roz[MAX_K001604_CHIPS][2];
r4135r4136
422421
423422   K001604_tile_ram[chip] = auto_malloc(0x20000);
424423
425   K001604_dirty_map[chip][0] = auto_malloc(K001604_NUM_TILES_LAYER0);
426   K001604_dirty_map[chip][1] = auto_malloc(K001604_NUM_TILES_LAYER1);
427
428424   K001604_reg[chip] = auto_malloc(0x400);
429425
430426   if (chip == 0)
r4135r4136
453449
454450   memset(K001604_char_ram[chip], 0, 0x200000);
455451   memset(K001604_tile_ram[chip], 0, 0x10000);
456   memset(K001604_dirty_map[chip][0], 0, K001604_NUM_TILES_LAYER0);
457   memset(K001604_dirty_map[chip][1], 0, K001604_NUM_TILES_LAYER1);
458452   memset(K001604_reg[chip], 0, 0x400);
459453
460454
461   machine->gfx[K001604_gfx_index[chip][0]] = allocgfx(machine, &K001604_char_layout_layer_8x8);
462   decodegfx(machine->gfx[K001604_gfx_index[chip][0]], (UINT8*)&K001604_char_ram[chip][0], 0, machine->gfx[K001604_gfx_index[chip][0]]->total_elements);
463   machine->gfx[K001604_gfx_index[chip][1]] = allocgfx(machine, &K001604_char_layout_layer_16x16);
464   decodegfx(machine->gfx[K001604_gfx_index[chip][1]], (UINT8*)&K001604_char_ram[chip][0], 0, machine->gfx[K001604_gfx_index[chip][1]]->total_elements);
455   machine->gfx[K001604_gfx_index[chip][0]] = gfx_element_alloc(machine, &K001604_char_layout_layer_8x8, (UINT8*)&K001604_char_ram[chip][0], machine->config->total_colors / 16, 0);
456   machine->gfx[K001604_gfx_index[chip][1]] = gfx_element_alloc(machine, &K001604_char_layout_layer_16x16, (UINT8*)&K001604_char_ram[chip][0], machine->config->total_colors / 16, 0);
465457
466   machine->gfx[K001604_gfx_index[chip][0]]->total_colors = machine->config->total_colors / 16;
467   machine->gfx[K001604_gfx_index[chip][1]]->total_colors = machine->config->total_colors / 16;
468
469458   return 0;
470459}
471460
472void K001604_tile_update(running_machine *machine, int chip)
473{
474   if(K001604_char_dirty[chip][0])
475   {
476      int i;
477      for (i=0; i < K001604_NUM_TILES_LAYER0; i++)
478      {
479         if(K001604_dirty_map[chip][0][i])
480         {
481            K001604_dirty_map[chip][0][i] = 0;
482            decodechar(machine->gfx[K001604_gfx_index[chip][0]], i, (UINT8*)&K001604_char_ram[chip][0]);
483         }
484      }
485      tilemap_mark_all_tiles_dirty(K001604_layer_8x8[chip][0]);
486      tilemap_mark_all_tiles_dirty(K001604_layer_8x8[chip][1]);
487
488      if (K001604_roz_size[chip] == 0)
489      {
490         tilemap_mark_all_tiles_dirty(K001604_layer_roz[chip][0]);
491         tilemap_mark_all_tiles_dirty(K001604_layer_roz[chip][1]);
492      }
493      K001604_char_dirty[chip][0] = 0;
494   }
495   if(K001604_char_dirty[chip][1])
496   {
497      int i;
498      for (i=0; i < K001604_NUM_TILES_LAYER1; i++)
499      {
500         if(K001604_dirty_map[chip][1][i])
501         {
502            K001604_dirty_map[chip][1][i] = 0;
503            decodechar(machine->gfx[K001604_gfx_index[chip][1]], i, (UINT8*)&K001604_char_ram[chip][0]);
504         }
505      }
506
507      if (K001604_roz_size[chip] == 1)
508      {
509         tilemap_mark_all_tiles_dirty(K001604_layer_roz[chip][0]);
510         tilemap_mark_all_tiles_dirty(K001604_layer_roz[chip][1]);
511      }
512      K001604_char_dirty[chip][1] = 0;
513   }
514}
515
516461void K001604_draw_back_layer(int chip, bitmap_t *bitmap, const rectangle *cliprect)
517462{
518463   int layer;
r4135r4136
659604
660605   COMBINE_DATA(K001604_char_ram[chip] + addr);
661606
662   K001604_dirty_map[chip][0][addr / 32] = 1;
663   K001604_char_dirty[chip][0] = 1;
664
665   K001604_dirty_map[chip][1][addr / 128] = 1;
666   K001604_char_dirty[chip][1] = 1;
607   gfx_element_mark_dirty(space->machine->gfx[K001604_gfx_index[chip][0]], addr / 32);
608   gfx_element_mark_dirty(space->machine->gfx[K001604_gfx_index[chip][1]], addr / 128);
667609}
668610
669611
r4135r4136
724666
725667   voodoo_update(voodoo, bitmap, cliprect);
726668
727   K001604_tile_update(screen->machine, 0);
728669   K001604_draw_front_layer(0, bitmap, cliprect);
729670
730671   draw_7segment_led(bitmap, 3, 3, led_reg0);
src/mame/drivers/zac2650.c
r4135r4136
1818WRITE8_HANDLER( tinvader_videoram_w );
1919static WRITE8_HANDLER( tinvader_sound_w );
2020READ8_HANDLER( zac_s2636_r );
21WRITE8_HANDLER( zac_s2636_w );
2122READ8_HANDLER( tinvader_port_0_r );
2223
2324VIDEO_START( tinvader );
r4135r4136
3334    AM_RANGE(0x1e82, 0x1e82) AM_READ_PORT("1E82")
3435   AM_RANGE(0x1e85, 0x1e85) AM_READ_PORT("1E85")               /* Dodgem Only */
3536   AM_RANGE(0x1e86, 0x1e86) AM_READ_PORT("1E86") AM_WRITENOP      /* Dodgem Only */
36   AM_RANGE(0x1f00, 0x1fff) AM_READWRITE(zac_s2636_r, SMH_RAM) AM_BASE(&zac2650_s2636_0_ram)
37   AM_RANGE(0x1f00, 0x1fff) AM_READWRITE(zac_s2636_r, zac_s2636_w) AM_BASE(&zac2650_s2636_0_ram)
3738ADDRESS_MAP_END
3839
3940static ADDRESS_MAP_START( port_map, ADDRESS_SPACE_IO, 8 )
r4135r4136
210211
211212static const gfx_layout tinvader_character =
212213{
213   24,24,
214   8,8,
214215   128,
215216   1,
216217   { 0 },
217   { 0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7 },
218      { 0*8, 0*8, 0*8, 1*8, 1*8, 1*8, 2*8, 2*8, 2*8, 3*8, 3*8, 3*8, 4*8, 4*8, 4*8,
219     5*8, 5*8, 5*8, 6*8, 6*8, 6*8, 7*8, 7*8, 7*8 },
218   { STEP8(0,1) },
219   { STEP8(0,8) },
220220   8*8
221221};
222222
223223
224static const gfx_layout s2636_character8 =
224static const gfx_layout s2636_character =
225225{
226   32,30,
226   8,10,
227227   16,
228228   1,
229229   { 0 },
230   { 0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7 },
231      { 0*8, 0*8, 0*8, 1*8, 1*8, 1*8, 2*8, 2*8, 2*8, 3*8, 3*8, 3*8,
232     4*8, 4*8, 4*8, 5*8, 5*8, 5*8, 6*8, 6*8, 6*8, 7*8, 7*8, 7*8,
233     8*8, 8*8, 8*8, 9*8, 9*8, 9*8    } ,
230   { STEP8(0,1) },
231      { STEP8(0,8), STEP2(8*8,8) },
234232   8*8
235233};
236234
237static const UINT32 s2636_character16_xoffset[64] =
238{
239   0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,
240   4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7
241};
242
243static const UINT32 s2636_character16_yoffset[60] =
244{
245   0*8, 0*8, 0*8, 0*8, 0*8, 0*8, 1*8, 1*8, 1*8, 1*8, 1*8, 1*8,
246   2*8, 2*8, 2*8, 2*8, 2*8, 2*8, 3*8, 3*8, 3*8, 3*8, 3*8, 3*8,
247   4*8, 4*8, 4*8, 4*8, 4*8, 4*8, 5*8, 5*8, 5*8, 5*8, 5*8, 5*8,
248   6*8, 6*8, 6*8, 6*8, 6*8, 6*8, 7*8, 7*8, 7*8, 7*8, 7*8, 7*8,
249   8*8, 8*8, 8*8, 8*8, 8*8, 8*8, 9*8, 9*8, 9*8, 9*8, 9*8, 9*8
250};
251
252static const gfx_layout s2636_character16 =
253{
254   64,60,
255   16,
256   1,
257   { 0 },
258   EXTENDED_XOFFS,
259   EXTENDED_YOFFS,
260   8*8,
261   s2636_character16_xoffset,
262   s2636_character16_yoffset
263};
264
265235static GFXDECODE_START( tinvader )
266   GFXDECODE_ENTRY( "gfx1", 0, tinvader_character,  0, 2 )
267     GFXDECODE_ENTRY( NULL,   0x1F00, s2636_character8, 0, 2 )   /* dynamic */
268     GFXDECODE_ENTRY( NULL,   0x1F00, s2636_character16, 0, 2 )   /* dynamic */
236   GFXDECODE_SCALE( "gfx1", 0, tinvader_character,   0, 2, 3, 3 )
237     GFXDECODE_SCALE( NULL,   0x1F00, s2636_character, 0, 2, 4, 3 )   /* dynamic */
238     GFXDECODE_SCALE( NULL,   0x1F00, s2636_character, 0, 2, 8, 6 )   /* dynamic */
269239GFXDECODE_END
270240
271241static MACHINE_DRIVER_START( tinvader )
src/mame/drivers/vcombat.c
r4135r4136
1717
1818There are two boards to this hardware.  The upper, which contains the
1919graphics ROMs and the i860, and the lower which contains the main
20and sound CPUs.  Virtual Combat sports two upper boards which presumably
20and sound CPUs.  Virtual Combat sports two upper boards which
2121output a different rasterization of the scene for each stereo eye.
2222
23UPPER:
23UPPER: (Virtual Combat has an identical MIDDLE board also).
2424    Intel I860 XR processor
2525    MB8298-25P-SK RAMS x12 (silkscreen said 62256)
2626    Analog device ADV476KN50E (silkscreen said BT476)
r4135r4136
5454        The data stored in "samples" is simply a series of
5555            Creative Media VOC files concatenated to eachother.
5656        The sound program ("sound") is about 640 bytes long.
57        The graphics ROMs have had images successfully extracted from
58            them.  Pictures for Shadow Fighters can be found online.
5957        The hardware is said to run at medium resolution.
6058        The SRAM module dump can likely be thrown away for both games.
6159        The PAL that's dumped for Shadow Fighters looks pretty bad.
62        Websites seem to say Shadow Fighters is a SEGA game, but I
63            couldn't find a SEGA string anywhere in the ROMs.  I also,
64            however, could not find a VR8 string in the Virtual Combat
65            ROMs, so who knows...  Kyle's name is easily found in both
66            though :).
6760
68TODO :  This is a skeleton driver.  Nearly everything.
69        i860XR-25 CPU core!
61TODO :  This is a partially working driver.  Most of the memory maps for
62            all four CPUs are complete.  An Intel i860XR CPU core has now
63            been incorporated into MAME.
7064
65    --------                Notes/questions                  ----------
66     - Most of the memory maps and input ports are complete now.
67       For "main", the only I/O locations that seem to be left
68       mysterious are:
69         0x600010,
70         0x60000C: Only written; maybe mc6845? Often accessed
71               together, and 16 consecutive words of data are
72               written to 0x60000C, making me think it might be
73               6845-related.  May or may not be important for
74               reasonable emulation.
75         0x60001C: Only read; might be a latch of some sort.  It is
76               read each time M0's interrupt service routine syncs
77               with the i860's to have them update the frame buffer.
78               Might this be a HW blank bit so things look clean when
79               the i860's do their updates?
80               The two other times I see it read are just before
81               and after one of the pallette setups is done.
82         0x600018: ? No info yet.
83         0x704000: (VC only) Likely analog axis for VR headset
84         0x703000: (VC only) Likely analog axis for VR headset
85         0x702000: (Shadow only). I think this is another IN port. It
86               is always read at the same time as the other two
87               ports.
88
89      - Assuming a single framebuffer, as I think we are at the moment,
90        how are all the CPUs writes to the framebuffer prioritized,
91        if at all?  The zero values written by the 68k side erase
92        the i860-generated FB data (i.e., zero maps to black in the
93        pallette).  On the other hand, treating the zero values as
94        transparent doesn't quite look right either.  Could just the
95        i860s each have their own framebuffers?  After
96        all, since each eye of the binocular sees a slightly different
97        picture, the i860's might just maintain their own.  Then maybe
98        the 68k shares with each of the two, since I think it just
99        generates a single picture (not sure about that either).
100    ----------------------------------------------
71101*/
72102
73103#include <stdio.h>
r4135r4136
77107#include "video/generic.h"
78108#include "video/tlc34076.h"
79109
80static UINT16* framebuffer;
110static UINT16* framebuffer_main;
111static UINT16* framebuffer_secondary;
81112static UINT16* vid_0_shared_RAM;
82113static UINT16* vid_1_shared_RAM;
83114
115
116static VIDEO_UPDATE( vcombat )
117{
118   int x, y;
119   int count = 0;
120   const rgb_t *pens = tlc34076_get_pens();
121
122   /* TODO: It looks like the leftmost chunk of the ground should really be on the right side? */
123   /*       But the i860 draws the background correctly, so it may be an original game issue. */
124   /*       There's also some garbage in the upper-left corner. Might be related to this 'wraparound'. */
125   /*       Or maybe it's related to the 68k's alpha?  It might come from the 68k side of the house.  */
126
127   /* Main eye */
128   for(y = 0; y < 256; y++)
129   {
130      for(x = 384; x < 640; x++)
131      {
132         UINT32 color;
133         if (x % 2) color = (framebuffer_main[count] & 0xff00) >> 8;
134         else      color =  framebuffer_main[count] & 0x00ff;
135
136         /* Vcombat's screen renders 'flopped' - very likely because VR headset displays may reflect off mirrors.
137               Shadfgtr isn't flopped, so it's not a constant feature of the hardware. */
138         if(x < video_screen_get_visible_area(screen)->max_x && y < video_screen_get_visible_area(screen)->max_y)
139            *BITMAP_ADDR32(bitmap, y, x) = pens[color];
140
141         if (x % 2) count++;
142      }
143   }
144
145   /* Early out for shadow fighters */
146   if (!framebuffer_secondary)
147      return 0;
148
149   /* Secondary eye */
150   count = 0;
151   for(y = 0; y < 256; y++)
152   {
153      for(x = 0; x < 256; x++)
154      {
155         UINT32 color;
156         if (x % 2) color = (framebuffer_secondary[count] & 0xff00) >> 8;
157         else      color =  framebuffer_secondary[count] & 0x00ff;
158
159         /* Vcombat's screen renders 'flopped' - very likely because VR headset displays may reflect off mirrors.
160               Shadfgtr isn't flopped, so it's not a constant feature of the hardware. */
161         if(x < video_screen_get_visible_area(screen)->max_x && y < video_screen_get_visible_area(screen)->max_y)
162            *BITMAP_ADDR32(bitmap, y, x) = pens[color];
163
164         if (x % 2) count++;
165      }
166   }
167
168   return 0;
169}
170
171
172/* Maybe there's a blend chip between the 68k and the framebuffer? */
173static WRITE16_HANDLER( main_video_write )
174{
175   /* Doesn't seem to make sense for shadow fighters. Maybe some of that factory rework disables this?  */
176   /* Doesn't always seem to work for vcombat either.  More testing needed.  */
177   if (data != 0x00000000) {
178      framebuffer_main[offset] = data;
179   }
180}
181
182static READ16_HANDLER( control_1_r )
183{
184   return (input_port_read(space->machine, "IN0") << 8);
185}
186
187static READ16_HANDLER( control_2_r )
188{
189   return (input_port_read(space->machine, "IN1") << 8);
190}
191
192static void wiggle_i860_common(int n, UINT16 data, const device_config *device)
193{
194   int bus_hold = (data & 0x03) == 0x03;
195   int reset = data & 0x10;
196   assert(n >= 0 && n < 2);
197   if (!device)
198      return;
199   if (bus_hold)
200   {
201      fprintf(stderr, "M0 asserting bus HOLD to i860 %s\n", device->tag);
202      i860_set_pin(device->token, DEC_PIN_BUS_HOLD, 1);
203   }
204   else
205   {
206      fprintf(stderr, "M0 clearing bus HOLD to i860 %s\n", device->tag);
207      i860_set_pin(device->token, DEC_PIN_BUS_HOLD, 0);
208   }
209
210   if (reset)
211   {
212      fprintf(stderr, "M0 asserting RESET to i860 %s\n", device->tag);
213      i860_set_pin(device->token, DEC_PIN_RESET, 1);
214   }
215   else
216      i860_set_pin(device->token, DEC_PIN_RESET, 0);
217}
218
219static WRITE16_HANDLER( wiggle_i860p0_pins_w )
220{
221   wiggle_i860_common(0, data, cputag_get_cpu(space->machine, "vid_0"));
222}
223
224static WRITE16_HANDLER( wiggle_i860p1_pins_w )
225{
226   wiggle_i860_common(1, data, cputag_get_cpu(space->machine, "vid_1"));
227}
228
229static READ16_HANDLER( main_irqiack_r )
230{
231   //fprintf(stderr, "M0: irq iack\n");
232   cpu_set_input_line(cputag_get_cpu(space->machine, "main"), M68K_IRQ_1, CLEAR_LINE);
233   //cpu_set_input_line(cputag_get_cpu(space->machine, "main"), INPUT_LINE_RESET, CLEAR_LINE);
234   return 0;
235}
236
237static READ16_HANDLER( sound_resetmain_r )
238{
239   //fprintf(stderr, "M1: reset line to M0\n");
240   //cpu_set_input_line(cputag_get_cpu(space->machine, "main"), INPUT_LINE_RESET, PULSE_LINE);
241   return 0;
242}
243
244static WRITE64_HANDLER( v0_fb_w )
245{
246   /* The frame buffer seems to sit on a 32-bit data bus, while the
247       i860 uses a 64-bit data bus.  Adjust accordingly.  */
248   char *p = (char *)framebuffer_main;
249   int m = mem_mask;
250   int o = (offset << 2);
251   if (m & 0xff000000) {
252      p[o+3] = (data >> 24) & 0xff;
253   }
254   if (m & 0x00ff0000) {
255      p[o+2] = (data >> 16) & 0xff;
256   }
257   if (m & 0x0000ff00) {
258      p[o+1] = (data >> 8) & 0xff;
259   }
260   if (m & 0x000000ff) {
261      p[o+0] = (data >> 0) & 0xff;
262   }
263}
264
265/* This is just temporary so we can see what each i860 is doing to the
266   framebuffer.  */
267static WRITE64_HANDLER( v1_fb_w )
268{
269   /* The frame buffer seems to sit on a 32-bit data bus, while the
270       i860 uses a 64-bit data bus.  Adjust accordingly.  */
271   char *p = (char *)framebuffer_secondary;
272   int m = mem_mask;
273   int o = (offset << 2);
274   if (m & 0xff000000) {
275      p[o+3] = (data >> 24) & 0xff;
276   }
277   if (m & 0x00ff0000) {
278      p[o+2] = (data >> 16) & 0xff;
279   }
280   if (m & 0x0000ff00) {
281      p[o+1] = (data >> 8) & 0xff;
282   }
283   if (m & 0x000000ff) {
284      p[o+0] = (data >> 0) & 0xff;
285   }
286}
287
288
84289static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
85290   AM_RANGE(0x000000, 0x0fffff) AM_ROM
86291   AM_RANGE(0x200000, 0x2fffff) AM_RAM
87   AM_RANGE(0x300000, 0x3fffff) AM_RAM AM_BASE(&framebuffer) AM_SHARE(1)
292   AM_RANGE(0x300000, 0x30ffff) AM_RAM_WRITE(main_video_write)
88293
89294   AM_RANGE(0x400000, 0x43ffff) AM_RAM AM_BASE(&vid_0_shared_RAM) AM_SHARE(2)   /* First i860 shared RAM */
90//  AM_RANGE(0x440000, 0x440003) i860 #1 com 1
91//  AM_RANGE(0x480000, 0x480003) i860 #1 com 2
92//  AM_RANGE(0x4c0000, 0x4c0003) i860 #1 stop/start/reset
295   AM_RANGE(0x440000, 0x440003) AM_RAM AM_SHARE(6)      /* M0->P0 i860 #1 com 1 */
296   AM_RANGE(0x480000, 0x480003) AM_RAM AM_SHARE(7)      /* M0<-P0 i860 #1 com 2 */
297   AM_RANGE(0x4c0000, 0x4c0003) AM_WRITE(wiggle_i860p0_pins_w)   /* i860 #1 stop/start/reset */
93298
94299   AM_RANGE(0x500000, 0x53ffff) AM_RAM AM_BASE(&vid_1_shared_RAM) AM_SHARE(3)   /* Second i860 shared RAM */
95//  AM_RANGE(0x540000, 0x540003) i860 #2 com 1
96//  AM_RANGE(0x580000, 0x580003) i860 #2 com 2
97//  AM_RANGE(0x5c0000, 0x5c0003) i860 #2 stop/start/reset
300   AM_RANGE(0x540000, 0x540003) AM_RAM AM_SHARE(8)      /* M0->P1 i860 #2 com 1 */
301   AM_RANGE(0x580000, 0x580003) AM_RAM AM_SHARE(9)      /* M0<-P1 i860 #2 com 2 */
302   AM_RANGE(0x5c0000, 0x5c0003) AM_WRITE(wiggle_i860p1_pins_w)   /* i860 #2 stop/start/reset */
98303
304   AM_RANGE(0x600000, 0x600001) AM_READ(control_1_r)   /* IN0 port */
305   AM_RANGE(0x600004, 0x600005) AM_RAM AM_SHARE(5)      /* M0<-M1 */
306   AM_RANGE(0x600008, 0x600009) AM_READ(control_2_r)   /* IN1 port */
307   /* AM_RANGE(0x60000c, 0x60000d)                        See notes at top of driver.  */
308   /* AM_RANGE(0x600010, 0x600011)                        See notes at top of driver.  */
309   AM_RANGE(0x700000, 0x7007ff) AM_RAM               /* TODO: Non-volatile RAM */
310   AM_RANGE(0x701000, 0x701001) AM_READ(main_irqiack_r)
311   AM_RANGE(0x705000, 0x705001) AM_RAM AM_SHARE(4)      /* M1->M0 */
312
313   //AM_RANGE(0x703000, 0x703001)      /* Headset rotation axis? */
314   //AM_RANGE(0x704000, 0x704001)      /* Headset rotation axis? */
315
99316   AM_RANGE(0x706000, 0x70601f) AM_READWRITE(tlc34076_lsb_r, tlc34076_lsb_w)
100317ADDRESS_MAP_END
101318
102319
103320/* The first i860 - middle board */
104static ADDRESS_MAP_START( vid_0_map, ADDRESS_SPACE_PROGRAM, 32 )
105   AM_RANGE(0x00000000, 0x000fffff) AM_RAM AM_SHARE(1)               /* Shared framebuffer */
106//  AM_RANGE(0x20000000, 0x20000003) com 1      (0x440000 in 68k-land)
107//  AM_RANGE(0x40000000, 0x401fffff) AM_ROM                             /* 3d data ROMs */
108//  AM_RANGE(0x80000000, 0x80000003) com 2      (0x480000 in 68k-land)
109   AM_RANGE(0xfffc0000, 0xffffffff) AM_RAM AM_SHARE(2)               /* Shared RAM with main */
321static ADDRESS_MAP_START( vid_0_map, ADDRESS_SPACE_PROGRAM, 64 )
322   AM_RANGE(0x00000000, 0x0001ffff) AM_RAM_WRITE(v0_fb_w)      /* Shared framebuffer - half of the bits lost to 32-bit bus */
323   AM_RANGE(0x20000000, 0x20000007) AM_RAM AM_SHARE(6)       /* M0<-P0 com 1 (0x440000 in 68k-land) */
324   AM_RANGE(0x40000000, 0x401fffff) AM_ROM AM_REGION("gfx", 0)
325   AM_RANGE(0x80000000, 0x80000007) AM_RAM AM_SHARE(7)       /* M0->P0 com 2 (0x480000 in 68k-land) */
326   AM_RANGE(0xc0000000, 0xc0000fff) AM_NOP                   /* Dummy D$ flush page. */
327   AM_RANGE(0xfffc0000, 0xffffffff) AM_RAM AM_SHARE(2)         /* Shared RAM with main */
110328ADDRESS_MAP_END
111329
112330
113331/* The second i860 - top board */
114static ADDRESS_MAP_START( vid_1_map, ADDRESS_SPACE_PROGRAM, 32 )
115   AM_RANGE(0x00000000, 0x000fffff) AM_RAM AM_SHARE(1)               /* Shared framebuffer */
116//  AM_RANGE(0x20000000, 0x20000003) com 1      (0x540000 in 68k-land)
117//  AM_RANGE(0x40000000, 0x401fffff) AM_ROM                             /* 3d data ROMs */
118//  AM_RANGE(0x80000000, 0x80000003) com 2      (0x580000 in 68k-land)
119   AM_RANGE(0xfffc0000, 0xffffffff) AM_RAM AM_SHARE(3)               /* Shared RAM with main */
332static ADDRESS_MAP_START( vid_1_map, ADDRESS_SPACE_PROGRAM, 64 )
333   AM_RANGE(0x00000000, 0x0001ffff) AM_RAM_WRITE(v1_fb_w)      /* Half of the bits lost to 32-bit bus */
334   AM_RANGE(0x20000000, 0x20000007) AM_RAM AM_SHARE(8)       /* M0->P1 com 1 (0x540000 in 68k-land) */
335   AM_RANGE(0x40000000, 0x401fffff) AM_ROM AM_REGION("gfx", 0)
336   AM_RANGE(0x80000000, 0x80000007) AM_RAM AM_SHARE(9)         /* M0<-P1 com 2      (0x580000 in 68k-land) */
337   AM_RANGE(0xc0000000, 0xc0000fff) AM_NOP                   /* Dummy D$ flush page. */
338   AM_RANGE(0xfffc0000, 0xffffffff) AM_RAM AM_SHARE(3)         /* Shared RAM with main */
120339ADDRESS_MAP_END
121340
122341
123/* Sound CPU - temprarily disabled */
124//static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 16 )
125//  AM_RANGE(0x000000, 0x03ffff) AM_ROM
126//ADDRESS_MAP_END
342/* Sound CPU */
343static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 16 )
344   AM_RANGE(0x000000, 0x03ffff) AM_ROM
345   AM_RANGE(0x081000, 0x081fff) AM_RAM
346   AM_RANGE(0x140000, 0x140001) AM_READ(sound_resetmain_r)   /* Ping M0's reset line */
347   AM_RANGE(0x180000, 0x180001) AM_RAM AM_SHARE(4)   /* M1<-M0 */
348   AM_RANGE(0x1C0000, 0x1C0001) AM_RAM AM_SHARE(5)   /* M1->M0 */
349ADDRESS_MAP_END
127350
128351
129352static MACHINE_RESET( vcombat )
130353{
131354   /* Setup the Bt476 VGA RAMDAC palette chip */
132355   tlc34076_reset(6);
356
357   i860_set_pin(cputag_get_cpu(machine, "vid_0")->token, DEC_PIN_BUS_HOLD, 1);
358   i860_set_pin(cputag_get_cpu(machine, "vid_1")->token, DEC_PIN_BUS_HOLD, 1);
133359}
134360
361static MACHINE_RESET( shadfgtr )
362{
363   /* Setup the Bt476 VGA RAMDAC palette chip */
364   tlc34076_reset(6);
365
366   i860_set_pin(cputag_get_cpu(machine, "vid_0")->token, DEC_PIN_BUS_HOLD, 1);
367}
368
369
135370static DIRECT_UPDATE_HANDLER( vid_0_direct_handler )
136371{
137372   if (address >= 0xfffc0000 && address <= 0xffffffff)
r4135r4136
152387   return address;
153388}
154389
390
155391static DRIVER_INIT( vcombat )
156392{
157393   UINT8 *ROM = memory_region(machine, "main");
r4135r4136
160396   memory_set_direct_update_handler(cputag_get_address_space(machine, "vid_0", ADDRESS_SPACE_PROGRAM), vid_0_direct_handler);
161397   memory_set_direct_update_handler(cputag_get_address_space(machine, "vid_1", ADDRESS_SPACE_PROGRAM), vid_1_direct_handler);
162398
163   // Hacks
164   // pc==4016 : jump 4038 ... There's something strange about how it waits at 402e (interrupts all masked out)
399   /* Allocate the two framebuffers */
400   framebuffer_main = auto_malloc(0x10000 * sizeof(UINT16));
401   framebuffer_secondary = auto_malloc(0x10000 * sizeof(UINT16));
402
403   /* pc==4016 : jump 4038 ... There's something strange about how it waits at 402e (interrupts all masked out)
404       I think what is happening here is that M0 snags the first time
405       it hits this point based on a counter test just above this
406       instruction.  That counter gets updated just past this instruction.
407       However, the only way this can be passed is if the M0 CPU is
408       reset (the IPL=7, but irq 7 is a nop).  I am almost sure that M1
409       reads a latch, which resets M0 (probably to ensure M0 and M1 are
410       both alive) and gets passed this snag.  I tried to hook up a reset
411       which should work, but asserting the reset line on the m68k doesn't
412       seem to do anything.  Maybe the 68k emulator doesn't respond to
413       that, or I didn't do it correctly.  But I think that is what needs
414       to be done.  But it isn't crucial for emulation.  Shadow does not
415       have this snag. */
165416   ROM[0x4017] = 0x66;
417}
166418
167   // Sound CPU comm bits
168   // pc==40fa : jump 40fc ... 600004 should be -16
169   ROM[0x40fb] = 0x67;
170   // pc==410e : jump 4110 ... 600004 should be 31
171   ROM[0x410f] = 0x67;
419static DRIVER_INIT( shadfgtr )
420{
421   /* Allocate just one framebuffer */
422   framebuffer_main = auto_malloc(0x10000 * sizeof(UINT16));
423   framebuffer_secondary = NULL;
172424
173   // pc==e220 : jump e222 ... 20119a should not be 0. (no interrupts masked)
174   // TODO: I wonder if this is an input bit that's ticked on vblank or something.  The menu selection continually crawls up.
425   /* The i860 executes out of RAM */
426   memory_set_direct_update_handler(cputag_get_address_space(machine, "vid_0", ADDRESS_SPACE_PROGRAM), vid_0_direct_handler);
175427}
176428
177429
178430static INPUT_PORTS_START( vcombat )
431   PORT_START("IN0")
432   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
433   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )   /* Left button */
434   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 )   /* Right button */
435   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
436   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
437   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
438   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
439   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
440
441   PORT_START("IN1")
442   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
443   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
444   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
445   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
446   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
447   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE )
448   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
449   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
179450INPUT_PORTS_END
180451
181452
182static VIDEO_UPDATE( vcombat )
183{
184   int x, y;
185   int count = 0;
186   const rgb_t *pens = tlc34076_get_pens();
453static INPUT_PORTS_START( shadfgtr )
454   PORT_START("IN0")
455   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
456   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )
457   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 )
458   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
459   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY /* ? */
460   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY /* ? */
461   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
462   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
187463
188   for(y = 0; y < 480; y++)
189   {
190      for(x = 0; x < 256; x++)
191      {
192         UINT32 color;
464   PORT_START("IN1")
465   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
466   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
467   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
468   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
469   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
470   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE )
471   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
472   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
473INPUT_PORTS_END
193474
194         if (x % 2) color = (framebuffer[count] & 0xff00) >> 8;
195         else      color =  framebuffer[count] & 0x00ff;
196475
197         if(x < video_screen_get_visible_area(screen)->max_x && y < video_screen_get_visible_area(screen)->max_y)
198            *BITMAP_ADDR32(bitmap, y, x) = pens[color];
199
200         if (x % 2) count++;
201      }
202   }
203   return 0;
204}
205
206
207// This is just here to show that there is text in the main program ROM.  It probably won't really be a useful decode.
208static const gfx_layout vcombat_charlayout =
209{
210   8, 8,
211   0x100000 / 0x80,
212   8,
213   { 0,1,2,3,4,5,6,7 },
214   { 0*16,   1*16,   2*16,   3*16,   4*16,   5*16,   6*16,   7*16 },
215   { 0*16*8, 1*16*8, 2*16*8, 3*16*8, 4*16*8, 5*16*8, 6*16*8, 7*16*8 },
216   8 * 0x80
217};
218
219
220static GFXDECODE_START( vcombat )
221   GFXDECODE_ENTRY( "main", 0, vcombat_charlayout, 0, 256 )
222GFXDECODE_END
223
224
225476static MACHINE_DRIVER_START( vcombat )
226477   MDRV_CPU_ADD("main", M68000, XTAL_12MHz)
227478   MDRV_CPU_PROGRAM_MAP(main_map,0)
228   //MDRV_CPU_VBLANK_INT("main", irq7_line_hold)
479   MDRV_CPU_VBLANK_INT("main", irq1_line_assert)
229480
230481   /* The middle board i860 */
231482   MDRV_CPU_ADD("vid_0", I860, XTAL_20MHz)
r4135r4136
235486   MDRV_CPU_ADD("vid_1", I860, XTAL_20MHz)
236487   MDRV_CPU_PROGRAM_MAP(vid_1_map,0)
237488
238   /* Sound CPU Disabled for now */
239   //MDRV_CPU_ADD("sound", M68000, XTAL_12MHz)
240   //MDRV_CPU_PROGRAM_MAP(sound_map,0)
489   /* Sound CPU */
490   MDRV_CPU_ADD("sound", M68000, XTAL_12MHz)
491   MDRV_CPU_PROGRAM_MAP(sound_map,0)
241492
242493   MDRV_MACHINE_RESET(vcombat)
243494
244   // Likely will go away
245   MDRV_GFXDECODE(vcombat)
495/* Temporary hack for experimenting with timing. */
496#if 0
497   //MDRV_QUANTUM_TIME(HZ(1200))
498   MDRV_QUANTUM_PERFECT_CPU("main")
499#endif
246500
247501   MDRV_SCREEN_ADD("main", RASTER)
502   MDRV_SCREEN_REFRESH_RATE(50)
503   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
504   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
505   MDRV_SCREEN_SIZE(640, 480)
506   MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
507
508   MDRV_VIDEO_UPDATE(vcombat)
509MACHINE_DRIVER_END
510
511
512static MACHINE_DRIVER_START( shadfgtr )
513   MDRV_CPU_ADD("main", M68000, XTAL_12MHz)
514   MDRV_CPU_PROGRAM_MAP(main_map,0)
515   MDRV_CPU_VBLANK_INT("main", irq1_line_assert)
516
517   /* The middle board i860 */
518   MDRV_CPU_ADD("vid_0", I860, XTAL_20MHz)
519   MDRV_CPU_PROGRAM_MAP(vid_0_map,0)
520
521   /* Sound CPU */
522   MDRV_CPU_ADD("sound", M68000, XTAL_12MHz)
523   MDRV_CPU_PROGRAM_MAP(sound_map,0)
524
525   MDRV_MACHINE_RESET(shadfgtr)
526
527   MDRV_SCREEN_ADD("main", RASTER)
248528   MDRV_SCREEN_REFRESH_RATE(60)
249529   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
250530   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
r4135r4136
255535MACHINE_DRIVER_END
256536
257537
538/* Perhaps add this to the core romload.h file?  */
539#define ROM_LOAD64_WORD(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_SKIP(6))
540
258541ROM_START( vcombat )
259542   ROM_REGION( 0x100000, "main", 0 )
260543   ROM_LOAD16_BYTE( "ep8v2.b49", 0x00000, 0x80000, CRC(98d5a45d) SHA1(099e314f11c93ad6e642ceaa311e2a5b6fd7193c) )
r4135r4136
270553   ROM_LOAD16_BYTE( "ep3v2.b40", 0x100000, 0x40000, CRC(8c491526) SHA1(95c6bcbe0adcfffb12fd2b86c9f4ca26aa188bbf) )
271554   ROM_LOAD16_BYTE( "ep5v2.b36", 0x100001, 0x40000, CRC(7592b2eb) SHA1(92a540726306d7adbf207fe86a4c4fa66958f90b) )
272555
273   ROM_REGION( 0x800, "user1", 0 )   /* The SRAM module */
556   ROM_REGION( 0x800, "user1", 0 ) /* The SRAM module */
274557   ROM_LOAD( "ds1220y.b53", 0x000, 0x800, CRC(b21cfe5f) SHA1(898ace3cd0913ea4b0dc84320219777773ef856f) )
275558
276559   /* These roms are identical on both of the upper boards */
277   ROM_REGION( 0x200000, "3d", 0 )
278   ROM_LOAD16_BYTE( "11.u56", 0x000000, 0x80000, CRC(a83094ce) SHA1(c3512375fecdb5e7eb02a4aa140ae4efe0233cb8) )
279   ROM_LOAD16_BYTE( "9.u54",  0x000001, 0x80000, CRC(a276e18b) SHA1(6d60e519196a4858b82241504592413df498e12f) )
280   ROM_LOAD16_BYTE( "12.u57", 0x100000, 0x80000, CRC(0cdffd4f) SHA1(65ace78711b3ef6e0ff9a7ad7343b5558e652f6c) )
281   ROM_LOAD16_BYTE( "10.u55", 0x100001, 0x80000, CRC(8921f20e) SHA1(6e9ca2eaad3e1108ba0e1d7792fd5d0305bec201) )
560   ROM_REGION( 0x200000, "gfx", 0 )
561   ROM_LOAD64_WORD( "9.u55",  0x000000, 0x80000, CRC(a276e18b) SHA1(6d60e519196a4858b82241504592413df498e12f) )
562   ROM_LOAD64_WORD( "10.u57", 0x000002, 0x80000, CRC(8921f20e) SHA1(6e9ca2eaad3e1108ba0e1d7792fd5d0305bec201) )
563   ROM_LOAD64_WORD( "11.u54", 0x000004, 0x80000, CRC(a83094ce) SHA1(c3512375fecdb5e7eb02a4aa140ae4efe0233cb8) )
564   ROM_LOAD64_WORD( "12.u56", 0x000006, 0x80000, CRC(0cdffd4f) SHA1(65ace78711b3ef6e0ff9a7ad7343b5558e652f6c) )
282565
283566   ROM_REGION( 0x400, "plds", 0 )
284567   ROM_LOAD( "pal1_w2.u51", 0x000, 0x1f1, CRC(af497420) SHA1(03aa82189d91ae194dd5a6e7b9dbdb7cd473ddb6) )
r4135r4136
301584   ROM_REGION( 0x800, "user1", 0 )   /* The SRAM module */
302585   ROM_LOAD( "shadfgtr.b53", 0x000, 0x800, CRC(e766a3ab) SHA1(e7696ec08d5c86f64d768480f43edbd19ded162d) )
303586
304   /* These roms are identical on both of the upper boards */
305   ROM_REGION( 0x200000, "3d", 0 )
306   ROM_LOAD16_BYTE( "shadfgtr.u56", 0x000000, 0x80000, CRC(fb76db5a) SHA1(fa546f465df113c13037abed1162bfa6f9b1dc9b) )
307   ROM_LOAD16_BYTE( "shadfgtr.u54", 0x000001, 0x80000, CRC(c45d68d6) SHA1(a133e4f13d3af18bccf0d060a659d64ac699b159) )
308   ROM_LOAD16_BYTE( "shadfgtr.u57", 0x100000, 0x80000, CRC(60d701d7) SHA1(936473b5e3b2e9e9e3b50cf977fc5a670a097850) )
309   ROM_LOAD16_BYTE( "shadfgtr.u55", 0x100001, 0x80000, CRC(e807631d) SHA1(9027ff7dc60b808434dac292c08f0630d3d52186) )
587   ROM_REGION( 0x200000, "gfx", 0 )
588   ROM_LOAD64_WORD( "shadfgtr.u55", 0x000000, 0x80000, CRC(e807631d) SHA1(9027ff7dc60b808434dac292c08f0630d3d52186) )
589   ROM_LOAD64_WORD( "shadfgtr.u57", 0x000002, 0x80000, CRC(60d701d7) SHA1(936473b5e3b2e9e9e3b50cf977fc5a670a097850) )
590   ROM_LOAD64_WORD( "shadfgtr.u54", 0x000004, 0x80000, CRC(c45d68d6) SHA1(a133e4f13d3af18bccf0d060a659d64ac699b159) )
591   ROM_LOAD64_WORD( "shadfgtr.u56", 0x000006, 0x80000, CRC(fb76db5a) SHA1(fa546f465df113c13037abed1162bfa6f9b1dc9b) )
310592
311593   ROM_REGION( 0x200, "plds", 0 )
312594   ROM_LOAD( "shadfgtr.u51", 0x000, 0x1f1, CRC(bab58337) SHA1(c4a79c8e53aeadb7f64d49d214b607b5b36f144e) )
313595   /* The second upper-board PAL couldn't be read */
314596ROM_END
315597
316/*    YEAR  NAME      PARENT  MACHINE  INPUT    INIT     MONITOR COMPANY     FULLNAME           FLAGS */
317GAME( 1993, vcombat,  0,      vcombat, vcombat, vcombat, ROT0,   "VR8 Inc.", "Virtual Combat",  GAME_NOT_WORKING | GAME_NO_SOUND )
318GAME( 1989, shadfgtr, 0,      vcombat, vcombat, 0,       ROT0,   "Sega?",    "Shadow Fighters", GAME_NOT_WORKING | GAME_NO_SOUND )
598/*    YEAR  NAME      PARENT  MACHINE   INPUT     INIT      MONITOR COMPANY      FULLNAME           FLAGS */
599GAME( 1993, vcombat,  0,      vcombat,  vcombat,  vcombat,  ORIENTATION_FLIP_X,  "VR8 Inc.",     "Virtual Combat",  GAME_NOT_WORKING | GAME_NO_SOUND )
600GAME( 1989, shadfgtr, 0,      shadfgtr, shadfgtr, shadfgtr, ROT0,                "DUTECH Inc.",  "Shadow Fighters", GAME_NOT_WORKING | GAME_NO_SOUND )
src/mame/drivers/relief.c
r4135r4136
294294 *
295295 *************************************/
296296
297static const gfx_layout pfmolayout =
297static const gfx_layout pflayout =
298298{
299299   8,8,
300   RGN_FRAC(1,4),
300   RGN_FRAC(1,5),
301301   4,
302   { RGN_FRAC(3,4), RGN_FRAC(2,4), RGN_FRAC(1,4), RGN_FRAC(0,4) },
303   { 0, 1, 2, 3, 4, 5, 6, 7 },
304   { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
302   { RGN_FRAC(3,5), RGN_FRAC(2,5), RGN_FRAC(1,5), RGN_FRAC(0,5) },
303   { STEP8(0,1) },
304   { STEP8(0,16) },
305305   16*8
306306};
307307
308308
309static const gfx_layout moexlayout =
309static const gfx_layout molayout =
310310{
311311   8,8,
312   RGN_FRAC(1,1),
312   RGN_FRAC(1,5),
313313   5,
314   { 0, 0, 0, 0, 0 },
315   { 0, 1, 2, 3, 4, 5, 6, 7 },
316   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
317   8*8
314   { RGN_FRAC(4,5), RGN_FRAC(3,5), RGN_FRAC(2,5), RGN_FRAC(1,5), RGN_FRAC(0,5) },
315   { STEP8(0,1) },
316   { STEP8(0,16) },
317   16*8
318318};
319319
320320
321321static GFXDECODE_START( relief )
322   GFXDECODE_ENTRY( "gfx1", 0, pfmolayout,   0, 64 )      /* alpha & playfield */
323   GFXDECODE_ENTRY( "gfx1", 1, pfmolayout, 256, 16 )      /* sprites */
324   GFXDECODE_ENTRY( "gfx2", 0, moexlayout, 256, 16 )      /* extra sprite bit */
322   GFXDECODE_ENTRY( "gfx1", 0, pflayout,   0, 64 )      /* alpha & playfield */
323   GFXDECODE_ENTRY( "gfx1", 1, molayout, 256, 16 )      /* sprites */
325324GFXDECODE_END
326325
327326
r4135r4136
381380   ROM_LOAD16_BYTE( "136093-0013.17e", 0x40000, 0x20000, CRC(1e1e82e5) SHA1(d33c84ae950db9775f9db9bf953aa63188d3f2f9) )
382381   ROM_LOAD16_BYTE( "136093-0014.17j", 0x40001, 0x20000, CRC(19e5decd) SHA1(8d93d93f966df46d59cf9f4cdaa689e4dcd2689a) )
383382
384   ROM_REGION( 0x200000, "gfx1", ROMREGION_DISPOSE | ROMREGION_INVERT )
385   ROM_LOAD( "136093-0025a.14s", 0x000000, 0x80000, CRC(1b9e5ef2) SHA1(d7d14e75ca2d56c5c67154506096570c9ccbcf8e) )
386   ROM_LOAD( "136093-0026a.8d",  0x080000, 0x80000, CRC(09b25d93) SHA1(94d424b21410182b5121201066f4acfa415f4b6b) )
387   ROM_LOAD( "136093-0027a.18s", 0x100000, 0x80000, CRC(5bc1c37b) SHA1(89f1bca55dd431ca3171b89347209decf0b25e12) )
388   ROM_LOAD( "136093-0028a.10d", 0x180000, 0x80000, CRC(55fb9111) SHA1(a95508f0831842fa79ca2fc168cfadc8c6d3fbd4) )
383   ROM_REGION( 0x280000, "gfx1", ROMREGION_DISPOSE | ROMREGION_INVERT )
384   ROM_LOAD( "136093-0025a.14s",       0x000000, 0x80000, CRC(1b9e5ef2) SHA1(d7d14e75ca2d56c5c67154506096570c9ccbcf8e) )
385   ROM_LOAD( "136093-0026a.8d",        0x080000, 0x80000, CRC(09b25d93) SHA1(94d424b21410182b5121201066f4acfa415f4b6b) )
386   ROM_LOAD( "136093-0027a.18s",       0x100000, 0x80000, CRC(5bc1c37b) SHA1(89f1bca55dd431ca3171b89347209decf0b25e12) )
387   ROM_LOAD( "136093-0028a.10d",       0x180000, 0x80000, CRC(55fb9111) SHA1(a95508f0831842fa79ca2fc168cfadc8c6d3fbd4) )
388   ROM_LOAD16_BYTE( "136093-0029a.4d", 0x200001, 0x40000, CRC(e4593ff4) SHA1(7360ec7a65aabc90aa787dc30f39992e342495dd) )
389389
390   ROM_REGION( 0x040000, "gfx2", ROMREGION_DISPOSE | ROMREGION_INVERT )
391   ROM_LOAD( "136093-0029a.4d",  0x000000, 0x40000, CRC(e4593ff4) SHA1(7360ec7a65aabc90aa787dc30f39992e342495dd) )
392
393390   ROM_REGION( 0x200000, "oki", 0 )   /* 2MB for ADPCM data */
394391   ROM_LOAD( "136093-0030a.9b",  0x100000, 0x80000, CRC(f4c567f5) SHA1(7e8c1d54d918b0b41625eacbaf6dcb5bd99d1949) )
395392   ROM_LOAD( "136093-0031a.10b", 0x180000, 0x80000, CRC(ba908d73) SHA1(a83afd86f4c39394cf624b728a87b8d8b6de1944) )
r4135r4136
412409   ROM_LOAD16_BYTE( "136093-0013.17e", 0x40000, 0x20000, CRC(1e1e82e5) SHA1(d33c84ae950db9775f9db9bf953aa63188d3f2f9) )
413410   ROM_LOAD16_BYTE( "136093-0014.17j", 0x40001, 0x20000, CRC(19e5decd) SHA1(8d93d93f966df46d59cf9f4cdaa689e4dcd2689a) )
414411
415   ROM_REGION( 0x200000, "gfx1", ROMREGION_DISPOSE | ROMREGION_INVERT )
416   ROM_LOAD( "136093-0025a.14s", 0x000000, 0x80000, CRC(1b9e5ef2) SHA1(d7d14e75ca2d56c5c67154506096570c9ccbcf8e) )
417   ROM_LOAD( "136093-0026a.8d",  0x080000, 0x80000, CRC(09b25d93) SHA1(94d424b21410182b5121201066f4acfa415f4b6b) )
418   ROM_LOAD( "136093-0027a.18s", 0x100000, 0x80000, CRC(5bc1c37b) SHA1(89f1bca55dd431ca3171b89347209decf0b25e12) )
419   ROM_LOAD( "136093-0028a.10d", 0x180000, 0x80000, CRC(55fb9111) SHA1(a95508f0831842fa79ca2fc168cfadc8c6d3fbd4) )
412   ROM_REGION( 0x280000, "gfx1", ROMREGION_DISPOSE | ROMREGION_INVERT )
413   ROM_LOAD( "136093-0025a.14s",      0x000000, 0x80000, CRC(1b9e5ef2) SHA1(d7d14e75ca2d56c5c67154506096570c9ccbcf8e) )
414   ROM_LOAD( "136093-0026a.8d",       0x080000, 0x80000, CRC(09b25d93) SHA1(94d424b21410182b5121201066f4acfa415f4b6b) )
415   ROM_LOAD( "136093-0027a.18s",      0x100000, 0x80000, CRC(5bc1c37b) SHA1(89f1bca55dd431ca3171b89347209decf0b25e12) )
416   ROM_LOAD( "136093-0028a.10d",      0x180000, 0x80000, CRC(55fb9111) SHA1(a95508f0831842fa79ca2fc168cfadc8c6d3fbd4) )
417   ROM_LOAD16_BYTE( "136093-0029.4d", 0x200001, 0x40000, CRC(e4593ff4) SHA1(7360ec7a65aabc90aa787dc30f39992e342495dd) )
420418
421   ROM_REGION( 0x040000, "gfx2", ROMREGION_DISPOSE | ROMREGION_INVERT )
422   ROM_LOAD( "136093-0029.4d",  0x000000, 0x40000, CRC(e4593ff4) SHA1(7360ec7a65aabc90aa787dc30f39992e342495dd) )
423
424419   ROM_REGION( 0x200000, "oki", 0 )   /* 2MB for ADPCM data */
425420   ROM_LOAD( "136093-0030a.9b",  0x100000, 0x80000, CRC(f4c567f5) SHA1(7e8c1d54d918b0b41625eacbaf6dcb5bd99d1949) )
426421   ROM_LOAD( "136093-0031a.10b", 0x180000, 0x80000, CRC(ba908d73) SHA1(a83afd86f4c39394cf624b728a87b8d8b6de1944) )
src/mame/drivers/baraduke.c
r4135r4136
144144   switch (inputport_selected)
145145   {
146146      case 0x00:   /* DSW A (bits 0-4) */
147         return (input_port_read(space->machine, "DSWA") & 0xf8) >> 3; break;
147         return (input_port_read(space->machine, "DSWA") & 0xf8) >> 3;
148148      case 0x01:   /* DSW A (bits 5-7), DSW B (bits 0-1) */
149         return ((input_port_read(space->machine, "DSWA") & 0x07) << 2) | ((input_port_read(space->machine, "DSWB") & 0xc0) >> 6); break;
149         return ((input_port_read(space->machine, "DSWA") & 0x07) << 2) | ((input_port_read(space->machine, "DSWB") & 0xc0) >> 6);
150150      case 0x02:   /* DSW B (bits 2-6) */
151         return (input_port_read(space->machine, "DSWB") & 0x3e) >> 1; break;
151         return (input_port_read(space->machine, "DSWB") & 0x3e) >> 1;
152152      case 0x03:   /* DSW B (bit 7), DSW C (bits 0-3) */
153         return ((input_port_read(space->machine, "DSWB") & 0x01) << 4) | (input_port_read(space->machine, "EDGE") & 0x0f); break;
153         return ((input_port_read(space->machine, "DSWB") & 0x01) << 4) | (input_port_read(space->machine, "EDGE") & 0x0f);
154154      case 0x04:   /* coins, start */
155         return input_port_read(space->machine, "IN0"); break;
155         return input_port_read(space->machine, "IN0");
156156      case 0x05:   /* 2P controls */
157         return input_port_read(space->machine, "IN2"); break;
157         return input_port_read(space->machine, "IN2");
158158      case 0x06:   /* 1P controls */
159         return input_port_read(space->machine, "IN1"); break;
159         return input_port_read(space->machine, "IN1");
160160      default:
161161         return 0xff;
162162   }
src/mame/drivers/megasys1.c
r4135r4136
147147
148148
149149
150/*
151**
152**  Main cpu data
153**
154**
155*/
150/*************************************
151 *
152 *  Main CPU memory handlers
153 *
154 *************************************/
156155
157
158156/***************************************************************************
159157                        [ Main CPU - System A / Z ]
160158***************************************************************************/
r4135r4136
248246
249247   switch (i)
250248   {
251         case 0 :   return input_port_read(space->machine, "SYSTEM");   break;
252         case 1 :   return input_port_read(space->machine, "P1");      break;
253         case 2 :   return input_port_read(space->machine, "P2");      break;
254         case 3 :   return input_port_read(space->machine, "DSW1");   break;
255         case 4 :   return input_port_read(space->machine, "DSW2");   break;
249         case 0 :   return input_port_read(space->machine, "SYSTEM");
250         case 1 :   return input_port_read(space->machine, "P1");
251         case 2 :   return input_port_read(space->machine, "P2");
252         case 3 :   return input_port_read(space->machine, "DSW1");
253         case 4 :   return input_port_read(space->machine, "DSW2");
256254         default    :   return 0x0006;
257255   }
258256}
r4135r4136
369367ADDRESS_MAP_END
370368
371369
370/*************************************
371 *
372 *  Sound CPU memory handlers
373 *
374 *************************************/
372375
373
374376/*
375**
376**  Sound cpu data
377**
378**
379*/
380
381/*
382377                            [ Sound CPU interrupts ]
383378
384379    [MS1-A]
r4135r4136
537532ADDRESS_MAP_END
538533
539534
535/*************************************
536 *
537 *  Generic port definitions
538 *
539 *************************************/
540540
541static INPUT_PORTS_START( megasys1_generic )
542   PORT_START("SYSTEM")
543   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 )
544   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START2 )
545   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN )
546   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN )
547   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )
548   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_SERVICE1 )
549   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_COIN1 )
550   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN2 )
551   PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
541552
553   PORT_START("P1")
554   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
555   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
556   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
557   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
558   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
559   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
560   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
561   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
562
563   PORT_START("P2")
564   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
565   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
566   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
567   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
568   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
569   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
570   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
571   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
572   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Reserve 1P */
573   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
574   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
575   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
576   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Reserve 2P */
577   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
578   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
579   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
580INPUT_PORTS_END
581
582/* Coinage DSWs */
583//  1]  01-41 02-31 03-21 07-11 06-12 05-13 04-14 00-FC * 2
584//  2]  04-31 02-21 07-11 03-12 05-13 01-14 06-15 00-FC
585//      00-41 20-31 10-21 38-11 18-12 28-13 08-14 30-15
586
587#define COINAGE_8BITS \
588   PORT_DIPNAME( 0x000f, 0x000f, DEF_STR( Coin_A ) )\
589   PORT_DIPSETTING(      0x0007, DEF_STR( 4C_1C ) )\
590   PORT_DIPSETTING(      0x0008, DEF_STR( 3C_1C ) )\
591   PORT_DIPSETTING(      0x0009, DEF_STR( 2C_1C ) )\
592   PORT_DIPSETTING(      0x000f, DEF_STR( 1C_1C ) )\
593/*  PORT_DIPSETTING(      0x0005, DEF_STR( 1C_1C ) )*/\
594/*  PORT_DIPSETTING(      0x0004, DEF_STR( 1C_1C ) )*/\
595/*  PORT_DIPSETTING(      0x0003, DEF_STR( 1C_1C ) )*/\
596/*  PORT_DIPSETTING(      0x0002, DEF_STR( 1C_1C ) )*/\
597/*  PORT_DIPSETTING(      0x0001, DEF_STR( 1C_1C ) )*/\
598   PORT_DIPSETTING(      0x0006, DEF_STR( 2C_3C ) )\
599   PORT_DIPSETTING(      0x000e, DEF_STR( 1C_2C ) )\
600   PORT_DIPSETTING(      0x000d, DEF_STR( 1C_3C ) )\
601   PORT_DIPSETTING(      0x000c, DEF_STR( 1C_4C ) )\
602   PORT_DIPSETTING(      0x000b, DEF_STR( 1C_5C ) )\
603   PORT_DIPSETTING(      0x000a, DEF_STR( 1C_6C ) )\
604   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )\
605   PORT_DIPNAME( 0x00f0, 0x00f0, DEF_STR( Coin_B ) )\
606   PORT_DIPSETTING(      0x0070, DEF_STR( 4C_1C ) )\
607   PORT_DIPSETTING(      0x0080, DEF_STR( 3C_1C ) )\
608   PORT_DIPSETTING(      0x0090, DEF_STR( 2C_1C ) )\
609   PORT_DIPSETTING(      0x00f0, DEF_STR( 1C_1C ) )\
610/*  PORT_DIPSETTING(      0x0050, DEF_STR( 1C_1C ) )*/\
611/*  PORT_DIPSETTING(      0x0040, DEF_STR( 1C_1C ) )*/\
612/*  PORT_DIPSETTING(      0x0030, DEF_STR( 1C_1C ) )*/\
613/*  PORT_DIPSETTING(      0x0020, DEF_STR( 1C_1C ) )*/\
614/*  PORT_DIPSETTING(      0x0010, DEF_STR( 1C_1C ) )*/\
615   PORT_DIPSETTING(      0x0060, DEF_STR( 2C_3C ) )\
616   PORT_DIPSETTING(      0x00e0, DEF_STR( 1C_2C ) )\
617   PORT_DIPSETTING(      0x00d0, DEF_STR( 1C_3C ) )\
618   PORT_DIPSETTING(      0x00c0, DEF_STR( 1C_4C ) )\
619   PORT_DIPSETTING(      0x00b0, DEF_STR( 1C_5C ) )\
620   PORT_DIPSETTING(      0x00a0, DEF_STR( 1C_6C ) )\
621   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
622
623/*************************************
624 *
625 *  Game-specific port definitions
626 *
627 *************************************/
628
629static INPUT_PORTS_START( 64street )
630   PORT_INCLUDE( megasys1_generic )
631
632   PORT_START("DSW1")
633   COINAGE_8BITS
634
635   PORT_START("DSW2")
636   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
637   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
638   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
639   PORT_DIPNAME( 0x0002, 0x0000, DEF_STR( Demo_Sounds ) )
640   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
641   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
642   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Allow_Continue ) )
643   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
644   PORT_DIPSETTING(      0x0004, DEF_STR( On ) )
645   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Difficulty ) )
646   PORT_DIPSETTING(      0x0010, DEF_STR( Easy ) )
647   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
648   PORT_DIPSETTING(      0x0008, DEF_STR( Hard ) )
649   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
650   PORT_DIPNAME( 0x0060, 0x0020, DEF_STR( Lives ) )
651   PORT_DIPSETTING(      0x0040, "1" )
652   PORT_DIPSETTING(      0x0060, "2" )
653   PORT_DIPSETTING(      0x0020, "3" )
654   PORT_DIPSETTING(      0x0000, "5" )
655   PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
656INPUT_PORTS_END
657
658static INPUT_PORTS_START( astyanax )
659   PORT_INCLUDE( megasys1_generic )
660
661   PORT_MODIFY("P1")
662   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
663
664   PORT_MODIFY("P2")
665   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
666
667   PORT_START("DSW")
668   PORT_DIPUNUSED( 0x0001, 0x0001 ) // according to manual
669   PORT_DIPUNUSED( 0x0002, 0x0002 ) // according to manual
670   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Bonus_Life ) )
671   PORT_DIPSETTING(      0x0004, "30k 70k 110k then every 30k" )
672   PORT_DIPSETTING(      0x0000, "50k 100k then every 40k" )
673   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Lives ) )
674   PORT_DIPSETTING(      0x0008, "2" )
675   PORT_DIPSETTING(      0x0018, "3" )
676   PORT_DIPSETTING(      0x0010, "4" )
677   PORT_DIPSETTING(      0x0000, "5" )
678   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Difficulty ) )
679   PORT_DIPSETTING(      0x0020, DEF_STR( Normal ) )
680   PORT_DIPSETTING(      0x0000, DEF_STR( Hard ) )
681   PORT_DIPNAME( 0x0040, 0x0040, "Swap 1P/2P Controls" )
682   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
683   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
684   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
685   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
686   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
687
688   PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coin_A ) )
689   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
690   PORT_DIPSETTING(      0x0400, DEF_STR( 3C_1C ) )
691   PORT_DIPSETTING(      0x0200, DEF_STR( 2C_1C ) )
692   PORT_DIPSETTING(      0x0700, DEF_STR( 1C_1C ) )
693//  PORT_DIPSETTING(      0x0300, DEF_STR( 1C_1C ) )    // 1_2 shown in test mode
694//  PORT_DIPSETTING(      0x0500, DEF_STR( 1C_1C ) )    // 1_3
695//  PORT_DIPSETTING(      0x0100, DEF_STR( 1C_1C ) )    // 1_4
696//  PORT_DIPSETTING(      0x0600, DEF_STR( 1C_1C ) )    // 1_5
697   PORT_DIPNAME( 0x3800, 0x3800, DEF_STR( Coin_B ) )
698   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
699   PORT_DIPSETTING(      0x2000, DEF_STR( 3C_1C ) )
700   PORT_DIPSETTING(      0x1000, DEF_STR( 2C_1C ) )
701   PORT_DIPSETTING(      0x3800, DEF_STR( 1C_1C ) )
702//  PORT_DIPSETTING(      0x1800, DEF_STR( 1C_1C ) )    // 1_2 shown in test mode
703//  PORT_DIPSETTING(      0x2800, DEF_STR( 1C_1C ) )    // 1_3
704//  PORT_DIPSETTING(      0x0800, DEF_STR( 1C_1C ) )    // 1_4
705//  PORT_DIPSETTING(      0x3000, DEF_STR( 1C_1C ) )    // 1_5
706   PORT_DIPNAME( 0x4000, 0x0000, DEF_STR( Demo_Sounds ) )
707   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
708   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
709   PORT_DIPNAME( 0x8000, 0x8000, "Test Mode" )
710   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
711   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
712INPUT_PORTS_END
713
714static INPUT_PORTS_START( avspirit )
715   PORT_INCLUDE( 64street )
716
717   PORT_MODIFY("DSW2")
718   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Difficulty ) )
719   PORT_DIPSETTING(      0x0008, DEF_STR( Easy ) )
720   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
721   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )
722   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
723   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Cabinet ) )
724   PORT_DIPSETTING(      0x0020, DEF_STR( Upright ) )
725   PORT_DIPSETTING(      0x0000, DEF_STR( Cocktail ) )
726   PORT_DIPNAME( 0x0040, 0x0040, "Test Mode" ) // freeze & slow motion via P1 + P2 start
727   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
728   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
729INPUT_PORTS_END
730
731
732static INPUT_PORTS_START( phantasm )
733   PORT_INCLUDE( megasys1_generic )
734
735   PORT_START("DSW")
736   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
737   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
738   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
739   PORT_DIPNAME( 0x0002, 0x0000, DEF_STR( Demo_Sounds ) )
740   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
741   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
742   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Allow_Continue ) )
743   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
744   PORT_DIPSETTING(      0x0004, DEF_STR( On ) )
745   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Difficulty ) )
746   PORT_DIPSETTING(      0x0008, DEF_STR( Easy ) )
747   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
748   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )
749   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
750   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Cabinet ) )
751   PORT_DIPSETTING(      0x0020, DEF_STR( Upright ) )
752   PORT_DIPSETTING(      0x0000, DEF_STR( Cocktail ) )
753   PORT_DIPNAME( 0x0040, 0x0040, "Test Mode" ) // freeze & slow motion via P1 + P2 start
754   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
755   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
756   PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
757
758   PORT_DIPNAME( 0x0f00, 0x0f00, DEF_STR( Coin_A ) )
759   PORT_DIPSETTING(      0x0700, DEF_STR( 4C_1C ) )
760   PORT_DIPSETTING(      0x0800, DEF_STR( 3C_1C ) )
761   PORT_DIPSETTING(      0x0900, DEF_STR( 2C_1C ) )
762   PORT_DIPSETTING(      0x0f00, DEF_STR( 1C_1C ) )
763/*  PORT_DIPSETTING(      0x0500, DEF_STR( 1C_1C ) )*/
764/*  PORT_DIPSETTING(      0x0400, DEF_STR( 1C_1C ) )*/
765/*  PORT_DIPSETTING(      0x0300, DEF_STR( 1C_1C ) )*/
766/*  PORT_DIPSETTING(      0x0200, DEF_STR( 1C_1C ) )*/
767/*  PORT_DIPSETTING(      0x0100, DEF_STR( 1C_1C ) )*/
768   PORT_DIPSETTING(      0x0600, DEF_STR( 2C_3C ) )
769   PORT_DIPSETTING(      0x0e00, DEF_STR( 1C_2C ) )
770   PORT_DIPSETTING(      0x0d00, DEF_STR( 1C_3C ) )
771   PORT_DIPSETTING(      0x0c00, DEF_STR( 1C_4C ) )
772   PORT_DIPSETTING(      0x0b00, DEF_STR( 1C_5C ) )
773   PORT_DIPSETTING(      0x0a00, DEF_STR( 1C_6C ) )
774   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
775   PORT_DIPNAME( 0xf000, 0xf000, DEF_STR( Coin_B ) )
776   PORT_DIPSETTING(      0x7000, DEF_STR( 4C_1C ) )
777   PORT_DIPSETTING(      0x8000, DEF_STR( 3C_1C ) )
778   PORT_DIPSETTING(      0x9000, DEF_STR( 2C_1C ) )
779   PORT_DIPSETTING(      0xf000, DEF_STR( 1C_1C ) )
780/*  PORT_DIPSETTING(      0x5000, DEF_STR( 1C_1C ) )*/
781/*  PORT_DIPSETTING(      0x4000, DEF_STR( 1C_1C ) )*/
782/*  PORT_DIPSETTING(      0x3000, DEF_STR( 1C_1C ) )*/
783/*  PORT_DIPSETTING(      0x2000, DEF_STR( 1C_1C ) )*/
784/*  PORT_DIPSETTING(      0x1000, DEF_STR( 1C_1C ) )*/
785   PORT_DIPSETTING(      0x6000, DEF_STR( 2C_3C ) )
786   PORT_DIPSETTING(      0xe000, DEF_STR( 1C_2C ) )
787   PORT_DIPSETTING(      0xd000, DEF_STR( 1C_3C ) )
788   PORT_DIPSETTING(      0xc000, DEF_STR( 1C_4C ) )
789   PORT_DIPSETTING(      0xb000, DEF_STR( 1C_5C ) )
790   PORT_DIPSETTING(      0xa000, DEF_STR( 1C_6C ) )
791   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
792INPUT_PORTS_END
793
794static INPUT_PORTS_START( bigstrik )
795   PORT_INCLUDE( 64street )
796
797   PORT_MODIFY("P1")
798   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
799
800   PORT_MODIFY("P2")
801   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
802
803   PORT_MODIFY("DSW2")
804   PORT_DIPNAME( 0x0006, 0x0006, DEF_STR( Difficulty ) )
805   PORT_DIPSETTING(      0x0002, DEF_STR( Easy ) )
806   PORT_DIPSETTING(      0x0006, DEF_STR( Normal )  )
807   PORT_DIPSETTING(      0x0004, DEF_STR( Hard ) )
808   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
809   PORT_DIPNAME( 0x0018, 0x0018, "Time" )
810   PORT_DIPSETTING(      0x0000, "Very Short" )
811   PORT_DIPSETTING(      0x0010, "Short" )
812   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
813   PORT_DIPSETTING(      0x0008, "Long" )
814   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Demo_Sounds ) )
815   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
816   PORT_DIPSETTING(      0x0020, DEF_STR( On ) )
817   PORT_DIPNAME( 0x0040, 0x0040, "1 Credit 2 Play" )
818   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
819   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
820INPUT_PORTS_END
821
822static INPUT_PORTS_START( chimerab )
823   PORT_INCLUDE( megasys1_generic )
824
825   PORT_START("DSW1")
826   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
827   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
828   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
829   PORT_DIPNAME( 0x0002, 0x0000, DEF_STR( Demo_Sounds ) )
830   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
831   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
832   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Allow_Continue ) )
833   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
834   PORT_DIPSETTING(      0x0004, DEF_STR( On ) )
835   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Difficulty ) )
836   PORT_DIPSETTING(      0x0010, DEF_STR( Easy ) )
837   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
838   PORT_DIPSETTING(      0x0008, DEF_STR( Hard ) )
839   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
840   PORT_DIPNAME( 0x0060, 0x0020, DEF_STR( Lives ) )
841   PORT_DIPSETTING(      0x0040, "1" )
842   PORT_DIPSETTING(      0x0060, "2" )
843   PORT_DIPSETTING(      0x0020, "3" )
844   PORT_DIPSETTING(      0x0000, "4" )
845   PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
846
847   PORT_START("DSW2")
848   COINAGE_8BITS
849INPUT_PORTS_END
850
851static INPUT_PORTS_START( cybattlr )
852   PORT_INCLUDE( megasys1_generic )
853
854   PORT_START("DSW1")      /*1fd2d9.b, !1fd009.b */
855   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
856   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
857   PORT_DIPSETTING(      0x0001, DEF_STR( 3C_1C ) )
858   PORT_DIPSETTING(      0x0003, DEF_STR( 2C_1C ) )
859   PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) )
860   PORT_DIPSETTING(      0x0002, DEF_STR( 2C_3C ) )
861   PORT_DIPSETTING(      0x0006, DEF_STR( 1C_2C ) )
862   PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) )
863   PORT_DIPSETTING(      0x0004, DEF_STR( 1C_4C ) )
864   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) )
865   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
866   PORT_DIPSETTING(      0x0008, DEF_STR( 3C_1C ) )
867   PORT_DIPSETTING(      0x0018, DEF_STR( 2C_1C ) )
868   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
869   PORT_DIPSETTING(      0x0010, DEF_STR( 2C_3C ) )
870   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_2C ) )
871   PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) )
872   PORT_DIPSETTING(      0x0020, DEF_STR( 1C_4C ) )
873   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Free_Play ) )
874   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
875   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
876   PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
877
878   PORT_START("DSW2")      /* 1fd2d7.b, !1fd007.b */
879   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) )
880   PORT_DIPSETTING(      0x0002, DEF_STR( Easy ) )
881   PORT_DIPSETTING(      0x0003, DEF_STR( Normal ) )
882   PORT_DIPSETTING(      0x0001, DEF_STR( Hard ) )
883   PORT_DIPSETTING(      0x0000, DEF_STR( Very_Hard ) )
884   PORT_DIPNAME( 0x0004, 0x0004, "Disable Instruction Screen" ) /* Manual states this dip is "Unused" */
885   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
886   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
887   PORT_DIPNAME( 0x0018, 0x00018, DEF_STR( Allow_Continue ) )
888   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
889   PORT_DIPSETTING(      0x0010, "Up to Mission 4" )
890   PORT_DIPSETTING(      0x0008, "Not on Final Mission" )
891   PORT_DIPSETTING(      0x0018, DEF_STR( On ) )
892   PORT_DIPNAME( 0x0020, 0x0020, "Intro Music" )
893   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
894   PORT_DIPSETTING(      0x0020, DEF_STR( On ) )
895   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Demo_Sounds ) )
896   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
897   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
898   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
899   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
900   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
901INPUT_PORTS_END
902
903static INPUT_PORTS_START( edf )
904   PORT_INCLUDE( megasys1_generic )
905
906   PORT_START("DSW1")
907   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
908   PORT_DIPSETTING(      0x0004, DEF_STR( 3C_1C ) )
909   PORT_DIPSETTING(      0x0002, DEF_STR( 2C_1C ) )
910   PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) )
911   PORT_DIPSETTING(      0x0003, DEF_STR( 1C_2C ) )
912   PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) )
913   PORT_DIPSETTING(      0x0001, DEF_STR( 1C_4C ) )
914   PORT_DIPSETTING(      0x0006, DEF_STR( 1C_5C ) )
915   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
916   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) )
917   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
918   PORT_DIPSETTING(      0x0020, DEF_STR( 3C_1C ) )
919   PORT_DIPSETTING(      0x0010, DEF_STR( 2C_1C ) )
920   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
921   PORT_DIPSETTING(      0x0018, DEF_STR( 1C_2C ) )
922   PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) )
923   PORT_DIPSETTING(      0x0008, DEF_STR( 1C_4C ) )
924   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_5C ) )
925   PORT_DIPNAME( 0x000040, 0x000040, DEF_STR( Demo_Sounds ) )
926   PORT_DIPSETTING(      0x000000, DEF_STR( Off ) )
927   PORT_DIPSETTING(      0x000040, DEF_STR( On ) )
928   PORT_SERVICE( 0x000080, IP_ACTIVE_LOW )
929
930   PORT_START("DSW2")         /* 0x66007.b */
931   PORT_DIPNAME( 0x0007, 0x0007, "DSW-B bits 2-0" )
932   PORT_DIPSETTING(      0x0000, "0" )
933   PORT_DIPSETTING(      0x0001, "1" )
934   PORT_DIPSETTING(      0x0002, "2" )
935   PORT_DIPSETTING(      0x0003, "3" )
936   PORT_DIPSETTING(      0x0004, "4" )
937   PORT_DIPSETTING(      0x0005, "5" )
938   PORT_DIPSETTING(      0x0006, "6" )
939   PORT_DIPSETTING(      0x0007, "7" )
940   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Lives ) )
941   PORT_DIPSETTING(      0x0008, "3" )
942   PORT_DIPSETTING(      0x0000, "4" )
943   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
944   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
945   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
946   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )
947   PORT_DIPSETTING(      0x0020, DEF_STR( Very_Hard ) )
948   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
949   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
950   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
951   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
952   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
953   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
954INPUT_PORTS_END
955
956static INPUT_PORTS_START( hachoo )
957   PORT_INCLUDE( megasys1_generic )
958
959   PORT_START("DSW")
960   PORT_DIPUNUSED( 0x0001, 0x0001 ) /* Manual states dips 1-4 & 6 are "Unused" */
961   PORT_DIPUNUSED( 0x0002, 0x0002 )
962   PORT_DIPUNUSED( 0x0004, 0x0004 )
963   PORT_DIPUNUSED( 0x0008, 0x0008 )
964   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
965   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
966   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )
967   PORT_DIPSETTING(      0x0010, DEF_STR( Harder ) )
968   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
969   PORT_DIPUNUSED( 0x0040, 0x0040 )
970   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
971   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
972   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
973
974   PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coin_A ) )
975   PORT_DIPSETTING(      0x0400, DEF_STR( 3C_1C ) )
976   PORT_DIPSETTING(      0x0200, DEF_STR( 2C_1C ) )
977   PORT_DIPSETTING(      0x0700, DEF_STR( 1C_1C ) )
978   PORT_DIPSETTING(      0x0300, DEF_STR( 1C_2C ) )
979   PORT_DIPSETTING(      0x0500, DEF_STR( 1C_3C ) )
980   PORT_DIPSETTING(      0x0100, DEF_STR( 1C_4C ) )
981   PORT_DIPSETTING(      0x0600, DEF_STR( 1C_5C ) )
982   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
983   PORT_DIPNAME( 0x3800, 0x3800, DEF_STR( Coin_B ) )
984   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
985   PORT_DIPSETTING(      0x2000, DEF_STR( 3C_1C ) )
986   PORT_DIPSETTING(      0x1000, DEF_STR( 2C_1C ) )
987   PORT_DIPSETTING(      0x3800, DEF_STR( 1C_1C ) )
988   PORT_DIPSETTING(      0x1800, DEF_STR( 1C_2C ) )
989   PORT_DIPSETTING(      0x2800, DEF_STR( 1C_3C ) )
990   PORT_DIPSETTING(      0x0800, DEF_STR( 1C_4C ) )
991   PORT_DIPSETTING(      0x3000, DEF_STR( 1C_5C ) )
992   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Demo_Sounds ) )
993   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
994   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
995   PORT_DIPUNUSED( 0x8000, 0x8000 )
996INPUT_PORTS_END
997
998static INPUT_PORTS_START( kazan )
999   PORT_INCLUDE( hachoo )
1000
1001   PORT_MODIFY("DSW")
1002   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )
1003   PORT_DIPSETTING(      0x0003, "2" )
1004   PORT_DIPSETTING(      0x0001, "3" )
1005   PORT_DIPSETTING(      0x0002, "4" )
1006   PORT_DIPSETTING(      0x0000, "Infinite (Cheat)" )
1007   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Bonus_Life ) )
1008   PORT_DIPSETTING(      0x0004, "50k" )
1009   PORT_DIPSETTING(      0x0000, "200k" )
1010   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Allow_Continue ) )
1011   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1012   PORT_DIPSETTING(      0x0008, DEF_STR( On ) )
1013   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Cabinet ) )
1014   PORT_DIPSETTING(      0x0000, DEF_STR( Upright ) )
1015   PORT_DIPSETTING(      0x0040, DEF_STR( Cocktail ) )
1016
1017   PORT_DIPNAME( 0x8000, 0x8000, "Freeze Screen (Cheat)")
1018   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
1019   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1020INPUT_PORTS_END
1021
1022static INPUT_PORTS_START( jitsupro )
1023   PORT_INCLUDE( hachoo )
1024
1025   PORT_MODIFY("P1")
1026   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
1027
1028   PORT_MODIFY("P2")
1029   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
1030
1031   PORT_MODIFY("DSW")
1032   PORT_DIPNAME( 0x0001, 0x0001, "2 Player Innings per Credit" )
1033   PORT_DIPSETTING(      0x0001, "2" )
1034   PORT_DIPSETTING(      0x0000, "3" )
1035   PORT_DIPNAME( 0x0002, 0x0002, "Difficulty for Catching Ball" )
1036   PORT_DIPSETTING(      0x0002, DEF_STR( Normal ) )   // $200-140
1037   PORT_DIPSETTING(      0x0000, DEF_STR( Hard ) )   // $400-140
1038   PORT_DIPNAME( 0x003c, 0x003c, "Franchise (Increase Batting Power)" )
1039   PORT_DIPSETTING(      0x003c, DEF_STR( Normal )  )
1040   PORT_DIPSETTING(      0x0038, "G"  )
1041   PORT_DIPSETTING(      0x0034, "D"  )
1042   PORT_DIPSETTING(      0x0030, "C"  ) /* I hope the Japanese Baseball crowd knows what these leagues are ;-) */
1043   PORT_DIPSETTING(      0x002c, "S"  )
1044   PORT_DIPSETTING(      0x0028, "W (B)"  )
1045   PORT_DIPSETTING(      0x0024, "T"  )
1046   PORT_DIPSETTING(      0x0020, "L"  )
1047   PORT_DIPSETTING(      0x001c, "Br (Bw)"  )
1048   PORT_DIPSETTING(      0x0018, "F"  )
1049   PORT_DIPSETTING(      0x0014, "H" )
1050   PORT_DIPSETTING(      0x0010, "O (M)" )
1051   PORT_DIPSETTING(      0x000c, "Bu" )
1052//  PORT_DIPSETTING(      0x0008, "13" )
1053//  PORT_DIPSETTING(      0x0004, "14" )
1054//  PORT_DIPSETTING(      0x0000, "15" )
1055   PORT_DIPNAME( 0x0040, 0x0040, "Scroll Is Based On" )
1056   PORT_DIPSETTING(      0x0040, "Shadow of Baseball" )
1057   PORT_DIPSETTING(      0x0000, "The Baseball Itself" )
1058INPUT_PORTS_END
1059
1060static INPUT_PORTS_START( kickoff )
1061   PORT_INCLUDE( megasys1_generic )
1062
1063   PORT_START("DSW")
1064   PORT_DIPNAME( 0x0003, 0x0003, "Time" )   // -> !f0082.w
1065   PORT_DIPSETTING(      0x0003, "3'" )
1066   PORT_DIPSETTING(      0x0002, "4'" )
1067   PORT_DIPSETTING(      0x0001, "5'" )
1068   PORT_DIPSETTING(      0x0000, "6'" )
1069   PORT_DIPUNUSED( 0x0004, 0x0004 ) /* Manual states dips 3 & 4 are "Unused" */
1070   PORT_DIPUNUSED( 0x0008, 0x0008 )
1071   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
1072   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
1073   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )
1074   PORT_DIPSETTING(      0x0010, DEF_STR( Harder ) )
1075   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
1076   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Controls ) )
1077   PORT_DIPSETTING(      0x0040, DEF_STR( Trackball ) )
1078   PORT_DIPSETTING(      0x0000, DEF_STR( Joystick ) )
1079   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
1080   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
1081   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1082
1083   PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coinage ) )
1084   PORT_DIPSETTING(      0x0100, DEF_STR( 4C_1C ) )
1085   PORT_DIPSETTING(      0x0200, DEF_STR( 3C_1C ) )
1086   PORT_DIPSETTING(      0x0300, DEF_STR( 2C_1C ) )
1087   PORT_DIPSETTING(      0x0700, DEF_STR( 1C_1C ) )
1088   PORT_DIPSETTING(      0x0600, DEF_STR( 1C_2C ) )
1089   PORT_DIPSETTING(      0x0500, DEF_STR( 1C_3C ) )
1090   PORT_DIPSETTING(      0x0400, DEF_STR( 1C_4C ) )
1091   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
1092   PORT_DIPUNUSED( 0x0800, 0x0800 )
1093   PORT_DIPUNUSED( 0x1000, 0x1000 )
1094   PORT_DIPNAME( 0x2000, 0x2000, "Freeze Screen (Cheat)" )
1095   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
1096   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1097   PORT_DIPNAME( 0x4000, 0x0000, DEF_STR( Demo_Sounds ) )
1098   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
1099   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1100   PORT_DIPNAME( 0x8000, 0x8000, "Text" )
1101   PORT_DIPSETTING(      0x8000, DEF_STR( Japanese ) )
1102   PORT_DIPSETTING(      0x0000, DEF_STR( English ) )   // show "Japan Only" warning
1103INPUT_PORTS_END
1104
1105static INPUT_PORTS_START( lomakai )
1106   PORT_INCLUDE( megasys1_generic )
1107
1108   PORT_START("DSW")
1109   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )
1110   PORT_DIPSETTING(      0x0000, "2" )
1111   PORT_DIPSETTING(      0x0003, "3" )
1112   PORT_DIPSETTING(      0x0002, "4" )
1113   PORT_DIPSETTING(      0x0001, "5" )
1114   PORT_DIPUNUSED( 0x0004, 0x0004 )
1115   PORT_DIPUNUSED( 0x0008, 0x0008 )
1116   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )   // boss enemy damage bar
1117   PORT_DIPSETTING(      0x0030, DEF_STR( Easy ) )         // 6 dots
1118   PORT_DIPSETTING(      0x0020, DEF_STR( Normal ) )      // 8 dots
1119   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )         // 9 dots
1120   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )      // 12 dots
1121   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Cabinet ) )
1122   PORT_DIPSETTING(      0x0000, DEF_STR( Upright ) )
1123   PORT_DIPSETTING(      0x0040, DEF_STR( Cocktail ) )
1124   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
1125   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
1126   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1127
1128   PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coin_A ) )
1129   PORT_DIPSETTING(      0x0100, DEF_STR( 4C_1C ) )
1130   PORT_DIPSETTING(      0x0200, DEF_STR( 3C_1C ) )
1131   PORT_DIPSETTING(      0x0300, DEF_STR( 2C_1C ) )
1132   PORT_DIPSETTING(      0x0700, DEF_STR( 1C_1C ) )
1133   PORT_DIPSETTING(      0x0600, DEF_STR( 1C_2C ) )
1134   PORT_DIPSETTING(      0x0500, DEF_STR( 1C_3C ) )
1135   PORT_DIPSETTING(      0x0400, DEF_STR( 1C_4C ) )
1136   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
1137   PORT_DIPNAME( 0x3800, 0x3800, DEF_STR( Coin_B ) )
1138   PORT_DIPSETTING(      0x0800, DEF_STR( 4C_1C ) )
1139   PORT_DIPSETTING(      0x1000, DEF_STR( 3C_1C ) )
1140   PORT_DIPSETTING(      0x1800, DEF_STR( 2C_1C ) )
1141   PORT_DIPSETTING(      0x3800, DEF_STR( 1C_1C ) )
1142   PORT_DIPSETTING(      0x3000, DEF_STR( 1C_2C ) )
1143   PORT_DIPSETTING(      0x2800, DEF_STR( 1C_3C ) )
1144   PORT_DIPSETTING(      0x2000, DEF_STR( 1C_4C ) )
1145   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
1146   PORT_DIPNAME( 0x4000, 0x0000, DEF_STR( Demo_Sounds ) )
1147   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
1148   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1149   PORT_DIPNAME( 0x8000, 0x8000, "Invulnerability (Cheat)")
1150   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
1151   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1152INPUT_PORTS_END
1153
1154static INPUT_PORTS_START( p47 )
1155   PORT_INCLUDE( lomakai )
1156
1157   PORT_MODIFY("DSW")    /* Manual states dips 3 & 4 are "Unused" */
1158   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )
1159   PORT_DIPSETTING(      0x0002, "2" )
1160   PORT_DIPSETTING(      0x0003, "3" )
1161   PORT_DIPSETTING(      0x0001, "4" )
1162   PORT_DIPSETTING(      0x0000, "5" )
1163   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
1164   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
1165   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
1166   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )
1167   PORT_DIPSETTING(      0x0010, DEF_STR( Hardest ) )
1168   PORT_DIPUNUSED( 0x0040, 0x0040 ) /* Manual states this dip is "Unused" */
1169INPUT_PORTS_END
1170
1171static INPUT_PORTS_START( plusalph )
1172   PORT_INCLUDE( hachoo )
1173
1174   PORT_MODIFY("DSW")
1175   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )
1176   PORT_DIPSETTING(      0x0003, "3" )
1177   PORT_DIPSETTING(      0x0002, "4" )
1178   PORT_DIPSETTING(      0x0001, "5" )
1179   PORT_DIPSETTING(      0x0000, "Infinite (Cheat)" )
1180   PORT_DIPNAME( 0x0004, 0x0004, "Hyper Laser Beams" )
1181   PORT_DIPSETTING(      0x0000, "2" )
1182   PORT_DIPSETTING(      0x0004, "3" )
1183   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Bonus_Life ) )
1184   PORT_DIPSETTING(      0x0008, "70k and every 200k")      /* As stated in manual, but was 70K & Every 130K */
1185   PORT_DIPSETTING(      0x0000, "100k and 300k Only")      /* As stated in manual, but was 100K & Every 200K */
1186   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
1187   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
1188   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
1189   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )
1190   PORT_DIPSETTING(      0x0020, DEF_STR( Hardest ) )
1191   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Cabinet ) )
1192   PORT_DIPSETTING(      0x0000, DEF_STR( Upright ) )
1193   PORT_DIPSETTING(      0x0040, DEF_STR( Cocktail ) )
1194
1195   PORT_DIPNAME( 0x8000, 0x8000, "Freeze Screen (Cheat)")
1196   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
1197   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1198INPUT_PORTS_END
1199
1200static INPUT_PORTS_START( rodland )
1201   PORT_INCLUDE( hachoo )
1202
1203   PORT_MODIFY("DSW")    /* Manual states dips 1 & 2 are "Unused" */
1204   PORT_DIPNAME( 0x000c, 0x000c, DEF_STR( Lives ) )
1205   PORT_DIPSETTING(      0x0004, "2" )
1206   PORT_DIPSETTING(      0x000c, "3" )
1207   PORT_DIPSETTING(      0x0008, "4" )
1208   PORT_DIPSETTING(      0x0000, "Infinite (Cheat)")
1209   PORT_DIPNAME( 0x0010, 0x0010, "Default episode" )
1210   PORT_DIPSETTING(      0x0010, "1" )
1211   PORT_DIPSETTING(      0x0000, "2" )
1212   PORT_DIPNAME( 0x0060, 0x0060, DEF_STR( Difficulty ) )
1213   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
1214   PORT_DIPSETTING(      0x0060, DEF_STR( Normal ) )
1215   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )
1216   PORT_DIPSETTING(      0x0040, DEF_STR( Hardest ) )
1217
1218   PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
1219INPUT_PORTS_END
1220
1221static INPUT_PORTS_START( stdragon )
1222   PORT_INCLUDE( lomakai )
1223
1224   PORT_MODIFY("DSW")   /* Manual states dips 3 & 4 are "Unused" */
1225   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )
1226   PORT_DIPSETTING(      0x0002, "2" )
1227   PORT_DIPSETTING(      0x0003, "3" )
1228   PORT_DIPSETTING(      0x0001, "4" )
1229   PORT_DIPSETTING(      0x0000, "5" )
1230   PORT_DIPUNUSED( 0x8000, 0x8000 )   // used?
1231INPUT_PORTS_END
1232
1233static INPUT_PORTS_START( soldam )
1234   PORT_INCLUDE( lomakai )
1235
1236   PORT_MODIFY("DSW")
1237   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) )
1238   PORT_DIPSETTING(      0x0000, DEF_STR( Easy )   )
1239   PORT_DIPSETTING(      0x0003, DEF_STR( Normal ) )
1240   PORT_DIPSETTING(      0x0002, DEF_STR( Hard )   )
1241   PORT_DIPSETTING(      0x0001, DEF_STR( Hardest ))
1242   PORT_DIPNAME( 0x000c, 0x000c, "Games To Play (Vs)" )
1243   PORT_DIPSETTING(      0x0000, "1" )
1244   PORT_DIPSETTING(      0x000c, "2" )
1245   PORT_DIPSETTING(      0x0008, "3" )
1246   PORT_DIPSETTING(      0x0004, "4" )
1247   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Allow_Continue ) )
1248   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1249   PORT_DIPSETTING(      0x0010, DEF_STR( On ) )
1250   PORT_DIPNAME( 0x0020, 0x0020, "Credits To Start (Vs)" )
1251   PORT_DIPSETTING(      0x0020, "1" )
1252   PORT_DIPSETTING(      0x0000, "2" )
1253   PORT_DIPNAME( 0x0040, 0x0040, "Credits To Continue (Vs)" )
1254   PORT_DIPSETTING(      0x0040, "1" )
1255   PORT_DIPSETTING(      0x0000, "2" )
1256   PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
1257INPUT_PORTS_END
1258
1259static INPUT_PORTS_START( tshingen )
1260   PORT_INCLUDE( hachoo )
1261
1262   PORT_MODIFY("P1")
1263   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
1264
1265   PORT_MODIFY("P2")
1266   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
1267
1268   PORT_MODIFY("DSW")
1269   PORT_DIPNAME( 0x0003, 0x0001, DEF_STR( Lives ) )
1270   PORT_DIPSETTING(      0x0003, "2" )
1271   PORT_DIPSETTING(      0x0001, "3" )
1272   PORT_DIPSETTING(      0x0002, "4" )
1273   PORT_DIPSETTING(      0x0000, "Infinite (Cheat)" )
1274   PORT_DIPNAME( 0x000c, 0x000c, DEF_STR( Bonus_Life ) )
1275   PORT_DIPSETTING(      0x000c, "20k" )
1276   PORT_DIPSETTING(      0x0004, "30k" )
1277   PORT_DIPSETTING(      0x0008, "40k" )
1278   PORT_DIPSETTING(      0x0000, "50k" )
1279   PORT_DIPNAME( 0x0030, 0x0010, DEF_STR( Difficulty ) )   // damage when hit
1280   PORT_DIPSETTING(      0x0030, DEF_STR( Easy ) )         // 0
1281   PORT_DIPSETTING(      0x0010, DEF_STR( Normal )  )      // 1
1282   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )         // 2
1283   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )      // 3
1284   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Allow_Continue ) )
1285   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1286   PORT_DIPSETTING(      0x0040, DEF_STR( On ) )
1287INPUT_PORTS_END
1288
1289static INPUT_PORTS_START( hayaosi1 )
1290   PORT_START("SYSTEM")
1291   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 )
1292   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START2 )
1293   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN )
1294   PORT_SERVICE_NO_TOGGLE( 0x0008, IP_ACTIVE_LOW )
1295   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START3 )
1296   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_SERVICE1 )
1297   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_COIN1 )
1298   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN2 )
1299   PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
1300
1301   PORT_START("P1")
1302   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
1303   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
1304   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
1305   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
1306   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(3)
1307   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)
1308   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(1)
1309   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(3)
1310   PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
1311
1312   PORT_START("P2")
1313   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)
1314   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
1315   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1)
1316   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
1317   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(3)
1318   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3)
1319   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(2)
1320   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
1321
1322   PORT_START("DSW1")
1323   COINAGE_8BITS
1324
1325   PORT_START("DSW2")         /* 0x69353.b */
1326   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
1327   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
1328   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1329   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Demo_Sounds ) )
1330   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1331   PORT_DIPSETTING(      0x0002, DEF_STR( On ) )
1332   PORT_DIPNAME( 0x0004, 0x0004, "Unknown 2-2" )
1333   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
1334   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1335   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Difficulty ) )
1336   PORT_DIPSETTING(      0x0010, DEF_STR( Easy ) )
1337   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
1338   PORT_DIPSETTING(      0x0008, DEF_STR( Hard ) )
1339   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
1340   PORT_DIPNAME( 0x0020, 0x0020, "Points To Win" )
1341   PORT_DIPSETTING(      0x0000, "10" )
1342   PORT_DIPSETTING(      0x0020, "15" )
1343   PORT_DIPNAME( 0x0040, 0x0040, "Unknown 2-6" )
1344   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
1345   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1346   PORT_DIPNAME( 0x0080, 0x0080, "Unknown 2-7" )
1347   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
1348   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1349INPUT_PORTS_END
1350
1351static INPUT_PORTS_START( peekaboo )
1352   PORT_START("SYSTEM")
1353   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN3 )      // called "service"
1354   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN4 )      // called "test"
1355   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN1 )
1356   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN2 )
1357   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START1 )
1358   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_START2 )
1359   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
1360   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
1361   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 )
1362   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON2 )
1363   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
1364   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
1365   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON3 )      // called "stage clear"
1366   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON4 )      // called "option"
1367   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1368   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1369
1370   PORT_START("P1")
1371   PORT_BIT( 0x00ff, 0x0080, IPT_PADDLE ) PORT_PLAYER(1) PORT_MINMAX(0x0018,0x00e0) PORT_SENSITIVITY(50) PORT_KEYDELTA(10) PORT_CENTERDELTA(0)
1372
1373   PORT_START("P2")
1374   PORT_BIT( 0x00ff, 0x0080, IPT_PADDLE ) PORT_PLAYER(2) PORT_MINMAX(0x0018,0x00e0) PORT_SENSITIVITY(50) PORT_KEYDELTA(10) PORT_CENTERDELTA(0) PORT_COCKTAIL
1375
1376   PORT_START("DSW")
1377   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) )      // 1f0358<-!
1378   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
1379   PORT_DIPSETTING(      0x0003, DEF_STR( Normal ) )
1380   PORT_DIPSETTING(      0x0002, DEF_STR( Hard ) )
1381   PORT_DIPSETTING(      0x0001, DEF_STR( Hardest ) )
1382   PORT_SERVICE( 0x0004, IP_ACTIVE_LOW )
1383   PORT_DIPNAME( 0x0008, 0x0008, "Movement" )               // 1f0392<-!
1384   PORT_DIPSETTING(      0x0008, "Paddles" )
1385   PORT_DIPSETTING(      0x0000, "Buttons" )
1386   PORT_DIPNAME( 0x0030, 0x0030, "Nudity" )               // 1f0356<-!
1387   PORT_DIPSETTING(      0x0030, "Female and Male (Full)" )
1388   PORT_DIPSETTING(      0x0020, "Female (Full)" )
1389   PORT_DIPSETTING(      0x0010, "Female (Partial)" )
1390   PORT_DIPSETTING(      0x0000, DEF_STR( None ) )
1391   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Cabinet ) )         // 1f006a<-!
1392   PORT_DIPSETTING(      0x0040, DEF_STR( Upright ) )
1393   PORT_DIPSETTING(      0x0000, DEF_STR( Cocktail ) )
1394   PORT_DIPNAME( 0x0080, 0x0080, "Number of controllers" )      // 1f0074<-!
1395   PORT_DIPSETTING(      0x0080, "1" )
1396   PORT_DIPSETTING(      0x0000, "2" )
1397
1398   PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coin_A ) )
1399   PORT_DIPSETTING(      0x0100, DEF_STR( 4C_1C ) )
1400   PORT_DIPSETTING(      0x0200, DEF_STR( 3C_1C ) )
1401   PORT_DIPSETTING(      0x0300, DEF_STR( 2C_1C ) )
1402   PORT_DIPSETTING(      0x0700, DEF_STR( 1C_1C ) )
1403   PORT_DIPSETTING(      0x0600, DEF_STR( 1C_2C ) )
1404   PORT_DIPSETTING(      0x0500, DEF_STR( 1C_3C ) )
1405   PORT_DIPSETTING(      0x0400, DEF_STR( 1C_4C ) )
1406   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
1407   PORT_DIPNAME( 0x3800, 0x3800, DEF_STR( Coin_B ) )
1408   PORT_DIPSETTING(      0x0800, DEF_STR( 4C_1C ) )
1409   PORT_DIPSETTING(      0x1000, DEF_STR( 3C_1C ) )
1410   PORT_DIPSETTING(      0x1800, DEF_STR( 2C_1C ) )
1411   PORT_DIPSETTING(      0x3800, DEF_STR( 1C_1C ) )
1412   PORT_DIPSETTING(      0x3000, DEF_STR( 1C_2C ) )
1413   PORT_DIPSETTING(      0x2800, DEF_STR( 1C_3C ) )
1414   PORT_DIPSETTING(      0x2000, DEF_STR( 1C_4C ) )
1415   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
1416   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Demo_Sounds ) )      // 1f0354<-
1417   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1418   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
1419   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Flip_Screen ) )      // 1f0022/6e<-!
1420   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
1421   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1422INPUT_PORTS_END
1423
1424/*************************************
1425 *
1426 *  Peek-a-Boo! Custom I/O
1427 *
1428 *************************************/
1429
1430static UINT16 protection_val;
1431
1432/* Read the input ports, through a protection device */
1433static READ16_HANDLER( protection_peekaboo_r )
1434{
1435   switch (protection_val)
1436   {
1437      case 0x02:   return 0x03;
1438      case 0x51:   return input_port_read(space->machine, "P1");
1439      case 0x52:   return input_port_read(space->machine, "P2");
1440      default:   return protection_val;
1441   }
1442}
1443
1444static WRITE16_HANDLER( protection_peekaboo_w )
1445{
1446   static int bank;
1447
1448   COMBINE_DATA(&protection_val);
1449
1450   if ((protection_val & 0x90) == 0x90)
1451   {
1452      UINT8 *RAM = memory_region(space->machine, "oki1");
1453      int new_bank = (protection_val & 0x7) % 7;
1454
1455      if (bank != new_bank)
1456      {
1457         memcpy(&RAM[0x20000],&RAM[0x40000 + 0x20000*new_bank],0x20000);
1458         bank = new_bank;
1459      }
1460   }
1461
1462   cpu_set_input_line(space->machine->cpu[0],4,HOLD_LINE);
1463}
1464
1465/*************************************
1466 *
1467 *  Graphics definitions
1468 *
1469 *************************************/
1470
5421471static const gfx_layout tilelayout =
5431472{
5441473   8,8,
r4135r4136
5741503   GFXDECODE_ENTRY( "gfx4", 0, spritelayout, 256*3, 16 )   // [3] Sprites
5751504GFXDECODE_END
5761505
1506/*************************************
1507 *
1508 *  Machine Driver Macros
1509 *
1510 *************************************/
5771511
5781512/***************************************************************************
5791513
580                            Machine Driver Macros
581
582***************************************************************************/
583
584/***************************************************************************
585
5861514                        [  Mega System 1 A,B and C ]
5871515
5881516                          2x68000 2xM6295 1xYM2151
r4135r4136
8011729MACHINE_DRIVER_END
8021730
8031731
1732/*************************************
1733 *
1734 *  ROM definition(s)
1735 *
1736 *************************************/
8041737
805
806
8071738/***************************************************************************
8081739
809                                ROMs Loading
810
811***************************************************************************/
812
813
814
815/***************************************************************************
816
8171740                            [ 64th Street ]
8181741
8191742It runs on 1 MC68000P12 and 1 MC6800P10
r4135r4136
8501773
8511774***************************************************************************/
8521775
1776
8531777ROM_START( 64street )
8541778   ROM_REGION( 0x80000, "main", 0 )      /* Main CPU Code */
8551779   ROM_LOAD16_BYTE( "64th_03.rom", 0x000000, 0x040000, CRC(ed6c6942) SHA1(f610b31548ed4889a43d77be286b9bfabf700064) )
r4135r4136
9221846ROM_END
9231847
9241848
925
926static INPUT_PORTS_START( 64street )
927   PORT_START("SYSTEM")
928   COINS
929
930   PORT_START("P1")
931   JOY_2BUTTONS(1)      //  fire    jump
932
933   PORT_START("P2")
934   JOY_2BUTTONS(2)
935   RESERVE            // Unused
936
937   PORT_START("DSW1")
938   COINAGE_8BITS
939
940   PORT_START("DSW2")
941   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
942   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
943   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
944   PORT_DIPNAME( 0x0002, 0x0000, DEF_STR( Demo_Sounds ) )
945   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
946   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
947   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Allow_Continue ) )
948   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
949   PORT_DIPSETTING(      0x0004, DEF_STR( On ) )
950   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Difficulty ) )
951   PORT_DIPSETTING(      0x0010, DEF_STR( Easy ) )
952   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
953   PORT_DIPSETTING(      0x0008, DEF_STR( Hard ) )
954   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
955   PORT_DIPNAME( 0x0060, 0x0020, DEF_STR( Lives ) )
956   PORT_DIPSETTING(      0x0040, "1" )
957   PORT_DIPSETTING(      0x0060, "2" )
958   PORT_DIPSETTING(      0x0020, "3" )
959   PORT_DIPSETTING(      0x0000, "5" )
960   PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
961INPUT_PORTS_END
962
963
9641849/***************************************************************************
9651850
9661851                    [ The Astyanax ] / [ The Lord of King ]
r4135r4136
10141899   ROM_LOAD( "rd.bpr",       0x0000, 0x0200, CRC(85b30ac4) SHA1(b03f577ceb0f26b67453ffa52ef61fea76a93184) )
10151900ROM_END
10161901
1902
10171903ROM_START( lordofk )
10181904   ROM_REGION( 0x80000, "main", 0 )      /* Main CPU Code */
10191905   ROM_LOAD16_BYTE( "lokj02.bin", 0x00000, 0x20000, CRC(0d7f9b4a) SHA1(551f237cd60e3b9aa339e393a672b08645b043cc) )
r4135r4136
10591945ROM_END
10601946
10611947
1062static INPUT_PORTS_START( astyanax )
1063   PORT_START("SYSTEM")   /* 0x80001.b */
1064   COINS
1065
1066   PORT_START("P1")   /* 0x80003.b */
1067   JOY_3BUTTONS(1)      //  fire    jump    magic
1068
1069   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
1070   JOY_3BUTTONS(2)
1071   RESERVE
1072
1073   PORT_START("DSW")
1074   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unknown ) ) // according to manual
1075   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
1076   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1077   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) // according to manual
1078   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
1079   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1080   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Bonus_Life ) )
1081   PORT_DIPSETTING(      0x0004, "30k 70k 110k then every 30k" )
1082   PORT_DIPSETTING(      0x0000, "50k 100k then every 40k" )
1083   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Lives ) )
1084   PORT_DIPSETTING(      0x0008, "2" )
1085   PORT_DIPSETTING(      0x0018, "3" )
1086   PORT_DIPSETTING(      0x0010, "4" )
1087   PORT_DIPSETTING(      0x0000, "5" )
1088   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Difficulty ) )
1089   PORT_DIPSETTING(      0x0020, DEF_STR( Normal ) )
1090   PORT_DIPSETTING(      0x0000, DEF_STR( Hard ) )
1091   PORT_DIPNAME( 0x0040, 0x0040, "Swap 1P/2P Controls" )
1092   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
1093   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1094   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
1095   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
1096   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1097
1098   PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coin_A ) )
1099   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
1100   PORT_DIPSETTING(      0x0400, DEF_STR( 3C_1C ) )
1101   PORT_DIPSETTING(      0x0200, DEF_STR( 2C_1C ) )
1102   PORT_DIPSETTING(      0x0700, DEF_STR( 1C_1C ) )
1103//  PORT_DIPSETTING(      0x0300, DEF_STR( 1C_1C ) )    // 1_2 shown in test mode
1104//  PORT_DIPSETTING(      0x0500, DEF_STR( 1C_1C ) )    // 1_3
1105//  PORT_DIPSETTING(      0x0100, DEF_STR( 1C_1C ) )    // 1_4
1106//  PORT_DIPSETTING(      0x0600, DEF_STR( 1C_1C ) )    // 1_5
1107   PORT_DIPNAME( 0x3800, 0x3800, DEF_STR( Coin_B ) )
1108   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
1109   PORT_DIPSETTING(      0x2000, DEF_STR( 3C_1C ) )
1110   PORT_DIPSETTING(      0x1000, DEF_STR( 2C_1C ) )
1111   PORT_DIPSETTING(      0x3800, DEF_STR( 1C_1C ) )
1112//  PORT_DIPSETTING(      0x1800, DEF_STR( 1C_1C ) )    // 1_2 shown in test mode
1113//  PORT_DIPSETTING(      0x2800, DEF_STR( 1C_1C ) )    // 1_3
1114//  PORT_DIPSETTING(      0x0800, DEF_STR( 1C_1C ) )    // 1_4
1115//  PORT_DIPSETTING(      0x3000, DEF_STR( 1C_1C ) )    // 1_5
1116   PORT_DIPNAME( 0x4000, 0x0000, DEF_STR( Demo_Sounds ) )
1117   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
1118   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1119   PORT_DIPNAME( 0x8000, 0x8000, "Test Mode" )
1120   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
1121   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1122INPUT_PORTS_END
1123
1124
1125
11261948/***************************************************************************
11271949
11281950                    [ Avenging Spirit ] / [ Phantasm ]
r4135r4136
11611983
11621984***************************************************************************/
11631985
1986
11641987ROM_START( avspirit )
11651988   ROM_REGION( 0xc0000, "main", 0 )      /* Main CPU Code: 00000-3ffff & 80000-bffff */
11661989   ROM_LOAD16_BYTE( "spirit05.rom",  0x000000, 0x020000, CRC(b26a341a) SHA1(5ff5b7d3aa73cc7cea7b6e8cc2ba55f4cd9b52e5) )
r4135r4136
12402063   ROM_LOAD( "ph.bin",        0x0000, 0x0200, CRC(8359650a) SHA1(97d0105f06c64340fb19a541db03481a7e0b5e05) )
12412064ROM_END
12422065
1243/*
12442066
2067/***************************************************************************
2068
12452069Monky Elf
12462070
12472071PCB Layout
r4135r4136
12732097     YM2151 clock 3.000MHz [12/4]
12742098     M6295 clocks 3.000MHz [12/4] pin 7 high
12752099
1276*/
2100***************************************************************************/
12772101
2102
12782103ROM_START( monkelf )
12792104   ROM_REGION( 0xc0000, "main", 0 )      /* Main CPU Code: 00000-3ffff & 80000-bffff */
12802105   ROM_LOAD16_BYTE( "6",  0x000000, 0x020000, CRC(40b80914) SHA1(103dd3531b6b270e0d756801ff5ac69db5c6b82f) )
r4135r4136
13112136ROM_END
13122137
13132138
1314static INPUT_PORTS_START( avspirit )
1315   PORT_START("SYSTEM")
1316   COINS
1317
1318   PORT_START("P1")
1319   JOY_2BUTTONS(1)
1320
1321   PORT_START("P2")
1322   JOY_2BUTTONS(2)
1323   RESERVE
1324
1325   PORT_START("DSW1")
1326   COINAGE_8BITS
1327
1328   PORT_START("DSW2")
1329   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
1330   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
1331   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1332   PORT_DIPNAME( 0x0002, 0x0000, DEF_STR( Demo_Sounds ) )
1333   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
1334   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1335   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Allow_Continue ) )
1336   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1337   PORT_DIPSETTING(      0x0004, DEF_STR( On ) )
1338   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Difficulty ) )
1339   PORT_DIPSETTING(      0x0008, DEF_STR( Easy ) )
1340   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
1341   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )
1342   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
1343   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Cabinet ) )
1344   PORT_DIPSETTING(      0x0020, DEF_STR( Upright ) )
1345   PORT_DIPSETTING(      0x0000, DEF_STR( Cocktail ) )
1346   PORT_DIPNAME( 0x0040, 0x0040, "Test Mode" ) // freeze & slow motion via P1 + P2 start
1347   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
1348   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1349   PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
1350INPUT_PORTS_END
1351
1352
1353static INPUT_PORTS_START( phantasm )
1354   PORT_START("SYSTEM")
1355   COINS
1356
1357   PORT_START("P1")
1358   JOY_2BUTTONS(1)
1359
1360   PORT_START("P2")
1361   JOY_2BUTTONS(2)
1362   RESERVE
1363
1364   PORT_START("DSW")
1365   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
1366   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
1367   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1368   PORT_DIPNAME( 0x0002, 0x0000, DEF_STR( Demo_Sounds ) )
1369   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
1370   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1371   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Allow_Continue ) )
1372   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1373   PORT_DIPSETTING(      0x0004, DEF_STR( On ) )
1374   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Difficulty ) )
1375   PORT_DIPSETTING(      0x0008, DEF_STR( Easy ) )
1376   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
1377   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )
1378   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
1379   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Cabinet ) )
1380   PORT_DIPSETTING(      0x0020, DEF_STR( Upright ) )
1381   PORT_DIPSETTING(      0x0000, DEF_STR( Cocktail ) )
1382   PORT_DIPNAME( 0x0040, 0x0040, "Test Mode" ) // freeze & slow motion via P1 + P2 start
1383   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
1384   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1385   PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
1386
1387   PORT_DIPNAME( 0x0f00, 0x0f00, DEF_STR( Coin_A ) )
1388   PORT_DIPSETTING(      0x0700, DEF_STR( 4C_1C ) )
1389   PORT_DIPSETTING(      0x0800, DEF_STR( 3C_1C ) )
1390   PORT_DIPSETTING(      0x0900, DEF_STR( 2C_1C ) )
1391   PORT_DIPSETTING(      0x0f00, DEF_STR( 1C_1C ) )
1392/*  PORT_DIPSETTING(      0x0500, DEF_STR( 1C_1C ) )*/
1393/*  PORT_DIPSETTING(      0x0400, DEF_STR( 1C_1C ) )*/
1394/*  PORT_DIPSETTING(      0x0300, DEF_STR( 1C_1C ) )*/
1395/*  PORT_DIPSETTING(      0x0200, DEF_STR( 1C_1C ) )*/
1396/*  PORT_DIPSETTING(      0x0100, DEF_STR( 1C_1C ) )*/
1397   PORT_DIPSETTING(      0x0600, DEF_STR( 2C_3C ) )
1398   PORT_DIPSETTING(      0x0e00, DEF_STR( 1C_2C ) )
1399   PORT_DIPSETTING(      0x0d00, DEF_STR( 1C_3C ) )
1400   PORT_DIPSETTING(      0x0c00, DEF_STR( 1C_4C ) )
1401   PORT_DIPSETTING(      0x0b00, DEF_STR( 1C_5C ) )
1402   PORT_DIPSETTING(      0x0a00, DEF_STR( 1C_6C ) )
1403   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
1404   PORT_DIPNAME( 0xf000, 0xf000, DEF_STR( Coin_B ) )
1405   PORT_DIPSETTING(      0x7000, DEF_STR( 4C_1C ) )
1406   PORT_DIPSETTING(      0x8000, DEF_STR( 3C_1C ) )
1407   PORT_DIPSETTING(      0x9000, DEF_STR( 2C_1C ) )
1408   PORT_DIPSETTING(      0xf000, DEF_STR( 1C_1C ) )
1409/*  PORT_DIPSETTING(      0x5000, DEF_STR( 1C_1C ) )*/
1410/*  PORT_DIPSETTING(      0x4000, DEF_STR( 1C_1C ) )*/
1411/*  PORT_DIPSETTING(      0x3000, DEF_STR( 1C_1C ) )*/
1412/*  PORT_DIPSETTING(      0x2000, DEF_STR( 1C_1C ) )*/
1413/*  PORT_DIPSETTING(      0x1000, DEF_STR( 1C_1C ) )*/
1414   PORT_DIPSETTING(      0x6000, DEF_STR( 2C_3C ) )
1415   PORT_DIPSETTING(      0xe000, DEF_STR( 1C_2C ) )
1416   PORT_DIPSETTING(      0xd000, DEF_STR( 1C_3C ) )
1417   PORT_DIPSETTING(      0xc000, DEF_STR( 1C_4C ) )
1418   PORT_DIPSETTING(      0xb000, DEF_STR( 1C_5C ) )
1419   PORT_DIPSETTING(      0xa000, DEF_STR( 1C_6C ) )
1420   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
1421INPUT_PORTS_END
1422
1423
1424
14252139/***************************************************************************
14262140
14272141                            [ Big Striker ]
r4135r4136
14482162
14492163***************************************************************************/
14502164
2165
14512166ROM_START( bigstrik )
14522167   ROM_REGION( 0x80000, "main", 0 )      /* Main CPU Code */
14532168   ROM_LOAD16_BYTE( "91105v11.3", 0x000000, 0x020000, CRC(5d6e08ec) SHA1(4b80a5073cd0b0142cad094816b935d750ac11fb) )
r4135r4136
14832198ROM_END
14842199
14852200
1486static INPUT_PORTS_START( bigstrik )
1487   PORT_START("SYSTEM")
1488   COINS
1489
1490   PORT_START("P1")
1491   JOY_3BUTTONS(1)      //  pass    shoot   feint
1492
1493   PORT_START("P2")
1494   JOY_3BUTTONS(2)
1495   RESERVE
1496
1497   PORT_START("DSW1")
1498   PORT_DIPNAME( 0x000f, 0x000f, DEF_STR( Coin_A ) )
1499   PORT_DIPSETTING(      0x0007, DEF_STR( 4C_1C ) )
1500   PORT_DIPSETTING(      0x0008, DEF_STR( 3C_1C ) )
1501   PORT_DIPSETTING(      0x0009, DEF_STR( 2C_1C ) )
1502   PORT_DIPSETTING(      0x000f, DEF_STR( 1C_1C ) )
1503   PORT_DIPSETTING(      0x0005, DEF_STR( 2C_3C ) )
1504//  PORT_DIPSETTING(      0x0004, DEF_STR( 2C_3C ) )
1505//  PORT_DIPSETTING(      0x0003, DEF_STR( 2C_3C ) )
1506//  PORT_DIPSETTING(      0x0002, DEF_STR( 2C_3C ) )
1507//  PORT_DIPSETTING(      0x0001, DEF_STR( 2C_3C ) )
1508//  PORT_DIPSETTING(      0x0006, DEF_STR( 2C_3C ) )
1509   PORT_DIPSETTING(      0x000e, DEF_STR( 1C_2C ) )
1510   PORT_DIPSETTING(      0x000d, DEF_STR( 1C_3C ) )
1511   PORT_DIPSETTING(      0x000c, DEF_STR( 1C_4C ) )
1512   PORT_DIPSETTING(      0x000b, DEF_STR( 1C_5C ) )
1513   PORT_DIPSETTING(      0x000a, DEF_STR( 1C_6C ) )
1514   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
1515   PORT_DIPNAME( 0x00f0, 0x00f0, DEF_STR( Coin_B ) )
1516   PORT_DIPSETTING(      0x0070, DEF_STR( 4C_1C ) )
1517   PORT_DIPSETTING(      0x0080, DEF_STR( 3C_1C ) )
1518   PORT_DIPSETTING(      0x0090, DEF_STR( 2C_1C ) )
1519   PORT_DIPSETTING(      0x00f0, DEF_STR( 1C_1C ) )
1520   PORT_DIPSETTING(      0x0050, DEF_STR( 2C_3C ) )
1521//  PORT_DIPSETTING(      0x0040, DEF_STR( 2C_3C ) )
1522//  PORT_DIPSETTING(      0x0030, DEF_STR( 2C_3C ) )
1523//  PORT_DIPSETTING(      0x0020, DEF_STR( 2C_3C ) )
1524//  PORT_DIPSETTING(      0x0010, DEF_STR( 2C_3C ) )
1525//  PORT_DIPSETTING(      0x0060, DEF_STR( 2C_3C ) )
1526   PORT_DIPSETTING(      0x00e0, DEF_STR( 1C_2C ) )
1527   PORT_DIPSETTING(      0x00d0, DEF_STR( 1C_3C ) )
1528   PORT_DIPSETTING(      0x00c0, DEF_STR( 1C_4C ) )
1529   PORT_DIPSETTING(      0x00b0, DEF_STR( 1C_5C ) )
1530   PORT_DIPSETTING(      0x00a0, DEF_STR( 1C_6C ) )
1531   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
1532
1533   PORT_START("DSW2")
1534   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
1535   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
1536   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1537   PORT_DIPNAME( 0x0006, 0x0006, DEF_STR( Difficulty ) )
1538   PORT_DIPSETTING(      0x0002, DEF_STR( Easy ) )
1539   PORT_DIPSETTING(      0x0006, DEF_STR( Normal )  )
1540   PORT_DIPSETTING(      0x0004, DEF_STR( Hard ) )
1541   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
1542   PORT_DIPNAME( 0x0018, 0x0018, "Time" )
1543   PORT_DIPSETTING(      0x0000, "Very Short" )
1544   PORT_DIPSETTING(      0x0010, "Short" )
1545   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
1546   PORT_DIPSETTING(      0x0008, "Long" )
1547   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Demo_Sounds ) )
1548   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1549   PORT_DIPSETTING(      0x0020, DEF_STR( On ) )
1550   PORT_DIPNAME( 0x0040, 0x0040, "1 Credit 2 Play" )
1551   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
1552   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1553   PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
1554INPUT_PORTS_END
1555
1556
15572201/***************************************************************************
15582202
15592203                            [ Chimera Beast ]
r4135r4136
15662210
15672211***************************************************************************/
15682212
2213
15692214ROM_START( chimerab )
15702215   ROM_REGION( 0x80000, "main", 0 )      /* Main CPU Code */
15712216   ROM_LOAD16_BYTE( "prg3.bin", 0x000000, 0x040000, CRC(70f1448f) SHA1(60aaee1cf7aa15ffa4962d947747b0ae7cdcfd8a) )
r4135r4136
16012246   ROM_LOAD( "prom",         0x0000, 0x0200, NO_DUMP )
16022247ROM_END
16032248
1604static INPUT_PORTS_START( chimerab )
1605   PORT_START("SYSTEM")
1606   COINS
16072249
1608   PORT_START("P1")
1609   JOY_2BUTTONS(1)      //  fire    jump    unused?(shown in service mode, but not in instructions)
1610
1611   PORT_START("P2")
1612   JOY_2BUTTONS(2)
1613   RESERVE            // Unused
1614
1615   PORT_START("DSW1")
1616   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
1617   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
1618   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1619   PORT_DIPNAME( 0x0002, 0x0000, DEF_STR( Demo_Sounds ) )
1620   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
1621   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1622   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Allow_Continue ) )
1623   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1624   PORT_DIPSETTING(      0x0004, DEF_STR( On ) )
1625   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Difficulty ) )
1626   PORT_DIPSETTING(      0x0010, DEF_STR( Easy ) )
1627   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
1628   PORT_DIPSETTING(      0x0008, DEF_STR( Hard ) )
1629   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
1630   PORT_DIPNAME( 0x0060, 0x0020, DEF_STR( Lives ) )
1631   PORT_DIPSETTING(      0x0040, "1" )
1632   PORT_DIPSETTING(      0x0060, "2" )
1633   PORT_DIPSETTING(      0x0020, "3" )
1634   PORT_DIPSETTING(      0x0000, "4" )
1635   PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
1636
1637   PORT_START("DSW2")
1638   COINAGE_8BITS
1639INPUT_PORTS_END
1640
1641
1642
16432250/***************************************************************************
16442251
16452252                                [ Cybattler ]
r4135r4136
16912298
16922299***************************************************************************/
16932300
2301
16942302ROM_START( cybattlr )
16952303   ROM_REGION( 0x80000, "main", 0 )      /* Main CPU Code */
16962304   ROM_LOAD16_BYTE( "cb_03.rom", 0x000000, 0x040000, CRC(bee20587) SHA1(3c1d546c63a3d6f8a63b7dee1c8e99a7091d774d) )
r4135r4136
17262334   ROM_LOAD( "pr-91028.12",  0x0000, 0x0200, CRC(cfe90082) SHA1(b59991ec7b3e83ba645b709547e5b4cbe03c0f11) )
17272335ROM_END
17282336
1729static INPUT_PORTS_START( cybattlr )
1730   PORT_START("SYSTEM")
1731   COINS
17322337
1733   PORT_START("P1")
1734   JOY_2BUTTONS(1)      //  fire    sword
1735
1736   PORT_START("P2")
1737   JOY_2BUTTONS(2)
1738   RESERVE            // Unused
1739
1740   PORT_START("DSW1")      /*1fd2d9.b, !1fd009.b */
1741   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
1742   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
1743   PORT_DIPSETTING(      0x0001, DEF_STR( 3C_1C ) )
1744   PORT_DIPSETTING(      0x0003, DEF_STR( 2C_1C ) )
1745   PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) )
1746   PORT_DIPSETTING(      0x0002, DEF_STR( 2C_3C ) )
1747   PORT_DIPSETTING(      0x0006, DEF_STR( 1C_2C ) )
1748   PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) )
1749   PORT_DIPSETTING(      0x0004, DEF_STR( 1C_4C ) )
1750   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) )
1751   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
1752   PORT_DIPSETTING(      0x0008, DEF_STR( 3C_1C ) )
1753   PORT_DIPSETTING(      0x0018, DEF_STR( 2C_1C ) )
1754   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
1755   PORT_DIPSETTING(      0x0010, DEF_STR( 2C_3C ) )
1756   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_2C ) )
1757   PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) )
1758   PORT_DIPSETTING(      0x0020, DEF_STR( 1C_4C ) )
1759   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Free_Play ) )
1760   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
1761   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1762   PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
1763
1764   PORT_START("DSW2")      /* 1fd2d7.b, !1fd007.b */
1765   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) )
1766   PORT_DIPSETTING(      0x0002, DEF_STR( Easy ) )
1767   PORT_DIPSETTING(      0x0003, DEF_STR( Normal ) )
1768   PORT_DIPSETTING(      0x0001, DEF_STR( Hard ) )
1769   PORT_DIPSETTING(      0x0000, DEF_STR( Very_Hard ) )
1770   PORT_DIPNAME( 0x0004, 0x0004, "Disable Instruction Screen" ) /* Manual states this dip is "Unused" */
1771   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
1772   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1773   PORT_DIPNAME( 0x0018, 0x00018, DEF_STR( Allow_Continue ) )
1774   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1775   PORT_DIPSETTING(      0x0010, "Up to Mission 4" )
1776   PORT_DIPSETTING(      0x0008, "Not on Final Mission" )
1777   PORT_DIPSETTING(      0x0018, DEF_STR( On ) )
1778   PORT_DIPNAME( 0x0020, 0x0020, "Intro Music" )
1779   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
1780   PORT_DIPSETTING(      0x0020, DEF_STR( On ) )
1781   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Demo_Sounds ) )
1782   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
1783   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1784   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
1785   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
1786   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1787INPUT_PORTS_END
1788
1789
1790
1791
17922338/***************************************************************************
17932339
17942340                         [ Earth Defense Force ]
r4135r4136
18122358
18132359***************************************************************************/
18142360
2361
18152362ROM_START( edf )
18162363   ROM_REGION( 0xc0000, "main", 0 )      /* Main CPU Code: 00000-3ffff & 80000-bffff */
18172364   ROM_LOAD16_BYTE( "edf5.b5",  0x000000, 0x020000, CRC(105094d1) SHA1(e962164836756bc20c2b5dc0032042a0219e82d8) )
r4135r4136
18482395   ROM_LOAD( "rd.20n",    0x0000, 0x0200, CRC(1d877538) SHA1(a5be0dc65dcfc36fbba10d1fddbe155e24b6122f) )
18492396ROM_END
18502397
2398
18512399ROM_START( edfu )
18522400   ROM_REGION( 0xc0000, "main", 0 )      /* Main CPU Code: 00000-3ffff & 80000-bffff */
18532401   ROM_LOAD16_BYTE( "edf5.b5",  0x000000, 0x020000, CRC(105094d1) SHA1(e962164836756bc20c2b5dc0032042a0219e82d8) )
r4135r4136
18842432   ROM_LOAD( "rd.20n",    0x0000, 0x0200, CRC(1d877538) SHA1(a5be0dc65dcfc36fbba10d1fddbe155e24b6122f) )
18852433ROM_END
18862434
1887static INPUT_PORTS_START( edf )
1888   PORT_START("SYSTEM")
1889   COINS
18902435
1891   PORT_START("P1")
1892   JOY_2BUTTONS(1)      //  fire    unfold_weapons
1893
1894   PORT_START("P2")
1895   JOY_2BUTTONS(2)
1896   RESERVE
1897
1898   PORT_START("DSW1")
1899   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
1900   PORT_DIPSETTING(      0x0004, DEF_STR( 3C_1C ) )
1901   PORT_DIPSETTING(      0x0002, DEF_STR( 2C_1C ) )
1902   PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) )
1903   PORT_DIPSETTING(      0x0003, DEF_STR( 1C_2C ) )
1904   PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) )
1905   PORT_DIPSETTING(      0x0001, DEF_STR( 1C_4C ) )
1906   PORT_DIPSETTING(      0x0006, DEF_STR( 1C_5C ) )
1907   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
1908   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) )
1909   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
1910   PORT_DIPSETTING(      0x0020, DEF_STR( 3C_1C ) )
1911   PORT_DIPSETTING(      0x0010, DEF_STR( 2C_1C ) )
1912   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
1913   PORT_DIPSETTING(      0x0018, DEF_STR( 1C_2C ) )
1914   PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) )
1915   PORT_DIPSETTING(      0x0008, DEF_STR( 1C_4C ) )
1916   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_5C ) )
1917   PORT_DIPNAME( 0x000040, 0x000040, DEF_STR( Demo_Sounds ) )
1918   PORT_DIPSETTING(      0x000000, DEF_STR( Off ) )
1919   PORT_DIPSETTING(      0x000040, DEF_STR( On ) )
1920   PORT_SERVICE( 0x000080, IP_ACTIVE_LOW )
1921
1922   PORT_START("DSW2")         /* 0x66007.b */
1923   PORT_DIPNAME( 0x0007, 0x0007, "DSW-B bits 2-0" )
1924   PORT_DIPSETTING(      0x0000, "0" )
1925   PORT_DIPSETTING(      0x0001, "1" )
1926   PORT_DIPSETTING(      0x0002, "2" )
1927   PORT_DIPSETTING(      0x0003, "3" )
1928   PORT_DIPSETTING(      0x0004, "4" )
1929   PORT_DIPSETTING(      0x0005, "5" )
1930   PORT_DIPSETTING(      0x0006, "6" )
1931   PORT_DIPSETTING(      0x0007, "7" )
1932   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Lives ) )
1933   PORT_DIPSETTING(      0x0008, "3" )
1934   PORT_DIPSETTING(      0x0000, "4" )
1935   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
1936   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
1937   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
1938   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )
1939   PORT_DIPSETTING(      0x0020, DEF_STR( Very_Hard ) )
1940   PORT_DIPNAME( 0x0040, 0x0040, "DSW-B bit 6" )
1941   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
1942   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1943   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
1944   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
1945   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
1946INPUT_PORTS_END
1947
1948
1949
19502436/***************************************************************************
19512437
19522438                                [ Hachoo! ]
r4135r4136
20012487ROM_END
20022488
20032489
2004static INPUT_PORTS_START( hachoo )
2005   PORT_START("SYSTEM")   /* 0x80001.b */
2006   COINS
2007
2008   PORT_START("P1")   /* 0x80003.b */
2009   JOY_2BUTTONS(1)      //  fire    jump
2010
2011   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
2012   JOY_2BUTTONS(2)
2013   RESERVE
2014
2015   PORT_START("DSW")
2016   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unused ) ) /* Manual states dips 1-4 & 6 are "Unused" */
2017   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
2018   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2019   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unused ) )
2020   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
2021   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2022   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unused ) )
2023   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
2024   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2025   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unused ) )
2026   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
2027   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2028   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
2029   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
2030   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )
2031   PORT_DIPSETTING(      0x0010, DEF_STR( Harder ) )
2032   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
2033   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unused ) )
2034   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
2035   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2036   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
2037   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
2038   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2039
2040   COINAGE_6BITS
2041   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Demo_Sounds ) )
2042   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
2043   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
2044   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unused ) )
2045   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
2046   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2047INPUT_PORTS_END
2048
2049
2050
20512490/***************************************************************************
20522491
20532492Hayaoshi Quiz Ouza Ketteisen
r4135r4136
20852524
20862525***************************************************************************/
20872526
2527
20882528ROM_START( hayaosi1 )
20892529   ROM_REGION( 0xc0000, "main", 0 )      /* Main CPU Code: 00000-3ffff & 80000-bffff */
20902530   ROM_LOAD16_BYTE( "5", 0x000000, 0x020000, CRC(eaf38fab) SHA1(0f9cd6e674668a86d2bb54228b50217c934e96af) )
r4135r4136
21212561   ROM_LOAD( "pr-91044",  0x0000, 0x0200, CRC(c69423d6) SHA1(ba9644a9899df2d73a5a16bf7ceef1954c2e25f3) )
21222562ROM_END
21232563
2124static INPUT_PORTS_START( hayaosi1 )
2125   PORT_START("SYSTEM")
2126   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 )
2127   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START2 )
2128   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN )
2129   PORT_SERVICE_NO_TOGGLE( 0x0008, IP_ACTIVE_LOW )
2130   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START3 )
2131   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_SERVICE1 )
2132   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_COIN1 )
2133   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN2 )
2134   PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
21352564
2136   PORT_START("P1")
2137   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
2138   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
2139   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
2140   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
2141   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(3)
2142   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)
2143   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(1)
2144   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(3)
2145   PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
2146
2147   PORT_START("P2")
2148   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)
2149   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
2150   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1)
2151   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
2152   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(3)
2153   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3)
2154   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(2)
2155   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
2156   RESERVE
2157
2158   PORT_START("DSW1")
2159   COINAGE_8BITS
2160
2161   PORT_START("DSW2")         /* 0x69353.b */
2162   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Flip_Screen ) )
2163   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
2164   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2165   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Demo_Sounds ) )
2166   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
2167   PORT_DIPSETTING(      0x0002, DEF_STR( On ) )
2168   PORT_DIPNAME( 0x0004, 0x0004, "Unknown 2-2" )
2169   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
2170   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2171   PORT_DIPNAME( 0x0018, 0x0018, DEF_STR( Difficulty ) )
2172   PORT_DIPSETTING(      0x0010, DEF_STR( Easy ) )
2173   PORT_DIPSETTING(      0x0018, DEF_STR( Normal ) )
2174   PORT_DIPSETTING(      0x0008, DEF_STR( Hard ) )
2175   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
2176   PORT_DIPNAME( 0x0020, 0x0020, "Points To Win" )
2177   PORT_DIPSETTING(      0x0000, "10" )
2178   PORT_DIPSETTING(      0x0020, "15" )
2179   PORT_DIPNAME( 0x0040, 0x0040, "Unknown 2-6" )
2180   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
2181   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2182   PORT_DIPNAME( 0x0080, 0x0080, "Unknown 2-7" )
2183   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
2184   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2185INPUT_PORTS_END
2186
2187
2188
21892565/***************************************************************************
21902566
21912567                    [ Ninja Kazan ] \ [ Iga Ninjyutsuden ]
r4135r4136
22022578
22032579***************************************************************************/
22042580
2581
22052582ROM_START( kazan )
22062583   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
22072584   ROM_LOAD16_BYTE( "kazan.2",    0x000000, 0x020000, CRC(072aa3d6) SHA1(49fd03d72f647dcda140d0a507f23a80911427e1) )
r4135r4136
22442621   ROM_LOAD( "kazan.14m",    0x0000, 0x0200, CRC(85b30ac4) SHA1(b03f577ceb0f26b67453ffa52ef61fea76a93184) )
22452622ROM_END
22462623
2624
22472625ROM_START( iganinju )
22482626   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
22492627   ROM_LOAD16_BYTE( "iga_02.bin", 0x000000, 0x020000, CRC(bd00c280) SHA1(d4e074bb25fc7295b1a39aa22e966cf471a6789f) )
r4135r4136
22782656ROM_END
22792657
22802658
2281static INPUT_PORTS_START( kazan )
2282   PORT_START("SYSTEM")   /* 0x80001.b */
2283   COINS
2284
2285   PORT_START("P1")   /* 0x80003.b */
2286   JOY_2BUTTONS(1)      //  fire    jump
2287
2288   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
2289   JOY_2BUTTONS(2)
2290   RESERVE
2291
2292   PORT_START("DSW")
2293   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )
2294   PORT_DIPSETTING(      0x0003, "2" )
2295   PORT_DIPSETTING(      0x0001, "3" )
2296   PORT_DIPSETTING(      0x0002, "4" )
2297   PORT_DIPSETTING(      0x0000, "Infinite (Cheat)" )
2298   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Bonus_Life ) )
2299   PORT_DIPSETTING(      0x0004, "50k" )
2300   PORT_DIPSETTING(      0x0000, "200k" )
2301   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Allow_Continue ) )
2302   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
2303   PORT_DIPSETTING(      0x0008, DEF_STR( On ) )
2304   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
2305   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
2306   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )
2307   PORT_DIPSETTING(      0x0010, DEF_STR( Harder ) )
2308   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
2309   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Cabinet ) )
2310   PORT_DIPSETTING(      0x0000, DEF_STR( Upright ) )
2311   PORT_DIPSETTING(      0x0040, DEF_STR( Cocktail ) )
2312   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
2313   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
2314   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2315
2316   COINAGE_6BITS
2317   PORT_DIPNAME( 0x4000, 0x0000, DEF_STR( Demo_Sounds ) )
2318   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
2319   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2320   PORT_DIPNAME( 0x8000, 0x8000, "Freeze Screen (Cheat)")
2321   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
2322   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2323INPUT_PORTS_END
2324
2325
2326
23272659/***************************************************************************
23282660
23292661                        [ Jitsuryoku!! Pro Yakyuu ]
r4135r4136
23472679
23482680***************************************************************************/
23492681
2682
23502683ROM_START( jitsupro )
23512684   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
23522685   ROM_LOAD16_BYTE( "jp_2.bin", 0x000000, 0x020000, CRC(5d842ff2) SHA1(69032601c0e67c5c78fad1cb2bb4f1b59014fe5a) )
r4135r4136
23812714ROM_END
23822715
23832716
2384static INPUT_PORTS_START( jitsupro )
2385   PORT_START("SYSTEM")   /* 0x80001.b */
2386   COINS
2387
2388   PORT_START("P1")   /* 0x80003.b */
2389   JOY_3BUTTONS(1)      //  shoot   change view     change bat
2390
2391   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
2392   JOY_3BUTTONS(2)
2393   RESERVE
2394
2395   PORT_START("DSW")
2396   PORT_DIPNAME( 0x0001, 0x0001, "2 Player Innings per Credit" )
2397   PORT_DIPSETTING(      0x0001, "2" )
2398   PORT_DIPSETTING(      0x0000, "3" )
2399   PORT_DIPNAME( 0x0002, 0x0002, "Difficulty for Catching Ball" )
2400   PORT_DIPSETTING(      0x0002, DEF_STR( Normal ) )   // $200-140
2401   PORT_DIPSETTING(      0x0000, DEF_STR( Hard ) )   // $400-140
2402   PORT_DIPNAME( 0x003c, 0x003c, "Franchise (Increase Batting Power)" )
2403   PORT_DIPSETTING(      0x003c, DEF_STR( Normal )  )
2404   PORT_DIPSETTING(      0x0038, "G"  )
2405   PORT_DIPSETTING(      0x0034, "D"  )
2406   PORT_DIPSETTING(      0x0030, "C"  ) /* I hope the Japanese Baseball crowd knows what these leagues are ;-) */
2407   PORT_DIPSETTING(      0x002c, "S"  )
2408   PORT_DIPSETTING(      0x0028, "W (B)"  )
2409   PORT_DIPSETTING(      0x0024, "T"  )
2410   PORT_DIPSETTING(      0x0020, "L"  )
2411   PORT_DIPSETTING(      0x001c, "Br (Bw)"  )
2412   PORT_DIPSETTING(      0x0018, "F"  )
2413   PORT_DIPSETTING(      0x0014, "H" )
2414   PORT_DIPSETTING(      0x0010, "O (M)" )
2415   PORT_DIPSETTING(      0x000c, "Bu" )
2416//  PORT_DIPSETTING(      0x0008, "13" )
2417//  PORT_DIPSETTING(      0x0004, "14" )
2418//  PORT_DIPSETTING(      0x0000, "15" )
2419   PORT_DIPNAME( 0x0040, 0x0040, "Scroll Is Based On" )
2420   PORT_DIPSETTING(      0x0040, "Shadow of Baseball" )
2421   PORT_DIPSETTING(      0x0000, "The Baseball Itself" )
2422   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
2423   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
2424   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2425
2426   COINAGE_6BITS
2427   PORT_DIPNAME( 0x4000, 0x0000, DEF_STR( Demo_Sounds ) )
2428   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
2429   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2430   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unused ) )
2431   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
2432   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2433INPUT_PORTS_END
2434
2435
2436
24372717/***************************************************************************
24382718
24392719                            [ Kick Off ]
r4135r4136
24642744
24652745***************************************************************************/
24662746
2747
24672748ROM_START( kickoff )
24682749   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
24692750   ROM_LOAD16_BYTE( "kioff03.rom", 0x000000, 0x010000, CRC(3b01be65) SHA1(110b4e02053073c0315aba1eca8c19afe5fafb33) )
r4135r4136
25042785   ROM_LOAD( "kick.bin",    0x0000, 0x0200, CRC(85b30ac4) SHA1(b03f577ceb0f26b67453ffa52ef61fea76a93184) )
25052786ROM_END
25062787
2507static INPUT_PORTS_START( kickoff )
2508   PORT_START("SYSTEM")   /* 0x80001.b ->  !f0008/a.w  */
2509   COINS
25102788
2511   PORT_START("P1")   /* 0x80003.b ->  !f000c/e.w  */
2512   JOY_2BUTTONS(1)      //  shoot   pass
2513
2514   PORT_START("P2")   /* 0x80004.b --> !f0010/11.w */
2515   JOY_2BUTTONS(2)
2516   RESERVE
2517
2518   PORT_START("DSW")
2519   PORT_DIPNAME( 0x0003, 0x0003, "Time" )   // -> !f0082.w
2520   PORT_DIPSETTING(      0x0003, "3'" )
2521   PORT_DIPSETTING(      0x0002, "4'" )
2522   PORT_DIPSETTING(      0x0001, "5'" )
2523   PORT_DIPSETTING(      0x0000, "6'" )
2524   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unused ) ) /* Manual states dips 3 & 4 are "Unused" */
2525   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
2526   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2527   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unused ) )
2528   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
2529   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2530   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
2531   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
2532   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )
2533   PORT_DIPSETTING(      0x0010, DEF_STR( Harder ) )
2534   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
2535   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Controls ) )
2536   PORT_DIPSETTING(      0x0040, DEF_STR( Trackball ) )
2537   PORT_DIPSETTING(      0x0000, DEF_STR( Joystick ) )
2538   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
2539   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
2540   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2541
2542   PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coin_A ) )
2543   PORT_DIPSETTING(      0x0100, DEF_STR( 4C_1C ) )
2544   PORT_DIPSETTING(      0x0200, DEF_STR( 3C_1C ) )
2545   PORT_DIPSETTING(      0x0300, DEF_STR( 2C_1C ) )
2546   PORT_DIPSETTING(      0x0700, DEF_STR( 1C_1C ) )
2547   PORT_DIPSETTING(      0x0600, DEF_STR( 1C_2C ) )
2548   PORT_DIPSETTING(      0x0500, DEF_STR( 1C_3C ) )
2549   PORT_DIPSETTING(      0x0400, DEF_STR( 1C_4C ) )
2550   PORT_DIPSETTING(      0x0000, DEF_STR( Free_Play ) )
2551   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unused ) )
2552   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
2553   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2554   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unused ) )
2555   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
2556   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2557   PORT_DIPNAME( 0x2000, 0x2000, "Freeze Screen (Cheat)" )
2558   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
2559   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2560   PORT_DIPNAME( 0x4000, 0x0000, DEF_STR( Demo_Sounds ) )
2561   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
2562   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2563   PORT_DIPNAME( 0x8000, 0x8000, "Text" )
2564   PORT_DIPSETTING(      0x8000, DEF_STR( Japanese ) )
2565   PORT_DIPSETTING(      0x0000, DEF_STR( English ) )   // show "Japan Only" warning
2566INPUT_PORTS_END
2567
2568
25692789/***************************************************************************
25702790
25712791                            [ Legend of Makai ]
r4135r4136
26002820   ROM_LOAD( "makaiden.10", 0x0100, 0x0100, CRC(e6709c51) SHA1(f5cd4f0454c1a71a5b0006b098f9e76c2d8a27d2) )
26012821ROM_END
26022822
2823
26032824ROM_START( makaiden )
26042825   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
26052826   ROM_LOAD16_BYTE( "makaiden.3a", 0x000000, 0x020000, CRC(87cf81d1) SHA1(c4410a86a01c683368dbc3daca61e21931885650) )
r4135r4136
26222843   ROM_LOAD( "makaiden.10", 0x0100, 0x0100, CRC(e6709c51) SHA1(f5cd4f0454c1a71a5b0006b098f9e76c2d8a27d2) )
26232844ROM_END
26242845
2625static INPUT_PORTS_START( lomakai )
2626   PORT_START("SYSTEM")   /* 0x80001.b */
2627   COINS
26282846
2629   PORT_START("P1")   /* 0x80003.b */
2630   JOY_2BUTTONS(1)      //  fire    jump
2631
2632   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
2633   JOY_2BUTTONS(2)
2634   RESERVE
2635
2636   PORT_START("DSW")
2637   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )
2638   PORT_DIPSETTING(      0x0000, "2" )
2639   PORT_DIPSETTING(      0x0003, "3" )
2640   PORT_DIPSETTING(      0x0002, "4" )
2641   PORT_DIPSETTING(      0x0001, "5" )
2642   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
2643   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
2644   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2645   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
2646   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
2647   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2648   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )   // boss enemy damage bar
2649   PORT_DIPSETTING(      0x0030, DEF_STR( Easy ) )         // 6 dots
2650   PORT_DIPSETTING(      0x0020, DEF_STR( Normal ) )      // 8 dots
2651   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )         // 9 dots
2652   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )      // 12 dots
2653   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Cabinet ) )
2654   PORT_DIPSETTING(      0x0000, DEF_STR( Upright ) )
2655   PORT_DIPSETTING(      0x0040, DEF_STR( Cocktail ) )
2656   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
2657   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
2658   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2659
2660   COINAGE_6BITS_2
2661   PORT_DIPNAME( 0x4000, 0x0000, DEF_STR( Demo_Sounds ) )
2662   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
2663   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2664   PORT_DIPNAME( 0x8000, 0x8000, "Invulnerability (Cheat)")
2665   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
2666   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2667INPUT_PORTS_END
2668
2669
26702847/***************************************************************************
26712848
26722849                             [ P - 47 ]
r4135r4136
28032980   ROM_LOAD( "p-47.14m",    0x0000, 0x0200, CRC(1d877538) SHA1(a5be0dc65dcfc36fbba10d1fddbe155e24b6122f) )
28042981ROM_END
28052982
2806static INPUT_PORTS_START( p47 )
2807   PORT_START("SYSTEM")   /* 0x80001.b */
2808   COINS
28092983
2810   PORT_START("P1")   /* 0x80003.b */
2811   JOY_2BUTTONS(1)      //  fire    bomb
2812
2813   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
2814   JOY_2BUTTONS(2)
2815   RESERVE
2816
2817   PORT_START("DSW")
2818   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )
2819   PORT_DIPSETTING(      0x0002, "2" )
2820   PORT_DIPSETTING(      0x0003, "3" )
2821   PORT_DIPSETTING(      0x0001, "4" )
2822   PORT_DIPSETTING(      0x0000, "5" )
2823   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unused ) ) /* Manual states dips 3 & 4 are "Unused" */
2824   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
2825   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2826   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unused ) )
2827   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
2828   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2829   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
2830   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
2831   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
2832   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )
2833   PORT_DIPSETTING(      0x0010, DEF_STR( Hardest ) )
2834   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unused ) ) /* Manual states this dip is "Unused" */
2835   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
2836   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2837   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
2838   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
2839   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2840
2841   COINAGE_6BITS_2
2842   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Demo_Sounds ) )
2843   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
2844   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
2845   PORT_DIPNAME( 0x8000, 0x8000, "Invulnerability (Cheat)")
2846   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
2847   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2848INPUT_PORTS_END
2849
2850
2851
2852
28532984/***************************************************************************
28542985
28552986                            [ Peek-a-Boo! ]
r4135r4136
29413072
29423073***************************************************************************/
29433074
3075
29443076ROM_START( peekaboo )
29453077   ROM_REGION( 0x40000, "main", 0 )      /* 68000 CPU Code */
29463078   ROM_LOAD16_BYTE( "j3", 0x000000, 0x020000, CRC(f5f4cf33) SHA1(f135f2b627347255bb0811e9a4a213e3b447c199) )
r4135r4136
29693101   ROM_LOAD( "priority.69",    0x000000, 0x200, CRC(b40bff56) SHA1(39c95eed79328ef2df754988db83e07909e848f8) )
29703102ROM_END
29713103
2972#define PEEKABOO_PADDLE(_FLAG_)   \
2973   PORT_BIT( 0x00ff, 0x0080, IPT_PADDLE ) PORT_PLAYER(_FLAG_) PORT_MINMAX(0x0018,0x00e0) PORT_SENSITIVITY(50) PORT_KEYDELTA(10) PORT_CENTERDELTA(0)
29743104
2975static INPUT_PORTS_START( peekaboo )
2976   PORT_START("SYSTEM")
2977   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN3 )      // called "service"
2978   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN4 )      // called "test"
2979   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN1 )
2980   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN2 )
2981   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_START1 )
2982   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_START2 )
2983   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
2984   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
2985   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 )
2986   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON2 )
2987   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
2988   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
2989   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON3 )      // called "stage clear"
2990   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON4 )      // called "option"
2991   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
2992   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
2993
2994   PORT_START("P1")
2995   PEEKABOO_PADDLE(1)
2996
2997   PORT_START("P2")
2998   PEEKABOO_PADDLE(2) PORT_COCKTAIL
2999   RESERVE
3000
3001   PORT_START("DSW")
3002   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) )      // 1f0358<-!
3003   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
3004   PORT_DIPSETTING(      0x0003, DEF_STR( Normal ) )
3005   PORT_DIPSETTING(      0x0002, DEF_STR( Hard ) )
3006   PORT_DIPSETTING(      0x0001, DEF_STR( Hardest ) )
3007   PORT_SERVICE( 0x0004, IP_ACTIVE_LOW )
3008   PORT_DIPNAME( 0x0008, 0x0008, "Movement" )               // 1f0392<-!
3009   PORT_DIPSETTING(      0x0008, "Paddles" )
3010   PORT_DIPSETTING(      0x0000, "Buttons" )
3011   PORT_DIPNAME( 0x0030, 0x0030, "Nudity" )               // 1f0356<-!
3012   PORT_DIPSETTING(      0x0030, "Female and Male (Full)" )
3013   PORT_DIPSETTING(      0x0020, "Female (Full)" )
3014   PORT_DIPSETTING(      0x0010, "Female (Partial)" )
3015   PORT_DIPSETTING(      0x0000, DEF_STR( None ) )
3016   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Cabinet ) )         // 1f006a<-!
3017   PORT_DIPSETTING(      0x0040, DEF_STR( Upright ) )
3018   PORT_DIPSETTING(      0x0000, DEF_STR( Cocktail ) )
3019   PORT_DIPNAME( 0x0080, 0x0080, "Number of controllers" )      // 1f0074<-!
3020   PORT_DIPSETTING(      0x0080, "1" )
3021   PORT_DIPSETTING(      0x0000, "2" )
3022
3023   COINAGE_6BITS_2
3024   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Demo_Sounds ) )      // 1f0354<-
3025   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
3026   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
3027   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Flip_Screen ) )      // 1f0022/6e<-!
3028   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
3029   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3030INPUT_PORTS_END
3031
3032
3033
3034static UINT16 protection_val;
3035
3036/* Read the input ports, through a protection device */
3037static READ16_HANDLER( protection_peekaboo_r )
3038{
3039   switch (protection_val)
3040   {
3041      case 0x02:   return 0x03;
3042      case 0x51:   return input_port_read(space->machine, "P1");
3043      case 0x52:   return input_port_read(space->machine, "P2");
3044      default:   return protection_val;
3045   }
3046}
3047
3048static WRITE16_HANDLER( protection_peekaboo_w )
3049{
3050   static int bank;
3051
3052   COMBINE_DATA(&protection_val);
3053
3054   if ((protection_val & 0x90) == 0x90)
3055   {
3056      UINT8 *RAM = memory_region(space->machine, "oki1");
3057      int new_bank = (protection_val & 0x7) % 7;
3058
3059      if (bank != new_bank)
3060      {
3061         memcpy(&RAM[0x20000],&RAM[0x40000 + 0x20000*new_bank],0x20000);
3062         bank = new_bank;
3063      }
3064   }
3065
3066   cpu_set_input_line(space->machine->cpu[0],4,HOLD_LINE);
3067}
3068
3069
30703105/***************************************************************************
30713106
30723107                            [ Plus Alpha ]
r4135r4136
30783113
30793114***************************************************************************/
30803115
3116
30813117ROM_START( plusalph )
30823118   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
30833119   ROM_LOAD16_BYTE( "pa-rom2.bin", 0x000000, 0x020000, CRC(33244799) SHA1(686fb7fa8a6c25b5aff78bc509f35c69492d7d1e) )
r4135r4136
31223158   ROM_LOAD( "prom.14m",     0x0000, 0x0200, CRC(1d877538) SHA1(a5be0dc65dcfc36fbba10d1fddbe155e24b6122f) )
31233159ROM_END
31243160
3125static INPUT_PORTS_START( plusalph )
3126   PORT_START("SYSTEM")   /* 0x80001.b */
3127   COINS
31283161
3129   PORT_START("P1")   /* 0x80003.b */
3130   JOY_2BUTTONS(1)      //  fire    bomb
3131
3132   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
3133   JOY_2BUTTONS(2)
3134   RESERVE
3135
3136   PORT_START("DSW")
3137   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )
3138   PORT_DIPSETTING(      0x0003, "3" )
3139   PORT_DIPSETTING(      0x0002, "4" )
3140   PORT_DIPSETTING(      0x0001, "5" )
3141   PORT_DIPSETTING(      0x0000, "Infinite (Cheat)" )
3142   PORT_DIPNAME( 0x0004, 0x0004, "Hyper Laser Beams" )
3143   PORT_DIPSETTING(      0x0000, "2" )
3144   PORT_DIPSETTING(      0x0004, "3" )
3145   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Bonus_Life ) )
3146   PORT_DIPSETTING(      0x0008, "70k and every 200k")      /* As stated in manual, but was 70K & Every 130K */
3147   PORT_DIPSETTING(      0x0000, "100k and 300k Only")      /* As stated in manual, but was 100K & Every 200K */
3148   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
3149   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
3150   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
3151   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )
3152   PORT_DIPSETTING(      0x0020, DEF_STR( Hardest ) )
3153   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Cabinet ) )
3154   PORT_DIPSETTING(      0x0000, DEF_STR( Upright ) )
3155   PORT_DIPSETTING(      0x0040, DEF_STR( Cocktail ) )
3156   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
3157   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
3158   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3159
3160   COINAGE_6BITS
3161   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Demo_Sounds ) )
3162   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
3163   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
3164   PORT_DIPNAME( 0x8000, 0x8000, "Freeze Screen (Cheat)")
3165   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
3166   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3167INPUT_PORTS_END
3168
3169
31703162/***************************************************************************
31713163
31723164                            [ RodLand ]
r4135r4136
31983190
31993191***************************************************************************/
32003192
3193
32013194ROM_START( rodland )
32023195   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
32033196   ROM_LOAD16_BYTE( "rl_02.rom", 0x000000, 0x020000, CRC(c7e00593) SHA1(055b7bcabf90ed6d5edc2797d0f85a5d49b8693b) )
r4135r4136
32363229   ROM_LOAD( "rl.bin",    0x0000, 0x0200, CRC(8914e72d) SHA1(80a664471f14c8ed8544a5e226fdca425ab3c657) )
32373230ROM_END
32383231
3232
32393233ROM_START( rodlandj )
32403234   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
32413235   ROM_LOAD16_BYTE( "rl_2.bin", 0x000000, 0x020000, CRC(b1d2047e) SHA1(75d282b7614c5f4b76ab44e34fea9e87ab8b992c) )
r4135r4136
33133307ROM_END
33143308
33153309
3316static INPUT_PORTS_START( rodland )
3317   PORT_START("SYSTEM")   /* 0x80001.b */
3318   COINS
3319
3320   PORT_START("P1")   /* 0x80003.b */
3321   JOY_2BUTTONS(1)      //  fire    ladder
3322
3323   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
3324   JOY_2BUTTONS(2)
3325   RESERVE
3326
3327   PORT_START("DSW")
3328   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unused ) ) /* according to manual */
3329   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
3330   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3331   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unused ) ) /* according to manual */
3332   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
3333   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3334   PORT_DIPNAME( 0x000c, 0x000c, DEF_STR( Lives ) )
3335   PORT_DIPSETTING(      0x0004, "2" )
3336   PORT_DIPSETTING(      0x000c, "3" )
3337   PORT_DIPSETTING(      0x0008, "4" )
3338   PORT_DIPSETTING(      0x0000, "Infinite (Cheat)")
3339   PORT_DIPNAME( 0x0010, 0x0010, "Default episode" )
3340   PORT_DIPSETTING(      0x0010, "1" )
3341   PORT_DIPSETTING(      0x0000, "2" )
3342   PORT_DIPNAME( 0x0060, 0x0060, DEF_STR( Difficulty ) )
3343   PORT_DIPSETTING(      0x0000, DEF_STR( Easy ) )
3344   PORT_DIPSETTING(      0x0060, DEF_STR( Normal ) )
3345   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )
3346   PORT_DIPSETTING(      0x0040, DEF_STR( Hardest ) )
3347   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
3348   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
3349   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3350
3351   COINAGE_6BITS
3352   PORT_DIPNAME( 0x4000, 0x0000, DEF_STR( Demo_Sounds ) )
3353   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
3354   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3355   PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
3356INPUT_PORTS_END
3357
3358
33593310/***************************************************************************
33603311
33613312                            [ Saint Dragon ]
r4135r4136
33663317
33673318***************************************************************************/
33683319
3320
33693321ROM_START( stdragon )
33703322   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
33713323   ROM_LOAD16_BYTE( "jsd-02.bin", 0x000000, 0x020000, CRC(cc29ab19) SHA1(e145eeb01fad313e300f0c614c0e7a5c1d75d7d9) )
r4135r4136
34083360   ROM_LOAD( "prom.14m",    0x0000, 0x0200, CRC(1d877538) SHA1(a5be0dc65dcfc36fbba10d1fddbe155e24b6122f) )
34093361ROM_END
34103362
3411static INPUT_PORTS_START( stdragon )
3412   PORT_START("SYSTEM")   /* 0x80001.b */
3413   COINS
34143363
3415   PORT_START("P1")   /* 0x80003.b */
3416   JOY_2BUTTONS(1)      //  fire    fire
3417
3418   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
3419   JOY_2BUTTONS(2)
3420   RESERVE
3421
3422   PORT_START("DSW")
3423   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )
3424   PORT_DIPSETTING(      0x0002, "2" )
3425   PORT_DIPSETTING(      0x0003, "3" )
3426   PORT_DIPSETTING(      0x0001, "4" )
3427   PORT_DIPSETTING(      0x0000, "5" )
3428   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unused ) ) /* Manual states dips 3 & 4 are "Unused" */
3429   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
3430   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3431   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unused ) )
3432   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
3433   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3434   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Difficulty ) )
3435   PORT_DIPSETTING(      0x0030, DEF_STR( Easy ) )
3436   PORT_DIPSETTING(      0x0020, DEF_STR( Normal ) )
3437   PORT_DIPSETTING(      0x0010, DEF_STR( Hard ) )
3438   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
3439   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Cabinet ) )
3440   PORT_DIPSETTING(      0x0000, DEF_STR( Upright ) )
3441   PORT_DIPSETTING(      0x0040, DEF_STR( Cocktail ) )
3442   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
3443   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
3444   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3445
3446   COINAGE_6BITS_2
3447   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Demo_Sounds ) )
3448   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
3449   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
3450   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unused ) )   // used?
3451   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
3452   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3453INPUT_PORTS_END
3454
3455
3456
3457
34583364/***************************************************************************
34593365
34603366                                [ Soldam ]
r4135r4136
34673373
34683374***************************************************************************/
34693375
3376
34703377ROM_START( soldam )
34713378   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
34723379   ROM_LOAD16_BYTE( "2ver1j.bin",0x000000, 0x020000, CRC(45444b07) SHA1(d991dd52904671fbd8cfcfe07c956d9fd45b3470) )
r4135r4136
35343441   ROM_LOAD( "pr-91023.m14",   0x0000, 0x0200, CRC(8914e72d) SHA1(80a664471f14c8ed8544a5e226fdca425ab3c657) )
35353442ROM_END
35363443
3537static INPUT_PORTS_START( soldamj )
3538   PORT_START("SYSTEM")   /* 0x80001.b */
3539   COINS
35403444
3541   PORT_START("P1")   /* 0x80003.b */
3542   JOY_2BUTTONS(1)      //  turn    turn    (3rd button is shown in service mode, but seems unused)
3543
3544   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
3545   JOY_2BUTTONS(2)
3546   RESERVE
3547
3548   PORT_START("DSW")
3549   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) )
3550   PORT_DIPSETTING(      0x0000, DEF_STR( Easy )   )
3551   PORT_DIPSETTING(      0x0003, DEF_STR( Normal ) )
3552   PORT_DIPSETTING(      0x0002, DEF_STR( Hard )   )
3553   PORT_DIPSETTING(      0x0001, DEF_STR( Hardest ))
3554   PORT_DIPNAME( 0x000c, 0x000c, "Games To Play (Vs)" )
3555   PORT_DIPSETTING(      0x0000, "1" )
3556   PORT_DIPSETTING(      0x000c, "2" )
3557   PORT_DIPSETTING(      0x0008, "3" )
3558   PORT_DIPSETTING(      0x0004, "4" )
3559   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Allow_Continue ) )
3560   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
3561   PORT_DIPSETTING(      0x0010, DEF_STR( On ) )
3562   PORT_DIPNAME( 0x0020, 0x0020, "Credits To Start (Vs)" )
3563   PORT_DIPSETTING(      0x0020, "1" )
3564   PORT_DIPSETTING(      0x0000, "2" )
3565   PORT_DIPNAME( 0x0040, 0x0040, "Credits To Continue (Vs)" )
3566   PORT_DIPSETTING(      0x0040, "1" )
3567   PORT_DIPSETTING(      0x0000, "2" )
3568   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
3569   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
3570   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3571
3572   COINAGE_6BITS_2
3573   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Demo_Sounds ) )
3574   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
3575   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
3576   PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
3577INPUT_PORTS_END
3578
3579static READ16_HANDLER( soldamj_spriteram16_r )
3580{
3581   return spriteram16[offset];
3582}
3583static WRITE16_HANDLER( soldamj_spriteram16_w )
3584{
3585   if (offset < 0x800/2)   COMBINE_DATA(&spriteram16[offset]);
3586}
3587
3588
3589
35903445/***************************************************************************
35913446
35923447                            [ Takeda Shingen ]
35933448
35943449***************************************************************************/
35953450
3596ROM_START( tshingen )
3451
3452ROM_START( tshingna )
35973453   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
35983454   ROM_LOAD16_BYTE( "takeda2.bin", 0x000000, 0x020000, CRC(6ddfc9f3) SHA1(0ce1b8eae31453db0b2081717d7dbda9ea7d5a60) )
35993455   ROM_LOAD16_BYTE( "takeda1.bin", 0x000001, 0x020000, CRC(1afc6b7d) SHA1(b56da1b8c5b417a88a2952491c2d5472bb783945) )
r4135r4136
36323488   ROM_LOAD( "ts.bpr",        0x0000, 0x0200, CRC(85b30ac4) SHA1(b03f577ceb0f26b67453ffa52ef61fea76a93184) )
36333489ROM_END
36343490
3635ROM_START( tshingna )
3491
3492ROM_START( tshingen )
36363493   ROM_REGION( 0x60000, "main", 0 )      /* Main CPU Code */
36373494   ROM_LOAD16_BYTE( "shing_02.rom", 0x000000, 0x020000, CRC(d9ab5b78) SHA1(c7622ec11a636dc7a6bcad02556a98aa0a9fb043) )
36383495   ROM_LOAD16_BYTE( "shing_01.rom", 0x000001, 0x020000, CRC(a9d2de20) SHA1(b53205722ae19305a1c373abbbac4fbcbcb0b0f0) )
r4135r4136
36713528   ROM_LOAD( "ts.bpr",        0x0000, 0x0200, CRC(85b30ac4) SHA1(b03f577ceb0f26b67453ffa52ef61fea76a93184) )
36723529ROM_END
36733530
3674static INPUT_PORTS_START( tshingen )
3675   PORT_START("SYSTEM")   /* 0x80001.b */
3676   COINS
36773531
3678   PORT_START("P1")   /* 0x80003.b */
3679   JOY_3BUTTONS(1)      // sword_left   sword_right     jump
3532/*************************************
3533 *
3534 *  Code Decryption
3535 *
3536 *************************************/
36803537
3681   PORT_START("P2")   /* 0x80004.b  - 0x80005.b */
3682   JOY_3BUTTONS(2)
3683   RESERVE
3684
3685   PORT_START("DSW")
3686   PORT_DIPNAME( 0x0003, 0x0001, DEF_STR( Lives ) )
3687   PORT_DIPSETTING(      0x0003, "2" )
3688   PORT_DIPSETTING(      0x0001, "3" )
3689   PORT_DIPSETTING(      0x0002, "4" )
3690   PORT_DIPSETTING(      0x0000, "Infinite (Cheat)" )
3691   PORT_DIPNAME( 0x000c, 0x000c, DEF_STR( Bonus_Life ) )
3692   PORT_DIPSETTING(      0x000c, "20k" )
3693   PORT_DIPSETTING(      0x0004, "30k" )
3694   PORT_DIPSETTING(      0x0008, "40k" )
3695   PORT_DIPSETTING(      0x0000, "50k" )
3696   PORT_DIPNAME( 0x0030, 0x0010, DEF_STR( Difficulty ) )   // damage when hit
3697   PORT_DIPSETTING(      0x0030, DEF_STR( Easy ) )         // 0
3698   PORT_DIPSETTING(      0x0010, DEF_STR( Normal )  )      // 1
3699   PORT_DIPSETTING(      0x0020, DEF_STR( Hard ) )         // 2
3700   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )      // 3
3701   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Allow_Continue ) )
3702   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
3703   PORT_DIPSETTING(      0x0040, DEF_STR( On ) )
3704   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )
3705   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
3706   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3707
3708   COINAGE_6BITS
3709   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Demo_Sounds ) )
3710   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
3711   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
3712   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unused ) )
3713   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
3714   PORT_DIPSETTING(      0x8000, DEF_STR( On ) )
3715INPUT_PORTS_END
3716
3717
3718
3719
3720/***************************************************************************
3721
3722                             Code Decryption
3723
3724***************************************************************************/
3725
37263538void phantasm_rom_decode(running_machine *machine, const char *region)
37273539{
37283540   UINT16   *RAM   =   (UINT16 *) memory_region(machine, region);
r4135r4136
38853697   free(buffer);
38863698}
38873699
3700/*************************************
3701 *
3702 *  Game-specific driver inits
3703 *
3704 *************************************/
38883705
3889
3890
38913706static DRIVER_INIT( 64street )
38923707{
38933708//  UINT16 *RAM = (UINT16 *) memory_region(machine, "main");
r4135r4136
40553870   astyanax_rom_decode(machine, "main");
40563871}
40573872
3873static READ16_HANDLER( soldamj_spriteram16_r )
3874{
3875   return spriteram16[offset];
3876}
3877static WRITE16_HANDLER( soldamj_spriteram16_w )
3878{
3879   if (offset < 0x800/2)   COMBINE_DATA(&spriteram16[offset]);
3880}
3881
40583882static DRIVER_INIT( soldamj )
40593883{
40603884   astyanax_rom_decode(machine, "main");
r4135r4136
40983922
40993923}
41003924
3925/*************************************
3926 *
3927 *  Game driver(s)
3928 *
3929 *************************************/
41013930
4102
41033931GAME( 1988, lomakai,  0,        system_Z,          lomakai,  0,        ROT0,   "Jaleco", "Legend of Makai (World)", 0 )
41043932GAME( 1988, makaiden, lomakai,  system_Z,          lomakai,  0,        ROT0,   "Jaleco", "Makai Densetsu (Japan)", 0 )
41053933GAME( 1988, p47,      0,        system_A,          p47,      0,        ROT0,   "Jaleco", "P-47 - The Phantom Fighter (World)", 0 )
41063934GAME( 1988, p47j,     p47,      system_A,          p47,      0,        ROT0,   "Jaleco", "P-47 - The Freedom Fighter (Japan)", 0 )
41073935GAME( 1988, kickoff,  0,        system_A,          kickoff,  0,        ROT0,   "Jaleco", "Kick Off (Japan)", 0 )
4108GAME( 1988, tshingen, 0,        system_A,          tshingen, phantasm, ROT0,   "Jaleco", "Takeda Shingen (Japan, Japanese)", 0 )
4109GAME( 1988, tshingna, tshingen, system_A,          tshingen, phantasm, ROT0,   "Jaleco", "Shingen Samurai-Fighter (Japan, English)", 0 )
3936GAME( 1988, tshingen, 0,        system_A,          tshingen, phantasm, ROT0,   "Jaleco", "Shingen Samurai-Fighter (Japan, English)", 0 )
3937GAME( 1988, tshingna, tshingen, system_A,          tshingen, phantasm, ROT0,   "Jaleco", "Takeda Shingen (Japan, Japanese)", 0 )
41103938GAME( 1988, kazan,    0,        system_A,          kazan,    iganinju, ROT0,   "Jaleco", "Ninja Kazan (World)", 0 )
41113939GAME( 1988, iganinju, kazan,    system_A,          kazan,    iganinju, ROT0,   "Jaleco", "Iga Ninjyutsuden (Japan)", 0 )
41123940GAME( 1989, astyanax, 0,        system_A,          astyanax, astyanax, ROT0,   "Jaleco", "The Astyanax", 0 )
r4135r4136
41253953GAME( 1991, edfu,     edf,      system_B,          edf,      edf,      ROT0,   "Jaleco", "E.D.F. : Earth Defense Force (North America)", 0 )
41263954GAME( 1991, 64street, 0,        system_C,          64street, 64street, ROT0,   "Jaleco", "64th. Street - A Detective Story (World)", 0 )
41273955GAME( 1991, 64streej, 64street, system_C,          64street, 64street, ROT0,   "Jaleco", "64th. Street - A Detective Story (Japan)", 0 )
4128GAME( 1992, soldam,   0,        system_A,          soldamj,  soldam,   ROT0,   "Jaleco", "Soldam", 0 )
4129GAME( 1992, soldamj,  soldam,   system_A,          soldamj,  soldamj,  ROT0,   "Jaleco", "Soldam (Japan)", 0 )
3956GAME( 1992, soldam,   0,        system_A,          soldam,   soldam,   ROT0,   "Jaleco", "Soldam", 0 )
3957GAME( 1992, soldamj,  soldam,   system_A,          soldam,   soldamj,  ROT0,   "Jaleco", "Soldam (Japan)", 0 )
41303958GAME( 1992, bigstrik, 0,        system_C,          bigstrik, bigstrik, ROT0,   "Jaleco", "Big Striker", 0 )
41313959GAME( 1993, chimerab, 0,        system_C,          chimerab, chimerab, ROT0,   "Jaleco", "Chimera Beast (prototype)", 0 )
41323960GAME( 1993, cybattlr, 0,        system_C,          cybattlr, cybattlr, ROT90,  "Jaleco", "Cybattler", 0 )
src/mame/drivers/airbustr.c
r4135r4136
589589
590590/* Machine Initialization */
591591
592static MACHINE_START( airbustr )
593{
594    state_save_register_global(machine, soundlatch_status);
595    state_save_register_global(machine, soundlatch2_status);
596    state_save_register_global(machine, master_addr);
597    state_save_register_global(machine, slave_addr);
598}
599
592600static MACHINE_RESET( airbustr )
593601{
594602   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
r4135r4136
621629
622630   MDRV_QUANTUM_TIME(HZ(6000))   // Palette RAM is filled by sub cpu with data supplied by main cpu
623631                     // Maybe a high value is safer in order to avoid glitches
632    MDRV_MACHINE_START(airbustr)
624633   MDRV_MACHINE_RESET(airbustr)
625634   MDRV_WATCHDOG_TIME_INIT(SEC(3))   /* a guess, and certainly wrong */
626635
r4135r4136
768777
769778/* Game Drivers */
770779
771GAME( 1990, airbustr, 0,        airbustr, airbustr, airbustr, ROT0, "Kaneko (Namco license)", "Air Buster: Trouble Specialty Raid Unit (World)" , 0)   // 891220
772GAME( 1990, airbustj, airbustr, airbustr, airbustj, airbustr, ROT0, "Kaneko (Namco license)", "Air Buster: Trouble Specialty Raid Unit (Japan)" , 0)   // 891229
773GAME( 1990, airbusb,  airbustr, airbusb,  airbustj, 0,        ROT0, "bootleg", "Air Buster: Trouble Specialty Raid Unit (bootleg)" , 0)   // based on Japan set (891229)
780GAME( 1990, airbustr, 0,        airbustr, airbustr, airbustr, ROT0, "Kaneko (Namco license)", "Air Buster: Trouble Specialty Raid Unit (World)", GAME_SUPPORTS_SAVE )   // 891220
781GAME( 1990, airbustj, airbustr, airbustr, airbustj, airbustr, ROT0, "Kaneko (Namco license)", "Air Buster: Trouble Specialty Raid Unit (Japan)", GAME_SUPPORTS_SAVE)    // 891229
782GAME( 1990, airbusb,  airbustr, airbusb,  airbustj, 0,        ROT0, "bootleg", "Air Buster: Trouble Specialty Raid Unit (bootleg)", GAME_SUPPORTS_SAVE)   // based on Japan set (891229)
src/mame/drivers/parentj.c
r4135r4136
1010
1111static UINT16* parentj_video;
1212
13VIDEO_START(parentj)
13static VIDEO_START(parentj)
1414{
1515
1616
1717}
1818
19VIDEO_UPDATE(parentj)
19static VIDEO_UPDATE(parentj)
2020{
2121   const gfx_element *gfx = screen->machine->gfx[0];
2222   int count = 0x0c000/2;
src/mame/drivers/srmp6.c
r4135r4136
7272#include "sound/nile.h"
7373
7474static UINT16* tileram;
75static UINT8* dirty_tileram;
7675static UINT16* dmaram;
7776
7877static UINT16 *sprram, *sprram_old;
r4135r4136
127126
128127static VIDEO_START(srmp6)
129128{
130   /* create the char set (gfx will then be updated dynamically from RAM) */
131   machine->gfx[0] = allocgfx(machine, &tiles8x8_layout);
132   machine->gfx[0]->total_colors = machine->config->total_colors / 256;
133   machine->gfx[0]->color_granularity=256;
134
135129   tileram = auto_malloc(0x100000*16);
136   dirty_tileram = auto_malloc((0x100000*16)/0x40); // every 8x8x8 tile is 0x40 bytes
137
138130   memset(tileram,0x00,(0x100000*16));
139   memset(dirty_tileram,1,(0x100000*16)/0x40);
140131
141132   dmaram = auto_malloc(0x100);
142133
143134   sprram_old = auto_malloc(0x80000);
144135   memset(sprram_old, 0, 0x80000);
145136
137   /* create the char set (gfx will then be updated dynamically from RAM) */
138   machine->gfx[0] = gfx_element_alloc(machine, &tiles8x8_layout, (UINT8*)tileram, machine->config->total_colors / 256, 0);
139   machine->gfx[0]->color_granularity=256;
140
146141   brightness = 0x60;
147142}
148143
149/* Debug code */
150#ifdef UNUSED_FUNCTION
151static void srmp6_decode_charram(running_machine *machine)
152{
153   if(input_code_pressed_once(KEYCODE_Z))
154   {
155      int i;
156      for (i=0;i<(0x100000*16)/0x40;i++)
157      {
158         decodechar(machine->gfx[0], i, (UINT8*)tileram);
159         dirty_tileram[i] = 0;
160      }
161   }
162}
163#endif
164
165144#if 0
166145static int xixi=0;
167146#endif
168147
169148static VIDEO_UPDATE(srmp6)
170149{
171   int trans = TRANSPARENCY_PEN;
150   int alpha;
172151   int x,y,tileno,height,width,xw,yw,sprite,xb,yb;
173152   UINT16 *sprite_list=sprram_old;
174153   UINT16 mainlist_offset = 0;
r4135r4136
183162
184163#if 0
185164   /* debug */
186   srmp6_decode_charram(screen->machine);
187
188
189
190   /* debug */
191165   if(input_code_pressed_once(KEYCODE_Q))
192166   {
193167      ++xixi;
r4135r4136
226200
227201         if((sprite_list[mainlist_offset+5] & 0x700) == 0x700)
228202         {
229            trans = TRANSPARENCY_ALPHA;
230            alpha_set_level((sprite_list[mainlist_offset+5] & 0x1F) << 3);
203            alpha = (sprite_list[mainlist_offset+5] & 0x1F) << 3;
231204         }
232205         else
233206         {
234            trans = TRANSPARENCY_PEN;
235            alpha_set_level(255);
207            alpha = 255;
236208         }
237209   //  printf("%x %x \n",sprite_list[mainlist_offset+1],sublist_length);
238210
r4135r4136
273245                  else
274246                     yb=y+(height-yw-1)*8+global_y;
275247
276                  if (dirty_tileram[tileno])
277                  {
278                     decodechar(screen->machine->gfx[0], tileno, (UINT8*)tileram);
279                     dirty_tileram[tileno] = 0;
280                  }
281
282                  drawgfx(bitmap,screen->machine->gfx[0],tileno,global_pal,flip_x,flip_y,xb,yb,cliprect,trans,0);
248                  drawgfx_alpha(bitmap,cliprect,screen->machine->gfx[0],tileno,global_pal,flip_x,flip_y,xb,yb,0,alpha);
283249                  tileno++;
284250                }
285251            }
r4135r4136
384350static unsigned short lastb2;
385351static int destl;
386352
387static UINT32 process(UINT8 b,UINT32 dst_offset)
353static UINT32 process(running_machine *machine,UINT8 b,UINT32 dst_offset)
388354{
389355
390356    int l=0;
r4135r4136
399365       for(i=0;i<rle;++i)
400366       {
401367         tram[dst_offset+destl] = lastb;
402         dirty_tileram[(dst_offset+destl)/0x40] = 1;
368         gfx_element_mark_dirty(machine->gfx[0], (dst_offset+destl)/0x40);
403369
404370         dst_offset++;
405371          ++l;
r4135r4136
413379       lastb2=lastb;
414380       lastb=b;
415381      tram[dst_offset+destl] = b;
416      dirty_tileram[(dst_offset+destl)/0x40] = 1;
382      gfx_element_mark_dirty(machine->gfx[0], (dst_offset+destl)/0x40);
417383
418384       return 1;
419385    }
r4135r4136
467433            {
468434               UINT8 real_byte;
469435               real_byte = rom[srctab+p*2];
470               tempidx+=process(real_byte,tempidx);
436               tempidx+=process(space->machine,real_byte,tempidx);
471437               real_byte = rom[srctab+p*2+1];//px[DMA_XOR((current_table_address+p*2+1))];
472               tempidx+=process(real_byte,tempidx);
438               tempidx+=process(space->machine,real_byte,tempidx);
473439             }
474440             else
475441             {
476                tempidx+=process(p,tempidx);
442                tempidx+=process(space->machine,p,tempidx);
477443             }
478444
479445             ctrl<<=1;
src/mame/drivers/sengokmj.c
r4135r4136
1010- Find what the remaining video C.R.T. registers does;
1111- Fix sprites bugs at a start of a play;
1212- Check NVRAM boudaries;
13- Why we need to write "something" to the comms to let the coins to work? Bug with the Seibu custom z80?
1314- How the "SW Service Mode" (press F2 during gameplay) really works (inputs etc)? Nothing mapped works with it...
1415
1516Notes:
r4135r4136
6465WRITE16_HANDLER( sengokmj_mdvram_w );
6566WRITE16_HANDLER( sengokmj_txvram_w );
6667WRITE16_HANDLER( sengokmj_layer_enable_w );
68WRITE16_HANDLER( sengokmj_bg_scrolly_w );
6769VIDEO_START( sengokmj );
6870VIDEO_UPDATE( sengokmj );
6971
r4135r4136
99101   coin_counter_w(0,data & 4);
100102}
101103
104static WRITE16_HANDLER( seibu_z80_com_6_mirror_w )
105{
106   seibu_main_word_w(space,6,data,0xffff);
107}
102108
103109static ADDRESS_MAP_START( sengokmj_map, ADDRESS_SPACE_PROGRAM, 16 )
104110   AM_RANGE(0x00000, 0x07fff) AM_RAM
r4135r4136
114120
115121static ADDRESS_MAP_START( sengokmj_io_map, ADDRESS_SPACE_IO, 16 )
116122   AM_RANGE(0x4000, 0x400f) AM_READWRITE(seibu_main_word_r, seibu_main_word_w)
117   AM_RANGE(0x8000, 0x800f) AM_WRITE(seibu_main_word_w)
118   /*Areas from 8010-804f appears to be video registers / C.R.T. related,probably usual Seibu customness.*/
119   AM_RANGE(0x8010, 0x801b) AM_WRITENOP
123   /*Areas from 8000-804f are for the custom Seibu CRTC.*/
124//  AM_RANGE(0x8000, 0x800f) AM_WRITE(seibu_main_word_w)
125//  AM_RANGE(0x8010, 0x801b) AM_WRITENOP
120126   AM_RANGE(0x801c, 0x801d) AM_WRITE(sengokmj_layer_enable_w)
121   AM_RANGE(0x801e, 0x801f) AM_WRITENOP
122   AM_RANGE(0x8020, 0x802f) AM_WRITENOP
123   AM_RANGE(0x8030, 0x803f) AM_WRITENOP
124   AM_RANGE(0x8040, 0x804f) AM_WRITENOP
127//  AM_RANGE(0x801e, 0x801f) AM_WRITENOP
128//  AM_RANGE(0x8020, 0x802f) AM_WRITENOP
129   AM_RANGE(0x8022, 0x8023) AM_WRITE(sengokmj_bg_scrolly_w)
130//  AM_RANGE(0x8030, 0x803f) AM_WRITENOP
131//  AM_RANGE(0x8040, 0x804f) AM_WRITENOP
125132
126   AM_RANGE(0x8100, 0x8101) AM_WRITENOP // always 0
133   AM_RANGE(0x8080, 0x8081) AM_WRITE(seibu_z80_com_6_mirror_w)
134//  AM_RANGE(0x80c0, 0x80c1) AM_WRITE(seibu_z80_com_unk_mirror_w)
135//  AM_RANGE(0x8100, 0x8101) AM_WRITENOP // always 0
127136   AM_RANGE(0x8180, 0x8181) AM_WRITE(sengokmj_out_w)
128   AM_RANGE(0x8080, 0x8081) AM_WRITENOP
129   AM_RANGE(0x80c0, 0x80cf) AM_WRITENOP
130137   AM_RANGE(0x8140, 0x8141) AM_WRITE(mahjong_panel_w)
131138   AM_RANGE(0xc000, 0xc001) AM_READ_PORT("DSW1")
132139   AM_RANGE(0xc002, 0xc003) AM_READ(mahjong_panel_r)
src/mame/drivers/cham24.c
r4135r4136
5555*/
5656
5757#include "driver.h"
58#include "cpu/m6502/m6502.h"
59#include "sound/dac.h"
60#include "sound/nes_apu.h"
5861#include "video/ppu2c0x.h"
59#include "sound/nes_apu.h"
60#include "cpu/m6502/m6502.h"
6162
6263static WRITE8_HANDLER( sprite_dma_w )
6364{
src/mame/drivers/williams.c
r4135r4136
494494#include "driver.h"
495495#include "cpu/m6809/m6809.h"
496496#include "cpu/m6800/m6800.h"
497#include "machine/6821pia.h"
497#include "sound/dac.h"
498#include "sound/hc55516.h"
499#include "machine/6821new.h"
498500#include "audio/williams.h"
499501#include "williams.h"
500#include "sound/dac.h"
501502
502503
503504#define MASTER_CLOCK      (12000000)
r4135r4136
522523
523524void defender_install_io_space(const address_space *space)
524525{
526   const device_config *pia_0 = devtag_get_device(space->machine, PIA6821, "pia_0");
527   const device_config *pia_1 = devtag_get_device(space->machine, PIA6821, "pia_1");
528
525529   /* this routine dynamically installs the memory mapped above from c000-cfff */
526   memory_install_write8_handler     (space, 0xc000, 0xc00f, 0, 0x03e0, SMH_BANK4);
527   memory_install_write8_handler     (space, 0xc010, 0xc01f, 0, 0x03e0, defender_video_control_w);
528   memory_install_write8_handler     (space, 0xc3ff, 0xc3ff, 0, 0,      williams_watchdog_reset_w);
529   memory_install_readwrite8_handler (space, 0xc400, 0xc4ff, 0, 0x0300, SMH_BANK3, williams_cmos_w);
530   memory_install_read8_handler      (space, 0xc800, 0xcbff, 0, 0x03e0, williams_video_counter_r);
531   memory_install_readwrite8_handler (space, 0xcc00, 0xcc03, 0, 0x03e0, pia_1_r, pia_1_w);
532   memory_install_readwrite8_handler (space, 0xcc04, 0xcc07, 0, 0x03e0, pia_0_r, pia_0_w);
530   memory_install_write8_handler    (space, 0xc000, 0xc00f, 0, 0x03e0, SMH_BANK4);
531   memory_install_write8_handler    (space, 0xc010, 0xc01f, 0, 0x03e0, defender_video_control_w);
532   memory_install_write8_handler    (space, 0xc3ff, 0xc3ff, 0, 0,      williams_watchdog_reset_w);
533   memory_install_readwrite8_handler(space, 0xc400, 0xc4ff, 0, 0x0300, SMH_BANK3, williams_cmos_w);
534   memory_install_read8_handler     (space, 0xc800, 0xcbff, 0, 0x03e0, williams_video_counter_r);
535   memory_install_readwrite8_device_handler(space, pia_1, 0xcc00, 0xcc03, 0, 0x03e0, pia_r, pia_w);
536   memory_install_readwrite8_device_handler(space, pia_0, 0xcc04, 0xcc07, 0, 0x03e0, pia_r, pia_w);
533537   memory_set_bankptr(space->machine, 3, generic_nvram);
534538   memory_set_bankptr(space->machine, 4, paletteram);
535539}
r4135r4136
546550   AM_RANGE(0x0000, 0x8fff) AM_READWRITE(SMH_BANK1, SMH_RAM) AM_BASE(&williams_videoram)
547551   AM_RANGE(0x9000, 0xbfff) AM_RAM
548552   AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0x03f0) AM_WRITE(SMH_RAM) AM_BASE(&paletteram)
549   AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_READWRITE(pia_0_r, pia_0_w)
550   AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_READWRITE(pia_1_r, pia_1_w)
553   AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w)
554   AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, pia_w)
551555   AM_RANGE(0xc900, 0xc9ff) AM_WRITE(williams_vram_select_w)
552556   AM_RANGE(0xca00, 0xca07) AM_MIRROR(0x00f8) AM_WRITE(williams_blitter_w)
553557   AM_RANGE(0xcb00, 0xcbff) AM_READ(williams_video_counter_r)
r4135r4136
561565   AM_RANGE(0x0000, 0x8fff) AM_READWRITE(SMH_BANK1, SMH_RAM) AM_BASE(&williams_videoram)
562566   AM_RANGE(0x9000, 0xbfff) AM_RAM
563567   AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0x03f0) AM_WRITE(SMH_RAM) AM_BASE(&paletteram)
564   AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_READWRITE(pia_0_r, pia_0_w)
565   AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_READWRITE(pia_1_r, pia_1_w)
568   AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w)
569   AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, pia_w)
566570   AM_RANGE(0xc900, 0xc9ff) AM_WRITE(sinistar_vram_select_w)
567571   AM_RANGE(0xca00, 0xca07) AM_MIRROR(0x00f8) AM_WRITE(williams_blitter_w)
568572   AM_RANGE(0xcb00, 0xcbff) AM_READ(williams_video_counter_r)
r4135r4136
587591   AM_RANGE(0xbc00, 0xbcff) AM_WRITE(SMH_RAM) AM_BASE(&blaster_scanline_control)
588592   AM_RANGE(0x9000, 0xbfff) AM_RAM
589593   AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0x03f0) AM_WRITE(SMH_RAM) AM_BASE(&paletteram)
590   AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_READWRITE(pia_0_r, pia_0_w)
591   AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_READWRITE(pia_1_r, pia_1_w)
594   AM_RANGE(0xc804, 0xc807) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w)
595   AM_RANGE(0xc80c, 0xc80f) AM_MIRROR(0x00f0) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, pia_w)
592596   AM_RANGE(0xc900, 0xc93f) AM_WRITE(blaster_vram_select_w)
593597   AM_RANGE(0xc940, 0xc97f) AM_WRITE(blaster_remap_select_w)
594598   AM_RANGE(0xc980, 0xc9bf) AM_WRITE(blaster_bank_select_w)
r4135r4136
615619   AM_RANGE(0xc800, 0xc87f) AM_WRITE(williams2_bank_select_w)
616620   AM_RANGE(0xc880, 0xc887) AM_MIRROR(0x0078) AM_WRITE(williams_blitter_w)
617621   AM_RANGE(0xc900, 0xc97f) AM_WRITE(williams2_watchdog_reset_w)
618   AM_RANGE(0xc980, 0xc983) AM_MIRROR(0x0070) AM_READWRITE(pia_1_r, pia_1_w)
619   AM_RANGE(0xc984, 0xc987) AM_MIRROR(0x0070) AM_READWRITE(pia_0_r, pia_0_w)
622   AM_RANGE(0xc980, 0xc983) AM_MIRROR(0x0070) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, pia_w)
623   AM_RANGE(0xc984, 0xc987) AM_MIRROR(0x0070) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w)
620624   AM_RANGE(0xc98c, 0xc98f) AM_MIRROR(0x0070) AM_WRITE(williams2_7segment_w)
621625   AM_RANGE(0xcb00, 0xcb1f) AM_WRITE(williams2_fg_select_w)
622626   AM_RANGE(0xcb20, 0xcb3f) AM_WRITE(williams2_bg_select_w)
r4135r4136
637641   AM_RANGE(0xc800, 0xc87f) AM_WRITE(williams2_bank_select_w)
638642   AM_RANGE(0xc880, 0xc887) AM_MIRROR(0x0078) AM_WRITE(williams_blitter_w)
639643   AM_RANGE(0xc900, 0xc97f) AM_WRITE(williams2_watchdog_reset_w)
640   AM_RANGE(0xc980, 0xc983) AM_MIRROR(0x0070) AM_READWRITE(pia_1_r, pia_1_w)
641   AM_RANGE(0xc984, 0xc987) AM_MIRROR(0x0070) AM_READWRITE(pia_0_r, pia_0_w)
644   AM_RANGE(0xc980, 0xc983) AM_MIRROR(0x0070) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, pia_w)
645   AM_RANGE(0xc984, 0xc987) AM_MIRROR(0x0070) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w)
642646   AM_RANGE(0xc98c, 0xc98f) AM_MIRROR(0x0070) AM_WRITE(williams2_7segment_w)
643647   AM_RANGE(0xcb00, 0xcb1f) AM_WRITE(williams2_fg_select_w)
644648   AM_RANGE(0xcb20, 0xcb3f) AM_WRITE(williams2_bg_select_w)
r4135r4136
662666
663667static ADDRESS_MAP_START( defender_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
664668   AM_RANGE(0x0000, 0x007f) AM_RAM      /* internal RAM */
665   AM_RANGE(0x0400, 0x0403) AM_MIRROR(0x8000) AM_READWRITE(pia_2_r, pia_2_w)
669   AM_RANGE(0x0400, 0x0403) AM_MIRROR(0x8000) AM_DEVREADWRITE(PIA6821, "pia_2", pia_r, pia_w)
666670   AM_RANGE(0xb000, 0xffff) AM_ROM      /* most games start at $F000, Sinistar starts at $B000 */
667671ADDRESS_MAP_END
668672
r4135r4136
670674static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
671675   AM_RANGE(0x0000, 0x007f) AM_RAM      /* internal RAM */
672676   AM_RANGE(0x0080, 0x00ff) AM_RAM      /* MC6810 RAM */
673   AM_RANGE(0x0400, 0x0403) AM_MIRROR(0x8000) AM_READWRITE(pia_2_r, pia_2_w)
677   AM_RANGE(0x0400, 0x0403) AM_MIRROR(0x8000) AM_DEVREADWRITE(PIA6821, "pia_2", pia_r, pia_w)
674678   AM_RANGE(0xb000, 0xffff) AM_ROM      /* most games start at $F000, Sinistar starts at $B000 */
675679ADDRESS_MAP_END
676680
r4135r4136
685689static ADDRESS_MAP_START( williams2_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
686690   AM_RANGE(0x0000, 0x007f) AM_RAM      /* internal RAM */
687691   AM_RANGE(0x0080, 0x00ff) AM_RAM      /* MC6810 RAM */
688   AM_RANGE(0x2000, 0x2003) AM_MIRROR(0x1ffc) AM_READWRITE(pia_2_r, pia_2_w)
692   AM_RANGE(0x2000, 0x2003) AM_MIRROR(0x1ffc) AM_DEVREADWRITE(PIA6821, "pia_2", pia_r, pia_w)
689693   AM_RANGE(0xe000, 0xffff) AM_ROM
690694ADDRESS_MAP_END
691695
r4135r4136
14451449
14461450   MDRV_SOUND_ADD("dac", DAC, 0)
14471451   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
1452
1453   /* pia */
1454   MDRV_PIA6821_ADD("pia_0", williams_pia_0_intf)
1455   MDRV_PIA6821_ADD("pia_1", williams_pia_1_intf)
1456   MDRV_PIA6821_ADD("pia_2", williams_snd_pia_intf)
14481457MACHINE_DRIVER_END
14491458
14501459
r4135r4136
14731482MACHINE_DRIVER_END
14741483
14751484
1485static MACHINE_DRIVER_START( williams_muxed )
1486
1487   /* basic machine hardware */
1488   MDRV_IMPORT_FROM(williams)
1489
1490   /* pia */
1491   MDRV_PIA6821_MODIFY("pia_0", williams_muxed_pia_0_intf)
1492MACHINE_DRIVER_END
1493
1494
14761495static MACHINE_DRIVER_START( williams_extra_ram )
14771496
14781497   /* basic machine hardware */
r4135r4136
14831502MACHINE_DRIVER_END
14841503
14851504
1505static MACHINE_DRIVER_START( spdball )
1506
1507   /* basic machine hardware */
1508   MDRV_IMPORT_FROM(williams)
1509
1510   /* pia */
1511   MDRV_PIA6821_ADD("pia_3", spdball_pia_3_intf)
1512MACHINE_DRIVER_END
1513
1514
1515static MACHINE_DRIVER_START( lottofun )
1516
1517   /* basic machine hardware */
1518   MDRV_IMPORT_FROM(williams)
1519
1520   /* pia */
1521   MDRV_PIA6821_MODIFY("pia_0", lottofun_pia_0_intf)
1522MACHINE_DRIVER_END
1523
1524
14861525static MACHINE_DRIVER_START( alienar )
14871526
14881527   /* basic machine hardware */
r4135r4136
14941533   MDRV_MACHINE_RESET(williams)
14951534   MDRV_SCREEN_MODIFY("main")
14961535   MDRV_SCREEN_VISIBLE_AREA(6, 298-1, 7, 247-1)
1536
1537   /* pia */
1538   MDRV_PIA6821_MODIFY("pia_0", williams_muxed_pia_0_intf)
14971539MACHINE_DRIVER_END
14981540
14991541
r4135r4136
15051547   /* sound hardware */
15061548   MDRV_SOUND_ADD("cvsd", HC55516, 0)
15071549   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
1550
1551   /* pia */
1552   MDRV_PIA6821_MODIFY("pia_0", williams_49way_pia_0_intf)
1553   MDRV_PIA6821_MODIFY("pia_2", sinistar_snd_pia_intf)
15081554MACHINE_DRIVER_END
15091555
15101556
r4135r4136
15201566   /* sound hardware */
15211567   MDRV_SOUND_ADD("cvsd", HC55516, 0)
15221568   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
1569
1570   /* pia */
1571   MDRV_PIA6821_MODIFY("pia_1", playball_pia_1_intf)
1572   MDRV_PIA6821_MODIFY("pia_2", sinistar_snd_pia_intf)
15231573MACHINE_DRIVER_END
15241574
15251575
r4135r4136
15361586   /* video hardware */
15371587   MDRV_VIDEO_START(blaster)
15381588   MDRV_VIDEO_UPDATE(blaster)
1589
1590   /* pia */
1591   MDRV_PIA6821_MODIFY("pia_0", williams_49way_pia_0_intf)
15391592MACHINE_DRIVER_END
15401593
15411594
1595static MACHINE_DRIVER_START( blastkit )
1596
1597   /* basic machine hardware */
1598   MDRV_IMPORT_FROM(blaster)
1599
1600   /* pia */
1601   MDRV_PIA6821_MODIFY("pia_0", williams_49way_muxed_pia_0_intf)
1602MACHINE_DRIVER_END
1603
1604
15421605static MACHINE_DRIVER_START( williams2 )
15431606
15441607   /* basic machine hardware */
r4135r4136
15681631
15691632   MDRV_SOUND_ADD("wmsdac", DAC, 0)
15701633   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
1634
1635   /* pia */
1636   MDRV_PIA6821_ADD("pia_0", williams2_muxed_pia_0_intf)
1637   MDRV_PIA6821_ADD("pia_1", williams2_pia_1_intf)
1638   MDRV_PIA6821_ADD("pia_2", williams2_snd_pia_intf)
15711639MACHINE_DRIVER_END
15721640
15731641
r4135r4136
15811649MACHINE_DRIVER_END
15821650
15831651
1652static MACHINE_DRIVER_START( mysticm )
1653
1654   /* basic machine hardware */
1655   MDRV_IMPORT_FROM(williams2_extra_ram)
1656
1657   /* pia */
1658   MDRV_PIA6821_MODIFY("pia_0", mysticm_pia_0_intf)
1659   MDRV_PIA6821_MODIFY("pia_1", mysticm_pia_1_intf)
1660MACHINE_DRIVER_END
1661
1662
1663static MACHINE_DRIVER_START( tshoot )
1664
1665   /* basic machine hardware */
1666   MDRV_IMPORT_FROM(williams2)
1667
1668   /* pia */
1669   MDRV_PIA6821_MODIFY("pia_0", tshoot_pia_0_intf)
1670   MDRV_PIA6821_MODIFY("pia_1", tshoot_pia_1_intf)
1671   MDRV_PIA6821_MODIFY("pia_2", tshoot_snd_pia_intf)
1672MACHINE_DRIVER_END
1673
1674
15841675static MACHINE_DRIVER_START( joust2 )
15851676
15861677   /* basic machine hardware */
r4135r4136
15931684
15941685   /* sound hardware */
15951686   MDRV_SOUND_REMOVE("wmsdac")
1687
1688   /* pia */
1689   MDRV_PIA6821_MODIFY("pia_1", joust2_pia_1_intf)
1690   MDRV_PIA6821_ADD("pia_3", joust2_pia_3_intf)
15961691MACHINE_DRIVER_END
15971692
15981693
r4135r4136
26002695#define CONFIGURE_TILEMAP(x) \
26012696   williams2_tilemap_config = x
26022697
2603#define CONFIGURE_PIAS(a,b,c) \
2604   pia_config(machine, 0, &a);\
2605   pia_config(machine, 1, &b);\
2606   pia_config(machine, 2, &c)
26072698
26082699
2609
26102700/*************************************
26112701 *
26122702 *  Defender hardware driver init
r4135r4136
26162706static DRIVER_INIT( defender )
26172707{
26182708   CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000);
2619   CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
26202709}
26212710
26222711
r4135r4136
26262715   int i;
26272716
26282717   CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000);
2629   CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
26302718
26312719   /* apply simple decryption by swapping bits 0 and 7 */
26322720   for (i = 0xd000; i < 0x19000; i++)
r4135r4136
26372725static DRIVER_INIT( mayday )
26382726{
26392727   CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000);
2640   CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
26412728
26422729   /* install a handler to catch protection checks */
26432730   mayday_protection = memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa190, 0xa191, 0, 0, mayday_protection_r);
r4135r4136
26542741static DRIVER_INIT( stargate )
26552742{
26562743   CONFIGURE_BLITTER(WILLIAMS_BLITTER_NONE, 0x0000);
2657   CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
26582744}
26592745
26602746
26612747static DRIVER_INIT( robotron )
26622748{
26632749   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000);
2664   CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
26652750}
26662751
26672752
26682753static DRIVER_INIT( joust )
26692754{
26702755   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000);
2671   CONFIGURE_PIAS(williams_muxed_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
26722756}
26732757
26742758
26752759static DRIVER_INIT( bubbles )
26762760{
26772761   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000);
2678   CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
26792762
26802763   /* bubbles has a full 8-bit-wide CMOS */
26812764   memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xcc00, 0xcfff, 0, 0, bubbles_cmos_w);
r4135r4136
26852768static DRIVER_INIT( splat )
26862769{
26872770   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0xc000);
2688   CONFIGURE_PIAS(williams_muxed_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
26892771}
26902772
26912773
26922774static DRIVER_INIT( sinistar )
26932775{
26942776   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0x7400);
2695   CONFIGURE_PIAS(williams_49way_pia_0_intf, williams_pia_1_intf, sinistar_snd_pia_intf);
26962777}
26972778
26982779
26992780static DRIVER_INIT( playball )
27002781{
27012782   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000);
2702   CONFIGURE_PIAS(williams_pia_0_intf, playball_pia_1_intf, sinistar_snd_pia_intf);
27032783}
27042784
27052785
27062786static DRIVER_INIT( blaster )
27072787{
27082788   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9700);
2709   CONFIGURE_PIAS(williams_49way_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
27102789}
27112790
27122791
27132792static DRIVER_INIT( blastkit )
27142793{
27152794   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9700);
2716   CONFIGURE_PIAS(williams_49way_muxed_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
27172795}
27182796
27192797
27202798static DRIVER_INIT( spdball )
27212799{
2800   const device_config *pia_3 = devtag_get_device(machine, PIA6821, "pia_3");
2801
27222802   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000);
2723   CONFIGURE_PIAS(williams_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
27242803
27252804   /* add a third PIA */
2726   pia_config(machine, 3, &spdball_pia_3_intf);
2727   memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc808, 0xc80b, 0, 0, pia_3_r, pia_3_w);
2805   memory_install_readwrite8_device_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), pia_3, 0xc808, 0xc80b, 0, 0, pia_r, pia_w);
27282806
27292807   /* install extra input handlers */
27302808   memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc800, 0xc800, 0, 0, input_port_read_handler8(machine->portconfig, "AN0"));
r4135r4136
27372815static DRIVER_INIT( alienar )
27382816{
27392817   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000);
2740   CONFIGURE_PIAS(williams_muxed_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
27412818   memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xcbff, 0xcbff, 0, 0, SMH_NOP);
27422819}
27432820
r4135r4136
27452822static DRIVER_INIT( alienaru )
27462823{
27472824   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000);
2748   CONFIGURE_PIAS(williams_muxed_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
27492825   memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xcbff, 0xcbff, 0, 0, SMH_NOP);
27502826}
27512827
r4135r4136
27532829static DRIVER_INIT( lottofun )
27542830{
27552831   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC01, 0xc000);
2756   CONFIGURE_PIAS(lottofun_pia_0_intf, williams_pia_1_intf, williams_snd_pia_intf);
27572832}
27582833
27592834
r4135r4136
27682843{
27692844   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9000);
27702845   CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_MYSTICM);
2771   CONFIGURE_PIAS(mysticm_pia_0_intf, mysticm_pia_1_intf, williams2_snd_pia_intf);
27722846}
27732847
27742848
r4135r4136
27762850{
27772851   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9000);
27782852   CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_TSHOOT);
2779   CONFIGURE_PIAS(tshoot_pia_0_intf, tshoot_pia_1_intf, tshoot_snd_pia_intf);
27802853}
27812854
27822855
r4135r4136
27842857{
27852858   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9000);
27862859   CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_TSHOOT);
2787   CONFIGURE_PIAS(williams2_muxed_pia_0_intf, williams2_pia_1_intf, williams2_snd_pia_intf);
27882860}
27892861
27902862
r4135r4136
27922864{
27932865   CONFIGURE_BLITTER(WILLIAMS_BLITTER_SC02, 0x9000);
27942866   CONFIGURE_TILEMAP(WILLIAMS_TILEMAP_JOUST2);
2795   CONFIGURE_PIAS(williams2_muxed_pia_0_intf, joust2_pia_1_intf, williams2_snd_pia_intf);
27962867}
27972868
27982869
r4135r4136
28272898GAME( 1981, stargate, 0,        williams,            stargate, stargate, ROT0,   "Williams", "Stargate", GAME_SUPPORTS_SAVE )
28282899GAME( 1982, robotron, 0,        williams,            robotron, robotron, ROT0,   "Williams", "Robotron (Solid Blue label)", GAME_SUPPORTS_SAVE )
28292900GAME( 1982, robotryo, robotron, williams,            robotron, robotron, ROT0,   "Williams", "Robotron (Yellow/Orange label)", GAME_SUPPORTS_SAVE )
2830GAME( 1982, joust,    0,        williams,            joust,    joust,    ROT0,   "Williams", "Joust (White/Green label)", GAME_SUPPORTS_SAVE )
2831GAME( 1982, joustr,   joust,    williams,            joust,    joust,    ROT0,   "Williams", "Joust (Solid Red label)", GAME_SUPPORTS_SAVE )
2832GAME( 1982, joustwr,  joust,    williams,            joust,    joust,    ROT0,   "Williams", "Joust (White/Red label)", GAME_SUPPORTS_SAVE )
2901GAME( 1982, joust,    0,        williams_muxed,      joust,    joust,    ROT0,   "Williams", "Joust (White/Green label)", GAME_SUPPORTS_SAVE )
2902GAME( 1982, joustr,   joust,    williams_muxed,      joust,    joust,    ROT0,   "Williams", "Joust (Solid Red label)", GAME_SUPPORTS_SAVE )
2903GAME( 1982, joustwr,  joust,    williams_muxed,      joust,    joust,    ROT0,   "Williams", "Joust (White/Red label)", GAME_SUPPORTS_SAVE )
28332904GAME( 1982, bubbles,  0,        williams,            bubbles,  bubbles,  ROT0,   "Williams", "Bubbles", GAME_SUPPORTS_SAVE )
28342905GAME( 1982, bubblesr, bubbles,  williams,            bubbles,  bubbles,  ROT0,   "Williams", "Bubbles (Solid Red label)", GAME_SUPPORTS_SAVE )
28352906GAME( 1982, bubblesp, bubbles,  williams,            bubbles,  bubbles,  ROT0,   "Williams", "Bubbles (prototype version)", GAME_SUPPORTS_SAVE )
2836GAME( 1982, splat,    0,        williams,            splat,    splat,    ROT0,   "Williams", "Splat!", GAME_SUPPORTS_SAVE )
2907GAME( 1982, splat,    0,        williams_muxed,      splat,    splat,    ROT0,   "Williams", "Splat!", GAME_SUPPORTS_SAVE )
28372908GAME( 1982, sinistar, 0,        sinistar,            sinistar, sinistar, ROT270, "Williams", "Sinistar (revision 3)", GAME_SUPPORTS_SAVE )
28382909GAME( 1982, sinista1, sinistar, sinistar,            sinistar, sinistar, ROT270, "Williams", "Sinistar (prototype version)", GAME_SUPPORTS_SAVE )
28392910GAME( 1982, sinista2, sinistar, sinistar,            sinistar, sinistar, ROT270, "Williams", "Sinistar (revision 2)", GAME_SUPPORTS_SAVE )
28402911GAME( 1983, playball, 0,        playball,            playball, playball, ROT270, "Williams", "PlayBall! (prototype)", GAME_SUPPORTS_SAVE )
28412912GAME( 1983, blaster,  0,        blaster,             blaster,  blaster,  ROT0,   "Williams", "Blaster", GAME_SUPPORTS_SAVE )
28422913GAME( 1983, blast30,  blaster,  blaster,             blaster,  blaster,  ROT0,   "Williams", "Blaster (early 30 wave version)", GAME_SUPPORTS_SAVE )
2843GAME( 1983, blastkit, blaster,  blaster,             blastkit, blastkit, ROT0,   "Williams", "Blaster (kit)", GAME_SUPPORTS_SAVE )
2844GAME( 1985, spdball,  0,        williams,            spdball,  spdball,  ROT0,   "Williams", "Speed Ball (prototype)", GAME_SUPPORTS_SAVE )
2914GAME( 1983, blastkit, blaster,  blastkit,            blastkit, blastkit, ROT0,   "Williams", "Blaster (kit)", GAME_SUPPORTS_SAVE )
2915GAME( 1985, spdball,  0,        spdball,             spdball,  spdball,  ROT0,   "Williams", "Speed Ball (prototype)", GAME_SUPPORTS_SAVE )
28452916GAME( 1985, alienar,  0,        alienar,             alienar,  alienar,  ROT0,   "Duncan Brown", "Alien Arena", GAME_SUPPORTS_SAVE )
28462917GAME( 1985, alienaru, alienar,  alienar,             alienar,  alienaru, ROT0,   "Duncan Brown", "Alien Arena (Stargate Upgrade)", GAME_SUPPORTS_SAVE )
2847GAME( 1987, lottofun, 0,        williams,            lottofun, lottofun, ROT0,   "H.A.R. Management", "Lotto Fun", GAME_SUPPORTS_SAVE )
2918GAME( 1987, lottofun, 0,        lottofun,            lottofun, lottofun, ROT0,   "H.A.R. Management", "Lotto Fun", GAME_SUPPORTS_SAVE )
28482919
28492920/* 2nd Generation Williams hardware with tilemaps */
2850GAME( 1983, mysticm,  0,        williams2_extra_ram, mysticm,  mysticm,  ROT0,   "Williams", "Mystic Marathon", GAME_SUPPORTS_SAVE )
2851GAME( 1984, tshoot,   0,        williams2,           tshoot,   tshoot,   ROT0,   "Williams", "Turkey Shoot", GAME_SUPPORTS_SAVE )
2921GAME( 1983, mysticm,  0,        mysticm,             mysticm,  mysticm,  ROT0,   "Williams", "Mystic Marathon", GAME_SUPPORTS_SAVE )
2922GAME( 1984, tshoot,   0,        tshoot,              tshoot,   tshoot,   ROT0,   "Williams", "Turkey Shoot", GAME_SUPPORTS_SAVE )
28522923GAME( 1984, inferno,  0,        williams2_extra_ram, inferno,  inferno,  ROT0,   "Williams", "Inferno", GAME_SUPPORTS_SAVE )
28532924GAME( 1986, joust2,   0,        joust2,              joust2,   joust2,   ROT270, "Williams", "Joust 2 - Survival of the Fittest (set 1)", GAME_SUPPORTS_SAVE )
src/mame/drivers/slotcarn.c
r4135r4136
168168static ADDRESS_MAP_START( slotcarn_map, ADDRESS_SPACE_PROGRAM, 8 )
169169   AM_RANGE(0x0000, 0x5fff) AM_ROM
170170   AM_RANGE(0x6000, 0x67ff) AM_RAM AM_BASE(&backup_ram)
171   AM_RANGE(0x6800, 0x6fff) AM_RAM // spielbud
172   AM_RANGE(0x7000, 0xafff) AM_ROM // spielbud
171173
174
172175   AM_RANGE(0xb000, 0xb000) AM_WRITE(ay8910_control_port_0_w)
173176   AM_RANGE(0xb100, 0xb100) AM_READWRITE(ay8910_read_port_0_r,ay8910_write_port_0_w)
174177
r4135r4136
189192   AM_RANGE(0xf800, 0xfbff) AM_READWRITE(palette_r, palette_w)
190193ADDRESS_MAP_END
191194
195// spielbud - is the ay mirrored, or are there now 2?
196static ADDRESS_MAP_START( spielbud_io_map, ADDRESS_SPACE_IO, 8 )
197   AM_RANGE(0xb000, 0xb000) AM_WRITE(ay8910_control_port_0_w)
198   AM_RANGE(0xb100, 0xb100) AM_WRITE(ay8910_write_port_0_w)
199ADDRESS_MAP_END
192200
193201/********************************
194202*          Input Ports          *
r4135r4136
200208   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
201209   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
202210   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
203   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Key In") PORT_CODE(KEYCODE_Q)
204   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Start")  PORT_CODE(KEYCODE_N)
205   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Cancel") PORT_CODE(KEYCODE_M)
206   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Select") PORT_CODE(KEYCODE_B)
211   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_Q) PORT_NAME("Key In")
212   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_N) PORT_NAME("Start")
213   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_M) PORT_NAME("Cancel")
214   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Select")
207215
208216   PORT_START("IN1")   /* b801 (ppi8255) */
209217   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)       /* Coin A */
210218   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2)    PORT_IMPULSE(2)       /* Coin B */
211   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Stats")    PORT_CODE(KEYCODE_0)
212   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Settings") PORT_CODE(KEYCODE_9)
219   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
220   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
213221   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
214222   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)       /* Coin C */
215223   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)       /* Coin D */
216224   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
217225
218226   PORT_START("IN2")   /* b802 (ppi8255) */
219   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
220   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
221   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
222   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
223   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
224   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
225   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
226   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
227   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
227228
228229   PORT_START("IN3")   /* bc00 (ppi8255) */
229230   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
230231   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
231232   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
232   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Double-Up")    PORT_CODE(KEYCODE_C)
233   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Take Score")   PORT_CODE(KEYCODE_V)
234   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Bet")          PORT_CODE(KEYCODE_Z)
235   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Payout")       PORT_CODE(KEYCODE_W)
236   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Empty Hopper") PORT_CODE(KEYCODE_H)
233   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Double-Up")
234   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Take Score")
235   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("Bet")
236   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_W) PORT_NAME("Payout")
237   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_H) PORT_NAME("Empty Hopper")
237238
238239   PORT_START("IN4")   /* bc01 (ppi8255) */
239   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
240   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
241   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
242   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
243   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
244   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
245   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
246   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
240   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
247241
248242   PORT_START("DSW1")   /* ba00 (ppi8255) */
249243   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:8")
r4135r4136
349343   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
350344INPUT_PORTS_END
351345
346static INPUT_PORTS_START( spielbud )
347   PORT_START("IN0")   /* b800 (ppi8255) */
348   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z) PORT_NAME("Discard 1 / Deal (BJ)")
349   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X) PORT_NAME("Discard 2")
350   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C) PORT_NAME("Discard 3 / Bet 1 / Split (BJ)")
351   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V) PORT_NAME("Discard4 / Stand (BJ)")
352   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B) PORT_NAME("Discard5 / Hit (BJ)")
353   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_CODE(KEYCODE_1) PORT_NAME("Start")
354   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_CODE(KEYCODE_N) PORT_NAME("Cancel / Select")
355   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
352356
357   PORT_START("IN1")   /* b801 (ppi8255) */
358   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1)    PORT_IMPULSE(2)   /* Coin A */
359   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2)    PORT_IMPULSE(2)   /* Coin B */
360   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Stats")
361   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Settings")
362   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
363   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3)    PORT_IMPULSE(2)   /* Coin C */
364   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN4)    PORT_IMPULSE(2)   /* Coin D */
365   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
366
367   PORT_START("IN2")   /* b802 (ppi8255) */
368   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
369
370   PORT_START("IN3")   /* bc00 (ppi8255) */
371   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
372   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON8 )  PORT_CODE(KEYCODE_A) PORT_NAME("Tief (Low)")
373   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON9 )  PORT_CODE(KEYCODE_S) PORT_NAME("Hoch (High)")
374   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_CODE(KEYCODE_3) PORT_NAME("Double-Up")
375   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_CODE(KEYCODE_4) PORT_NAME("Take Score")
376   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_CODE(KEYCODE_2) PORT_NAME("Bet 2")
377   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE )  PORT_CODE(KEYCODE_W) PORT_NAME("Payout")
378   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
379
380   PORT_START("IN4")   /* bc01 (ppi8255) */
381   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
382
383   PORT_START("DSW1")   /* ba00 (ppi8255) */
384   PORT_DIPNAME( 0x01, 0x01, "Game STRATEGIE" )
385   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
386   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
387   PORT_DIPNAME( 0x02, 0x02, "Game MITTE TRIFFT" )
388   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
389   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
390   PORT_DIPNAME( 0x04, 0x04, "Game KNOBELN" )
391   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
392   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
393   PORT_DIPNAME( 0x08, 0x08, "Game BLACK JACK" )
394   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
395   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
396   PORT_DIPNAME( 0x10, 0x10, "Game CONTINENTAL" )
397   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
398   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
399   PORT_DIPNAME( 0x20, 0x20, "Game 5 LINIEN SPIEL" )
400   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
401   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
402   PORT_DIPNAME( 0xc0, 0xc0, "Max Bet Settings" )
403   PORT_DIPSETTING(    0xc0, "Play 1 to 10 bets" )
404   PORT_DIPSETTING(    0x80, "Play 1 to 20 bets" )
405   PORT_DIPSETTING(    0x40, "Play 1 bet by hand" )
406   PORT_DIPSETTING(    0x00, "Play 1 to 50 bets" )
407
408   PORT_START("DSW2")   /* ay8910, port B */
409   PORT_DIPNAME( 0x07, 0x07, "Main Game rate" )
410   PORT_DIPSETTING(    0x06, "75%" )
411   PORT_DIPSETTING(    0x05, "80%" )
412   PORT_DIPSETTING(    0x07, "85%" )
413   PORT_DIPSETTING(    0x03, "90%" )
414   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
415   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
416   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
417   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
418   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
419   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
420   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
421   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
422   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
423   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
424   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
425   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
426   PORT_DIPNAME( 0x80, 0x00, "Hold Buttons Behaviour" )
427   PORT_DIPSETTING(    0x00, "Hold" )
428   PORT_DIPSETTING(    0x80, "Discard" )
429
430   PORT_START("DSW3")   /* c000 direct */
431   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
432   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
433   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
434   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
435   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
436   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
437   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
438   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
439   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
440   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
441   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
442   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
443   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
444   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
445   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
446   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
447   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
448   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
449   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
450   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
451   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
452   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
453   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
454   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
455
456   PORT_START("DSW4")   /* c400 direct */
457   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
458   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
459   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
460   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
461   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
462   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
463   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
464   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
465   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
466   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
467   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
468   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
469   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
470   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
471   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
472   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
473   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
474   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
475   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
476   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
477   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
478   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
479   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
480   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
481INPUT_PORTS_END
482
483
353484/*************************************
354485*          Graphics Layouts          *
355486*************************************/
r4135r4136
463594   /* basic machine hardware */
464595   MDRV_CPU_ADD("main", Z80, CPU_CLOCK) // 2.5 Mhz?
465596   MDRV_CPU_PROGRAM_MAP(slotcarn_map,0)
466   //MDRV_CPU_IO_MAP(goldstar_readport,0)
467   //MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
597   MDRV_CPU_IO_MAP(spielbud_io_map,0)
468598
469599   /* 3x 8255 */
470600   MDRV_PPI8255_ADD( "ppi8255_0", scarn_ppi8255_intf[0] )
r4135r4136
561691   ROM_LOAD( "rom4.a5", 0x0000, 0x4000, CRC(1428c46c) SHA1(ea30eeebcc2cc825f33e1ffeb590b047e3072b9c) )
562692ROM_END
563693
694/*
564695
696Lucky - Wing?
697--------------
698
699CPU:      1x Z80 (NEC D780C)
700Video:    1x 6845 (HD46505SP HD6845SP)
701Sound:    1x AY-3-8910
702I/O:      3x 8255 (M5L8255AP-5)
703
704ROM:      6x 2764 (0, 1, 2, 3, 4, 9)
705          3x 27128 (6, 7, 8)
706
707RAM:      1x HM6116LP-3 near ROMs 0 to 4
708          1x M58725P near ROMs 0 to 4
709          2x M58725P near ROMs 6 to 9
710
711Xtal:     10 MHz.
712
713DIP SW:   4x 8 DSW banks.
714
715
716---------------------------------
717
718Not from Wing.
719It's a multi cards game produced in 1983, called "Spiel Bud" (Play Booth)
720Language: german.
721
722Roms have stickers with only a number, so were renamed from lwing to spielbud.
723
724*/
725
726ROM_START( spielbud )
727   ROM_REGION( 0x20000, "main", 0 )
728   ROM_LOAD( "spielbud.00", 0x0000, 0x2000, CRC(201c7f19) SHA1(fb902824d1f6cfdf7ba124fca4c680af099ca4e1) )
729   ROM_LOAD( "spielbud.01", 0x2000, 0x2000, CRC(16339de8) SHA1(00b14c6bca268b98bfb6ac9840d59b9a64d43b92) )
730   ROM_LOAD( "spielbud.02", 0x4000, 0x2000, CRC(c791e75b) SHA1(b0276a82302a194fc1ab2608440a5bf1efe99e64) )
731   ROM_LOAD( "spielbud.03", 0x7000, 0x2000, CRC(ddc60075) SHA1(592dc1f9ff00e703ed1c06fd037aa32569b19143) )
732   ROM_LOAD( "spielbud.04", 0x9000, 0x2000, CRC(74f1ca60) SHA1(17a67beb00d9c4b3310930ad5c5f566b801634d7) )
733
734   ROM_REGION( 0xc000, "gfx1", 0 )
735   ROM_LOAD( "spielbud.08", 0x0000, 0x4000, CRC(4a4ebe62) SHA1(5d789f2eea61864cd55f20a7697304daaff105c4) )
736   ROM_LOAD( "spielbud.07", 0x4000, 0x4000, CRC(33c0064e) SHA1(bb4b80359b36b0b34e0d31ee1f18fd64b92ed342) )
737   ROM_LOAD( "spielbud.06", 0x8000, 0x4000, CRC(bb2b6fd3) SHA1(5adb543c1d10aaede08609463f2ce82c5a68aca8) )
738
739   ROM_REGION( 0x4000, "gfx2", 0 )
740   ROM_LOAD( "spielbud.09", 0x0000, 0x2000, CRC(d88c72f2) SHA1(bb015685f4c2cc7723c24880c11cb6d31f71e73f) )
741ROM_END
742
743
565744/*********************************************
566745*                Game Drivers                *
567746**********************************************
568747
569      YEAR  NAME      PARENT   MACHINE   INPUT     INIT   ROT    COMPANY        FULLNAME        FLAGS  */
570GAME( 1985, slotcarn, 0,       slotcarn, slotcarn, 0,     ROT0, "Wing Co.Ltd", "Slot Carnival", GAME_NOT_WORKING )
571
748      YEAR  NAME      PARENT   MACHINE   INPUT     INIT   ROT    COMPANY        FULLNAME               FLAGS  */
749GAME( 1985, slotcarn, 0,       slotcarn, slotcarn, 0,     ROT0, "Wing Co.Ltd", "Slot Carnival",        GAME_NOT_WORKING )
750GAME( 1985, spielbud, 0,       slotcarn, spielbud, 0,     ROT0, "ADP",         "Spiel Bude (German)",  GAME_NOT_WORKING )
src/mame/drivers/genesis.c
r4135r4136
180180   {
181181   case 0:                     /* DRAM mode is write only */
182182      return 0xffff;
183      break;
184183   case 0x80:                  /* return Z80 CPU Function Stop Accessible or not */
185184      /* logerror("Returning z80 state\n"); */
186185      return (z80running ? 0x0100 : 0x0);
187      break;
188186   case 0x100:                  /* Z80 CPU Reset - write only */
189187      return 0xffff;
190      break;
191188   }
192189   return 0x00;
193190
r4135r4136
204201   {
205202   case 0:                     /* set DRAM mode... we have to ignore this for production cartridges */
206203      return;
207      break;
208204   case 0x80:                  /* Z80 BusReq */
209205      if (data == 0x100)
210206      {
r4135r4136
221217         /* logerror("z80 started, BusReq ends\n"); */
222218      }
223219      return;
224      break;
225220   case 0x100:                  /* Z80 CPU Reset */
226221      if (data == 0x00)
227222      {
r4135r4136
238233         /* logerror("z80 out of reset\n"); */
239234      }
240235      return;
241
242      break;
243236   }
244237}
245238
src/mame/drivers/thepit.c
r4135r4136
185185ADDRESS_MAP_END
186186
187187static ADDRESS_MAP_START( intrepid_main_map, ADDRESS_SPACE_PROGRAM, 8 )
188   AM_RANGE(0x0000, 0x4fff) AM_ROM
188   AM_RANGE(0x0000, 0x7fff) AM_ROM
189189   AM_RANGE(0x8000, 0x87ff) AM_RAM
190190   AM_RANGE(0x8c00, 0x8fff) AM_READWRITE(thepit_colorram_r, thepit_colorram_w) /* mirror for intrepi2 */
191191   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(thepit_videoram_w) AM_BASE(&thepit_videoram)
src/mame/drivers/trvmadns.c
r4135r4136
143143static WRITE8_HANDLER( trvmadns_gfxram_w )
144144{
145145   trvmadns_gfxram[offset] = data;
146   decodechar(space->machine->gfx[0], offset/16, trvmadns_gfxram);
147
148   tilemap_mark_all_tiles_dirty(bg_tilemap);
146   gfx_element_mark_dirty(space->machine->gfx[0], offset/16);
149147}
150148
151149#ifdef UNUSED_FUNCTION
r4135r4136
268266   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
269267
270268   tilemap_set_transparent_pen(bg_tilemap,1);
269
270   gfx_element_set_source(machine->gfx[0], trvmadns_gfxram);
271271}
272272
273273static VIDEO_UPDATE( trvmadns )
src/mame/drivers/bingoc.c
r4135r4136
3535
3636#define SOUND_TEST 0
3737
38VIDEO_START(bingoc)
38static VIDEO_START(bingoc)
3939{
4040
4141}
4242
43VIDEO_UPDATE(bingoc)
43static VIDEO_UPDATE(bingoc)
4444{
4545   return 0;
4646}
src/mame/drivers/ajax.c
r4135r4136
242242   MDRV_QUANTUM_TIME(HZ(600))
243243
244244   MDRV_MACHINE_RESET(ajax)
245    MDRV_MACHINE_START(ajax)
245246
246247   /* video hardware */
247248   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS)
r4135r4136
436437
437438
438439
439GAME( 1987, ajax,    0,    ajax, ajax, ajax, ROT90, "Konami", "Ajax", 0 )
440GAME( 1987, typhoon, ajax, ajax, ajax, ajax, ROT90, "Konami", "Typhoon", 0 )
441GAME( 1987, ajaxj,   ajax, ajax, ajax, ajax, ROT90, "Konami", "Ajax (Japan)", 0 )
440GAME( 1987, ajax,    0,    ajax, ajax, ajax, ROT90, "Konami", "Ajax", GAME_SUPPORTS_SAVE )
441GAME( 1987, typhoon, ajax, ajax, ajax, ajax, ROT90, "Konami", "Typhoon", GAME_SUPPORTS_SAVE )
442GAME( 1987, ajaxj,   ajax, ajax, ajax, ajax, ROT90, "Konami", "Ajax (Japan)", GAME_SUPPORTS_SAVE )
src/osd/winui/treeview.c
r4135r4136
951951
952952void CreateSoundFolders(int parent_index)
953953{
954   int i,jj;
955   int nGames = driver_list_get_count(drivers);
956   int nFolder = numFolders;
957   LPTREEFOLDER lpFolder = treeFolders[parent_index];
958   LPTREEFOLDER map[SOUND_COUNT];
959
960   sndintrf_init(NULL);
961
962   // no games in top level folder
963   SetAllBits(lpFolder->m_lpGameBits,FALSE);
964
965   for (i = 1 ; i < SOUND_COUNT ; i++)
966   {
967      LPTREEFOLDER lpTemp;
968      // Init to NULL here in case it doesn't get assigned below.     
969      map[i] = NULL;
970      // empty fields get filled in with SOUND_DUMMY, so check for this and
971      // don't add it
972      if (strcmp(sndtype_get_name(SOUND_DUMMY), sndtype_get_name(i)) == 0)
973         continue;
974
975      lpTemp = NewFolder(sndtype_get_name(i), next_folder_id, parent_index, IDI_SOUND,
976                      GetFolderFlags(numFolders));
977      ExtraFolderData[next_folder_id] = malloc(sizeof(EXFOLDERDATA) );
978      memset(ExtraFolderData[next_folder_id], 0, sizeof(EXFOLDERDATA));
979
980      ExtraFolderData[next_folder_id]->m_nFolderId = next_folder_id;
981      ExtraFolderData[next_folder_id]->m_nIconId = IDI_SOUND;
982      ExtraFolderData[next_folder_id]->m_nParent = lpFolder->m_nFolderId;
983      ExtraFolderData[next_folder_id]->m_nSubIconId = -1;
984      strcpy( ExtraFolderData[next_folder_id]->m_szTitle, sndtype_get_name(i) );
985      ExtraFolderData[next_folder_id++]->m_dwFlags = 0;
986      AddFolder(lpTemp);
987      map[i] = treeFolders[nFolder++];
988   }
989
990   for (jj = 0; jj < nGames; jj++)
991   {
992      int n;
993      machine_config *config;
994
995      config = machine_config_alloc(drivers[jj]->machine_config);
996      for (n = 0; n < MAX_SOUND ; n++) {
997         if (config->sound[n].type != SOUND_DUMMY)
998//         {
999//            if (map[config->sound[n].type] != NULL) {
1000               // sound type #'s are one-based, though that doesn't affect us here
1001               AddGame(map[config->sound[n].type],jj);
1002//            }
1003//         }
1004      }
1005      machine_config_free(config);
1006   }
1007
954   CreateDeviceFolders(parent_index, DEVICE_CLASS_SOUND_CHIP, IDI_SOUND);
1008955}
1009956
1010957void CreateDeficiencyFolders(int parent_index)
src/osd/winui/properties.c
r4135r4136
137137#include "winmain.h"
138138#include "strconv.h"
139139#include "winutf8.h"
140#include "sound/2413intf.h"
141#include "sound/3812intf.h"
140142
141143typedef HANDLE HTHEME;
142144
r4135r4136
651653   {
652654      if (config->sound[chipnum].type != SOUND_DUMMY)
653655      {
654         int clock,sound_type,count;
656         int clock,count;
657         sound_type sound_type_;
655658
656         sound_type = config->sound[chipnum].type;
659         sound_type_ = config->sound[chipnum].type;
657660         clock = config->sound[chipnum].clock;
658661
659662         count = 1;
r4135r4136
661664
662665         /* Matching chips at the same clock are aggregated */
663666         while (chipnum < ARRAY_LENGTH(config->sound)
664            && config->sound[chipnum].type == sound_type
667            && config->sound[chipnum].type == sound_type_
665668            && config->sound[chipnum].clock == clock)
666669         {
667670            count++;
r4135r4136
673676            sprintf(&buf[strlen(buf)],"%dx",count);
674677         }
675678
676         sprintf(&buf[strlen(buf)],"%s",sndtype_get_name(sound_type));
679         sprintf(&buf[strlen(buf)],"%s",sndtype_get_name(sound_type_));
677680
678681         if (clock)
679682         {
src/emu/debug/debugcpu.c
r4135r4136
17351735
17361736UINT64 debug_read_opcode(const address_space *space, offs_t address, int size, int arg)
17371737{
1738   UINT64 result = ~(UINT64)0 & (~(UINT64)0 >> (64 - 8*size)), result2;
17381739   cpu_debug_data *info = cpu_get_debug_data(space->cpu);
1739   offs_t lowbits_mask;
1740   const void *ptr;
17411740
17421741   /* keep in logical range */
17431742   address &= space->logbytemask;
r4135r4136
17651764
17661765   /* translate to physical first */
17671766   if (!debug_cpu_translate(space, TRANSLATE_FETCH_DEBUG, &address))
1768      return ~(UINT64)0 & (~(UINT64)0 >> (64 - 8*size));
1767      return result;
17691768
17701769   /* keep in physical range */
17711770   address &= space->bytemask;
r4135r4136
18221821         break;
18231822   }
18241823
1825   /* get pointer to data */
1826   /* note that we query aligned to the bus width, and then add back the low bits */
1827   lowbits_mask = space->dbits / 8 - 1;
1828   if (!arg)
1829      ptr = memory_decrypted_read_ptr(space, address & ~lowbits_mask);
1830   else
1831      ptr = memory_raw_read_ptr(space, address & ~lowbits_mask);
1832   if (ptr == NULL)
1833      return ~(UINT64)0 & (~(UINT64)0 >> (64 - 8*size));
1834   ptr = (UINT8 *)ptr + (address & lowbits_mask);
1835
1836   /* return based on the size */
1824   /* switch off the size and handle unaligned accesses */
18371825   switch (size)
18381826   {
1839      case 1: return *(UINT8 *) ptr;
1840      case 2:   return *(UINT16 *)ptr;
1841      case 4:   return *(UINT32 *)ptr;
1842      case 8:   return *(UINT64 *)ptr;
1827      case 1:
1828         result = (arg) ? memory_raw_read_byte(space, address) : memory_decrypted_read_byte(space, address);
1829         break;
1830
1831      case 2:
1832         result = (arg) ? memory_raw_read_word(space, address & ~1) : memory_decrypted_read_word(space, address & ~1);
1833         if ((address & 1) != 0)
1834         {
1835            result2 = (arg) ? memory_raw_read_word(space, (address & ~1) + 2) : memory_decrypted_read_word(space, (address & ~1) + 2);
1836            if (space->endianness == ENDIANNESS_LITTLE)
1837               result = (result >> (8 * (address & 1))) | (result2 << (16 - 8 * (address & 1)));
1838            else
1839               result = (result << (8 * (address & 1))) | (result2 >> (16 - 8 * (address & 1)));
1840            result &= 0xffff;
1841         }
1842         break;
1843
1844      case 4:
1845         result = (arg) ? memory_raw_read_dword(space, address & ~3) : memory_decrypted_read_dword(space, address & ~3);
1846         if ((address & 3) != 0)
1847         {
1848            result2 = (arg) ? memory_raw_read_dword(space, (address & ~3) + 4) : memory_decrypted_read_dword(space, (address & ~3) + 4);
1849            if (space->endianness == ENDIANNESS_LITTLE)
1850               result = (result >> (8 * (address & 3))) | (result2 << (32 - 8 * (address & 3)));
1851            else
1852               result = (result << (8 * (address & 3))) | (result2 >> (32 - 8 * (address & 3)));
1853            result &= 0xffffffff;
1854         }
1855         break;
1856
1857      case 8:
1858         result = (arg) ? memory_raw_read_qword(space, address & ~7) : memory_decrypted_read_qword(space, address & ~7);
1859         if ((address & 7) != 0)
1860         {
1861            result2 = (arg) ? memory_raw_read_qword(space, (address & ~7) + 8) : memory_decrypted_read_qword(space, (address & ~7) + 8);
1862            if (space->endianness == ENDIANNESS_LITTLE)
1863               result = (result >> (8 * (address & 7))) | (result2 << (64 - 8 * (address & 7)));
1864            else
1865               result = (result << (8 * (address & 7))) | (result2 >> (64 - 8 * (address & 7)));
1866         }
1867         break;
18431868   }
1844
1845   return 0;   /* appease compiler */
1869   return result;
18461870}
18471871
18481872
src/emu/cpu/h83002/h8_8.c
r4135r4136
7373   return h8_disasm(buffer, pc, oprom, opram, 0xffff);
7474}
7575
76void h8_300_InterruptRequest(h83xx_state *h8, UINT8 source)
76static void h8_300_InterruptRequest(h83xx_state *h8, UINT8 source)
7777{
7878   if(source>31)
7979   {
src/emu/cpu/tms34010/34010ops.h
r4135r4136
1414
1515#include "cpuintrf.h"
1616
17#ifndef INLINE
18#define INLINE static inline
19#endif
20
2117/* Size of the memory buffer allocated for the shiftr register */
2218#define SHIFTREG_SIZE         (8 * 512 * sizeof(UINT16))
2319
src/emu/cpu/m37710/m37710.c
r4135r4136
404404   {
405405      case 2: // p0
406406         return memory_read_byte_8le(cpustate->io, M37710_PORT0);
407         break;
408407      case 3: // p1
409408         return memory_read_byte_8le(cpustate->io, M37710_PORT1);
410         break;
411409      case 6: // p2
412410         return memory_read_byte_8le(cpustate->io, M37710_PORT2);
413         break;
414411      case 7: // p3
415412         return memory_read_byte_8le(cpustate->io, M37710_PORT3);
416         break;
417413      case 0xa: // p4
418414         return memory_read_byte_8le(cpustate->io, M37710_PORT4);
419         break;
420415      case 0xb: // p5
421416         return memory_read_byte_8le(cpustate->io, M37710_PORT5);
422         break;
423417      case 0xe: // p6
424418         return memory_read_byte_8le(cpustate->io, M37710_PORT6);
425         break;
426419      case 0xf: // p7
427420         return memory_read_byte_8le(cpustate->io, M37710_PORT7);
428         break;
429421      case 0x12: // p8
430422         return memory_read_byte_8le(cpustate->io, M37710_PORT8);
431         break;
432423
433424      case 0x20:
434425         return memory_read_byte_8le(cpustate->io, M37710_ADC0_L);
435         break;
436426      case 0x21:
437427         return memory_read_byte_8le(cpustate->io, M37710_ADC0_H);
438         break;
439428      case 0x22:
440429         return memory_read_byte_8le(cpustate->io, M37710_ADC1_L);
441         break;
442430      case 0x23:
443431         return memory_read_byte_8le(cpustate->io, M37710_ADC1_H);
444         break;
445432      case 0x24:
446433         return memory_read_byte_8le(cpustate->io, M37710_ADC2_L);
447         break;
448434      case 0x25:
449435         return memory_read_byte_8le(cpustate->io, M37710_ADC2_H);
450         break;
451436      case 0x26:
452437         return memory_read_byte_8le(cpustate->io, M37710_ADC3_L);
453         break;
454438      case 0x27:
455439         return memory_read_byte_8le(cpustate->io, M37710_ADC3_H);
456         break;
457440      case 0x28:
458441         return memory_read_byte_8le(cpustate->io, M37710_ADC4_L);
459         break;
460442      case 0x29:
461443         return memory_read_byte_8le(cpustate->io, M37710_ADC4_H);
462         break;
463444      case 0x2a:
464445         return memory_read_byte_8le(cpustate->io, M37710_ADC5_L);
465         break;
466446      case 0x2b:
467447         return memory_read_byte_8le(cpustate->io, M37710_ADC5_H);
468         break;
469448      case 0x2c:
470449         return memory_read_byte_8le(cpustate->io, M37710_ADC6_L);
471         break;
472450      case 0x2d:
473451         return memory_read_byte_8le(cpustate->io, M37710_ADC6_H);
474         break;
475452      case 0x2e:
476453         return memory_read_byte_8le(cpustate->io, M37710_ADC7_L);
477         break;
478454      case 0x2f:
479455         return memory_read_byte_8le(cpustate->io, M37710_ADC7_H);
480         break;
481456      case 0x35:
482457         return 0xff;   // UART control
483         break;
484458
485459      case 0x70:   // A/D IRQ control
486460         return cpustate->m37710_regs[offset] | 8;
487         break;
488461   }
489462
490463   return cpustate->m37710_regs[offset];
r4135r4136
499472      case 2: // p0
500473         memory_write_byte_8le(cpustate->io, M37710_PORT0, data);
501474         return;
502         break;
503475      case 3: // p1
504476         memory_write_byte_8le(cpustate->io, M37710_PORT1, data);
505477         return;
506         break;
507478      case 6: // p2
508479         memory_write_byte_8le(cpustate->io, M37710_PORT2, data);
509480         return;
510         break;
511481      case 7: // p3
512482         memory_write_byte_8le(cpustate->io, M37710_PORT3, data);
513483         return;
514         break;
515484      case 0xa: // p4
516485         memory_write_byte_8le(cpustate->io, M37710_PORT4, data);
517486         return;
518         break;
519487      case 0xb: // p5
520488         memory_write_byte_8le(cpustate->io, M37710_PORT5, data);
521489         return;
522         break;
523490      case 0xe: // p6
524491         memory_write_byte_8le(cpustate->io, M37710_PORT6, data);
525492         return;
526         break;
527493      case 0xf: // p7
528494         memory_write_byte_8le(cpustate->io, M37710_PORT7, data);
529495         return;
530         break;
531496      case 0x12: // p8
532497         memory_write_byte_8le(cpustate->io, M37710_PORT8, data);
533498         return;
534         break;
535499
536500      case 0x40:   // count start
537501         for (i = 0; i < 8; i++)
r4135r4136
546510         cpustate->m37710_regs[offset] = data;
547511
548512         return;
549         break;
550513
551514      case 0x60:        // watchdog reset
552515         return;
553         break;
554516   }
555517
556518   cpustate->m37710_regs[offset] = data;
r4135r4136
841803}
842804
843805/* Exit and clean up */
844CPU_EXIT( m37710 )
806static CPU_EXIT( m37710 )
845807{
846808   /* nothing to do yet */
847809}
r4135r4136
888850   FTABLE_SET_REG(cpustate, regnum, value);
889851}
890852
891/* Load a CPU state */
892void m37710_state_load(void *file)
893{
894}
895
896/* Save the current CPU state */
897void m37710_state_save(void *file)
898{
899}
900
901853/* Set an interrupt line */
902854static void m37710_set_irq_line(m37710i_cpu_struct *cpustate, int line, int state)
903855{
src/emu/cpu/m37710/m7700ds.c
r4135r4136
1616
1717#define ADDRESS_24BIT(A) ((A)&0xffffff)
1818
19#ifndef INLINE
20#define INLINE static
21#endif
22
2319typedef struct
2420{
2521   unsigned char name;
src/emu/cpu/m37710/m37710op.h
r4135r4136
28622862                  cpustate->m37710_regs[m37710_irq_levels[line]] |= 8;
28632863               }
28642864               return;
2865               break;
28662865            case ASSERT_LINE:
28672866            case PULSE_LINE:
28682867            case HOLD_LINE:
src/emu/cpu/m37710/m37710cm.h
r4135r4136
2121/* ================================= MAME ================================= */
2222/* ======================================================================== */
2323
24/* Clean up after the emulation core - Not used in this core - */
25CPU_EXIT( m37710 );
26
27/* Save the current CPU state to disk */
28void m37710_state_save(void *file);
29
30/* Load a CPU state from disk */
31void m37710_state_load(void *file);
32
3324#undef M37710_CALL_DEBUGGER
3425
3526#define M37710_CALL_DEBUGGER(x)       debugger_instruction_hook(cpustate->device, x)
r4135r4136
4637/* ================================ GENERAL =============================== */
4738/* ======================================================================== */
4839
49/* Fallback on static if we don't have inline */
50#ifndef INLINE
51#define INLINE static
52#endif
53
5440/* This should be set to the default size of your processor (min 16 bit) */
5541#undef uint
5642#define uint unsigned int
src/emu/cpu/cpu.mak
r4135r4136
300300
301301
302302#-------------------------------------------------
303# National Semiconductor COP4xx
303# National Semiconductor COP400 family
304304#-------------------------------------------------
305305
306CPUDEFS += -DHAS_COP401=$(if $(filter COP401,$(CPUS)),1,0)
307CPUDEFS += -DHAS_COP410=$(if $(filter COP410,$(CPUS)),1,0)
308CPUDEFS += -DHAS_COP411=$(if $(filter COP411,$(CPUS)),1,0)
309CPUDEFS += -DHAS_COP402=$(if $(filter COP402,$(CPUS)),1,0)
310CPUDEFS += -DHAS_COP420=$(if $(filter COP420,$(CPUS)),1,0)
311CPUDEFS += -DHAS_COP421=$(if $(filter COP421,$(CPUS)),1,0)
312CPUDEFS += -DHAS_COP422=$(if $(filter COP421,$(CPUS)),1,0)
313CPUDEFS += -DHAS_COP404=$(if $(filter COP404,$(CPUS)),1,0)
314CPUDEFS += -DHAS_COP424=$(if $(filter COP424,$(CPUS)),1,0)
315CPUDEFS += -DHAS_COP425=$(if $(filter COP425,$(CPUS)),1,0)
316CPUDEFS += -DHAS_COP426=$(if $(filter COP426,$(CPUS)),1,0)
317CPUDEFS += -DHAS_COP444=$(if $(filter COP444,$(CPUS)),1,0)
318CPUDEFS += -DHAS_COP445=$(if $(filter COP445,$(CPUS)),1,0)
306CPUDEFS += -DHAS_COP400=$(if $(filter COP400,$(CPUS)),1,0)
319307
320ifneq ($(filter COP401 COP410 COP411,$(CPUS)),)
308ifneq ($(filter COP400,$(CPUS)),)
321309OBJDIRS += $(CPUOBJ)/cop400
322CPUOBJS += $(CPUOBJ)/cop400/cop410.o
310CPUOBJS += $(CPUOBJ)/cop400/cop400.o
323311DBGOBJS += $(CPUOBJ)/cop400/cop410ds.o
324endif
325
326ifneq ($(filter COP402 COP420 COP421 COP422,$(CPUS)),)
327OBJDIRS += $(CPUOBJ)/cop400
328CPUOBJS += $(CPUOBJ)/cop400/cop420.o
329312DBGOBJS += $(CPUOBJ)/cop400/cop420ds.o
330endif
331
332ifneq ($(filter COP404 COP424 COP425 COP426 COP444 COP445,$(CPUS)),)
333OBJDIRS += $(CPUOBJ)/cop400
334CPUOBJS += $(CPUOBJ)/cop400/cop440.o
335313DBGOBJS += $(CPUOBJ)/cop400/cop440ds.o
336314endif
337315
338$(CPUOBJ)/cop400/cop410.o:   $(CPUSRC)/cop400/cop410.c \
316$(CPUOBJ)/cop400/cop400.o:   $(CPUSRC)/cop400/cop400.c \
339317                     $(CPUSRC)/cop400/cop400.h \
340                     $(CPUSRC)/cop400/410ops.c
318                     $(CPUSRC)/cop400/cop400op.c
341319
342$(CPUOBJ)/cop400/cop420.o:   $(CPUSRC)/cop400/cop420.c \
343                     $(CPUSRC)/cop400/cop400.h \
344                     $(CPUSRC)/cop400/410ops.c \
345                     $(CPUSRC)/cop400/420ops.c
346320
347$(CPUOBJ)/cop400/cop440.o:   $(CPUSRC)/cop400/cop440.c \
348                     $(CPUSRC)/cop400/cop400.h \
349                     $(CPUSRC)/cop400/410ops.c \
350                     $(CPUSRC)/cop400/420ops.c \
351                     $(CPUSRC)/cop400/440ops.c
352321
353
354322#-------------------------------------------------
355323# CP1610
356324#-------------------------------------------------
r4135r4136
776744ifneq ($(filter I860,$(CPUS)),)
777745OBJDIRS += $(CPUOBJ)/i860
778746CPUOBJS += $(CPUOBJ)/i860/i860.o
779DBGOBJS += $(CPUOBJ)/i860/i860dasm.o
747DBGOBJS += $(CPUOBJ)/i860/i860dis.o
780748endif
781749
782$(CPUOBJ)/i860/i860.o:   $(CPUSRC)/i860/i860.c \
783                  $(CPUSRC)/i860/i860.h
750$(CPUOBJ)/i860/i860.o:  $(CPUSRC)/i860/i860.c \
751                                               $(CPUSRC)/i860/i860.h \
752                                               $(CPUSRC)/i860/i860dec.c
784753
785
786754#-------------------------------------------------
787755# Intel i960
788756#-------------------------------------------------
src/emu/cpu/v60/am1.c
r4135r4136
10581058   case 0:
10591059      cpustate->amout = OpRead8(cpustate->program, cpustate->modadd + 1);
10601060      return 2;
1061      break;
10621061
10631062   case 1:
10641063      cpustate->amout = OpRead16(cpustate->program, cpustate->modadd + 1);
10651064      return 3;
1066      break;
10671065
10681066   case 2:
10691067      cpustate->amout = OpRead32(cpustate->program, cpustate->modadd + 1);
10701068      return 5;
1071      break;
10721069   }
10731070
10741071   // It should not be here!  Written to avoid warning
src/emu/cpu/dsp56k/dsp56mem.c
r4135r4136
721721      // Interrupt Control Register (ICR)
722722      case 0x00:
723723         return ICR;
724         break;
725724
726725      // Command Vector Register (CVR)
727726      case 0x01:
728727         return CVR;
729         break;
730728
731729      // Interrupt status register (ISR)
732730      case 0x02:
733731         return ISR;
734         break;
735732
736733      // Interrupt vector register (IVR)
737734      case 0x03:
738735         return IVR;
739         break;
740736
741737      // Read zeroes
742738      case 0x04:
743739         return 0x00;
744         break;
745740
746741      // Reserved
747742      case 0x05:
src/emu/cpu/dsp56k/dsp56ops.c
r4135r4136
43454345
43464346   switch(q)
43474347   {
4348      case 0x0: /* No permanent changes */ ; return (*rX)+(*nX); break;
4349      case 0x1: (*rX)--;                  return (*rX);      break;   // This one is special - it's a *PRE-decrement*!
4348      case 0x0: /* No permanent changes */ ; return (*rX)+(*nX);
4349      case 0x1: (*rX)--;                  return (*rX);   // This one is special - it's a *PRE-decrement*!
43504350   }
43514351
43524352   /* Should not get here */
src/emu/cpu/dsp56k/dsp56dsm.c
r4135r4136
26592659{
26602660   switch(BBB)
26612661   {
2662      case 0x4: return BBB_UPPER ; break;
2663      case 0x2: return BBB_MIDDLE; break;
2664      case 0x1: return BBB_LOWER ; break;
2662      case 0x4: return BBB_UPPER;
2663      case 0x2: return BBB_MIDDLE;
2664      case 0x1: return BBB_LOWER;
26652665   }
26662666
26672667   return BBB_LOWER;                          /* Not really safe... */
src/emu/cpu/spc700/spc700.h
r4135r4136
1212/* ============================= Configuration ============================ */
1313/* ======================================================================== */
1414
15#ifndef INLINE
16#define INLINE static
17#endif
18
1915#undef uint
2016#define uint unsigned int
2117
src/emu/cpu/spc700/spc700ds.c
r4135r4136
1919#include "spc700ds.h"
2020
2121
22#ifndef INLINE
23#define INLINE static
24#endif
2522
26
2723typedef struct
2824{
2925   unsigned char name;
src/emu/cpu/spc700/spc700.c
r4135r4136
101101/* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */
102102/* ======================================================================== */
103103
104/* Fallback on static if we don't have inline */
105#ifndef INLINE
106#define INLINE static
107#endif
108
109104/* This should be set to the default size of your processor (min 16 bit) */
110105#undef uint
111106#define uint unsigned int
r4135r4136
259254
260255
261256/* ======================================================================== */
262/* ============================= INTERFACE API ============================ */
263/* ======================================================================== */
264
265/* This is the interface, not the implementation.  Please call the  */
266/* implementation APIs below.                                       */
267
268
269CPU_INIT( spc700 );
270
271/* Pulse the RESET pin on the CPU */
272CPU_RESET( spc700 );
273
274/* Set the RESET line on the CPU */
275void spc700_set_reset_line(spc700i_cpu *cpustate, int state, void* param);
276
277/* Clean up after the emulation core - Not used in this core - */
278CPU_EXIT( spc700 );
279
280/* Get the current Program Counter */
281unsigned spc700_get_pc(spc700i_cpu *cpustate);
282
283/* Set the current Program Counter */
284void spc700_set_pc(spc700i_cpu *cpustate,unsigned val);
285
286/* Get the current Stack Pointer */
287unsigned spc700_get_sp(spc700i_cpu *cpustate);
288
289/* Set the current Stack Pointer */
290void spc700_set_sp(spc700i_cpu *cpustate,unsigned val);
291
292/* Get a register from the core */
293unsigned spc700_get_reg(spc700i_cpu *cpustate,int regnum);
294
295/* Set a register in the core */
296void spc700_set_reg(spc700i_cpu *cpustate,int regnum, unsigned val);
297
298/* Note about NMI:
299 *   NMI is a one-shot trigger.  In order to trigger NMI again, you must
300 *   clear NMI and then assert it again.
301 */
302void spc700_set_nmi_line(spc700i_cpu *cpustate,int state);
303
304/* Assert or clear the IRQ pin */
305void spc700_set_irq_line(spc700i_cpu *cpustate,int line, int state);
306
307/* Set the callback that will be called when an interrupt is serviced */
308void spc700_set_irq_callback(spc700i_cpu *cpustate,cpu_irq_callback callback);
309
310/* Get a formatted string representing a register and its contents */
311const char *spc700_info(spc700i_cpu *cpustate,void *context, int regnum);
312
313
314/* Pulse the SO (Set Overflow) pin on the CPU */
315void spc700_pulse_so(spc700i_cpu *cpustate);
316
317
318/* ======================================================================== */
319257/* ============================ UTILITY MACROS ============================ */
320258/* ======================================================================== */
321259
r4135r4136
12991237/* ================================= API ================================== */
13001238/* ======================================================================== */
13011239
1302CPU_INIT( spc700 )
1240static CPU_INIT( spc700 )
13031241{
13041242   spc700i_cpu *cpustate = device->token;
13051243
r4135r4136
13091247}
13101248
13111249
1312CPU_RESET( spc700 )
1250static CPU_RESET( spc700 )
13131251{
13141252   spc700i_cpu *cpustate = device->token;
13151253
r4135r4136
13301268}
13311269
13321270/* Exit and clean up */
1333CPU_EXIT( spc700 )
1271static CPU_EXIT( spc700 )
13341272{
13351273   /* nothing to do yet */
13361274}
13371275
13381276
1339/* Get the current Program Counter */
1340unsigned spc700_get_pc(spc700i_cpu *cpustate)
1341{
1342   return REG_PC;
1343}
1344
1345/* Set the Program Counter */
1346void spc700_set_pc(spc700i_cpu *cpustate,unsigned val)
1347{
1348   JUMP(cpustate, val);
1349}
1350
1351/* Get the current Stack Pointer */
1352unsigned spc700_get_sp(spc700i_cpu *cpustate)
1353{
1354   return REG_S + STACK_PAGE;
1355}
1356
1357/* Set the Stack Pointer */
1358void spc700_set_sp(spc700i_cpu *cpustate,unsigned val)
1359{
1360   REG_S = MAKE_UINT_8(val);
1361}
1362
13631277/* Assert or clear the NMI line of the CPU */
1364void spc700_set_nmi_line(spc700i_cpu *cpustate,int state)
1278static void spc700_set_nmi_line(spc700i_cpu *cpustate,int state)
13651279{
13661280#if !SPC700_OPTIMIZE_SNES
13671281   if(state == CLEAR_LINE)
r4135r4136
13781292}
13791293
13801294/* Assert or clear the IRQ line of the CPU */
1381void spc700_set_irq_line(spc700i_cpu *cpustate,int line, int state)
1295static void spc700_set_irq_line(spc700i_cpu *cpustate,int line, int state)
13821296{
13831297#if !SPC700_OPTIMIZE_SNES
13841298   LINE_IRQ = (state != CLEAR_LINE) ? IRQ_SET : IRQ_CLEAR;
r4135r4136
13861300#endif /* SPC700_OPTIMIZE_SNES */
13871301}
13881302
1389/* Set the callback that is called when servicing an interrupt */
1390void spc700_set_irq_callback(spc700i_cpu *cpustate,cpu_irq_callback callback)
1391{
1392   INT_ACK = callback;
1393}
1394
13951303#include "spc700ds.h"
13961304
13971305//int dump_flag = 0;
13981306
13991307/* Execute instructions for <clocks> cycles */
1400CPU_EXECUTE( spc700 )
1308static CPU_EXECUTE( spc700 )
14011309{
14021310   spc700i_cpu *cpustate = device->token;
14031311
src/emu/cpu/hd6309/6309ops.c
r4135r4136
945945         case  2: srcValue = RM(Y++); break;
946946         case  3: srcValue = RM(U++); break;
947947         case  4: srcValue = RM(S++); break;
948         default: IIError(m68_state); return; break;      /* reg PC thru F */
948         default: IIError(m68_state); return;      /* reg PC thru F */
949949      }
950950
951951      switch(tb&15) {
r4135r4136
954954         case  2: WM(Y++, srcValue); break;
955955         case  3: WM(U++, srcValue); break;
956956         case  4: WM(S++, srcValue); break;
957         default: IIError(m68_state); return; break;      /* reg PC thru F */
957         default: IIError(m68_state); return;      /* reg PC thru F */
958958      }
959959
960960      PCD = PCD - 3;
r4135r4136
979979         case  2: srcValue = RM(Y--); break;
980980         case  3: srcValue = RM(U--); break;
981981         case  4: srcValue = RM(S--); break;
982         default: IIError(m68_state); return; break;      /* reg PC thru F */
982         default: IIError(m68_state); return;      /* reg PC thru F */
983983      }
984984
985985      switch(tb&15) {
r4135r4136
988988         case  2: WM(Y--, srcValue); break;
989989         case  3: WM(U--, srcValue); break;
990990         case  4: WM(S--, srcValue); break;
991         default: IIError(m68_state); return; break;      /* reg PC thru F */
991         default: IIError(m68_state); return;      /* reg PC thru F */
992992      }
993993
994994      PCD = PCD - 3;
r4135r4136
10131013         case  2: srcValue = RM(Y++); break;
10141014         case  3: srcValue = RM(U++); break;
10151015         case  4: srcValue = RM(S++); break;
1016         default: IIError(m68_state); return; break;      /* reg PC thru F */
1016         default: IIError(m68_state); return;      /* reg PC thru F */
10171017      }
10181018
10191019      switch(tb&15) {
r4135r4136
10221022         case  2: WM(Y, srcValue); break;
10231023         case  3: WM(U, srcValue); break;
10241024         case  4: WM(S, srcValue); break;
1025         default: IIError(m68_state); return; break;      /* reg PC thru F */
1025         default: IIError(m68_state); return;      /* reg PC thru F */
10261026      }
10271027
10281028      PCD = PCD - 3;
r4135r4136
10471047         case  2: srcValue = RM(Y); break;
10481048         case  3: srcValue = RM(U); break;
10491049         case  4: srcValue = RM(S); break;
1050         default: IIError(m68_state); return; break;      /* reg PC thru F */
1050         default: IIError(m68_state); return;      /* reg PC thru F */
10511051      }
10521052
10531053      switch(tb&15) {
r4135r4136
10561056         case  2: WM(Y++, srcValue); break;
10571057         case  3: WM(U++, srcValue); break;
10581058         case  4: WM(S++, srcValue); break;
1059         default: IIError(m68_state); return; break;      /* reg PC thru F */
1059         default: IIError(m68_state); return;      /* reg PC thru F */
10601060      }
10611061
10621062      PCD = PCD - 3;
src/emu/cpu/se3208/se3208.c
r4135r4136
14641464         break;
14651465      case 0x1:
14661466         return LERI;
1467         break;
14681467      case 0x2:
14691468         {
14701469            switch(EXTRACT(Opcode,11,13))
src/emu/cpu/se3208/se3208dis.c
r4135r4136
11711171         break;
11721172      case 0x1:
11731173         return LERI;
1174         break;
11751174      case 0x2:
11761175         {
11771176            switch(EXTRACT(Opcode,11,13))
src/emu/cpu/i860/i860dec.c
r0r4136
1/***************************************************************************
2
3    i860dec.c
4
5    Execution engine for the Intel i860 emulator.
6
7    Copyright (C) 1995-present Jason Eckhardt (jle@rice.edu)
8    Released for general non-commercial use under the MAME license
9    with the additional requirement that you are free to use and
10    redistribute this code in modified or unmodified form, provided
11    you list me in the credits.
12    Visit http://mamedev.org for licensing and usage restrictions.
13
14***************************************************************************/
15
16/*
17 * References:
18 *  `i860 Microprocessor Programmer's Reference Manual', Intel, 1990.
19 *
20 * This code was originally written by Jason Eckhardt as part of an
21 * emulator for some i860-based Unix workstations (early 1990's) such
22 * as the Stardent Vistra 800 series and the OkiStation/i860 7300 series.
23 * The code you are reading now is the i860 CPU portion only, which has
24 * been adapted to (and simplified for) MAME.
25 * MAME-specific notes:
26 * - i860XR emulation only (i860XP unnecessary for MAME).
27 * - No emulation of data and instruction caches (unnecessary for MAME version).
28 * - No emulation of DIM mode or CS8 mode (unnecessary for MAME version).
29 * - No BL/IL/locked sequences (unnecessary for MAME).
30 * - Emulate only the i860's LSB-first mode (BE = 0).
31 * Generic notes:
32 * - There is some amount of code duplication (e.g., see the
33 *   various insn_* routines for the branches and FP routines) that
34 *   could be eliminated.
35 * - The host's floating point types are used to emulate the i860's
36 *   floating point.  Should probably be made machine independent by
37 *   using an IEEE FP emulation library.  On the other hand, most machines
38 *   today also use IEEE FP.
39 *
40 */
41#include "i860.h"
42#include <math.h>
43
44
45#ifdef LSB_FIRST
46#undef HOST_MSB
47#else
48#define HOST_MSB
49#endif
50
51
52#undef  TRACE_RDWR_MEM
53#undef  TRACE_ADDR_TRANSLATION
54#undef  TRACE_PAGE_FAULT
55#define TRACE_UNDEFINED_I860
56#undef  TRACE_EXT_INT
57#define TRACE_UNALIGNED_MEM
58
59
60
61#define i860s i860_state_t
62
63
64/* Prototypes.  */
65static void decode_exec (i860s *, UINT32, UINT32);
66static UINT32 get_address_translation (i860s *, UINT32, int, int);
67static UINT32 readmemi_emu (i860s *cpustate, UINT32, int);
68
69//static void debugger (i860s *cpustate);
70//static void disasm (i860s *cpustate, UINT32, int);
71//static void dump_state (i860s *cpustate);
72
73
74
75
76/* Defines for pending_trap.  */
77enum {
78   TRAP_NORMAL        = 0x01,
79   TRAP_IN_DELAY_SLOT = 0x02,
80   TRAP_WAS_EXTERNAL  = 0x04
81};
82
83
84
85
86/* Get/set general register value -- watch for r0 on writes.  */
87#define get_iregval(gr)       (cpustate->iregs[(gr)])
88#define set_iregval(gr, val)  (cpustate->iregs[(gr)] = ((gr) == 0 ? 0 : (val)))
89
90INLINE float get_fregval_s (i860s *cpustate, int fr)
91{
92   float f;
93   UINT32 x;
94   UINT8 *tp;
95   fr = 31 - fr;
96   tp = (UINT8 *)(&cpustate->frg[fr * 4]);
97   x = ((UINT32)tp[0] << 24) | ((UINT32)tp[1] << 16) |
98      ((UINT32)tp[2] << 8) | ((UINT32)tp[3]);
99   f = *(float *)(&x);
100   return f;
101}
102
103INLINE double get_fregval_d (i860s *cpustate, int fr)
104{
105   double d;
106   UINT64 x;
107   UINT8 *tp;
108   fr = 31 - (fr + 1);
109   tp = (UINT8 *)(&cpustate->frg[fr * 4]);
110   x = ((UINT64)tp[0] << 56) | ((UINT64)tp[1] << 48) |
111      ((UINT64)tp[2] << 40) | ((UINT64)tp[3] << 32) |
112      ((UINT64)tp[4] << 24) | ((UINT64)tp[5] << 16) |
113      ((UINT64)tp[6] << 8) | ((UINT64)tp[7]);
114   d = *(double *)(&x);
115   return d;
116}
117
118INLINE void set_fregval_s (i860s *cpustate, int fr, float s)
119{
120   UINT8 *f = (UINT8 *)&s;
121   UINT8 *tp;
122   int newfr = 31 - fr;
123   float jj = s;
124   tp = (UINT8 *)(&cpustate->frg[newfr * 4]);
125
126   f = (UINT8 *)(&jj);
127   if (fr == 0 || fr == 1)
128   {
129      tp[0] = 0; tp[1] = 0; tp[2] = 0; tp[3] = 0;
130   }
131   else
132   {
133#ifndef HOST_MSB
134      tp[0] = f[3]; tp[1] = f[2]; tp[2] = f[1]; tp[3] = f[0];
135#else
136      tp[0] = f[0]; tp[1] = f[1]; tp[2] = f[2]; tp[3] = f[3];
137#endif
138   }
139}
140
141INLINE void set_fregval_d (i860s *cpustate, int fr, double d)
142{
143   UINT8 *f = (UINT8 *)&d;
144   UINT8 *tp;
145   int newfr = 31 - (fr + 1);
146   double jj = d;
147   tp = (UINT8 *)(&cpustate->frg[newfr * 4]);
148
149   f = (UINT8 *)(&jj);
150
151   if (fr == 0)
152   {
153      tp[0] = 0; tp[1] = 0; tp[2] = 0; tp[3] = 0;
154      tp[4] = 0; tp[5] = 0; tp[6] = 0; tp[7] = 0;
155   }
156   else
157   {
158#ifndef HOST_MSB
159      tp[0] = f[7]; tp[1] = f[6]; tp[2] = f[5]; tp[3] = f[4];
160      tp[4] = f[3]; tp[5] = f[2]; tp[6] = f[1]; tp[7] = f[0];
161#else
162      tp[0] = f[0]; tp[1] = f[1]; tp[2] = f[2]; tp[3] = f[3];
163      tp[4] = f[4]; tp[5] = f[5]; tp[6] = f[6]; tp[7] = f[7];
164#endif
165   }
166}
167
168
169/* Macros for accessing register fields in instruction word.  */
170#define get_isrc1(bits) (((bits) >> 11) & 0x1f)
171#define get_isrc2(bits) (((bits) >> 21) & 0x1f)
172#define get_idest(bits) (((bits) >> 16) & 0x1f)
173#define get_fsrc1(bits) (((bits) >> 11) & 0x1f)
174#define get_fsrc2(bits) (((bits) >> 21) & 0x1f)
175#define get_fdest(bits) (((bits) >> 16) & 0x1f)
176#define get_creg(bits) (((bits) >> 21) & 0x7)
177
178/* Macros for accessing immediate fields.  */
179/* 16-bit immediate.  */
180#define get_imm16(insn) ((insn) & 0xffff)
181
182/* Control register numbers.  */
183enum {
184    CR_FIR     = 0,
185    CR_PSR     = 1,
186    CR_DIRBASE = 2,
187    CR_DB      = 3,
188    CR_FSR     = 4,
189    CR_EPSR    = 5
190};
191
192/* A mask for all the trap bits of the PSR (FT, DAT, IAT, IN, IT, or
193   bits [12..8]).  */
194#define PSR_ALL_TRAP_BITS_MASK 0x00001f00
195
196/* A mask for PSR bits which can only be changed from supervisor level.  */
197#define PSR_SUPERVISOR_ONLY_MASK 0x0000fff3
198
199
200/* PSR: BR flag (PSR[0]):  set/get.  */
201#define GET_PSR_BR()  ((cpustate->cregs[CR_PSR] >> 0) & 1)
202#define SET_PSR_BR(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 0)) | (((val) & 1) << 0))
203
204/* PSR: BW flag (PSR[1]):  set/get.  */
205#define GET_PSR_BW()  ((cpustate->cregs[CR_PSR] >> 1) & 1)
206#define SET_PSR_BW(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 1)) | (((val) & 1) << 1))
207
208/* PSR: Shift count (PSR[21..17]):  set/get.  */
209#define GET_PSR_SC()  ((cpustate->cregs[CR_PSR] >> 17) & 0x1f)
210#define SET_PSR_SC(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~0x003e0000) | (((val) & 0x1f) << 17))
211
212/* PSR: CC flag (PSR[2]):  set/get.  */
213#define GET_PSR_CC()  ((cpustate->cregs[CR_PSR] >> 2) & 1)
214#define SET_PSR_CC(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 2)) | (((val) & 1) << 2))
215
216/* PSR: IT flag (PSR[8]):  set/get.  */
217#define GET_PSR_IT()  ((cpustate->cregs[CR_PSR] >> 8) & 1)
218#define SET_PSR_IT(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 8)) | (((val) & 1) << 8))
219
220/* PSR: IN flag (PSR[9]):  set/get.  */
221#define GET_PSR_IN()  ((cpustate->cregs[CR_PSR] >> 9) & 1)
222#define SET_PSR_IN(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 9)) | (((val) & 1) << 9))
223
224/* PSR: IAT flag (PSR[10]):  set/get.  */
225#define GET_PSR_IAT()  ((cpustate->cregs[CR_PSR] >> 10) & 1)
226#define SET_PSR_IAT(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 10)) | (((val) & 1) << 10))
227
228/* PSR: DAT flag (PSR[11]):  set/get.  */
229#define GET_PSR_DAT()  ((cpustate->cregs[CR_PSR] >> 11) & 1)
230#define SET_PSR_DAT(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 11)) | (((val) & 1) << 11))
231
232/* PSR: FT flag (PSR[12]):  set/get.  */
233#define GET_PSR_FT()  ((cpustate->cregs[CR_PSR] >> 12) & 1)
234#define SET_PSR_FT(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 12)) | (((val) & 1) << 12))
235
236/* PSR: DS flag (PSR[13]):  set/get.  */
237#define GET_PSR_DS()  ((cpustate->cregs[CR_PSR] >> 13) & 1)
238#define SET_PSR_DS(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 13)) | (((val) & 1) << 13))
239
240/* PSR: DIM flag (PSR[14]):  set/get.  */
241#define GET_PSR_DIM()  ((cpustate->cregs[CR_PSR] >> 14) & 1)
242#define SET_PSR_DIM(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 14)) | (((val) & 1) << 14))
243
244/* PSR: LCC (PSR[3]):  set/get.  */
245#define GET_PSR_LCC()  ((cpustate->cregs[CR_PSR] >> 3) & 1)
246#define SET_PSR_LCC(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 3)) | (((val) & 1) << 3))
247
248/* PSR: IM (PSR[4]):  set/get.  */
249#define GET_PSR_IM()  ((cpustate->cregs[CR_PSR] >> 4) & 1)
250#define SET_PSR_IM(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 4)) | (((val) & 1) << 4))
251
252/* PSR: PIM (PSR[5]):  set/get.  */
253#define GET_PSR_PIM()  ((cpustate->cregs[CR_PSR] >> 5) & 1)
254#define SET_PSR_PIM(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 5)) | (((val) & 1) << 5))
255
256/* PSR: U (PSR[6]):  set/get.  */
257#define GET_PSR_U()  ((cpustate->cregs[CR_PSR] >> 6) & 1)
258#define SET_PSR_U(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 6)) | (((val) & 1) << 6))
259
260/* PSR: PU (PSR[7]):  set/get.  */
261#define GET_PSR_PU()  ((cpustate->cregs[CR_PSR] >> 7) & 1)
262#define SET_PSR_PU(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~(1 << 7)) | (((val) & 1) << 7))
263
264/* PSR: Pixel size (PSR[23..22]):  set/get.  */
265#define GET_PSR_PS()  ((cpustate->cregs[CR_PSR] >> 22) & 0x3)
266#define SET_PSR_PS(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~0x00c00000) | (((val) & 0x3) << 22))
267
268/* PSR: Pixel mask (PSR[31..24]):  set/get.  */
269#define GET_PSR_PM()  ((cpustate->cregs[CR_PSR] >> 24) & 0xff)
270#define SET_PSR_PM(val)  (cpustate->cregs[CR_PSR] = (cpustate->cregs[CR_PSR] & ~0xff000000) | (((val) & 0xff) << 24))
271
272/* EPSR: WP bit (EPSR[14]):  set/get.  */
273#define GET_EPSR_WP()  ((cpustate->cregs[CR_EPSR] >> 14) & 1)
274#define SET_EPSR_WP(val)  (cpustate->cregs[CR_EPSR] = (cpustate->cregs[CR_EPSR] & ~(1 << 14)) | (((val) & 1) << 14))
275
276/* EPSR: INT bit (EPSR[17]):  set/get.  */
277#define GET_EPSR_INT()  ((cpustate->cregs[CR_EPSR] >> 17) & 1)
278#define SET_EPSR_INT(val)  (cpustate->cregs[CR_EPSR] = (cpustate->cregs[CR_EPSR] & ~(1 << 17)) | (((val) & 1) << 17))
279
280
281/* EPSR: OF flag (EPSR[24]):  set/get.  */
282#define GET_EPSR_OF()  ((cpustate->cregs[CR_EPSR] >> 24) & 1)
283#define SET_EPSR_OF(val)  (cpustate->cregs[CR_EPSR] = (cpustate->cregs[CR_EPSR] & ~(1 << 24)) | (((val) & 1) << 24))
284
285/* EPSR: BE flag (EPSR[23]):  set/get.  */
286#define GET_EPSR_BE()  ((cpustate->cregs[CR_EPSR] >> 23) & 1)
287#define SET_EPSR_BE(val)  (cpustate->cregs[CR_EPSR] = (cpustate->cregs[CR_EPSR] & ~(1 << 23)) | (((val) & 1) << 23))
288
289/* DIRBASE: ATE bit (DIRBASE[0]):  get.  */
290#define GET_DIRBASE_ATE()  (cpustate->cregs[CR_DIRBASE] & 1)
291
292/* DIRBASE: CS8 bit (DIRBASE[7]):  get.  */
293#define GET_DIRBASE_CS8()  ((cpustate->cregs[CR_DIRBASE] >> 7) & 1)
294
295/* FSR: FTE bit (FSR[5]):  set/get.  */
296#define GET_FSR_FTE()  ((cpustate->cregs[CR_FSR] >> 5) & 1)
297#define SET_FSR_FTE(val)  (cpustate->cregs[CR_FSR] = (cpustate->cregs[CR_FSR] & ~(1 << 5)) | (((val) & 1) << 5))
298
299/* FSR: SE bit (FSR[8]):  set/get.  */
300#define GET_FSR_SE()  ((cpustate->cregs[CR_FSR] >> 8) & 1)
301#define SET_FSR_SE(val)  (cpustate->cregs[CR_FSR] = (cpustate->cregs[CR_FSR] & ~(1 << 8)) | (((val) & 1) << 8))
302
303
304/*
305static int has_delay_slot(UINT32 insn)
306{
307    int opc = (insn >> 26) & 0x3f;
308    if (opc == 0x10 || opc == 0x1a || opc == 0x1b || opc == 0x1d ||
309        opc == 0x1f || opc == 0x2d || (opc == 0x13 && (insn & 3) == 2))
310    return 1;
311    return 0;
312}
313*/
314
315/* This is the external interface for asserting/deasserting pins on
316   the i860.  */
317void i860_set_pin (i860s *cpustate, int pin, int val)
318{
319   if (pin == DEC_PIN_BUS_HOLD)
320      cpustate->pin_bus_hold = val;
321   else if (pin == DEC_PIN_RESET)
322      cpustate->pin_reset = val;
323   else
324      assert (0);
325}
326
327
328/* This is the external interface for indicating an external interrupt
329   to the i860.  */
330void i860_gen_interrupt (i860s *cpustate)
331{
332   /* If interrupts are enabled, then set PSR.IN and prepare for trap.
333       Otherwise, the external interrupt is ignored.  We also set
334       bit EPSR.INT (which tracks the INT pin).  */
335   if (GET_PSR_IM ())
336   {
337      SET_PSR_IN (1);
338      SET_EPSR_INT (1);
339      cpustate->pending_trap = TRAP_WAS_EXTERNAL;
340   }
341
342#ifdef TRACE_EXT_INT
343   fprintf (stderr, "i860_gen_interrupt: External interrupt received ");
344   if (GET_PSR_IM ())
345      fprintf (stderr, "[PSR.IN set, preparing to trap]\n");
346   else
347      fprintf   (stderr, "[ignored (interrupts disabled)]\n");
348#endif
349}
350
351
352/* Fetch instructions from instruction cache.
353   Note: The instruction cache is not implemented for MAME version,
354   this just fetches and returns 1 instruction from memory.  */
355static UINT32 ifetch (i860s *cpustate, UINT32 pc)
356{
357   UINT32 phys_pc = 0;
358   UINT32 w1 = 0;
359
360   /* If virtual mode, get translation.  */
361   if (GET_DIRBASE_ATE ())
362   {
363      phys_pc = get_address_translation (cpustate, pc, 0   /* is_dataref */, 0   /* is_write */);
364      cpustate->exiting_ifetch = 0;
365      if (cpustate->pending_trap && (GET_PSR_DAT () || GET_PSR_IAT ()))
366      {
367         cpustate->exiting_ifetch = 1;
368         return 0xffeeffee;
369      }
370   }
371   else
372      phys_pc   = pc;
373
374   /* Since i860 instructions are always stored LSB first (regardless of
375       the BE bit), we need to adjust the instruction below on MSB hosts.  */
376   w1 = memory_read_dword_64le(cpustate->program, phys_pc);
377#ifdef HOST_MSB
378   BYTE_REV32 (w1);
379#endif /* HOST_MSB.  */
380   return w1;
381}
382
383
384/* Given a virtual address, perform the i860 address translation and
385   return the corresponding physical address.
386     vaddr:      virtual address
387     is_dataref: 1 = load/store, 0 = instruction fetch.
388     is_write:   1 = writing to vaddr, 0 = reading from vaddr
389   The last two arguments are only used to determine what types
390   of traps should be taken.
391
392   Page tables must always be in memory (not cached).  So the routine
393   here only accesses memory.  */
394static UINT32 get_address_translation (i860s *cpustate, UINT32 vaddr, int is_dataref, int is_write)
395{
396   UINT32 vdir = (vaddr >> 22) & 0x3ff;
397   UINT32 vpage = (vaddr >> 12) & 0x3ff;
398   UINT32 voffset = vaddr & 0xfff;
399   UINT32 dtb = (cpustate->cregs[CR_DIRBASE]) & 0xfffff000;
400   UINT32 pg_dir_entry_a = 0;
401   UINT32 pg_dir_entry = 0;
402   UINT32 pg_tbl_entry_a = 0;
403   UINT32 pg_tbl_entry = 0;
404   UINT32 pfa1 = 0;
405   UINT32 pfa2 = 0;
406   UINT32 ret = 0;
407   UINT32 ttpde = 0;
408   UINT32 ttpte = 0;
409
410   assert (GET_DIRBASE_ATE ());
411
412   /* Get page directory entry at DTB:DIR:00.  */
413   pg_dir_entry_a = dtb | (vdir << 2);
414   pg_dir_entry = memory_read_dword_64le(cpustate->program, pg_dir_entry_a);
415#ifdef HOST_MSB
416   BYTE_REV32 (pg_dir_entry);
417#endif
418
419   /* Check for non-present PDE.  */
420   if (!(pg_dir_entry & 1))
421   {
422      /* PDE is not present, generate DAT or IAT.  */
423      if (is_dataref)
424         SET_PSR_DAT (1);
425      else
426         SET_PSR_IAT   (1);
427      cpustate->pending_trap = 1;
428
429      /* Dummy return.  */
430      return 0;
431   }
432
433   /* PDE Check for write protection violations.  */
434   if (is_write && is_dataref
435      && !(pg_dir_entry & 2)               /* W = 0.  */
436      && (GET_PSR_U () || GET_EPSR_WP ()))   /* PSR_U = 1 or EPSR_WP = 1.  */
437   {
438      SET_PSR_DAT (1);
439      cpustate->pending_trap = 1;
440      /* Dummy return.  */
441      return 0;
442   }
443
444   /* PDE Check for user-mode access to supervisor pages.  */
445   if (GET_PSR_U ()
446      && !(pg_dir_entry & 4))               /* U = 0.  */
447   {
448      if (is_dataref)
449         SET_PSR_DAT (1);
450      else
451         SET_PSR_IAT   (1);
452      cpustate->pending_trap = 1;
453      /* Dummy return.  */
454      return 0;
455   }
456
457   /* FIXME: How exactly to handle A check/update?.  */
458
459   /* Get page table entry at PFA1:PAGE:00.  */
460   pfa1 = pg_dir_entry & 0xfffff000;
461   pg_tbl_entry_a = pfa1 | (vpage << 2);
462   pg_tbl_entry = memory_read_dword_64le(cpustate->program, pg_tbl_entry_a);
463#ifdef HOST_MSB
464   BYTE_REV32 (pg_tbl_entry);
465#endif
466
467   /* Check for non-present PTE.  */
468   if (!(pg_tbl_entry & 1))
469   {
470      /* PTE is not present, generate DAT or IAT.  */
471      if (is_dataref)
472         SET_PSR_DAT (1);
473      else
474         SET_PSR_IAT   (1);
475      cpustate->pending_trap = 1;
476
477      /* Dummy return.  */
478      return 0;
479   }
480
481   /* PTE Check for write protection violations.  */
482   if (is_write && is_dataref
483      && !(pg_tbl_entry & 2)               /* W = 0.  */
484      && (GET_PSR_U () || GET_EPSR_WP ()))   /* PSR_U = 1 or EPSR_WP = 1.  */
485   {
486      SET_PSR_DAT (1);
487      cpustate->pending_trap = 1;
488      /* Dummy return.  */
489      return 0;
490   }
491
492   /* PTE Check for user-mode access to supervisor pages.  */
493   if (GET_PSR_U ()
494      && !(pg_tbl_entry & 4))               /* U = 0.  */
495   {
496      if (is_dataref)
497         SET_PSR_DAT (1);
498      else
499         SET_PSR_IAT   (1);
500      cpustate->pending_trap = 1;
501      /* Dummy return.  */
502      return 0;
503   }
504
505   /* Update A bit and check D bit.  */
506   ttpde = pg_dir_entry | 0x20;
507   ttpte = pg_tbl_entry | 0x20;
508#ifdef HOST_MSB
509   BYTE_REV32 (ttpde);
510   BYTE_REV32 (ttpte);
511#endif
512   memory_write_dword_64le(cpustate->program, pg_dir_entry_a, ttpde);
513   memory_write_dword_64le(cpustate->program, pg_tbl_entry_a, ttpte);
514
515   if (is_write && is_dataref && (pg_tbl_entry & 0x40) == 0)
516   {
517      /* fprintf(stderr, "DAT trap on write without dirty bit v0x%08x/p0x%08x\n",
518           vaddr, (pg_tbl_entry & ~0xfff)|voffset); */
519      SET_PSR_DAT (1);
520      cpustate->pending_trap = 1;
521      /* Dummy return.  */
522      return 0;
523   }
524
525   pfa2 = (pg_tbl_entry & 0xfffff000);
526   ret = pfa2 | voffset;
527
528#ifdef TRACE_ADDR_TRANSLATION
529   fprintf (stderr, "get_address_translation: virt(0x%08x) -> phys(0x%08x)\n",
530          vaddr, ret);
531#endif
532
533   return ret;
534}
535
536
537/* Read memory emulation.
538     addr = address to read.
539     size = size of read in bytes.  */
540static UINT32 readmemi_emu (i860s *cpustate, UINT32 addr, int size)
541{
542#ifdef TRACE_RDWR_MEM
543   fprintf (stderr, "readmemi_emu: (ATE=%d) addr = 0x%08x, size = %d\n",
544          GET_DIRBASE_ATE (), addr, size);
545#endif
546
547   /* If virtual mode, do translation.  */
548   if (GET_DIRBASE_ATE ())
549   {
550      UINT32 phys = get_address_translation (cpustate, addr, 1 /* is_dataref */, 0 /* is_write */);
551      if (cpustate->pending_trap && (GET_PSR_IAT () || GET_PSR_DAT ()))
552      {
553#ifdef TRACE_PAGE_FAULT
554         fprintf (stderr, "0x%08x: ## Page fault (readmemi_emu).\n",
555                cpustate->pc);
556#endif
557         cpustate->exiting_readmem = 1;
558         return 0;
559      }
560      addr = phys;
561   }
562
563   /* First check for match to db register (before read).  */
564   if (((addr & ~(size - 1)) == cpustate->cregs[CR_DB]) && GET_PSR_BR ())
565   {
566      SET_PSR_DAT (1);
567      cpustate->pending_trap = 1;
568      return 0;
569   }
570
571   /* Now do the actual read.  */
572   if (size == 1)
573   {
574      UINT32 ret = memory_read_byte_64le(cpustate->program, addr);
575      return ret & 0xff;
576   }
577   else if (size == 2)
578   {
579      UINT32 ret = memory_read_word_64le(cpustate->program, addr);
580#ifdef HOST_MSB
581      BYTE_REV16 (ret);
582#endif
583      return ret & 0xffff;
584   }
585   else if (size == 4)
586   {
587      UINT32 ret = memory_read_dword_64le(cpustate->program, addr);
588#ifdef HOST_MSB
589      BYTE_REV32 (ret);
590#endif
591      return ret;
592   }
593   else
594      assert (0);
595
596   return 0;
597}
598
599
600/* Write memory emulation.
601     addr = address to write.
602     size = size of write in bytes.
603     data = data to write.  */
604static void writememi_emu (i860s *cpustate, UINT32 addr, int size, UINT32 data)
605{
606#ifdef TRACE_RDWR_MEM
607   fprintf (stderr, "writememi_emu: (ATE=%d) addr = 0x%08x, size = %d, data = 0x%08x\n",
608          GET_DIRBASE_ATE (), addr, size, data);
609#endif
610
611   /* If virtual mode, do translation.  */
612   if (GET_DIRBASE_ATE ())
613   {
614      UINT32 phys = get_address_translation (cpustate, addr, 1 /* is_dataref */, 1 /* is_write */);
615      if (cpustate->pending_trap && (GET_PSR_IAT () || GET_PSR_DAT ()))
616      {
617#ifdef TRACE_PAGE_FAULT
618         fprintf (stderr, "0x%08x: ## Page fault (writememi_emu).\n",
619                cpustate->pc);
620#endif
621         cpustate->exiting_readmem = 2;
622         return;
623      }
624      addr = phys;
625   }
626
627   /* First check for match to db register (before write).  */
628   if (((addr & ~(size - 1)) == cpustate->cregs[CR_DB]) && GET_PSR_BW ())
629   {
630      SET_PSR_DAT (1);
631      cpustate->pending_trap = 1;
632      return;
633   }
634
635   /* Now do the actual write.  */
636   if (size == 1)
637      memory_write_byte_64le(cpustate->program, addr, data);
638   else if (size == 2)
639   {
640#ifdef HOST_MSB
641      BYTE_REV16 (data);
642#endif
643      memory_write_word_64le(cpustate->program, addr, data);
644   }
645   else if (size == 4)
646   {
647#ifdef HOST_MSB
648      BYTE_REV32 (data);
649#endif
650      memory_write_dword_64le(cpustate->program, addr, data);
651   }
652   else
653      assert (0);
654}
655
656
657/* Floating-point read mem routine.
658     addr = address to read.
659     size = size of read in bytes.
660     dest = memory to put read data.  */
661static void fp_readmem_emu (i860s *cpustate, UINT32 addr, int size, UINT8 *dest)
662{
663#ifdef TRACE_RDWR_MEM
664   fprintf (stderr, "fp_readmem_emu: (ATE=%d) addr = 0x%08x, size = %d\n",
665          GET_DIRBASE_ATE (), addr, size);
666#endif
667
668   assert (size == 4 || size == 8 || size == 16);
669
670   /* If virtual mode, do translation.  */
671   if (GET_DIRBASE_ATE ())
672   {
673      UINT32 phys = get_address_translation (cpustate, addr, 1 /* is_dataref */, 0 /* is_write */);
674      if (cpustate->pending_trap && (GET_PSR_IAT () || GET_PSR_DAT ()))
675      {
676#ifdef TRACE_PAGE_FAULT
677         fprintf (stderr, "0x%08x: ## Page fault (fp_readmem_emu).\n",
678                cpustate->pc);
679#endif
680         cpustate->exiting_readmem = 3;
681         return;
682      }
683      addr = phys;
684   }
685
686   /* First check for match to db register (before read).  */
687   if (((addr & ~(size - 1)) == cpustate->cregs[CR_DB]) && GET_PSR_BR ())
688   {
689      SET_PSR_DAT (1);
690      cpustate->pending_trap = 1;
691      return;
692   }
693
694   if (size == 4)
695   {
696      dest[0] = memory_read_byte_64le(cpustate->program, addr+3);
697      dest[1] = memory_read_byte_64le(cpustate->program, addr+2);
698      dest[2] = memory_read_byte_64le(cpustate->program, addr+1);
699      dest[3] = memory_read_byte_64le(cpustate->program, addr+0);
700   }
701   else if (size == 8)
702   {
703      dest[0] = memory_read_byte_64le(cpustate->program, addr+7);
704      dest[1] = memory_read_byte_64le(cpustate->program, addr+6);
705      dest[2] = memory_read_byte_64le(cpustate->program, addr+5);
706      dest[3] = memory_read_byte_64le(cpustate->program, addr+4);
707      dest[4] = memory_read_byte_64le(cpustate->program, addr+3);
708      dest[5] = memory_read_byte_64le(cpustate->program, addr+2);
709      dest[6] = memory_read_byte_64le(cpustate->program, addr+1);
710      dest[7] = memory_read_byte_64le(cpustate->program, addr+0);
711   }
712   else if (size == 16)
713   {
714      int i;
715      for (i = 0; i < 16; i++)
716      {
717         dest[i] = memory_read_byte_64le(cpustate->program, addr+15-i);
718      }
719   }
720}
721
722
723/* Floating-point write mem routine.
724     addr = address to read.
725     size = size of read in bytes.
726     data = pointer to the data.
727     wmask = bit mask of bytes to write (only for pst.d).  */
728static void fp_writemem_emu (i860s *cpustate, UINT32 addr, int size, UINT8 *data, UINT32 wmask)
729{
730#ifdef TRACE_RDWR_MEM
731   fprintf (stderr, "fp_writemem_emu: (ATE=%d) addr = 0x%08x, size = %d\n",
732          GET_DIRBASE_ATE (), addr, size);
733#endif
734
735   assert (size == 4 || size == 8 || size == 16);
736
737   /* If virtual mode, do translation.  */
738   if (GET_DIRBASE_ATE ())
739   {
740      UINT32 phys = get_address_translation (cpustate, addr, 1 /* is_dataref */, 1 /* is_write */);
741      if (cpustate->pending_trap && GET_PSR_DAT ())
742      {
743#ifdef TRACE_PAGE_FAULT
744         fprintf (stderr, "0x%08x: ## Page fault (fp_writememi_emu).\n",
745                cpustate->pc);
746#endif
747         cpustate->exiting_readmem = 4;
748         return;
749      }
750      addr = phys;
751   }
752
753   /* First check for match to db register (before read).  */
754   if (((addr & ~(size - 1)) == cpustate->cregs[CR_DB]) && GET_PSR_BW ())
755   {
756      SET_PSR_DAT (1);
757      cpustate->pending_trap = 1;
758      return;
759   }
760
761   if (size == 4)
762   {
763#if 1
764      memory_write_byte_64le(cpustate->program, addr+3, data[0]);
765      memory_write_byte_64le(cpustate->program, addr+2, data[1]);
766      memory_write_byte_64le(cpustate->program, addr+1, data[2]);
767      memory_write_byte_64le(cpustate->program, addr+0, data[3]);
768#else
769      UINT32 ddd = (data[3]) | (data[2] << 8) | (data[1] << 16) |(data[0] << 24);
770      memory_write_dword_64le(cpustate->program, addr+0, ddd);
771#endif
772   }
773   else if (size == 8)
774   {
775      /* Special: watch for wmask != 0xff, which means we're doing pst.d.  */
776      if (wmask == 0xff)
777      {
778         memory_write_byte_64le(cpustate->program, addr+7, data[0]);
779         memory_write_byte_64le(cpustate->program, addr+6, data[1]);
780         memory_write_byte_64le(cpustate->program, addr+5, data[2]);
781         memory_write_byte_64le(cpustate->program, addr+4, data[3]);
782         memory_write_byte_64le(cpustate->program, addr+3, data[4]);
783         memory_write_byte_64le(cpustate->program, addr+2, data[5]);
784         memory_write_byte_64le(cpustate->program, addr+1, data[6]);
785         memory_write_byte_64le(cpustate->program, addr+0, data[7]);
786      }
787      else
788      {
789         if (wmask & 0x80) memory_write_byte_64le(cpustate->program, addr+7, data[0]);
790         if (wmask & 0x40) memory_write_byte_64le(cpustate->program, addr+6, data[1]);
791         if (wmask & 0x20) memory_write_byte_64le(cpustate->program, addr+5, data[2]);
792         if (wmask & 0x10) memory_write_byte_64le(cpustate->program, addr+4, data[3]);
793         if (wmask & 0x08) memory_write_byte_64le(cpustate->program, addr+3, data[4]);
794         if (wmask & 0x04) memory_write_byte_64le(cpustate->program, addr+2, data[5]);
795         if (wmask & 0x02) memory_write_byte_64le(cpustate->program, addr+1, data[6]);
796         if (wmask & 0x01) memory_write_byte_64le(cpustate->program, addr+0, data[7]);
797      }
798   }
799   else if (size == 16)
800   {
801      int i;
802      for (i = 0; i < 16; i++)
803      {
804         memory_write_byte_64le(cpustate->program, addr+15-i, data[i]);
805      }
806   }
807
808}
809
810
811#if 0
812/* Do a pipeline dump.
813    type: 0 (all), 1 (add), 2 (mul), 3 (load), 4 (graphics).  */
814static void dump_pipe (i860s *cpustate, int type)
815{
816   int i = 0;
817
818   fprintf (stderr, "pipeline state:\n");
819   /* Dump the adder pipeline, if requested.  */
820   if (type == 0 || type == 1)
821   {
822      fprintf (stderr, "  A: ");
823      for (i = 0; i < 3; i++)
824      {
825         if (cpustate->A[i].stat.arp)
826            fprintf (stderr, "[%dd] 0x%016llx ", i + 1,
827                   *(UINT64 *)(&cpustate->A[i].val.d));
828         else
829            fprintf   (stderr, "[%ds] 0x%08x ", i + 1,
830                   *(UINT32 *)(&cpustate->A[i].val.s));
831      }
832      fprintf (stderr, "\n");
833   }
834
835
836   /* Dump the multiplier pipeline, if requested.  */
837   if (type == 0 || type == 2)
838   {
839      fprintf (stderr, "  M: ");
840      for (i = 0; i < 3; i++)
841      {
842         if (cpustate->M[i].stat.mrp)
843            fprintf (stderr, "[%dd] 0x%016llx ", i + 1,
844                   *(UINT64 *)(&cpustate->M[i].val.d));
845         else
846            fprintf   (stderr, "[%ds] 0x%08x ", i + 1,
847                   *(UINT32 *)(&cpustate->M[i].val.s));
848      }
849      fprintf (stderr, "\n");
850   }
851
852   /* Dump the load pipeline, if requested.  */
853   if (type == 0 || type == 3)
854   {
855      fprintf (stderr, "  L: ");
856      for (i = 0; i < 3; i++)
857      {
858         if (cpustate->L[i].stat.lrp)
859            fprintf (stderr, "[%dd] 0x%016llx ", i + 1,
860                   *(UINT64 *)(&cpustate->L[i].val.d));
861         else
862            fprintf   (stderr, "[%ds] 0x%08x ", i + 1,
863                   *(UINT32 *)(&cpustate->L[i].val.s));
864      }
865      fprintf (stderr, "\n");
866   }
867
868   /* Dump the graphics pipeline, if requested.  */
869   if (type == 0 || type == 4)
870   {
871      fprintf (stderr, "  I: ");
872      if (cpustate->G.stat.irp)
873         fprintf (stderr, "[1d] 0x%016llx\n",
874                *(UINT64 *)(&cpustate->G.val.d));
875      else
876         fprintf   (stderr, "[1s] 0x%08x\n",
877                *(UINT32 *)(&cpustate->G.val.s));
878   }
879}
880
881
882/* Do a register/state dump.  */
883static void dump_state (i860s *cpustate)
884{
885   int rn;
886
887   /* GR's first, 4 per line.  */
888   for (rn = 0; rn < 32; rn++)
889   {
890      if ((rn % 4) == 0)
891         fprintf (stderr, "\n");
892      fprintf (stderr, "%%r%-3d: 0x%08x  ", rn, get_iregval (rn));
893   }
894   fprintf (stderr, "\n");
895
896   /* FR's (as 32-bits), 4 per line.  */
897   for (rn = 0; rn < 32; rn++)
898   {
899      float ff = get_fregval_s (cpustate, rn);
900      if ((rn % 4) == 0)
901         fprintf (stderr, "\n");
902      fprintf (stderr, "%%f%-3d: 0x%08x  ", rn, *(UINT32 *)&ff);
903   }
904   fprintf (stderr, "\n");
905
906   fprintf (stderr, " psr: CC = %d, LCC = %d, SC = %d, IM = %d, U = %d\n",
907          GET_PSR_CC (), GET_PSR_LCC (), GET_PSR_SC (), GET_PSR_IM (),
908          GET_PSR_U ());
909   fprintf (stderr, "      IT/FT/IAT/DAT/IN = %d/%d/%d/%d/%d\n",
910          GET_PSR_IT (), GET_PSR_FT (), GET_PSR_IAT (),
911          GET_PSR_DAT (), GET_PSR_IN ());
912   fprintf (stderr, "epsr: INT = %d, OF = %d, BE = %d\n",
913          GET_EPSR_INT (), GET_EPSR_OF (), GET_EPSR_BE ());
914   fprintf (stderr, " fir: 0x%08x  dirbase: 0x%08x  fsr: 0x%08x\n",
915          cpustate->cregs[CR_FIR], cpustate->cregs[CR_DIRBASE],
916          cpustate->cregs[CR_FSR]);
917   fprintf (stderr, "  pc: 0x%08x\n", cpustate->pc);
918}
919#endif
920
921/* Sign extend N-bit number.  */
922INLINE INT32 sign_ext (UINT32 x, int n)
923{
924   INT32 t;
925   t = x >> (n - 1);
926   t = ((-t) << n) | x;
927   return t;
928}
929
930
931static void unrecog_opcode (UINT32 pc, UINT32 insn)
932{
933   fprintf (stderr, "0x%08x: 0x%08x   (unrecognized opcode)\n", pc, insn);
934}
935
936
937/* Execute "ld.c csrc2,idest" instruction.  */
938static void insn_ld_ctrl (i860s *cpustate, UINT32 insn)
939{
940   UINT32 csrc2 = get_creg (insn);
941   UINT32 idest = get_idest (insn);
942
943#ifdef TRACE_UNDEFINED_I860
944   if (csrc2 > 5)
945   {
946      /* Control register not between 0..5.  Undefined i860XR behavior.  */
947      fprintf (stderr, "WARNING: insn_ld_from_ctrl (pc=0x%08x): bad creg in ld.c (ignored)\n", cpustate->pc);
948      return;
949   }
950#endif
951
952   /* If this is a load of the fir, then there are two cases:
953       1. First load of fir after a trap = usual value.
954       2. Not first load of fir after a trap = address of the ld.c insn.  */
955   if (csrc2 == CR_FIR)
956   {
957      if (cpustate->fir_gets_trap_addr)
958         set_iregval (idest, cpustate->cregs[csrc2]);
959      else
960      {
961         cpustate->cregs[csrc2] = cpustate->pc;
962         set_iregval (idest, cpustate->cregs[csrc2]);
963      }
964      cpustate->fir_gets_trap_addr = 0;
965   }
966   else
967      set_iregval   (idest, cpustate->cregs[csrc2]);
968}
969
970
971/* Execute "st.c isrc1,csrc2" instruction.  */
972static void insn_st_ctrl (i860s *cpustate, UINT32 insn)
973{
974   UINT32 csrc2 = get_creg (insn);
975   UINT32 isrc1 = get_isrc1 (insn);
976
977#ifdef TRACE_UNDEFINED_I860
978   if (csrc2 > 5)
979   {
980      /* Control register not between 0..5.  Undefined i860XR behavior.  */
981      fprintf (stderr, "WARNING: insn_st_to_ctrl (pc=0x%08x): bad creg in st.c (ignored)\n", cpustate->pc);
982      return;
983   }
984#endif
985
986   /* Look for ITI bit turned on (but it never actually is written --
987       it always appears to be 0).  */
988   if (csrc2 == CR_DIRBASE && (get_iregval (isrc1) & 0x20))
989   {
990      /* NOTE: The actual icache and TLB flush are unimplemented for
991           the MAME version.  */
992
993      /* Make sure ITI isn't actually written.  */
994      set_iregval (isrc1, (get_iregval (isrc1) & ~0x20));
995   }
996
997   if (csrc2 == CR_DIRBASE && (get_iregval (isrc1) & 1)
998      && GET_DIRBASE_ATE () == 0)
999   {
1000      fprintf (stderr, "0x%08x: ** ATE going high!\n", cpustate->pc);
1001   }
1002
1003   /* Update the register -- unless it is fir which cannot be updated.  */
1004   if (csrc2 == CR_EPSR)
1005   {
1006      UINT32 enew = 0, tmp = 0;
1007      /* Make sure unchangeable EPSR bits stay unchanged (DCS, stepping,
1008           and type).  Also, some bits are only writeable in supervisor
1009           mode.  */
1010      if (GET_PSR_U ())
1011      {
1012         enew = get_iregval (isrc1) & ~(0x003e1fff | 0x00c06000);
1013         tmp = cpustate->cregs[CR_EPSR] & (0x003e1fff | 0x00c06000);
1014      }
1015      else
1016      {
1017         enew = get_iregval (isrc1) & ~0x003e1fff;
1018         tmp = cpustate->cregs[CR_EPSR] & 0x003e1fff;
1019      }
1020      cpustate->cregs[CR_EPSR] = enew | tmp;
1021   }
1022   else if (csrc2 == CR_PSR)
1023   {
1024      /* Some PSR bits are only writeable in supervisor mode.  */
1025      if (GET_PSR_U ())
1026      {
1027         UINT32 enew = get_iregval (isrc1) & ~PSR_SUPERVISOR_ONLY_MASK;
1028         UINT32 tmp = cpustate->cregs[CR_PSR] & PSR_SUPERVISOR_ONLY_MASK;
1029         cpustate->cregs[CR_PSR] = enew | tmp;
1030      }
1031      else
1032         cpustate->cregs[CR_PSR] = get_iregval (isrc1);
1033   }
1034   else if (csrc2 == CR_FSR)
1035   {
1036      /* I believe that only 21..17, 8..5, and 3..0 should be updated.  */
1037      UINT32 enew = get_iregval (isrc1) & 0x003e01ef;
1038      UINT32 tmp = cpustate->cregs[CR_FSR] & ~0x003e01ef;
1039      cpustate->cregs[CR_FSR] = enew | tmp;
1040   }
1041   else if (csrc2 != CR_FIR)
1042      cpustate->cregs[csrc2] = get_iregval (isrc1);
1043}
1044
1045
1046/* Execute "ld.{s,b,l} isrc1(isrc2),idest" or
1047   "ld.{s,b,l} #const(isrc2),idest".  */
1048static void insn_ldx (i860s *cpustate, UINT32 insn)
1049{
1050   UINT32 isrc1 = get_isrc1 (insn);
1051   INT32 immsrc1 = sign_ext (get_imm16 (insn), 16);
1052   UINT32 isrc2 = get_isrc2 (insn);
1053   UINT32 idest = get_idest (insn);
1054   UINT32 eff = 0;
1055   /* Operand size, in bytes.  */
1056   int sizes[4] = { 1, 1, 2, 4};
1057   int size = 0;
1058   int form_disp_reg = 0;
1059
1060   /* Bits 28 and 0 determine the operand size.  */
1061   size = sizes[((insn >> 27) & 2) | (insn & 1)];
1062
1063   /* Bit 26 determines the addressing mode (reg+reg or disp+reg).  */
1064   form_disp_reg = (insn & 0x04000000);
1065
1066   /* Get effective address depending on disp+reg or reg+reg form.  */
1067   if (form_disp_reg)
1068   {
1069      /* Chop off lower bits of displacement.  */
1070      immsrc1 &= ~(size - 1);
1071      eff = (UINT32)(immsrc1 + (INT32)(get_iregval (isrc2)));
1072   }
1073   else
1074      eff   = get_iregval (isrc1) + get_iregval (isrc2);
1075
1076#ifdef TRACE_UNALIGNED_MEM
1077   if (eff & (size - 1))
1078   {
1079      fprintf (stderr, "0x%08x: Unaligned access detected (0x%08x).\n",
1080             cpustate->pc, eff);
1081      SET_PSR_DAT (1);
1082      cpustate->pending_trap = 1;
1083      return;
1084   }
1085#endif
1086
1087   /* The i860 sign-extends 8- or 16-bit integer loads.
1088
1089       Below, the readmemi_emu() needs to happen outside of the
1090       set_iregval macro (otherwise the readmem won't occur if r0
1091       is the target register).  */
1092   if (size < 4)
1093   {
1094      UINT32 readval = sign_ext (readmemi_emu (cpustate, eff, size), size * 8);
1095      /* Do not update register on page fault.  */
1096      if (cpustate->exiting_readmem)
1097      {
1098         return;
1099      }
1100      set_iregval (idest, readval);
1101   }
1102   else
1103   {
1104      UINT32 readval = readmemi_emu (cpustate, eff, size);
1105      /* Do not update register on page fault.  */
1106      if (cpustate->exiting_readmem)
1107      {
1108         return;
1109      }
1110      set_iregval (idest, readval);
1111   }
1112}
1113
1114
1115/* Execute "st.x isrc1ni,#const(isrc2)" instruction (there is no
1116   (reg + reg form).  Store uses the split immediate, not the normal
1117   16-bit immediate as in ld.x.  */
1118static void insn_stx (i860s *cpustate, UINT32 insn)
1119{
1120   INT32 immsrc = sign_ext ((((insn >> 5) & 0xf800) | (insn & 0x07ff)), 16);
1121   UINT32 isrc1 = get_isrc1 (insn);
1122   UINT32 isrc2 = get_isrc2 (insn);
1123   UINT32 eff = 0;
1124   /* Operand size, in bytes.  */
1125   int sizes[4] = { 1, 1, 2, 4};
1126   int size = 0;
1127
1128   /* Bits 28 and 0 determine the operand size.  */
1129   size = sizes[((insn >> 27) & 2) | (insn & 1)];
1130
1131   /* FIXME: Do any necessary traps.  */
1132
1133   /* Get effective address.  Chop off lower bits of displacement.  */
1134   immsrc &= ~(size - 1);
1135   eff = (UINT32)(immsrc + (INT32)get_iregval (isrc2));
1136
1137   /* Write data (value of reg isrc1) to memory at eff.  */
1138   writememi_emu (cpustate, eff, size, get_iregval (isrc1));
1139   if (cpustate->exiting_readmem)
1140      return;
1141}
1142
1143
1144/* Execute "fst.y fdest,isrc1(isrc2)", "fst.y fdest,isrc1(isrc2)++",
1145           "fst.y fdest,#const(isrc2)" or "fst.y fdest,#const(isrc2)++"
1146   instruction.  */
1147static void insn_fsty (i860s *cpustate, UINT32 insn)
1148{
1149   UINT32 isrc1 = get_isrc1 (insn);
1150   INT32 immsrc1 = sign_ext (get_imm16 (insn), 16);
1151   UINT32 isrc2 = get_isrc2 (insn);
1152   UINT32 fdest = get_fdest (insn);
1153   UINT32 eff = 0;
1154   /* Operand size, in bytes.  */
1155   int sizes[4] = { 8, 4, 16, 4};
1156   int size = 0;
1157   int form_disp_reg = 0;
1158   int auto_inc = (insn & 1);
1159
1160   /* Bits 2 and 1 determine the operand size.  */
1161   size = sizes[((insn >> 1) & 3)];
1162
1163   /* Bit 26 determines the addressing mode (reg+reg or disp+reg).  */
1164   form_disp_reg = (insn & 0x04000000);
1165
1166   /* FIXME: Check for undefined behavior, non-even or non-quad
1167       register operands for fst.d and fst.q respectively.  */
1168
1169   /* Get effective address depending on disp+reg or reg+reg form.  */
1170   if (form_disp_reg)
1171   {
1172      /* Chop off lower bits of displacement.  */
1173      immsrc1 &= ~(size - 1);
1174      eff = (UINT32)(immsrc1 + (INT32)(get_iregval (isrc2)));
1175   }
1176   else
1177      eff   = get_iregval (isrc1) + get_iregval (isrc2);
1178
1179#ifdef TRACE_UNALIGNED_MEM
1180   if (eff & (size - 1))
1181   {
1182      fprintf (stderr, "0x%08x: Unaligned access detected (0x%08x).\n",
1183             cpustate->pc, eff);
1184      SET_PSR_DAT (1);
1185      cpustate->pending_trap = 1;
1186      return;
1187   }
1188#endif
1189
1190   /* Do (post) auto-increment.  */
1191   if (auto_inc)
1192   {
1193      set_iregval (isrc2, eff);
1194#ifdef TRACE_UNDEFINED_I860
1195      /* When auto-inc, isrc1 and isrc2 regs can't be the same.  */
1196      if (isrc1 == isrc2)
1197      {
1198         /* Undefined i860XR behavior.  */
1199         fprintf (stderr, "WARNING: insn_fsty (pc=0x%08x): isrc1 = isrc2 in fst with auto-inc (ignored)\n", cpustate->pc);
1200         return;
1201      }
1202#endif
1203   }
1204
1205   /* Write data (value of freg fdest) to memory at eff.  */
1206   if (size == 4)
1207      fp_writemem_emu (cpustate, eff, size, (UINT8 *)(&cpustate->frg[4 * (31 - fdest)]), 0xff);
1208   else if (size == 8)
1209      fp_writemem_emu (cpustate, eff, size, (UINT8 *)(&cpustate->frg[4 * (31 - (fdest + 1))]), 0xff);
1210   else
1211      fp_writemem_emu   (cpustate, eff, size, (UINT8 *)(&cpustate->frg[4 * (31 - (fdest + 3))]), 0xff);
1212
1213}
1214
1215
1216/* Execute "fld.y isrc1(isrc2),fdest", "fld.y isrc1(isrc2)++,idest",
1217           "fld.y #const(isrc2),fdest" or "fld.y #const(isrc2)++,idest".
1218   Where y = {l,d,q}.  Note, there is no pfld.q, though.  */
1219static void insn_fldy (i860s *cpustate, UINT32 insn)
1220{
1221   UINT32 isrc1 = get_isrc1 (insn);
1222   INT32 immsrc1 = sign_ext (get_imm16 (insn), 16);
1223   UINT32 isrc2 = get_isrc2 (insn);
1224   UINT32 fdest = get_fdest (insn);
1225   UINT32 eff = 0;
1226   /* Operand size, in bytes.  */
1227   int sizes[4] = { 8, 4, 16, 4};
1228   int size = 0;
1229   int form_disp_reg = 0;
1230   int auto_inc = (insn & 1);
1231   int piped = (insn & 0x40000000);
1232
1233   /* Bits 2 and 1 determine the operand size.  */
1234   size = sizes[((insn >> 1) & 3)];
1235
1236   /* Bit 26 determines the addressing mode (reg+reg or disp+reg).  */
1237   form_disp_reg = (insn & 0x04000000);
1238
1239   /* There is no pipelined load quad.  */
1240   if (piped && size == 16)
1241   {
1242      unrecog_opcode (cpustate->pc, insn);
1243      return;
1244   }
1245
1246   /* FIXME: Check for undefined behavior, non-even or non-quad
1247       register operands for fld.d and fld.q respectively.  */
1248
1249   /* Get effective address depending on disp+reg or reg+reg form.  */
1250   if (form_disp_reg)
1251   {
1252      /* Chop off lower bits of displacement.  */
1253      immsrc1 &= ~(size - 1);
1254      eff = (UINT32)(immsrc1 + (INT32)(get_iregval (isrc2)));
1255   }
1256   else
1257      eff   = get_iregval (isrc1) + get_iregval (isrc2);
1258
1259   /* Do (post) auto-increment.  */
1260   if (auto_inc)
1261   {
1262      set_iregval (isrc2, eff);
1263#ifdef TRACE_UNDEFINED_I860
1264      /* When auto-inc, isrc1 and isrc2 regs can't be the same.  */
1265      if (isrc1 == isrc2)
1266      {
1267         /* Undefined i860XR behavior.  */
1268         fprintf (stderr, "WARNING: insn_fldy (pc=0x%08x): isrc1 = isrc2 in fst with auto-inc (ignored)\n", cpustate->pc);
1269         return;
1270      }
1271#endif
1272   }
1273
1274#ifdef TRACE_UNALIGNED_MEM
1275   if (eff & (size - 1))
1276   {
1277      fprintf (stderr, "0x%08x: Unaligned access detected (0x%08x).\n",
1278             cpustate->pc, eff);
1279      SET_PSR_DAT (1);
1280      cpustate->pending_trap = 1;
1281      return;
1282   }
1283#endif
1284
1285   /* Update the load pipe if necessary.  */
1286   /* FIXME: Copy result-status bits to fsr from last stage.  */
1287   if (!piped)
1288   {
1289      /* Scalar version writes the current result to fdest.  */
1290      /* Read data at 'eff' into freg 'fdest' (reads to f0 or f1 are
1291           thrown away).  */
1292      if (fdest > 1)
1293      {
1294         if (size == 4)
1295            fp_readmem_emu (cpustate, eff, size, (UINT8 *)&(cpustate->frg[4 * (31 - fdest)]));
1296         else if (size == 8)
1297            fp_readmem_emu (cpustate, eff, size, (UINT8 *)&(cpustate->frg[4 * (31 - (fdest + 1))]));
1298         else if (size == 16)
1299            fp_readmem_emu (cpustate, eff, size, (UINT8 *)&(cpustate->frg[4 * (31 - (fdest + 3))]));
1300      }
1301   }
1302   else
1303   {
1304      /* Read the data into a temp space first.  This way we can test
1305           for any traps before updating the pipeline.  The pipeline must
1306           stay unaffected after a trap so that the instruction can be
1307           properly restarted.  */
1308      UINT8 bebuf[8];
1309      fp_readmem_emu (cpustate, eff, size, bebuf);
1310      if (cpustate->pending_trap && cpustate->exiting_readmem)
1311         goto ab_op;
1312
1313      /* Pipelined version writes fdest with the result from the last
1314           stage of the pipeline, with precision specified by the LRP
1315           bit of the stage's result-status bits.  */
1316#if 1 /* FIXME: WIP on FSR update.  This may not be correct.  */
1317      /* Copy 3rd stage LRP to FSR.  */
1318      if (cpustate->L[1 /* 2 */].stat.lrp)
1319         cpustate->cregs[CR_FSR] |= 0x04000000;
1320      else
1321         cpustate->cregs[CR_FSR] &= ~0x04000000;
1322#endif
1323      if (cpustate->L[2].stat.lrp)  /* 3rd (last) stage.  */
1324         set_fregval_d (cpustate, fdest, cpustate->L[2].val.d);
1325      else
1326         set_fregval_s (cpustate, fdest, cpustate->L[2].val.s);
1327
1328      /* Now advance pipeline and write loaded data to first stage.  */
1329      cpustate->L[2] = cpustate->L[1];
1330      cpustate->L[1] = cpustate->L[0];
1331      if (size == 8)
1332      {
1333         UINT8 *t = (UINT8 *)&(cpustate->L[0].val.d);
1334#ifndef HOST_MSB
1335         t[7] = bebuf[0]; t[6] = bebuf[1]; t[5] = bebuf[2]; t[4] = bebuf[3];
1336         t[3] = bebuf[4]; t[2] = bebuf[5]; t[1] = bebuf[6]; t[0] = bebuf[7];
1337#else
1338         t[0] = bebuf[0]; t[1] = bebuf[1]; t[2] = bebuf[2]; t[3] = bebuf[3];
1339         t[4] = bebuf[4]; t[5] = bebuf[5]; t[6] = bebuf[6]; t[7] = bebuf[7];
1340#endif
1341         cpustate->L[0].stat.lrp = 1;
1342      }
1343      else
1344      {
1345         UINT8 *t = (UINT8 *)&(cpustate->L[0].val.s);
1346#ifndef HOST_MSB
1347         t[3] = bebuf[0]; t[2] = bebuf[1]; t[1] = bebuf[2]; t[0] = bebuf[3];
1348#else
1349         t[0] = bebuf[0]; t[1] = bebuf[1]; t[2] = bebuf[2]; t[3] = bebuf[3];
1350#endif
1351         cpustate->L[0].stat.lrp = 0;
1352      }
1353   }
1354
1355   ab_op:;
1356}
1357
1358
1359/* Execute "pst.d fdest,#const(isrc2)" or "fst.d fdest,#const(isrc2)++"
1360   instruction.  */
1361static void insn_pstd (i860s *cpustate, UINT32 insn)
1362{
1363   INT32 immsrc1 = sign_ext (get_imm16 (insn), 16);
1364   UINT32 isrc2 = get_isrc2 (insn);
1365   UINT32 fdest = get_fdest (insn);
1366   UINT32 eff = 0;
1367   int auto_inc = (insn & 1);
1368   UINT8 *bebuf = 0;
1369   int pm = GET_PSR_PM ();
1370   int i;
1371   UINT32 wmask;
1372   int orig_pm = pm;
1373
1374   /* Get the pixel size, where:
1375       PS: 0 = 8 bits, 1 = 16 bits, 2 = 32-bits.  */
1376   int ps = GET_PSR_PS ();
1377
1378#ifdef TRACE_UNDEFINED_I860
1379   if (!(ps == 0 || ps == 1 || ps == 2))
1380      fprintf (stderr, "insn_pstd: Undefined i860XR behavior, invalid value %d for pixel size.\n", ps);
1381#endif
1382
1383#ifdef TRACE_UNDEFINED_I860
1384   /* Bits 2 and 1 determine the operand size, which must always be
1385       zero (indicating a 64-bit operand).  */
1386   if (insn & 0x6)
1387   {
1388      /* Undefined i860XR behavior.  */
1389      fprintf (stderr, "WARNING: insn_pstd (pc=0x%08x): bad operand size specifier\n", cpustate->pc);
1390   }
1391#endif
1392
1393   /* FIXME: Check for undefined behavior, non-even register operands.  */
1394
1395   /* Get effective address.  Chop off lower bits of displacement.  */
1396   immsrc1 &= ~(8 - 1);
1397   eff = (UINT32)(immsrc1 + (INT32)(get_iregval (isrc2)));
1398
1399#ifdef TRACE_UNALIGNED_MEM
1400   if (eff & (8 - 1))
1401   {
1402      fprintf (stderr, "0x%08x: Unaligned access detected (0x%08x).\n",
1403             cpustate->pc, eff);
1404      SET_PSR_DAT (1);
1405      cpustate->pending_trap = 1;
1406      return;
1407   }
1408#endif
1409
1410   /* Do (post) auto-increment.  */
1411   if (auto_inc)
1412      set_iregval (isrc2, eff);
1413
1414   /* Update the the pixel mask depending on the pixel size.  Shift PM
1415       right by 8/2^ps bits.  */
1416   if (ps == 0)
1417      pm = (pm >> 8) & 0x00;
1418   else if (ps == 1)
1419      pm = (pm >> 4) & 0x0f;
1420   else if (ps == 2)
1421      pm = (pm >> 2) & 0x3f;
1422   SET_PSR_PM (pm);
1423
1424   /* Write data (value of freg fdest) to memory at eff-- but only those
1425       bytes that are enabled by the bits in PSR.PM.  Bit 0 of PM selects
1426       the pixel at the lowest address.  */
1427   wmask = 0;
1428   for (i = 0; i < 8; )
1429   {
1430      if (ps == 0)
1431      {
1432         if (orig_pm & 0x80)
1433            wmask |= 1 << (7-i);
1434         i += 1;
1435      }
1436      else if (ps == 1)
1437      {
1438         if (orig_pm & 0x08)
1439            wmask |= 0x3 << (6-i);
1440         i += 2;
1441      }
1442      else if (ps == 2)
1443      {
1444         if (orig_pm & 0x02)
1445            wmask |= 0xf << (4-i);
1446         i += 4;
1447      }
1448      else
1449      {
1450         wmask = 0xff;
1451         break;
1452      }
1453      orig_pm <<= 1;
1454   }
1455   bebuf = (UINT8 *)(&cpustate->frg[4 * (31 - (fdest + 1))]);
1456   fp_writemem_emu (cpustate, eff, 8, bebuf, wmask);
1457}
1458
1459
1460/* Execute "ixfr isrc1ni,fdest" instruction.  */
1461static void insn_ixfr (i860s *cpustate, UINT32 insn)
1462{
1463   UINT32 isrc1 = get_isrc1 (insn);
1464   UINT32 fdest = get_fdest (insn);
1465   UINT32 iv = 0;
1466
1467   /* This is a bit-pattern transfer, not a conversion.  */
1468   iv = get_iregval (isrc1);
1469   set_fregval_s (cpustate, fdest, *(float *)&iv);
1470}
1471
1472
1473/* Execute "addu isrc1,isrc2,idest".  */
1474static void insn_addu (i860s *cpustate, UINT32 insn)
1475{
1476   UINT32 src1val;
1477   UINT32 isrc2 = get_isrc2 (insn);
1478   UINT32 idest = get_idest (insn);
1479   UINT32 tmp_dest_val = 0;
1480   UINT64 tmp = 0;
1481
1482   src1val = get_iregval (get_isrc1 (insn));
1483
1484   /* We don't update the actual idest register now because below we
1485       need to test the original src1 and src2 if either happens to
1486       be the destination register.  */
1487   tmp_dest_val = src1val + get_iregval (isrc2);
1488
1489   /* Set OF and CC flags.
1490       For unsigned:
1491         OF = bit 31 carry
1492         CC = bit 31 carry.
1493     */
1494   tmp = (UINT64)src1val + (UINT64)(get_iregval (isrc2));
1495   if ((tmp >> 32) & 1)
1496   {
1497      SET_PSR_CC (1);
1498      SET_EPSR_OF (1);
1499   }
1500   else
1501   {
1502      SET_PSR_CC (0);
1503      SET_EPSR_OF (0);
1504   }
1505
1506   /* Now update the destination register.  */
1507   set_iregval (idest, tmp_dest_val);
1508}
1509
1510
1511/* Execute "addu #const,isrc2,idest".  */
1512static void insn_addu_imm (i860s *cpustate, UINT32 insn)
1513{
1514   UINT32 src1val;
1515   UINT32 isrc2 = get_isrc2 (insn);
1516   UINT32 idest = get_idest (insn);
1517   UINT32 tmp_dest_val = 0;
1518   UINT64 tmp = 0;
1519
1520   src1val = sign_ext (get_imm16 (insn), 16);
1521
1522   /* We don't update the actual idest register now because below we
1523       need to test the original src1 and src2 if either happens to
1524       be the destination register.  */
1525   tmp_dest_val = src1val + get_iregval (isrc2);
1526
1527   /* Set OF and CC flags.
1528       For unsigned:
1529         OF = bit 31 carry
1530         CC = bit 31 carry.
1531     */
1532   tmp = (UINT64)src1val + (UINT64)(get_iregval (isrc2));
1533   if ((tmp >> 32) & 1)
1534   {
1535      SET_PSR_CC (1);
1536      SET_EPSR_OF (1);
1537   }
1538   else
1539   {
1540      SET_PSR_CC (0);
1541      SET_EPSR_OF (0);
1542   }
1543
1544   /* Now update the destination register.  */
1545   set_iregval (idest, tmp_dest_val);
1546}
1547
1548
1549/* Execute "adds isrc1,isrc2,idest".  */
1550static void insn_adds (i860s *cpustate, UINT32 insn)
1551{
1552   UINT32 src1val;
1553   UINT32 isrc2 = get_isrc2 (insn);
1554   UINT32 idest = get_idest (insn);
1555   UINT32 tmp_dest_val = 0;
1556   int sa, sb, sres;
1557
1558   src1val = get_iregval (get_isrc1 (insn));
1559
1560   /* We don't update the actual idest register now because below we
1561       need to test the original src1 and src2 if either happens to
1562       be the destination register.  */
1563   tmp_dest_val = src1val + get_iregval (isrc2);
1564
1565   /* Set OF and CC flags.
1566       For signed:
1567         OF = standard signed overflow.
1568         CC set   if isrc2 < -isrc1
1569         CC clear if isrc2 >= -isrc1
1570     */
1571   sa = src1val & 0x80000000;
1572   sb = get_iregval (isrc2) & 0x80000000;
1573   sres = tmp_dest_val & 0x80000000;
1574   if (sa != sb && sa != sres)
1575      SET_EPSR_OF (1);
1576   else
1577      SET_EPSR_OF   (0);
1578
1579   if ((INT32)get_iregval (isrc2) < -(INT32)(src1val))
1580      SET_PSR_CC (1);
1581   else
1582      SET_PSR_CC (0);
1583
1584   /* Now update the destination register.  */
1585   set_iregval (idest, tmp_dest_val);
1586}
1587
1588
1589/* Execute "adds #const,isrc2,idest".  */
1590static void insn_adds_imm (i860s *cpustate, UINT32 insn)
1591{
1592   UINT32 src1val;
1593   UINT32 isrc2 = get_isrc2 (insn);
1594   UINT32 idest = get_idest (insn);
1595   UINT32 tmp_dest_val = 0;
1596   int sa, sb, sres;
1597
1598   src1val = sign_ext (get_imm16 (insn), 16);
1599
1600   /* We don't update the actual idest register now because below we
1601       need to test the original src1 and src2 if either happens to
1602       be the destination register.  */
1603   tmp_dest_val = src1val + get_iregval (isrc2);
1604
1605   /* Set OF and CC flags.
1606       For signed:
1607         OF = standard signed overflow.
1608         CC set   if isrc2 < -isrc1
1609         CC clear if isrc2 >= -isrc1
1610     */
1611   sa = src1val & 0x80000000;
1612   sb = get_iregval (isrc2) & 0x80000000;
1613   sres = tmp_dest_val & 0x80000000;
1614   if (sa != sb && sa != sres)
1615      SET_EPSR_OF (1);
1616   else
1617      SET_EPSR_OF   (0);
1618
1619   if ((INT32)get_iregval (isrc2) < -(INT32)(src1val))
1620      SET_PSR_CC (1);
1621   else
1622      SET_PSR_CC (0);
1623
1624   /* Now update the destination register.  */
1625   set_iregval (idest, tmp_dest_val);
1626}
1627
1628
1629/* Execute "subu isrc1,isrc2,idest".  */
1630static void insn_subu (i860s *cpustate, UINT32 insn)
1631{
1632   UINT32 src1val;
1633   UINT32 isrc2 = get_isrc2 (insn);
1634   UINT32 idest = get_idest (insn);
1635   UINT32 tmp_dest_val = 0;
1636
1637   src1val = get_iregval (get_isrc1 (insn));
1638
1639   /* We don't update the actual idest register now because below we
1640       need to test the original src1 and src2 if either happens to
1641       be the destination register.  */
1642   tmp_dest_val = src1val - get_iregval (isrc2);
1643
1644   /* Set OF and CC flags.
1645       For unsigned:
1646         OF = NOT(bit 31 carry)
1647         CC = bit 31 carry.
1648         (i.e. CC set   if isrc2 <= isrc1
1649               CC clear if isrc2 > isrc1
1650     */
1651   if ((UINT32)get_iregval (isrc2) <= (UINT32)src1val)
1652   {
1653      SET_PSR_CC (1);
1654      SET_EPSR_OF (0);
1655   }
1656   else
1657   {
1658      SET_PSR_CC (0);
1659      SET_EPSR_OF (1);
1660   }
1661
1662   /* Now update the destination register.  */
1663   set_iregval (idest, tmp_dest_val);
1664}
1665
1666
1667/* Execute "subu #const,isrc2,idest".  */
1668static void insn_subu_imm (i860s *cpustate, UINT32 insn)
1669{
1670   UINT32 src1val;
1671   UINT32 isrc2 = get_isrc2 (insn);
1672   UINT32 idest = get_idest (insn);
1673   UINT32 tmp_dest_val = 0;
1674
1675   src1val = sign_ext (get_imm16 (insn), 16);
1676
1677   /* We don't update the actual idest register now because below we
1678       need to test the original src1 and src2 if either happens to
1679       be the destination register.  */
1680   tmp_dest_val = src1val - get_iregval (isrc2);
1681
1682   /* Set OF and CC flags.
1683       For unsigned:
1684         OF = NOT(bit 31 carry)
1685         CC = bit 31 carry.
1686         (i.e. CC set   if isrc2 <= isrc1
1687               CC clear if isrc2 > isrc1
1688     */
1689   if ((UINT32)get_iregval (isrc2) <= (UINT32)src1val)
1690   {
1691      SET_PSR_CC (1);
1692      SET_EPSR_OF (0);
1693   }
1694   else
1695   {
1696      SET_PSR_CC (0);
1697      SET_EPSR_OF (1);
1698   }
1699
1700   /* Now update the destination register.  */
1701   set_iregval (idest, tmp_dest_val);
1702}
1703
1704
1705/* Execute "subs isrc1,isrc2,idest".  */
1706static void insn_subs (i860s *cpustate, UINT32 insn)
1707{
1708   UINT32 src1val;
1709   UINT32 isrc2 = get_isrc2 (insn);
1710   UINT32 idest = get_idest (insn);
1711   UINT32 tmp_dest_val = 0;
1712   int sa, sb, sres;
1713
1714   src1val = get_iregval (get_isrc1 (insn));
1715
1716   /* We don't update the actual idest register now because below we
1717       need to test the original src1 and src2 if either happens to
1718       be the destination register.  */
1719   tmp_dest_val = src1val - get_iregval (isrc2);
1720
1721   /* Set OF and CC flags.
1722       For signed:
1723         OF = standard signed overflow.
1724         CC set   if isrc2 > isrc1
1725         CC clear if isrc2 <= isrc1
1726     */
1727   sa = src1val & 0x80000000;
1728   sb = get_iregval (isrc2) & 0x80000000;
1729   sres = tmp_dest_val & 0x80000000;
1730   if (sa != sb && sa != sres)
1731      SET_EPSR_OF (1);
1732   else
1733      SET_EPSR_OF   (0);
1734
1735   if ((INT32)get_iregval (isrc2) > (INT32)(src1val))
1736      SET_PSR_CC (1);
1737   else
1738      SET_PSR_CC (0);
1739
1740   /* Now update the destination register.  */
1741   set_iregval (idest, tmp_dest_val);
1742}
1743
1744
1745/* Execute "subs #const,isrc2,idest".  */
1746static void insn_subs_imm (i860s *cpustate, UINT32 insn)
1747{
1748   UINT32 src1val;
1749   UINT32 isrc2 = get_isrc2 (insn);
1750   UINT32 idest = get_idest (insn);
1751   UINT32 tmp_dest_val = 0;
1752   int sa, sb, sres;
1753
1754   src1val = sign_ext (get_imm16 (insn), 16);
1755
1756   /* We don't update the actual idest register now because below we
1757       need to test the original src1 and src2 if either happens to
1758       be the destination register.  */
1759   tmp_dest_val = src1val - get_iregval (isrc2);
1760
1761   /* Set OF and CC flags.
1762       For signed:
1763         OF = standard signed overflow.
1764         CC set   if isrc2 > isrc1
1765         CC clear if isrc2 <= isrc1
1766     */
1767   sa = src1val & 0x80000000;
1768   sb = get_iregval (isrc2) & 0x80000000;
1769   sres = tmp_dest_val & 0x80000000;
1770   if (sa != sb && sa != sres)
1771      SET_EPSR_OF (1);
1772   else
1773      SET_EPSR_OF   (0);
1774
1775   if ((INT32)get_iregval (isrc2) > (INT32)(src1val))
1776      SET_PSR_CC (1);
1777   else
1778      SET_PSR_CC (0);
1779
1780   /* Now update the destination register.  */
1781   set_iregval (idest, tmp_dest_val);
1782}
1783
1784
1785/* Execute "shl isrc1,isrc2,idest".  */
1786static void insn_shl (i860s *cpustate, UINT32 insn)
1787{
1788   UINT32 src1val = 0;
1789   UINT32 isrc2 = get_isrc2 (insn);
1790   UINT32 idest = get_idest (insn);
1791
1792   src1val = get_iregval (get_isrc1 (insn));
1793   set_iregval (idest, get_iregval (isrc2) << src1val);
1794}
1795
1796
1797/* Execute "shl #const,isrc2,idest".  */
1798static void insn_shl_imm (i860s *cpustate, UINT32 insn)
1799{
1800   UINT32 src1val = 0;
1801   UINT32 isrc2 = get_isrc2 (insn);
1802   UINT32 idest = get_idest (insn);
1803
1804   src1val = sign_ext (get_imm16 (insn), 16);
1805   set_iregval (idest, get_iregval (isrc2) << src1val);
1806}
1807
1808
1809/* Execute "shr isrc1,isrc2,idest".  */
1810static void insn_shr (i860s *cpustate, UINT32 insn)
1811{
1812   UINT32 src1val = 0;
1813   UINT32 isrc2 = get_isrc2 (insn);
1814   UINT32 idest = get_idest (insn);
1815
1816   src1val = get_iregval (get_isrc1 (insn));
1817
1818   /* The iregs array is UINT32, so this is a logical shift.  */
1819   set_iregval (idest, get_iregval (isrc2) >> src1val);
1820
1821   /* shr also sets the SC in psr (shift count).  */
1822   SET_PSR_SC (src1val);
1823}
1824
1825
1826/* Execute "shr #const,isrc2,idest".  */
1827static void insn_shr_imm (i860s *cpustate, UINT32 insn)
1828{
1829   UINT32 src1val = 0;
1830   UINT32 isrc2 = get_isrc2 (insn);
1831   UINT32 idest = get_idest (insn);
1832
1833   src1val = sign_ext (get_imm16 (insn), 16);
1834
1835   /* The iregs array is UINT32, so this is a logical shift.  */
1836   set_iregval (idest, get_iregval (isrc2) >> src1val);
1837
1838   /* shr also sets the SC in psr (shift count).  */
1839   SET_PSR_SC (src1val);
1840}
1841
1842
1843/* Execute "shra isrc1,isrc2,idest".  */
1844static void insn_shra (i860s *cpustate, UINT32 insn)
1845{
1846   UINT32 src1val = 0;
1847   UINT32 isrc2 = get_isrc2 (insn);
1848   UINT32 idest = get_idest (insn);
1849
1850   src1val = get_iregval (get_isrc1 (insn));
1851
1852   /* The iregs array is UINT32, so cast isrc2 to get arithmetic shift.  */
1853   set_iregval (idest, (INT32)get_iregval (isrc2) >> src1val);
1854}
1855
1856
1857/* Execute "shra #const,isrc2,idest".  */
1858static void insn_shra_imm (i860s *cpustate, UINT32 insn)
1859{
1860   UINT32 src1val = 0;
1861   UINT32 isrc2 = get_isrc2 (insn);
1862   UINT32 idest = get_idest (insn);
1863
1864   src1val = sign_ext (get_imm16 (insn), 16);
1865
1866   /* The iregs array is UINT32, so cast isrc2 to get arithmetic shift.  */
1867   set_iregval (idest, (INT32)get_iregval (isrc2) >> src1val);
1868}
1869
1870
1871/* Execute "shrd isrc1ni,isrc2,idest" instruction.  */
1872static void insn_shrd (i860s *cpustate, UINT32 insn)
1873{
1874   UINT32 isrc1 = get_isrc1 (insn);
1875   UINT32 isrc2 = get_isrc2 (insn);
1876   UINT32 idest = get_idest (insn);
1877   UINT32 sc = GET_PSR_SC ();
1878   UINT32 tmp;
1879
1880   /* Do the operation:
1881       idest = low_32(isrc1ni:isrc2 >> sc).  */
1882   if (sc == 0)
1883      tmp = get_iregval (isrc2);
1884   else
1885   {
1886      tmp = get_iregval (isrc1) << (32 - sc);
1887      tmp |= (get_iregval (isrc2) >> sc);
1888   }
1889   set_iregval (idest, tmp);
1890}
1891
1892
1893/* Execute "and isrc1,isrc2,idest".  */
1894static void insn_and (i860s *cpustate, UINT32 insn)
1895{
1896   UINT32 isrc1 = get_isrc1 (insn);
1897   UINT32 isrc2 = get_isrc2 (insn);
1898   UINT32 idest = get_idest (insn);
1899   UINT32 res = 0;
1900
1901   /* Do the operation.  */
1902   res = get_iregval (isrc1) & get_iregval (isrc2);
1903
1904   /* Set flags.  */
1905   if (res == 0)
1906      SET_PSR_CC (1);
1907   else
1908      SET_PSR_CC (0);
1909
1910   set_iregval (idest, res);
1911}
1912
1913
1914/* Execute "and #const,isrc2,idest".  */
1915static void insn_and_imm (i860s *cpustate, UINT32 insn)
1916{
1917   UINT32 src1val = 0;
1918   UINT32 isrc2 = get_isrc2 (insn);
1919   UINT32 idest = get_idest (insn);
1920   UINT32 res = 0;
1921
1922   /* Do the operation.  */
1923   src1val = get_imm16 (insn);
1924   res = src1val & get_iregval (isrc2);
1925
1926   /* Set flags.  */
1927   if (res == 0)
1928      SET_PSR_CC (1);
1929   else
1930      SET_PSR_CC (0);
1931
1932   set_iregval (idest, res);
1933}
1934
1935
1936/* Execute "andh #const,isrc2,idest".  */
1937static void insn_andh_imm (i860s *cpustate, UINT32 insn)
1938{
1939   UINT32 src1val = 0;
1940   UINT32 isrc2 = get_isrc2 (insn);
1941   UINT32 idest = get_idest (insn);
1942   UINT32 res = 0;
1943
1944   /* Do the operation.  */
1945   src1val = get_imm16 (insn);
1946   res = (src1val << 16) & get_iregval (isrc2);
1947
1948   /* Set flags.  */
1949   if (res == 0)
1950      SET_PSR_CC (1);
1951   else
1952      SET_PSR_CC (0);
1953
1954   set_iregval (idest, res);
1955}
1956
1957
1958/* Execute "andnot isrc1,isrc2,idest".  */
1959static void insn_andnot (i860s *cpustate, UINT32 insn)
1960{
1961   UINT32 isrc1 = get_isrc1 (insn);
1962   UINT32 isrc2 = get_isrc2 (insn);
1963   UINT32 idest = get_idest (insn);
1964   UINT32 res = 0;
1965
1966   /* Do the operation.  */
1967   res = (~get_iregval (isrc1)) & get_iregval (isrc2);
1968
1969   /* Set flags.  */
1970   if (res == 0)
1971      SET_PSR_CC (1);
1972   else
1973      SET_PSR_CC (0);
1974
1975   set_iregval (idest, res);
1976}
1977
1978
1979/* Execute "andnot #const,isrc2,idest".  */
1980static void insn_andnot_imm (i860s *cpustate, UINT32 insn)
1981{
1982   UINT32 src1val = 0;
1983   UINT32 isrc2 = get_isrc2 (insn);
1984   UINT32 idest = get_idest (insn);
1985   UINT32 res = 0;
1986
1987   /* Do the operation.  */
1988   src1val = get_imm16 (insn);
1989   res = (~src1val) & get_iregval (isrc2);
1990
1991   /* Set flags.  */
1992   if (res == 0)
1993      SET_PSR_CC (1);
1994   else
1995      SET_PSR_CC (0);
1996
1997   set_iregval (idest, res);
1998}
1999
2000
2001/* Execute "andnoth #const,isrc2,idest".  */
2002static void insn_andnoth_imm (i860s *cpustate, UINT32 insn)
2003{
2004   UINT32 src1val = 0;
2005   UINT32 isrc2 = get_isrc2 (insn);
2006   UINT32 idest = get_idest (insn);
2007   UINT32 res = 0;
2008
2009   /* Do the operation.  */
2010   src1val = get_imm16 (insn);
2011   res = (~(src1val << 16)) & get_iregval (isrc2);
2012
2013   /* Set flags.  */
2014   if (res == 0)
2015      SET_PSR_CC (1);
2016   else
2017      SET_PSR_CC (0);
2018
2019   set_iregval (idest, res);
2020}
2021
2022
2023/* Execute "or isrc1,isrc2,idest".  */
2024static void insn_or (i860s *cpustate, UINT32 insn)
2025{
2026   UINT32 isrc1 = get_isrc1 (insn);
2027   UINT32 isrc2 = get_isrc2 (insn);
2028   UINT32 idest = get_idest (insn);
2029   UINT32 res = 0;
2030
2031   /* Do the operation.  */
2032   res = get_iregval (isrc1) | get_iregval (isrc2);
2033
2034   /* Set flags.  */
2035   if (res == 0)
2036      SET_PSR_CC (1);
2037   else
2038      SET_PSR_CC (0);
2039
2040   set_iregval (idest, res);
2041}
2042
2043
2044/* Execute "or #const,isrc2,idest".  */
2045static void insn_or_imm (i860s *cpustate, UINT32 insn)
2046{
2047   UINT32 src1val = 0;
2048   UINT32 isrc2 = get_isrc2 (insn);
2049   UINT32 idest = get_idest (insn);
2050   UINT32 res = 0;
2051
2052   /* Do the operation.  */
2053   src1val = get_imm16 (insn);
2054   res = src1val | get_iregval (isrc2);
2055
2056   /* Set flags.  */
2057   if (res == 0)
2058      SET_PSR_CC (1);
2059   else
2060      SET_PSR_CC (0);
2061
2062   set_iregval (idest, res);
2063}
2064
2065
2066/* Execute "orh #const,isrc2,idest".  */
2067static void insn_orh_imm (i860s *cpustate, UINT32 insn)
2068{
2069   UINT32 src1val = 0;
2070   UINT32 isrc2 = get_isrc2 (insn);
2071   UINT32 idest = get_idest (insn);
2072   UINT32 res = 0;
2073
2074   /* Do the operation.  */
2075   src1val = get_imm16 (insn);
2076   res = (src1val << 16) | get_iregval (isrc2);
2077
2078   /* Set flags.  */
2079   if (res == 0)
2080      SET_PSR_CC (1);
2081   else
2082      SET_PSR_CC (0);
2083
2084   set_iregval (idest, res);
2085}
2086
2087
2088/* Execute "xor isrc1,isrc2,idest".  */
2089static void insn_xor (i860s *cpustate, UINT32 insn)
2090{
2091   UINT32 isrc1 = get_isrc1 (insn);
2092   UINT32 isrc2 = get_isrc2 (insn);
2093   UINT32 idest = get_idest (insn);
2094   UINT32 res = 0;
2095
2096   /* Do the operation.  */
2097   res = get_iregval (isrc1) ^ get_iregval (isrc2);
2098
2099   /* Set flags.  */
2100   if (res == 0)
2101      SET_PSR_CC (1);
2102   else
2103      SET_PSR_CC (0);
2104
2105   set_iregval (idest, res);
2106}
2107
2108
2109/* Execute "xor #const,isrc2,idest".  */
2110static void insn_xor_imm (i860s *cpustate, UINT32 insn)
2111{
2112   UINT32 src1val = 0;
2113   UINT32 isrc2 = get_isrc2 (insn);
2114   UINT32 idest = get_idest (insn);
2115   UINT32 res = 0;
2116
2117   /* Do the operation.  */
2118   src1val = get_imm16 (insn);
2119   res = src1val ^ get_iregval (isrc2);
2120
2121   /* Set flags.  */
2122   if (res == 0)
2123      SET_PSR_CC (1);
2124   else
2125      SET_PSR_CC (0);
2126
2127   set_iregval (idest, res);
2128}
2129
2130
2131/* Execute "xorh #const,isrc2,idest".  */
2132static void insn_xorh_imm (i860s *cpustate, UINT32 insn)
2133{
2134   UINT32 src1val = 0;
2135   UINT32 isrc2 = get_isrc2 (insn);
2136   UINT32 idest = get_idest (insn);
2137   UINT32 res = 0;
2138
2139   /* Do the operation.  */
2140   src1val = get_imm16 (insn);
2141   res = (src1val << 16) ^ get_iregval (isrc2);
2142
2143   /* Set flags.  */
2144   if (res == 0)
2145      SET_PSR_CC (1);
2146   else
2147      SET_PSR_CC (0);
2148
2149   set_iregval (idest, res);
2150}
2151
2152
2153/* Execute "trap isrc1ni,isrc2,idest" instruction.  */
2154static void insn_trap (i860s *cpustate, UINT32 insn)
2155{
2156   SET_PSR_IT (1);
2157   cpustate->pending_trap = 1;
2158}
2159
2160
2161/* Execute "intovr" instruction.  */
2162static void insn_intovr (i860s *cpustate, UINT32 insn)
2163{
2164   if (GET_EPSR_OF ())
2165   {
2166      SET_PSR_IT (1);
2167      cpustate->pending_trap = 1;
2168   }
2169}
2170
2171
2172/* Execute "bte isrc1,isrc2,sbroff".  */
2173static void insn_bte (i860s *cpustate, UINT32 insn)
2174{
2175   UINT32 src1val = 0;
2176   UINT32 isrc2 = get_isrc2 (insn);
2177   UINT32 target_addr = 0;
2178   INT32 sbroff = 0;
2179   int res = 0;
2180
2181   src1val = get_iregval (get_isrc1 (insn));
2182
2183   /* Compute the target address from the sbroff field.  */
2184   sbroff = sign_ext ((((insn >> 5) & 0xf800) | (insn & 0x07ff)), 16);
2185   target_addr = (INT32)cpustate->pc + 4 + (sbroff << 2);
2186
2187   /* Determine comparison result.  */
2188   res = (src1val == get_iregval (isrc2));
2189
2190   /* Branch routines always update the PC.  */
2191   if (res)
2192      cpustate->pc = target_addr;
2193   else
2194      cpustate->pc += 4;
2195
2196   cpustate->pc_updated = 1;
2197}
2198
2199
2200/* Execute "bte #const5,isrc2,sbroff".  */
2201static void insn_bte_imm (i860s *cpustate, UINT32 insn)
2202{
2203   UINT32 src1val = 0;
2204   UINT32 isrc2 = get_isrc2 (insn);
2205   UINT32 target_addr = 0;
2206   INT32 sbroff = 0;
2207   int res = 0;
2208
2209   src1val = (insn >> 11) & 0x1f;   /* 5-bit field, zero-extended.  */
2210
2211   /* Compute the target address from the sbroff field.  */
2212   sbroff = sign_ext ((((insn >> 5) & 0xf800) | (insn & 0x07ff)), 16);
2213   target_addr = (INT32)cpustate->pc + 4 + (sbroff << 2);
2214
2215   /* Determine comparison result.  */
2216   res = (src1val == get_iregval (isrc2));
2217
2218   /* Branch routines always update the PC.  */
2219   if (res)
2220      cpustate->pc = target_addr;
2221   else
2222      cpustate->pc += 4;
2223
2224   cpustate->pc_updated = 1;
2225}
2226
2227
2228/* Execute "btne isrc1,isrc2,sbroff".  */
2229static void insn_btne (i860s *cpustate, UINT32 insn)
2230{
2231   UINT32 src1val = 0;
2232   UINT32 isrc2 = get_isrc2 (insn);
2233   UINT32 target_addr = 0;
2234   INT32 sbroff = 0;
2235   int res = 0;
2236
2237   src1val = get_iregval (get_isrc1 (insn));
2238
2239   /* Compute the target address from the sbroff field.  */
2240   sbroff = sign_ext ((((insn >> 5) & 0xf800) | (insn & 0x07ff)), 16);
2241   target_addr = (INT32)cpustate->pc + 4 + (sbroff << 2);
2242
2243   /* Determine comparison result.  */
2244   res = (src1val != get_iregval (isrc2));
2245
2246   /* Branch routines always update the PC.  */
2247   if (res)
2248      cpustate->pc = target_addr;
2249   else
2250      cpustate->pc += 4;
2251
2252   cpustate->pc_updated = 1;
2253}
2254
2255
2256/* Execute "btne #const5,isrc2,sbroff".  */
2257static void insn_btne_imm (i860s *cpustate, UINT32 insn)
2258{
2259   UINT32 src1val = 0;
2260   UINT32 isrc2 = get_isrc2 (insn);
2261   UINT32 target_addr = 0;
2262   INT32 sbroff = 0;
2263   int res = 0;
2264
2265   src1val = (insn >> 11) & 0x1f;   /* 5-bit field, zero-extended.  */
2266
2267   /* Compute the target address from the sbroff field.  */
2268   sbroff = sign_ext ((((insn >> 5) & 0xf800) | (insn & 0x07ff)), 16);
2269   target_addr = (INT32)cpustate->pc + 4 + (sbroff << 2);
2270
2271   /* Determine comparison result.  */
2272   res = (src1val != get_iregval (isrc2));
2273
2274   /* Branch routines always update the PC.  */
2275   if (res)
2276      cpustate->pc = target_addr;
2277   else
2278      cpustate->pc += 4;
2279
2280   cpustate->pc_updated = 1;
2281}
2282
2283
2284/* Execute "bc lbroff" instruction.  */
2285static void insn_bc (i860s *cpustate, UINT32 insn)
2286{
2287   UINT32 target_addr = 0;
2288   INT32 lbroff = 0;
2289   int res = 0;
2290
2291   /* Compute the target address from the lbroff field.  */
2292   lbroff = sign_ext ((insn & 0x03ffffff), 26);
2293   target_addr = (INT32)cpustate->pc + 4 + (lbroff << 2);
2294
2295   /* Determine comparison result.  */
2296   res = (GET_PSR_CC () == 1);
2297
2298   /* Branch routines always update the PC.  */
2299   if (res)
2300      cpustate->pc = target_addr;
2301   else
2302      cpustate->pc += 4;
2303
2304   cpustate->pc_updated = 1;
2305}
2306
2307
2308/* Execute "bnc lbroff" instruction.  */
2309static void insn_bnc (i860s *cpustate, UINT32 insn)
2310{
2311   UINT32 target_addr = 0;
2312   INT32 lbroff = 0;
2313   int res = 0;
2314
2315   /* Compute the target address from the lbroff field.  */
2316   lbroff = sign_ext ((insn & 0x03ffffff), 26);
2317   target_addr = (INT32)cpustate->pc + 4 + (lbroff << 2);
2318
2319   /* Determine comparison result.  */
2320   res = (GET_PSR_CC () == 0);
2321
2322   /* Branch routines always update the PC, since pc_updated is set
2323       in the decode routine.  */
2324   if (res)
2325      cpustate->pc = target_addr;
2326   else
2327      cpustate->pc += 4;
2328
2329   cpustate->pc_updated = 1;
2330}
2331
2332
2333/* Execute "bc.t lbroff" instruction.  */
2334static void insn_bct (i860s *cpustate, UINT32 insn)
2335{
2336   UINT32 target_addr = 0;
2337   INT32 lbroff = 0;
2338   int res = 0;
2339   UINT32 orig_pc = cpustate->pc;
2340
2341   /* Compute the target address from the lbroff field.  */
2342   lbroff = sign_ext ((insn & 0x03ffffff), 26);
2343   target_addr = (INT32)cpustate->pc + 4 + (lbroff << 2);
2344
2345   /* Determine comparison result.  */
2346   res = (GET_PSR_CC () == 1);
2347
2348   /* Careful. Unlike bla, the delay slot instruction is only executed
2349       if the branch is taken.  */
2350   if (res)
2351   {
2352      /* Execute delay slot instruction.  */
2353      cpustate->pc += 4;
2354      decode_exec (cpustate, ifetch (cpustate, orig_pc + 4), 0);
2355      cpustate->pc = orig_pc;
2356      if (cpustate->pending_trap)
2357      {
2358         cpustate->pending_trap |= TRAP_IN_DELAY_SLOT;
2359         goto ab_op;
2360      }
2361   }
2362
2363   /* Since this branch is delayed, we must jump 2 instructions if
2364       if isn't taken.  */
2365   if (res)
2366      cpustate->pc = target_addr;
2367   else
2368      cpustate->pc += 8;
2369
2370   cpustate->pc_updated = 1;
2371
2372   ab_op:
2373   ;
2374}
2375
2376
2377/* Execute "bnc.t lbroff" instruction.  */
2378static void insn_bnct (i860s *cpustate, UINT32 insn)
2379{
2380   UINT32 target_addr = 0;
2381   INT32 lbroff = 0;
2382   int res = 0;
2383   UINT32 orig_pc = cpustate->pc;
2384
2385   /* Compute the target address from the lbroff field.  */
2386   lbroff = sign_ext ((insn & 0x03ffffff), 26);
2387   target_addr = (INT32)cpustate->pc + 4 + (lbroff << 2);
2388
2389   /* Determine comparison result.  */
2390   res = (GET_PSR_CC () == 0);
2391
2392   /* Careful. Unlike bla, the delay slot instruction is only executed
2393       if the branch is taken.  */
2394   if (res)
2395   {
2396      /* Execute delay slot instruction.  */
2397      cpustate->pc += 4;
2398      decode_exec (cpustate, ifetch (cpustate, orig_pc + 4), 0);
2399      cpustate->pc = orig_pc;
2400      if (cpustate->pending_trap)
2401      {
2402         cpustate->pending_trap |= TRAP_IN_DELAY_SLOT;
2403         goto ab_op;
2404      }
2405   }
2406
2407   /* Since this branch is delayed, we must jump 2 instructions if
2408       if isn't taken.  */
2409   if (res)
2410      cpustate->pc = target_addr;
2411   else
2412      cpustate->pc += 8;
2413
2414   cpustate->pc_updated = 1;
2415
2416   ab_op:
2417   ;
2418}
2419
2420
2421/* Execute "call lbroff" instruction.  */
2422static void insn_call (i860s *cpustate, UINT32 insn)
2423{
2424   UINT32 target_addr = 0;
2425   INT32 lbroff = 0;
2426   UINT32 orig_pc = cpustate->pc;
2427
2428   /* Compute the target address from the lbroff field.  */
2429   lbroff = sign_ext ((insn & 0x03ffffff), 26);
2430   target_addr = (INT32)cpustate->pc + 4 + (lbroff << 2);
2431
2432   /* Execute the delay slot instruction.  */
2433   cpustate->pc += 4;
2434   decode_exec (cpustate, ifetch (cpustate, orig_pc + 4), 0);
2435   cpustate->pc = orig_pc;
2436   if (cpustate->pending_trap)
2437   {
2438      cpustate->pending_trap |= TRAP_IN_DELAY_SLOT;
2439      goto ab_op;
2440   }
2441
2442   /* Sets the return pointer (r1).  */
2443   set_iregval (1, orig_pc + 8);
2444
2445   /* New target.  */
2446   cpustate->pc = target_addr;
2447   cpustate->pc_updated = 1;
2448
2449   ab_op:;
2450}
2451
2452
2453/* Execute "br lbroff".  */
2454static void insn_br (i860s *cpustate, UINT32 insn)
2455{
2456   UINT32 target_addr = 0;
2457   INT32 lbroff = 0;
2458   UINT32 orig_pc = cpustate->pc;
2459
2460   /* Compute the target address from the lbroff field.  */
2461   lbroff = sign_ext ((insn & 0x03ffffff), 26);
2462   target_addr = (INT32)cpustate->pc + 4 + (lbroff << 2);
2463
2464   /* Execute the delay slot instruction.  */
2465   cpustate->pc += 4;
2466   decode_exec (cpustate, ifetch (cpustate, orig_pc + 4), 0);
2467   cpustate->pc = orig_pc;
2468   if (cpustate->pending_trap)
2469   {
2470      cpustate->pending_trap |= TRAP_IN_DELAY_SLOT;
2471      goto ab_op;
2472   }
2473
2474   /* New target.  */
2475   cpustate->pc = target_addr;
2476   cpustate->pc_updated = 1;
2477
2478   ab_op:;
2479}
2480
2481
2482/* Execute "bri isrc1ni" instruction.
2483   Note: I didn't merge this code with calli because bri must do
2484   a lot of flag manipulation if any trap bits are set.  */
2485static void insn_bri (i860s *cpustate, UINT32 insn)
2486{
2487   UINT32 isrc1 = get_isrc1 (insn);
2488   UINT32 orig_pc = cpustate->pc;
2489   UINT32 orig_psr = cpustate->cregs[CR_PSR];
2490   UINT32 orig_src1_val = get_iregval (isrc1);
2491
2492#if 1 /* TURBO.  */
2493   cpustate->cregs[CR_PSR] &= ~PSR_ALL_TRAP_BITS_MASK;
2494#endif
2495
2496   /* Execute the delay slot instruction.  */
2497   cpustate->pc += 4;
2498   decode_exec (cpustate, ifetch (cpustate, orig_pc + 4), 0);
2499   cpustate->pc = orig_pc;
2500
2501   /* Delay slot insn caused a trap, abort operation.  */
2502   if (cpustate->pending_trap)
2503   {
2504      cpustate->pending_trap |= TRAP_IN_DELAY_SLOT;
2505      goto ab_op;
2506   }
2507
2508   /* If any trap bits are set, we need to do the return from
2509       trap work.  Note, we must use the PSR value that existed
2510       before the delay slot instruction was executed since the
2511       delay slot instruction might itself cause a trap bit to
2512       be set.  */
2513   if (orig_psr & PSR_ALL_TRAP_BITS_MASK)
2514   {
2515      /* Restore U and IM from their previous copies.  */
2516      SET_PSR_U (GET_PSR_PU ());
2517      SET_PSR_IM (GET_PSR_PIM ());
2518
2519      cpustate->fir_gets_trap_addr = 0;
2520   }
2521
2522   /* Update PC.  */
2523   cpustate->pc = orig_src1_val;
2524
2525   cpustate->pc_updated = 1;
2526   ab_op:;
2527}
2528
2529/* Execute "calli isrc1ni" instruction.  */
2530static void insn_calli (i860s *cpustate, UINT32 insn)
2531{
2532   UINT32 isrc1 = get_isrc1 (insn);
2533   UINT32 orig_pc = cpustate->pc;
2534   UINT32 orig_src1_val = get_iregval (isrc1);
2535
2536#ifdef TRACE_UNDEFINED_I860
2537   /* Check for undefined behavior.  */
2538   if (isrc1 == 1)
2539   {
2540      /* Src1 must not be r1.  */
2541      fprintf (stderr, "WARNING: insn_calli (pc=0x%08x): isrc1 = r1 on a calli\n", cpustate->pc);
2542   }
2543#endif
2544
2545   /* Set return pointer before executing delay slot instruction.  */
2546   set_iregval (1, cpustate->pc + 8);
2547
2548   /* Execute the delay slot instruction.  */
2549   cpustate->pc += 4;
2550   decode_exec (cpustate, ifetch (cpustate, orig_pc + 4), 0);
2551   cpustate->pc = orig_pc;
2552   if (cpustate->pending_trap)
2553   {
2554      set_iregval (1, orig_src1_val);
2555      cpustate->pending_trap |= TRAP_IN_DELAY_SLOT;
2556      goto ab_op;
2557   }
2558
2559   /* Set new PC.  */
2560   cpustate->pc = orig_src1_val;
2561   cpustate->pc_updated = 1;
2562
2563   ab_op:;
2564}
2565
2566
2567/* Execute "bla isrc1ni,isrc2,sbroff" instruction.  */
2568static void insn_bla (i860s *cpustate, UINT32 insn)
2569{
2570   UINT32 isrc1 = get_isrc1 (insn);
2571   UINT32 isrc2 = get_isrc2 (insn);
2572   UINT32 target_addr = 0;
2573   INT32 sbroff = 0;
2574   int lcc_tmp = 0;
2575   UINT32 orig_pc = cpustate->pc;
2576   UINT32 orig_isrc2val = get_iregval (isrc2);
2577
2578#ifdef TRACE_UNDEFINED_I860
2579   /* Check for undefined behavior.  */
2580   if (isrc1 == isrc2)
2581   {
2582      /* Src1 and src2 the same is undefined i860XR behavior.  */
2583      fprintf (stderr, "WARNING: insn_bla (pc=0x%08x): isrc1 and isrc2 are the same (ignored)\n", cpustate->pc);
2584      return;
2585   }
2586#endif
2587
2588   /* Compute the target address from the sbroff field.  */
2589   sbroff = sign_ext ((((insn >> 5) & 0xf800) | (insn & 0x07ff)), 16);
2590   target_addr = (INT32)cpustate->pc + 4 + (sbroff << 2);
2591
2592   /* Determine comparison result based on opcode.  */
2593   lcc_tmp = ((INT32)get_iregval (isrc2) >= -(INT32)get_iregval (isrc1));
2594
2595   set_iregval (isrc2, get_iregval (isrc1) + orig_isrc2val);
2596
2597   /* Execute the delay slot instruction.  */
2598   cpustate->pc += 4;
2599   decode_exec (cpustate, ifetch (cpustate, orig_pc + 4), 0);
2600   cpustate->pc = orig_pc;
2601   if (cpustate->pending_trap)
2602   {
2603      cpustate->pending_trap |= TRAP_IN_DELAY_SLOT;
2604      goto ab_op;
2605   }
2606
2607   if (GET_PSR_LCC ())
2608      cpustate->pc = target_addr;
2609   else
2610   {
2611      /* Since this branch is delayed, we must jump 2 instructions if
2612           if isn't taken.  */
2613      cpustate->pc += 8;
2614   }
2615   SET_PSR_LCC (lcc_tmp);
2616
2617   cpustate->pc_updated = 1;
2618   ab_op:;
2619}
2620
2621
2622/* Execute "flush #const(isrc2)" or "flush #const(isrc2)++" instruction.  */
2623static void insn_flush (i860s *cpustate, UINT32 insn)
2624{
2625   UINT32 src1val = sign_ext (get_imm16 (insn), 16);
2626   UINT32 isrc2 = get_isrc2 (insn);
2627   int auto_inc = (insn & 1);
2628   UINT32 eff = 0;
2629
2630   /* Technically, idest should be encoded as r0 because idest
2631       is undefined after the instruction.  We don't currently
2632       check for this.
2633
2634       Flush D$ block at address #const+isrc2.  Block is undefined
2635       after.  The effective address must be 16-byte aligned.
2636
2637       FIXME: Need to examine RB and RC and do this right.
2638      */
2639
2640   /* Chop off lower bits of displacement to 16-byte alignment.  */
2641   src1val &= ~(16-1);
2642   eff = src1val + get_iregval (isrc2);
2643   if (auto_inc)
2644      set_iregval (isrc2, eff);
2645
2646   /* In user mode, the flush is ignored.  */
2647   if (GET_PSR_U () == 0)
2648   {
2649      /* If line is dirty, write it to memory and invalidate.
2650           NOTE: The actual dirty write is unimplemented in the MAME version
2651           as we don't emulate the dcache.  */
2652   }
2653}
2654
2655
2656/* Execute "[p]fmul.{ss,sd,dd} fsrc1,fsrc2,fdest" instruction or
2657   pfmul3.dd fsrc1,fsrc2,fdest.
2658
2659   The pfmul3.dd differs from pfmul.dd in that it treats the pipeline
2660   as 3 stages, even though it is a double precision multiply.  */
2661static void insn_fmul (i860s *cpustate, UINT32 insn)
2662{
2663   UINT32 fsrc1 = get_fsrc1 (insn);
2664   UINT32 fsrc2 = get_fsrc2 (insn);
2665   UINT32 fdest = get_fdest (insn);
2666   int src_prec = insn & 0x100;    /* 1 = double, 0 = single.  */
2667   int res_prec = insn & 0x080;    /* 1 = double, 0 = single.  */
2668   int piped = insn & 0x400;       /* 1 = pipelined, 0 = scalar.  */
2669   double dbl_tmp_dest = 0.0;
2670   float sgl_tmp_dest = 0.0;
2671   double dbl_last_stage_contents = 0.0;
2672   float sgl_last_stage_contents = 0.0;
2673   int is_pfmul3 = insn & 0x4;
2674   int num_stages = (src_prec && !is_pfmul3) ? 2 : 3;
2675
2676   /* Only .dd is valid for pfmul.  */
2677   if (is_pfmul3 && (insn & 0x180) != 0x180)
2678   {
2679      unrecog_opcode (cpustate->pc, insn);
2680      return;
2681   }
2682
2683   /* Check for invalid .ds combination.  */
2684   if ((insn & 0x180) == 0x100)
2685   {
2686      unrecog_opcode (cpustate->pc, insn);
2687      return;
2688   }
2689
2690   /* For pipelined version, retrieve the contents of the last stage
2691       of the pipeline, whose precision is specified by the MRP bit
2692       of the stage's result-status bits.  Note for pfmul, the number
2693       of stages is determined by the source precision of the current
2694       operation.  */
2695   if (piped)
2696   {
2697      if (cpustate->M[num_stages - 1].stat.mrp)
2698         dbl_last_stage_contents = cpustate->M[num_stages - 1].val.d;
2699      else
2700         sgl_last_stage_contents   = cpustate->M[num_stages - 1].val.s;
2701   }
2702
2703   /* Do the operation, being careful about source and result
2704       precision.  */
2705   if (src_prec)
2706   {
2707      double v1 = get_fregval_d (cpustate, fsrc1);
2708      double v2 = get_fregval_d (cpustate, fsrc2);
2709
2710      /* For pipelined mul, if fsrc2 is the same as fdest, then the last
2711           stage is bypassed to fsrc2 (rather than using the value in fsrc2).
2712           This bypass is not available for fsrc1, and is undefined behavior.  */
2713      if (0 && piped && fdest != 0 && fsrc1 == fdest)
2714         v1 = dbl_last_stage_contents;
2715      if (piped && fdest != 0 && fsrc2 == fdest)
2716         v2 = dbl_last_stage_contents;
2717
2718      if (res_prec)
2719         dbl_tmp_dest = v1 * v2;
2720      else
2721         sgl_tmp_dest = (float)(v1 * v2);
2722   }
2723   else
2724   {
2725      float v1 = get_fregval_s (cpustate, fsrc1);
2726      float v2 = get_fregval_s (cpustate, fsrc2);
2727
2728      /* For pipelined mul, if fsrc2 is the same as fdest, then the last
2729           stage is bypassed to fsrc2 (rather than using the value in fsrc2).
2730           This bypass is not available for fsrc1, and is undefined behavior.  */
2731      if (0 && piped && fdest != 0 && fsrc1 == fdest)
2732         v1 = sgl_last_stage_contents;
2733      if (piped && fdest != 0 && fsrc2 == fdest)
2734         v2 = sgl_last_stage_contents;
2735
2736      if (res_prec)
2737         dbl_tmp_dest = (double)(v1 * v2);
2738      else
2739         sgl_tmp_dest = v1 * v2;
2740   }
2741
2742   /* FIXME: Set result-status bits besides MRP. And copy to fsr from
2743              last stage.  */
2744   /* FIXME: Scalar version flows through all stages.  */
2745   /* FIXME: Mixed precision (only wierd for pfmul).  */
2746   if (!piped)
2747   {
2748      /* Scalar version writes the current calculation to the fdest
2749           register, with precision specified by the R bit.  */
2750      if (res_prec)
2751         set_fregval_d (cpustate, fdest, dbl_tmp_dest);
2752      else
2753         set_fregval_s (cpustate, fdest, sgl_tmp_dest);
2754   }
2755   else
2756   {
2757      /* Pipelined version writes fdest with the result from the last
2758           stage of the pipeline.  */
2759#if 1 /* FIXME: WIP on FSR update.  This may not be correct.  */
2760      /* Copy 3rd stage MRP to FSR.  */
2761      if (cpustate->M[num_stages - 2   /* 1 */].stat.mrp)
2762         cpustate->cregs[CR_FSR] |= 0x10000000;
2763      else
2764         cpustate->cregs[CR_FSR] &= ~0x10000000;
2765#endif
2766
2767      if (cpustate->M[num_stages - 1].stat.mrp)
2768         set_fregval_d (cpustate, fdest, dbl_last_stage_contents);
2769      else
2770         set_fregval_s (cpustate, fdest, sgl_last_stage_contents);
2771
2772      /* Now advance pipeline and write current calculation to
2773           first stage.  */
2774      if (num_stages == 3)
2775      {
2776         cpustate->M[2] = cpustate->M[1];
2777         cpustate->M[1] = cpustate->M[0];
2778      }
2779      else
2780         cpustate->M[1]   = cpustate->M[0];
2781
2782      if (res_prec)
2783      {
2784         cpustate->M[0].val.d = dbl_tmp_dest;
2785         cpustate->M[0].stat.mrp = 1;
2786      }
2787      else
2788      {
2789         cpustate->M[0].val.s = sgl_tmp_dest;
2790         cpustate->M[0].stat.mrp = 0;
2791      }
2792   }
2793}
2794
2795
2796/* Execute "fmlow.dd fsrc1,fsrc2,fdest" instruction.  */
2797static void insn_fmlow (i860s *cpustate, UINT32 insn)
2798{
2799   UINT32 fsrc1 = get_fsrc1 (insn);
2800   UINT32 fsrc2 = get_fsrc2 (insn);
2801   UINT32 fdest = get_fdest (insn);
2802
2803   double v1 = get_fregval_d (cpustate, fsrc1);
2804   double v2 = get_fregval_d (cpustate, fsrc2);
2805   INT64 i1 = *(UINT64 *)&v1;
2806   INT64 i2 = *(UINT64 *)&v2;
2807   INT64 tmp = 0;
2808
2809   /* Only .dd is valid for fmlow.  */
2810   if ((insn & 0x180) != 0x180)
2811   {
2812      unrecog_opcode (cpustate->pc, insn);
2813      return;
2814   }
2815
2816   /* The lower 32-bits are obvious.  What exactly goes in the upper
2817       bits?
2818       Technically, the upper-most 10 bits are undefined, but i'd like
2819       to be undefined in the same way as the real i860 if possible.  */
2820
2821   /* Keep lower 53 bits of multiply.  */
2822   tmp = i1 * i2;
2823   tmp &= 0x001fffffffffffffULL;
2824   tmp |= (i1 & 0x8000000000000000LL) ^ (i2 & 0x8000000000000000LL);
2825   set_fregval_d (cpustate, fdest, *(double *)&tmp);
2826}
2827
2828
2829/* Execute [p]fadd.{ss,sd,dd} fsrc1,fsrc2,fdest (.ds disallowed above).  */
2830static void insn_fadd_sub (i860s *cpustate, UINT32 insn)
2831{
2832   UINT32 fsrc1 = get_fsrc1 (insn);
2833   UINT32 fsrc2 = get_fsrc2 (insn);
2834   UINT32 fdest = get_fdest (insn);
2835   int src_prec = insn & 0x100;    /* 1 = double, 0 = single.  */
2836   int res_prec = insn & 0x080;    /* 1 = double, 0 = single.  */
2837   int piped = insn & 0x400;       /* 1 = pipelined, 0 = scalar.  */
2838   int is_sub = insn & 1;          /* 1 = sub, 0 = add.  */
2839   double dbl_tmp_dest = 0.0;
2840   float sgl_tmp_dest = 0.0;
2841   double dbl_last_stage_contents = 0.0;
2842   float sgl_last_stage_contents = 0.0;
2843
2844   /* Check for invalid .ds combination.  */
2845   if ((insn & 0x180) == 0x100)
2846   {
2847      unrecog_opcode (cpustate->pc, insn);
2848      return;
2849   }
2850
2851   /* For pipelined version, retrieve the contents of the last stage
2852       of the pipeline, whose precision is specified by the ARP bit
2853       of the stage's result-status bits.  There are always three stages
2854       for pfadd/pfsub.  */
2855   if (piped)
2856   {
2857      if (cpustate->A[2].stat.arp)
2858         dbl_last_stage_contents = cpustate->A[2].val.d;
2859      else
2860         sgl_last_stage_contents   = cpustate->A[2].val.s;
2861   }
2862
2863   /* Do the operation, being careful about source and result
2864       precision.  */
2865   if (src_prec)
2866   {
2867      double v1 = get_fregval_d (cpustate, fsrc1);
2868      double v2 = get_fregval_d (cpustate, fsrc2);
2869
2870      /* For pipelined add/sub, if fsrc1 is the same as fdest, then the last
2871           stage is bypassed to fsrc1 (rather than using the value in fsrc1).
2872           Likewise for fsrc2.  */
2873      if (piped && fdest != 0 && fsrc1 == fdest)
2874         v1 = dbl_last_stage_contents;
2875      if (piped && fdest != 0 && fsrc2 == fdest)
2876         v2 = dbl_last_stage_contents;
2877
2878      if (res_prec)
2879         dbl_tmp_dest = is_sub ? v1 - v2 : v1 + v2;
2880      else
2881         sgl_tmp_dest = is_sub ? (float)(v1 - v2) : (float)(v1 + v2);
2882   }
2883   else
2884   {
2885      float v1 = get_fregval_s (cpustate, fsrc1);
2886      float v2 = get_fregval_s (cpustate, fsrc2);
2887
2888      /* For pipelined add/sub, if fsrc1 is the same as fdest, then the last
2889           stage is bypassed to fsrc1 (rather than using the value in fsrc1).
2890           Likewise for fsrc2.  */
2891      if (piped && fdest != 0 && fsrc1 == fdest)
2892         v1 = sgl_last_stage_contents;
2893      if (piped && fdest != 0 && fsrc2 == fdest)
2894         v2 = sgl_last_stage_contents;
2895
2896      if (res_prec)
2897         dbl_tmp_dest = is_sub ? (double)(v1 - v2) : (double)(v1 + v2);
2898      else
2899         sgl_tmp_dest = is_sub ? v1 - v2 : v1 + v2;
2900   }
2901
2902   /* FIXME: Set result-status bits besides ARP. And copy to fsr from
2903              last stage.  */
2904   /* FIXME: Scalar version flows through all stages.  */
2905   if (!piped)
2906   {
2907      /* Scalar version writes the current calculation to the fdest
2908           register, with precision specified by the R bit.  */
2909      if (res_prec)
2910         set_fregval_d (cpustate, fdest, dbl_tmp_dest);
2911      else
2912         set_fregval_s (cpustate, fdest, sgl_tmp_dest);
2913   }
2914   else
2915   {
2916      /* Pipelined version writes fdest with the result from the last
2917           stage of the pipeline, with precision specified by the ARP
2918           bit of the stage's result-status bits.  */
2919#if 1 /* FIXME: WIP on FSR update.  This may not be correct.  */
2920      /* Copy 3rd stage ARP to FSR.  */
2921      if (cpustate->A[1 /* 2 */].stat.arp)
2922         cpustate->cregs[CR_FSR] |= 0x20000000;
2923      else
2924         cpustate->cregs[CR_FSR] &= ~0x20000000;
2925#endif
2926      if (cpustate->A[2].stat.arp)  /* 3rd (last) stage.  */
2927         set_fregval_d (cpustate, fdest, dbl_last_stage_contents);
2928      else
2929         set_fregval_s (cpustate, fdest, sgl_last_stage_contents);
2930
2931      /* Now advance pipeline and write current calculation to
2932           first stage.  */
2933      cpustate->A[2] = cpustate->A[1];
2934      cpustate->A[1] = cpustate->A[0];
2935      if (res_prec)
2936      {
2937         cpustate->A[0].val.d = dbl_tmp_dest;
2938         cpustate->A[0].stat.arp = 1;
2939      }
2940      else
2941      {
2942         cpustate->A[0].val.s = sgl_tmp_dest;
2943         cpustate->A[0].stat.arp = 0;
2944      }
2945   }
2946}
2947
2948
2949/* Operand types for PFAM/PFMAM routine below.  */
2950enum {
2951   OP_SRC1     = 0,
2952   OP_SRC2     = 1,
2953   OP_KI       = 2,
2954   OP_KR       = 4,
2955   OP_T        = 8,
2956   OP_MPIPE    = 16,
2957   OP_APIPE    = 32,
2958   FLAGM       = 64   /* Indicates PFMAM uses M rather than A pipe result.  */
2959};
2960
2961/* A table to map DPC value to source operands.
2962
2963   The PFAM and PFMAM tables are nearly identical, and the only differences
2964   are that every time PFAM uses the A pipe, PFMAM uses the M pipe instead.
2965   So we only represent the PFAM table and use a special flag on any entry
2966   where the PFMAM table would use the M pipe rather than the A pipe.
2967   Also, entry 16 is not valid for PFMAM.  */
2968static struct
2969{
2970   int M_unit_op1;
2971   int M_unit_op2;
2972   int A_unit_op1;
2973   int A_unit_op2;
2974   int T_loaded;
2975   int K_loaded;
2976} src_opers[] = {
2977   /* 0000 */ { OP_KR,   OP_SRC2,        OP_SRC1,        OP_MPIPE,       0, 0},
2978   /* 0001 */ { OP_KR,   OP_SRC2,        OP_T,           OP_MPIPE,       0, 1},
2979   /* 0010 */ { OP_KR,   OP_SRC2,        OP_SRC1,        OP_APIPE|FLAGM, 1, 0},
2980   /* 0011 */ { OP_KR,   OP_SRC2,        OP_T,           OP_APIPE|FLAGM, 1, 1},
2981   /* 0100 */ { OP_KI,   OP_SRC2,        OP_SRC1,        OP_MPIPE,       0, 0},
2982   /* 0101 */ { OP_KI,   OP_SRC2,        OP_T,           OP_MPIPE,       0, 1},
2983   /* 0110 */ { OP_KI,   OP_SRC2,        OP_SRC1,        OP_APIPE|FLAGM, 1, 0},
2984   /* 0111 */ { OP_KI,   OP_SRC2,        OP_T,           OP_APIPE|FLAGM, 1, 1},
2985   /* 1000 */ { OP_KR,   OP_APIPE|FLAGM, OP_SRC1,        OP_SRC2,        1, 0},
2986   /* 1001 */ { OP_SRC1, OP_SRC2,        OP_APIPE|FLAGM, OP_MPIPE,       0, 0},
2987   /* 1010 */ { OP_KR,   OP_APIPE|FLAGM, OP_SRC1,        OP_SRC2,        0, 0},
2988   /* 1011 */ { OP_SRC1, OP_SRC2,        OP_T,           OP_APIPE|FLAGM, 1, 0},
2989   /* 1100 */ { OP_KI,   OP_APIPE|FLAGM, OP_SRC1,        OP_SRC2,        1, 0},
2990   /* 1101 */ { OP_SRC1, OP_SRC2,        OP_T,           OP_MPIPE,       0, 0},
2991   /* 1110 */ { OP_KI,   OP_APIPE|FLAGM, OP_SRC1,        OP_SRC2,        0, 0},
2992   /* 1111 */ { OP_SRC1, OP_SRC2,        OP_T,           OP_APIPE|FLAGM, 0, 0}
2993};
2994
2995float get_fval_from_optype_s (i860s *cpustate, UINT32 insn, int optype)
2996{
2997   float retval = 0.0;
2998   UINT32 fsrc1 = get_fsrc1 (insn);
2999   UINT32 fsrc2 = get_fsrc2 (insn);
3000
3001   optype &= ~FLAGM;
3002   switch (optype)
3003   {
3004   case OP_SRC1:
3005      retval = get_fregval_s (cpustate, fsrc1);
3006      break;
3007   case OP_SRC2:
3008      retval = get_fregval_s (cpustate, fsrc2);
3009      break;
3010   case OP_KI:
3011      retval = cpustate->KI.s;
3012      break;
3013   case OP_KR:
3014      retval = cpustate->KR.s;
3015      break;
3016   case OP_T:
3017      retval = cpustate->T.s;
3018      break;
3019   case OP_MPIPE:
3020      /* Last stage is 3rd stage for single precision input.  */
3021      retval = cpustate->M[2].val.s;
3022      break;
3023   case OP_APIPE:
3024      retval = cpustate->A[2].val.s;
3025      break;
3026   default:
3027      assert (0);
3028   }
3029
3030   return retval;
3031}
3032
3033
3034double get_fval_from_optype_d (i860s *cpustate, UINT32 insn, int optype)
3035{
3036   double retval = 0.0;
3037   UINT32 fsrc1 = get_fsrc1 (insn);
3038   UINT32 fsrc2 = get_fsrc2 (insn);
3039
3040   optype &= ~FLAGM;
3041   switch (optype)
3042   {
3043   case OP_SRC1:
3044      retval = get_fregval_d (cpustate, fsrc1);
3045      break;
3046   case OP_SRC2:
3047      retval = get_fregval_d (cpustate, fsrc2);
3048      break;
3049   case OP_KI:
3050      retval = cpustate->KI.d;
3051      break;
3052   case OP_KR:
3053      retval = cpustate->KR.d;
3054      break;
3055   case OP_T:
3056      retval = cpustate->T.d;
3057      break;
3058   case OP_MPIPE:
3059      /* Last stage is 2nd stage for double precision input.  */
3060      retval = cpustate->M[1].val.d;
3061      break;
3062   case OP_APIPE:
3063      retval = cpustate->A[2].val.d;
3064      break;
3065   default:
3066      assert (0);
3067   }
3068
3069   return retval;
3070}
3071
3072
3073/* Execute pf[m]{a,s}m.{ss,sd,dd} fsrc1,fsrc2,fdest (FP dual ops).
3074
3075   Since these are always pipelined, the P bit is used to distinguish
3076   family pfam (P=1) from family pfmam (P=0), and the lower 4 bits
3077   of the extended opcode is the DPC.
3078
3079   Note also that the S and R bits are slightly different than normal
3080   floating point operations.  The S bit denotes the precision of the
3081   multiplication source, while the R bit denotes the precision of
3082   the addition source as well as precision of all results.  */
3083static void insn_dualop (i860s *cpustate, UINT32 insn)
3084{
3085   UINT32 fsrc1 = get_fsrc1 (insn);
3086   UINT32 fsrc2 = get_fsrc2 (insn);
3087   UINT32 fdest = get_fdest (insn);
3088   int src_prec = insn & 0x100;    /* 1 = double, 0 = single.  */
3089   int res_prec = insn & 0x080;    /* 1 = double, 0 = single.  */
3090   int is_pfam = insn & 0x400;       /* 1 = pfam, 0 = pfmam.  */
3091   int is_sub = insn & 0x10;       /* 1 = pf[m]sm, 0 = pf[m]am.  */
3092   double dbl_tmp_dest_mul = 0.0;
3093   float sgl_tmp_dest_mul = 0.0;
3094   double dbl_tmp_dest_add = 0.0;
3095   float sgl_tmp_dest_add = 0.0;
3096   double dbl_last_Mstage_contents = 0.0;
3097   float sgl_last_Mstage_contents = 0.0;
3098   double dbl_last_Astage_contents = 0.0;
3099   float sgl_last_Astage_contents = 0.0;
3100   int num_mul_stages = src_prec ? 2 : 3;
3101
3102   int dpc = insn & 0xf;
3103   int M_unit_op1 = src_opers[dpc].M_unit_op1;
3104   int M_unit_op2 = src_opers[dpc].M_unit_op2;
3105   int A_unit_op1 = src_opers[dpc].A_unit_op1;
3106   int A_unit_op2 = src_opers[dpc].A_unit_op2;
3107   int T_loaded = src_opers[dpc].T_loaded;
3108   int K_loaded = src_opers[dpc].K_loaded;
3109
3110   /* Check for invalid .ds combination.  */
3111   if ((insn & 0x180) == 0x100)
3112   {
3113      unrecog_opcode (cpustate->pc, insn);
3114      return;
3115   }
3116
3117   if (is_pfam == 0)
3118   {
3119      /* Check for invalid DPC combination 16 for PFMAM.  */
3120      if (dpc == 16)
3121      {
3122         unrecog_opcode (cpustate->pc, insn);
3123         return;
3124      }
3125
3126      /* PFMAM table adjustments (M_unit_op1 is never a pipe stage,
3127           so no adjustment made for it).   */
3128      M_unit_op2 = (M_unit_op2 & FLAGM) ? OP_MPIPE : M_unit_op2;
3129      A_unit_op1 = (A_unit_op1 & FLAGM) ? OP_MPIPE : A_unit_op1;
3130      A_unit_op2 = (A_unit_op2 & FLAGM) ? OP_MPIPE : A_unit_op2;
3131   }
3132
3133   /* FIXME: Check for fsrc1/fdest overlap for some mul DPC combinations.  */
3134
3135   /* Retrieve the contents of the last stage of the multiplier pipeline,
3136       whose precision is specified by the MRP bit of the stage's result-
3137       status bits.  Note for multiply, the number of stages is determined
3138       by the source precision of the current operation.  */
3139   if (cpustate->M[num_mul_stages - 1].stat.mrp)
3140      dbl_last_Mstage_contents = cpustate->M[num_mul_stages - 1].val.d;
3141   else
3142      sgl_last_Mstage_contents = cpustate->M[num_mul_stages - 1].val.s;
3143
3144   /* Similarly, retrieve the last stage of the adder pipe.  */
3145   if (cpustate->A[2].stat.arp)
3146      dbl_last_Astage_contents = cpustate->A[2].val.d;
3147   else
3148      sgl_last_Astage_contents = cpustate->A[2].val.s;
3149
3150   /* Do the mul operation, being careful about source and result
3151       precision.  */
3152   if (src_prec)
3153   {
3154      double v1 = get_fval_from_optype_d (cpustate, insn, M_unit_op1);
3155      double v2 = get_fval_from_optype_d (cpustate, insn, M_unit_op2);
3156
3157      /* For mul, if fsrc2 is the same as fdest, then the last stage
3158           is bypassed to fsrc2 (rather than using the value in fsrc2).
3159           This bypass is not available for fsrc1, and is undefined behavior.  */
3160      if (0 && M_unit_op1 == OP_SRC1 && fdest != 0 && fsrc1 == fdest)
3161         v1 = is_pfam ? dbl_last_Astage_contents : dbl_last_Mstage_contents;
3162      if (M_unit_op2 == OP_SRC2 && fdest != 0 && fsrc2 == fdest)
3163         v2 = is_pfam ? dbl_last_Astage_contents : dbl_last_Mstage_contents;
3164
3165      if (res_prec)
3166         dbl_tmp_dest_mul = v1 * v2;
3167      else
3168         sgl_tmp_dest_mul = (float)(v1 * v2);
3169   }
3170   else
3171   {
3172      float v1 = get_fval_from_optype_s (cpustate, insn, M_unit_op1);
3173      float v2 = get_fval_from_optype_s (cpustate, insn, M_unit_op2);
3174
3175      /* For mul, if fsrc2 is the same as fdest, then the last stage
3176           is bypassed to fsrc2 (rather than using the value in fsrc2).
3177           This bypass is not available for fsrc1, and is undefined behavior.  */
3178      if (0 && M_unit_op1 == OP_SRC1 && fdest != 0 && fsrc1 == fdest)
3179         v1 = is_pfam ? sgl_last_Astage_contents : sgl_last_Mstage_contents;
3180      if (M_unit_op2 == OP_SRC2 && fdest != 0 && fsrc2 == fdest)
3181         v2 = is_pfam ? sgl_last_Astage_contents : sgl_last_Mstage_contents;
3182
3183      if (res_prec)
3184         dbl_tmp_dest_mul = (double)(v1 * v2);
3185      else
3186         sgl_tmp_dest_mul = v1 * v2;
3187   }
3188
3189   /* Do the add operation, being careful about source and result
3190       precision.  Remember, the R bit indicates source and result precision
3191       here.  */
3192   if (res_prec)
3193   {
3194      double v1 = get_fval_from_optype_d (cpustate, insn, A_unit_op1);
3195      double v2 = get_fval_from_optype_d (cpustate, insn, A_unit_op2);
3196
3197      /* For add/sub, if fsrc1 is the same as fdest, then the last stage
3198           is bypassed to fsrc1 (rather than using the value in fsrc1).
3199           Likewise for fsrc2.  */
3200      if (A_unit_op1 == OP_SRC1 && fdest != 0 && fsrc1 == fdest)
3201         v1 = is_pfam ? dbl_last_Astage_contents : dbl_last_Mstage_contents;
3202      if (A_unit_op2 == OP_SRC2 && fdest != 0 && fsrc2 == fdest)
3203         v2 = is_pfam ? dbl_last_Astage_contents : dbl_last_Mstage_contents;
3204
3205      if (res_prec)
3206         dbl_tmp_dest_add = is_sub ? v1 - v2 : v1 + v2;
3207      else
3208         sgl_tmp_dest_add = is_sub ? (float)(v1 - v2) : (float)(v1 + v2);
3209   }
3210   else
3211   {
3212      float v1 = get_fval_from_optype_s (cpustate, insn, A_unit_op1);
3213      float v2 = get_fval_from_optype_s (cpustate, insn, A_unit_op2);
3214
3215      /* For add/sub, if fsrc1 is the same as fdest, then the last stage
3216           is bypassed to fsrc1 (rather than using the value in fsrc1).
3217           Likewise for fsrc2.  */
3218      if (A_unit_op1 == OP_SRC1 && fdest != 0 && fsrc1 == fdest)
3219         v1 = is_pfam ? sgl_last_Astage_contents : sgl_last_Mstage_contents;
3220      if (A_unit_op2 == OP_SRC2 && fdest != 0 && fsrc2 == fdest)
3221         v2 = is_pfam ? sgl_last_Astage_contents : sgl_last_Mstage_contents;
3222
3223      if (res_prec)
3224         dbl_tmp_dest_add = is_sub ? (double)(v1 - v2) : (double)(v1 + v2);
3225      else
3226         sgl_tmp_dest_add = is_sub ? v1 - v2 : v1 + v2;
3227   }
3228
3229   /* If necessary, load T.  */
3230   if (T_loaded)
3231   {
3232      /* T is loaded from the result of the last stage of the multiplier.  */
3233      if (cpustate->M[num_mul_stages - 1].stat.mrp)
3234         cpustate->T.d = dbl_last_Mstage_contents;
3235      else
3236         cpustate->T.s = sgl_last_Mstage_contents;
3237   }
3238
3239   /* If necessary, load KR or KI.  */
3240   if (K_loaded)
3241   {
3242      /* KI or KR is loaded from the first register input.  */
3243      if (M_unit_op1 == OP_KI)
3244      {
3245         if (src_prec)
3246            cpustate->KI.d = get_fregval_d (cpustate, fsrc1);
3247         else
3248            cpustate->KI.s   = get_fregval_s (cpustate, fsrc1);
3249      }
3250      else if (M_unit_op1 == OP_KR)
3251      {
3252         if (src_prec)
3253            cpustate->KR.d = get_fregval_d (cpustate, fsrc1);
3254         else
3255            cpustate->KR.s   = get_fregval_s (cpustate, fsrc1);
3256      }
3257      else
3258         assert (0);
3259   }
3260
3261   /* Now update fdest (either from adder pipe or multiplier pipe,
3262       depending on whether the instruction is pfam or pfmam).  */
3263   if (is_pfam)
3264   {
3265      /* Update fdest with the result from the last stage of the
3266           adder pipeline, with precision specified by the ARP
3267           bit of the stage's result-status bits.  */
3268      if (cpustate->A[2].stat.arp)
3269         set_fregval_d (cpustate, fdest, dbl_last_Astage_contents);
3270      else
3271         set_fregval_s (cpustate, fdest, sgl_last_Astage_contents);
3272   }
3273   else
3274   {
3275      /* Update fdest with the result from the last stage of the
3276           multiplier pipeline, with precision specified by the MRP
3277           bit of the stage's result-status bits.  */
3278      if (cpustate->M[num_mul_stages - 1].stat.mrp)
3279         set_fregval_d (cpustate, fdest, dbl_last_Mstage_contents);
3280      else
3281         set_fregval_s (cpustate, fdest, sgl_last_Mstage_contents);
3282   }
3283
3284   /* FIXME: Set result-status bits besides MRP. And copy to fsr from
3285              last stage.  */
3286   /* FIXME: Mixed precision (only wierd for pfmul).  */
3287#if 1 /* FIXME: WIP on FSR update.  This may not be correct.  */
3288   /* Copy 3rd stage MRP to FSR.  */
3289   if (cpustate->M[num_mul_stages - 2   /* 1 */].stat.mrp)
3290      cpustate->cregs[CR_FSR] |= 0x10000000;
3291   else
3292      cpustate->cregs[CR_FSR] &= ~0x10000000;
3293#endif
3294
3295   /* Now advance multiplier pipeline and write current calculation to
3296       first stage.  */
3297   if (num_mul_stages == 3)
3298   {
3299      cpustate->M[2] = cpustate->M[1];
3300      cpustate->M[1] = cpustate->M[0];
3301   }
3302   else
3303      cpustate->M[1]   = cpustate->M[0];
3304
3305   if (res_prec)
3306   {
3307      cpustate->M[0].val.d = dbl_tmp_dest_mul;
3308      cpustate->M[0].stat.mrp = 1;
3309   }
3310   else
3311   {
3312      cpustate->M[0].val.s = sgl_tmp_dest_mul;
3313      cpustate->M[0].stat.mrp = 0;
3314   }
3315
3316   /* FIXME: Set result-status bits besides ARP. And copy to fsr from
3317              last stage.  */
3318#if 1 /* FIXME: WIP on FSR update.  This may not be correct.  */
3319   /* Copy 3rd stage ARP to FSR.  */
3320   if (cpustate->A[1 /* 2 */].stat.arp)
3321      cpustate->cregs[CR_FSR] |= 0x20000000;
3322   else
3323      cpustate->cregs[CR_FSR] &= ~0x20000000;
3324#endif
3325
3326   /* Now advance adder pipeline and write current calculation to
3327       first stage.  */
3328   cpustate->A[2] = cpustate->A[1];
3329   cpustate->A[1] = cpustate->A[0];
3330   if (res_prec)
3331   {
3332      cpustate->A[0].val.d = dbl_tmp_dest_add;
3333      cpustate->A[0].stat.arp = 1;
3334   }
3335   else
3336   {
3337      cpustate->A[0].val.s = sgl_tmp_dest_add;
3338      cpustate->A[0].stat.arp = 0;
3339   }
3340}
3341
3342
3343/* Execute frcp.{ss,sd,dd} fsrc2,fdest (.ds disallowed above).  */
3344static void insn_frcp (i860s *cpustate, UINT32 insn)
3345{
3346   UINT32 fsrc2 = get_fsrc2 (insn);
3347   UINT32 fdest = get_fdest (insn);
3348   int src_prec = insn & 0x100;    /* 1 = double, 0 = single.  */
3349   int res_prec = insn & 0x080;    /* 1 = double, 0 = single.  */
3350
3351   /* Do the operation, being careful about source and result
3352       precision.  */
3353   if (src_prec)
3354   {
3355      double v = get_fregval_d (cpustate, fsrc2);
3356      double res;
3357      if (v == (double)0.0)
3358      {
3359         /* Generate source-exception trap if fsrc2 is 0.  */
3360         if (0 /* && GET_FSR_FTE () */)
3361         {
3362            SET_PSR_FT (1);
3363            SET_FSR_SE (1);
3364            cpustate->pending_trap = GET_FSR_FTE ();
3365         }
3366         /* Set fdest to INF or some other exceptional value here?  */
3367      }
3368      else
3369      {
3370         /* Real i860 isn't a precise as a real divide, but this should
3371               be okay.  */
3372         SET_FSR_SE (0);
3373         *((UINT64 *)&v) &= 0xfffff00000000000ULL;
3374         res = (double)1.0/v;
3375         *((UINT64 *)&res) &= 0xfffff00000000000ULL;
3376         if (res_prec)
3377            set_fregval_d (cpustate, fdest, res);
3378         else
3379            set_fregval_s (cpustate, fdest, (float)res);
3380      }
3381   }
3382   else
3383   {
3384      float v = get_fregval_s (cpustate, fsrc2);
3385      float res;
3386      if (v == 0.0)
3387      {
3388         /* Generate source-exception trap if fsrc2 is 0.  */
3389         if (0 /* GET_FSR_FTE () */)
3390         {
3391            SET_PSR_FT (1);
3392            SET_FSR_SE (1);
3393            cpustate->pending_trap = GET_FSR_FTE ();
3394         }
3395         /* Set fdest to INF or some other exceptional value here?  */
3396      }
3397      else
3398      {
3399         /* Real i860 isn't a precise as a real divide, but this should
3400               be okay.  */
3401         SET_FSR_SE (0);
3402         *((UINT32 *)&v) &= 0xffff8000;
3403         res = (float)1.0/v;
3404         *((UINT32 *)&res) &= 0xffff8000;
3405         if (res_prec)
3406            set_fregval_d (cpustate, fdest, (double)res);
3407         else
3408            set_fregval_s (cpustate, fdest, res);
3409      }
3410   }
3411}
3412
3413
3414/* Execute frsqr.{ss,sd,dd} fsrc2,fdest (.ds disallowed above).  */
3415static void insn_frsqr (i860s *cpustate, UINT32 insn)
3416{
3417   UINT32 fsrc2 = get_fsrc2 (insn);
3418   UINT32 fdest = get_fdest (insn);
3419   int src_prec = insn & 0x100;    /* 1 = double, 0 = single.  */
3420   int res_prec = insn & 0x080;    /* 1 = double, 0 = single.  */
3421
3422   /* Check for invalid .ds combination.  */
3423   if ((insn & 0x180) == 0x100)
3424   {
3425      unrecog_opcode (cpustate->pc, insn);
3426      return;
3427   }
3428
3429   /* Check for invalid .ds combination.  */
3430   if ((insn & 0x180) == 0x100)
3431   {
3432      unrecog_opcode (cpustate->pc, insn);
3433      return;
3434   }
3435
3436   /* Do the operation, being careful about source and result
3437       precision.  */
3438   if (src_prec)
3439   {
3440      double v = get_fregval_d (cpustate, fsrc2);
3441      double res;
3442      if (v == 0.0 || v < 0.0)
3443      {
3444         /* Generate source-exception trap if fsrc2 is 0 or negative.  */
3445         if (0 /* GET_FSR_FTE () */)
3446         {
3447            SET_PSR_FT (1);
3448            SET_FSR_SE (1);
3449            cpustate->pending_trap = GET_FSR_FTE ();
3450         }
3451         /* Set fdest to INF or some other exceptional value here?  */
3452      }
3453      else
3454      {
3455         SET_FSR_SE (0);
3456         *((UINT64 *)&v) &= 0xfffff00000000000ULL;
3457         res = (double)1.0/sqrt (v);
3458         *((UINT64 *)&res) &= 0xfffff00000000000ULL;
3459         if (res_prec)
3460            set_fregval_d (cpustate, fdest, res);
3461         else
3462            set_fregval_s (cpustate, fdest, (float)res);
3463      }
3464   }
3465   else
3466   {
3467      float v = get_fregval_s (cpustate, fsrc2);
3468      float res;
3469      if (v == 0.0 || v < 0.0)
3470      {
3471         /* Generate source-exception trap if fsrc2 is 0 or negative.  */
3472         if (0 /* GET_FSR_FTE () */)
3473         {
3474            SET_PSR_FT (1);
3475            SET_FSR_SE (1);
3476            cpustate->pending_trap = GET_FSR_FTE ();
3477         }
3478         /* Set fdest to INF or some other exceptional value here?  */
3479      }
3480      else
3481      {
3482         SET_FSR_SE (0);
3483         *((UINT32 *)&v) &= 0xffff8000;
3484         res = (float)1.0/sqrt (v);
3485         *((UINT32 *)&res) &= 0xffff8000;
3486         if (res_prec)
3487            set_fregval_d (cpustate, fdest, (double)res);
3488         else
3489            set_fregval_s (cpustate, fdest, res);
3490      }
3491   }
3492}
3493
3494
3495/* Execute fxfr fsrc1,idest.  */
3496static void insn_fxfr (i860s *cpustate, UINT32 insn)
3497{
3498   UINT32 fsrc1 = get_fsrc1 (insn);
3499   UINT32 idest = get_idest (insn);
3500   float fv = 0;
3501
3502   /* This is a bit-pattern transfer, not a conversion.  */
3503   fv = get_fregval_s (cpustate, fsrc1);
3504   set_iregval (idest, *(UINT32 *)&fv);
3505}
3506
3507
3508/* Execute [p]ftrunc.{ss,sd,dd} fsrc1,idest.  */
3509/* FIXME: Is .ss really a valid combination?  On the one hand,
3510   the programmer's reference (1990) lists ftrunc.p where .p
3511   is any of {ss,sd,dd}.  On the other hand, a paragraph on the
3512   same page states that [p]ftrunc must specify double-precision
3513   results.  Inconsistent.
3514   Update: The vendor SVR4 assembler does not accept .ss combination,
3515   so the latter sentence above appears to be the correct way.  */
3516static void insn_ftrunc (i860s *cpustate, UINT32 insn)
3517{
3518   UINT32 fsrc1 = get_fsrc1 (insn);
3519   UINT32 fdest = get_fdest (insn);
3520   int src_prec = insn & 0x100;    /* 1 = double, 0 = single.  */
3521   int res_prec = insn & 0x080;    /* 1 = double, 0 = single.  */
3522   int piped = insn & 0x400;       /* 1 = pipelined, 0 = scalar.  */
3523
3524   /* Check for invalid .ds or .ss combinations.  */
3525   if ((insn & 0x080) == 0)
3526   {
3527      unrecog_opcode (cpustate->pc, insn);
3528      return;
3529   }
3530
3531   /* Do the operation, being careful about source and result
3532       precision.  Operation: fdest = integer part of fsrc1 in
3533       lower 32-bits.  */
3534   if (src_prec)
3535   {
3536      double v1 = get_fregval_d (cpustate, fsrc1);
3537      INT32 iv = (INT32)v1;
3538      /* We always write a single, since the lower 32-bits of fdest
3539           get the result (and the even numbered reg is the lower).  */
3540      set_fregval_s (cpustate, fdest, *(float *)&iv);
3541   }
3542   else
3543   {
3544      float v1 = get_fregval_s (cpustate, fsrc1);
3545      INT32 iv = (INT32)v1;
3546      /* We always write a single, since the lower 32-bits of fdest
3547           get the result (and the even numbered reg is the lower).  */
3548      set_fregval_s (cpustate, fdest, *(float *)&iv);
3549   }
3550
3551   /* FIXME: Handle updating of pipestages for pftrunc.  */
3552   /* Includes looking at ARP (add result precision.) */
3553   if (piped)
3554   {
3555      fprintf (stderr, "insn_ftrunc: FIXME: pipelined not functional yet.\n");
3556      if (res_prec)
3557         set_fregval_d (cpustate, fdest, 0.0);
3558      else
3559         set_fregval_s (cpustate, fdest, 0.0);
3560   }
3561}
3562
3563
3564/* Execute [p]famov.{ss,sd,ds,dd} fsrc1,fdest.  */
3565static void insn_famov (i860s *cpustate, UINT32 insn)
3566{
3567   UINT32 fsrc1 = get_fsrc1 (insn);
3568   UINT32 fdest = get_fdest (insn);
3569   int src_prec = insn & 0x100;    /* 1 = double, 0 = single.  */
3570   int res_prec = insn & 0x080;    /* 1 = double, 0 = single.  */
3571   int piped = insn & 0x400;       /* 1 = pipelined, 0 = scalar.  */
3572   double dbl_tmp_dest = 0.0;
3573   double sgl_tmp_dest = 0.0;
3574
3575   /* Do the operation, being careful about source and result
3576       precision.  */
3577   if (src_prec)
3578   {
3579      double v1 = get_fregval_d (cpustate, fsrc1);
3580      if (res_prec)
3581         dbl_tmp_dest = v1;
3582      else
3583         sgl_tmp_dest = (float)v1;
3584   }
3585   else
3586   {
3587      float v1 = get_fregval_s (cpustate, fsrc1);
3588      if (res_prec)
3589         dbl_tmp_dest = (double)v1;
3590      else
3591         sgl_tmp_dest = v1;
3592   }
3593
3594   /* FIXME: Set result-status bits besides ARP. And copy to fsr from
3595              last stage.  */
3596   /* FIXME: Scalar version flows through all stages.  */
3597   if (!piped)
3598   {
3599      /* Scalar version writes the current calculation to the fdest
3600           register, with precision specified by the R bit.  */
3601      if (res_prec)
3602         set_fregval_d (cpustate, fdest, dbl_tmp_dest);
3603      else
3604         set_fregval_s (cpustate, fdest, sgl_tmp_dest);
3605   }
3606   else
3607   {
3608      /* Pipelined version writes fdest with the result from the last
3609           stage of the pipeline, with precision specified by the ARP
3610           bit of the stage's result-status bits.  */
3611#if 1 /* FIXME: WIP on FSR update.  This may not be correct.  */
3612      /* Copy 3rd stage ARP to FSR.  */
3613      if (cpustate->A[1 /* 2 */].stat.arp)
3614         cpustate->cregs[CR_FSR] |= 0x20000000;
3615      else
3616         cpustate->cregs[CR_FSR] &= ~0x20000000;
3617#endif
3618      if (cpustate->A[2].stat.arp)  /* 3rd (last) stage.  */
3619         set_fregval_d (cpustate, fdest, cpustate->A[2].val.d);
3620      else
3621         set_fregval_s (cpustate, fdest, cpustate->A[2].val.s);
3622
3623      /* Now advance pipeline and write current calculation to
3624           first stage.  */
3625      cpustate->A[2] = cpustate->A[1];
3626      cpustate->A[1] = cpustate->A[0];
3627      if (res_prec)
3628      {
3629         cpustate->A[0].val.d = dbl_tmp_dest;
3630         cpustate->A[0].stat.arp = 1;
3631      }
3632      else
3633      {
3634         cpustate->A[0].val.s = sgl_tmp_dest;
3635         cpustate->A[0].stat.arp = 0;
3636      }
3637   }
3638}
3639
3640
3641/* Execute [p]fiadd/sub.{ss,dd} fsrc1,fsrc2,fdest.  */
3642static void insn_fiadd_sub (i860s *cpustate, UINT32 insn)
3643{
3644   UINT32 fsrc1 = get_fsrc1 (insn);
3645   UINT32 fsrc2 = get_fsrc2 (insn);
3646   UINT32 fdest = get_fdest (insn);
3647   int src_prec = insn & 0x100;    /* 1 = double, 0 = single.  */
3648   int res_prec = insn & 0x080;    /* 1 = double, 0 = single.  */
3649   int piped = insn & 0x400;       /* 1 = pipelined, 0 = scalar.  */
3650   int is_sub = insn & 0x4;       /* 1 = sub, 0 = add.  */
3651   double dbl_tmp_dest = 0.0;
3652   float sgl_tmp_dest = 0.0;
3653
3654   /* Check for invalid .ds and .sd combinations.  */
3655   if ((insn & 0x180) == 0x100
3656      || (insn & 0x180) == 0x080)
3657   {
3658      unrecog_opcode (cpustate->pc, insn);
3659      return;
3660   }
3661
3662   /* Do the operation, being careful about source and result
3663       precision.  */
3664   if (src_prec)
3665   {
3666      double v1 = get_fregval_d (cpustate, fsrc1);
3667      double v2 = get_fregval_d (cpustate, fsrc2);
3668      UINT64 iv1 = *(UINT64 *)&v1;
3669      UINT64 iv2 = *(UINT64 *)&v2;
3670      UINT64 r;
3671      if (is_sub)
3672         r = iv1 - iv2;
3673      else
3674         r = iv1 + iv2;
3675      if (res_prec)
3676         dbl_tmp_dest = *(double *)&r;
3677      else
3678         assert (0);      /* .ds not allowed.  */
3679   }
3680   else
3681   {
3682      float v1 = get_fregval_s (cpustate, fsrc1);
3683      float v2 = get_fregval_s (cpustate, fsrc2);
3684      UINT64 iv1 = (UINT64)(*(UINT32 *)&v1);
3685      UINT64 iv2 = (UINT64)(*(UINT32 *)&v2);
3686      UINT32 r;
3687      if (is_sub)
3688         r = (UINT32)(iv1 - iv2);
3689      else
3690         r = (UINT32)(iv1 + iv2);
3691      if (res_prec)
3692         assert (0);      /* .sd not allowed.  */
3693      else
3694         sgl_tmp_dest = *(float *)&r;
3695   }
3696
3697   /* FIXME: Copy result-status bit IRP to fsr from last stage.  */
3698   /* FIXME: Scalar version flows through all stages.  */
3699   if (!piped)
3700   {
3701      /* Scalar version writes the current calculation to the fdest
3702           register, with precision specified by the R bit.  */
3703      if (res_prec)
3704         set_fregval_d (cpustate, fdest, dbl_tmp_dest);
3705      else
3706         set_fregval_s (cpustate, fdest, sgl_tmp_dest);
3707   }
3708   else
3709   {
3710      /* Pipelined version writes fdest with the result from the last
3711           stage of the pipeline, with precision specified by the IRP
3712           bit of the stage's result-status bits.  */
3713#if 1 /* FIXME: WIP on FSR update.  This may not be correct.  */
3714      /* Copy stage IRP to FSR.  */
3715      if (res_prec)
3716         cpustate->cregs[CR_FSR] |= 0x08000000;
3717      else
3718         cpustate->cregs[CR_FSR] &= ~0x08000000;
3719#endif
3720      if (cpustate->G.stat.irp)   /* 1st (and last) stage.  */
3721         set_fregval_d (cpustate, fdest, cpustate->G.val.d);
3722      else
3723         set_fregval_s (cpustate, fdest, cpustate->G.val.s);
3724
3725      /* Now write current calculation to first and only stage.  */
3726      if (res_prec)
3727      {
3728         cpustate->G.val.d = dbl_tmp_dest;
3729         cpustate->G.stat.irp = 1;
3730      }
3731      else
3732      {
3733         cpustate->G.val.s = sgl_tmp_dest;
3734         cpustate->G.stat.irp = 0;
3735      }
3736   }
3737}
3738
3739
3740/* Execute pf{gt,le,eq}.{ss,dd} fsrc1,fsrc2,fdest.
3741   Opcode pfgt has R bit cleared; pfle has R bit set.  */
3742static void insn_fcmp (i860s *cpustate, UINT32 insn)
3743{
3744   UINT32 fsrc1 = get_fsrc1 (insn);
3745   UINT32 fsrc2 = get_fsrc2 (insn);
3746   UINT32 fdest = get_fdest (insn);
3747   int src_prec = insn & 0x100;    /* 1 = double, 0 = single.  */
3748   double dbl_tmp_dest = 0.0;
3749   double sgl_tmp_dest = 0.0;
3750   /* int is_eq = insn & 1; */
3751   int is_gt = ((insn & 0x81) == 0x00);
3752   int is_le = ((insn & 0x81) == 0x80);
3753
3754   /* Do the operation.  Source and result precision must be the same.
3755         pfgt: CC set     if fsrc1 > fsrc2, else cleared.
3756         pfle: CC cleared if fsrc1 <= fsrc2, else set.
3757         pfeq: CC set     if fsrc1 = fsrc2, else cleared.
3758
3759       Note that the compares write an undefined (but non-exceptional)
3760       result into the first stage of the adder pipeline.  We'll model
3761       this by just pushing in dbl_ or sgl_tmp_dest which equal 0.0.  */
3762   if (src_prec)
3763   {
3764      double v1 = get_fregval_d (cpustate, fsrc1);
3765      double v2 = get_fregval_d (cpustate, fsrc2);
3766      if (is_gt)              /* gt.  */
3767         SET_PSR_CC (v1 > v2 ? 1 : 0);
3768      else if (is_le)           /* le.  */
3769         SET_PSR_CC (v1 <= v2 ? 0 : 1);
3770      else                 /* eq.  */
3771         SET_PSR_CC (v1 == v2 ? 1 : 0);
3772   }
3773   else
3774   {
3775      float v1 = get_fregval_s (cpustate, fsrc1);
3776      float v2 = get_fregval_s (cpustate, fsrc2);
3777      if (is_gt)              /* gt.  */
3778         SET_PSR_CC (v1 > v2 ? 1 : 0);
3779      else if (is_le)           /* le.  */
3780         SET_PSR_CC (v1 <= v2 ? 0 : 1);
3781      else                 /* eq.  */
3782         SET_PSR_CC (v1 == v2 ? 1 : 0);
3783   }
3784
3785   /* FIXME: Set result-status bits besides ARP. And copy to fsr from
3786              last stage.  */
3787   /* These write fdest with the result from the last
3788       stage of the pipeline, with precision specified by the ARP
3789       bit of the stage's result-status bits.  */
3790#if 1 /* FIXME: WIP on FSR update.  This may not be correct.  */
3791   /* Copy 3rd stage ARP to FSR.  */
3792   if (cpustate->A[1 /* 2 */].stat.arp)
3793      cpustate->cregs[CR_FSR] |= 0x20000000;
3794   else
3795      cpustate->cregs[CR_FSR] &= ~0x20000000;
3796#endif
3797   if (cpustate->A[2].stat.arp)  /* 3rd (last) stage.  */
3798      set_fregval_d (cpustate, fdest, cpustate->A[2].val.d);
3799   else
3800      set_fregval_s (cpustate, fdest, cpustate->A[2].val.s);
3801
3802   /* Now advance pipeline and write current calculation to
3803       first stage.  */
3804   cpustate->A[2] = cpustate->A[1];
3805   cpustate->A[1] = cpustate->A[0];
3806   if (src_prec)
3807   {
3808      cpustate->A[0].val.d = dbl_tmp_dest;
3809      cpustate->A[0].stat.arp = 1;
3810   }
3811   else
3812   {
3813      cpustate->A[0].val.s = sgl_tmp_dest;
3814      cpustate->A[0].stat.arp = 0;
3815   }
3816}
3817
3818
3819/* Execute [p]fzchk{l,s} fsrc1,fsrc2,fdest.
3820   The fzchk instructions have S and R bits set.  */
3821static void insn_fzchk (i860s *cpustate, UINT32 insn)
3822{
3823   UINT32 fsrc1 = get_fsrc1 (insn);
3824   UINT32 fsrc2 = get_fsrc2 (insn);
3825   UINT32 fdest = get_fdest (insn);
3826   int piped = insn & 0x400;       /* 1 = pipelined, 0 = scalar.  */
3827   int is_fzchks = insn & 8;       /* 1 = fzchks, 0 = fzchkl.  */
3828   double dbl_tmp_dest = 0.0;
3829   int i;
3830   double v1 = get_fregval_d (cpustate, fsrc1);
3831   double v2 = get_fregval_d (cpustate, fsrc2);
3832   UINT64 iv1 = *(UINT64 *)&v1;
3833   UINT64 iv2 = *(UINT64 *)&v2;
3834   UINT64 r = 0;
3835   char pm = GET_PSR_PM ();
3836
3837   /* Check for S and R bits set.  */
3838   if ((insn & 0x180) != 0x180)
3839   {
3840      unrecog_opcode (cpustate->pc, insn);
3841      return;
3842   }
3843
3844   /* Do the operation.  The fzchks version operates in parallel on
3845       four 16-bit pixels, while the fzchkl operates on two 32-bit
3846       pixels (pixels are unsigned ordinals in this context).  */
3847   if (is_fzchks)
3848   {
3849      pm = (pm >> 4) & 0x0f;
3850      for (i = 3; i >= 0; i--)
3851      {
3852         UINT16 ps1 = (iv1 >> (i * 16)) & 0xffff;
3853         UINT16 ps2 = (iv2 >> (i * 16)) & 0xffff;
3854         if (ps2 <= ps1)
3855         {
3856            r |= ((UINT64)ps2 << (i * 16));
3857            pm |= (1 << (7 - (3 - i)));
3858         }
3859         else
3860         {
3861            r |= ((UINT64)ps1 << (i * 16));
3862            pm &= ~(1 << (7 - (3 - i)));
3863         }
3864      }
3865   }
3866   else
3867   {
3868      pm = (pm >> 2) & 0x3f;
3869      for (i = 1; i >= 0; i--)
3870      {
3871         UINT32 ps1 = (iv1 >> (i * 32)) & 0xffffffff;
3872         UINT32 ps2 = (iv2 >> (i * 32)) & 0xffffffff;
3873         if (ps2 <= ps1)
3874         {
3875            r |= ((UINT64)ps2 << (i * 32));
3876            pm |= (1 << (7 - (1 - i)));
3877         }
3878         else
3879         {
3880            r |= ((UINT64)ps1 << (i * 32));
3881            pm &= ~(1 << (7 - (1 - i)));
3882         }
3883      }
3884   }
3885
3886   dbl_tmp_dest = *(double *)&r;
3887   SET_PSR_PM (pm);
3888   cpustate->merge = 0;
3889
3890   /* FIXME: Copy result-status bit IRP to fsr from last stage.  */
3891   /* FIXME: Scalar version flows through all stages.  */
3892   if (!piped)
3893   {
3894      /* Scalar version writes the current calculation to the fdest
3895           register, always with double precision.  */
3896      set_fregval_d (cpustate, fdest, dbl_tmp_dest);
3897   }
3898   else
3899   {
3900      /* Pipelined version writes fdest with the result from the last
3901           stage of the pipeline, with precision specified by the IRP
3902           bit of the stage's result-status bits.  */
3903      if (cpustate->G.stat.irp)   /* 1st (and last) stage.  */
3904         set_fregval_d (cpustate, fdest, cpustate->G.val.d);
3905      else
3906         set_fregval_s (cpustate, fdest, cpustate->G.val.s);
3907
3908      /* Now write current calculation to first and only stage.  */
3909      cpustate->G.val.d = dbl_tmp_dest;
3910      cpustate->G.stat.irp = 1;
3911   }
3912}
3913
3914
3915/* Execute [p]form.dd fsrc1,fdest.
3916   The form.dd instructions have S and R bits set.  */
3917static void insn_form (i860s *cpustate, UINT32 insn)
3918{
3919   UINT32 fsrc1 = get_fsrc1 (insn);
3920   UINT32 fdest = get_fdest (insn);
3921   int piped = insn & 0x400;       /* 1 = pipelined, 0 = scalar.  */
3922   double dbl_tmp_dest = 0.0;
3923   double v1 = get_fregval_d (cpustate, fsrc1);
3924   UINT64 iv1 = *(UINT64 *)&v1;
3925
3926   /* Check for S and R bits set.  */
3927   if ((insn & 0x180) != 0x180)
3928   {
3929      unrecog_opcode (cpustate->pc, insn);
3930      return;
3931   }
3932
3933   iv1 |= cpustate->merge;
3934   dbl_tmp_dest = *(double *)&iv1;
3935   cpustate->merge = 0;
3936
3937   /* FIXME: Copy result-status bit IRP to fsr from last stage.  */
3938   /* FIXME: Scalar version flows through all stages.  */
3939   if (!piped)
3940   {
3941      /* Scalar version writes the current calculation to the fdest
3942           register, always with double precision.  */
3943      set_fregval_d (cpustate, fdest, dbl_tmp_dest);
3944   }
3945   else
3946   {
3947      /* Pipelined version writes fdest with the result from the last
3948           stage of the pipeline, with precision specified by the IRP
3949           bit of the stage's result-status bits.  */
3950      if (cpustate->G.stat.irp)   /* 1st (and last) stage.  */
3951         set_fregval_d (cpustate, fdest, cpustate->G.val.d);
3952      else
3953         set_fregval_s (cpustate, fdest, cpustate->G.val.s);
3954
3955      /* Now write current calculation to first and only stage.  */
3956      cpustate->G.val.d = dbl_tmp_dest;
3957      cpustate->G.stat.irp = 1;
3958   }
3959}
3960
3961
3962/* Execute [p]faddp fsrc1,fsrc2,fdest.  */
3963static void insn_faddp (i860s *cpustate, UINT32 insn)
3964{
3965   UINT32 fsrc1 = get_fsrc1 (insn);
3966   UINT32 fsrc2 = get_fsrc2 (insn);
3967   UINT32 fdest = get_fdest (insn);
3968   int piped = insn & 0x400;       /* 1 = pipelined, 0 = scalar.  */
3969   double dbl_tmp_dest = 0.0;
3970   double v1 = get_fregval_d (cpustate, fsrc1);
3971   double v2 = get_fregval_d (cpustate, fsrc2);
3972   UINT64 iv1 = *(UINT64 *)&v1;
3973   UINT64 iv2 = *(UINT64 *)&v2;
3974   UINT64 r = 0;
3975   int ps = GET_PSR_PS ();
3976
3977   r = iv1 + iv2;
3978   dbl_tmp_dest = *(double *)&r;
3979
3980   /* Update the merge register depending on the pixel size.
3981       PS: 0 = 8 bits, 1 = 16 bits, 2 = 32-bits.  */
3982   if (ps == 0)
3983   {
3984      cpustate->merge = ((cpustate->merge >> 8) & ~0xff00ff00ff00ff00ULL);
3985      cpustate->merge |= (r & 0xff00ff00ff00ff00ULL);
3986   }
3987   else if (ps == 1)
3988   {
3989      cpustate->merge = ((cpustate->merge >> 6) & ~0xfc00fc00fc00fc00ULL);
3990      cpustate->merge |= (r & 0xfc00fc00fc00fc00ULL);
3991   }
3992   else if (ps == 2)
3993   {
3994      cpustate->merge = ((cpustate->merge >> 8) & ~0xff000000ff000000ULL);
3995      cpustate->merge |= (r & 0xff000000ff000000ULL);
3996   }
3997#ifdef TRACE_UNDEFINED_I860
3998   else
3999      fprintf   (stderr, "insn_faddp: Undefined i860XR behavior, invalid value %d for pixel size.\n", ps);
4000#endif
4001
4002   /* FIXME: Copy result-status bit IRP to fsr from last stage.  */
4003   /* FIXME: Scalar version flows through all stages.  */
4004   if (!piped)
4005   {
4006      /* Scalar version writes the current calculation to the fdest
4007           register, always with double precision.  */
4008      set_fregval_d (cpustate, fdest, dbl_tmp_dest);
4009   }
4010   else
4011   {
4012      /* Pipelined version writes fdest with the result from the last
4013           stage of the pipeline, with precision specified by the IRP
4014           bit of the stage's result-status bits.  */
4015      if (cpustate->G.stat.irp)   /* 1st (and last) stage.  */
4016         set_fregval_d (cpustate, fdest, cpustate->G.val.d);
4017      else
4018         set_fregval_s (cpustate, fdest, cpustate->G.val.s);
4019
4020      /* Now write current calculation to first and only stage.  */
4021      cpustate->G.val.d = dbl_tmp_dest;
4022      cpustate->G.stat.irp = 1;
4023   }
4024}
4025
4026
4027/* Execute [p]faddz fsrc1,fsrc2,fdest.  */
4028static void insn_faddz (i860s *cpustate, UINT32 insn)
4029{
4030   UINT32 fsrc1 = get_fsrc1 (insn);
4031   UINT32 fsrc2 = get_fsrc2 (insn);
4032   UINT32 fdest = get_fdest (insn);
4033   int piped = insn & 0x400;       /* 1 = pipelined, 0 = scalar.  */
4034   double dbl_tmp_dest = 0.0;
4035   double v1 = get_fregval_d (cpustate, fsrc1);
4036   double v2 = get_fregval_d (cpustate, fsrc2);
4037   UINT64 iv1 = *(UINT64 *)&v1;
4038   UINT64 iv2 = *(UINT64 *)&v2;
4039   UINT64 r = 0;
4040
4041   r = iv1 + iv2;
4042   dbl_tmp_dest = *(double *)&r;
4043
4044   /* Update the merge register depending on the pixel size.  */
4045   cpustate->merge = ((cpustate->merge >> 16) & ~0xffff0000ffff0000ULL);
4046   cpustate->merge |= (r & 0xffff0000ffff0000ULL);
4047
4048   /* FIXME: Copy result-status bit IRP to fsr from last stage.  */
4049   /* FIXME: Scalar version flows through all stages.  */
4050   if (!piped)
4051   {
4052      /* Scalar version writes the current calculation to the fdest
4053           register, always with double precision.  */
4054      set_fregval_d (cpustate, fdest, dbl_tmp_dest);
4055   }
4056   else
4057   {
4058      /* Pipelined version writes fdest with the result from the last
4059           stage of the pipeline, with precision specified by the IRP
4060           bit of the stage's result-status bits.  */
4061      if (cpustate->G.stat.irp)   /* 1st (and last) stage.  */
4062         set_fregval_d (cpustate, fdest, cpustate->G.val.d);
4063      else
4064         set_fregval_s (cpustate, fdest, cpustate->G.val.s);
4065
4066      /* Now write current calculation to first and only stage.  */
4067      cpustate->G.val.d = dbl_tmp_dest;
4068      cpustate->G.stat.irp = 1;
4069   }
4070}
4071
4072
4073/* Flags for the decode table.  */
4074enum {
4075   DEC_MORE    = 1,    /* More decoding necessary.  */
4076   DEC_DECODED = 2     /* Fully decoded, go.  */
4077};
4078
4079
4080typedef struct {
4081   /* Execute function for this opcode.  */
4082   void (*insn_exec)(i860s *, UINT32);
4083
4084   /* Flags for this opcode.  */
4085   char flags;
4086} decode_tbl_t;
4087
4088
4089/* First-level decode table (i.e., for the 6 primary opcode bits).  */
4090static decode_tbl_t decode_tbl[64] = {
4091   /* A slight bit of decoding for loads and stores is done in the
4092       execution routines (operand size and addressing mode), which
4093       is why their respective entries are identical.  */
4094   { insn_ldx,         DEC_DECODED}, /* ld.b isrc1(isrc2),idest.  */
4095   { insn_ldx,         DEC_DECODED}, /* ld.b #const(isrc2),idest.  */
4096   { insn_ixfr,        DEC_DECODED}, /* ixfr isrc1ni,fdest.  */
4097   { insn_stx,         DEC_DECODED}, /* st.b isrc1ni,#const(isrc2).  */
4098   { insn_ldx,         DEC_DECODED}, /* ld.{s,l} isrc1(isrc2),idest.  */
4099   { insn_ldx,         DEC_DECODED}, /* ld.{s,l} #const(isrc2),idest.  */
4100   { 0,                0},
4101   { insn_stx,         DEC_DECODED}, /* st.{s,l} isrc1ni,#const(isrc2),idest.*/
4102   { insn_fldy,        DEC_DECODED}, /* fld.{l,d,q} isrc1(isrc2)[++],fdest. */
4103   { insn_fldy,        DEC_DECODED}, /* fld.{l,d,q} #const(isrc2)[++],fdest. */
4104   { insn_fsty,        DEC_DECODED}, /* fst.{l,d,q} fdest,isrc1(isrc2)[++] */
4105   { insn_fsty,        DEC_DECODED}, /* fst.{l,d,q} fdest,#const(isrc2)[++] */
4106   { insn_ld_ctrl,     DEC_DECODED}, /* ld.c csrc2,idest.  */
4107   { insn_flush,       DEC_DECODED}, /* flush #const(isrc2) (or autoinc).  */
4108   { insn_st_ctrl,     DEC_DECODED}, /* st.c isrc1,csrc2.  */
4109   { insn_pstd,        DEC_DECODED}, /* pst.d fdest,#const(isrc2)[++].  */
4110   { insn_bri,         DEC_DECODED}, /* bri isrc1ni.  */
4111   { insn_trap,        DEC_DECODED}, /* trap isrc1ni,isrc2,idest.   */
4112   { 0,                DEC_MORE}, /* FP ESCAPE FORMAT, more decode.  */
4113   { 0,                DEC_MORE}, /* CORE ESCAPE FORMAT, more decode.  */
4114   { insn_btne,        DEC_DECODED}, /* btne isrc1,isrc2,sbroff.  */
4115   { insn_btne_imm,    DEC_DECODED}, /* btne #const,isrc2,sbroff.  */
4116   { insn_bte,         DEC_DECODED}, /* bte isrc1,isrc2,sbroff.  */
4117   { insn_bte_imm,     DEC_DECODED}, /* bte #const5,isrc2,idest.  */
4118   { insn_fldy,        DEC_DECODED}, /* pfld.{l,d,q} isrc1(isrc2)[++],fdest.*/
4119   { insn_fldy,        DEC_DECODED}, /* pfld.{l,d,q} #const(isrc2)[++],fdest.*/
4120   { insn_br,          DEC_DECODED}, /* br lbroff.  */
4121   { insn_call,        DEC_DECODED}, /* call lbroff .  */
4122   { insn_bc,          DEC_DECODED}, /* bc lbroff.  */
4123   { insn_bct,         DEC_DECODED}, /* bc.t lbroff.  */
4124   { insn_bnc,         DEC_DECODED}, /* bnc lbroff.  */
4125   { insn_bnct,        DEC_DECODED}, /* bnc.t lbroff.  */
4126   { insn_addu,        DEC_DECODED}, /* addu isrc1,isrc2,idest.  */
4127   { insn_addu_imm,    DEC_DECODED}, /* addu #const,isrc2,idest.  */
4128   { insn_subu,        DEC_DECODED}, /* subu isrc1,isrc2,idest.  */
4129   { insn_subu_imm,    DEC_DECODED}, /* subu #const,isrc2,idest.  */
4130   { insn_adds,        DEC_DECODED}, /* adds isrc1,isrc2,idest.  */
4131   { insn_adds_imm,    DEC_DECODED}, /* adds #const,isrc2,idest.  */
4132   { insn_subs,        DEC_DECODED}, /* subs isrc1,isrc2,idest.  */
4133   { insn_subs_imm,    DEC_DECODED}, /* subs #const,isrc2,idest.  */
4134   { insn_shl,         DEC_DECODED}, /* shl isrc1,isrc2,idest.  */
4135   { insn_shl_imm,     DEC_DECODED}, /* shl #const,isrc2,idest.  */
4136   { insn_shr,         DEC_DECODED}, /* shr isrc1,isrc2,idest.  */
4137   { insn_shr_imm,     DEC_DECODED}, /* shr #const,isrc2,idest.  */
4138   { insn_shrd,        DEC_DECODED}, /* shrd isrc1ni,isrc2,idest.  */
4139   { insn_bla,         DEC_DECODED}, /* bla isrc1ni,isrc2,sbroff.  */
4140   { insn_shra,        DEC_DECODED}, /* shra isrc1,isrc2,idest.  */
4141   { insn_shra_imm,    DEC_DECODED}, /* shra #const,isrc2,idest.  */
4142   { insn_and,         DEC_DECODED}, /* and isrc1,isrc2,idest.  */
4143   { insn_and_imm,     DEC_DECODED}, /* and #const,isrc2,idest.  */
4144   { 0,                0},
4145   { insn_andh_imm,    DEC_DECODED}, /* andh #const,isrc2,idest.  */
4146   { insn_andnot,      DEC_DECODED}, /* andnot isrc1,isrc2,idest.  */
4147   { insn_andnot_imm,  DEC_DECODED}, /* andnot #const,isrc2,idest.  */
4148   { 0,                0},
4149   { insn_andnoth_imm, DEC_DECODED}, /* andnoth #const,isrc2,idest.  */
4150   { insn_or,          DEC_DECODED}, /* or isrc1,isrc2,idest.  */
4151   { insn_or_imm,      DEC_DECODED}, /* or #const,isrc2,idest.  */
4152   { 0,                0},
4153   { insn_orh_imm,     DEC_DECODED}, /* orh #const,isrc2,idest.  */
4154   { insn_xor,         DEC_DECODED}, /* xor isrc1,isrc2,idest.  */
4155   { insn_xor_imm,     DEC_DECODED}, /* xor #const,isrc2,idest.  */
4156   { 0,                0},
4157   { insn_xorh_imm,    DEC_DECODED}, /* xorh #const,isrc2,idest.  */
4158};
4159
4160
4161/* Second-level decode table (i.e., for the 3 core escape opcode bits).  */
4162static decode_tbl_t core_esc_decode_tbl[8] = {
4163   { 0,                0},
4164   { 0,                0},   /* lock  (FIXME: unimplemented).  */
4165   { insn_calli,       DEC_DECODED}, /* calli isrc1ni.                 */
4166   { 0,                0},
4167   { insn_intovr,      DEC_DECODED}, /* intovr.                        */
4168   { 0,                0},
4169   { 0,                0},
4170   { 0,                0},   /* unlock (FIXME: unimplemented). */
4171};
4172
4173
4174/* Second-level decode table (i.e., for the 7 FP extended opcode bits).  */
4175static decode_tbl_t fp_decode_tbl[128] = {
4176   /* Floating point instructions.  The least significant 7 bits are
4177       the (extended) opcode and bits 10:7 are P,D,S,R respectively
4178       ([p]ipelined, [d]ual, [s]ource prec., [r]esult prec.).
4179       For some operations, I defer decoding the P,S,R bits to the
4180       emulation routine for them.  */
4181   { insn_dualop,      DEC_DECODED}, /* 0x00 pf[m]am */
4182   { insn_dualop,      DEC_DECODED}, /* 0x01 pf[m]am */
4183   { insn_dualop,      DEC_DECODED}, /* 0x02 pf[m]am */
4184   { insn_dualop,      DEC_DECODED}, /* 0x03 pf[m]am */
4185   { insn_dualop,      DEC_DECODED}, /* 0x04 pf[m]am */
4186   { insn_dualop,      DEC_DECODED}, /* 0x05 pf[m]am */
4187   { insn_dualop,      DEC_DECODED}, /* 0x06 pf[m]am */
4188   { insn_dualop,      DEC_DECODED}, /* 0x07 pf[m]am */
4189   { insn_dualop,      DEC_DECODED}, /* 0x08 pf[m]am */
4190   { insn_dualop,      DEC_DECODED}, /* 0x09 pf[m]am */
4191   { insn_dualop,      DEC_DECODED}, /* 0x0A pf[m]am */
4192   { insn_dualop,      DEC_DECODED}, /* 0x0B pf[m]am */
4193   { insn_dualop,      DEC_DECODED}, /* 0x0C pf[m]am */
4194   { insn_dualop,      DEC_DECODED}, /* 0x0D pf[m]am */
4195   { insn_dualop,      DEC_DECODED}, /* 0x0E pf[m]am */
4196   { insn_dualop,      DEC_DECODED}, /* 0x0F pf[m]am */
4197   { insn_dualop,      DEC_DECODED}, /* 0x10 pf[m]sm */
4198   { insn_dualop,      DEC_DECODED}, /* 0x11 pf[m]sm */
4199   { insn_dualop,      DEC_DECODED}, /* 0x12 pf[m]sm */
4200   { insn_dualop,      DEC_DECODED}, /* 0x13 pf[m]sm */
4201   { insn_dualop,      DEC_DECODED}, /* 0x14 pf[m]sm */
4202   { insn_dualop,      DEC_DECODED}, /* 0x15 pf[m]sm */
4203   { insn_dualop,      DEC_DECODED}, /* 0x16 pf[m]sm */
4204   { insn_dualop,      DEC_DECODED}, /* 0x17 pf[m]sm */
4205   { insn_dualop,      DEC_DECODED}, /* 0x18 pf[m]sm */
4206   { insn_dualop,      DEC_DECODED}, /* 0x19 pf[m]sm */
4207   { insn_dualop,      DEC_DECODED}, /* 0x1A pf[m]sm */
4208   { insn_dualop,      DEC_DECODED}, /* 0x1B pf[m]sm */
4209   { insn_dualop,      DEC_DECODED}, /* 0x1C pf[m]sm */
4210   { insn_dualop,      DEC_DECODED}, /* 0x1D pf[m]sm */
4211   { insn_dualop,      DEC_DECODED}, /* 0x1E pf[m]sm */
4212   { insn_dualop,      DEC_DECODED}, /* 0x1F pf[m]sm */
4213   { insn_fmul,        DEC_DECODED}, /* 0x20 [p]fmul */
4214   { insn_fmlow,       DEC_DECODED}, /* 0x21 fmlow.dd */
4215   { insn_frcp,        DEC_DECODED}, /* 0x22 frcp.{ss,sd,dd} */
4216   { insn_frsqr,       DEC_DECODED}, /* 0x23 frsqr.{ss,sd,dd} */
4217   { insn_fmul,        DEC_DECODED}, /* 0x24 pfmul3.dd */
4218   { 0,                0},   /* 0x25 */
4219   { 0,                0},   /* 0x26 */
4220   { 0,                0},   /* 0x27 */
4221   { 0,                0},   /* 0x28 */
4222   { 0,                0},   /* 0x29 */
4223   { 0,                0},   /* 0x2A */
4224   { 0,                0},   /* 0x2B */
4225   { 0,                0},   /* 0x2C */
4226   { 0,                0},   /* 0x2D */
4227   { 0,                0},   /* 0x2E */
4228   { 0,                0},   /* 0x2F */
4229   { insn_fadd_sub,    DEC_DECODED}, /* 0x30, [p]fadd.{ss,sd,dd} */
4230   { insn_fadd_sub,    DEC_DECODED}, /* 0x31, [p]fsub.{ss,sd,dd} */
4231   { 0,                0},   /* 0x32, [p]fix.{ss,sd,dd}  FIXME: nyi. */
4232   { insn_famov,       DEC_DECODED}, /* 0x33, [p]famov.{ss,sd,ds,dd} */
4233   { insn_fcmp,        DEC_DECODED}, /* 0x34, pf{gt,le}.{ss,dd} */
4234   { insn_fcmp,        DEC_DECODED}, /* 0x35, pfeq.{ss,dd} */
4235   { 0,                0},   /* 0x36 */
4236   { 0,                0},   /* 0x37 */
4237   { 0,                0},   /* 0x38 */
4238   { 0,                0},   /* 0x39 */
4239   { insn_ftrunc,      DEC_DECODED}, /* 0x3A, [p]ftrunc.{ss,sd,dd} */
4240   { 0,                0},   /* 0x3B */
4241   { 0,                0},   /* 0x3C */
4242   { 0,                0},   /* 0x3D */
4243   { 0,                0},   /* 0x3E */
4244   { 0,                0},   /* 0x3F */
4245   { insn_fxfr,        DEC_DECODED}, /* 0x40, fxfr */
4246   { 0,                0},   /* 0x41 */
4247   { 0,                0},   /* 0x42 */
4248   { 0,                0},   /* 0x43 */
4249   { 0,                0},   /* 0x44 */
4250   { 0,                0},   /* 0x45 */
4251   { 0,                0},   /* 0x46 */
4252   { 0,                0},   /* 0x47 */
4253   { 0,                0},   /* 0x48 */
4254   { insn_fiadd_sub,   DEC_DECODED}, /* 0x49, [p]fiadd.{ss,dd} */
4255   { 0,                0},   /* 0x4A */
4256   { 0,                0},   /* 0x4B */
4257   { 0,                0},   /* 0x4C */
4258   { insn_fiadd_sub,   DEC_DECODED}, /* 0x4D, [p]fisub.{ss,dd} */
4259   { 0,                0},   /* 0x4E */
4260   { 0,                0},   /* 0x4F */
4261   { insn_faddp,       DEC_DECODED}, /* 0x50, [p]faddp */
4262   { insn_faddz,       DEC_DECODED}, /* 0x51, [p]faddz */
4263   { 0,                0},   /* 0x52 */
4264   { 0,                0},   /* 0x53 */
4265   { 0,                0},   /* 0x54 */
4266   { 0,                0},   /* 0x55 */
4267   { 0,                0},   /* 0x56 */
4268   { insn_fzchk,       DEC_DECODED}, /* 0x57, [p]fzchkl */
4269   { 0,                0},   /* 0x58 */
4270   { 0,                0},   /* 0x59 */
4271   { insn_form,        DEC_DECODED}, /* 0x5A, [p]form.dd */
4272   { 0,                0},   /* 0x5B */
4273   { 0,                0},   /* 0x5C */
4274   { 0,                0},   /* 0x5D */
4275   { 0,                0},   /* 0x5E */
4276   { insn_fzchk,       DEC_DECODED}, /* 0x5F, [p]fzchks */
4277   { 0,                0},   /* 0x60 */
4278   { 0,                0},   /* 0x61 */
4279   { 0,                0},   /* 0x62 */
4280   { 0,                0},   /* 0x63 */
4281   { 0,                0},   /* 0x64 */
4282   { 0,                0},   /* 0x65 */
4283   { 0,                0},   /* 0x66 */
4284   { 0,                0},   /* 0x67 */
4285   { 0,                0},   /* 0x68 */
4286   { 0,                0},   /* 0x69 */
4287   { 0,                0},   /* 0x6A */
4288   { 0,                0},   /* 0x6B */
4289   { 0,                0},   /* 0x6C */
4290   { 0,                0},   /* 0x6D */
4291   { 0,                0},   /* 0x6E */
4292   { 0,                0},   /* 0x6F */
4293   { 0,                0},   /* 0x70 */
4294   { 0,                0},   /* 0x71 */
4295   { 0,                0},   /* 0x72 */
4296   { 0,                0},   /* 0x73 */
4297   { 0,                0},   /* 0x74 */
4298   { 0,                0},   /* 0x75 */
4299   { 0,                0},   /* 0x76 */
4300   { 0,                0},   /* 0x77 */
4301   { 0,                0},   /* 0x78 */
4302   { 0,                0},   /* 0x79 */
4303   { 0,                0},   /* 0x7A */
4304   { 0,                0},   /* 0x7B */
4305   { 0,                0},   /* 0x7C */
4306   { 0,                0},   /* 0x7D */
4307   { 0,                0},   /* 0x7E */
4308   { 0,                0},   /* 0x7F */
4309};
4310
4311
4312/*
4313 * Main decoder driver.
4314 *  insn = instruction at the current PC to execute.
4315 *  non_shadow = This insn is not in the shadow of a delayed branch).
4316 */
4317static void decode_exec (i860s *cpustate, UINT32 insn, UINT32 non_shadow)
4318{
4319   int upper_6bits = (insn >> 26) & 0x3f;
4320   char flags = 0;
4321   int unrecognized = 1;
4322
4323   if (cpustate->exiting_ifetch)
4324      return;
4325
4326   if ((upper_6bits == 0x12 || upper_6bits == 0x2c) && insn & 0x0200)
4327      logerror("D-bit seen.\n");
4328   if (GET_EPSR_BE ())
4329      logerror("BE-bit high.\n");
4330   if (GET_DIRBASE_CS8 ())
4331      logerror("CS8-bit high.\n");
4332
4333   flags = decode_tbl[upper_6bits].flags;
4334   if (flags & DEC_DECODED)
4335   {
4336      decode_tbl[upper_6bits].insn_exec (cpustate, insn);
4337      unrecognized = 0;
4338   }
4339   else if (flags & DEC_MORE)
4340   {
4341      if (upper_6bits == 0x12)
4342      {
4343         /* FP instruction format handled here.  */
4344         char fp_flags = fp_decode_tbl[insn & 0x7f].flags;
4345         if (fp_flags & DEC_DECODED)
4346         {
4347            fp_decode_tbl[insn & 0x7f].insn_exec (cpustate, insn);
4348            unrecognized = 0;
4349         }
4350      }
4351      else if (upper_6bits == 0x13)
4352      {
4353         /* Core escape instruction format handled here.  */
4354         char esc_flags = core_esc_decode_tbl[insn & 0x3].flags;
4355         if (esc_flags & DEC_DECODED)
4356         {
4357            core_esc_decode_tbl[insn & 0x3].insn_exec (cpustate, insn);
4358            unrecognized = 0;
4359         }
4360      }
4361   }
4362
4363   if (unrecognized)
4364      unrecog_opcode (cpustate->pc, insn);
4365
4366   /* For now, just treat every instruction as taking the same number of
4367       clocks-- a major oversimplification.  */
4368   cpustate->icount -= 9;
4369}
4370
4371
4372/* Set-up all the default power-on/reset values.  */
4373void reset_i860 (i860s *cpustate)
4374{
4375   int i;
4376   /* On power-up/reset, i860 has values:
4377         PC = 0xffffff00.
4378         Integer registers: r0 = 0, others = undefined.
4379         FP registers:      f0:f1 = 0, others undefined.
4380         psr: U = IM = BR = BW = 0; others = undefined.
4381         epsr: IL = WP = PBM = BE = 0; processor type, stepping, and
4382               DCS are proper and read-only; others = undefined.
4383         db: undefined.
4384         dirbase: DPS, BL, ATE = 0
4385         fir, fsr, KR, KI, MERGE: undefined. (what about T?)
4386
4387         I$: flushed.
4388         D$: undefined (all modified bits = 0).
4389         TLB: flushed.
4390
4391       Note that any undefined values are set to 0x55aa55aa patterns to
4392       try to detect defective i860 software.  */
4393
4394   /* PC is at trap address after reset.  */
4395   cpustate->pc = 0xffffff00;
4396
4397   /* Set grs and frs to undefined/nonsense values, except r0.  */
4398   for (i = 0; i < 32; i++)
4399   {
4400      set_iregval (i, 0x55aa55aa);
4401      set_fregval_s (cpustate, i, 0.0);
4402   }
4403   set_iregval (0, 0);
4404   set_fregval_s (cpustate, 0, 0.0);
4405   set_fregval_s (cpustate, 1, 0.0);
4406
4407   /* Set whole psr to 0.  This sets the proper bits to 0 as specified
4408       above, and zeroes the undefined bits.  */
4409   cpustate->cregs[CR_PSR] = 0;
4410
4411   /* Set most of the epsr bits to 0 (as specified above), leaving
4412       undefined as zero as well.  Then properly set processor type,
4413       step, and DCS. Type = EPSR[7..0], step = EPSR[12..8],
4414       DCS = EPSR[21..18] (2^[12+dcs] = cache size).
4415       We'll pretend to be stepping D0, since it has the fewest bugs
4416       (and I don't want to emulate the many defects in the earlier
4417       steppings).
4418       Proc type: 1 = XR, 2 = XP   (XR has 8KB data cache -> DCS = 1).
4419       Steppings (XR): 3,4,5,6,7 = (B2, C0, B3, C1, D0 respectively).
4420       Steppings (XP): 0, 2, 3, 4 = (A0, B0, B1, B2) (any others?).  */
4421   cpustate->cregs[CR_EPSR] = 0x00040701;
4422
4423   /* Set DPS, BL, ATE = 0 and the undefined parts also to 0.  */
4424   cpustate->cregs[CR_DIRBASE] = 0x00000000;
4425
4426   /* Set fir, fsr, KR, KI, MERGE, T to undefined.  */
4427   cpustate->cregs[CR_FIR] = 0xaa55aa55;
4428   cpustate->cregs[CR_FSR] = /* 0xaa55aa55; */ 0;
4429   cpustate->KR.d = 0.0;
4430   cpustate->KI.d = 0.0;
4431   cpustate->T.d = 0.0;
4432   cpustate->merge = 0xaa55aa55;
4433
4434   cpustate->fir_gets_trap_addr = 0;
4435}
4436
4437
4438
4439
4440/*=================================================================*/
4441/* MAME execution hook for i860 emulator. */
4442/*=================================================================*/
4443
4444#include "cpuintrf.h"
4445
4446static CPU_EXECUTE( i860 )
4447{
4448   i860_state_t *cpustate = device->token;
4449
4450   /* Check if the data bus is held by another device, and bail if so.
4451       Also check for reset.  */
4452   if (cpustate->pin_reset)
4453      reset_i860 (cpustate);
4454   if (cpustate->pin_bus_hold)
4455      return cycles;
4456
4457   cpustate->exiting_readmem = 0;
4458   cpustate->exiting_ifetch = 0;
4459   cpustate->icount = cycles;
4460
4461   /* Decode and execute loop.  */
4462   while (cpustate->icount > 0)
4463   {
4464      UINT32 savepc = cpustate->pc;
4465      cpustate->pc_updated = 0;
4466      cpustate->pending_trap = 0;
4467
4468#if 1 /* Delete me soon, for debugging VC inter-processor synch.  */
4469      if (cpustate->pc == 0xfffc0370 ||
4470         cpustate->pc == 0xfffc03a4)
4471      {
4472         fprintf(stderr, "(%s) 0x%08x: snag 0x20000000\n", cpustate->device->tag, cpustate->pc);
4473         cpustate->single_stepping = 0;
4474      }
4475      else if (cpustate->pc == 0xfffc0384 ||
4476             cpustate->pc == 0xfffc03b8)
4477      {
4478         fprintf(stderr, "(%s) 0x%08x: passed 0x20000000\n", cpustate->device->tag, cpustate->pc);
4479         cpustate->single_stepping = 0;
4480      }
4481#endif
4482
4483      savepc = cpustate->pc;
4484        debugger_instruction_hook(cpustate->device, cpustate->pc);
4485      decode_exec (cpustate, ifetch (cpustate, cpustate->pc), 1);
4486
4487      cpustate->exiting_ifetch = 0;
4488      cpustate->exiting_readmem = 0;
4489
4490      if (cpustate->pending_trap)
4491      {
4492         /* If we need to trap, change PC to trap address.
4493               Also set supervisor mode, copy U and IM to their
4494               previous versions, clear IM.  */
4495         if ((cpustate->pending_trap & TRAP_WAS_EXTERNAL) || (GET_EPSR_INT () && GET_PSR_IN ()))
4496         {
4497            if (!cpustate->pc_updated)
4498               cpustate->cregs[CR_FIR] = savepc + 4;
4499            else
4500               cpustate->cregs[CR_FIR] = cpustate->pc;
4501         }
4502         else if (cpustate->pending_trap & TRAP_IN_DELAY_SLOT)
4503         {
4504            cpustate->cregs[CR_FIR] = savepc + 4;
4505         }
4506         else
4507            cpustate->cregs[CR_FIR] = savepc;
4508
4509         cpustate->fir_gets_trap_addr = 1;
4510         SET_PSR_PU (GET_PSR_U ());
4511         SET_PSR_PIM (GET_PSR_IM ());
4512         SET_PSR_U (0);
4513         SET_PSR_IM (0);
4514         SET_PSR_DIM (0);
4515         SET_PSR_DS (0);
4516         cpustate->pc = 0xffffff00;
4517         cpustate->pending_trap = 0;
4518      }
4519      else if (!cpustate->pc_updated)
4520      {
4521         /* If the PC wasn't updated by a control flow instruction, just
4522               bump to next sequential instruction.  */
4523         cpustate->pc += 4;
4524      }
4525
4526      /*if (cpustate->single_stepping)
4527            debugger (cpustate); */
4528   }
4529
4530   return cycles - cpustate->icount;
4531}
4532/*=================================================================*/
4533
4534
4535
4536
4537#if 0
4538/*=================================================================*/
4539/* Internal debugger-related stuff.  */
4540
4541extern unsigned disasm_i860 (char *buf, unsigned int pc, unsigned int insn);
4542
4543
4544/* Disassemble `len' instructions starting at `addr'.  */
4545static void disasm (i860s *cpustate, UINT32 addr, int len)
4546{
4547   UINT32 insn;
4548   int j;
4549   for (j = 0; j < len; j++)
4550   {
4551      char buf[256];
4552      UINT32 phys_addr = addr;
4553      if (GET_DIRBASE_ATE ())
4554         phys_addr = get_address_translation (cpustate, addr, 1   /* is_dataref */, 0   /* is_write */);
4555
4556      /* Note that we print the incoming (possibly virtual) address as the
4557           PC rather than the translated address.  */
4558      fprintf (stderr, "  (%s) 0x%08x: ", cpustate->device->tag, addr);
4559      insn = memory_read_dword_64le(cpustate->program, phys_addr);
4560#ifdef HOST_MSB
4561      BYTE_REV32 (insn);
4562#endif /* HOST_MSB.  */
4563      disasm_i860 (buf, addr, insn); fprintf (stderr, "%s", buf);
4564      fprintf (stderr, "\n");
4565      addr += 4;
4566#if 1
4567      if (cpustate->single_stepping == 1 && has_delay_slot (insn))
4568         len += 1;
4569#endif
4570   }
4571}
4572
4573
4574/* Dump `len' bytes starting at `addr'.  */
4575static void dbg_db (i860s *cpustate, UINT32 addr, int len)
4576{
4577   UINT8 b[16];
4578   int i;
4579   /* This will always dump a multiple of 16 bytes, even if 'len' isn't.  */
4580   while (len > 0)
4581   {
4582      /* Note that we print the incoming (possibly virtual) address
4583           rather than the translated address.  */
4584      fprintf (stderr, "0x%08x: ", addr);
4585      for (i = 0; i < 16; i++)
4586      {
4587         UINT32 phys_addr = addr;
4588         if (GET_DIRBASE_ATE ())
4589            phys_addr = get_address_translation (cpustate, addr, 1   /* is_dataref */, 0   /* is_write */);
4590
4591         b[i] = memory_read_byte_64le(cpustate->program, phys_addr);
4592         fprintf (stderr, "%02x ", b[i]);
4593         addr++;
4594      }
4595      fprintf (stderr, "| ");
4596      for (i = 0; i < 16; i++)
4597      {
4598         if (isprint (b[i]))
4599            fprintf (stderr, "%c", b[i]);
4600         else
4601            fprintf   (stderr, ".");
4602      }
4603      fprintf (stderr, "\n");
4604      len -= 16;
4605   }
4606}
4607
4608
4609/* A simple internal debugger.  */
4610void debugger (i860s *cpustate)
4611{
4612   char buf[256];
4613   UINT32 curr_disasm = cpustate->pc;
4614   UINT32 curr_dumpdb = 0;
4615   int c = 0;
4616
4617   if (cpustate->single_stepping > 1 && cpustate->single_stepping != cpustate->pc)
4618      return;
4619
4620   buf[0] = 0;
4621
4622   /* Always disassemble the upcoming instruction when single-stepping.  */
4623   if (cpustate->single_stepping)
4624   {
4625      disasm (cpustate, cpustate->pc, 1);
4626      if (has_delay_slot (2))
4627         disasm (cpustate, cpustate->pc + 4, 1);
4628   }
4629   else
4630      fprintf   (stderr, "\nEmulator: internal debugger started (? for help).\n");
4631
4632   fflush (stdin);
4633
4634   cpustate->single_stepping = 0;
4635   while (!cpustate->single_stepping)
4636   {
4637      fprintf (stderr, "- ");
4638#if 0  /* Doesn't work on MacOSX BSD flavor.  */
4639      fscanf (stdin, "%s", buf);
4640#else
4641      while (1)
4642      {
4643         char it = 0;
4644         if (read(STDIN_FILENO, &it, 1) == 1)
4645         {
4646            if (it == '\n')
4647            {
4648               buf[c] = 0;
4649               c = 0;
4650               break;
4651            }
4652            buf[c++] = it;
4653         }
4654      }
4655#endif
4656      if (buf[0] == 'g')
4657      {
4658         if (buf[1] == '0')
4659            sscanf (buf + 1, "%x", &cpustate->single_stepping);
4660         else
4661            break;
4662         buf[1] = 0;
4663         fprintf (stderr, "go until pc = 0x%08x.\n",
4664                cpustate->single_stepping);
4665         cpustate->single_stepping = 0;     /* HACK */
4666      }
4667      else if (buf[0] == 'r')
4668         dump_state (cpustate);
4669      else if (buf[0] == 'u')
4670      {
4671         if (buf[1] == '0')
4672            sscanf (buf + 1, "%x", &curr_disasm);
4673         disasm (cpustate, curr_disasm, 10);
4674         curr_disasm += 10 * 4;
4675         buf[1] = 0;
4676      }
4677      else if (buf[0] == 'p')
4678      {
4679         if (buf[1] >= '0' && buf[1] <= '4')
4680            dump_pipe (cpustate, buf[1] - 0x30);
4681         buf[1] = 0;
4682      }
4683      else if (buf[0] == 's')
4684         cpustate->single_stepping = 1;
4685      else if (buf[0] == 'l')
4686         ; //cpustate->pc = elf_load(buf + 1);
4687      else if (buf[0] == 'd' && buf[1] == 'b')
4688      {
4689         if (buf[2] == '0')
4690            sscanf (buf + 2, "%x", &curr_dumpdb);
4691         dbg_db (cpustate, curr_dumpdb, 32);
4692         curr_dumpdb += 32;
4693      }
4694      else if (buf[0] == 'x' && buf[1] == '0')
4695      {
4696         UINT32 v;
4697         sscanf (buf + 1, "%x", &v);
4698         if (GET_DIRBASE_ATE ())
4699            fprintf (stderr, "vma 0x%08x ==> phys 0x%08x\n", v,
4700                   get_address_translation (cpustate, v, 1, 0));
4701         else
4702            fprintf   (stderr, "not in virtual address mode.\n");
4703      }
4704      else if (buf[0] == 'B')
4705      {
4706         ;//cpustate->pc = elf_load("bins/bsd");
4707         break;
4708      }
4709      else if (buf[0] == '?')
4710      {
4711         fprintf (stderr, "  db: dump bytes (db[0xaddress])\n   r: dump registers\n   s: single-step\n   g: go back to emulator (g[0xaddress])\n   u: disassemble (u[0xaddress])\n   p: dump pipelines (p{0-4} for all, add, mul, load, graphics)\n   l: load an ELF binary (lpath)\n   x: give virt->phys translation (x{0xaddress})\n");
4712      }
4713      else
4714         fprintf   (stderr, "Bad command '%s'.\n", buf);
4715   }
4716
4717   /* Less noise when single-stepping.  */
4718   if (cpustate->single_stepping != 1)
4719      fprintf (stderr, "Debugger done, continuing emulation.\n");
4720}
4721
4722#endif
src/emu/cpu/i860/i860.c
r4135r4136
1#include "debugger.h"
2#include "i860.h"
1/***************************************************************************
32
4/**************************************************************************
5 * The core struct
6 **************************************************************************/
7typedef struct _i860_state_t i860_state_t;
8struct _i860_state_t
9{
10   const device_config *device;
11   const address_space *program;
3    i860.c
124
13   UINT32 pc;
14   UINT32 ppc;
5    Interface file for the Intel i860 emulator.
156
16   int icount;
17};
7    Copyright (C) 1995-present Jason Eckhardt (jle@rice.edu)
8    Released for general non-commercial use under the MAME license
9    with the additional requirement that you are free to use and
10    redistribute this code in modified or unmodified form, provided
11    you list me in the credits.
12    Visit http://mamedev.org for licensing and usage restrictions.
1813
14***************************************************************************/
1915
16/*
17TODO: Separate out i860XR and i860XP (make different types, etc).
18      Hook IRQ lines into MAME core (they're custom functions atm).
19*/
20
21#include "debugger.h"
22#include "i860.h"
23
2024/**************************************************************************
2125 * Functions specified by GET_INFO
2226 **************************************************************************/
2327
2428static CPU_INIT( i860 )
2529{
26   i860_state_t *i860 = device->token;
27   i860->device = device;
28   i860->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
30   i860_state_t *cpustate = device->token;
31   cpustate->device = device;
32   cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
33   reset_i860(cpustate);
34   i860_set_pin(cpustate, DEC_PIN_BUS_HOLD, 0);
35   i860_set_pin(cpustate, DEC_PIN_RESET, 0);
36   cpustate->single_stepping = 0;
37
38   state_save_register_device_item_array(device, 0, cpustate->iregs);
39   state_save_register_device_item_array(device, 0, cpustate->cregs);
40   state_save_register_device_item_array(device, 0, cpustate->frg);
41   state_save_register_device_item(device, 0, cpustate->pc);
2942}
3043
3144static CPU_RESET( i860 )
3245{
33   logerror("i860 reset\n");
46   i860_state_t *cpustate = device->token;
47   reset_i860(cpustate);
3448}
3549
36static CPU_EXECUTE( i860 )
50
51/***************************************************************************
52 *  Disassembler hook
53 ***************************************************************************/
54
55static CPU_DISASSEMBLE( i860 )
3756{
38   /* Just a disassembler ATM */
39   return cycles;
57   extern unsigned disasm_i860(char*, unsigned, UINT32);
58
59   /* Hard-coded little endian for now.  */
60   return disasm_i860(buffer, pc, (oprom[0] << 0)  |
61                           (oprom[1] << 8)  |
62                           (oprom[2] << 16) |
63                           (oprom[3] << 24));
4064}
4165
42extern CPU_DISASSEMBLE( i860 );
4366
67/**************************************************************************
68 * The actual decode and execute code.
69 **************************************************************************/
70#include "i860dec.c"
4471
72
4573/**************************************************************************
4674 * Generic set_info/get_info
4775 **************************************************************************/
76
77#define CPU_SET_INFO_F(fnum) cpustate->frg[0+(4*fnum)] = (info->i & 0x000000ff);       \
78                      cpustate->frg[1+(4*fnum)] = (info->i & 0x0000ff00) >> 8;  \
79                      cpustate->frg[2+(4*fnum)] = (info->i & 0x00ff0000) >> 16; \
80                      cpustate->frg[3+(4*fnum)] = (info->i & 0xff000000) >> 24;
81
4882static CPU_SET_INFO( i860 )
4983{
50   i860_state_t *i860 = device->token;
84   i860_state_t *cpustate = device->token;
5185
5286   switch(state)
5387   {
54      /* Interfacing */
5588      case CPUINFO_INT_PC:
56      case CPUINFO_INT_REGISTER + I860_PC:   i860->pc = info->i & 0xffffffff;   break;
89      case CPUINFO_INT_REGISTER + I860_PC:      cpustate->pc = info->i & 0xffffffff;      break;
90
91      case CPUINFO_INT_REGISTER + I860_FIR:      cpustate->cregs[CR_FIR]    = info->i & 0xffffffff;   break;
92      case CPUINFO_INT_REGISTER + I860_PSR:      cpustate->cregs[CR_PSR]    = info->i & 0xffffffff;   break;
93      case CPUINFO_INT_REGISTER + I860_DIRBASE:   cpustate->cregs[CR_DIRBASE] = info->i & 0xffffffff;   break;
94      case CPUINFO_INT_REGISTER + I860_DB:      cpustate->cregs[CR_DB]       = info->i & 0xffffffff;   break;
95      case CPUINFO_INT_REGISTER + I860_FSR:      cpustate->cregs[CR_FSR]    = info->i & 0xffffffff;   break;
96      case CPUINFO_INT_REGISTER + I860_EPSR:      cpustate->cregs[CR_EPSR]    = info->i & 0xffffffff;   break;
97
98      case CPUINFO_INT_REGISTER + I860_R0:      cpustate->iregs[0]  = info->i & 0xffffffff;   break;
99      case CPUINFO_INT_REGISTER + I860_R1:      cpustate->iregs[1]  = info->i & 0xffffffff;   break;
100      case CPUINFO_INT_REGISTER + I860_R2:      cpustate->iregs[2]  = info->i & 0xffffffff;   break;
101      case CPUINFO_INT_REGISTER + I860_R3:      cpustate->iregs[3]  = info->i & 0xffffffff;   break;
102      case CPUINFO_INT_REGISTER + I860_R4:      cpustate->iregs[4]  = info->i & 0xffffffff;   break;
103      case CPUINFO_INT_REGISTER + I860_R5:      cpustate->iregs[5]  = info->i & 0xffffffff;   break;
104      case CPUINFO_INT_REGISTER + I860_R6:      cpustate->iregs[6]  = info->i & 0xffffffff;   break;
105      case CPUINFO_INT_REGISTER + I860_R7:      cpustate->iregs[7]  = info->i & 0xffffffff;   break;
106      case CPUINFO_INT_REGISTER + I860_R8:      cpustate->iregs[8]  = info->i & 0xffffffff;   break;
107      case CPUINFO_INT_REGISTER + I860_R9:      cpustate->iregs[9]  = info->i & 0xffffffff;   break;
108      case CPUINFO_INT_REGISTER + I860_R10:      cpustate->iregs[10] = info->i & 0xffffffff;   break;
109      case CPUINFO_INT_REGISTER + I860_R11:      cpustate->iregs[11] = info->i & 0xffffffff;   break;
110      case CPUINFO_INT_REGISTER + I860_R12:      cpustate->iregs[12] = info->i & 0xffffffff;   break;
111      case CPUINFO_INT_REGISTER + I860_R13:      cpustate->iregs[13] = info->i & 0xffffffff;   break;
112      case CPUINFO_INT_REGISTER + I860_R14:      cpustate->iregs[14] = info->i & 0xffffffff;   break;
113      case CPUINFO_INT_REGISTER + I860_R15:      cpustate->iregs[15] = info->i & 0xffffffff;   break;
114      case CPUINFO_INT_REGISTER + I860_R16:      cpustate->iregs[16] = info->i & 0xffffffff;   break;
115      case CPUINFO_INT_REGISTER + I860_R17:      cpustate->iregs[17] = info->i & 0xffffffff;   break;
116      case CPUINFO_INT_REGISTER + I860_R18:      cpustate->iregs[18] = info->i & 0xffffffff;   break;
117      case CPUINFO_INT_REGISTER + I860_R19:      cpustate->iregs[19] = info->i & 0xffffffff;   break;
118      case CPUINFO_INT_REGISTER + I860_R20:      cpustate->iregs[20] = info->i & 0xffffffff;   break;
119      case CPUINFO_INT_REGISTER + I860_R21:      cpustate->iregs[21] = info->i & 0xffffffff;   break;
120      case CPUINFO_INT_REGISTER + I860_R22:      cpustate->iregs[22] = info->i & 0xffffffff;   break;
121      case CPUINFO_INT_REGISTER + I860_R23:      cpustate->iregs[23] = info->i & 0xffffffff;   break;
122      case CPUINFO_INT_REGISTER + I860_R24:      cpustate->iregs[24] = info->i & 0xffffffff;   break;
123      case CPUINFO_INT_REGISTER + I860_R25:      cpustate->iregs[25] = info->i & 0xffffffff;   break;
124      case CPUINFO_INT_REGISTER + I860_R26:      cpustate->iregs[26] = info->i & 0xffffffff;   break;
125      case CPUINFO_INT_REGISTER + I860_R27:      cpustate->iregs[27] = info->i & 0xffffffff;   break;
126      case CPUINFO_INT_REGISTER + I860_R28:      cpustate->iregs[28] = info->i & 0xffffffff;   break;
127      case CPUINFO_INT_REGISTER + I860_R29:      cpustate->iregs[29] = info->i & 0xffffffff;   break;
128      case CPUINFO_INT_REGISTER + I860_R30:      cpustate->iregs[30] = info->i & 0xffffffff;   break;
129      case CPUINFO_INT_REGISTER + I860_R31:      cpustate->iregs[31] = info->i & 0xffffffff;   break;
130
131      case CPUINFO_INT_REGISTER + I860_F0:      CPU_SET_INFO_F(0);   break;
132      case CPUINFO_INT_REGISTER + I860_F1:      CPU_SET_INFO_F(1);   break;
133      case CPUINFO_INT_REGISTER + I860_F2:      CPU_SET_INFO_F(2);   break;
134      case CPUINFO_INT_REGISTER + I860_F3:      CPU_SET_INFO_F(3);   break;
135      case CPUINFO_INT_REGISTER + I860_F4:      CPU_SET_INFO_F(4);   break;
136      case CPUINFO_INT_REGISTER + I860_F5:      CPU_SET_INFO_F(5);   break;
137      case CPUINFO_INT_REGISTER + I860_F6:      CPU_SET_INFO_F(6);   break;
138      case CPUINFO_INT_REGISTER + I860_F7:      CPU_SET_INFO_F(7);   break;
139      case CPUINFO_INT_REGISTER + I860_F8:      CPU_SET_INFO_F(8);   break;
140      case CPUINFO_INT_REGISTER + I860_F9:      CPU_SET_INFO_F(9);   break;
141      case CPUINFO_INT_REGISTER + I860_F10:      CPU_SET_INFO_F(10);   break;
142      case CPUINFO_INT_REGISTER + I860_F11:      CPU_SET_INFO_F(11);   break;
143      case CPUINFO_INT_REGISTER + I860_F12:      CPU_SET_INFO_F(12);   break;
144      case CPUINFO_INT_REGISTER + I860_F13:      CPU_SET_INFO_F(13);   break;
145      case CPUINFO_INT_REGISTER + I860_F14:      CPU_SET_INFO_F(14);   break;
146      case CPUINFO_INT_REGISTER + I860_F15:      CPU_SET_INFO_F(15);   break;
147      case CPUINFO_INT_REGISTER + I860_F16:      CPU_SET_INFO_F(16);   break;
148      case CPUINFO_INT_REGISTER + I860_F17:      CPU_SET_INFO_F(17);   break;
149      case CPUINFO_INT_REGISTER + I860_F18:      CPU_SET_INFO_F(18);   break;
150      case CPUINFO_INT_REGISTER + I860_F19:      CPU_SET_INFO_F(19);   break;
151      case CPUINFO_INT_REGISTER + I860_F20:      CPU_SET_INFO_F(20);   break;
152      case CPUINFO_INT_REGISTER + I860_F21:      CPU_SET_INFO_F(21);   break;
153      case CPUINFO_INT_REGISTER + I860_F22:      CPU_SET_INFO_F(22);   break;
154      case CPUINFO_INT_REGISTER + I860_F23:      CPU_SET_INFO_F(23);   break;
155      case CPUINFO_INT_REGISTER + I860_F24:      CPU_SET_INFO_F(24);   break;
156      case CPUINFO_INT_REGISTER + I860_F25:      CPU_SET_INFO_F(25);   break;
157      case CPUINFO_INT_REGISTER + I860_F26:      CPU_SET_INFO_F(26);   break;
158      case CPUINFO_INT_REGISTER + I860_F27:      CPU_SET_INFO_F(27);   break;
159      case CPUINFO_INT_REGISTER + I860_F28:      CPU_SET_INFO_F(28);   break;
160      case CPUINFO_INT_REGISTER + I860_F29:      CPU_SET_INFO_F(29);   break;
161      case CPUINFO_INT_REGISTER + I860_F30:      CPU_SET_INFO_F(30);   break;
162      case CPUINFO_INT_REGISTER + I860_F31:      CPU_SET_INFO_F(31);   break;
57163   }
58164}
59165
166#define CPU_GET_INFO_INT_F(fnum) (info->i = cpustate->frg[0+(4*fnum)]       | \
167                                 cpustate->frg[1+(4*fnum)] << 8  | \
168                                 cpustate->frg[2+(4*fnum)] << 16 | \
169                                 cpustate->frg[3+(4*fnum)] << 24)
170
171#define CPU_GET_INFO_STR_F(fnum) (sprintf(info->s, "F%d : %08x", fnum, cpustate->frg[0+(4*fnum)]       | \
172                                                      cpustate->frg[1+(4*fnum)] << 8  | \
173                                                      cpustate->frg[2+(4*fnum)] << 16 | \
174                                                      cpustate->frg[3+(4*fnum)] << 24))
175
60176CPU_GET_INFO( i860 )
61177{
62   i860_state_t *i860 = (device != NULL) ? device->token : NULL;
178   i860_state_t *cpustate = (device != NULL) ? device->token : NULL;
63179
64180   switch (state)
65181   {
66      // --- the following bits of info are returned as 64-bit signed integers ---
67      case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(i860_state_t);         break;
68      case CPUINFO_INT_INPUT_LINES:               info->i = 0;                     break;
69      case CPUINFO_INT_DEFAULT_IRQ_VECTOR:         info->i = 0x00000000;               break;
70      case CPUINFO_INT_ENDIANNESS:               info->i = ENDIANNESS_LITTLE;         break;
71      case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;                     break;
72      case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 1;                     break;
73      case CPUINFO_INT_MIN_INSTRUCTION_BYTES:         info->i = 4;                     break;
74      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 4;                     break;
75      case CPUINFO_INT_MIN_CYCLES:               info->i = 1;                     break;
76      case CPUINFO_INT_MAX_CYCLES:               info->i = 8;                     break;
182      /* --- the following bits of info are returned as 64-bit signed integers --- */
183      case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(i860_state_t);      break;
184      case CPUINFO_INT_INPUT_LINES:               info->i = 0;                  break;
185      case CPUINFO_INT_DEFAULT_IRQ_VECTOR:         info->i = 0x00000000;            break;
186      case CPUINFO_INT_ENDIANNESS:               info->i = ENDIANNESS_LITTLE;      break;
187      case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;                  break;
188      case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 1;                  break;
189      case CPUINFO_INT_MIN_INSTRUCTION_BYTES:         info->i = 4;                  break;
190      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 4;                  break;
191      case CPUINFO_INT_MIN_CYCLES:               info->i = 1;                  break;
192      case CPUINFO_INT_MAX_CYCLES:               info->i = 8;                  break;
77193
78      case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM:   info->i = 32;               break;
79      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32;               break;
80      case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = 0;               break;
81      case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_DATA:   info->i = 0;               break;
82      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA:    info->i = 0;               break;
83      case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_DATA:    info->i = 0;               break;
84      case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_IO:      info->i = 0;               break;
85      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO:       info->i = 0;               break;
86      case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO:       info->i = 0;               break;
194      case CPUINFO_INT_DATABUS_WIDTH_PROGRAM:         info->i = 64;   break;
195      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:       info->i = 32;   break;
196      case CPUINFO_INT_ADDRBUS_SHIFT_PROGRAM:       info->i = 0;   break;
197      case CPUINFO_INT_DATABUS_WIDTH_DATA:         info->i = 0;   break;
198      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:          info->i = 0;   break;
199      case CPUINFO_INT_ADDRBUS_SHIFT_DATA:          info->i = 0;   break;
200      case CPUINFO_INT_DATABUS_WIDTH_IO:            info->i = 0;   break;
201      case CPUINFO_INT_ADDRBUS_WIDTH_IO:             info->i = 0;   break;
202      case CPUINFO_INT_ADDRBUS_SHIFT_IO:             info->i = 0;   break;
87203
88      // --- the following bits of info are returned as pointers to data or functions ---
204      case CPUINFO_INT_PC:
205      case CPUINFO_INT_REGISTER + I860_PC:         info->i = cpustate->pc;               break;
206      case CPUINFO_INT_PREVIOUSPC:               info->i = cpustate->ppc;            break;
207
208      case CPUINFO_INT_REGISTER + I860_FIR:         info->i = cpustate->cregs[CR_FIR];      break;
209      case CPUINFO_INT_REGISTER + I860_PSR:         info->i = cpustate->cregs[CR_PSR];      break;
210      case CPUINFO_INT_REGISTER + I860_DIRBASE:      info->i = cpustate->cregs[CR_DIRBASE];   break;
211      case CPUINFO_INT_REGISTER + I860_DB:         info->i = cpustate->cregs[CR_DB];      break;
212      case CPUINFO_INT_REGISTER + I860_FSR:         info->i = cpustate->cregs[CR_FSR];      break;
213      case CPUINFO_INT_REGISTER + I860_EPSR:         info->i = cpustate->cregs[CR_EPSR];      break;
214
215      case CPUINFO_INT_REGISTER + I860_R0:         info->i = cpustate->iregs[0];         break;
216      case CPUINFO_INT_REGISTER + I860_R1:         info->i = cpustate->iregs[1];         break;
217      case CPUINFO_INT_REGISTER + I860_R2:         info->i = cpustate->iregs[2];         break;
218      case CPUINFO_INT_REGISTER + I860_R3:         info->i = cpustate->iregs[3];         break;
219      case CPUINFO_INT_REGISTER + I860_R4:         info->i = cpustate->iregs[4];         break;
220      case CPUINFO_INT_REGISTER + I860_R5:         info->i = cpustate->iregs[5];         break;
221      case CPUINFO_INT_REGISTER + I860_R6:         info->i = cpustate->iregs[6];         break;
222      case CPUINFO_INT_REGISTER + I860_R7:         info->i = cpustate->iregs[7];         break;
223      case CPUINFO_INT_REGISTER + I860_R8:         info->i = cpustate->iregs[8];         break;
224      case CPUINFO_INT_REGISTER + I860_R9:         info->i = cpustate->iregs[9];         break;
225      case CPUINFO_INT_REGISTER + I860_R10:         info->i = cpustate->iregs[10];         break;
226      case CPUINFO_INT_REGISTER + I860_R11:         info->i = cpustate->iregs[11];         break;
227      case CPUINFO_INT_REGISTER + I860_R12:         info->i = cpustate->iregs[12];         break;
228      case CPUINFO_INT_REGISTER + I860_R13:         info->i = cpustate->iregs[13];         break;
229      case CPUINFO_INT_REGISTER + I860_R14:         info->i = cpustate->iregs[14];         break;
230      case CPUINFO_INT_REGISTER + I860_R15:         info->i = cpustate->iregs[15];         break;
231      case CPUINFO_INT_REGISTER + I860_R16:         info->i = cpustate->iregs[16];         break;
232      case CPUINFO_INT_REGISTER + I860_R17:         info->i = cpustate->iregs[17];         break;
233      case CPUINFO_INT_REGISTER + I860_R18:         info->i = cpustate->iregs[18];         break;
234      case CPUINFO_INT_REGISTER + I860_R19:         info->i = cpustate->iregs[19];         break;
235      case CPUINFO_INT_REGISTER + I860_R20:         info->i = cpustate->iregs[20];         break;
236      case CPUINFO_INT_REGISTER + I860_R21:         info->i = cpustate->iregs[21];         break;
237      case CPUINFO_INT_REGISTER + I860_R22:         info->i = cpustate->iregs[22];         break;
238      case CPUINFO_INT_REGISTER + I860_R23:         info->i = cpustate->iregs[23];         break;
239      case CPUINFO_INT_REGISTER + I860_R24:         info->i = cpustate->iregs[24];         break;
240      case CPUINFO_INT_REGISTER + I860_R25:         info->i = cpustate->iregs[25];         break;
241      case CPUINFO_INT_REGISTER + I860_R26:         info->i = cpustate->iregs[26];         break;
242      case CPUINFO_INT_REGISTER + I860_R27:         info->i = cpustate->iregs[27];         break;
243      case CPUINFO_INT_REGISTER + I860_R28:         info->i = cpustate->iregs[28];         break;
244      case CPUINFO_INT_REGISTER + I860_R29:         info->i = cpustate->iregs[29];         break;
245      case CPUINFO_INT_REGISTER + I860_R30:         info->i = cpustate->iregs[30];         break;
246      case CPUINFO_INT_REGISTER + I860_R31:         info->i = cpustate->iregs[31];         break;
247
248      case CPUINFO_INT_REGISTER + I860_F0:         CPU_GET_INFO_INT_F(0);   break;
249      case CPUINFO_INT_REGISTER + I860_F1:         CPU_GET_INFO_INT_F(1);   break;
250      case CPUINFO_INT_REGISTER + I860_F2:         CPU_GET_INFO_INT_F(2);   break;
251      case CPUINFO_INT_REGISTER + I860_F3:         CPU_GET_INFO_INT_F(3);   break;
252      case CPUINFO_INT_REGISTER + I860_F4:         CPU_GET_INFO_INT_F(4);   break;
253      case CPUINFO_INT_REGISTER + I860_F5:         CPU_GET_INFO_INT_F(5);   break;
254      case CPUINFO_INT_REGISTER + I860_F6:         CPU_GET_INFO_INT_F(6);   break;
255      case CPUINFO_INT_REGISTER + I860_F7:         CPU_GET_INFO_INT_F(7);   break;
256      case CPUINFO_INT_REGISTER + I860_F8:         CPU_GET_INFO_INT_F(8);   break;
257      case CPUINFO_INT_REGISTER + I860_F9:         CPU_GET_INFO_INT_F(9);   break;
258      case CPUINFO_INT_REGISTER + I860_F10:         CPU_GET_INFO_INT_F(10);   break;
259      case CPUINFO_INT_REGISTER + I860_F11:         CPU_GET_INFO_INT_F(11);   break;
260      case CPUINFO_INT_REGISTER + I860_F12:         CPU_GET_INFO_INT_F(12);   break;
261      case CPUINFO_INT_REGISTER + I860_F13:         CPU_GET_INFO_INT_F(13);   break;
262      case CPUINFO_INT_REGISTER + I860_F14:         CPU_GET_INFO_INT_F(14);   break;
263      case CPUINFO_INT_REGISTER + I860_F15:         CPU_GET_INFO_INT_F(15);   break;
264      case CPUINFO_INT_REGISTER + I860_F16:         CPU_GET_INFO_INT_F(16);   break;
265      case CPUINFO_INT_REGISTER + I860_F17:         CPU_GET_INFO_INT_F(17);   break;
266      case CPUINFO_INT_REGISTER + I860_F18:         CPU_GET_INFO_INT_F(18);   break;
267      case CPUINFO_INT_REGISTER + I860_F19:         CPU_GET_INFO_INT_F(19);   break;
268      case CPUINFO_INT_REGISTER + I860_F20:         CPU_GET_INFO_INT_F(20);   break;
269      case CPUINFO_INT_REGISTER + I860_F21:         CPU_GET_INFO_INT_F(21);   break;
270      case CPUINFO_INT_REGISTER + I860_F22:         CPU_GET_INFO_INT_F(22);   break;
271      case CPUINFO_INT_REGISTER + I860_F23:         CPU_GET_INFO_INT_F(23);   break;
272      case CPUINFO_INT_REGISTER + I860_F24:         CPU_GET_INFO_INT_F(24);   break;
273      case CPUINFO_INT_REGISTER + I860_F25:         CPU_GET_INFO_INT_F(25);   break;
274      case CPUINFO_INT_REGISTER + I860_F26:         CPU_GET_INFO_INT_F(26);   break;
275      case CPUINFO_INT_REGISTER + I860_F27:         CPU_GET_INFO_INT_F(27);   break;
276      case CPUINFO_INT_REGISTER + I860_F28:         CPU_GET_INFO_INT_F(28);   break;
277      case CPUINFO_INT_REGISTER + I860_F29:         CPU_GET_INFO_INT_F(29);   break;
278      case CPUINFO_INT_REGISTER + I860_F30:         CPU_GET_INFO_INT_F(30);   break;
279      case CPUINFO_INT_REGISTER + I860_F31:         CPU_GET_INFO_INT_F(31);   break;
280
281
282      /* --- the following bits of info are returned as pointers to data or functions --- */
89283      case CPUINFO_FCT_SET_INFO:                  info->setinfo      = CPU_SET_INFO_NAME(i860);   break;
90284      case CPUINFO_FCT_INIT:                     info->init         = CPU_INIT_NAME(i860);      break;
91285      case CPUINFO_FCT_RESET:                     info->reset      = CPU_RESET_NAME(i860);      break;
r4135r4136
98292      case CPUINFO_FCT_READ:                     info->read         = NULL;                  break;
99293      case CPUINFO_FCT_WRITE:                     info->write      = NULL;                  break;
100294      case CPUINFO_FCT_READOP:                  info->readop      = NULL;                  break;
101      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount      = &i860->icount;            break;
295      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount      = &cpustate->icount;         break;
102296
103      // --- the following bits of info are returned as NULL-terminated strings ---
104      case CPUINFO_STR_NAME:                     strcpy(info->s, "i860");         break;
105      case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "Intel");         break;
297      /* --- the following bits of info are returned as NULL-terminated strings --- */
298      case CPUINFO_STR_NAME:                     strcpy(info->s, "i860XR");         break;
299      case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "Intel i860");      break;
106300      case CPUINFO_STR_CORE_VERSION:               strcpy(info->s, "0.1");            break;
107301      case CPUINFO_STR_CORE_FILE:                  strcpy(info->s, __FILE__);         break;
108      case CPUINFO_STR_CORE_CREDITS:               strcpy(info->s, "Jason Eckhardt and Andrew Gardner");   break;
302      case CPUINFO_STR_CORE_CREDITS:               strcpy(info->s, "Jason Eckhardt");   break;
109303
110      case CPUINFO_INT_PC:                     info->i = i860->pc;               break;
111      case CPUINFO_INT_PREVIOUSPC:               info->i = i860->ppc;            break;
304      case CPUINFO_STR_FLAGS:
305         strcpy(info->s, ""); break;
306
307      case CPUINFO_STR_REGISTER + I860_PC:         sprintf(info->s, "PC : %08x", cpustate->pc);               break;
308      case CPUINFO_STR_REGISTER + I860_FIR:         sprintf(info->s, "FIR : %08x", cpustate->cregs[CR_FIR]);      break;
309      case CPUINFO_STR_REGISTER + I860_PSR:         sprintf(info->s, "PSR : %08x", cpustate->cregs[CR_PSR]);      break;
310      case CPUINFO_STR_REGISTER + I860_DIRBASE:      sprintf(info->s, "DIRBASE : %08x", cpustate->cregs[CR_DIRBASE]);break;
311      case CPUINFO_STR_REGISTER + I860_DB:         sprintf(info->s, "DB : %08x", cpustate->cregs[CR_DB]);         break;
312      case CPUINFO_STR_REGISTER + I860_FSR:         sprintf(info->s, "FSR : %08x", cpustate->cregs[CR_FSR]);      break;
313      case CPUINFO_STR_REGISTER + I860_EPSR:         sprintf(info->s, "EPSR : %08x", cpustate->cregs[CR_EPSR]);      break;
314
315      case CPUINFO_STR_REGISTER + I860_R0:         sprintf(info->s, "R0 : %08x",  cpustate->iregs[0]);      break;
316      case CPUINFO_STR_REGISTER + I860_R1:         sprintf(info->s, "R1 : %08x",  cpustate->iregs[1]);      break;
317      case CPUINFO_STR_REGISTER + I860_R2:         sprintf(info->s, "R2 : %08x",  cpustate->iregs[2]);      break;
318      case CPUINFO_STR_REGISTER + I860_R3:         sprintf(info->s, "R3 : %08x",  cpustate->iregs[3]);      break;
319      case CPUINFO_STR_REGISTER + I860_R4:         sprintf(info->s, "R4 : %08x",  cpustate->iregs[4]);      break;
320      case CPUINFO_STR_REGISTER + I860_R5:         sprintf(info->s, "R5 : %08x",  cpustate->iregs[5]);      break;
321      case CPUINFO_STR_REGISTER + I860_R6:         sprintf(info->s, "R6 : %08x",  cpustate->iregs[6]);      break;
322      case CPUINFO_STR_REGISTER + I860_R7:         sprintf(info->s, "R7 : %08x",  cpustate->iregs[7]);      break;
323      case CPUINFO_STR_REGISTER + I860_R8:         sprintf(info->s, "R8 : %08x",  cpustate->iregs[8]);      break;
324      case CPUINFO_STR_REGISTER + I860_R9:         sprintf(info->s, "R9 : %08x",  cpustate->iregs[9]);      break;
325      case CPUINFO_STR_REGISTER + I860_R10:         sprintf(info->s, "R10 : %08x", cpustate->iregs[10]);   break;
326      case CPUINFO_STR_REGISTER + I860_R11:         sprintf(info->s, "R11 : %08x", cpustate->iregs[11]);   break;
327      case CPUINFO_STR_REGISTER + I860_R12:         sprintf(info->s, "R12 : %08x", cpustate->iregs[12]);   break;
328      case CPUINFO_STR_REGISTER + I860_R13:         sprintf(info->s, "R13 : %08x", cpustate->iregs[13]);   break;
329      case CPUINFO_STR_REGISTER + I860_R14:         sprintf(info->s, "R14 : %08x", cpustate->iregs[14]);   break;
330      case CPUINFO_STR_REGISTER + I860_R15:         sprintf(info->s, "R15 : %08x", cpustate->iregs[15]);   break;
331      case CPUINFO_STR_REGISTER + I860_R16:         sprintf(info->s, "R16 : %08x", cpustate->iregs[16]);   break;
332      case CPUINFO_STR_REGISTER + I860_R17:         sprintf(info->s, "R17 : %08x", cpustate->iregs[17]);   break;
333      case CPUINFO_STR_REGISTER + I860_R18:         sprintf(info->s, "R18 : %08x", cpustate->iregs[18]);   break;
334      case CPUINFO_STR_REGISTER + I860_R19:         sprintf(info->s, "R19 : %08x", cpustate->iregs[19]);   break;
335      case CPUINFO_STR_REGISTER + I860_R20:         sprintf(info->s, "R20 : %08x", cpustate->iregs[20]);   break;
336      case CPUINFO_STR_REGISTER + I860_R21:         sprintf(info->s, "R21 : %08x", cpustate->iregs[21]);   break;
337      case CPUINFO_STR_REGISTER + I860_R22:         sprintf(info->s, "R22 : %08x", cpustate->iregs[22]);   break;
338      case CPUINFO_STR_REGISTER + I860_R23:         sprintf(info->s, "R23 : %08x", cpustate->iregs[23]);   break;
339      case CPUINFO_STR_REGISTER + I860_R24:         sprintf(info->s, "R24 : %08x", cpustate->iregs[24]);   break;
340      case CPUINFO_STR_REGISTER + I860_R25:         sprintf(info->s, "R25 : %08x", cpustate->iregs[25]);   break;
341      case CPUINFO_STR_REGISTER + I860_R26:         sprintf(info->s, "R26 : %08x", cpustate->iregs[26]);   break;
342      case CPUINFO_STR_REGISTER + I860_R27:         sprintf(info->s, "R27 : %08x", cpustate->iregs[27]);   break;
343      case CPUINFO_STR_REGISTER + I860_R28:         sprintf(info->s, "R28 : %08x", cpustate->iregs[28]);   break;
344      case CPUINFO_STR_REGISTER + I860_R29:         sprintf(info->s, "R29 : %08x", cpustate->iregs[29]);   break;
345      case CPUINFO_STR_REGISTER + I860_R30:         sprintf(info->s, "R30 : %08x", cpustate->iregs[30]);   break;
346      case CPUINFO_STR_REGISTER + I860_R31:         sprintf(info->s, "R31 : %08x", cpustate->iregs[31]);   break;
347
348      case CPUINFO_STR_REGISTER + I860_F0:         CPU_GET_INFO_STR_F(0);   break;
349      case CPUINFO_STR_REGISTER + I860_F1:         CPU_GET_INFO_STR_F(1);   break;
350      case CPUINFO_STR_REGISTER + I860_F2:         CPU_GET_INFO_STR_F(2);   break;
351      case CPUINFO_STR_REGISTER + I860_F3:         CPU_GET_INFO_STR_F(3);   break;
352      case CPUINFO_STR_REGISTER + I860_F4:         CPU_GET_INFO_STR_F(4);   break;
353      case CPUINFO_STR_REGISTER + I860_F5:         CPU_GET_INFO_STR_F(5);   break;
354      case CPUINFO_STR_REGISTER + I860_F6:         CPU_GET_INFO_STR_F(6);   break;
355      case CPUINFO_STR_REGISTER + I860_F7:         CPU_GET_INFO_STR_F(7);   break;
356      case CPUINFO_STR_REGISTER + I860_F8:         CPU_GET_INFO_STR_F(8);   break;
357      case CPUINFO_STR_REGISTER + I860_F9:         CPU_GET_INFO_STR_F(9);   break;
358      case CPUINFO_STR_REGISTER + I860_F10:         CPU_GET_INFO_STR_F(10);   break;
359      case CPUINFO_STR_REGISTER + I860_F11:         CPU_GET_INFO_STR_F(11);   break;
360      case CPUINFO_STR_REGISTER + I860_F12:         CPU_GET_INFO_STR_F(12);   break;
361      case CPUINFO_STR_REGISTER + I860_F13:         CPU_GET_INFO_STR_F(13);   break;
362      case CPUINFO_STR_REGISTER + I860_F14:         CPU_GET_INFO_STR_F(14);   break;
363      case CPUINFO_STR_REGISTER + I860_F15:         CPU_GET_INFO_STR_F(15);   break;
364      case CPUINFO_STR_REGISTER + I860_F16:         CPU_GET_INFO_STR_F(16);   break;
365      case CPUINFO_STR_REGISTER + I860_F17:         CPU_GET_INFO_STR_F(17);   break;
366      case CPUINFO_STR_REGISTER + I860_F18:         CPU_GET_INFO_STR_F(18);   break;
367      case CPUINFO_STR_REGISTER + I860_F19:         CPU_GET_INFO_STR_F(19);   break;
368      case CPUINFO_STR_REGISTER + I860_F20:         CPU_GET_INFO_STR_F(20);   break;
369      case CPUINFO_STR_REGISTER + I860_F21:         CPU_GET_INFO_STR_F(21);   break;
370      case CPUINFO_STR_REGISTER + I860_F22:         CPU_GET_INFO_STR_F(22);   break;
371      case CPUINFO_STR_REGISTER + I860_F23:         CPU_GET_INFO_STR_F(23);   break;
372      case CPUINFO_STR_REGISTER + I860_F24:         CPU_GET_INFO_STR_F(24);   break;
373      case CPUINFO_STR_REGISTER + I860_F25:         CPU_GET_INFO_STR_F(25);   break;
374      case CPUINFO_STR_REGISTER + I860_F26:         CPU_GET_INFO_STR_F(26);   break;
375      case CPUINFO_STR_REGISTER + I860_F27:         CPU_GET_INFO_STR_F(27);   break;
376      case CPUINFO_STR_REGISTER + I860_F28:         CPU_GET_INFO_STR_F(28);   break;
377      case CPUINFO_STR_REGISTER + I860_F29:         CPU_GET_INFO_STR_F(29);   break;
378      case CPUINFO_STR_REGISTER + I860_F30:         CPU_GET_INFO_STR_F(30);   break;
379      case CPUINFO_STR_REGISTER + I860_F31:         CPU_GET_INFO_STR_F(31);   break;
112380   }
113381}
src/emu/cpu/i860/i860dis.c
r0r4136
1/***************************************************************************
2
3    i860dis.c
4
5    Disassembler for the Intel i860 emulator.
6
7    Copyright (C) 1995-present Jason Eckhardt (jle@rice.edu)
8    Released for general non-commercial use under the MAME license
9    with the additional requirement that you are free to use and
10    redistribute this code in modified or unmodified form, provided
11    you list me in the credits.
12    Visit http://mamedev.org for licensing and usage restrictions.
13
14***************************************************************************/
15
16#include "i860.h"
17#include <string.h>
18
19/* Macros for accessing register fields in instruction word.  */
20#define get_isrc1(bits) (((bits) >> 11) & 0x1f)
21#define get_isrc2(bits) (((bits) >> 21) & 0x1f)
22#define get_idest(bits) (((bits) >> 16) & 0x1f)
23#define get_fsrc1(bits) (((bits) >> 11) & 0x1f)
24#define get_fsrc2(bits) (((bits) >> 21) & 0x1f)
25#define get_fdest(bits) (((bits) >> 16) & 0x1f)
26#define get_creg(bits)  (((bits) >> 21) & 0x7)
27
28/* Macros for accessing immediate fields.  */
29/* 16-bit immediate.  */
30#define get_imm16(insn) ((insn) & 0xffff)
31
32
33/* Control register names.  */
34static const char *const cr2str[] =
35   {"fir", "psr", "dirbase", "db", "fsr", "epsr", "!", "!"};
36
37
38/* Sign extend N-bit number.  */
39static INT32 sign_ext(UINT32 x, int n)
40{
41   INT32 t;
42   t = x >> (n - 1);
43   t = ((-t) << n) | x;
44   return t;
45}
46
47
48/* Basic integer 3-address register format:
49 *   mnemonic %rs1,%rs2,%rd  */
50static void int_12d(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
51{
52   /* Possibly prefix shrd with 'd.' */
53   if (((insn & 0xfc000000) == 0xb0000000) && (insn & 0x200))
54      sprintf(buf, "d.%s\t%%r%d,%%r%d,%%r%d", mnemonic,
55         get_isrc1 (insn), get_isrc2 (insn), get_idest (insn));
56   else
57      sprintf(buf, "%s\t%%r%d,%%r%d,%%r%d", mnemonic,
58         get_isrc1 (insn), get_isrc2 (insn), get_idest (insn));
59}
60
61
62/* Basic integer 3-address imm16 format:
63 *   mnemonic #imm16,%rs2,%rd  */
64static void int_i2d(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
65{
66   /* Sign extend the 16-bit immediate.
67       Print as hex for the bitwise operations.  */
68   int upper_6bits = (insn >> 26) & 0x3f;
69   if (upper_6bits >= 0x30 && upper_6bits <= 0x3f)
70      sprintf(buf, "%s\t0x%04x,%%r%d,%%r%d", mnemonic,
71         (UINT32)(get_imm16 (insn)), get_isrc2 (insn), get_idest (insn));
72   else
73      sprintf(buf, "%s\t%d,%%r%d,%%r%d", mnemonic,
74         sign_ext(get_imm16 (insn), 16), get_isrc2 (insn), get_idest (insn));
75}
76
77
78/* Integer (mixed) 2-address  isrc1ni,fdest.  */
79static void int_1d(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
80{
81   sprintf(buf, "%s\t%%r%d,%%f%d", mnemonic, get_isrc1 (insn), get_fdest (insn));
82}
83
84
85/* Integer (mixed) 2-address  csrc2,idest.  */
86static void int_cd(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
87{
88   sprintf(buf, "%s\t%%%s,%%r%d", mnemonic, cr2str[get_creg (insn)], get_idest (insn));
89}
90
91
92/* Integer (mixed) 2-address  isrc1,csrc2.  */
93static void int_1c(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
94{
95   sprintf(buf, "%s\t%%r%d,%%%s", mnemonic, get_isrc1(insn), cr2str[get_creg (insn)]);
96}
97
98
99/* Integer 1-address register format:
100 *   mnemonic %rs1  */
101static void int_1(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
102{
103   sprintf(buf, "%s\t%%r%d", mnemonic, get_isrc1 (insn));
104}
105
106
107/* Integer no-address register format:
108 *   mnemonic  */
109static void int_0(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
110{
111   sprintf(buf, "%s", mnemonic);
112}
113
114
115/* Basic floating-point 3-address register format:
116 *   mnemonic %fs1,%fs2,%fd  */
117static void flop_12d(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
118{
119   const char *suffix[4] = { "ss", "sd", "ds", "dd" };
120   const char *prefix_d, *prefix_p;
121   int s = (insn & 0x180) >> 7;
122   prefix_p = (insn & 0x400) ? "p" : "";
123   prefix_d = (insn & 0x200) ? "d." : "";
124
125   /* Special case: pf[m]am and pf[m]sm families are always pipelined, so they
126       do not have a prefix.  Also, for the pfmam and pfmsm families, replace
127       any 'a' in the mnemonic with 'm' and prepend an 'm'.  */
128   if ((insn & 0x7f) < 0x20)
129   {
130      int is_pfam = insn & 0x400;
131      if (!is_pfam)
132      {
133         char newname[256];
134         char *op = mnemonic;
135         char *np = newname + 1;
136         newname[0] = 'm';
137         while (*op)
138         {
139            if (*op == 'a')
140               *np = 'm';
141            else
142               *np = *op;
143            np++;
144            op++;
145         }
146         *np = 0;
147         mnemonic = newname;
148      }
149      prefix_p = "";
150   }
151
152   /* Special case: pfgt/pfle-- R-bit distinguishes the two.  */
153   if ((insn & 0x7f) == 0x34)
154   {
155      const char *mn[2] = { "fgt.", "fle." };
156      int r = (insn & 0x080) >> 7;
157      int s = (insn & 0x100) ? 3 : 0;
158      sprintf(buf, "%s%s%s%s\t%%f%d,%%f%d,%%f%d", prefix_d, prefix_p, mn[r],
159         suffix[s], get_fsrc1 (insn), get_fsrc2 (insn), get_fdest (insn));
160   }
161   else
162      sprintf(buf, "%s%s%s%s\t%%f%d,%%f%d,%%f%d", prefix_d, prefix_p, mnemonic,
163         suffix[s], get_fsrc1 (insn), get_fsrc2 (insn), get_fdest (insn));
164}
165
166
167/* Floating-point 2-address register format:
168 *   mnemonic %fs1,%fd  */
169static void flop_1d(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
170{
171   const char *suffix[4] = { "ss", "sd", "ds", "dd" };
172   const char *prefix_d, *prefix_p;
173   int s = (insn & 0x180) >> 7;
174   prefix_p = (insn & 0x400) ? "p" : "";
175   prefix_d = (insn & 0x200) ? "d." : "";
176   sprintf(buf, "%s%s%s%s\t%%f%d,%%f%d", prefix_d, prefix_p, mnemonic,
177      suffix[s], get_fsrc1 (insn), get_fdest (insn));
178}
179
180
181/* Floating-point 2-address register format:
182 *   mnemonic %fs2,%fd  */
183static void flop_2d(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
184{
185   const char *suffix[4] = { "ss", "sd", "ds", "dd" };
186   const char *prefix_d;
187   int s = (insn & 0x180) >> 7;
188   prefix_d = (insn & 0x200) ? "d." : "";
189   sprintf(buf, "%s%s%s\t%%f%d,%%f%d", prefix_d, mnemonic, suffix[s],
190      get_fsrc2 (insn), get_fdest (insn));
191}
192
193
194/* Floating-point (mixed) 2-address register format:
195 *  fxfr fsrc1,idest.  */
196static void flop_fxfr(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
197{
198   const char *prefix_d = (insn & 0x200) ? "d." : "";
199   sprintf(buf, "%s%s\t%%f%d,%%r%d", prefix_d, mnemonic, get_fsrc1 (insn),
200      get_idest (insn));
201}
202
203
204/* Branch with reg,reg,sbroff format:
205 *   mnemonic %rs1,%rs2,sbroff  */
206static void int_12S(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
207{
208   INT32 sbroff = sign_ext ((((insn >> 5) & 0xf800) | (insn & 0x07ff)), 16);
209   INT32 rel = (INT32)pc + (sbroff << 2) + 4;
210
211   sprintf(buf, "%s\t%%r%d,%%r%d,0x%08x", mnemonic, get_isrc1 (insn),
212      get_isrc2 (insn), (UINT32)rel);
213}
214
215
216/* Branch with #const5,reg,sbroff format:
217 *   mnemonic #const5,%rs2,sbroff  */
218static void int_i2S(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
219{
220   INT32 sbroff = sign_ext ((((insn >> 5) & 0xf800) | (insn & 0x07ff)), 16);
221   INT32 rel = (INT32)pc + (sbroff << 2) + 4;
222
223   sprintf(buf, "%s\t%d,%%r%d,0x%08x", mnemonic, ((insn >> 11) & 0x1f),
224      get_isrc2 (insn), (UINT32)rel);
225}
226
227
228/* Branch with lbroff format:
229 *   mnemonic lbroff  */
230static void int_L(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
231{
232   INT32 lbroff =  sign_ext ((insn & 0x03ffffff), 26);
233   INT32 rel = (INT32)pc + (lbroff << 2) + 4;
234
235   sprintf(buf, "%s\t0x%08x", mnemonic, (UINT32)rel);
236}
237
238
239/* Integer load.
240 *  ld.{b,s,l} isrc1(isrc2),idest
241 *  ld.{b,s,l} #const(isrc2),idest  */
242static void int_ldx(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
243{
244   /* Operand size, in bytes.  */
245   int sizes[4] = { 1, 1, 2, 4 };
246   const char *suffix[4] = { "b", "b", "s", "l" };
247   UINT32 idx = 0;
248
249   /* Bits 28 and 0 determine the operand size.  */
250   idx = ((insn >> 27) & 2) | (insn & 1);
251
252   /* Bit 26 determines the addressing mode (reg+reg or disp+reg).  */
253   if (insn & 0x04000000)
254   {
255      /* Chop off lower bits of displacement.  */
256      INT32 immsrc1 = sign_ext (get_imm16 (insn), 16);
257      int size = sizes[idx];
258      immsrc1 &= ~(size - 1);
259      sprintf(buf, "%s%s\t%d(%%r%d),%%r%d", mnemonic, suffix[idx],
260         immsrc1, get_isrc2 (insn), get_idest (insn));
261   }
262   else
263      sprintf(buf, "%s%s\t%%r%d(%%r%d),%%r%d", mnemonic, suffix[idx],
264         get_isrc1 (insn), get_isrc2 (insn), get_idest (insn));
265}
266
267
268/* Integer store: st.b isrc1ni,#const(isrc2)  */
269static void int_stx(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
270{
271   /* Operand size, in bytes.  */
272   int sizes[4] = { 1, 1, 2, 4 };
273   const char *suffix[4] = { "b", "b", "s", "l" };
274   int idx = 0;
275   int size;
276   INT32 immsrc = sign_ext ((((insn >> 5) & 0xf800) | (insn & 0x07ff)), 16);
277
278   /* Bits 28 and 0 determine the operand size.  */
279   idx = ((insn >> 27) & 2) | (insn & 1);
280
281   /* Chop off lower bits of displacement.  */
282   size = sizes[idx];
283   immsrc &= ~(size - 1);
284   sprintf(buf, "%s%s\t%%r%d,%d(%%r%d)", mnemonic, suffix[idx],
285      get_isrc1 (insn), immsrc, get_isrc2 (insn));
286}
287
288
289/* Disassemble:
290 *  "[p]fld.y isrc1(isrc2),fdest", "[p]fld.y isrc1(isrc2)++,idest",
291 *  "[p]fld.y #const(isrc2),fdest" or "[p]fld.y #const(isrc2)++,idest".
292 *  "fst.y fdest,isrc1(isrc2)", "fst.y fdest,isrc1(isrc2)++",
293 *  "fst.y fdest,#const(isrc2)" or "fst.y fdest,#const(isrc2)++"
294 *  Where y = {l,d,q}.  Note, there is no pfld.q, though.  */
295static void int_fldst(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
296{
297   INT32 immsrc1 = sign_ext (get_imm16 (insn), 16);
298   /* Operand size, in bytes.  */
299   int sizes[4] = { 8, 4, 16, 4 };
300   const char *suffix[4] = { "d", "l", "q", "l" };
301   int idx = 0;
302   int size = 0;
303   int auto_inc = (insn & 1);
304   const char *auto_suff[2] = { "", "++" };
305   int piped = (insn & 0x40000000) >> 29;
306   const char *piped_suff[2] = { "", "p" };
307   int upper_6bits = (insn >> 26) & 0x3f;
308   int is_load = (upper_6bits == 8 || upper_6bits == 9 || upper_6bits == 24
309               || upper_6bits == 25);
310
311   /* Bits 2 and 1 determine the operand size.  */
312   idx = ((insn >> 1) & 3);
313   size = sizes[idx];
314
315   /* There is no pipelined load quad on XR.  */
316   if (piped && size == 16)
317    {
318      sprintf (buf, ".long\t%#08x; *", insn);
319      return;
320    }
321
322   /* There is only a 64-bit pixel store.  */
323   if ((upper_6bits == 15) && size != 8)
324   {
325      sprintf (buf, ".long\t%#08x", insn);
326      return;
327   }
328
329   /* Bit 26 determines the addressing mode (reg+reg or disp+reg).  */
330   if (insn & 0x04000000)
331   {
332      /* Chop off lower bits of displacement.  */
333      immsrc1 &= ~(size - 1);
334      if (is_load)
335         sprintf(buf, "%s%s%s\t%d(%%r%d)%s,%%f%d", piped_suff[piped], mnemonic,
336            suffix[idx], immsrc1, get_isrc2 (insn), auto_suff[auto_inc],
337            get_fdest (insn));
338      else
339         sprintf(buf, "%s%s\t%%f%d,%d(%%r%d)%s", mnemonic, suffix[idx],
340            get_fdest (insn), immsrc1, get_isrc2 (insn), auto_suff[auto_inc]);
341   }
342   else
343   {
344      if (is_load)
345         sprintf(buf, "%s%s%s\t%%r%d(%%r%d)%s,%%f%d", piped_suff[piped],
346            mnemonic, suffix[idx], get_isrc1 (insn), get_isrc2 (insn),
347            auto_suff[auto_inc], get_fdest (insn));
348      else
349         sprintf(buf, "%s%s\t%%f%d,%%r%d(%%r%d)%s", mnemonic, suffix[idx],
350            get_fdest (insn), get_isrc1 (insn), get_isrc2 (insn),
351            auto_suff[auto_inc]);
352   }
353}
354
355
356/* flush #const(isrc2)[++].  */
357static void int_flush(char *buf, char *mnemonic, UINT32 pc, UINT32 insn)
358{
359   const char *auto_suff[2] = { "", "++" };
360   INT32 immsrc = sign_ext (get_imm16 (insn), 16);
361   immsrc &= ~(16-1);
362   sprintf(buf, "%s\t%d(%%r%d)%s", mnemonic, immsrc, get_isrc2 (insn),
363      auto_suff[(insn & 1)]);
364}
365
366
367/* Flags for the decode table.  */
368enum
369{
370   DEC_MORE    = 1,    /* More decoding necessary.  */
371   DEC_DECODED = 2     /* Fully decoded, go.  */
372};
373
374
375typedef struct
376{
377   /* Disassembly function for this opcode.
378       Call with buffer, mnemonic, pc, insn.  */
379   void (*insn_dis)(char *, char *, UINT32, UINT32);
380
381    /* Flags for this opcode.  */
382   char flags;
383
384    /* Mnemonic of this opcode (sometimes partial when more decode is
385       done in disassembly routines-- e.g., loads and stores).  */
386   const char *mnemonic;
387} decode_tbl_t;
388
389
390/* First-level decode table (i.e., for the 6 primary opcode bits).  */
391static decode_tbl_t decode_tbl[64] =
392{
393   /* A slight bit of decoding for loads and stores is done in the
394       execution routines (operand size and addressing mode), which
395       is why their respective entries are identical.  */
396   { int_ldx,   DEC_DECODED, "ld."        }, /* ld.b isrc1(isrc2),idest.  */
397   { int_ldx,   DEC_DECODED, "ld."        }, /* ld.b #const(isrc2),idest.  */
398   { int_1d,    DEC_DECODED, "ixfr"       }, /* ixfr isrc1ni,fdest.        */
399   { int_stx,   DEC_DECODED, "st."        }, /* st.b isrc1ni,#const(isrc2).  */
400   { int_ldx,   DEC_DECODED, "ld."        }, /* ld.{s,l} isrc1(isrc2),idest.  */
401   { int_ldx,   DEC_DECODED, "ld."        }, /* ld.{s,l} #const(isrc2),idest.  */
402   { 0,         0           , 0           },
403   { int_stx,   DEC_DECODED, "st."        }, /* st.{s,l} isrc1ni,#const(isrc2),idest.*/
404   { int_fldst, DEC_DECODED, "fld."       }, /* fld.{l,d,q} isrc1(isrc2)[++],fdest.  */
405   { int_fldst, DEC_DECODED, "fld."       }, /* fld.{l,d,q} #const(isrc2)[++],fdest. */
406   { int_fldst, DEC_DECODED, "fst."       }, /* fst.{l,d,q} fdest,isrc1(isrc2)[++]   */
407   { int_fldst, DEC_DECODED, "fst."       }, /* fst.{l,d,q} fdest,#const(isrc2)[++]  */
408   { int_cd,    DEC_DECODED, "ld.c"       }, /* ld.c csrc2,idest.                    */
409   { int_flush, DEC_DECODED, "flush"      }, /* flush #const(isrc2) (or autoinc).    */
410   { int_1c,    DEC_DECODED, "st.c"       }, /* st.c isrc1,csrc2.                    */
411   { int_fldst, DEC_DECODED, "pstd."      }, /* pst.d fdest,#const(isrc2)[++].       */
412   { int_1,     DEC_DECODED, "bri"        }, /* bri isrc1ni.                         */
413   { int_12d,   DEC_DECODED, "trap"       }, /* trap isrc1ni,isrc2,idest.            */
414   { 0,         DEC_MORE,    0            }, /* FP ESCAPE FORMAT, more decode.       */
415   { 0,         DEC_MORE,    0            }, /* CORE ESCAPE FORMAT, more decode.     */
416   { int_12S,   DEC_DECODED, "btne"       }, /* btne isrc1,isrc2,sbroff.             */
417   { int_i2S,   DEC_DECODED, "btne"       }, /* btne #const,isrc2,sbroff.            */
418   { int_12S,   DEC_DECODED, "bte"        }, /* bte isrc1,isrc2,sbroff.              */
419   { int_i2S,   DEC_DECODED, "bte"        }, /* bte #const5,isrc2,idest.             */
420   { int_fldst, DEC_DECODED, "pfld."      }, /* pfld.{l,d,q} isrc1(isrc2)[++],fdest. */
421   { int_fldst, DEC_DECODED, "pfld."      }, /* pfld.{l,d,q} #const(isrc2)[++],fdest.*/
422   { int_L,     DEC_DECODED, "br"         }, /* br lbroff.    */
423   { int_L,     DEC_DECODED, "call"       }, /* call lbroff . */
424   { int_L,     DEC_DECODED, "bc"         }, /* bc lbroff.    */
425   { int_L,     DEC_DECODED, "bc.t"       }, /* bc.t lbroff.  */
426   { int_L,     DEC_DECODED, "bnc"        }, /* bnc lbroff.   */
427   { int_L,     DEC_DECODED, "bnc.t"      }, /* bnc.t lbroff. */
428   { int_12d,   DEC_DECODED, "addu"       }, /* addu isrc1,isrc2,idest.    */
429   { int_i2d,   DEC_DECODED, "addu"       }, /* addu #const,isrc2,idest.   */
430   { int_12d,   DEC_DECODED, "subu"       }, /* subu isrc1,isrc2,idest.    */
431   { int_i2d,   DEC_DECODED, "subu"       }, /* subu #const,isrc2,idest.   */
432   { int_12d,   DEC_DECODED, "adds"       }, /* adds isrc1,isrc2,idest.    */
433   { int_i2d,   DEC_DECODED, "adds"       }, /* adds #const,isrc2,idest.   */
434   { int_12d,   DEC_DECODED, "subs"       }, /* subs isrc1,isrc2,idest.    */
435   { int_i2d,   DEC_DECODED, "subs"       }, /* subs #const,isrc2,idest.   */
436   { int_12d,   DEC_DECODED, "shl"        }, /* shl isrc1,isrc2,idest.     */
437   { int_i2d,   DEC_DECODED, "shl"        }, /* shl #const,isrc2,idest.    */
438   { int_12d,   DEC_DECODED, "shr"        }, /* shr isrc1,isrc2,idest.     */
439   { int_i2d,   DEC_DECODED, "shr"        }, /* shr #const,isrc2,idest.    */
440   { int_12d,   DEC_DECODED, "shrd"       }, /* shrd isrc1ni,isrc2,idest.  */
441   { int_12S,   DEC_DECODED, "bla"        }, /* bla isrc1ni,isrc2,sbroff.  */
442   { int_12d,   DEC_DECODED, "shra"       }, /* shra isrc1,isrc2,idest.    */
443   { int_i2d,   DEC_DECODED, "shra"       }, /* shra #const,isrc2,idest.   */
444   { int_12d,   DEC_DECODED, "and"        }, /* and isrc1,isrc2,idest.     */
445   { int_i2d,   DEC_DECODED, "and"        }, /* and #const,isrc2,idest.    */
446   { 0,         0           , 0           },
447   { int_i2d,   DEC_DECODED, "andh"       }, /* andh #const,isrc2,idest.   */
448   { int_12d,   DEC_DECODED, "andnot"     }, /* andnot isrc1,isrc2,idest.  */
449   { int_i2d,   DEC_DECODED, "andnot"     }, /* andnot #const,isrc2,idest. */
450   { 0,         0           , 0           },
451   { int_i2d,   DEC_DECODED, "andnoth"    }, /* andnoth #const,isrc2,idest.*/
452   { int_12d,   DEC_DECODED, "or"         }, /* or isrc1,isrc2,idest.      */
453   { int_i2d,   DEC_DECODED, "or"         }, /* or #const,isrc2,idest.     */
454   { 0,         0           , 0           },
455   { int_i2d,   DEC_DECODED, "orh"        }, /* orh #const,isrc2,idest.    */
456   { int_12d,   DEC_DECODED, "xor"        }, /* xor isrc1,isrc2,idest.     */
457   { int_i2d,   DEC_DECODED, "xor"        }, /* xor #const,isrc2,idest.    */
458   { 0,         0           , 0           },
459   { int_i2d,   DEC_DECODED, "xorh"       }, /* xorh #const,isrc2,idest.   */
460};
461
462
463/* Second-level decode table (i.e., for the 3 core escape opcode bits).  */
464static decode_tbl_t core_esc_decode_tbl[8] =
465{
466   { 0,         0          , 0           },
467   { int_0,     DEC_DECODED, "lock"      }, /* lock.           */
468   { int_1,     DEC_DECODED, "calli"     }, /* calli isrc1ni.  */
469   { 0,         0          , 0           },
470   { int_0,     DEC_DECODED, "intovr"    }, /* intovr.         */
471   { 0,         0          , 0           },
472   { 0,         0          , 0           },
473   { int_0,     DEC_DECODED, "unlock"    }, /* unlock.         */
474};
475
476
477/* Second-level decode table (i.e., for the 7 FP extended opcode bits).  */
478static decode_tbl_t fp_decode_tbl[128] =
479{
480   /* Floating point instructions.  The least significant 7 bits are
481       the (extended) opcode and bits 10:7 are P,D,S,R respectively
482       ([p]ipelined, [d]ual, [s]ource prec., [r]esult prec.).
483       For some operations, I defer decoding the P,S,R bits to the
484       emulation routine for them.  */
485   { flop_12d,  DEC_DECODED, "r2p1."     }, /* 0x00 pf[m]am */
486   { flop_12d,  DEC_DECODED, "r2pt."     }, /* 0x01 pf[m]am */
487   { flop_12d,  DEC_DECODED, "r2ap1."    }, /* 0x02 pf[m]am */
488   { flop_12d,  DEC_DECODED, "r2apt."    }, /* 0x03 pf[m]am */
489   { flop_12d,  DEC_DECODED, "i2p1."     }, /* 0x04 pf[m]am */
490   { flop_12d,  DEC_DECODED, "i2pt."     }, /* 0x05 pf[m]am */
491   { flop_12d,  DEC_DECODED, "i2ap1."    }, /* 0x06 pf[m]am */
492   { flop_12d,  DEC_DECODED, "i2apt."    }, /* 0x07 pf[m]am */
493   { flop_12d,  DEC_DECODED, "rat1p2."   }, /* 0x08 pf[m]am */
494   { flop_12d,  DEC_DECODED, "m12apm."   }, /* 0x09 pf[m]am */
495   { flop_12d,  DEC_DECODED, "ra1p2."    }, /* 0x0A pf[m]am */
496   { flop_12d,  DEC_DECODED, "m12ttpa."  }, /* 0x0B pf[m]am */
497   { flop_12d,  DEC_DECODED, "iat1p2."   }, /* 0x0C pf[m]am */
498   { flop_12d,  DEC_DECODED, "m12tpm."   }, /* 0x0D pf[m]am */
499   { flop_12d,  DEC_DECODED, "ia1p2."    }, /* 0x0E pf[m]am */
500   { flop_12d,  DEC_DECODED, "m12tpa."   }, /* 0x0F pf[m]am */
501   { flop_12d,  DEC_DECODED, "r2s1."     }, /* 0x10 pf[m]sm */
502   { flop_12d,  DEC_DECODED, "r2st."     }, /* 0x11 pf[m]sm */
503   { flop_12d,  DEC_DECODED, "r2as1."    }, /* 0x12 pf[m]sm */
504   { flop_12d,  DEC_DECODED, "r2ast."    }, /* 0x13 pf[m]sm */
505   { flop_12d,  DEC_DECODED, "i2s1."     }, /* 0x14 pf[m]sm */
506   { flop_12d,  DEC_DECODED, "i2st."     }, /* 0x15 pf[m]sm */
507   { flop_12d,  DEC_DECODED, "i2as1."    }, /* 0x16 pf[m]sm */
508   { flop_12d,  DEC_DECODED, "i2ast."    }, /* 0x17 pf[m]sm */
509   { flop_12d,  DEC_DECODED, "rat1s2."   }, /* 0x18 pf[m]sm */
510   { flop_12d,  DEC_DECODED, "m12asm."   }, /* 0x19 pf[m]sm */
511   { flop_12d,  DEC_DECODED, "ra1s2."    }, /* 0x1A pf[m]sm */
512   { flop_12d,  DEC_DECODED, "m12ttsa."  }, /* 0x1B pf[m]sm */
513   { flop_12d,  DEC_DECODED, "iat1s2."   }, /* 0x1C pf[m]sm */
514   { flop_12d,  DEC_DECODED, "m12tsm."   }, /* 0x1D pf[m]sm */
515   { flop_12d,  DEC_DECODED, "ia1s2."    }, /* 0x1E pf[m]sm */
516   { flop_12d,  DEC_DECODED, "m12tsa."   }, /* 0x1F pf[m]sm */
517   { flop_12d,  DEC_DECODED, "fmul."     }, /* 0x20 [p]fmul */
518   { flop_12d,  DEC_DECODED, "fmlow."    }, /* 0x21 fmlow.dd */
519   { flop_2d,   DEC_DECODED, "frcp."     }, /* 0x22 frcp.{ss,sd,dd} */
520   { flop_2d,   DEC_DECODED, "frsqr."    }, /* 0x23 frsqr.{ss,sd,dd} */
521   { flop_12d,  DEC_DECODED, "pfmul3.dd" }, /* 0x24 pfmul3.dd */
522   { 0,         0          , 0           }, /* 0x25 */
523   { 0,         0          , 0           }, /* 0x26 */
524   { 0,         0          , 0           }, /* 0x27 */
525   { 0,         0          , 0           }, /* 0x28 */
526   { 0,         0          , 0           }, /* 0x29 */
527   { 0,         0          , 0           }, /* 0x2A */
528   { 0,         0          , 0           }, /* 0x2B */
529   { 0,         0          , 0           }, /* 0x2C */
530   { 0,         0          , 0           }, /* 0x2D */
531   { 0,         0          , 0           }, /* 0x2E */
532   { 0,         0          , 0           }, /* 0x2F */
533   { flop_12d,  DEC_DECODED, "fadd."     }, /* 0x30, [p]fadd.{ss,sd,dd} */
534   { flop_12d,  DEC_DECODED, "fsub."     }, /* 0x31, [p]fsub.{ss,sd,dd} */
535   { flop_1d,   DEC_DECODED, "fix."      }, /* 0x32, [p]fix.{ss,sd,dd} */
536   { flop_1d,   DEC_DECODED, "famov."    }, /* 0x33, [p]famov.{ss,sd,ds,dd} */
537   { flop_12d,  DEC_DECODED, "f{gt,le}"  }, /* 0x34, pf{gt,le}.{ss,dd} */
538   { flop_12d,  DEC_DECODED, "feq."      }, /* 0x35, pfeq.{ss,dd} */
539   { 0,         0          , 0           }, /* 0x36 */
540   { 0,         0          , 0           }, /* 0x37 */
541   { 0,         0          , 0           }, /* 0x38 */
542   { 0,         0          , 0           }, /* 0x39 */
543   { flop_1d,   DEC_DECODED, "ftrunc."   }, /* 0x3A, [p]ftrunc.{ss,sd,dd} */
544   { 0,         0          , 0           }, /* 0x3B */
545   { 0,         0          , 0           }, /* 0x3C */
546   { 0,         0          , 0           }, /* 0x3D */
547   { 0,         0          , 0           }, /* 0x3E */
548   { 0,         0          , 0           }, /* 0x3F */
549   { flop_fxfr, DEC_DECODED, "fxfr"      }, /* 0x40, fxfr fsrc1,idest. */
550   { 0,         0          , 0           }, /* 0x41 */
551   { 0,         0          , 0           }, /* 0x42 */
552   { 0,         0          , 0           }, /* 0x43 */
553   { 0,         0          , 0           }, /* 0x44 */
554   { 0,         0          , 0           }, /* 0x45 */
555   { 0,         0          , 0           }, /* 0x46 */
556   { 0,         0          , 0           }, /* 0x47 */
557   { 0,         0          , 0           }, /* 0x48 */
558   { flop_12d,  DEC_DECODED, "fiadd."    }, /* 0x49, [p]fiadd.{ss,dd} */
559   { 0,         0          , 0           }, /* 0x4A */
560   { 0,         0          , 0           }, /* 0x4B */
561   { 0,         0          , 0           }, /* 0x4C */
562   { flop_12d,  DEC_DECODED, "fisub."    }, /* 0x4D, [p]fisub.{ss,dd} */
563   { 0,         0          , 0           }, /* 0x4E */
564   { 0,         0          , 0           }, /* 0x4F */
565   { flop_12d,  DEC_DECODED, "faddp"     }, /* 0x50, [p]faddp */
566   { flop_12d,  DEC_DECODED, "faddz"     }, /* 0x51, [p]faddz */
567   { 0,         0          , 0           }, /* 0x52 */
568   { 0,         0          , 0           }, /* 0x53 */
569   { 0,         0          , 0           }, /* 0x54 */
570   { 0,         0          , 0           }, /* 0x55 */
571   { 0,         0          , 0           }, /* 0x56 */
572   { flop_12d,  DEC_DECODED, "fzchkl"    }, /* 0x57, [p]fzchkl */
573   { 0,         0          , 0           }, /* 0x58 */
574   { 0,         0          , 0           }, /* 0x59 */
575   { flop_1d,   DEC_DECODED, "form"      }, /* 0x5A, [p]form.dd */
576   { 0,         0          , 0           }, /* 0x5B */
577   { 0,         0          , 0           }, /* 0x5C */
578   { 0,         0          , 0           }, /* 0x5D */
579   { 0,         0          , 0           }, /* 0x5E */
580   { flop_12d,  DEC_DECODED, "fzchks"    }, /* 0x5F, [p]fzchks */
581   { 0,         0          , 0           }, /* 0x60 */
582   { 0,         0          , 0           }, /* 0x61 */
583   { 0,         0          , 0           }, /* 0x62 */
584   { 0,         0          , 0           }, /* 0x63 */
585   { 0,         0          , 0           }, /* 0x64 */
586   { 0,         0          , 0           }, /* 0x65 */
587   { 0,         0          , 0           }, /* 0x66 */
588   { 0,         0          , 0           }, /* 0x67 */
589   { 0,         0          , 0           }, /* 0x68 */
590   { 0,         0          , 0           }, /* 0x69 */
591   { 0,         0          , 0           }, /* 0x6A */
592   { 0,         0          , 0           }, /* 0x6B */
593   { 0,         0          , 0           }, /* 0x6C */
594   { 0,         0          , 0           }, /* 0x6D */
595   { 0,         0          , 0           }, /* 0x6E */
596   { 0,         0          , 0           }, /* 0x6F */
597   { 0,         0          , 0           }, /* 0x70 */
598   { 0,         0          , 0           }, /* 0x71 */
599   { 0,         0          , 0           }, /* 0x72 */
600   { 0,         0          , 0           }, /* 0x73 */
601   { 0,         0          , 0           }, /* 0x74 */
602   { 0,         0          , 0           }, /* 0x75 */
603   { 0,         0          , 0           }, /* 0x76 */
604   { 0,         0          , 0           }, /* 0x77 */
605   { 0,         0          , 0           }, /* 0x78 */
606   { 0,         0          , 0           }, /* 0x79 */
607   { 0,         0          , 0           }, /* 0x7A */
608   { 0,         0          , 0           }, /* 0x7B */
609   { 0,         0          , 0           }, /* 0x7C */
610   { 0,         0          , 0           }, /* 0x7D */
611   { 0,         0          , 0           }, /* 0x7E */
612   { 0,         0          , 0           }, /* 0x7F */
613};
614
615
616/* Replaces tabs with spaces.  */
617static void i860_dasm_tab_replacer(char* buf, int tab_size)
618{
619   int i = 0;
620   int tab_count = 0;
621   char tab_buf[1024];
622   memset(tab_buf, 0, 1024);
623
624   while (i != strlen(buf))
625   {
626      if (buf[i] != '\t')
627      {
628         tab_buf[tab_count] = buf[i];
629         tab_count++;
630      }
631      else
632      {
633         while (tab_count % tab_size != 0)
634         {
635            strcat(tab_buf, " ");
636            tab_count++;
637         }
638      }
639      i++;
640   }
641
642   tab_buf[tab_count] = 0x00;
643   strcpy(buf, tab_buf);
644}
645
646
647/* Entry point for disassembler.  */
648unsigned disasm_i860(char *buf, unsigned pc, UINT32 insn)
649{
650   int unrecognized_op = 1;
651   int upper_6bits = (insn >> 26) & 0x3f;
652   char flags = decode_tbl[upper_6bits].flags;
653   if (flags & DEC_DECODED)
654   {
655      const char *s = decode_tbl[upper_6bits].mnemonic;
656      decode_tbl[upper_6bits].insn_dis (buf, (char *)s, pc, insn);
657      unrecognized_op = 0;
658   }
659   else if (flags & DEC_MORE)
660   {
661      if (upper_6bits == 0x12)
662      {
663         /* FP instruction format handled here.  */
664         char fp_flags = fp_decode_tbl[insn & 0x7f].flags;
665         const char *s = fp_decode_tbl[insn & 0x7f].mnemonic;
666         if (fp_flags & DEC_DECODED)
667         {
668            fp_decode_tbl[insn & 0x7f].insn_dis (buf, (char *)s, pc, insn);
669            unrecognized_op = 0;
670         }
671      }
672      else if (upper_6bits == 0x13)
673      {
674         /* Core escape instruction format handled here.  */
675         char esc_flags = core_esc_decode_tbl[insn & 0x3].flags;
676         const char *s = core_esc_decode_tbl[insn & 0x3].mnemonic;
677         if (esc_flags & DEC_DECODED)
678         {
679            core_esc_decode_tbl[insn & 0x3].insn_dis (buf, (char *)s, pc, insn);
680            unrecognized_op = 0;
681         }
682      }
683   }
684
685   if (unrecognized_op)
686      sprintf (buf, ".long\t%#08x", insn);
687
688   /* Replace tabs with spaces */
689   i860_dasm_tab_replacer(buf, 10);
690
691   /* Return number of bytes disassembled.  */
692   /* MAME dasm flags haven't been added yet */
693   return (4);
694}
src/emu/cpu/i860/i860.h
r4135r4136
1/***************************************************************************
2
3    i860.h
4
5    Interface file for the Intel i860 emulator.
6
7    Copyright (C) 1995-present Jason Eckhardt (jle@rice.edu)
8    Released for general non-commercial use under the MAME license
9    with the additional requirement that you are free to use and
10    redistribute this code in modified or unmodified form, provided
11    you list me in the credits.
12    Visit http://mamedev.org for licensing and usage restrictions.
13
14***************************************************************************/
15
116#pragma once
217
318#ifndef __I860_H__
r4135r4136
520
621#include "cpuintrf.h"
722
23/***************************************************************************
24    REGISTER ENUMERATION
25***************************************************************************/
26
827enum
928{
10   I860_PC = 0
29   I860_PC = 1,
30
31   I860_FIR,
32   I860_PSR,
33   I860_DIRBASE,
34   I860_DB,
35   I860_FSR,
36   I860_EPSR,
37
38   I860_R0,  I860_R1,  I860_R2,  I860_R3,  I860_R4,  I860_R5,  I860_R6,  I860_R7,   I860_R8,  I860_R9,
39   I860_R10, I860_R11,   I860_R12, I860_R13, I860_R14, I860_R15, I860_R16, I860_R17,   I860_R18, I860_R19,
40   I860_R20, I860_R21, I860_R22, I860_R23,   I860_R24, I860_R25,   I860_R26, I860_R27,   I860_R28, I860_R29,
41   I860_R30, I860_R31,
42
43   I860_F0,  I860_F1,  I860_F2,  I860_F3,  I860_F4,  I860_F5,  I860_F6,  I860_F7,   I860_F8,  I860_F9,
44   I860_F10, I860_F11,   I860_F12, I860_F13, I860_F14, I860_F15, I860_F16, I860_F17,   I860_F18, I860_F19,
45   I860_F20, I860_F21, I860_F22, I860_F23,   I860_F24, I860_F25,   I860_F26, I860_F27,   I860_F28, I860_F29,
46   I860_F30, I860_F31,
47
1148};
1249
50/* Needed for MAME */
1351CPU_GET_INFO( i860 );
1452#define CPU_I860 CPU_GET_INFO_NAME( i860 )
1553
54
55/***************************************************************************
56    STRUCTURES & TYPEDEFS
57***************************************************************************/
58
59/* i860 state.  */
60typedef struct {
61   /* Integer registers (32 x 32-bits).  */
62   UINT32 iregs[32];
63
64   /* Floating point registers (32 x 32-bits, 16 x 64 bits, or 8 x 128 bits).
65       When referenced as pairs or quads, the higher numbered registers
66       are the upper bits. E.g., double precision f0 is f1:f0.  */
67   UINT8 frg[32 * 4];
68
69   /* Control registers (6 x 32-bits).  */
70   UINT32 cregs[6];
71
72   /* Program counter (1 x 32-bits).  Reset starts at pc=0xffffff00.  */
73   UINT32 pc;
74
75   /* Special registers (4 x 64-bits).  */
76   union
77   {
78      float s;
79      double d;
80   } KR, KI, T;
81   UINT64 merge;
82
83   /* The adder pipeline, always 3 stages.  */
84   struct
85   {
86      /* The stage contents.  */
87      union {
88         float s;
89         double d;
90      } val;
91
92      /* The stage status bits.  */
93      struct {
94         /* Adder result precision (1 = dbl, 0 = sgl).  */
95         char arp;
96      } stat;
97   } A[3];
98
99   /* The multiplier pipeline. 3 stages for single precision, 2 stages
100       for double precision, and confusing for mixed precision.  */
101   struct {
102      /* The stage contents.  */
103      union {
104         float s;
105         double d;
106      } val;
107
108      /* The stage status bits.  */
109      struct {
110         /* Multiplier result precision (1 = dbl, 0 = sgl).  */
111         char mrp;
112      } stat;
113   } M[3];
114
115   /* The load pipeline, always 3 stages.  */
116   struct {
117      /* The stage contents.  */
118      union {
119         float s;
120         double d;
121      } val;
122
123      /* The stage status bits.  */
124      struct {
125         /* Load result precision (1 = dbl, 0 = sgl).  */
126         char lrp;
127      } stat;
128   } L[3];
129
130   /* The graphics/integer pipeline, always 1 stage.  */
131   struct {
132      /* The stage contents.  */
133      union {
134         float s;
135         double d;
136      } val;
137
138      /* The stage status bits.  */
139      struct {
140         /* Integer/graphics result precision (1 = dbl, 0 = sgl).  */
141         char irp;
142      } stat;
143   } G;
144
145   /* Pins.  */
146   int pin_bus_hold;
147   int pin_reset;
148
149   /*
150     * Other emulator state.
151     */
152   int exiting_readmem;
153   int exiting_ifetch;
154
155   /* Indicate a control-flow instruction, so we know the PC is updated.  */
156   int pc_updated;
157
158   /* Indicate an instruction just generated a trap, so we know the PC
159       needs to go to the trap address.  */
160   int pending_trap;
161
162   /* This is 1 if the next fir load gets the trap address, otherwise
163       it is 0 to get the ld.c address.  This is set to 1 only when a
164       non-reset trap occurs.  */
165   int fir_gets_trap_addr;
166
167   /* Single stepping flag for internal use.  */
168   int single_stepping;
169
170   /*
171     * MAME-specific stuff.
172     */
173   const device_config *device;
174   const address_space *program;
175   UINT32 ppc;
176   int icount;
177
178} i860_state_t;
179
180
181/***************************************************************************
182    PUBLIC FUNCTIONS
183***************************************************************************/
184
185/* This is the external interface for asserting an external interrupt
186   to the i860.  */
187extern void i860_gen_interrupt(i860_state_t*);
188
189/* This is the external interface for asserting/deasserting a pin on
190   the i860.  */
191extern void i860_set_pin(i860_state_t*, int, int);
192
193/* Hard or soft reset.  */
194extern void reset_i860(i860_state_t*);
195
196/* i860 pins.  */
197enum {
198   DEC_PIN_BUS_HOLD,      /* Bus HOLD pin.      */
199   DEC_PIN_RESET         /* System reset pin.  */
200};
201
202
203/*  TODO: THESE WILL BE REPLACED BY MAME FUNCTIONS
204#define BYTE_REV32(t)   \
205  do { \
206    (t) = ((UINT32)(t) >> 16) | ((UINT32)(t) << 16); \
207    (t) = (((UINT32)(t) >> 8) & 0x00ff00ff) | (((UINT32)(t) << 8) & 0xff00ff00); \
208  } while (0);
209
210#define BYTE_REV16(t)   \
211  do { \
212    (t) = (((UINT16)(t) >> 8) & 0x00ff) | (((UINT16)(t) << 8) & 0xff00); \
213  } while (0);
214#endif
215*/
216
16217#endif /* __I860_H__ */
17218
src/emu/cpu/mcs51/mcs51dasm.c
r4135r4136
5555
5656//SFR Names
5757
58static struct {
58static const struct {
5959   int feature;
6060   int addr;
6161   const char *name;
src/emu/cpu/cop400/cop400op.c
r0r4136
1/***************************************************************************
2
3    cop400op.c
4
5    National Semiconductor COP400 Emulator.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10***************************************************************************/
11
12/***************************************************************************
13    ARITHMETIC INSTRUCTIONS
14***************************************************************************/
15
16/*
17
18    Mnemonic:           ASC
19
20    Hex Code:           30
21    Binary:             0 0 1 1 0 0 0 0
22
23    Data Flow:          A + C + RAM(B) -> A
24                        Carry -> C
25
26    Skip Conditions:    Carry
27
28    Description:        Add with Carry, Skip on Carry
29
30*/
31
32INSTRUCTION( asc )
33{
34   A = A + C + RAM_R(B);
35
36   if (A > 0xF)
37   {
38      C = 1;
39      cpustate->skip = 1;
40      A &= 0xF;
41   }
42   else
43   {
44      C = 0;
45   }
46}
47
48/*
49
50    Mnemonic:           ADD
51
52    Hex Code:           31
53    Binary:             0 0 1 1 0 0 0 1
54
55    Data Flow:          A + RAM(B) -> A
56
57    Description:        Add RAM to A
58
59*/
60
61INSTRUCTION( add )
62{
63   A = (A + RAM_R(B)) & 0x0F;
64}
65
66/*
67
68    Mnemonic:           AISC
69
70    Operand:            y
71    Hex Code:           5-
72    Binary:             0 1 0 1 y3 y2 y1 y0
73
74    Data Flow:          A + y -> A
75
76    Skip Conditions:    Carry
77
78    Description:        Add Immediate, Skip on Carry (y != 0)
79
80*/
81
82INSTRUCTION( aisc )
83{
84   UINT8 y = opcode & 0x0f;
85
86   A = A + y;
87
88   if (A > 0x0f)
89   {
90      cpustate->skip = 1;
91      A &= 0xF;
92   }
93}
94
95/*
96
97    Mnemonic:           CLRA
98
99    Hex Code:           00
100    Binary:             0 0 0 0 0 0 0 0
101
102    Data Flow:          0 -> A
103
104    Description:        Clear A
105
106*/
107
108INSTRUCTION( clra )
109{
110   A = 0;
111}
112
113/*
114
115    Mnemonic:           COMP
116
117    Hex Code:           40
118    Binary:             0 1 0 0 0 0 0 0
119
120    Data Flow:          ~A -> A
121
122    Description:        Ones Complement of A to A
123
124*/
125
126INSTRUCTION( comp )
127{
128   A = A ^ 0xF;
129}
130
131/*
132
133    Mnemonic:           NOP
134
135    Hex Code:           44
136    Binary:             0 1 0 0 0 1 0 0
137
138    Description:        No Operation
139
140*/
141
142INSTRUCTION( nop )
143{
144   // do nothing
145}
146
147/*
148
149    Mnemonic:           RC
150
151    Hex Code:           32
152    Binary:             0 0 1 1 0 0 1 0
153
154    Data Flow:          "0" -> C
155
156    Description:        Reset C
157
158*/
159
160INSTRUCTION( rc )
161{
162   C = 0;
163}
164
165/*
166
167    Mnemonic:           SC
168
169    Hex Code:           22
170    Binary:             0 0 1 0 0 0 1 0
171
172    Data Flow:          "1" -> C
173
174    Description:        Set C
175
176*/
177
178INSTRUCTION( sc )
179{
180   C = 1;
181}
182
183/*
184
185    Mnemonic:           XOR
186
187    Hex Code:           02
188    Binary:             0 0 0 0 0 0 1 0
189
190    Data Flow:          A ^ RAM(B) -> A
191
192    Description:        Exclusive-OR RAM with A
193
194*/
195
196INSTRUCTION( xor )
197{
198   A = A ^ RAM_R(B);
199}
200
201/*
202
203    Mnemonic:           ADT
204
205    Hex Code:           4A
206    Binary:             0 1 0 0 1 0 1 0
207
208    Data Flow:          A + 10 -> A
209
210    Description:        Add Ten to A
211
212*/
213
214INSTRUCTION( adt )
215{
216   A = (A + 10) & 0x0F;
217}
218
219/*
220
221    Mnemonic:           CASC
222
223    Hex Code:           10
224    Binary:             0 0 0 1 0 0 0 0
225
226    Data Flow:          ~A + RAM(B) + C -> A
227                        Carry -> C
228
229    Skip Conditions:    Carry
230
231    Description:        Complement and Add with Carry, Skip on Carry
232
233*/
234
235INSTRUCTION( casc )
236{
237   A = (A ^ 0xF) + RAM_R(B) + C;
238
239   if (A > 0xF)
240   {
241      C = 1;
242      cpustate->skip = 1;
243      A &= 0xF;
244   }
245   else
246   {
247      C = 0;
248   }
249}
250
251/***************************************************************************
252    TRANSFER-OF-CONTROL INSTRUCTIONS
253***************************************************************************/
254
255/*
256
257    Mnemonic:           JID
258
259    Hex Code:           FF
260    Binary:             1 1 1 1 1 1 1 1
261
262    Data Flow:          ROM(PC10:8,A,M) -> PC7:0
263
264    Description:        Jump Indirect
265
266*/
267
268INSTRUCTION( jid )
269{
270   UINT16 addr = (PC & 0x700) | (A << 4) | RAM_R(B);
271   PC = (PC & 0x700) | ROM(addr);
272}
273
274/*
275
276    Mnemonic:           JMP
277
278    Operand:            a
279    Hex Code:           6- --
280    Binary:             0 1 1 0 0 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0
281
282    Data Flow:          a -> PC
283
284    Description:        Jump
285
286*/
287
288INSTRUCTION( jmp )
289{
290   UINT16 a = ((opcode & 0x07) << 8) | ROM(PC);
291
292   PC = a;
293}
294
295/*
296
297    Mnemonic:           JP
298
299    Operand:            a
300    Hex Code:           --
301    Binary:             1 a6 a5 a4 a3 a2 a1 a0
302                        (pages 2,3 only)
303
304                        1 1 a5 a4 a3 a2 a1 a0
305                        (all other pages)
306
307    Data Flow:          a -> PC6:0
308
309                        a -> PC5:0
310
311    Description:        Jump within Page
312
313*/
314
315INSTRUCTION( jp )
316{
317   UINT8 page = PC >> 6;
318
319   if (page == 2 || page == 3)
320   {
321      UINT8 a = opcode & 0x7f;
322      PC = (PC & 0x780) | a;
323   }
324   else if ((opcode & 0xc0) == 0xc0)
325   {
326      UINT8 a = opcode & 0x3f;
327      PC = (PC & 0x7c0) | a;
328   }
329   else
330   {
331      // JSRP
332      UINT8 a = opcode & 0x3f;
333      PUSH(cpustate, PC);
334      PC = 0x80 | a;
335   }
336}
337
338/*
339
340    Mnemonic:           JSR
341
342    Operand:            a
343    Hex Code:           6- --
344    Binary:             0 1 1 0 1 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0
345
346    Data Flow:          PC + 1 -> SA -> SB -> SC
347                        a -> PC
348
349    Description:        Jump to Subroutine
350
351*/
352
353INSTRUCTION( jsr )
354{
355   UINT16 a = ((opcode & 0x07) << 8) | ROM(PC);
356
357   PUSH(cpustate, PC + 1);
358   PC = a;
359}
360
361/*
362
363    Mnemonic:           RET
364
365    Hex Code:           48
366    Binary:             0 1 0 0 1 0 0 0
367
368    Data Flow:          SC -> SB -> SA -> PC
369
370    Description:        Return from Subroutine
371
372*/
373
374INSTRUCTION( ret )
375{
376   POP(cpustate);
377}
378
379/*
380
381    Processor:          COP420
382
383    Mnemonic:           RET
384
385    Hex Code:           48
386    Binary:             0 1 0 0 1 0 0 0
387
388    Data Flow:          SC -> SB -> SA -> PC
389
390    Description:        Return from Subroutine, restore Skip logic
391
392*/
393
394INSTRUCTION( cop420_ret )
395{
396   POP(cpustate);
397   cpustate->skip = cpustate->last_skip;
398}
399
400/*
401
402    Mnemonic:           RETSK
403
404    Hex Code:           49
405    Binary:             0 1 0 0 1 0 0 1
406
407    Data Flow:          SC -> SB -> SA -> PC
408
409    Skip Conditions:    Always Skip on Return
410
411    Description:        Return from Subroutine then Skip
412
413*/
414
415INSTRUCTION( retsk )
416{
417   POP(cpustate);
418   cpustate->skip = 1;
419}
420
421/*
422
423    Processor:          COP410C/COP411C
424
425    Mnemonic:           HALT
426
427    Hex Code:           33 38
428    Binary:             0 0 1 1 0 0 1 1 0 0 1 1 1 0 0 0
429
430    Description:        Halt processor
431
432*/
433
434INSTRUCTION( halt )
435{
436   cpustate->halt = 1;
437}
438
439/*
440
441    Mnemonic:           IT
442
443    Hex Code:           33 39
444    Binary:             0 0 1 1 0 0 1 1 0 0 1 1 1 0 0 1
445
446    Description:        IDLE till Timer Overflows then Continues
447
448*/
449
450INSTRUCTION( it )
451{
452   cpustate->halt = 1;
453   cpustate->idle = 1;
454}
455
456/***************************************************************************
457    MEMORY REFERENCE INSTRUCTIONS
458***************************************************************************/
459
460/*
461
462    Mnemonic:           CAMQ
463
464    Hex Code:           33 3C
465    Binary:             0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0
466
467    Data Flow:          A -> Q7:4
468                        RAM(B) -> Q3:0
469
470    Description:        Copy A, RAM to Q
471
472*/
473
474INSTRUCTION( camq )
475{
476   /*
477
478        Excerpt from the COP410L data sheet:
479
480        False states may be generated on L0-L7 during the execution of the CAMQ instruction.
481        The L-ports should not be used as clocks for edge sensitive devices such as flip-flops,
482        counters, shift registers, etc. the following short program that illustrates this situation.
483
484        START:
485            CLRA        ;ENABLE THE Q
486            LEI 4       ;REGISTER TO L LINES
487            LBI TEST
488            STII 3
489            AISC 12
490        LOOP:
491            LBI TEST    ;LOAD Q WITH X'C3
492            CAMQ
493            JP LOOP
494
495        In this program the internal Q register is enabled onto the L lines and a steady bit
496        pattern of logic highs is output on L0, L1, L6, L7, and logic lows on L2-L5 via the
497        two-byte CAMQ instruction. Timing constraints on the device are such that the Q
498        register may be temporarily loaded with the second byte of the CAMQ opcode (3C) prior
499        to receiving the valid data pattern. If this occurs, the opcode will ripple onto the L
500        lines and cause negative-going glitches on L0, L1, L6, L7, and positive glitches on
501        L2-L5. Glitch durations are under 2 ms, although the exact value may vary due to data
502        patterns, processing parameters, and L line loading. These false states are peculiar
503        only to the CAMQ instruction and the L lines.
504
505    */
506
507   UINT8 data = (A << 4) | RAM_R(B);
508
509   WRITE_Q(cpustate, data);
510
511#ifdef CAMQ_BUG
512   WRITE_Q(cpustate, 0x3c);
513   WRITE_Q(cpustate, data);
514#endif
515}
516
517/*
518
519    Mnemonic:           LD
520
521    Operand:            r
522    Hex Code:           -5
523    Binary:             0 0 r1 r0 0 1 0 1
524
525    Data Flow:          RAM(B) -> A
526                        Br ^ r -> Br
527
528    Description:        Load RAM into A, Exclusive-OR Br with r
529
530*/
531
532INSTRUCTION( ld )
533{
534   UINT8 r = opcode & 0x30;
535
536   A = RAM_R(B);
537   B = B ^ r;
538}
539
540/*
541
542    Mnemonic:           LQID
543
544    Hex Code:           BF
545    Binary:             1 0 1 1 1 1 1 1
546
547    Data Flow:          ROM(PC10:8,A,M) -> Q
548                        SB -> SC
549
550    Description:        Load Q Indirect
551
552*/
553
554INSTRUCTION( lqid )
555{
556   PUSH(cpustate, PC);
557   PC = (PC & 0x700) | (A << 4) | RAM_R(B);
558   WRITE_Q(cpustate, ROM(PC));
559   POP(cpustate);
560}
561
562/*
563
564    Mnemonic:           RMB
565
566    Operand:            0
567                        1
568                        2
569                        3
570
571    Hex Code:           4C
572                        45
573                        42
574                        43
575
576    Binary:             0 1 0 0 1 1 0 0
577                        0 1 0 0 0 1 0 1
578                        0 1 0 0 0 0 1 0
579                        0 1 0 0 0 0 1 1
580
581    Data Flow:          0 -> RAM(B)0
582                        0 -> RAM(B)1
583                        0 -> RAM(B)2
584                        0 -> RAM(B)3
585
586    Description:        Reset RAM Bit
587
588*/
589
590INSTRUCTION( rmb0 ) { RAM_W(B, RAM_R(B) & 0xE); }
591INSTRUCTION( rmb1 ) { RAM_W(B, RAM_R(B) & 0xD); }
592INSTRUCTION( rmb2 ) { RAM_W(B, RAM_R(B) & 0xB); }
593INSTRUCTION( rmb3 ) { RAM_W(B, RAM_R(B) & 0x7); }
594
595/*
596
597    Mnemonic:           SMB
598
599    Operand:            0
600                        1
601                        2
602                        3
603
604    Hex Code:           4D
605                        47
606                        46
607                        4B
608
609    Binary:             0 1 0 0 1 1 0 1
610                        0 1 0 0 0 1 1 1
611                        0 1 0 0 0 1 1 0
612                        0 1 0 0 1 0 1 1
613
614    Data Flow:          1 -> RAM(B)0
615                        1 -> RAM(B)1
616                        1 -> RAM(B)2
617                        1 -> RAM(B)3
618
619    Description:        Set RAM Bit
620
621*/
622
623INSTRUCTION( smb0 ) { RAM_W(B, RAM_R(B) | 0x1); }
624INSTRUCTION( smb1 ) { RAM_W(B, RAM_R(B) | 0x2); }
625INSTRUCTION( smb2 ) { RAM_W(B, RAM_R(B) | 0x4); }
626INSTRUCTION( smb3 ) { RAM_W(B, RAM_R(B) | 0x8); }
627
628/*
629
630    Mnemonic:           STII
631
632    Operand:            y
633    Hex Code:           7-
634    Binary:             0 1 1 1 y3 y2 y1 y0
635
636    Data Flow:          y -> RAM(B)
637                        Bd + 1 -> Bd
638
639    Description:        Store Memory Immediate and Increment Bd
640
641*/
642
643INSTRUCTION( stii )
644{
645   UINT8 y = opcode & 0x0f;
646   UINT16 Bd;
647
648   RAM_W(B, y);
649
650   Bd = ((B & 0x0f) + 1) & 0x0f;
651   B = (B & 0x70) + Bd;
652}
653
654/*
655
656    Mnemonic:           X
657
658    Operand:            r
659    Hex Code:           -6
660    Binary:             0 0 r1 r0 0 1 1 0
661
662    Data Flow:          RAM(B) <-> A
663                        Br ^ r -> Br
664
665    Description:        Exchange RAM with A, Exclusive-OR Br with r
666
667*/
668
669INSTRUCTION( x )
670{
671   UINT8 r = opcode & 0x30;
672   UINT8 t = RAM_R(B);
673
674   RAM_W(B, A);
675
676   A = t;
677   B = B ^ r;
678}
679
680/*
681
682    Mnemonic:           XAD
683
684    Operand:            r,d
685    Hex Code:           23 --
686    Binary:             0 0 1 0 0 0 1 1 1 r2 r1 r0 d3 d2 d1 d0
687
688    Data Flow:          RAM(r,d) <-> A
689
690    Description:        Exchange A with RAM pointed to directly by r,d
691
692*/
693
694INSTRUCTION( xad )
695{
696   UINT8 rd = opcode & 0x7f;
697   UINT8 t = A;
698
699   A = RAM_R(rd);
700
701   RAM_W(rd, t);
702}
703
704/*
705
706    Mnemonic:           XDS
707
708    Operand:            r
709    Hex Code:           -7
710    Binary:             0 0 r1 r0 0 1 1 1
711
712    Data Flow:          RAM(B) <-> A
713                        Bd - 1 -> Bd
714                        Br ^ r -> Br
715
716    Skip Conditions:    Bd decrements past 0
717
718    Description:        Exchange RAM with A and Decrement Bd, Exclusive-OR Br with r
719
720*/
721
722INSTRUCTION( xds )
723{
724   UINT8 t, Bd;
725   UINT8 r = opcode & 0x30;
726
727   t = RAM_R(B);
728   RAM_W(B, A);
729   A = t;
730
731   Bd = ((B & 0x0f) - 1) & 0x0f;
732   B = (B & 0x30) | Bd;
733
734   B = B ^ r;
735
736   if (Bd == 0x0f) cpustate->skip = 1;
737}
738
739/*
740
741    Mnemonic:           XIS
742
743    Operand:            r
744    Hex Code:           -4
745    Binary:             0 0 r1 r0 0 1 0 0
746
747    Data Flow:          RAM(B) <-> A
748                        Bd + 1 -> Bd
749                        Br ^ r -> Br
750
751    Skip Conditions:    Bd increments past 15
752
753    Description:        Exchange RAM with A and Increment Bd, Exclusive-OR Br with r
754
755*/
756
757INSTRUCTION( xis )
758{
759   UINT8 t, Bd;
760   UINT8 r = opcode & 0x30;
761
762   t = RAM_R(B);
763   RAM_W(B, A);
764   A = t;
765
766   Bd = ((B & 0x0f) + 1) & 0x0f;
767   B = (B & 0x30) | Bd;
768
769   B = B ^ r;
770
771   if (Bd == 0x00) cpustate->skip = 1;
772}
773
774/*
775
776    Mnemonic:           CQMA
777
778    Hex Code:           33 2C
779    Binary:             0 0 1 1 0 0 1 1 0 0 1 0 1 1 0 0
780
781    Data Flow:          Q7:4 -> RAM(B)
782                        Q3:0 -> A
783
784    Description:        Copy Q to RAM, A
785
786*/
787
788INSTRUCTION( cqma )
789{
790   RAM_W(B, Q >> 4);
791   A = Q & 0xF;
792}
793
794/*
795
796    Mnemonic:           LDD
797
798    Operand:            r, d
799    Hex Code:           23 --
800    Binary:             0 0 1 0 0 0 1 1 0 r2 r1 r0 d3 d2 d1 d0
801
802    Data Flow:          RAM(r,d) -> A
803
804    Description:        Load A with RAM pointed to directly by r,d
805
806*/
807
808INSTRUCTION( ldd )
809{
810   UINT8 rd = opcode & 0x7f;
811
812   A = RAM_R(rd);
813}
814
815/*
816
817    Mnemonic:           CAMT
818
819    Hex Code:           33 3F
820    Binary:
821
822    Data Flow:          A -> T7:4
823                        RAM(B) -> T3:0
824
825    Description:        Copy A, RAM to T
826
827*/
828
829INSTRUCTION( camt )
830{
831   T = (A << 4) | RAM_R(B);
832}
833/*
834
835    Mnemonic:           CTMA
836
837    Hex Code:           33 2F
838    Binary:
839
840    Data Flow:          T7:4 -> RAM(B)
841                        T3:0 -> A
842
843    Description:        Copy T to RAM, A
844
845*/
846
847INSTRUCTION( ctma )
848{
849   RAM_W(B, T >> 4);
850   A = T & 0x0f;
851}
852
853/***************************************************************************
854    REGISTER REFERENCE INSTRUCTIONS
855***************************************************************************/
856
857/*
858
859    Mnemonic:           CAB
860
861    Hex Code:           50
862    Binary:             0 1 0 1 0 0 0 0 0
863
864    Data Flow:          A -> Bd
865
866    Description:        Copy A to Bd
867
868*/
869
870INSTRUCTION( cab )
871{
872   B = (B & 0x70) | A;
873}
874
875/*
876
877    Mnemonic:           CBA
878
879    Hex Code:           4E
880    Binary:             0 1 0 0 1 1 1 0
881
882    Data Flow:          Bd -> A
883
884    Description:        Copy Bd to A
885
886*/
887
888INSTRUCTION( cba )
889{
890   A = B & 0xF;
891}
892
893/*
894
895    Mnemonic:           LBI
896
897    Operand:            r,d
898    Hex Code:           --
899                        33 --
900
901    Binary:             0 0 r1 r0 d3 d2 d1 d0 (d-1)
902                        0 0 1 1 0 0 1 1 1 r2 r1 r0 d3 d2 d1 d0
903
904    Data Flow:          r,d -> B
905
906    Skip Conditions:    Skip until not a LBI
907
908    Description:        Load B Immediate with r,d
909
910*/
911
912INSTRUCTION( lbi )
913{
914   if (opcode & 0x80)
915   {
916      B = opcode & 0x3f;
917   }
918   else
919   {
920      B = (opcode & 0x70) | (((opcode & 0x0f) + 1) & 0x0f);
921   }
922
923   cpustate->skip_lbi = 1;
924}
925
926/*
927
928    Mnemonic:           LEI
929
930    Operand:            y
931    Hex Code:           33 6-
932    Binary:             0 0 1 1 0 0 1 1 0 1 1 0 y3 y2 y1 y0
933
934    Data Flow:          y -> EN
935
936    Description:        Load EN Immediate
937
938*/
939
940INSTRUCTION( lei )
941{
942   UINT8 y = opcode & 0x0f;
943
944   EN = y;
945
946   if (BIT(EN, 2))
947   {
948      OUT_L(Q);
949   }
950}
951
952/*
953
954    Mnemonic:           XABR
955
956    Hex Code:           12
957    Binary:             0 0 0 1 0 0 1 0
958
959    Data Flow:          A <-> Br(0,0 -> A3,A2)
960
961    Description:        Exchange A with Br
962
963*/
964
965INSTRUCTION( xabr )
966{
967   UINT8 Br = A & 0x03;
968   UINT8 Bd = B & 0x0f;
969
970   A = B >> 4;
971   B = (Br << 4) + Bd;
972}
973
974/*
975
976    Processor:          COP444
977
978    Mnemonic:           XABR
979
980    Hex Code:           12
981    Binary:             0 0 0 1 0 0 1 0
982
983    Data Flow:          A <-> Br(0 -> A3)
984
985    Description:        Exchange A with Br
986
987*/
988
989INSTRUCTION( cop444_xabr )
990{
991   UINT8 Br = A & 0x07;
992   UINT8 Bd = B & 0x0f;
993
994   A = B >> 4;
995   B = (Br << 4) + Bd;
996}
997
998/***************************************************************************
999    TEST INSTRUCTIONS
1000***************************************************************************/
1001
1002/*
1003
1004    Mnemonic:           SKC
1005
1006    Hex Code:           20
1007    Binary:             0 0 1 0 0 0 0 0
1008
1009    Skip Conditions:    C = "1"
1010
1011    Description:        Skip if C is True
1012
1013*/
1014
1015INSTRUCTION( skc )
1016{
1017   if (C == 1) cpustate->skip = 1;
1018}
1019
1020/*
1021
1022    Mnemonic:           SKE
1023
1024    Hex Code:           21
1025    Binary:             0 0 1 0 0 0 0 1
1026
1027    Skip Conditions:    A = RAM(B)
1028
1029    Description:        Skip if A Equals RAM
1030
1031*/
1032
1033INSTRUCTION( ske )
1034{
1035   if (A == RAM_R(B)) cpustate->skip = 1;
1036}
1037
1038/*
1039
1040    Mnemonic:           SKGZ
1041
1042    Hex Code:           33 21
1043    Binary:             00 0 1 1 0 0 1 1 0 0 1 0 0 0 0 1
1044
1045    Skip Conditions:    G3:0 = 0
1046
1047    Description:        Skip if G is Zero (all 4 bits)
1048
1049*/
1050
1051INSTRUCTION( skgz )
1052{
1053   if (IN_G() == 0) cpustate->skip = 1;
1054}
1055
1056/*
1057
1058    Mnemonic:           SKGBZ
1059
1060    Hex Code:           33 01
1061                        33 11
1062                        33 03
1063                        33 13
1064
1065    Binary:
1066
1067    Skip Conditions:    G0 = 0
1068                        G1 = 0
1069                        G2 = 0
1070                        G3 = 0
1071
1072    Description:        Skip if G Bit is Zero
1073
1074*/
1075
1076INLINE void skgbz(cop400_state *cpustate, int bit)
1077{
1078   if (!BIT(IN_G(), bit)) cpustate->skip = 1;
1079}
1080
1081INSTRUCTION( skgbz0 ) { skgbz(cpustate, 0); }
1082INSTRUCTION( skgbz1 ) { skgbz(cpustate, 1); }
1083INSTRUCTION( skgbz2 ) { skgbz(cpustate, 2); }
1084INSTRUCTION( skgbz3 ) { skgbz(cpustate, 3); }
1085
1086/*
1087
1088    Mnemonic:           SKMBZ
1089
1090    Hex Code:           01
1091                        11
1092                        03
1093                        13
1094
1095    Binary:
1096
1097    Skip Conditions:    RAM(B)0 = 0
1098                        RAM(B)0 = 1
1099                        RAM(B)0 = 2
1100                        RAM(B)0 = 3
1101
1102    Description:        Skip if RAM Bit is Zero
1103
1104*/
1105
1106INLINE void skmbz(cop400_state *cpustate, int bit)
1107{
1108   if (!BIT(RAM_R(B), bit)) cpustate->skip = 1;
1109}
1110
1111INSTRUCTION( skmbz0 ) { skmbz(cpustate, 0); }
1112INSTRUCTION( skmbz1 ) { skmbz(cpustate, 1); }
1113INSTRUCTION( skmbz2 ) { skmbz(cpustate, 2); }
1114INSTRUCTION( skmbz3 ) { skmbz(cpustate, 3); }
1115
1116/*
1117
1118    Mnemonic:           SKT
1119
1120    Hex Code:           41
1121    Binary:             0 1 0 0 0 0 0 1
1122
1123    Skip Conditions:    A time-base counter carry has occurred since last test
1124
1125    Description:        Skip on Timer
1126
1127*/
1128
1129INSTRUCTION( skt )
1130{
1131   if (cpustate->skt_latch)
1132   {
1133      cpustate->skt_latch = 0;
1134      cpustate->skip = 1;
1135   }
1136}
1137
1138/***************************************************************************
1139    INPUT/OUTPUT INSTRUCTIONS
1140***************************************************************************/
1141
1142/*
1143
1144    Mnemonic:           ING
1145
1146    Hex Code:           33 2A
1147    Binary:
1148
1149    Data Flow:          G -> A
1150
1151    Description:        Input G Ports to A
1152
1153*/
1154
1155INSTRUCTION( ing )
1156{
1157   A = IN_G();
1158}
1159
1160/*
1161
1162    Mnemonic:           INL
1163
1164    Hex Code:           33 2E
1165    Binary:
1166
1167    Data Flow:          L7:4 -> RAM(B)
1168                        L3:0 -> A
1169
1170    Description:        Input L Ports to RAM,A
1171
1172*/
1173
1174INSTRUCTION( inl )
1175{
1176   UINT8 L = IN_L();
1177
1178   RAM_W(B, L >> 4);
1179   A = L & 0xF;
1180}
1181
1182/*
1183
1184    Mnemonic:           OBD
1185
1186    Hex Code:           33 3E
1187    Binary:
1188
1189    Data Flow:          Bd -> D
1190
1191    Description:        Output Bd to D Outputs
1192
1193*/
1194
1195INSTRUCTION( obd )
1196{
1197   OUT_D(B & 0x0f);
1198}
1199
1200/*
1201
1202    Mnemonic:           OMG
1203
1204    Hex Code:           33 3A
1205    Binary:
1206
1207    Data Flow:          RAM(B) -> G
1208
1209    Description:        Output RAM to G Ports
1210
1211*/
1212
1213INSTRUCTION( omg )
1214{
1215   WRITE_G(cpustate, RAM_R(B));
1216}
1217
1218/*
1219
1220    Mnemonic:           XAS
1221
1222    Hex Code:           4F
1223    Binary:             0 1 0 0 1 1 1 1
1224
1225    Data Flow:          A <-> SIO
1226                        C -> SK
1227
1228    Description:        Exchange A with SIO
1229
1230*/
1231
1232INSTRUCTION( xas )
1233{
1234   UINT8 t = SIO;
1235   SIO = A;
1236   A = t;
1237
1238   SKL = C;
1239}
1240
1241/*
1242
1243    Mnemonic:           ININ
1244
1245    Hex Code:           33 28
1246    Binary:
1247
1248    Data Flow:          IN -> A
1249
1250    Description:        Input IN Inputs to A
1251
1252*/
1253
1254INSTRUCTION( inin )
1255{
1256   A = IN_IN();
1257}
1258
1259/*
1260
1261    Processor:          COP402M
1262
1263    Mnemonic:           ININ
1264
1265    Hex Code:           33 28
1266    Binary:
1267
1268    Data Flow:          IN -> A, A1 = "1"
1269
1270    Description:        Input IN Inputs to A
1271
1272*/
1273
1274INSTRUCTION( cop402m_inin )
1275{
1276   A = IN_IN() | 0x02;
1277}
1278
1279/*
1280
1281    Mnemonic:           INIL
1282
1283    Hex Code:           33 29
1284    Binary:
1285
1286    Data Flow:          IL3,CKO,"0",IL0 -> A
1287
1288    Description:        Input IL Latches to A
1289
1290*/
1291
1292INSTRUCTION( inil )
1293{
1294   A = (IL & 0x09) | IN_CKO() << 2;
1295
1296   IL = 0;
1297}
1298
1299/*
1300
1301    Mnemonic:           OGI
1302
1303    Operand:            y
1304    Hex Code:           33 5-
1305    Binary:             0 0 1 1 0 0 1 1 0 1 0 1 y3 y2 y1 y0
1306
1307    Data Flow:          y -> G
1308
1309    Description:        Output to G Ports Immediate
1310
1311*/
1312
1313INSTRUCTION( ogi )
1314{
1315   UINT8 y = opcode & 0x0f;
1316
1317   WRITE_G(cpustate, y);
1318}
src/emu/cpu/cop400/cop400.c
r0r4136
1/***************************************************************************
2
3    cop400.c
4
5    National Semiconductor COP400 Emulator.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10****************************************************************************
11
12    Type        ROM     RAM     G       D       IN
13
14    COP410      512x8   32x4                    none
15    COP411      512x8   32x4    0-2     0-1     none
16    COP401      none    32x4                    none
17    COP413?
18    COP414?
19    COP415?
20    COP405?
21
22    COP420      1024x8  64x4
23    COP421      1024x8  64x4                    none
24    COP422      1024x8  64x4    2-3     2-3     none
25    COP402      none    64x4
26
27    COP444      2048x8  128x4
28    COP445      2048x8  128x4                   none
29    COP424      1024x8  64x4
30    COP425      1024x8  64x4                    none
31    COP426      1024x8  64x4    2-3     2-3
32    COP404      none    none
33
34    COP440      2048x8  160x4
35    COP441      2048x8  160x4
36    COP442      2048x8  160x4
37
38****************************************************************************
39
40    Prefix      Temperature Range
41
42    COP4xx      0C ... 70C
43    COP3xx      -40C ... +85C
44    COP2xx      -55C ... +125C
45
46***************************************************************************/
47
48/*
49
50    TODO:
51
52    - remove LBIOps
53    - remove InstLen
54    - run interrupt test suite
55    - run production test suite
56    - run microbus test suite
57    - when is the microbus int cleared?
58    - opcode support for 2048x8 and 128x4/160x4 memory sizes
59    - CKO sync input
60    - save internal RAM when CKO is RAM power supply pin
61    - COP413/COP414/COP415/COP405
62    - COP404 opcode map switching, dual timer, microbus enable
63    - COP440/COP441/COP442 (new registers: 2-bit N, 4-bit H, 8-bit R; some new opcodes, 2Kx8 ROM, 160x4 RAM)
64
65*/
66
67#include "driver.h"
68#include "cpuintrf.h"
69#include "debugger.h"
70#include "cop400.h"
71
72/***************************************************************************
73    CONSTANTS
74***************************************************************************/
75
76/* feature masks */
77#define COP410_FEATURE   0x01
78#define COP420_FEATURE   0x02
79#define COP444_FEATURE   0x04
80#define COP440_FEATURE   0x08
81
82/***************************************************************************
83    TYPE DEFINITIONS
84***************************************************************************/
85
86typedef struct _cop400_opcode_map cop400_opcode_map;
87
88typedef struct _cop400_state cop400_state;
89struct _cop400_state
90{
91   const cop400_interface *intf;
92
93    const address_space *program;
94    const address_space *data;
95    const address_space *io;
96
97   /* registers */
98   UINT16    pc;               /* 9/10/11-bit ROM address program counter */
99   UINT16   prevpc;         /* previous value of program counter */
100   UINT8   a;            /* 4-bit accumulator */
101   UINT8   b;            /* 5/6/7-bit RAM address register */
102   int      c;            /* 1-bit carry register */
103   UINT8   n;            /* 2-bit stack pointer (COP440 only) */
104   UINT8   en;            /* 4-bit enable register */
105   UINT8   g;            /* 4-bit general purpose I/O port */
106   UINT8   q;            /* 8-bit latch for L port */
107   UINT16   sa, sb, sc;      /* subroutine save registers (not present in COP440) */
108   UINT8   sio;         /* 4-bit shift register and counter */
109   int      skl;         /* 1-bit latch for SK output */
110   UINT8   h;            /* 4-bit general purpose I/O port (COP440 only) */
111   UINT8   r;            /* 8-bit general purpose I/O port (COP440 only) */
112
113   /* counter */
114   UINT8   t;            /* 8-bit timer */
115   int      skt_latch;      /* timer overflow latch */
116
117   /* input/output ports */
118   UINT8   g_mask;         /* G port mask */
119   UINT8   d_mask;         /* D port mask */
120   UINT8   in_mask;      /* IN port mask */
121   UINT8   il;            /* IN latch */
122   UINT8   in[4];         /* IN port shift register */
123   UINT8   si;            /* serial input */
124
125   /* skipping logic */
126   int skip;            /* skip next instruction */
127   int skip_lbi;         /* skip until next non-LBI instruction */
128   int last_skip;         /* last value of skip */
129   int halt;            /* halt mode */
130   int idle;            /* idle mode */
131
132   /* microbus */
133   int microbus_int;      /* microbus interrupt */
134
135   /* execution logic */
136   int InstLen[256];      /* instruction length in bytes */
137   int LBIops[256];
138   int LBIops33[256];
139   int icount;            /* instruction counter */
140   cpu_state_table state_table;   /* state table */
141
142   const cop400_opcode_map *opcode_map;
143
144   /* timers */
145   emu_timer *serial_timer;
146   emu_timer *counter_timer;
147   emu_timer *inil_timer;
148   emu_timer *microbus_timer;
149};
150
151struct _cop400_opcode_map {
152   unsigned cycles;
153   void (*function) (cop400_state *cpustate, UINT8 opcode);
154};
155
156/***************************************************************************
157    CPU STATE DESCRIPTION
158***************************************************************************/
159
160#define COP400_STATE_ENTRY(_name, _format, _member, _datamask, _featuremask, _flags) \
161   CPU_STATE_ENTRY(COP400_##_name, #_name, _format, cop400_state, _member, _datamask, _featuremask, _flags)
162
163#define COP410_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \
164   COP400_STATE_ENTRY(_name, _format, _member, _datamask, COP410_FEATURE | COP420_FEATURE | COP444_FEATURE | COP440_FEATURE, _flags)
165
166#define COP420_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \
167   COP400_STATE_ENTRY(_name, _format, _member, _datamask, COP420_FEATURE | COP444_FEATURE | COP440_FEATURE, _flags)
168
169#define COP444_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \
170   COP400_STATE_ENTRY(_name, _format, _member, _datamask, COP444_FEATURE | COP440_FEATURE, _flags)
171
172#define COP440_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \
173   COP400_STATE_ENTRY(_name, _format, _member, _datamask, COP440_FEATURE, _flags)
174
175static const cpu_state_entry state_array[] =
176{
177   COP410_STATE_ENTRY(GENPC, "%03X", pc, 0xfff, CPUSTATE_NOSHOW)
178   COP410_STATE_ENTRY(GENPCBASE, "%03X", prevpc, 0xfff, CPUSTATE_NOSHOW)
179   COP440_STATE_ENTRY(GENSP, "%01X", n, 0x3, CPUSTATE_NOSHOW)
180
181   COP410_STATE_ENTRY(PC, "%03X", pc, 0xfff, 0)
182
183   COP400_STATE_ENTRY(SA, "%03X", sa, 0xfff, COP410_FEATURE | COP420_FEATURE | COP444_FEATURE, 0)
184   COP400_STATE_ENTRY(SB, "%03X", sb, 0xfff, COP410_FEATURE | COP420_FEATURE | COP444_FEATURE, 0)
185   COP400_STATE_ENTRY(SC, "%03X", sc, 0xfff, COP420_FEATURE | COP444_FEATURE, 0)
186   COP440_STATE_ENTRY(N, "%01X", n, 0x3, 0)
187
188   COP410_STATE_ENTRY(A, "%01X", a, 0xf, 0)
189   COP410_STATE_ENTRY(B, "%02X", b, 0xff, 0)
190   COP410_STATE_ENTRY(C, "%1u", c, 0x1, 0)
191
192   COP410_STATE_ENTRY(EN, "%01X", en, 0xf, 0)
193   COP410_STATE_ENTRY(G, "%01X", g, 0xf, 0)
194   COP440_STATE_ENTRY(H, "%01X", h, 0xf, 0)
195   COP410_STATE_ENTRY(Q, "%02X", q, 0xff, 0)
196   COP440_STATE_ENTRY(R, "%02X", r, 0xff, 0)
197
198   COP410_STATE_ENTRY(SIO, "%01X", sio, 0xf, 0)
199   COP410_STATE_ENTRY(SKL, "%1u", skl, 0x1, 0)
200
201   COP420_STATE_ENTRY(T, "%02X", t, 0xff, 0)
202};
203
204static const cpu_state_table state_table_template =
205{
206   NULL,                  /* pointer to the base of state (offsets are relative to this) */
207   0,                     /* subtype this table refers to */
208   ARRAY_LENGTH(state_array),   /* number of entries */
209   state_array               /* array of entries */
210};
211
212/***************************************************************************
213    MACROS
214***************************************************************************/
215
216#define ROM(a)         memory_decrypted_read_byte(cpustate->program, a)
217#define RAM_R(a)      memory_read_byte_8le(cpustate->data, a)
218#define RAM_W(a, v)      memory_write_byte_8le(cpustate->data, a, v)
219#define IN(a)         memory_read_byte_8le(cpustate->io, a)
220#define OUT(a, v)      memory_write_byte_8le(cpustate->io, a, v)
221
222#define IN_G()         (IN(COP400_PORT_G) & cpustate->g_mask)
223#define IN_L()         IN(COP400_PORT_L)
224#define IN_SI()         BIT(IN(COP400_PORT_SIO), 0)
225#define IN_CKO()      BIT(IN(COP400_PORT_CKO), 0)
226#define IN_IN()         (cpustate->in_mask ? IN(COP400_PORT_IN) : 0)
227
228#define OUT_G(v)      OUT(COP400_PORT_G, (v) & cpustate->g_mask)
229#define OUT_L(v)      OUT(COP400_PORT_L, (v))
230#define OUT_D(v)      OUT(COP400_PORT_D, (v) & cpustate->d_mask)
231#define OUT_SK(v)      OUT(COP400_PORT_SK, (v))
232#define OUT_SO(v)      OUT(COP400_PORT_SIO, (v))
233
234#define PC            cpustate->pc
235#define A            cpustate->a
236#define B            cpustate->b
237#define C            cpustate->c
238#define G            cpustate->g
239#define Q            cpustate->q
240#define H            cpustate->h
241#define R            cpustate->r
242#define EN            cpustate->en
243#define SA            cpustate->sa
244#define SB            cpustate->sb
245#define SC            cpustate->sc
246#define SIO            cpustate->sio
247#define SKL            cpustate->skl
248#define T            cpustate->t
249#define IL            cpustate->il
250
251/***************************************************************************
252    INLINE FUNCTIONS
253***************************************************************************/
254
255INLINE void PUSH(cop400_state *cpustate, UINT16 data)
256{
257   if (cpustate->state_table.subtypemask != COP410_FEATURE)
258   {
259      SC = SB;
260   }
261
262   SB = SA;
263   SA = data;
264}
265
266INLINE void POP(cop400_state *cpustate)
267{
268   PC = SA;
269   SA = SB;
270
271   if (cpustate->state_table.subtypemask != COP410_FEATURE)
272   {
273      SB = SC;
274   }
275}
276
277INLINE void WRITE_Q(cop400_state *cpustate, UINT8 data)
278{
279   Q = data;
280
281   if (BIT(EN, 2))
282   {
283      OUT_L(Q);
284   }
285}
286
287INLINE void WRITE_G(cop400_state *cpustate, UINT8 data)
288{
289   if (cpustate->intf->microbus == COP400_MICROBUS_ENABLED)
290   {
291      data = (data & 0x0e) | cpustate->microbus_int;
292   }
293
294   G = data;
295
296   OUT_G(G);
297}
298
299/***************************************************************************
300    OPCODE HANDLERS
301***************************************************************************/
302
303#define INSTRUCTION(mnemonic) INLINE void (mnemonic)(cop400_state *cpustate, UINT8 opcode)
304
305INSTRUCTION(illegal)
306{
307   logerror("COP400: PC = %04x, Illegal opcode = %02x\n", PC-1, ROM(PC-1));
308}
309
310#include "cop400op.c"
311
312/***************************************************************************
313    OPCODE TABLES
314***************************************************************************/
315
316static const cop400_opcode_map COP410_OPCODE_23_MAP[] =
317{
318   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
319   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
320   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
321   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
322   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
323   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
324   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
325   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
326
327   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
328   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
329   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
330   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
331   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
332   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
333   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
334   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
335
336   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
337   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
338   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
339   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
340   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
341   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
342   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
343   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, xad       },
344
345   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
346   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
347   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
348   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
349   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
350   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
351   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
352   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    }
353};
354
355static void cop410_op23(cop400_state *cpustate, UINT8 opcode)
356{
357   UINT8 opcode23 = ROM(PC++);
358
359   (*(COP410_OPCODE_23_MAP[opcode23].function))(cpustate, opcode23);
360}
361
362static const cop400_opcode_map COP410_OPCODE_33_MAP[] =
363{
364   {1, illegal    },{1, skgbz0   },{1, illegal   },{1, skgbz2   },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
365   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
366   {1, illegal    },{1, skgbz1    },{1, illegal    },{1, skgbz3    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
367   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
368   {1, illegal    },{1, skgz       },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
369   {1, illegal    },{1, illegal    },{1, ing       },{1, illegal    },{1, illegal    },{1, illegal    },{1, inl       },{1, illegal    },
370   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
371   {1, halt       },{1, illegal    },{1, omg       },{1, illegal    },{1, camq       },{1, illegal    },{1, obd       },{1, illegal    },
372
373   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
374   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
375   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
376   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
377   {1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },
378   {1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },
379   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
380   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
381
382   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
383   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
384   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
385   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
386   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
387   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
388   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
389   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
390
391   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
392   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
393   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
394   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
395   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
396   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
397   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
398   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    }
399};
400
401static void cop410_op33(cop400_state *cpustate, UINT8 opcode)
402{
403   UINT8 opcode33 = ROM(PC++);
404
405   (*(COP410_OPCODE_33_MAP[opcode33].function))(cpustate, opcode33);
406}
407
408static const cop400_opcode_map COP410_OPCODE_MAP[] =
409{
410   {1, clra      },{1, skmbz0   },{1, xor      },{1, skmbz2      },{1, xis      },{1, ld      },{1, x         },{1, xds      },
411   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
412   {0, illegal      },{1, skmbz1   },{0, illegal   },{1, skmbz3      },{1, xis      },{1, ld      },{1, x         },{1, xds      },
413   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
414   {1, skc         },{1, ske      },{1, sc      },{1, cop410_op23   },{1, xis      },{1, ld      },{1, x         },{1, xds       },
415   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
416   {1, asc         },{1, add      },{1, rc      },{1, cop410_op33   },{1, xis      },{1, ld      },{1, x         },{1, xds      },
417   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
418
419   {1, comp      },{0, illegal   },{1, rmb2      },{1, rmb3         },{1, nop      },{1, rmb1      },{1, smb2      },{1, smb1      },
420   {1,   ret         },{1, retsk      },{0, illegal   },{1, smb3         },{1, rmb0      },{1, smb0      },{1, cba      },{1, xas      },
421   {1, cab         },{1, aisc      },{1, aisc      },{1, aisc         },{1, aisc      },{1, aisc      },{1, aisc      },{1, aisc      },
422   {1, aisc      },{1, aisc      },{1, aisc      },{1, aisc         },{1, aisc      },{1, aisc      },{1, aisc      },{1, aisc      },
423   {2, jmp         },{2, jmp      },{0, illegal   },{0, illegal      },{0, illegal   },{0, illegal   },{0, illegal   },{0, illegal   },
424   {2, jsr         },{2, jsr      },{0, illegal   },{0, illegal      },{0, illegal   },{0, illegal   },{0, illegal   },{0, illegal   },
425   {1, stii      },{1, stii      },{1, stii      },{1, stii         },{1, stii      },{1, stii      },{1, stii      },{1, stii      },
426   {1, stii      },{1, stii      },{1, stii      },{1, stii         },{1, stii      },{1, stii      },{1, stii      },{1, stii      },
427
428   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
429   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
430   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
431   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
432   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
433   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
434   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
435   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{2, lqid      },
436
437   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
438   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
439   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
440   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
441   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
442   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
443   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
444   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{2, jid      }
445};
446
447static const cop400_opcode_map COP420_OPCODE_23_MAP[] =
448{
449   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
450   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
451   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
452   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
453   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
454   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
455   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
456   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
457
458   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
459   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
460   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
461   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
462   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
463   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
464   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
465   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
466
467   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
468   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
469   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
470   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
471   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
472   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
473   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
474   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
475
476   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
477   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
478   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
479   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
480   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
481   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
482   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
483   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    }
484};
485
486static void cop420_op23(cop400_state *cpustate, UINT8 opcode)
487{
488   UINT8 opcode23 = ROM(PC++);
489
490   (*(COP420_OPCODE_23_MAP[opcode23].function))(cpustate, opcode23);
491}
492
493static const cop400_opcode_map COP420_OPCODE_33_MAP[] =
494{
495   {1, illegal      },{1, skgbz0    },{1, illegal    },{1, skgbz2    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
496   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
497   {1, illegal    },{1, skgbz1    },{1, illegal    },{1, skgbz3    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
498   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
499   {1, illegal    },{1, skgz       },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
500   {1, inin       },{1, inil       },{1, ing       },{1, illegal    },{1, cqma       },{1, illegal    },{1, inl       },{1, illegal    },
501   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
502   {1, illegal    },{1, illegal    },{1, omg       },{1, illegal    },{1, camq       },{1, illegal    },{1, obd       },{1, illegal    },
503
504   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
505   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
506   {1, ogi          },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },
507   {1, ogi          },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },
508   {1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },
509   {1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },
510   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
511   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
512
513   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
514   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
515   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
516   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
517   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
518   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
519   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
520   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
521
522   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
523   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
524   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
525   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
526   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
527   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
528   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
529   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    }
530};
531
532static void cop420_op33(cop400_state *cpustate, UINT8 opcode)
533{
534   UINT8 opcode33 = ROM(PC++);
535
536   (*(COP420_OPCODE_33_MAP[opcode33].function))(cpustate, opcode33);
537}
538
539static const cop400_opcode_map COP420_OPCODE_MAP[] =
540{
541   {1, clra      },{1, skmbz0   },{1, xor      },{1, skmbz2      },{1, xis      },{1, ld      },{1, x         },{1, xds      },
542   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
543   {1, casc      },{1, skmbz1   },{1, xabr      },{1, skmbz3      },{1, xis      },{1, ld      },{1, x         },{1, xds      },
544   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
545   {1, skc         },{1, ske      },{1, sc      },{1, cop420_op23   },{1, xis      },{1, ld      },{1, x         },{1, xds       },
546   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
547   {1, asc         },{1, add      },{1, rc      },{1, cop420_op33     },{1, xis      },{1, ld      },{1, x         },{1, xds      },
548   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
549
550   {1, comp      },{1, skt      },{1, rmb2      },{1, rmb3         },{1, nop      },{1, rmb1      },{1, smb2      },{1, smb1      },
551   {1,   cop420_ret   },{1, retsk      },{1, adt      },{1, smb3         },{1, rmb0      },{1, smb0      },{1, cba      },{1, xas      },
552   {1, cab         },{1, aisc      },{1, aisc      },{1, aisc         },{1, aisc      },{1, aisc      },{1, aisc      },{1, aisc      },
553   {1, aisc      },{1, aisc      },{1, aisc      },{1, aisc         },{1, aisc      },{1, aisc      },{1, aisc      },{1, aisc      },
554   {2, jmp         },{2, jmp      },{2, jmp      },{2, jmp         },{0, illegal   },{0, illegal   },{0, illegal   },{0, illegal   },
555   {2, jsr         },{2, jsr      },{2, jsr      },{2, jsr         },{0, illegal   },{0, illegal   },{0, illegal   },{0, illegal   },
556   {1, stii      },{1, stii      },{1, stii      },{1, stii         },{1, stii      },{1, stii      },{1, stii      },{1, stii      },
557   {1, stii      },{1, stii      },{1, stii      },{1, stii         },{1, stii      },{1, stii      },{1, stii      },{1, stii      },
558
559   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
560   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
561   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
562   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
563   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
564   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
565   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
566   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{2, lqid      },
567
568   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
569   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
570   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
571   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
572   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
573   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
574   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
575   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{2, jid      }
576};
577
578static const cop400_opcode_map COP444_OPCODE_23_MAP[256] =
579{
580   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
581   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
582   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
583   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
584   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
585   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
586   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
587   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
588
589   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
590   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
591   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
592   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
593   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
594   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
595   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
596   {1, ldd          },{1, ldd      },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },{1, ldd       },
597
598   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
599   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
600   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
601   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
602   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
603   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
604   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
605   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
606
607   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
608   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
609   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
610   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
611   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
612   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
613   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
614   {1, xad          },{1, xad      },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },{1, xad       },
615};
616
617static void cop444_op23(cop400_state *cpustate, UINT8 opcode)
618{
619   UINT8 opcode23 = ROM(PC++);
620
621   (*(COP444_OPCODE_23_MAP[opcode23].function))(cpustate, opcode23);
622}
623
624static const cop400_opcode_map COP444_OPCODE_33_MAP[256] =
625{
626   {1, illegal      },{1, skgbz0    },{1, illegal    },{1, skgbz2    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
627   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
628   {1, illegal    },{1, skgbz1    },{1, illegal    },{1, skgbz3    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
629   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
630   {1, illegal    },{1, skgz       },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
631   {1, inin       },{1, inil       },{1, ing       },{1, illegal    },{1, cqma       },{1, illegal    },{1, inl       },{1, ctma       },
632   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
633   {1, it          },{1, illegal    },{1, omg       },{1, illegal    },{1, camq       },{1, illegal    },{1, obd       },{1, camt       },
634
635   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
636   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
637   {1, ogi          },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },
638   {1, ogi          },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },{1, ogi       },
639   {1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },
640   {1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },{1, lei       },
641   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
642   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
643
644   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
645   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
646   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
647   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
648   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
649   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
650   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
651   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
652
653   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
654   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
655   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
656   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
657   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
658   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
659   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
660   {1, lbi          },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },{1, lbi       },
661};
662
663static void cop444_op33(cop400_state *cpustate, UINT8 opcode)
664{
665   UINT8 opcode33 = ROM(PC++);
666
667   (*(COP444_OPCODE_33_MAP[opcode33].function))(cpustate, opcode33);
668}
669
670static const cop400_opcode_map COP444_OPCODE_MAP[256] =
671{
672   {1, clra      },{1, skmbz0   },{1, xor      },{1, skmbz2      },{1, xis      },{1, ld      },{1, x         },{1, xds      },
673   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
674   {1, casc      },{1, skmbz1   },{1, cop444_xabr},{1, skmbz3      },{1, xis      },{1, ld      },{1, x         },{1, xds      },
675   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
676   {1, skc         },{1, ske      },{1, sc      },{1, cop444_op23   },{1, xis      },{1, ld      },{1, x         },{1, xds       },
677   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
678   {1, asc         },{1, add      },{1, rc      },{1, cop444_op33     },{1, xis      },{1, ld      },{1, x         },{1, xds      },
679   {1, lbi         },{1, lbi      },{1, lbi      },{1, lbi         },{1, lbi      },{1, lbi      },{1, lbi      },{1, lbi      },
680
681   {1, comp      },{1, skt      },{1, rmb2      },{1, rmb3         },{1, nop      },{1, rmb1      },{1, smb2      },{1, smb1      },
682   {1,   cop420_ret   },{1, retsk      },{1, adt      },{1, smb3         },{1, rmb0      },{1, smb0      },{1, cba      },{1, xas      },
683   {1, cab         },{1, aisc      },{1, aisc      },{1, aisc         },{1, aisc      },{1, aisc      },{1, aisc      },{1, aisc      },
684   {1, aisc      },{1, aisc      },{1, aisc      },{1, aisc         },{1, aisc      },{1, aisc      },{1, aisc      },{1, aisc      },
685   {2, jmp         },{2, jmp      },{2, jmp      },{2, jmp         },{2, jmp      },{2, jmp      },{2, jmp      },{2, jmp      },
686   {2, jsr         },{2, jsr      },{2, jsr      },{2, jsr         },{2, jsr      },{2, jsr      },{2, jsr      },{2, jsr      },
687   {1, stii      },{1, stii      },{1, stii      },{1, stii         },{1, stii      },{1, stii      },{1, stii      },{1, stii      },
688   {1, stii      },{1, stii      },{1, stii      },{1, stii         },{1, stii      },{1, stii      },{1, stii      },{1, stii      },
689
690   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
691   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
692   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
693   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
694   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
695   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
696   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
697   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{2, lqid      },
698
699   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
700   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
701   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
702   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
703   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
704   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
705   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{1, jp      },
706   {1, jp         },{1, jp      },{1, jp      },{1, jp         },{1, jp      },{1, jp      },{1, jp      },{2, jid      }
707};
708
709/***************************************************************************
710    TIMER CALLBACKS
711***************************************************************************/
712
713static TIMER_CALLBACK( serial_tick )
714{
715   cop400_state *cpustate = ptr;
716
717   if (BIT(EN, 0))
718   {
719      /*
720
721            SIO is an asynchronous binary counter decrementing its value by one upon each low-going pulse ("1" to "0") occurring on the SI input.
722            Each pulse must remain at each logic level at least two instruction cycles. SK outputs the value of the C upon the execution of an XAS
723            and remains latched until the execution of another XAS instruction. The SO output is equal to the value of EN3.
724
725        */
726
727      // serial output
728
729      OUT_SO(BIT(EN, 3));
730
731      // serial clock
732
733      OUT_SK(SKL);
734
735      // serial input
736
737      cpustate->si <<= 1;
738      cpustate->si = (cpustate->si & 0x0e) | IN_SI();
739
740      if ((cpustate->si & 0x0f) == 0x0c) // 1100
741      {
742         SIO--;
743         SIO &= 0x0f;
744      }
745   }
746   else
747   {
748      /*
749
750            SIO is a serial shift register, shifting continuously left each instruction cycle time. The data present at SI goes into the least
751            significant bit of SIO: SO can be enabled to output the most significant bit of SIO each cycle time. SK output becomes a logic-
752            controlled clock, providing a SYNC signal each instruction time. It will start outputting a SYNC pulse upon the execution of an XAS
753            instruction with C = "1," stopping upon the execution of a subsequent XAS with C = "0".
754
755            If EN0 is changed from "1" to "0" ("0" to "1") the SK output will change from "1" to SYNC (SYNC to "1") without the execution of
756            an XAS instruction.
757
758        */
759
760      // serial output
761
762      if (BIT(EN, 3))
763      {
764         OUT_SO(BIT(SIO, 3));
765      }
766      else
767      {
768         OUT_SO(0);
769      }
770
771      // serial clock
772
773      if (SKL)
774      {
775         OUT_SK(1); // SYNC
776      }
777      else
778      {
779         OUT_SK(0);
780      }
781
782      // serial input
783
784      SIO = ((SIO << 1) | IN_SI()) & 0x0f;
785   }
786}
787
788static TIMER_CALLBACK( counter_tick )
789{
790   cop400_state *cpustate = ptr;
791
792   T++;
793
794   if (T == 0)
795   {
796      cpustate->skt_latch = 1;
797
798      if (cpustate->idle)
799      {
800         cpustate->idle = 0;
801         cpustate->halt = 0;
802      }
803   }
804}
805
806static TIMER_CALLBACK( inil_tick )
807{
808   cop400_state *cpustate = ptr;
809   UINT8 in;
810   int i;
811
812   in = IN_IN();
813
814   for (i = 0; i < 4; i++)
815   {
816      cpustate->in[i] = (cpustate->in[i] << 1) | BIT(in, i);
817
818      if ((cpustate->in[i] & 0x07) == 0x04) // 100
819      {
820         IL |= (1 << i);
821      }
822   }
823}
824
825static TIMER_CALLBACK( microbus_tick )
826{
827   cop400_state *cpustate = ptr;
828   UINT8 in;
829
830   in = IN_IN();
831
832   if (!BIT(in, 2))
833   {
834      // chip select
835
836      if (!BIT(in, 1))
837      {
838         // read strobe
839
840         OUT_L(Q);
841
842         cpustate->microbus_int = 1;
843      }
844      else if (!BIT(in, 3))
845      {
846         // write strobe
847
848         Q = IN_L();
849
850         cpustate->microbus_int = 0;
851      }
852   }
853}
854
855/***************************************************************************
856    INITIALIZATION
857***************************************************************************/
858
859static void cop400_init(const device_config *device, UINT8 g_mask, UINT8 d_mask, UINT8 in_mask, int has_counter, int has_inil)
860{
861   cop400_state *cpustate = device->token;
862
863   cpustate->intf = (cop400_interface *) device->static_config;
864
865   /* find address spaces */
866
867   cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
868   cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
869   cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
870
871   /* set output pin masks */
872
873   cpustate->g_mask = g_mask;
874   cpustate->d_mask = d_mask;
875   cpustate->in_mask = in_mask;
876
877   /* set clock divider */
878
879   device_set_info_int(device, CPUINFO_INT_CLOCK_DIVIDER, cpustate->intf->cki);
880
881   /* allocate serial timer */
882
883   cpustate->serial_timer = timer_alloc(device->machine, serial_tick, cpustate);
884   timer_adjust_periodic(cpustate->serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16));
885
886   /* allocate counter timer */
887
888   if (has_counter)
889   {
890      cpustate->counter_timer = timer_alloc(device->machine, counter_tick, cpustate);
891      timer_adjust_periodic(cpustate->counter_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16 / 4));
892   }
893
894   /* allocate IN latch timer */
895
896   if (has_inil)
897   {
898      cpustate->inil_timer = timer_alloc(device->machine, inil_tick, cpustate);
899      timer_adjust_periodic(cpustate->inil_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16));
900   }
901
902   /* allocate Microbus timer */
903
904   if (cpustate->intf->microbus == COP400_MICROBUS_ENABLED)
905   {
906      cpustate->microbus_timer = timer_alloc(device->machine, microbus_tick, cpustate);
907      timer_adjust_periodic(cpustate->microbus_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16));
908   }
909
910   /* register for state saving */
911
912   state_save_register_device_item(device, 0, cpustate->pc);
913   state_save_register_device_item(device, 0, cpustate->prevpc);
914   state_save_register_device_item(device, 0, cpustate->n);
915   state_save_register_device_item(device, 0, cpustate->sa);
916   state_save_register_device_item(device, 0, cpustate->sb);
917   state_save_register_device_item(device, 0, cpustate->sc);
918   state_save_register_device_item(device, 0, cpustate->a);
919   state_save_register_device_item(device, 0, cpustate->b);
920   state_save_register_device_item(device, 0, cpustate->c);
921   state_save_register_device_item(device, 0, cpustate->g);
922   state_save_register_device_item(device, 0, cpustate->h);
923   state_save_register_device_item(device, 0, cpustate->q);
924   state_save_register_device_item(device, 0, cpustate->r);
925   state_save_register_device_item(device, 0, cpustate->en);
926   state_save_register_device_item(device, 0, cpustate->sio);
927   state_save_register_device_item(device, 0, cpustate->skl);
928   state_save_register_device_item(device, 0, cpustate->t);
929   state_save_register_device_item(device, 0, cpustate->skip);
930   state_save_register_device_item(device, 0, cpustate->skip_lbi);
931   state_save_register_device_item(device, 0, cpustate->skt_latch);
932   state_save_register_device_item(device, 0, cpustate->si);
933   state_save_register_device_item(device, 0, cpustate->last_skip);
934   state_save_register_device_item_array(device, 0, cpustate->in);
935   state_save_register_device_item(device, 0, cpustate->microbus_int);
936   state_save_register_device_item(device, 0, cpustate->halt);
937   state_save_register_device_item(device, 0, cpustate->idle);
938}
939
940static void cop410_init_opcodes(const device_config *device)
941{
942   cop400_state *cpustate = device->token;
943   int i;
944
945   /* set up the state table */
946
947   cpustate->state_table = state_table_template;
948   cpustate->state_table.baseptr = cpustate;
949   cpustate->state_table.subtypemask = COP410_FEATURE;
950
951   /* initialize instruction length array */
952
953   for (i=0; i<256; i++) cpustate->InstLen[i]=1;
954
955   cpustate->InstLen[0x60] = cpustate->InstLen[0x61] = cpustate->InstLen[0x68] =
956   cpustate->InstLen[0x69] = cpustate->InstLen[0x33] = cpustate->InstLen[0x23] = 2;
957
958   /* initialize LBI opcode array */
959
960   for (i=0; i<256; i++) cpustate->LBIops[i] = 0;
961   for (i=0x08; i<0x10; i++) cpustate->LBIops[i] = 1;
962   for (i=0x18; i<0x20; i++) cpustate->LBIops[i] = 1;
963   for (i=0x28; i<0x30; i++) cpustate->LBIops[i] = 1;
964   for (i=0x38; i<0x40; i++) cpustate->LBIops[i] = 1;
965
966   /* select opcode map */
967
968   cpustate->opcode_map = COP410_OPCODE_MAP;
969}
970
971static void cop420_init_opcodes(const device_config *device)
972{
973   cop400_state *cpustate = device->token;
974   int i;
975
976   /* set up the state table */
977
978   cpustate->state_table = state_table_template;
979   cpustate->state_table.baseptr = cpustate;
980   cpustate->state_table.subtypemask = COP420_FEATURE;
981
982   /* initialize instruction length array */
983
984   for (i=0; i<256; i++) cpustate->InstLen[i]=1;
985
986   cpustate->InstLen[0x60] = cpustate->InstLen[0x61] = cpustate->InstLen[0x62] = cpustate->InstLen[0x63] =
987   cpustate->InstLen[0x68] = cpustate->InstLen[0x69] = cpustate->InstLen[0x6a] = cpustate->InstLen[0x6b] =
988   cpustate->InstLen[0x33] = cpustate->InstLen[0x23] = 2;
989
990   /* initialize LBI opcode array */
991
992   for (i=0; i<256; i++) cpustate->LBIops[i] = 0;
993   for (i=0x08; i<0x10; i++) cpustate->LBIops[i] = 1;
994   for (i=0x18; i<0x20; i++) cpustate->LBIops[i] = 1;
995   for (i=0x28; i<0x30; i++) cpustate->LBIops[i] = 1;
996   for (i=0x38; i<0x40; i++) cpustate->LBIops[i] = 1;
997
998   for (i=0; i<256; i++) cpustate->LBIops33[i] = 0;
999   for (i=0x80; i<0xc0; i++) cpustate->LBIops33[i] = 1;
1000
1001   /* select opcode map */
1002
1003   cpustate->opcode_map = COP420_OPCODE_MAP;
1004}
1005
1006static void cop444_init_opcodes(const device_config *device)
1007{
1008   cop400_state *cpustate = device->token;
1009   int i;
1010
1011   /* set up the state table */
1012
1013   cpustate->state_table = state_table_template;
1014   cpustate->state_table.baseptr = cpustate;
1015   cpustate->state_table.subtypemask = COP444_FEATURE;
1016
1017   /* initialize instruction length array */
1018
1019   for (i=0; i<256; i++) cpustate->InstLen[i]=1;
1020
1021   cpustate->InstLen[0x60] = cpustate->InstLen[0x61] = cpustate->InstLen[0x62] = cpustate->InstLen[0x63] =
1022   cpustate->InstLen[0x68] = cpustate->InstLen[0x69] = cpustate->InstLen[0x6a] = cpustate->InstLen[0x6b] =
1023   cpustate->InstLen[0x33] = cpustate->InstLen[0x23] = 2;
1024
1025   /* initialize LBI opcode array */
1026
1027   for (i=0; i<256; i++) cpustate->LBIops[i] = 0;
1028   for (i=0x08; i<0x10; i++) cpustate->LBIops[i] = 1;
1029   for (i=0x18; i<0x20; i++) cpustate->LBIops[i] = 1;
1030   for (i=0x28; i<0x30; i++) cpustate->LBIops[i] = 1;
1031   for (i=0x38; i<0x40; i++) cpustate->LBIops[i] = 1;
1032
1033   for (i=0; i<256; i++) cpustate->LBIops33[i] = 0;
1034   for (i=0x80; i<0xc0; i++) cpustate->LBIops33[i] = 1;
1035
1036   /* select opcode map */
1037
1038   cpustate->opcode_map = COP444_OPCODE_MAP;
1039}
1040
1041static CPU_INIT( cop410 )
1042{
1043   cop410_init_opcodes(device);
1044   cop400_init(device, 0xf, 0xf, 0, 0, 0);
1045}
1046
1047static CPU_INIT( cop411 )
1048{
1049   cop410_init_opcodes(device);
1050   cop400_init(device, 0x7, 0x3, 0, 0, 0);
1051}
1052
1053static CPU_INIT( cop420 )
1054{
1055   cop420_init_opcodes(device);
1056   cop400_init(device, 0xf, 0xf, 0xf, 1, 1);
1057}
1058
1059static CPU_INIT( cop421 )
1060{
1061   cop420_init_opcodes(device);
1062   cop400_init(device, 0xf, 0xf, 0, 1, 0);
1063}
1064
1065static CPU_INIT( cop422 )
1066{
1067   cop420_init_opcodes(device);
1068   cop400_init(device, 0xe, 0xe, 0, 1, 0);
1069}
1070
1071static CPU_INIT( cop444 )
1072{
1073   cop444_init_opcodes(device);
1074   cop400_init(device, 0xf, 0xf, 0xf, 1, 1);
1075}
1076
1077static CPU_INIT( cop425 )
1078{
1079   cop444_init_opcodes(device);
1080   cop400_init(device, 0xf, 0xf, 0, 1, 0);
1081}
1082
1083static CPU_INIT( cop426 )
1084{
1085   cop444_init_opcodes(device);
1086   cop400_init(device, 0xe, 0xe, 0xf, 1, 1);
1087}
1088
1089static CPU_INIT( cop445 )
1090{
1091   cop444_init_opcodes(device);
1092   cop400_init(device, 0x7, 0x3, 0, 1, 0);
1093}
1094
1095/***************************************************************************
1096    RESET
1097***************************************************************************/
1098
1099static CPU_RESET( cop400 )
1100{
1101   cop400_state *cpustate = device->token;
1102
1103   PC = 0;
1104   A = 0;
1105   B = 0;
1106   C = 0;
1107   OUT_D(0);
1108   EN = 0;
1109   WRITE_G(cpustate, 0);
1110   SKL = 1;
1111
1112   T = 0;
1113   cpustate->skt_latch = 1;
1114
1115   cpustate->halt = 0;
1116   cpustate->idle = 0;
1117}
1118
1119/***************************************************************************
1120    EXECUTION
1121***************************************************************************/
1122
1123static CPU_EXECUTE( cop400 )
1124{
1125   cop400_state *cpustate = device->token;
1126
1127   UINT8 opcode;
1128
1129   cpustate->icount = cycles;
1130
1131   do
1132   {
1133      cpustate->prevpc = PC;
1134
1135      debugger_instruction_hook(device, PC);
1136
1137      if (cpustate->intf->cko == COP400_CKO_HALT_IO_PORT)
1138      {
1139         cpustate->halt = IN_CKO();
1140      }
1141
1142      if (cpustate->halt)
1143      {
1144         cpustate->icount -= 1;
1145         continue;
1146      }
1147
1148      opcode = ROM(PC);
1149
1150      if (cpustate->skip_lbi)
1151      {
1152         int is_lbi = 0;
1153
1154         if (opcode == 0x33)
1155         {
1156            is_lbi = cpustate->LBIops33[ROM(PC+1)];
1157         }
1158         else
1159         {
1160            is_lbi = cpustate->LBIops[opcode];
1161         }
1162
1163         if (is_lbi)
1164         {
1165            cpustate->icount -= cpustate->opcode_map[opcode].cycles;
1166
1167            PC += cpustate->InstLen[opcode];
1168         }
1169         else
1170         {
1171            cpustate->skip_lbi = 0;
1172         }
1173      }
1174
1175      if (!cpustate->skip_lbi)
1176      {
1177         int inst_cycles = cpustate->opcode_map[opcode].cycles;
1178
1179         PC++;
1180
1181         (*(cpustate->opcode_map[opcode].function))(cpustate, opcode);
1182         cpustate->icount -= inst_cycles;
1183
1184         // check for interrupt
1185
1186         if (BIT(EN, 1) && BIT(IL, 1))
1187         {
1188            void *function = cpustate->opcode_map[ROM(PC)].function;
1189
1190            if ((function != jp) &&   (function != jmp) && (function != jsr))
1191            {
1192               // store skip logic
1193               cpustate->last_skip = cpustate->skip;
1194               cpustate->skip = 0;
1195
1196               // push next PC
1197               PUSH(cpustate, PC);
1198
1199               // jump to interrupt service routine
1200               PC = 0x0ff;
1201
1202               // disable interrupt
1203               EN &= ~0x02;
1204            }
1205
1206            IL &= ~2;
1207         }
1208
1209         // skip next instruction?
1210
1211         if (cpustate->skip)
1212         {
1213            void *function = cpustate->opcode_map[ROM(PC)].function;
1214
1215            opcode = ROM(PC);
1216
1217            if ((function == lqid) || (function == jid))
1218            {
1219               cpustate->icount -= 1;
1220            }
1221            else
1222            {
1223               cpustate->icount -= cpustate->opcode_map[opcode].cycles;
1224            }
1225
1226            PC += cpustate->InstLen[opcode];
1227
1228            cpustate->skip = 0;
1229         }
1230      }
1231   } while (cpustate->icount > 0);
1232
1233   return cycles - cpustate->icount;
1234}
1235
1236/***************************************************************************
1237    ADDRESS MAPS
1238***************************************************************************/
1239
1240static ADDRESS_MAP_START( program_512b, ADDRESS_SPACE_PROGRAM, 8 )
1241   AM_RANGE(0x000, 0x1ff) AM_ROM
1242ADDRESS_MAP_END
1243
1244static ADDRESS_MAP_START( program_1kb, ADDRESS_SPACE_PROGRAM, 8 )
1245   AM_RANGE(0x000, 0x3ff) AM_ROM
1246ADDRESS_MAP_END
1247
1248static ADDRESS_MAP_START( program_2kb, ADDRESS_SPACE_PROGRAM, 8 )
1249   AM_RANGE(0x000, 0x7ff) AM_ROM
1250ADDRESS_MAP_END
1251
1252static ADDRESS_MAP_START( data_32b, ADDRESS_SPACE_DATA, 8 )
1253   AM_RANGE(0x00, 0x1f) AM_RAM
1254ADDRESS_MAP_END
1255
1256static ADDRESS_MAP_START( data_64b, ADDRESS_SPACE_DATA, 8 )
1257   AM_RANGE(0x00, 0x3f) AM_RAM
1258ADDRESS_MAP_END
1259
1260static ADDRESS_MAP_START( data_128b, ADDRESS_SPACE_DATA, 8 )
1261   AM_RANGE(0x00, 0x7f) AM_RAM
1262ADDRESS_MAP_END
1263
1264static ADDRESS_MAP_START( data_160b, ADDRESS_SPACE_DATA, 8 )
1265   AM_RANGE(0x00, 0x9f) AM_RAM
1266ADDRESS_MAP_END
1267
1268/***************************************************************************
1269    VALIDITY CHECKS
1270***************************************************************************/
1271
1272static CPU_VALIDITY_CHECK( cop410 )
1273{
1274   int error = FALSE;
1275   const cop400_interface *intf = (const cop400_interface *) config;
1276
1277   if ((intf == NULL) || (intf->cki <= 0))
1278   {
1279      mame_printf_error("%s: %s has an invalid CPU configuration\n", driver->source_file, driver->name);
1280      error = TRUE;
1281   }
1282
1283   return error;
1284}
1285
1286static CPU_VALIDITY_CHECK( cop420 )
1287{
1288   int error = FALSE;
1289   const cop400_interface *intf = (const cop400_interface *) config;
1290
1291   if ((intf == NULL) || (intf->cki <= 0))
1292   {
1293      mame_printf_error("%s: %s has an invalid CPU configuration\n", driver->source_file, driver->name);
1294      error = TRUE;
1295   }
1296
1297   return error;
1298}
1299
1300static CPU_VALIDITY_CHECK( cop421 )
1301{
1302   int error = FALSE;
1303   const cop400_interface *intf = (const cop400_interface *) config;
1304
1305   if ((intf == NULL) || (intf->cki <= 0) || (intf->microbus == COP400_MICROBUS_ENABLED))
1306   {
1307      mame_printf_error("%s: %s has an invalid CPU configuration\n", driver->source_file, driver->name);
1308      error = TRUE;
1309   }
1310
1311   return error;
1312}
1313
1314static CPU_VALIDITY_CHECK( cop444 )
1315{
1316   int error = FALSE;
1317   const cop400_interface *intf = (const cop400_interface *) config;
1318
1319   if ((intf == NULL) || (intf->cki <= 0))
1320   {
1321      mame_printf_error("%s: %s has an invalid CPU configuration\n", driver->source_file, driver->name);
1322      error = TRUE;
1323   }
1324
1325   return error;
1326}
1327
1328/***************************************************************************
1329    GENERAL CONTEXT ACCESS
1330***************************************************************************/
1331
1332static CPU_SET_INFO( cop400 )
1333{
1334   /* nothing to set */
1335}
1336
1337static CPU_GET_INFO( cop400 )
1338{
1339   cop400_state *cpustate = (device != NULL) ? device->token : NULL;
1340
1341   switch (state)
1342   {
1343      /* --- the following bits of info are returned as 64-bit signed integers --- */
1344      case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(cop400_state);                     break;
1345      case CPUINFO_INT_INPUT_LINES:               info->i = 0;                                 break;
1346      case CPUINFO_INT_DEFAULT_IRQ_VECTOR:         info->i = 0;                                 break;
1347      case CPUINFO_INT_ENDIANNESS:               info->i = ENDIANNESS_LITTLE;                     break;
1348      case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;                                 break;
1349      case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 16;                                 break;
1350      case CPUINFO_INT_MIN_INSTRUCTION_BYTES:         info->i = 1;                                 break;
1351      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 2;                                 break;
1352      case CPUINFO_INT_MIN_CYCLES:               info->i = 1;                                 break;
1353      case CPUINFO_INT_MAX_CYCLES:               info->i = 2;                                 break;
1354
1355      case CPUINFO_INT_DATABUS_WIDTH_PROGRAM:         info->i = 8;                                 break;
1356      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         /* set per-core */                              break;
1357      case CPUINFO_INT_ADDRBUS_SHIFT_PROGRAM:         info->i = 0;                                 break;
1358      case CPUINFO_INT_DATABUS_WIDTH_DATA:         info->i = 8; /* really 4 */                        break;
1359      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:          /* set per-core */                              break;
1360      case CPUINFO_INT_ADDRBUS_SHIFT_DATA:          info->i = 0;                                 break;
1361      case CPUINFO_INT_DATABUS_WIDTH_IO:            info->i = 8;                                 break;
1362      case CPUINFO_INT_ADDRBUS_WIDTH_IO:             info->i = 9;                                 break;
1363      case CPUINFO_INT_ADDRBUS_SHIFT_IO:             info->i = 0;                                 break;
1364
1365      /* --- the following bits of info are returned as pointers to functions --- */
1366      case CPUINFO_FCT_SET_INFO:                  info->setinfo = CPU_SET_INFO_NAME(cop400);            break;
1367      case CPUINFO_FCT_INIT:                     /* set per-core */                              break;
1368      case CPUINFO_FCT_RESET:                     info->reset = CPU_RESET_NAME(cop400);               break;
1369      case CPUINFO_FCT_EXECUTE:                  info->execute = CPU_EXECUTE_NAME(cop400);            break;
1370      case CPUINFO_FCT_DISASSEMBLE:               /* set per-core */                              break;
1371      case CPUINFO_FCT_VALIDITY_CHECK:            /* set per-core */                              break;
1372
1373      /* --- the following bits of info are returned as pointers --- */
1374      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &cpustate->icount;                  break;
1375      case CPUINFO_PTR_STATE_TABLE:               info->state_table = &cpustate->state_table;            break;
1376      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   /* set per-core */                              break;
1377      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:       /* set per-core */                               break;
1378
1379      /* --- the following bits of info are returned as NULL-terminated strings --- */
1380      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP400");                        break;
1381      case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "National Semiconductor COPS");         break;
1382      case CPUINFO_STR_CORE_VERSION:               strcpy(info->s, "1.0");                           break;
1383      case CPUINFO_STR_CORE_FILE:                  strcpy(info->s, __FILE__);                        break;
1384      case CPUINFO_STR_CORE_CREDITS:               strcpy(info->s, "Copyright MAME Team");               break;
1385   }
1386}
1387
1388/***************************************************************************
1389    CPU-SPECIFIC CONTEXT ACCESS
1390***************************************************************************/
1391
1392CPU_GET_INFO( cop410 )
1393{
1394   cop400_state *cpustate = (device != NULL) ? device->token : NULL;
1395
1396   switch (state)
1397   {
1398      /* --- the following bits of info are returned as 64-bit signed integers --- */
1399      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 9;                                 break;
1400      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:          info->i = 5;                                 break;
1401
1402      /* --- the following bits of info are returned as pointers to functions --- */
1403      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(cop410);                  break;
1404      case CPUINFO_FCT_DISASSEMBLE:               info->disassemble = CPU_DISASSEMBLE_NAME(cop410);      break;
1405      case CPUINFO_FCT_VALIDITY_CHECK:            info->validity_check = CPU_VALIDITY_CHECK_NAME(cop410);   break;
1406
1407      /* --- the following bits of info are returned as pointers --- */
1408      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map8 = ADDRESS_MAP_NAME(program_512b);   break;
1409      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:      info->internal_map8 = ADDRESS_MAP_NAME(data_32b);      break;
1410
1411      /* --- the following bits of info are returned as NULL-terminated strings --- */
1412      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP410");                        break;
1413
1414      case CPUINFO_STR_FLAGS: sprintf(info->s,
1415                           "%c%c",
1416                            cpustate->c ? 'C' : '.',
1417                            cpustate->skl ? 'S' : '.'); break;
1418
1419      default:                              CPU_GET_INFO_CALL(cop400);                        break;
1420   }
1421}
1422
1423CPU_GET_INFO( cop411 )
1424{
1425   // COP411 is a 20-pin package version of the COP410, missing D2/D3/G3/CKO
1426
1427   switch (state)
1428   {
1429      /* --- the following bits of info are returned as pointers to data or functions --- */
1430      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(cop411);                  break;
1431
1432      /* --- the following bits of info are returned as NULL-terminated strings --- */
1433      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP411");                        break;
1434
1435      default:                              CPU_GET_INFO_CALL(cop410);                        break;
1436   }
1437}
1438
1439CPU_GET_INFO( cop401 )
1440{
1441   // COP401 is a ROMless version of the COP410
1442
1443   switch (state)
1444   {
1445      /* --- the following bits of info are returned as pointers --- */
1446      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map8 = NULL;                        break;
1447
1448      /* --- the following bits of info are returned as NULL-terminated strings --- */
1449      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP401");                        break;
1450
1451      default:                              CPU_GET_INFO_CALL(cop410);                        break;
1452   }
1453}
1454
1455CPU_GET_INFO( cop420 )
1456{
1457   cop400_state *cpustate = (device != NULL) ? device->token : NULL;
1458
1459   switch (state)
1460   {
1461      /* --- the following bits of info are returned as 64-bit signed integers --- */
1462      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 10;                                 break;
1463      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:          info->i = 6;                                 break;
1464
1465      /* --- the following bits of info are returned as pointers to functions --- */
1466      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(cop420);                  break;
1467      case CPUINFO_FCT_DISASSEMBLE:               info->disassemble = CPU_DISASSEMBLE_NAME(cop420);      break;
1468      case CPUINFO_FCT_VALIDITY_CHECK:            info->validity_check = CPU_VALIDITY_CHECK_NAME(cop420);   break;
1469
1470      /* --- the following bits of info are returned as pointers --- */
1471      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map8 = ADDRESS_MAP_NAME(program_1kb);   break;
1472      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:      info->internal_map8 = ADDRESS_MAP_NAME(data_64b);      break;
1473
1474      /* --- the following bits of info are returned as NULL-terminated strings --- */
1475      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP420");                        break;
1476
1477      case CPUINFO_STR_FLAGS: sprintf(info->s,
1478                           "%c%c%c",
1479                            cpustate->c ? 'C' : '.',
1480                            cpustate->skl ? 'S' : '.',
1481                            cpustate->skt_latch ? 'T' : '.'); break;
1482
1483      default:                              CPU_GET_INFO_CALL(cop400);                        break;
1484   }
1485}
1486
1487CPU_GET_INFO( cop421 )
1488{
1489   // COP421 is a 24-pin package version of the COP420, lacking the IN ports
1490
1491   switch (state)
1492   {
1493      /* --- the following bits of info are returned as pointers to data or functions --- */
1494      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(cop421);                  break;
1495      case CPUINFO_FCT_VALIDITY_CHECK:            info->validity_check = CPU_VALIDITY_CHECK_NAME(cop421);   break;
1496
1497      /* --- the following bits of info are returned as NULL-terminated strings --- */
1498      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP421");                        break;
1499
1500      default:                              CPU_GET_INFO_CALL(cop420);                        break;
1501   }
1502}
1503
1504CPU_GET_INFO( cop422 )
1505{
1506   // COP422 is a 20-pin package version of the COP420, lacking G0/G1, D0/D1, and the IN ports
1507
1508   switch (state)
1509   {
1510      /* --- the following bits of info are returned as pointers to data or functions --- */
1511      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(cop422);                  break;
1512
1513      /* --- the following bits of info are returned as NULL-terminated strings --- */
1514      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP422");                        break;
1515
1516      default:                              CPU_GET_INFO_CALL(cop421);                        break;
1517   }
1518}
1519
1520CPU_GET_INFO( cop402 )
1521{
1522   // COP402 is a ROMless version of the COP420
1523
1524   switch (state)
1525   {
1526      /* --- the following bits of info are returned as pointers to data or functions --- */
1527      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map8 = NULL;                        break;
1528
1529      /* --- the following bits of info are returned as NULL-terminated strings --- */
1530      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP402");                        break;
1531
1532      default:                              CPU_GET_INFO_CALL(cop420);                        break;
1533   }
1534}
1535
1536CPU_GET_INFO( cop444 )
1537{
1538   cop400_state *cpustate = (device != NULL) ? device->token : NULL;
1539
1540   switch (state)
1541   {
1542      /* --- the following bits of info are returned as 64-bit signed integers --- */
1543      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 11;                                 break;
1544      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:          info->i = 7;                                 break;
1545
1546      /* --- the following bits of info are returned as pointers to functions --- */
1547      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(cop444);                  break;
1548      case CPUINFO_FCT_DISASSEMBLE:               info->disassemble = CPU_DISASSEMBLE_NAME(cop444);      break;
1549      case CPUINFO_FCT_VALIDITY_CHECK:            info->validity_check = CPU_VALIDITY_CHECK_NAME(cop444);   break;
1550
1551      /* --- the following bits of info are returned as pointers --- */
1552      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map8 = ADDRESS_MAP_NAME(program_2kb);   break;
1553      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:      info->internal_map8 = ADDRESS_MAP_NAME(data_128b);      break;
1554
1555      /* --- the following bits of info are returned as NULL-terminated strings --- */
1556      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP444");                        break;
1557
1558      case CPUINFO_STR_FLAGS: sprintf(info->s,
1559                           "%c%c%c",
1560                            cpustate->c ? 'C' : '.',
1561                            cpustate->skl ? 'S' : '.',
1562                            cpustate->skt_latch ? 'T' : '.'); break;
1563
1564      default:                              CPU_GET_INFO_CALL(cop400);                        break;
1565   }
1566}
1567
1568CPU_GET_INFO( cop445 )
1569{
1570   // COP445 is a 24-pin package version of the COP444, lacking the IN ports
1571
1572   switch (state)
1573   {
1574      /* --- the following bits of info are returned as pointers to data or functions --- */
1575      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(cop445);                  break;
1576
1577      /* --- the following bits of info are returned as NULL-terminated strings --- */
1578      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP445");                        break;
1579
1580      default:                              CPU_GET_INFO_CALL(cop444);                        break;
1581   }
1582}
1583
1584CPU_GET_INFO( cop424 )
1585{
1586   // COP424 is functionally equivalent to COP444, with only 1K ROM and 64x4 bytes RAM
1587
1588   switch (state)
1589   {
1590      /* --- the following bits of info are returned as 64-bit signed integers --- */
1591      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 10;                                 break;
1592      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:          info->i = 6;                                 break;
1593
1594      /* --- the following bits of info are returned as pointers to data or functions --- */
1595      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map8 = ADDRESS_MAP_NAME(program_1kb);   break;
1596      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:      info->internal_map8 = ADDRESS_MAP_NAME(data_64b);      break;
1597
1598      /* --- the following bits of info are returned as NULL-terminated strings --- */
1599      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP424");                        break;
1600
1601      default:                              CPU_GET_INFO_CALL(cop444);                        break;
1602   }
1603}
1604
1605CPU_GET_INFO( cop425 )
1606{
1607   // COP425 is a 24-pin package version of the COP424, lacking the IN ports
1608
1609   switch (state)
1610   {
1611      /* --- the following bits of info are returned as pointers to data or functions --- */
1612      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(cop425);                  break;
1613
1614      /* --- the following bits of info are returned as NULL-terminated strings --- */
1615      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP425");                        break;
1616
1617      default:                              CPU_GET_INFO_CALL(cop424);                        break;
1618   }
1619}
1620
1621CPU_GET_INFO( cop426 )
1622{
1623   // COP426 is a 20-pin package version of the COP424, with only L0-L7, G2-G3, D2-D3 ports
1624
1625   switch (state)
1626   {
1627      /* --- the following bits of info are returned as pointers to data or functions --- */
1628      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(cop426);                  break;
1629
1630      /* --- the following bits of info are returned as NULL-terminated strings --- */
1631      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP426");                        break;
1632
1633      default:                              CPU_GET_INFO_CALL(cop424);                        break;
1634   }
1635}
1636
1637CPU_GET_INFO( cop404 )
1638{
1639   // COP404 is a ROMless version of the COP444, which can emulate a COP410C/COP411C, COP424C/COP425C, or a COP444C/COP445C
1640
1641   switch (state)
1642   {
1643      /* --- the following bits of info are returned as pointers to data or functions --- */
1644      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map8 = NULL;                        break;
1645
1646      /* --- the following bits of info are returned as NULL-terminated strings --- */
1647      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP404");                        break;
1648
1649      default:                              CPU_GET_INFO_CALL(cop444);                        break;
1650   }
1651}
src/emu/cpu/cop400/cop400.h
r4135r4136
1414#ifndef __COP400__
1515#define __COP400__
1616
17/***************************************************************************
18    CONSTANTS
19***************************************************************************/
20
21/* register access indexes */
1722enum
1823{
24   COP400_PC,
25    COP400_SA,
26    COP400_SB,
27    COP400_SC,
28   COP400_N,
29   COP400_A,
30   COP400_B,
31   COP400_C,
32   COP400_G,
33   COP400_H,
34   COP400_Q,
35   COP400_R,
36   COP400_EN,
37    COP400_SIO,
38    COP400_SKL,
39    COP400_T,
40   COP400_GENPC = REG_GENPC,
41   COP400_GENPCBASE = REG_GENPCBASE,
42   COP400_GENSP = REG_GENSP
43};
44
45/* special I/O space ports */
46enum
47{
1948   COP400_PORT_L = 0x100,
2049   COP400_PORT_G,
2150   COP400_PORT_D,
r4135r4136
2756   COP400_PORT_CKO
2857};
2958
59/* input lines */
3060enum
3161{
32   COP400_PC = 1,
33   COP400_A,
34   COP400_B,
35   COP400_C,
36   COP400_G,
37   COP400_H,
38   COP400_R,
39   COP400_EN,
40   COP400_Q,
41    COP400_SA,
42    COP400_SB,
43    COP400_SC,
44    COP400_SIO,
45    COP400_SKL,
46    COP400_T
62   /* COP420 */
63   COP400_IN0 = 0,
64   COP400_IN1,
65   COP400_IN2,
66   COP400_IN3,
67
68   /* COP404 */
69   COP400_MB,
70   COP400_DUAL,
71   COP400_SEL10,
72   COP400_SEL20
4773};
4874
75/* CKI bonding options */
4976typedef enum _cop400_cki_bond cop400_cki_bond;
5077enum _cop400_cki_bond {
5178   COP400_CKI_DIVISOR_4 = 4,
r4135r4136
5481   COP400_CKI_DIVISOR_32 = 32
5582};
5683
84/* CKO bonding options */
5785typedef enum _cop400_cko_bond cop400_cko_bond;
5886enum _cop400_cko_bond {
5987   COP400_CKO_OSCILLATOR_OUTPUT = 0,
r4135r4136
6391   COP400_CKO_GENERAL_PURPOSE_INPUT
6492};
6593
94/* microbus bonding options */
6695typedef enum _cop400_microbus cop400_microbus;
6796enum _cop400_microbus {
6897   COP400_MICROBUS_DISABLED = 0,
r4135r4136
79108};
80109#define COP400_INTERFACE(name) const cop400_interface (name) =
81110
82/*
111/***************************************************************************
112    MACROS
113***************************************************************************/
83114
84    Prefix      Temperature Range
115#define CPU_COP401 CPU_GET_INFO_NAME( cop401 )
116#define CPU_COP410 CPU_GET_INFO_NAME( cop410 )
117#define CPU_COP411 CPU_GET_INFO_NAME( cop411 )
85118
86    COP4xx      0C to 70C
87    COP3xx      -40C to +85C
88    COP2xx      -55C to +125C
119#define CPU_COP402 CPU_GET_INFO_NAME( cop402 )
120#define CPU_COP420 CPU_GET_INFO_NAME( cop420 )
121#define CPU_COP421 CPU_GET_INFO_NAME( cop421 )
122#define CPU_COP422 CPU_GET_INFO_NAME( cop422 )
89123
90*/
124#define CPU_COP404 CPU_GET_INFO_NAME( cop404 )
125#define CPU_COP424 CPU_GET_INFO_NAME( cop424 )
126#define CPU_COP425 CPU_GET_INFO_NAME( cop425 )
127#define CPU_COP426 CPU_GET_INFO_NAME( cop426 )
128#define CPU_COP444 CPU_GET_INFO_NAME( cop444 )
129#define CPU_COP445 CPU_GET_INFO_NAME( cop445 )
91130
92/* COP 41x */
131/***************************************************************************
132    FUNCTION PROTOTYPES
133***************************************************************************/
134
135/* COP410 family */
93136extern CPU_GET_INFO( cop401 );
94137extern CPU_GET_INFO( cop410 );
95138extern CPU_GET_INFO( cop411 );
96139
97#define CPU_COP401 CPU_GET_INFO_NAME( cop401 )
98#define CPU_COP410 CPU_GET_INFO_NAME( cop410 )
99#define CPU_COP411 CPU_GET_INFO_NAME( cop411 )
100
101/* COP 42x */
140/* COP420 family */
102141extern CPU_GET_INFO( cop402 );
103142extern CPU_GET_INFO( cop420 );
104143extern CPU_GET_INFO( cop421 );
105144extern CPU_GET_INFO( cop422 );
106145
107#define CPU_COP402 CPU_GET_INFO_NAME( cop402 )
108#define CPU_COP420 CPU_GET_INFO_NAME( cop420 )
109#define CPU_COP421 CPU_GET_INFO_NAME( cop421 )
110#define CPU_COP422 CPU_GET_INFO_NAME( cop422 )
111
112/* COP 44x */
146/* COP444 family */
113147extern CPU_GET_INFO( cop404 );
114148extern CPU_GET_INFO( cop424 );
115149extern CPU_GET_INFO( cop425 );
r4135r4136
117151extern CPU_GET_INFO( cop444 );
118152extern CPU_GET_INFO( cop445 );
119153
120#define CPU_COP404 CPU_GET_INFO_NAME( cop404 )
121#define CPU_COP424 CPU_GET_INFO_NAME( cop424 )
122#define CPU_COP425 CPU_GET_INFO_NAME( cop425 )
123#define CPU_COP426 CPU_GET_INFO_NAME( cop426 )
124#define CPU_COP444 CPU_GET_INFO_NAME( cop444 )
125#define CPU_COP445 CPU_GET_INFO_NAME( cop445 )
154/* disassemblers */
155extern CPU_DISASSEMBLE( cop410 );
156extern CPU_DISASSEMBLE( cop420 );
157extern CPU_DISASSEMBLE( cop444 );
126158
127CPU_DISASSEMBLE( cop410 );
128CPU_DISASSEMBLE( cop420 );
129CPU_DISASSEMBLE( cop444 );
130
131159#endif  /* __COP400__ */
src/emu/cpu/arm/arm.c
r4135r4136
12001200         *pCarry = k ? (rm & (1 << (32 - k))) : (R15 & C_MASK);
12011201      }
12021202      return k ? LSL(rm, k) : rm;
1203      break;
12041203
12051204   case 1:                         /* LSR */
12061205      if (k == 0 || k == 32)
src/emu/cpu/tms32010/tms32010.c
r4135r4136
5656#include "tms32010.h"
5757
5858
59#ifndef INLINE
60#define INLINE static inline
61#endif
6259
63
6460#define M_RDROM(A)      TMS32010_ROM_RDMEM(A)
6561#define M_WRTROM(A,V)   TMS32010_ROM_WRMEM(A,V)
6662#define M_RDRAM(A)      TMS32010_RAM_RDMEM(A)
src/emu/cpu/sh2/sh2drc.c
r4135r4136
16611661   {
16621662      case  0:
16631663         return generate_group_0(sh2, block, compiler, desc, opcode, in_delay_slot);
1664         break;
16651664
16661665      case  1:    // MOVLS4
16671666         scratch = (opcode & 0x0f) * 4;
r4135r4136
16731672         if (!in_delay_slot)
16741673            generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
16751674         return TRUE;
1676         break;
16771675
16781676      case  2:
16791677         return generate_group_2(sh2, block, compiler, desc, opcode, in_delay_slot);
1680         break;
16811678      case  3:
16821679         return generate_group_3(sh2, block, compiler, desc, opcode);
1683         break;
16841680      case  4:
16851681         return generate_group_4(sh2, block, compiler, desc, opcode, in_delay_slot);
1686         break;
16871682
16881683      case  5:    // MOVLL4
16891684         scratch = (opcode & 0x0f) * 4;
r4135r4136
16951690         if (!in_delay_slot)
16961691            generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
16971692         return TRUE;
1698         break;
16991693
17001694      case  6:
17011695         return generate_group_6(sh2, block, compiler, desc, opcode, in_delay_slot);
1702         break;
17031696
17041697      case  7:    // ADDI
17051698         scratch = opcode & 0xff;
17061699         scratch2 = (UINT32)(INT32)(INT16)(INT8)scratch;
17071700         UML_ADD(block, R32(Rn), R32(Rn), IMM(scratch2));   // add Rn, Rn, scratch2
17081701         return TRUE;
1709         break;
17101702
17111703      case  8:
17121704         return generate_group_8(sh2, block, compiler, desc, opcode, in_delay_slot);
1713         break;
17141705
17151706      case  9:    // MOVWI
17161707         scratch = (desc->pc + 2) + ((opcode & 0xff) * 2) + 2;
r4135r4136
17311722         if (!in_delay_slot)
17321723            generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
17331724         return TRUE;
1734         break;
17351725
17361726      case 10:    // BRA
17371727         generate_delay_slot(sh2, block, compiler, desc);
r4135r4136
17431733         generate_update_cycles(sh2, block, compiler, IMM(sh2->ea), TRUE);   // <subtract cycles>
17441734         UML_HASHJMP(block, IMM(0), IMM(sh2->ea), sh2->nocode);   // hashjmp sh2->ea
17451735         return TRUE;
1746         break;
17471736
17481737      case 11:    // BSR
17491738         // panicstr @ 403da22 relies on the delay slot clobbering the PR set by a BSR, so
r4135r4136
17581747         generate_update_cycles(sh2, block, compiler, IMM(sh2->ea), TRUE);   // <subtract cycles>
17591748         UML_HASHJMP(block, IMM(0), IMM(sh2->ea), sh2->nocode);   // hashjmp sh2->ea
17601749         return TRUE;
1761         break;
17621750
17631751      case 12:
17641752         return generate_group_12(sh2, block, compiler, desc, opcode, in_delay_slot);
1765         break;
17661753
17671754      case 13:    // MOVLI
17681755         scratch = ((desc->pc + 4) & ~3) + ((opcode & 0xff) * 4);
r4135r4136
17821769         if (!in_delay_slot)
17831770            generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
17841771         return TRUE;
1785         break;
17861772
17871773      case 14:    // MOVI
17881774         scratch = opcode & 0xff;
17891775         scratch2 = (UINT32)(INT32)(INT16)(INT8)scratch;
17901776         UML_MOV(block, R32(Rn), IMM(scratch2));
17911777         return TRUE;
1792         break;
17931778
17941779      case 15:    // NOP
17951780         return TRUE;
1796         break;
17971781   }
17981782
17991783   return FALSE;
r4135r4136
18201804   case 0x3a: // NOP();
18211805   case 0x3b: // NOP();
18221806      return TRUE;
1823      break;
18241807
18251808   case 0x02: // STCSR(Rn);
18261809      UML_MOV(block, R32(Rn), MEM(&sh2->sr));
18271810      return TRUE;
1828      break;
18291811
18301812   case 0x03: // BSRF(Rn);
18311813      if (sh2->cpu_type > CPU_TYPE_SH1)
r4135r4136
18551837      if (!in_delay_slot)
18561838         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
18571839      return TRUE;
1858      break;
18591840
18601841   case 0x05: // MOVWS0(Rm, Rn);
18611842   case 0x15: // MOVWS0(Rm, Rn);
r4135r4136
18691850      if (!in_delay_slot)
18701851         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
18711852      return TRUE;
1872      break;
18731853
18741854   case 0x06: // MOVLS0(Rm, Rn);
18751855   case 0x16: // MOVLS0(Rm, Rn);
r4135r4136
18821862      if (!in_delay_slot)
18831863         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
18841864      return TRUE;
1885      break;
18861865
18871866   case 0x07: // MULL(Rm, Rn);
18881867   case 0x17: // MULL(Rm, Rn);
r4135r4136
18981877   case 0x08: // CLRT();
18991878      UML_AND(block, MEM(&sh2->sr), MEM(&sh2->sr), IMM(~T));   // and r0, sr, ~T (clear the T bit)
19001879      return TRUE;
1901      break;
19021880
19031881   case 0x0a: // STSMACH(Rn);
19041882      UML_MOV(block, R32(Rn), MEM(&sh2->mach));      // mov Rn, mach
19051883      return TRUE;
1906      break;
19071884
19081885   case 0x0b: // RTS();
19091886      UML_MOV(block, MEM(&sh2->target), MEM(&sh2->pr));   // mov target, pr (in case of d-slot shenanigans)
r4135r4136
19131890      generate_update_cycles(sh2, block, compiler, MEM(&sh2->target), TRUE);   // <subtract cycles>
19141891      UML_HASHJMP(block, IMM(0), MEM(&sh2->target), sh2->nocode);
19151892      return TRUE;
1916      break;
19171893
19181894   case 0x0c: // MOVBL0(Rm, Rn);
19191895   case 0x1c: // MOVBL0(Rm, Rn);
r4135r4136
19261902      if (!in_delay_slot)
19271903         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
19281904      return TRUE;
1929      break;
19301905
19311906   case 0x0d: // MOVWL0(Rm, Rn);
19321907   case 0x1d: // MOVWL0(Rm, Rn);
r4135r4136
19391914      if (!in_delay_slot)
19401915         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
19411916      return TRUE;
1942      break;
19431917
19441918   case 0x0e: // MOVLL0(Rm, Rn);
19451919   case 0x1e: // MOVLL0(Rm, Rn);
r4135r4136
19521926      if (!in_delay_slot)
19531927         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
19541928      return TRUE;
1955      break;
19561929
19571930   case 0x0f: // MAC_L(Rm, Rn);
19581931   case 0x1f: // MAC_L(Rm, Rn);
r4135r4136
19711944   case 0x12: // STCGBR(Rn);
19721945      UML_MOV(block, R32(Rn), MEM(&sh2->gbr));      // mov Rn, gbr
19731946      return TRUE;
1974      break;
19751947
19761948   case 0x18: // SETT();
19771949      UML_OR(block, MEM(&sh2->sr), MEM(&sh2->sr), IMM(T));   // or sr, sr, T
19781950      return TRUE;
1979      break;
19801951
19811952   case 0x19: // DIV0U();
19821953      UML_AND(block, MEM(&sh2->sr), MEM(&sh2->sr), IMM(~(M|Q|T)));   // and sr, sr, ~(M|Q|T)
19831954      return TRUE;
1984      break;
19851955
19861956   case 0x1a: // STSMACL(Rn);
19871957      UML_MOV(block, R32(Rn), MEM(&sh2->macl));      // mov Rn, macl
19881958      return TRUE;
1989      break;
19901959
19911960   case 0x1b: // SLEEP();
19921961      // inlined special version of generate_update_cycles here
r4135r4136
20241993      }
20251994
20261995      return TRUE;
2027      break;
20281996
20291997   case 0x22: // STCVBR(Rn);
20301998      UML_MOV(block, R32(Rn), MEM(&sh2->vbr));      // mov Rn, vbr
20311999      return TRUE;
2032      break;
20332000
20342001   case 0x23: // BRAF(Rn);
20352002      if (sh2->cpu_type > CPU_TYPE_SH1)
r4135r4136
20482015      UML_MOV(block, MEM(&sh2->macl), IMM(0));      // mov macl, #0
20492016      UML_MOV(block, MEM(&sh2->mach), IMM(0));      // mov mach, #0
20502017      return TRUE;
2051      break;
20522018
20532019   case 0x29: // MOVT(Rn);
20542020      UML_AND(block, R32(Rn), MEM(&sh2->sr), IMM(T));      // and Rn, sr, T
20552021      return TRUE;
2056      break;
20572022
20582023   case 0x2a: // STSPR(Rn);
20592024      UML_MOV(block, R32(Rn), MEM(&sh2->pr));         // mov Rn, pr
20602025      return TRUE;
2061      break;
20622026
20632027   case 0x2b: // RTE();
20642028      generate_delay_slot(sh2, block, compiler, desc);
r4135r4136
20792043      UML_HASHJMP(block, IMM(0), MEM(&sh2->pc), sh2->nocode);   // and jump to the "resume PC"
20802044
20812045      return TRUE;
2082      break;
20832046   }
20842047
20852048   return FALSE;
r4135r4136
20982061      if (!in_delay_slot)
20992062         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
21002063      return TRUE;
2101      break;
21022064
21032065   case  1: // MOVWS(Rm, Rn);
21042066      UML_MOV(block, IREG(0), R32(Rn));      // mov r0, Rn
r4135r4136
21092071      if (!in_delay_slot)
21102072         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
21112073      return TRUE;
2112      break;
21132074
21142075   case  2: // MOVLS(Rm, Rn);
21152076      UML_MOV(block, IREG(0), R32(Rn));      // mov r0, Rn
r4135r4136
21192080      if (!in_delay_slot)
21202081         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
21212082      return TRUE;
2122      break;
21232083
21242084   case  3: // NOP();
21252085      return TRUE;
2126      break;
21272086
21282087   case  4: // MOVBM(Rm, Rn);
21292088      UML_MOV(block, IREG(1), R32(Rm));      // mov r1, Rm
r4135r4136
21342093      if (!in_delay_slot)
21352094         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
21362095      return TRUE;
2137      break;
21382096
21392097   case  5: // MOVWM(Rm, Rn);
21402098      UML_MOV(block, IREG(1), R32(Rm));      // mov r1, Rm
r4135r4136
21452103      if (!in_delay_slot)
21462104         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
21472105      return TRUE;
2148      break;
21492106
21502107   case  6: // MOVLM(Rm, Rn);
21512108      UML_MOV(block, IREG(1), R32(Rm));      // mov r1, Rm
r4135r4136
21562113      if (!in_delay_slot)
21572114         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
21582115      return TRUE;
2159      break;
21602116
21612117   case 13: // XTRCT(Rm, Rn);
21622118      UML_SHL(block, IREG(0), R32(Rm), IMM(16));      // shl r0, Rm, #16
r4135r4136
21672123
21682124      UML_OR(block, R32(Rn), IREG(0), IREG(1));      // or Rn, r0, r1
21692125      return TRUE;
2170      break;
21712126
21722127   case  7: // DIV0S(Rm, Rn);
21732128      UML_MOV(block, IREG(0), MEM(&sh2->sr));            // move r0, sr
r4135r4136
21932148      UML_LABEL(block, compiler->labelnum++);            // labelnum:
21942149      UML_MOV(block, MEM(&sh2->sr), IREG(0));            // mov sr, r0
21952150      return TRUE;
2196      break;
21972151
21982152   case  8: // TST(Rm, Rn);
21992153      UML_AND(block, IREG(0), MEM(&sh2->sr), IMM(~T));   // and r0, sr, ~T (clear the T bit)
r4135r4136
22052159
22062160      UML_MOV(block, MEM(&sh2->sr), IREG(0));      // mov sh2->sr, r0
22072161      return TRUE;
2208      break;
22092162
22102163   case 12: // CMPSTR(Rm, Rn);
22112164      UML_XOR(block, IREG(0), R32(Rn), R32(Rm));   // xor r0, Rn, Rm       (temp)
r4135r4136
22372190
22382191      UML_LABEL(block, compiler->labelnum++);      // labelnum+1:
22392192      return TRUE;
2240      break;
22412193
22422194   case  9: // AND(Rm, Rn);
22432195      UML_AND(block, R32(Rn), R32(Rn), R32(Rm));   // and Rn, Rn, Rm
22442196      return TRUE;
2245      break;
22462197
22472198   case 10: // XOR(Rm, Rn);
22482199      UML_XOR(block, R32(Rn), R32(Rn), R32(Rm));   // xor Rn, Rn, Rm
22492200      return TRUE;
2250      break;
22512201
22522202   case 11: // OR(Rm, Rn);
22532203      UML_OR(block, R32(Rn), R32(Rn), R32(Rm));   // or Rn, Rn, Rm
22542204      return TRUE;
2255      break;
22562205
22572206   case 14: // MULU(Rm, Rn);
22582207      UML_AND(block, IREG(0), R32(Rm), IMM(0xffff));            // and r0, Rm, 0xffff
22592208      UML_AND(block, IREG(1), R32(Rn), IMM(0xffff));            // and r1, Rn, 0xffff
22602209      UML_MULU(block, MEM(&sh2->macl), MEM(&sh2->ea), IREG(0), IREG(1));   // mulu macl, ea, r0, r1
22612210      return TRUE;
2262      break;
22632211
22642212   case 15: // MULS(Rm, Rn);
22652213      UML_SEXT(block, IREG(0), R32(Rm), WORD);            // sext r0, Rm
22662214      UML_SEXT(block, IREG(1), R32(Rn), WORD);            // sext r1, Rn
22672215      UML_MULS(block, MEM(&sh2->macl), MEM(&sh2->ea), IREG(0), IREG(1));   // muls macl, ea, r0, r1
22682216      return TRUE;
2269      break;
22702217   }
22712218
22722219   return FALSE;
r4135r4136
22812228      UML_SETc(block, IF_E, IREG(0));         // set E, r0
22822229      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(1));   // rolins sr, r0, 0, 1
22832230      return TRUE;
2284      break;
22852231
22862232   case  2: // CMPHS(Rm, Rn); (unsigned greater than or equal)
22872233      UML_CMP(block, R32(Rn), R32(Rm));      // cmp Rn, Rm
22882234      UML_SETc(block, IF_AE, IREG(0));      // set AE, r0
22892235      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(1));   // rolins sr, r0, 0, 1
22902236      return TRUE;
2291      break;
22922237
22932238   case  3: // CMPGE(Rm, Rn); (signed greater than or equal)
22942239      UML_CMP(block, R32(Rn), R32(Rm));      // cmp Rn, Rm
22952240      UML_SETc(block, IF_GE, IREG(0));      // set GE, r0
22962241      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(1));   // rolins sr, r0, 0, 1
22972242      return TRUE;
2298      break;
22992243
23002244   case  6: // CMPHI(Rm, Rn); (unsigned greater than)
23012245      UML_CMP(block, R32(Rn), R32(Rm));      // cmp Rn, Rm
23022246      UML_SETc(block, IF_A, IREG(0));         // set A, r0
23032247      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(1));   // rolins sr, r0, 0, 1
23042248      return TRUE;
2305      break;
23062249
23072250   case  7: // CMPGT(Rm, Rn); (signed greater than)
23082251      UML_CMP(block, R32(Rn), R32(Rm));      // cmp Rn, Rm
23092252      UML_SETc(block, IF_G, IREG(0));         // set G, r0
23102253      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(1));   // rolins sr, r0, 0, 1
23112254      return TRUE;
2312      break;
23132255
23142256   case  1: // NOP();
23152257   case  9: // NOP();
23162258      return TRUE;
2317      break;
23182259
23192260   case  4: // DIV1(Rm, Rn);
23202261      save_fast_iregs(sh2, block);
r4135r4136
23222263      UML_CALLC(block, cfunc_DIV1, sh2);
23232264      load_fast_iregs(sh2, block);
23242265      return TRUE;
2325      break;
23262266
23272267   case  5: // DMULU(Rm, Rn);
23282268      if (sh2->cpu_type > CPU_TYPE_SH1)
r4135r4136
23432283   case  8: // SUB(Rm, Rn);
23442284      UML_SUB(block, R32(Rn), R32(Rn), R32(Rm));   // sub Rn, Rn, Rm
23452285      return TRUE;
2346      break;
23472286
23482287   case 12: // ADD(Rm, Rn);
23492288      UML_ADD(block, R32(Rn), R32(Rn), R32(Rm));   // add Rn, Rn, Rm
23502289      return TRUE;
2351      break;
23522290
23532291   case 10: // SUBC(Rm, Rn);
23542292      UML_CARRY(block, MEM(&sh2->sr), IMM(0));   // carry = T (T is bit 0 of SR)
r4135r4136
23562294      UML_SETc(block, IF_C, IREG(0));            // setc    i0, C
23572295      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(T)); // rolins sr,i0,0,T
23582296      return TRUE;
2359      break;
23602297
23612298   case 11: // SUBV(Rm, Rn);
23622299#if ADDSUBV_DIRECT
r4135r4136
23702307      load_fast_iregs(sh2, block);
23712308#endif
23722309      return TRUE;
2373      break;
23742310
23752311   case 14: // ADDC(Rm, Rn);
23762312      UML_CARRY(block, MEM(&sh2->sr), IMM(0));   // carry = T (T is bit 0 of SR)
r4135r4136
23782314      UML_SETc(block, IF_C, IREG(0));            // setc    i0, C
23792315      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(T)); // rolins sr,i0,0,T
23802316      return TRUE;
2381      break;
23822317
23832318   case 15: // ADDV(Rm, Rn);
23842319#if ADDSUBV_DIRECT
r4135r4136
23922327      load_fast_iregs(sh2, block);
23932328#endif
23942329      return TRUE;
2395      break;
23962330   }
23972331   return FALSE;
23982332}
r4135r4136
24062340      UML_SETc(block, IF_C, IREG(0));               // set i0,C
24072341      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(T)); // rolins [sr],i0,0,T
24082342      return TRUE;
2409      break;
24102343
24112344   case 0x01: // SHLR(Rn);
24122345      UML_SHR(block, R32(Rn), R32(Rn), IMM(1));      // shr Rn, Rn, 1
24132346      UML_SETc(block, IF_C, IREG(0));               // set i0,C
24142347      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(T)); // rolins [sr],i0,0,T
24152348      return TRUE;
2416      break;
24172349
24182350   case 0x04: // ROTL(Rn);
24192351      UML_ROL(block, R32(Rn), R32(Rn), IMM(1));      // rol Rn, Rn, 1
24202352      UML_SETc(block, IF_C, IREG(0));               // set i0,C
24212353      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(T)); // rolins [sr],i0,0,T
24222354      return TRUE;
2423      break;
24242355
24252356   case 0x05: // ROTR(Rn);
24262357      UML_ROR(block, R32(Rn), R32(Rn), IMM(1));      // ror Rn, Rn, 1
24272358      UML_SETc(block, IF_C, IREG(0));               // set i0,C
24282359      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(T)); // rolins [sr],i0,0,T
24292360      return TRUE;
2430      break;
24312361
24322362   case 0x02: // STSMMACH(Rn);
24332363      UML_SUB(block, R32(Rn), R32(Rn), IMM(4));   // sub Rn, Rn, #4
r4135r4136
24392369      if (!in_delay_slot)
24402370         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
24412371      return TRUE;
2442      break;
24432372
24442373   case 0x03: // STCMSR(Rn);
24452374      UML_SUB(block, R32(Rn), R32(Rn), IMM(4));   // sub Rn, Rn, #4
r4135r4136
24512380      if (!in_delay_slot)
24522381         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
24532382      return TRUE;
2454      break;
24552383
24562384   case 0x06: // LDSMMACH(Rn);
24572385      UML_MOV(block, IREG(0), R32(Rn));      // mov r0, Rn
r4135r4136
24632391      if (!in_delay_slot)
24642392         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
24652393      return TRUE;
2466      break;
24672394
24682395   case 0x07: // LDCMSR(Rn);
24692396      UML_MOV(block, IREG(0), R32(Rn));      // mov r0, Rn
r4135r4136
24762403      if (!in_delay_slot)
24772404         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
24782405      return TRUE;
2479      break;
24802406
2407
24812408   case 0x08: // SHLL2(Rn);
24822409      UML_SHL(block, R32(Rn), R32(Rn), IMM(2));
24832410      return TRUE;
2484      break;
24852411
24862412   case 0x09: // SHLR2(Rn);
24872413      UML_SHR(block, R32(Rn), R32(Rn), IMM(2));
24882414      return TRUE;
2489      break;
24902415
24912416   case 0x18: // SHLL8(Rn);
24922417      UML_SHL(block, R32(Rn), R32(Rn), IMM(8));
24932418      return TRUE;
2494      break;
24952419
24962420   case 0x19: // SHLR8(Rn);
24972421      UML_SHR(block, R32(Rn), R32(Rn), IMM(8));
24982422      return TRUE;
2499      break;
25002423
25012424   case 0x28: // SHLL16(Rn);
25022425      UML_SHL(block, R32(Rn), R32(Rn), IMM(16));
25032426      return TRUE;
2504      break;
25052427
25062428   case 0x29: // SHLR16(Rn);
25072429      UML_SHR(block, R32(Rn), R32(Rn), IMM(16));
25082430      return TRUE;
2509      break;
25102431
25112432   case 0x0a: // LDSMACH(Rn);
25122433      UML_MOV(block, MEM(&sh2->mach), R32(Rn));      // mov mach, Rn
25132434      return TRUE;
2514      break;
25152435
25162436   case 0x0b: // JSR(Rn);
25172437      UML_MOV(block, MEM(&sh2->target), R32(Rn));      // mov target, Rn
r4135r4136
25232443      generate_update_cycles(sh2, block, compiler, MEM(&sh2->target), TRUE);   // <subtract cycles>
25242444      UML_HASHJMP(block, IMM(0), MEM(&sh2->target), sh2->nocode);   // and do the jump
25252445      return TRUE;
2526      break;
25272446
25282447   case 0x0e: // LDCSR(Rn);
25292448      UML_MOV(block, IREG(0), R32(Rn));      // mov r0, Rn
r4135r4136
25322451
25332452      compiler->checkints = TRUE;
25342453      return TRUE;
2535      break;
25362454
25372455   case 0x0f: // MAC_W(Rm, Rn);
25382456   case 0x1f: // MAC_W(Rm, Rn);
r4135r4136
25432461      UML_CALLC(block, cfunc_MAC_W, sh2);
25442462      load_fast_iregs(sh2, block);
25452463      return TRUE;
2546      break;
25472464
25482465   case 0x10: // DT(Rn);
25492466      if (sh2->cpu_type > CPU_TYPE_SH1)
r4135r4136
25712488
25722489      UML_MOV(block, MEM(&sh2->sr), IREG(0));      // mov sh2->sr, r0
25732490      return TRUE;
2574      break;
25752491
25762492   case 0x15: // CMPPL(Rn);
25772493      UML_AND(block, IREG(0), MEM(&sh2->sr), IMM(~T));   // and r0, sr, ~T (clear the T bit)
r4135r4136
25862502      UML_LABEL(block, compiler->labelnum++);           // desc->pc:
25872503      UML_MOV(block, MEM(&sh2->sr), IREG(0));      // mov sh2->sr, r0
25882504      return TRUE;
2589      break;
25902505
25912506   case 0x12: // STSMMACL(Rn);
25922507      UML_SUB(block, R32(Rn), R32(Rn), IMM(4));   // sub Rn, Rn, #4
r4135r4136
25982513      if (!in_delay_slot)
25992514         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
26002515      return TRUE;
2601      break;
26022516
26032517   case 0x13: // STCMGBR(Rn);
26042518      UML_SUB(block, R32(Rn), R32(Rn), IMM(4));   // sub Rn, Rn, #4
r4135r4136
26102524      if (!in_delay_slot)
26112525         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
26122526      return TRUE;
2613      break;
26142527
26152528   case 0x16: // LDSMMACL(Rn);
26162529      UML_MOV(block, IREG(0), R32(Rn));      // mov r0, Rn
r4135r4136
26222535      if (!in_delay_slot)
26232536         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
26242537      return TRUE;
2625      break;
26262538
26272539   case 0x17: // LDCMGBR(Rn);
26282540      UML_MOV(block, IREG(0), R32(Rn));      // mov r0, Rn
r4135r4136
26342546      if (!in_delay_slot)
26352547         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
26362548      return TRUE;
2637      break;
26382549
26392550   case 0x1a: // LDSMACL(Rn);
26402551      UML_MOV(block, MEM(&sh2->macl), R32(Rn));      // mov macl, Rn
26412552      return TRUE;
2642      break;
26432553
26442554   case 0x1b: // TAS(Rn);
26452555      UML_MOV(block, IREG(0), R32(Rn));      // mov r0, Rn
r4135r4136
26632573      if (!in_delay_slot)
26642574         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
26652575      return TRUE;
2666      break;
26672576
26682577   case 0x1e: // LDCGBR(Rn);
26692578      UML_MOV(block, MEM(&sh2->gbr), R32(Rn));   // mov gbr, Rn
26702579      return TRUE;
2671      break;
26722580
26732581   case 0x20: // SHAL(Rn);
26742582      UML_AND(block, MEM(&sh2->sr), MEM(&sh2->sr), IMM(~T));   // and sr, sr, ~T
r4135r4136
26772585      UML_OR(block, MEM(&sh2->sr), MEM(&sh2->sr), IREG(0));   // or sr, sr, r0
26782586      UML_SHL(block, R32(Rn), R32(Rn), IMM(1));      // shl Rn, Rn, 1
26792587      return TRUE;
2680      break;
26812588
26822589   case 0x21: // SHAR(Rn);
26832590      UML_AND(block, MEM(&sh2->sr), MEM(&sh2->sr), IMM(~T));   // and sr, sr, ~T
r4135r4136
26852592      UML_OR(block, MEM(&sh2->sr), MEM(&sh2->sr), IREG(0));   // or sr, sr, r0
26862593      UML_SAR(block, R32(Rn), R32(Rn), IMM(1));      // sar Rn, Rn, 1
26872594      return TRUE;
2688      break;
26892595
26902596   case 0x22: // STSMPR(Rn);
26912597      UML_SUB(block, R32(Rn), R32(Rn), IMM(4));      // sub Rn, Rn, 4
r4135r4136
26972603      if (!in_delay_slot)
26982604         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
26992605      return TRUE;
2700      break;
27012606
27022607   case 0x23: // STCMVBR(Rn);
27032608      UML_SUB(block, R32(Rn), R32(Rn), IMM(4));      // sub Rn, Rn, 4
r4135r4136
27092614      if (!in_delay_slot)
27102615         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
27112616      return TRUE;
2712      break;
27132617
27142618   case 0x24: // ROTCL(Rn);
27152619      UML_CARRY(block, MEM(&sh2->sr), IMM(0));         // carry sr,0
r4135r4136
27172621      UML_SETc(block, IF_C, IREG(0));                  // set   i0,C
27182622      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(T)); // rolins sr,i0,0,T
27192623      return TRUE;
2720      break;
27212624
27222625   case 0x25: // ROTCR(Rn);
27232626      UML_CARRY(block, MEM(&sh2->sr), IMM(0));         // carry sr,0
r4135r4136
27252628      UML_SETc(block, IF_C, IREG(0));                  // set   i0,C
27262629      UML_ROLINS(block, MEM(&sh2->sr), IREG(0), IMM(0), IMM(T)); // rolins sr,i0,0,T
27272630      return TRUE;
2728      break;
27292631
27302632   case 0x26: // LDSMPR(Rn);
27312633      UML_MOV(block, IREG(0), R32(Rn));         // mov r0, Rn
r4135r4136
27372639      if (!in_delay_slot)
27382640         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
27392641      return TRUE;
2740      break;
27412642
27422643   case 0x27: // LDCMVBR(Rn);
27432644      UML_MOV(block, IREG(0), R32(Rn));         // mov r0, Rn
r4135r4136
27492650      if (!in_delay_slot)
27502651         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
27512652      return TRUE;
2752      break;
27532653
27542654   case 0x2a: // LDSPR(Rn);
27552655      UML_MOV(block, MEM(&sh2->pr), R32(Rn));         // mov sh2->pr, Rn
27562656      return TRUE;
2757      break;
27582657
27592658   case 0x2b: // JMP(Rn);
27602659      UML_MOV(block, MEM(&sh2->target), R32(Rn));      // mov target, Rn
r4135r4136
27642663      generate_update_cycles(sh2, block, compiler, MEM(&sh2->target), TRUE);   // <subtract cycles>
27652664      UML_HASHJMP(block, IMM(0), MEM(&sh2->target), sh2->nocode);   // jmp (target)
27662665      return TRUE;
2767      break;
27682666
27692667   case 0x2e: // LDCVBR(Rn);
27702668      UML_MOV(block, MEM(&sh2->vbr), R32(Rn));      //  mov vbr, Rn
27712669      return TRUE;
2772      break;
27732670
27742671   case 0x0c: // NOP();
27752672   case 0x0d: // NOP();
r4135r4136
27942691   case 0x3d: // NOP();
27952692   case 0x3e: // NOP();
27962693      return TRUE;
2797      break;
2798
27992694   }
28002695
28012696   return FALSE;
r4135r4136
28142709      if (!in_delay_slot)
28152710         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
28162711      return TRUE;
2817      break;
28182712
28192713   case  1: // MOVWL(Rm, Rn);
28202714      UML_MOV(block, IREG(0), R32(Rm));      // mov r0, Rm
r4135r4136
28252719      if (!in_delay_slot)
28262720         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
28272721      return TRUE;
2828      break;
28292722
28302723   case  2: // MOVLL(Rm, Rn);
28312724      UML_MOV(block, IREG(0), R32(Rm));      // mov r0, Rm
r4135r4136
28362729      if (!in_delay_slot)
28372730         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
28382731      return TRUE;
2839      break;
28402732
28412733   case  3: // MOV(Rm, Rn);
28422734      UML_MOV(block, R32(Rn), R32(Rm));      // mov Rn, Rm
28432735      return TRUE;
2844      break;
28452736
28462737   case  7: // NOT(Rm, Rn);
28472738      UML_XOR(block, R32(Rn), R32(Rm), IMM(0xffffffff));   // xor Rn, Rm, 0xffffffff
28482739      return TRUE;
2849      break;
28502740
28512741   case  9: // SWAPW(Rm, Rn);
28522742      UML_ROL(block, R32(Rn), R32(Rm), IMM(16));   // rol Rn, Rm, 16
28532743      return TRUE;
2854      break;
28552744
28562745   case 11: // NEG(Rm, Rn);
28572746      UML_SUB(block, R32(Rn), IMM(0), R32(Rm));   // sub Rn, 0, Rm
28582747      return TRUE;
2859      break;
28602748
28612749   case 12: // EXTUB(Rm, Rn);
28622750      UML_AND(block, R32(Rn), R32(Rm), IMM(0x000000ff));   // and Rn, Rm, 0xff
28632751      return TRUE;
2864      break;
28652752
28662753   case 13: // EXTUW(Rm, Rn);
28672754      UML_AND(block, R32(Rn), R32(Rm), IMM(0x0000ffff));   // and Rn, Rm, 0xffff
28682755      return TRUE;
2869      break;
28702756
28712757   case 14: // EXTSB(Rm, Rn);
28722758      UML_SEXT(block, R32(Rn), R32(Rm), BYTE);      // sext Rn, Rm, BYTE
28732759      return TRUE;
2874      break;
28752760
28762761   case 15: // EXTSW(Rm, Rn);
28772762      UML_SEXT(block, R32(Rn), R32(Rm), WORD);      // sext Rn, Rm, WORD
28782763      return TRUE;
2879      break;
28802764
28812765   case  4: // MOVBP(Rm, Rn);
28822766      UML_MOV(block, IREG(0), R32(Rm));      // mov r0, Rm
r4135r4136
28932777      if (!in_delay_slot)
28942778         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
28952779      return TRUE;
2896      break;
28972780
28982781   case  5: // MOVWP(Rm, Rn);
28992782      UML_MOV(block, IREG(0), R32(Rm));      // mov r0, Rm
r4135r4136
29102793      if (!in_delay_slot)
29112794         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
29122795      return TRUE;
2913      break;
29142796
29152797   case  6: // MOVLP(Rm, Rn);
29162798      UML_MOV(block, IREG(0), R32(Rm));      // mov r0, Rm
r4135r4136
29272809      if (!in_delay_slot)
29282810         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
29292811      return TRUE;
2930      break;
29312812
29322813   case  8: // SWAPB(Rm, Rn);
29332814      UML_AND(block, IREG(0), R32(Rm), IMM(0xffff0000));   // and r0, Rm, #0xffff0000
r4135r4136
29382819      UML_OR(block, IREG(0), IREG(0), IREG(1));      // or r0, r0, r1
29392820      UML_OR(block, R32(Rn), IREG(0), IREG(2));      // or Rn, r0, r2
29402821      return TRUE;
2941      break;
29422822
29432823   case 10: // NEGC(Rm, Rn);
29442824      UML_MOV(block, IREG(0), MEM(&sh2->sr));      // mov r0, sr (save SR)
r4135r4136
29532833      UML_LABEL(block, compiler->labelnum++);      // labelnum:
29542834
29552835      return TRUE;
2956      break;
29572836   }
29582837
29592838   return FALSE;
r4135r4136
29762855      if (!in_delay_slot)
29772856         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
29782857      return TRUE;
2979      break;
29802858
29812859   case  1 << 8: // MOVWS4(opcode & 0x0f, Rm);
29822860      udisp = (opcode & 0x0f) * 2;
r4135r4136
29872865      if (!in_delay_slot)
29882866         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
29892867      return TRUE;
2990      break;
29912868
29922869   case  2<< 8: // NOP();
29932870   case  3<< 8: // NOP();
r4135r4136
29972874   case 12<< 8: // NOP();
29982875   case 14<< 8: // NOP();
29992876      return TRUE;
3000      break;
30012877
30022878   case  4<< 8: // MOVBL4(Rm, opcode & 0x0f);
30032879      udisp = opcode & 0x0f;
r4135r4136
30092885      if (!in_delay_slot)
30102886         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
30112887      return TRUE;
3012      break;
30132888
30142889   case  5<< 8: // MOVWL4(Rm, opcode & 0x0f);
30152890      udisp = (opcode & 0x0f)*2;
r4135r4136
30212896      if (!in_delay_slot)
30222897         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
30232898      return TRUE;
3024      break;
30252899
30262900   case  8<< 8: // CMPIM(opcode & 0xff);
30272901      UML_AND(block, IREG(0), MEM(&sh2->sr), IMM(~T));   // and r0, sr, ~T (clear the T bit)
r4135r4136
30352909      UML_LABEL(block, compiler->labelnum++);           // labelnum:
30362910      UML_MOV(block, MEM(&sh2->sr), IREG(0));      // mov sh2->sr, r0
30372911      return TRUE;
3038      break;
30392912
30402913   case  9<< 8: // BT(opcode & 0xff);
30412914      UML_TEST(block, MEM(&sh2->sr), IMM(T));      // test sh2->sr, T
r4135r4136
30492922
30502923      UML_LABEL(block, compiler->labelnum++);           // labelnum:
30512924      return TRUE;
3052      break;
30532925
30542926   case 11<< 8: // BF(opcode & 0xff);
30552927      UML_TEST(block, MEM(&sh2->sr), IMM(T));      // test sh2->sr, T
r4135r4136
30632935
30642936      UML_LABEL(block, compiler->labelnum++);           // labelnum:
30652937      return TRUE;
3066      break;
30672938
30682939   case 13<< 8: // BTS(opcode & 0xff);
30692940      if (sh2->cpu_type > CPU_TYPE_SH1)
r4135r4136
31262997      if (!in_delay_slot)
31272998         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
31282999      return TRUE;
3129      break;
31303000
31313001   case  1<<8: // MOVWSG(opcode & 0xff);
31323002      scratch = (opcode & 0xff) * 2;
r4135r4136
31373007      if (!in_delay_slot)
31383008         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
31393009      return TRUE;
3140      break;
31413010
31423011   case  2<<8: // MOVLSG(opcode & 0xff);
31433012      scratch = (opcode & 0xff) * 4;
r4135r4136
31483017      if (!in_delay_slot)
31493018         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
31503019      return TRUE;
3151      break;
31523020
31533021   case  3<<8: // TRAPA(opcode & 0xff);
31543022      scratch = (opcode & 0xff) * 4;
r4135r4136
31693037      UML_HASHJMP(block, IMM(0), IREG(0), sh2->nocode);      // jmp (r0)
31703038
31713039      return TRUE;
3172      break;
31733040
31743041   case  4<<8: // MOVBLG(opcode & 0xff);
31753042      scratch = (opcode & 0xff);
r4135r4136
31803047      if (!in_delay_slot)
31813048         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
31823049      return TRUE;
3183      break;
31843050
31853051   case  5<<8: // MOVWLG(opcode & 0xff);
31863052      scratch = (opcode & 0xff) * 2;
r4135r4136
31913057      if (!in_delay_slot)
31923058         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
31933059      return TRUE;
3194      break;
31953060
31963061   case  6<<8: // MOVLLG(opcode & 0xff);
31973062      scratch = (opcode & 0xff) * 4;
r4135r4136
32023067      if (!in_delay_slot)
32033068         generate_update_cycles(sh2, block, compiler, IMM(desc->pc + 2), TRUE);
32043069      return TRUE;
3205      break;
32063070
32073071   case  7<<8: // MOVA(opcode & 0xff);
32083072      scratch = (opcode & 0xff) * 4;
r4135r4136
32103074
32113075      UML_MOV(block, R32(0), IMM(scratch));         // mov R0, scratch
32123076      return TRUE;
3213      break;
32143077
32153078   case  8<<8: // TSTI(opcode & 0xff);
32163079      scratch = opcode & 0xff;
r4135r4136
32243087
32253088      UML_LABEL(block, compiler->labelnum++);         // labelnum:
32263089      return TRUE;
3227      break;
32283090
32293091   case  9<<8: // ANDI(opcode & 0xff);
32303092      UML_AND(block, R32(0), R32(0), IMM(opcode & 0xff));   // and r0, r0, opcode & 0xff
32313093      return TRUE;
3232      break;
32333094
32343095   case 10<<8: // XORI(opcode & 0xff);
32353096      UML_XOR(block, R32(0), R32(0), IMM(opcode & 0xff));   // xor r0, r0, opcode & 0xff
32363097      return TRUE;
3237      break;
32383098
32393099   case 11<<8: // ORI(opcode & 0xff);
32403100      UML_OR(block, R32(0), R32(0), IMM(opcode & 0xff));   // or r0, r0, opcode & 0xff
32413101      return TRUE;
3242      break;
32433102
32443103   case 12<<8: // TSTM(opcode & 0xff);
32453104      UML_AND(block, MEM(&sh2->sr), MEM(&sh2->sr), IMM(~T));   // and sr, sr, ~T (clear the T bit)
r4135r4136
32533112
32543113      UML_LABEL(block, compiler->labelnum++);         // labelnum:
32553114      return TRUE;
3256      break;
32573115
32583116   case 13<<8: // ANDM(opcode & 0xff);
32593117      UML_ADD(block, IREG(0), R32(0), MEM(&sh2->gbr));   // add r0, R0, gbr
r4135r4136
32643122      SETEA(0);
32653123      UML_CALLH(block, sh2->write8);            // write8
32663124      return TRUE;
3267      break;
32683125
32693126   case 14<<8: // XORM(opcode & 0xff);
32703127      UML_ADD(block, IREG(0), R32(0), MEM(&sh2->gbr));   // add r0, R0, gbr
r4135r4136
32753132      SETEA(0);
32763133      UML_CALLH(block, sh2->write8);            // write8
32773134      return TRUE;
3278      break;
32793135
32803136   case 15<<8: // ORM(opcode & 0xff);
32813137      UML_ADD(block, IREG(0), R32(0), MEM(&sh2->gbr));   // add r0, R0, gbr
r4135r4136
32863142      SETEA(0);
32873143      UML_CALLH(block, sh2->write8);            // write8
32883144      return TRUE;
3289      break;
32903145   }
32913146
32923147   return FALSE;
src/emu/cpu/sh2/sh2fe.c
r4135r4136
4848   {
4949      case  0:
5050         return describe_group_0(context, desc, prev, opcode);
51         break;
5251
5352      case  1:    // MOVLS4
5453         desc->regin[0] |= REGFLAG_R(Rn) | REGFLAG_R(Rm);
5554         desc->flags |= OPFLAG_WRITES_MEMORY;
5655         return TRUE;
57         break;
5856
5957      case  2:
6058         return describe_group_2(context, desc, prev, opcode);
61         break;
6259
6360      case  3:
6461         return describe_group_3(context, desc, prev, opcode);
65         break;
6662
6763      case  4:
6864         return describe_group_4(context, desc, prev, opcode);
69         break;
7065
7166      case  5:    // MOVLL4
7267         desc->regin[0] |= REGFLAG_R(Rm);
7368         desc->regout[0] |= REGFLAG_R(Rn);
7469         desc->flags |= OPFLAG_READS_MEMORY;
7570         return TRUE;
76         break;
7771
7872      case  6:
7973         return describe_group_6(context, desc, prev, opcode);
80         break;
8174
8275      case  7:    // ADDI
8376         desc->regin[0] |= REGFLAG_R(Rn);
8477         desc->regout[0] |= REGFLAG_R(Rn);
8578         return TRUE;
86         break;
8779
8880      case  8:
8981         return describe_group_8(context, desc, prev, opcode);
90         break;
9182
9283      case  9:    // MOVWI
9384         desc->regout[0] |= REGFLAG_R(Rn);
9485         desc->flags |= OPFLAG_READS_MEMORY;
9586         return TRUE;
96         break;
9787
9888      case 11:    // BSR
9989         desc->regout[1] |= REGFLAG_PR;
r4135r4136
10898            desc->cycles = 2;
10999            return TRUE;
110100         }
111         break;
112101
113102      case 12:
114103         return describe_group_12(context, desc, prev, opcode);
115         break;
116104
117105      case 13:    // MOVLI
118106         desc->regout[0] |= REGFLAG_R(Rn);
119107         desc->flags |= OPFLAG_READS_MEMORY;
120108         return TRUE;
121         break;
122109
123110      case 14:    // MOVI
124111         desc->regout[0] |= REGFLAG_R(Rn);
125112         return TRUE;
126         break;
127113
128114      case 15:    // NOP
129115         return TRUE;
130         break;
131116   }
132117
133118   return FALSE;
r4135r4136
154139   case 0x3a: // NOP();
155140   case 0x3b: // NOP();
156141      return TRUE;
157      break;
158142
159143   case 0x02: // STCSR(Rn);
160144      desc->regout[0] |= REGFLAG_R(Rn);
161145      return TRUE;
162      break;
163146
164147   case 0x03: // BSRF(Rn);
165148      desc->regout[1] |= REGFLAG_PR;
r4135r4136
169152      desc->delayslots = 1;
170153
171154      return TRUE;
172      break;
173155
174156   case 0x04: // MOVBS0(Rm, Rn);
175157   case 0x05: // MOVWS0(Rm, Rn);
r4135r4136
186168      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn) | REGFLAG_R(0);
187169      desc->flags |= OPFLAG_READS_MEMORY;
188170      return TRUE;
189      break;
190171
191172   case 0x07: // MULL(Rm, Rn);
192173   case 0x17: // MULL(Rm, Rn);
r4135r4136
196177      desc->regout[1] |= REGFLAG_MACL;
197178      desc->cycles = 2;
198179      return TRUE;
199      break;
200180
201181   case 0x08: // CLRT();
202182      desc->regout[1] |= REGFLAG_SR;
203183      return TRUE;
204      break;
205184
206185   case 0x0a: // STSMACH(Rn);
207186      desc->regout[0] |= REGFLAG_R(Rn);
208187      desc->regout[1] |= REGFLAG_MACH;
209188      return TRUE;
210      break;
211189
212190   case 0x0b: // RTS();
213191      desc->regin[1] |= REGFLAG_PR;
r4135r4136
218196      desc->cycles = 2;
219197
220198      return TRUE;
221      break;
222199
223200   case 0x0c: // MOVBL0(Rm, Rn);
224201   case 0x0d: // MOVWL0(Rm, Rn);
r4135r4136
236213      desc->regout[0] |= REGFLAG_R(Rn);
237214      desc->flags |= OPFLAG_READS_MEMORY;
238215      return TRUE;
239      break;
240216
241217   case 0x0f: // MAC_L(Rm, Rn);
242218   case 0x1f: // MAC_L(Rm, Rn);
r4135r4136
246222      desc->regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
247223      desc->cycles = 3;
248224      return TRUE;
249      break;
250225
251226   case 0x12: // STCGBR(Rn);
252227      desc->regout[0] |= REGFLAG_R(Rn);
253228      desc->regin[1] |= REGFLAG_GBR;
254229      return TRUE;
255      break;
256230
257231   case 0x18: // SETT();
258232      desc->regout[1] |= REGFLAG_SR;
259233      return TRUE;
260      break;
261234
262235   case 0x19: // DIV0U();
263236      desc->regout[1] |= REGFLAG_SR;
264237      return TRUE;
265      break;
266238
267239   case 0x1a: // STSMACL(Rn);
268240      desc->regin[1] |= REGFLAG_MACL;
269241      desc->regout[0] |= REGFLAG_R(Rn);
270242      return TRUE;
271      break;
272243
273244   case 0x1b: // SLEEP();
274245      desc->cycles = 3;
275246      return TRUE;
276      break;
277247
278248   case 0x22: // STCVBR(Rn);
279249      desc->regin[0] |= REGFLAG_R(Rn);
280250      desc->regout[1] |= REGFLAG_VBR;
281251      return TRUE;
282      break;
283252
284253   case 0x23: // BRAF(Rn);
285254      desc->regin[0] |= REGFLAG_R(Rm);
r4135r4136
288257      desc->delayslots = 1;
289258      desc->cycles = 2;
290259      return TRUE;
291      break;
292260
293261   case 0x28: // CLRMAC();
294262      desc->regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
295263      return TRUE;
296      break;
297264
298265   case 0x29: // MOVT(Rn);
299266      desc->regin[1] |= REGFLAG_SR;
300267      desc->regout[0] |= REGFLAG_R(Rn);
301268      return TRUE;
302      break;
303269
304270   case 0x2a: // STSPR(Rn);
305271      desc->regin[1] |= REGFLAG_PR;
306272      desc->regout[0] |= REGFLAG_R(Rn);
307273      return TRUE;
308      break;
309274
310275   case 0x2b: // RTE();
311276      desc->regin[0] |= REGFLAG_R(15);
r4135r4136
317282      desc->cycles = 4;
318283
319284      return TRUE;
320      break;
321285   }
322286
323287   return FALSE;
r4135r4136
333297      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
334298      desc->flags |= OPFLAG_WRITES_MEMORY;
335299      return TRUE;
336      break;
337300
338301   case  3: // NOP();
339302      return TRUE;
340      break;
341303
342304   case  4: // MOVBM(Rm, Rn);
343305   case  5: // MOVWM(Rm, Rn);
r4135r4136
347309      desc->regout[0] |= REGFLAG_R(Rn);
348310      desc->flags |= OPFLAG_WRITES_MEMORY;
349311      return TRUE;
350      break;
351312
352313   case  7: // DIV0S(Rm, Rn);
353314   case  8: // TST(Rm, Rn);
r4135r4136
355316      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
356317      desc->regout[1] |= REGFLAG_SR;
357318      return TRUE;
358      break;
359319
360320   case  9: // AND(Rm, Rn);
361321   case 10: // XOR(Rm, Rn);
r4135r4136
363323      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
364324      desc->regout[0] |= REGFLAG_R(Rn);
365325      return TRUE;
366      break;
367326
368327   case 14: // MULU(Rm, Rn);
369328   case 15: // MULS(Rm, Rn);
r4135r4136
371330      desc->regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
372331      desc->cycles = 2;
373332      return TRUE;
374      break;
375333   }
376334
377335   return FALSE;
r4135r4136
389347      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
390348      desc->regout[1] |= REGFLAG_SR;
391349      return TRUE;
392      break;
393350
394351   case  1: // NOP();
395352   case  9: // NOP();
396353      return TRUE;
397      break;
398354
399355   case  4: // DIV1(Rm, Rn);
400356      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
401357      desc->regout[0] |= REGFLAG_R(Rn);
402358      desc->regout[1] |= REGFLAG_SR;
403359      return TRUE;
404      break;
405360
406361   case  5: // DMULU(Rm, Rn);
407362   case 13: // DMULS(Rm, Rn);
r4135r4136
409364      desc->regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
410365      desc->cycles = 2;
411366      return TRUE;
412      break;
413367
414368   case  8: // SUB(Rm, Rn);
415369   case 12: // ADD(Rm, Rn);
416370      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
417371      desc->regout[0] |= REGFLAG_R(Rn);
418372      return TRUE;
419      break;
420373
421374   case 10: // SUBC(Rm, Rn);
422375   case 11: // SUBV(Rm, Rn);
r4135r4136
427380      desc->regout[0] |= REGFLAG_R(Rn);
428381      desc->regout[1] |= REGFLAG_SR;
429382      return TRUE;
430      break;
431383   }
432384   return FALSE;
433385}
r4135r4136
444396      desc->regout[0] |= REGFLAG_R(Rn);
445397      desc->regout[1] |= REGFLAG_SR;
446398      return TRUE;
447      break;
448399
449400   case 0x02: // STSMMACH(Rn);
450401      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
452403      desc->regout[0] |= REGFLAG_R(Rn);
453404      desc->flags |= OPFLAG_WRITES_MEMORY;
454405      return TRUE;
455      break;
456406
457407   case 0x03: // STCMSR(Rn);
458408      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
460410      desc->cycles = 2;
461411      desc->flags |= OPFLAG_WRITES_MEMORY;
462412      return TRUE;
463      break;
464413
465414   case 0x06: // LDSMMACH(Rn);
466415      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
468417      desc->regout[1] |= REGFLAG_MACH;
469418      desc->flags |= OPFLAG_READS_MEMORY;
470419      return TRUE;
471      break;
472420
473421   case 0x07: // LDCMSR(Rn);
474422      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
477425      desc->cycles = 3;
478426      desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_END_SEQUENCE;
479427      return TRUE;
480      break;
481428
482429   case 0x08: // SHLL2(Rn);
483430   case 0x09: // SHLR2(Rn);
r4135r4136
488435      desc->regin[0] |= REGFLAG_R(Rn);
489436      desc->regout[0] |= REGFLAG_R(Rn);
490437      return TRUE;
491      break;
492438
493439   case 0x0a: // LDSMACH(Rn);
494440      desc->regin[0] |= REGFLAG_R(Rn);
495441      desc->regout[1] |= REGFLAG_MACH;
496442      return TRUE;
497      break;
498443
499444   case 0x0b: // JSR(Rn);
500445      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
503448      desc->targetpc = BRANCH_TARGET_DYNAMIC;
504449      desc->delayslots = 1;
505450      return TRUE;
506      break;
507451
508452   case 0x0e: // LDCSR(Rn);
509453      desc->regin[0] |= REGFLAG_R(Rn);
510454      desc->regout[1] |= REGFLAG_SR;
511455      desc->flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_END_SEQUENCE;
512456      return TRUE;
513      break;
514457
515458   case 0x0f: // MAC_W(Rm, Rn);
516459   case 0x1f: // MAC_W(Rm, Rn);
r4135r4136
522465      desc->regout[1] |= REGFLAG_MACL | REGFLAG_MACH;
523466      desc->cycles = 3;
524467      return TRUE;
525      break;
526468
527469   case 0x10: // DT(Rn);
528470      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
530472      desc->regout[0] |= REGFLAG_R(Rn);
531473      desc->regout[1] |= REGFLAG_SR;
532474      return TRUE;
533      break;
534475
535476   case 0x11: // CMPPZ(Rn);
536477   case 0x15: // CMPPL(Rn);
r4135r4136
538479      desc->regin[1] |= REGFLAG_SR;
539480      desc->regout[1] |= REGFLAG_SR;
540481      return TRUE;
541      break;
542482
543483   case 0x12: // STSMMACL(Rn);
544484      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
546486      desc->regout[0] |= REGFLAG_R(Rn);
547487      desc->flags |= OPFLAG_WRITES_MEMORY;
548488      return TRUE;
549      break;
550489
551490   case 0x13: // STCMGBR(Rn);
552491      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
554493      desc->regout[0] |= REGFLAG_R(Rn);
555494      desc->flags |= OPFLAG_WRITES_MEMORY;
556495      return TRUE;
557      break;
558496
559497   case 0x16: // LDSMMACL(Rn);
560498      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
r4135r4136
562500      desc->regout[1] |= REGFLAG_MACL;
563501      desc->flags |= OPFLAG_READS_MEMORY;
564502      return TRUE;
565      break;
566503
567504   case 0x17: // LDCMGBR(Rn);
568505      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
570507      desc->regout[1] |= REGFLAG_GBR;
571508      desc->flags |= OPFLAG_READS_MEMORY;
572509      return TRUE;
573      break;
574510
575511   case 0x1a: // LDSMACL(Rn);
576512      desc->regin[0] |= REGFLAG_R(Rn);
577513      desc->regout[1] |= REGFLAG_MACL;
578514      return TRUE;
579      break;
580515
581516   case 0x1b: // TAS(Rn);
582517      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
585520      desc->cycles = 4;
586521      desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_WRITES_MEMORY;
587522      return TRUE;
588      break;
589523
590524   case 0x1e: // LDCGBR(Rn);
591525      desc->regin[0] |= REGFLAG_R(Rn);
592526      desc->regout[1] |= REGFLAG_GBR;
593527      return TRUE;
594      break;
595528
596529   case 0x20: // SHAL(Rn);
597530   case 0x21: // SHAR(Rn);
r4135r4136
599532      desc->regout[0] |= REGFLAG_R(Rn);
600533      desc->regout[1] |= REGFLAG_SR;
601534      return TRUE;
602      break;
603535
604536   case 0x22: // STSMPR(Rn);
605537      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
607539      desc->regout[0] |= REGFLAG_R(Rn);
608540      desc->flags |= OPFLAG_WRITES_MEMORY;
609541      return TRUE;
610      break;
611542
612543   case 0x23: // STCMVBR(Rn);
613544      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
615546      desc->regout[0] |= REGFLAG_R(Rn);
616547      desc->flags |= OPFLAG_WRITES_MEMORY;
617548      return TRUE;
618      break;
619549
620550   case 0x24: // ROTCL(Rn);
621551   case 0x25: // ROTCR(Rn);
r4135r4136
624554      desc->regout[0] |= REGFLAG_R(Rn);
625555      desc->regout[1] |= REGFLAG_SR;
626556      return TRUE;
627      break;
628557
629558   case 0x26: // LDSMPR(Rn);
630559      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
632561      desc->regout[1] |= REGFLAG_PR;
633562      desc->flags |= OPFLAG_READS_MEMORY;
634563      return TRUE;
635      break;
636564
637565   case 0x27: // LDCMVBR(Rn);
638566      desc->regin[0] |= REGFLAG_R(Rn);
r4135r4136
640568      desc->regout[1] |= REGFLAG_VBR;
641569      desc->flags |= OPFLAG_READS_MEMORY;
642570      return TRUE;
643      break;
644571
645572   case 0x2a: // LDSPR(Rn);
646573      desc->regin[0] |= REGFLAG_R(Rn);
647574      desc->regout[1] |= REGFLAG_PR;
648575      return TRUE;
649      break;
650576
651577   case 0x2b: // JMP(Rm);
652578      desc->regin[0] |= REGFLAG_R(Rm);
r4135r4136
654580      desc->targetpc = BRANCH_TARGET_DYNAMIC;
655581      desc->delayslots = 1;
656582      return TRUE;
657      break;
658583
659584   case 0x2e: // LDCVBR(Rn);
660585      desc->regin[0] |= REGFLAG_R(Rn);
661586      desc->regout[1] |= REGFLAG_VBR;
662587      return TRUE;
663      break;
664588
665589   case 0x0c: // NOP();
666590   case 0x0d: // NOP();
r4135r4136
685609   case 0x3d: // NOP();
686610   case 0x3e: // NOP();
687611      return TRUE;
688      break;
689
690612   }
691613
692614   return FALSE;
r4135r4136
710632      desc->regin[0] |= REGFLAG_R(Rm);
711633      desc->regout[0] |= REGFLAG_R(Rn);
712634      return TRUE;
713      break;
714635
715636   case  4: // MOVBP(Rm, Rn);
716637   case  5: // MOVWP(Rm, Rn);
r4135r4136
719640      desc->regout[0] |= REGFLAG_R(Rn);
720641      desc->flags |= OPFLAG_READS_MEMORY;
721642      return TRUE;
722      break;
723643
724644   case  8: // SWAPB(Rm, Rn);
725645      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(Rn);
726646      desc->regout[0] |= REGFLAG_R(Rn);
727647      return TRUE;
728      break;
729648
730649   case 10: // NEGC(Rm, Rn);
731650      desc->regin[0] |= REGFLAG_R(Rm);
732651      desc->regout[0] |= REGFLAG_R(Rn);
733652      desc->regout[1] |= REGFLAG_SR;
734653      return TRUE;
735      break;
736654   }
737655   return FALSE;
738656}
r4135r4136
748666      desc->regin[0] |= REGFLAG_R(Rm) | REGFLAG_R(0);
749667      desc->flags |= OPFLAG_WRITES_MEMORY;
750668      return TRUE;
751      break;
752669
753670   case  2<< 8: // NOP();
754671   case  3<< 8: // NOP();
r4135r4136
758675   case 12<< 8: // NOP();
759676   case 14<< 8: // NOP();
760677      return TRUE;
761      break;
762678
763679   case  4<< 8: // MOVBL4(Rm, opcode & 0x0f);
764680   case  5<< 8: // MOVWL4(Rm, opcode & 0x0f);
r4135r4136
766682      desc->regout[0] |= REGFLAG_R(0);
767683      desc->flags |= OPFLAG_READS_MEMORY;
768684      return TRUE;
769      break;
770685
771686   case  8<< 8: // CMPIM(opcode & 0xff);
772687      desc->regin[0] |= REGFLAG_R(Rm);
773688      desc->regin[1] |= REGFLAG_SR;
774689      desc->regout[1] |= REGFLAG_SR;
775690      return TRUE;
776      break;
777691
778692   case  9<< 8: // BT(opcode & 0xff);
779693   case 11<< 8: // BF(opcode & 0xff);
r4135r4136
782696      disp = ((INT32)opcode << 24) >> 24;
783697      desc->targetpc = (desc->pc + 2) + disp * 2 + 2;
784698      return TRUE;
785      break;
786699
787700   case 13<< 8: // BTS(opcode & 0xff);
788701   case 15<< 8: // BFS(opcode & 0xff);
r4135r4136
792705      desc->targetpc = (desc->pc + 2) + disp * 2 + 2;
793706      desc->delayslots = 1;
794707      return TRUE;
795      break;
796708   }
797709
798710   return FALSE;
r4135r4136
808720      desc->regin[0] |= REGFLAG_R(0);
809721      desc->flags |= OPFLAG_WRITES_MEMORY;
810722      return TRUE;
811      break;
812723
813724   case  3<<8: // TRAPA(opcode & 0xff);
814725      desc->regin[0] |= REGFLAG_R(15);
r4135r4136
818729      desc->targetpc = BRANCH_TARGET_DYNAMIC;
819730      desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
820731      return TRUE;
821      break;
822732
823733   case  4<<8: // MOVBLG(opcode & 0xff);
824734   case  5<<8: // MOVWLG(opcode & 0xff);
r4135r4136
827737      desc->regout[0] |= REGFLAG_R(0);
828738      desc->flags |= OPFLAG_READS_MEMORY;
829739      return TRUE;
830      break;
831740
832741   case  8<<8: // TSTI(opcode & 0xff);
833742      desc->regin[0] |= REGFLAG_R(0);
834743      desc->regin[1] |= REGFLAG_SR;
835744      desc->regout[1] |= REGFLAG_SR;
836745      return TRUE;
837      break;
838746
839747   case  9<<8: // ANDI(opcode & 0xff);
840748   case 10<<8: // XORI(opcode & 0xff);
r4135r4136
842750      desc->regin[0] |= REGFLAG_R(0);
843751      desc->regout[0] |= REGFLAG_R(0);
844752      return TRUE;
845      break;
846753
847754   case 12<<8: // TSTM(opcode & 0xff);
848755   case 13<<8: // ANDM(opcode & 0xff);
r4135r4136
853760      desc->regout[1] |= REGFLAG_SR;
854761      desc->flags |= OPFLAG_READS_MEMORY;
855762      return TRUE;
856      break;
857763   }
858764
859765   return FALSE;
src/emu/cpu/sm8500/sm8500.c
r4135r4136
5959        0, 8, 2, 10, 4, 12, 6, 14
6060};
6161
62UINT8 sm85cpu_mem_readbyte( sm8500_state *cpustate, UINT32 offset ) {
62static UINT8 sm85cpu_mem_readbyte( sm8500_state *cpustate, UINT32 offset ) {
6363   return ( offset < 0x10 ) ? cpustate->register_base[offset] : memory_read_byte_8be( cpustate->program, offset );
6464}
6565
66void sm85cpu_mem_writebyte( sm8500_state *cpustate, UINT32 offset, UINT8 data ) {
66static void sm85cpu_mem_writebyte( sm8500_state *cpustate, UINT32 offset, UINT8 data ) {
6767   if ( offset < 0x10 ) {
6868      cpustate->register_base[offset] = data;
6969   } else {
r4135r4136
267267   }
268268}
269269
270unsigned sm8500_get_reg( sm8500_state *cpustate, int regnum )
270static unsigned sm8500_get_reg( sm8500_state *cpustate, int regnum )
271271{
272272   switch( regnum )
273273   {
src/emu/cpu/mb88xx/mb88xx.h
r4135r4136
1212#ifndef __MB88XX_H__
1313#define   __MB88XX_H__
1414
15#ifndef INLINE
16#define INLINE static inline
17#endif
18
1915#include "cpuintrf.h"
2016
2117/***************************************************************************
src/emu/cpu/alph8201/alph8201.h
r4135r4136
1212#ifndef __ALPH8201_H__
1313#define __ALPH8201_H__
1414
15#ifndef INLINE
16#define INLINE static inline
17#endif
18
1915#include "cpuintrf.h"
2016
2117enum
src/emu/cpu/g65816/g65816cm.h
r4135r4136
3030/* ================================ GENERAL =============================== */
3131/* ======================================================================== */
3232
33/* Fallback on static if we don't have inline */
34#ifndef INLINE
35#define INLINE static
36#endif
37
3833/* This should be set to the default size of your processor (min 16 bit) */
3934#undef uint
4035#define uint unsigned int
src/emu/cpu/g65816/g65816ds.c
r4135r4136
2424#endif
2525
2626#define ADDRESS_65816(A) ((A)&0xffffff)
27#ifndef INLINE
28#define INLINE static
29#endif
3027
3128
3229typedef struct
src/emu/cpu/esrip/esrip.c
r4135r4136
11/***************************************************************************
22
3    escpustate->c
3    esrip.c
44
55    Implementation of the Entertainment Sciences
66    AM29116-based Real Time Image Processor
r4135r4136
2323    MACROS
2424***************************************************************************/
2525
26#define ASSERT(x)
27//(assert(x))
2826#define RIP_PC      (cpustate->pc | ((cpustate->status_out & 1) << 8))
2927#define _BIT(x, n)   ((x) & (1 << (n)))
3028#define RISING_EDGE(old_val, new_val, bit)   (!(old_val & (1 << bit)) && (new_val & (1 << bit)))
3129
32#define UNHANDLED   do {printf("%s:UNHANDLED (%x)\n", __FUNCTION__, inst); ASSERT(0);}while(0)
33#define INVALID      do {printf("%s:INVALID (%x)\n", __FUNCTION__, inst); ASSERT(0);}while(0)
30#define UNHANDLED   do {printf("%s:UNHANDLED (%x)\n", __FUNCTION__, inst); assert(0);} while (0)
31#define INVALID      do {printf("%s:INVALID (%x)\n", __FUNCTION__, inst); assert(0);} while (0)
3432
3533#define RAM_ADDR   (inst & 0x1f)
3634#define MODE      (inst & 0x8000)
r4135r4136
9492   UINT16   attr_latch;
9593   UINT16   adl_latch;
9694   UINT16   adr_latch;
95   UINT16   iaddr_latch;
9796   UINT8   c_latch;
98   UINT16   iaddr;
9997
10098   UINT16   fdt_cnt;
10199   UINT16   ipt_cnt;
102100
103   UINT16   *ipt_ram;
104   UINT8   *lbrm;
101   UINT8   fig;
102   UINT16   fig_cycles;
105103
106104   UINT8   *optable;
107105
108   UINT8   fig;
109   UINT16   fig_cycles;
106   UINT16   *ipt_ram;
107   UINT8   *lbrm;
110108
111109   const   device_config *device;
112110   const   address_space *program;
r4135r4136
120118
121119
122120/***************************************************************************
123    INITIALIZATION AND SHUTDOWN
121    PUBLIC FUNCTIONS
124122***************************************************************************/
125123
126124UINT8 get_rip_status(const device_config *cpu)
127125{
128126   esrip_state *cpustate = cpu->token;
129
130127   return cpustate->status_out;
131128}
132129
133/*
134static STATE_POSTLOAD( esrip_postload )
135{
136130
137}
138*/
131/***************************************************************************
132    INITIALIZATION AND SHUTDOWN
133***************************************************************************/
139134
140//static void esrip_state_register(int index, const char *type)
141//{
142//  state_save_register_item_pointer(type, index, cpustate->ipt_ram, IPT_RAM_SIZE / 2);
143//}
144
145
146135enum
147136{
148137   ROTR1, TOR1, ROTR2, ROTC, ROTM, BOR2, CRCF, CRCR,
r4135r4136
150139   ROTNR, BONR, BOR1, SONR, SHFTNR, PRTNR, TONR
151140} ops;
152141
153
154142void make_ops(esrip_state *cpustate)
155143{
156144   int inst;
r4135r4136
260248   cpustate->status_in = _config->status_in;
261249   cpustate->draw = _config->draw;
262250
251   /* Allocate image pointer table RAM */
263252   cpustate->ipt_ram = auto_malloc(IPT_RAM_SIZE);
264//state_save_register_global_pointer(cpustate->ipt_ram, IPT_RAM_SIZE / 2);          // TODO
265253
266//  esrip_state_register(index, "esrip");
267254   cpustate->device = device;
268255   cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
269256
270257   /* Create the instruction decode lookup table */
271258   cpustate->optable = auto_malloc(65536);
272259   make_ops(cpustate);
260
261   /* Register stuff for state saving */
262   state_save_register_device_item(device, 0, cpustate->acc);
263   state_save_register_device_item_array(device, 0, cpustate->ram);
264   state_save_register_device_item(device, 0, cpustate->d_latch);
265   state_save_register_device_item(device, 0, cpustate->i_latch);
266   state_save_register_device_item(device, 0, cpustate->result);
267   state_save_register_device_item(device, 0, cpustate->new_status);
268   state_save_register_device_item(device, 0, cpustate->status);
269   state_save_register_device_item(device, 0, cpustate->inst);
270   state_save_register_device_item(device, 0, cpustate->immflag);
271   state_save_register_device_item(device, 0, cpustate->ct);
272   state_save_register_device_item(device, 0, cpustate->t);
273   state_save_register_device_item(device, 0, cpustate->l1);
274   state_save_register_device_item(device, 0, cpustate->l2);
275   state_save_register_device_item(device, 0, cpustate->l3);
276   state_save_register_device_item(device, 0, cpustate->l4);
277   state_save_register_device_item(device, 0, cpustate->l5);
278   state_save_register_device_item(device, 0, cpustate->l6);
279   state_save_register_device_item(device, 0, cpustate->l7);
280   state_save_register_device_item(device, 0, cpustate->pl1);
281   state_save_register_device_item(device, 0, cpustate->pl2);
282   state_save_register_device_item(device, 0, cpustate->pl3);
283   state_save_register_device_item(device, 0, cpustate->pl4);
284   state_save_register_device_item(device, 0, cpustate->pl5);
285   state_save_register_device_item(device, 0, cpustate->pl6);
286   state_save_register_device_item(device, 0, cpustate->pl7);
287   state_save_register_device_item(device, 0, cpustate->pc);
288   state_save_register_device_item(device, 0, cpustate->status_out);
289   state_save_register_device_item(device, 0, cpustate->x_scale);
290   state_save_register_device_item(device, 0, cpustate->y_scale);
291   state_save_register_device_item(device, 0, cpustate->line_latch);
292   state_save_register_device_item(device, 0, cpustate->fig_latch);
293   state_save_register_device_item(device, 0, cpustate->attr_latch);
294   state_save_register_device_item(device, 0, cpustate->adl_latch);
295   state_save_register_device_item(device, 0, cpustate->adr_latch);
296   state_save_register_device_item(device, 0, cpustate->iaddr_latch);
297   state_save_register_device_item(device, 0, cpustate->c_latch);
298   state_save_register_device_item(device, 0, cpustate->fdt_cnt);
299   state_save_register_device_item(device, 0, cpustate->ipt_cnt);
300   state_save_register_device_item(device, 0, cpustate->fig);
301   state_save_register_device_item(device, 0, cpustate->fig_cycles);
302   state_save_register_device_item_pointer(device, 0, cpustate->ipt_ram, IPT_RAM_SIZE / sizeof(UINT16));
273303}
274304
275305
r4135r4136
306336}
307337
308338
339/***************************************************************************
340    PRIVATE FUNCTIONS
341***************************************************************************/
309342
310343static int get_hblank(running_machine *machine)
311344{
r4135r4136
358391      }
359392   }
360393   else
361      ASSERT(!"RIP: Invalid jump control");
394      assert(!"RIP: Invalid jump control");
362395
363396   return ret;
364397}
r4135r4136
401434}
402435
403436
437/***************************************************************************
438    INSTRUCTIONS
439***************************************************************************/
440
404441enum
405442{
406443   ACC,
r4135r4136
16141651{
16151652   esrip_state *cpustate = device->token;
16161653   int calldebugger = (device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0;
1617   UINT16 status = cpustate->status_in(device->machine);
1654   UINT8 status;
16181655
16191656   cpustate->icount = cycles;
16201657
1658   /* I think we can get away with placing this outside of the loop */
1659   status = cpustate->status_in(device->machine);
1660
16211661   /* Core execution loop */
16221662   do
16231663   {
r4135r4136
16361676
16371677      if (cpustate->fig_cycles)
16381678      {
1639         if(--cpustate->fig_cycles == 0)
1679         if (--cpustate->fig_cycles == 0)
16401680            cpustate->fig = 0;
16411681      }
16421682
r4135r4136
17611801         cpustate->attr_latch = x_bus;
17621802
17631803         cpustate->fig = 1;
1764         cpustate->fig_cycles = cpustate->draw(device->machine, cpustate->adl_latch, cpustate->adr_latch, cpustate->fig_latch, cpustate->attr_latch, cpustate->iaddr, cpustate->c_latch, cpustate->x_scale, cpustate->line_latch);
1804         cpustate->fig_cycles = cpustate->draw(device->machine, cpustate->adl_latch, cpustate->adr_latch, cpustate->fig_latch, cpustate->attr_latch, cpustate->iaddr_latch, cpustate->c_latch, cpustate->x_scale, cpustate->line_latch);
17651805      }
17661806
17671807      /* X-scale */
r4135r4136
17771817
17781818      /* Image ROM address */
17791819      if (RISING_EDGE(cpustate->pl3, cpustate->l3, 5))
1780         cpustate->iaddr = y_bus;
1820         cpustate->iaddr_latch = y_bus;
17811821
17821822      /* IXLLD */
17831823      if (RISING_EDGE(cpustate->pl3, cpustate->l3, 6))
r4135r4136
18151855
18161856
18171857/***************************************************************************
1818    DISASSEMBLY HOOK
1858    DISASSEMBLY HOOK (TODO: FINISH)
18191859***************************************************************************/
18201860
18211861static CPU_DISASSEMBLE( esrip )
r4135r4136
18621902   UINT8 ctrl3 = (inst_hi) & 0xff;
18631903
18641904   sprintf(buffer, "%.4x %c%c%c%c %.2x %s%s%s%s%s%s%s%s %c%s%s%s %c%c%c%c%c%c%c%c\n",
1865      ins,
1866      ctrl & 1 ? 'D' : ' ',
1867      ctrl & 2 ? ' ' : 'Y',
1868      ctrl & 4 ? 'S' : ' ',
1869      (~jmp_ctrl & 0x18) ? 'J' : ' ',
1870      jmp_dest,
1871      ctrl1 & 0x01 ? "  " : "I ",
1872      ctrl1 & 0x02 ? "  " : "FL",
1873      ctrl1 & 0x04 ? "FE" : "  ",
1874      ctrl1 & 0x08 ? "  " : "FR",
1875      ctrl1 & 0x10 ? "  " : "IL",
1876      ctrl1 & 0x20 ? "IE" : "  ",
1877      ctrl1 & 0x40 ? "  " : "IR",
1878      ctrl1 & 0x80 ? "  " : "IW",
1905         ins,
1906         ctrl & 1 ? 'D' : ' ',
1907         ctrl & 2 ? ' ' : 'Y',
1908         ctrl & 4 ? 'S' : ' ',
1909         (~jmp_ctrl & 0x18) ? 'J' : ' ',
1910         jmp_dest,
1911         ctrl1 & 0x01 ? "  " : "I ",
1912         ctrl1 & 0x02 ? "  " : "FL",
1913         ctrl1 & 0x04 ? "FE" : "  ",
1914         ctrl1 & 0x08 ? "  " : "FR",
1915         ctrl1 & 0x10 ? "  " : "IL",
1916         ctrl1 & 0x20 ? "IE" : "  ",
1917         ctrl1 & 0x40 ? "  " : "IR",
1918         ctrl1 & 0x80 ? "  " : "IW",
18791919
1880      ctrl2 & 0x80 ? ' ' : 'O',
1881      ctrl2 & 0x40 ? "     " : "IXLLD",
1882      ctrl2 & 0x20 ? "     " : "IADLD",
1883      ctrl2 & 0x10 ? "     " : "SCALD",
1920         ctrl2 & 0x80 ? ' ' : 'O',
1921         ctrl2 & 0x40 ? "     " : "IXLLD",
1922         ctrl2 & 0x20 ? "     " : "IADLD",
1923         ctrl2 & 0x10 ? "     " : "SCALD",
18841924
1885      ctrl3 & 0x01 ? ' ' : '0',
1886      ctrl3 & 0x02 ? ' ' : '1',
1887      ctrl3 & 0x04 ? ' ' : '2',
1888      ctrl3 & 0x08 ? ' ' : '3',
1889      ctrl3 & 0x10 ? ' ' : '4',
1890      ctrl3 & 0x20 ? ' ' : '5',
1891      ctrl3 & 0x40 ? ' ' : '6',
1892      ctrl3 & 0x80 ? ' ' : '7'
1893      );
1925         ctrl3 & 0x01 ? ' ' : '0',
1926         ctrl3 & 0x02 ? ' ' : '1',
1927         ctrl3 & 0x04 ? ' ' : '2',
1928         ctrl3 & 0x08 ? ' ' : '3',
1929         ctrl3 & 0x10 ? ' ' : '4',
1930         ctrl3 & 0x20 ? ' ' : '5',
1931         ctrl3 & 0x40 ? ' ' : '6',
1932         ctrl3 & 0x80 ? ' ' : '7'
1933         );
18941934
18951935   return 1 | DASMFLAG_SUPPORTED;
18961936}
r4135r4136
18991939 * set_info
19001940 **************************************************************************/
19011941
1902CPU_SET_INFO( esrip )
1942static CPU_SET_INFO( esrip )
19031943{
19041944   esrip_state *cpustate = device->token;
19051945
r4135r4136
20252065      case CPUINFO_STR_REGISTER + ESRIP_ADRL:         sprintf(info->s, "ADRL: %04X", cpustate->adl_latch); break;
20262066      case CPUINFO_STR_REGISTER + ESRIP_ADRR:         sprintf(info->s, "ADRR: %04X", cpustate->adr_latch); break;
20272067      case CPUINFO_STR_REGISTER + ESRIP_COLR:         sprintf(info->s, "COLR: %04X", cpustate->c_latch); break;
2028      case CPUINFO_STR_REGISTER + ESRIP_IADDR:      sprintf(info->s, "IADR: %04X", cpustate->iaddr); break;
2068      case CPUINFO_STR_REGISTER + ESRIP_IADDR:      sprintf(info->s, "IADR: %04X", cpustate->iaddr_latch); break;
20292069   }
20302070}
src/emu/cpu/tms9900/9900dasm.c
r4135r4136
325325   {
326326      case 0x0:   /* workspace register */
327327         return sprintf (dest, "R%d", arg);
328         break;
329328      case 0x1:   /* workspace register indirect */
330329         return sprintf (dest, "*R%d", arg);
331         break;
332330      case 0x2:   /* symbolic|indexed */
333331         base = readop_arg(opram, pc);
334332         if (arg)    /* indexed */
r4135r4136
338336         break;
339337      case 0x3:   /* workspace register indirect auto increment */
340338         return sprintf (dest, "*R%d+", arg);
341         break;
342339   }
343340
344341   return 0;
src/emu/cpu/tms32025/tms32025.c
r4135r4136
123123#define CLK 4   /* 1 cycle equals 4 clock ticks */      /* PE/DI */
124124
125125
126#ifndef INLINE
127#define INLINE static inline
128#endif
129126
130
131127#define SET_PC(x)   do { cpustate->PC = (x); } while (0)
132128
133129#define P_IN(A)         (memory_read_word_16be(cpustate->io, (A)<<1))
src/emu/cpu/pic16c5x/pic16c5x.c
r4135r4136
5555#include "pic16c5x.h"
5656
5757
58#ifndef INLINE
59#define INLINE static inline
60#endif
6158
62
6359#define M_RDRAM(A)      (((A) < 8) ? cpustate->internalram[A] : PIC16C5x_RAM_RDMEM(A))
6460#define M_WRTRAM(A,V)   do { if ((A) < 8) cpustate->internalram[A] = (V); else PIC16C5x_RAM_WRMEM(A,V); } while (0)
6561#define M_RDOP(A)      PIC16C5x_RDOP(A)
src/emu/cpu/mb86233/mb86233.c
r4135r4136
204204
205205      case 0x16:   /* always */
206206         return 1;
207      break;
208207
209208      default:
210209         logerror( "TGP: Unknown condition code (cc=%d) at PC:%x\n", cond, GETPC());
r4135r4136
594593      {
595594         case 0x10:   /* A */
596595            return GETA().u;
597         break;
598596
599597         case 0x11:   /* A.e */
600598            return (GETA().u >> 23) & 0xff;
601         break;
602599
603600         case 0x12:   /* A.m */
604601            return (GETA().u & 0x7fffff) | ((GETA().u&0x80000000) >> 8);
605         break;
606602
607603         case 0x13:   /* B */
608604            return GETB().u;
609         break;
610605
611606         case 0x14:   /* B.e */
612607            return (GETB().u >> 23) & 0xff;
613         break;
614608
615609         case 0x15:   /* B.m */
616610            return (GETB().u & 0x7fffff) | ((GETB().u&0x80000000) >> 8);
617         break;
618611
619612         case 0x19:   /* D */
620613            return GETD().u;
621         break;
622614
623615         case 0x1A:   /* D.e */
624616            return (GETD().u >> 23) & 0xff;
625         break;
626617
627618         case 0x1B:   /* D.m */
628619            return (GETD().u & 0x7fffff) | ((GETD().u&0x80000000) >> 8);
629         break;
630620
631621         case 0x1C:   /* P */
632622            return GETP().u;
633         break;
634623
635624         case 0x1D:   /* P.e */
636625            return (GETP().u >> 23) & 0xff;
637         break;
638626
639627         case 0x1E:   /* P.m */
640628            return (GETP().u & 0x7fffff) | ((GETP().u&0x80000000) >> 8);
641         break;
642629
643630         case 0x1F:   /* Shift */
644631            return GETSHIFT();
645         break;
646632
647633         case 0x20:   /* Parallel Port */
648634            logerror( "TGP: Parallel port read at PC:%04x\n", GETPC() );
649635            return 0;
650         break;
651636
652637         case 0x21:   /* FIn */
653638         {
r4135r4136
664649            GETFIFOWAIT() = 1;
665650            return 0;
666651         }
667         break;
668652
669653         case 0x22:   /* FOut */
670654            return 0;
671         break;
672655
673656         case 0x23:   /* EB */
674657            return GETEB();
675         break;
676658
677659         case 0x34:
678660            return GETREPCNT();
679         break;
680661
681662         default:
682663            logerror( "TGP: Unknown GETREG (%d) at PC=%04x\n", reg, GETPC() );
src/emu/cpu/arm7/arm7core.c
r4135r4136
117117
118118/* Static Vars */
119119// Note: for multi-cpu implementation, this approach won't work w/o modification
120WRITE32_HANDLER((*arm7_coproc_do_callback));    // holder for the co processor Data Operations Callback func.
121READ32_HANDLER((*arm7_coproc_rt_r_callback));   // holder for the co processor Register Transfer Read Callback func.
122WRITE32_HANDLER((*arm7_coproc_rt_w_callback));  // holder for the co processor Register Transfer Write Callback Callback func.
120write32_space_func arm7_coproc_do_callback;    // holder for the co processor Data Operations Callback func.
121read32_space_func arm7_coproc_rt_r_callback;   // holder for the co processor Register Transfer Read Callback func.
122write32_space_func arm7_coproc_rt_w_callback;  // holder for the co processor Register Transfer Write Callback Callback func.
123123// holder for the co processor Data Transfer Read & Write Callback funcs
124124void (*arm7_coproc_dt_r_callback)(arm_state *cpustate, UINT32 insn, UINT32 *prn, UINT32 (*read32)(arm_state *cpustate, UINT32 addr));
125125void (*arm7_coproc_dt_w_callback)(arm_state *cpustate, UINT32 insn, UINT32 *prn, void (*write32)(arm_state *cpustate, UINT32 addr, UINT32 data));
src/emu/cpu/arm7/arm7core.h
r4135r4136
403403#define SET_REGISTER(state, reg, val)  SetRegister(state, reg, val)
404404#define ARM7_CHECKIRQ           arm7_check_irq_state(cpustate)
405405
406extern WRITE32_HANDLER((*arm7_coproc_do_callback));
407extern READ32_HANDLER((*arm7_coproc_rt_r_callback));
408extern WRITE32_HANDLER((*arm7_coproc_rt_w_callback));
406extern write32_space_func arm7_coproc_do_callback;
407extern read32_space_func arm7_coproc_rt_r_callback;
408extern write32_space_func arm7_coproc_rt_w_callback;
409409extern void (*arm7_coproc_dt_r_callback)(arm_state *cpustate, UINT32 insn, UINT32* prn, UINT32 (*read32)(arm_state *cpustate, UINT32 addr));
410410extern void (*arm7_coproc_dt_w_callback)(arm_state *cpustate, UINT32 insn, UINT32* prn, void (*write32)(arm_state *cpustate, UINT32 addr, UINT32 data));
411411
src/emu/cpu/h6280/h6280.c
r4135r4136
289289
290290   switch (offset&3)
291291   {
292   default: return cpustate->io_buffer; break;
292   default: return cpustate->io_buffer;
293293   case 3:
294294      {
295295         status=0;
r4135r4136
298298         if(cpustate->irq_state[2]!=CLEAR_LINE) status|=4; /* TIMER */
299299         return status|(cpustate->io_buffer&(~H6280_IRQ_MASK));
300300      }
301   case 2: return cpustate->irq_mask|(cpustate->io_buffer&(~H6280_IRQ_MASK));break;
301   case 2: return cpustate->irq_mask|(cpustate->io_buffer&(~H6280_IRQ_MASK));
302302   }
303303}
304304
src/emu/uigfx.c
r4135r4136
787787   for (y = 0; y < height; y++)
788788   {
789789      UINT32 *dest = (UINT32 *)bitmap->base + (dsty + y) * rowpixels + dstx;
790      UINT8 *src = gfx->gfxdata + index * gfx->char_modulo;
790      const UINT8 *src = gfx_element_get_data(gfx, index);
791791
792792      /* loop over columns in the cell */
793793      for (x = 0; x < width; x++)
794794      {
795795         int effx = x, effy = y;
796796         rgb_t pixel;
797         UINT8 *s;
797         const UINT8 *s;
798798
799799         /* compute effective x,y values after rotation */
800800         if (!(rotate & ORIENTATION_SWAP_XY))
src/emu/video/voodoo.c
r4135r4136
31213121               {
31223122                  stats->pixels_in++;
31233123                  stats->clip_fail++;
3124                  continue;
3124                  goto nextpixel;
31253125               }
31263126            }
31273127
r4135r4136
31423142            /* pixel pipeline part 2 handles color combine, fog, alpha, and final output */
31433143            PIXEL_PIPELINE_END(v, stats, dither, dither4, dither_lookup, x, dest, depth, v->reg[fbzMode].u, v->reg[fbzColorPath].u, v->reg[alphaMode].u, v->reg[fogMode].u, iterz, iterw, v->reg[zaColor]);
31443144         }
3145
3145nextpixel:
31463146         /* advance our pointers */
31473147         x++;
31483148         mask >>= 4;
src/emu/video/mc6845.c
r4135r4136
908908      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
909909      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
910910
911      /* --- the following bits of info are returned as pointers to data or functions --- */
911      /* --- the following bits of info are returned as pointers to functions --- */
912912      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(mc6845); break;
913913      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(mc6845);   break;
914914      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
src/emu/tilemap.c
r4135r4136
4646
4747
4848/* internal blitting callbacks */
49typedef void (*blitmask_func)(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
50typedef void (*blitopaque_func)(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
49typedef void (*blitmask_func)(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
50typedef void (*blitopaque_func)(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
5151
5252
5353/* blitting parameters for rendering */
r4135r4136
6161   UINT32             tilemap_priority_code;
6262   UINT8            mask;
6363   UINT8            value;
64   UINT8            alpha;
6465};
6566
6667
r4135r4136
9798   UINT8                  all_tiles_clean;   /* true if all tiles are clean */
9899   UINT32                  palette_offset;      /* palette offset */
99100   UINT32                  pen_data_offset;   /* pen data offset */
101   UINT32                  gfx_used;         /* bitmask of gfx items used */
102   UINT32                  gfx_dirtyseq[MAX_GFX_ELEMENTS]; /* dirtyseq values from last check */
100103
101104   /* scroll information */
102105   UINT32                  scrollrows;         /* number of independently scrolled rows */
r4135r4136
157160      UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound);
158161
159162/* scanline rasterizers for drawing to the pixmap */
160static void scanline_draw_opaque_null(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
161static void scanline_draw_masked_null(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
162static void scanline_draw_opaque_ind16(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
163static void scanline_draw_masked_ind16(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
164static void scanline_draw_opaque_rgb16(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
165static void scanline_draw_masked_rgb16(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
166static void scanline_draw_opaque_rgb16_alpha(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
167static void scanline_draw_masked_rgb16_alpha(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
168static void scanline_draw_opaque_rgb32(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
169static void scanline_draw_masked_rgb32(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
170static void scanline_draw_opaque_rgb32_alpha(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
171static void scanline_draw_masked_rgb32_alpha(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode);
163static void scanline_draw_opaque_null(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
164static void scanline_draw_masked_null(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
165static void scanline_draw_opaque_ind16(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
166static void scanline_draw_masked_ind16(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
167static void scanline_draw_opaque_rgb16(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
168static void scanline_draw_masked_rgb16(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
169static void scanline_draw_opaque_rgb16_alpha(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
170static void scanline_draw_masked_rgb16_alpha(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
171static void scanline_draw_opaque_rgb32(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
172static void scanline_draw_masked_rgb32(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
173static void scanline_draw_opaque_rgb32_alpha(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
174static void scanline_draw_masked_rgb32_alpha(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha);
172175
173176
174177
r4135r4136
251254}
252255
253256
257/*-------------------------------------------------
258    gfx_tiles_changed - return TRUE if any
259    gfx_elements used by this tilemap have
260    changed
261-------------------------------------------------*/
254262
263INLINE int gfx_elements_changed(tilemap *tmap)
264{
265   UINT32 usedmask = tmap->gfx_used;
266   int isdirty = FALSE;
267   int gfxnum;
268
269   /* iterate over all used gfx types and set the dirty flag if any of them have changed */
270   for (gfxnum = 0; usedmask != 0; usedmask >>= 1, gfxnum++)
271      if ((usedmask & 1) != 0)
272         if (tmap->gfx_dirtyseq[gfxnum] != tmap->machine->gfx[gfxnum]->dirtyseq)
273         {
274            tmap->gfx_dirtyseq[gfxnum] = tmap->machine->gfx[gfxnum]->dirtyseq;
275            isdirty = TRUE;
276         }
277
278   return isdirty;
279}
280
281
255282/***************************************************************************
256283    SYSTEM-WIDE MANAGEMENT
257284***************************************************************************/
r4135r4136
318345
319346   /* set up the default pen mask */
320347   tmap->tileinfo.pen_mask = 0xff;
348   tmap->tileinfo.gfxnum = 0xff;
321349
322350   /* initialize global states */
323351   tmap->enable = TRUE;
r4135r4136
391419
392420
393421/*-------------------------------------------------
394    tilemap_set_pen_data_offset - specify an offset
395    to be added to pen_data while rendering tiles
396-------------------------------------------------*/
397
398void tilemap_set_pen_data_offset(tilemap *tmap, UINT32 offset)
399{
400   if (tmap->pen_data_offset != offset)
401   {
402      tmap->pen_data_offset = offset;
403      tilemap_mark_all_tiles_dirty(tmap);
404   }
405}
406
407
408/*-------------------------------------------------
409422    tilemap_set_enable - set an enable flag for
410423    the tilemap; if 0, requests to draw the
411424    tilemap are ignored
r4135r4136
776789   original_cliprect = blit.cliprect;
777790
778791   /* if the whole map is dirty, mark it as such */
779   if (tmap->all_tiles_dirty)
792   if (tmap->all_tiles_dirty || gfx_elements_changed(tmap))
780793   {
781794      memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index);
782795      tmap->all_tiles_dirty = FALSE;
796      tmap->gfx_used = 0;
783797   }
784798
785799   width  = video_screen_get_width(tmap->machine->primary_screen);
r4135r4136
975989   scrolly = tmap->height - scrolly % tmap->height;
976990
977991   /* if the whole map is dirty, mark it as such */
978   if (tmap->all_tiles_dirty)
992   if (tmap->all_tiles_dirty || gfx_elements_changed(tmap))
979993   {
980994      memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index);
981995      tmap->all_tiles_dirty = FALSE;
996      tmap->gfx_used = 0;
982997   }
983998
984999   /* iterate to handle wraparound */
r4135r4136
12061221   int mincol, maxcol, minrow, maxrow;
12071222   int row, col;
12081223
1224   /* if the graphics changed, we need to mark everything dirty */
1225    if (gfx_elements_changed(tmap))
1226      tilemap_mark_all_tiles_dirty(tmap);
1227
12091228   /* if everything is clean, do nothing */
12101229   if (tmap->all_tiles_clean)
12111230      return;
r4135r4136
12321251   {
12331252      memset(tmap->tileflags, TILE_FLAG_DIRTY, tmap->max_logical_index);
12341253      tmap->all_tiles_dirty = FALSE;
1254      tmap->gfx_used = 0;
12351255   }
12361256
12371257   /* iterate over rows */
r4135r4136
12811301   if ((flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2)) == 0 && tmap->tileinfo.mask_data != NULL)
12821302      tmap->tileflags[logindex] = tile_apply_bitmask(tmap, tmap->tileinfo.mask_data, x0, y0, tmap->tileinfo.category, flags);
12831303
1304   /* track which gfx have been used for this tilemap */
1305   if (tmap->tileinfo.gfxnum != 0xff && (tmap->gfx_used & (1 << tmap->tileinfo.gfxnum)) == 0)
1306   {
1307      tmap->gfx_used |= 1 << tmap->tileinfo.gfxnum;
1308      tmap->gfx_dirtyseq[tmap->tileinfo.gfxnum] = tmap->machine->gfx[tmap->tileinfo.gfxnum]->dirtyseq;
1309   }
1310
12841311profiler_mark(PROFILER_END);
12851312}
12861313
r4135r4136
14701497      blit->cliprect.max_y = dest->height - 1;
14711498   }
14721499
1473   /* set the priority code */
1500   /* set the priority code and alpha */
14741501   blit->tilemap_priority_code = priority | (priority_mask << 8) | (tmap->palette_offset << 16);
1502   blit->alpha = (flags & TILEMAP_DRAW_ALPHA_FLAG) ? (flags >> 24) : 0xff;
14751503
14761504   /* if no destination, just render priority */
14771505   if (dest == NULL)
r4135r4136
14861514      switch (dest->format)
14871515      {
14881516         case BITMAP_FORMAT_RGB32:
1489            blit->draw_masked = (flags & TILEMAP_DRAW_ALPHA) ? scanline_draw_masked_rgb32_alpha : scanline_draw_masked_rgb32;
1490            blit->draw_opaque = (flags & TILEMAP_DRAW_ALPHA) ? scanline_draw_opaque_rgb32_alpha : scanline_draw_opaque_rgb32;
1517            blit->draw_masked = (blit->alpha < 0xff) ? scanline_draw_masked_rgb32_alpha : scanline_draw_masked_rgb32;
1518            blit->draw_opaque = (blit->alpha < 0xff) ? scanline_draw_opaque_rgb32_alpha : scanline_draw_opaque_rgb32;
14911519            break;
14921520
14931521         case BITMAP_FORMAT_RGB15:
1494            blit->draw_masked = (flags & TILEMAP_DRAW_ALPHA) ? scanline_draw_masked_rgb16_alpha : scanline_draw_masked_rgb16;
1495            blit->draw_opaque = (flags & TILEMAP_DRAW_ALPHA) ? scanline_draw_opaque_rgb16_alpha : scanline_draw_opaque_rgb16;
1522            blit->draw_masked = (blit->alpha < 0xff) ? scanline_draw_masked_rgb16_alpha : scanline_draw_masked_rgb16;
1523            blit->draw_opaque = (blit->alpha < 0xff) ? scanline_draw_opaque_rgb16_alpha : scanline_draw_opaque_rgb16;
14961524            break;
14971525
14981526         case BITMAP_FORMAT_INDEXED16:
r4135r4136
16501678            {
16511679               for (cury = y; cury < nexty; cury++)
16521680               {
1653                  (*blit->draw_opaque)(dest0, source0, x_end - x_start, tmap->machine->pens, pmap0, blit->tilemap_priority_code);
1681                  (*blit->draw_opaque)(dest0, source0, x_end - x_start, tmap->machine->pens, pmap0, blit->tilemap_priority_code, blit->alpha);
16541682
16551683                  dest0 = (UINT8 *)dest0 + dest_line_pitch_bytes;
16561684                  source0 += tmap->pixmap->rowpixels;
r4135r4136
16641692               const UINT8 *mask0 = mask_baseaddr + x_start;
16651693               for (cury = y; cury < nexty; cury++)
16661694               {
1667                  (*blit->draw_masked)(dest0, source0, mask0, blit->mask, blit->value, x_end - x_start, tmap->machine->pens, pmap0, blit->tilemap_priority_code);
1695                  (*blit->draw_masked)(dest0, source0, mask0, blit->mask, blit->value, x_end - x_start, tmap->machine->pens, pmap0, blit->tilemap_priority_code, blit->alpha);
16681696
16691697                  dest0 = (UINT8 *)dest0 + dest_line_pitch_bytes;
16701698                  source0 += tmap->pixmap->rowpixels;
r4135r4136
17121740   else if (blit->draw_masked == scanline_draw_masked_rgb16)            \
17131741      *(UINT16 *)dest = clut[INPUT_VAL];                           \
17141742   else if (blit->draw_masked == scanline_draw_masked_rgb32_alpha)         \
1715      *(UINT32 *)dest = alpha_blend32(*(UINT32 *)dest, clut[INPUT_VAL]);   \
1743      *(UINT32 *)dest = alpha_blend_r32(*(UINT32 *)dest, clut[INPUT_VAL], alpha);   \
17161744   else if (blit->draw_masked == scanline_draw_masked_rgb16_alpha)         \
1717      *(UINT16 *)dest = alpha_blend16(*(UINT16 *)dest, clut[INPUT_VAL]);   \
1745      *(UINT16 *)dest = alpha_blend_r16(*(UINT16 *)dest, clut[INPUT_VAL], alpha);   \
17181746} while (0)
17191747
17201748static void tilemap_draw_roz_core(tilemap *tmap, const blit_parameters *blit,
r4135r4136
17311759   UINT32 priority = blit->tilemap_priority_code;
17321760   UINT8 mask = blit->mask;
17331761   UINT8 value = blit->value;
1762   UINT8 alpha = blit->alpha;
17341763   UINT32 cx;
17351764   UINT32 cy;
17361765   int x;
r4135r4136
19021931    bitmap, setting priority only
19031932-------------------------------------------------*/
19041933
1905static void scanline_draw_opaque_null(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
1934static void scanline_draw_opaque_null(void *dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
19061935{
19071936   int i;
19081937
r4135r4136
19201949    bitmap using a mask, setting priority only
19211950-------------------------------------------------*/
19221951
1923static void scanline_draw_masked_null(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
1952static void scanline_draw_masked_null(void *dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
19241953{
19251954   int i;
19261955
r4135r4136
19401969    indexed bitmap
19411970-------------------------------------------------*/
19421971
1943static void scanline_draw_opaque_ind16(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
1972static void scanline_draw_opaque_ind16(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
19441973{
19451974   UINT16 *dest = _dest;
19461975   int pal = pcode >> 16;
r4135r4136
19832012    indexed bitmap using a mask
19842013-------------------------------------------------*/
19852014
1986static void scanline_draw_masked_ind16(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
2015static void scanline_draw_masked_ind16(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
19872016{
19882017   UINT16 *dest = _dest;
19892018   int pal = pcode >> 16;
r4135r4136
20162045    RGB bitmap
20172046-------------------------------------------------*/
20182047
2019static void scanline_draw_opaque_rgb16(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
2048static void scanline_draw_opaque_rgb16(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
20202049{
20212050   const pen_t *clut = &pens[pcode >> 16];
20222051   UINT16 *dest = _dest;
r4135r4136
20462075    RGB bitmap using a mask
20472076-------------------------------------------------*/
20482077
2049static void scanline_draw_masked_rgb16(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
2078static void scanline_draw_masked_rgb16(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
20502079{
20512080   const pen_t *clut = &pens[pcode >> 16];
20522081   UINT16 *dest = _dest;
r4135r4136
20782107    16bpp RGB bitmap with alpha blending
20792108-------------------------------------------------*/
20802109
2081static void scanline_draw_opaque_rgb16_alpha(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
2110static void scanline_draw_opaque_rgb16_alpha(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
20822111{
20832112   const pen_t *clut = &pens[pcode >> 16];
20842113   UINT16 *dest = _dest;
r4135r4136
20892118   {
20902119      for (i = 0; i < count; i++)
20912120      {
2092         dest[i] = alpha_blend16(dest[i], clut[source[i]]);
2121         dest[i] = alpha_blend_r16(dest[i], clut[source[i]], alpha);
20932122         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
20942123      }
20952124   }
r4135r4136
20982127   else
20992128   {
21002129      for (i = 0; i < count; i++)
2101         dest[i] = alpha_blend16(dest[i], clut[source[i]]);
2130         dest[i] = alpha_blend_r16(dest[i], clut[source[i]], alpha);
21022131   }
21032132}
21042133
r4135r4136
21092138    blending
21102139-------------------------------------------------*/
21112140
2112static void scanline_draw_masked_rgb16_alpha(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
2141static void scanline_draw_masked_rgb16_alpha(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
21132142{
21142143   const pen_t *clut = &pens[pcode >> 16];
21152144   UINT16 *dest = _dest;
r4135r4136
21212150      for (i = 0; i < count; i++)
21222151         if ((maskptr[i] & mask) == value)
21232152         {
2124            dest[i] = alpha_blend16(dest[i], clut[source[i]]);
2153            dest[i] = alpha_blend_r16(dest[i], clut[source[i]], alpha);
21252154            pri[i] = (pri[i] & (pcode >> 8)) | pcode;
21262155         }
21272156   }
r4135r4136
21312160   {
21322161      for (i = 0; i < count; i++)
21332162         if ((maskptr[i] & mask) == value)
2134            dest[i] = alpha_blend16(dest[i], clut[source[i]]);
2163            dest[i] = alpha_blend_r16(dest[i], clut[source[i]], alpha);
21352164   }
21362165}
21372166
r4135r4136
21412170    RGB bitmap
21422171-------------------------------------------------*/
21432172
2144static void scanline_draw_opaque_rgb32(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
2173static void scanline_draw_opaque_rgb32(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
21452174{
21462175   const pen_t *clut = &pens[pcode >> 16];
21472176   UINT32 *dest = _dest;
r4135r4136
21712200    RGB bitmap using a mask
21722201-------------------------------------------------*/
21732202
2174static void scanline_draw_masked_rgb32(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
2203static void scanline_draw_masked_rgb32(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
21752204{
21762205   const pen_t *clut = &pens[pcode >> 16];
21772206   UINT32 *dest = _dest;
r4135r4136
22032232    32bpp RGB bitmap with alpha blending
22042233-------------------------------------------------*/
22052234
2206static void scanline_draw_opaque_rgb32_alpha(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
2235static void scanline_draw_opaque_rgb32_alpha(void *_dest, const UINT16 *source, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
22072236{
22082237   const pen_t *clut = &pens[pcode >> 16];
22092238   UINT32 *dest = _dest;
r4135r4136
22142243   {
22152244      for (i = 0; i < count; i++)
22162245      {
2217         dest[i] = alpha_blend32(dest[i], clut[source[i]]);
2246         dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
22182247         pri[i] = (pri[i] & (pcode >> 8)) | pcode;
22192248      }
22202249   }
r4135r4136
22232252   else
22242253   {
22252254      for (i = 0; i < count; i++)
2226         dest[i] = alpha_blend32(dest[i], clut[source[i]]);
2255         dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
22272256   }
22282257}
22292258
r4135r4136
22342263    blending
22352264-------------------------------------------------*/
22362265
2237static void scanline_draw_masked_rgb32_alpha(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode)
2266static void scanline_draw_masked_rgb32_alpha(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, const pen_t *pens, UINT8 *pri, UINT32 pcode, UINT8 alpha)
22382267{
22392268   const pen_t *clut = &pens[pcode >> 16];
22402269   UINT32 *dest = _dest;
r4135r4136
22462275      for (i = 0; i < count; i++)
22472276         if ((maskptr[i] & mask) == value)
22482277         {
2249            dest[i] = alpha_blend32(dest[i], clut[source[i]]);
2278            dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
22502279            pri[i] = (pri[i] & (pcode >> 8)) | pcode;
22512280         }
22522281   }
r4135r4136
22562285   {
22572286      for (i = 0; i < count; i++)
22582287         if ((maskptr[i] & mask) == value)
2259            dest[i] = alpha_blend32(dest[i], clut[source[i]]);
2288            dest[i] = alpha_blend_r32(dest[i], clut[source[i]], alpha);
22602289   }
22612290}
src/emu/deprecat.h
r4135r4136
5454int cpu_getiloops(const device_config *device);
5555
5656
57
58/*************************************
59 *
60 *  Graphics decoding. Drivers should
61 *  use the new gfx_element_mark_dirty()
62 *  to explicitly mark tiles dirty, and
63 *  gfx_element_get_data() to fetch a
64 *  pointer to the data (and undirty
65 *  the tile)
66 *
67 *************************************/
68
69/* decode a series of tiles from a particular gfx_element */
70void decodegfx(gfx_element *gfx, UINT32 first, UINT32 count);
71
72void decodechar(const gfx_element *gfx, UINT32 code, const UINT8 *src);
73
74
75
5776#endif   /* __DEPRECAT_H__ */
src/emu/tilemap.h
r4135r4136
131131            * setting a global palette offset via
132132                tilemap_set_palette_offset()
133133
134            * setting a global pen data offset via
135                tilemap_set_pen_data_offset()
136
137134    3. In your memory write handlers for the tile memory, anytime tile
138135        data is modified, you need to mark the tile dirty so that it is
139136        re-rendered with the new data the next time the tilemap is drawn.
r4135r4136
282279        TILEMAP_DRAW_LAYER0 is assumed.
283280
284281    * If you want to render with alpha blending, you can call
285        tilemap_draw() with the TILEMAP_DRAW_ALPHA flag. To configure the
286        amount of alpha blending, call alpha_set_level() ahead of time.
282        tilemap_draw() with the TILEMAP_DRAW_ALPHA flag.
287283
288284    * To configure more complex pen-to-layer mapping, use the
289285        tilemap_map_pens_to_layer() call. This call takes a group number
r4135r4136
302298#define __TILEMAP_H__
303299
304300#include "mamecore.h"
301#include "drawgfx.h"
305302
306303
307304/***************************************************************************
r4135r4136
323320#define TILEMAP_DRAW_LAYER1            0x20      /* draw layer 1 */
324321#define TILEMAP_DRAW_LAYER2            0x40      /* draw layer 2 */
325322#define TILEMAP_DRAW_OPAQUE            0x80      /* draw everything, even transparent stuff */
326#define TILEMAP_DRAW_ALPHA            0x100      /* draw with alpha blending */
323#define TILEMAP_DRAW_ALPHA_FLAG         0x100      /* draw with alpha blending (in the upper 8 bits) */
324#define TILEMAP_DRAW_ALPHA(x)         (TILEMAP_DRAW_ALPHA_FLAG | (rgb_clamp(x) << 24))
327325#define TILEMAP_DRAW_ALL_CATEGORIES      0x200      /* draw all categories */
328326
329327
r4135r4136
390388typedef struct _tile_data tile_data;
391389struct _tile_data
392390{
393   const UINT8*   pen_data;      /* required */
394   const UINT8*   mask_data;      /* required */
391   const UINT8 *   pen_data;      /* required */
392   const UINT8 *   mask_data;      /* required */
395393   pen_t         palette_base;   /* defaults to 0 */
396394   UINT8         category;      /* defaults to 0; range from 0..15 */
397395   UINT8         group;         /* defaults to 0; range from 0..TILEMAP_NUM_GROUPS */
398396   UINT8         flags;         /* defaults to 0; one or more of TILE_* flags above */
399397   UINT8         pen_mask;      /* defaults to 0xff; mask to apply to pen_data while rendering the tile */
398   UINT8         gfxnum;         /* defaults to 0xff; specify index of machine->gfx for auto-invalidation on dirty */
400399};
401400
402401
r4135r4136
442441 */
443442void tilemap_set_palette_offset(tilemap *tmap, UINT32 offset);
444443
445/* specify an offset to be added to pen_data while rendering tiles.
446 * This will automatically mark all tiles dirty if the offset changes.
447 */
448void tilemap_set_pen_data_offset(tilemap *tmap, UINT32 offset);
449
450444/* set an enable flag for the tilemap; if 0, requests to draw the tilemap are ignored */
451445void tilemap_set_enable(tilemap *tmap, int enable);
452446
r4135r4136
570564
571565INLINE void tileinfo_set(running_machine *machine, tile_data *tileinfo, int gfxnum, int rawcode, int rawcolor, int flags)
572566{
573   const gfx_element *   gfx = machine->gfx[gfxnum];
567   const gfx_element *gfx = machine->gfx[gfxnum];
574568   int code = rawcode % gfx->total_elements;
575   tileinfo->pen_data = gfx->gfxdata + code * gfx->char_modulo;
569   tileinfo->pen_data = gfx_element_get_data(gfx, code);
576570   tileinfo->palette_base = gfx->color_base + gfx->color_granularity * rawcolor;
577571   tileinfo->flags = flags;
578572   if (gfx->flags & GFX_ELEMENT_PACKED)
579573      tileinfo->flags |= TILE_4BPP;
574   tileinfo->gfxnum = gfxnum;
580575}
581576
582577
src/emu/video.c
r4135r4136
1616#include "rendutil.h"
1717#include "ui.h"
1818#include "aviio.h"
19#include "deprecat.h"
1920
2021#include "snap.lh"
2122
r4135r4136
340341      (*machine->config->init_palette)(machine, memory_region(machine, "proms"));
341342
342343   /* actually decode the graphics */
343   if (machine->config->gfxdecodeinfo != NULL)
344   if (PREDECODE_GFX && machine->config->gfxdecodeinfo != NULL)
344345      decode_graphics(machine, machine->config->gfxdecodeinfo);
345346
346   /* reset video statics and get out of here */
347   pdrawgfx_shadow_lowpri = 0;
348
349347   /* create a render target for snapshots */
350348   viewname = options_get_string(mame_options(), OPTION_SNAPVIEW);
351349   global.snap_native = (machine->primary_screen != NULL && (viewname[0] == 0 || strcmp(viewname, "native") == 0));
r4135r4136
407405
408406   /* free all the graphics elements */
409407   for (i = 0; i < MAX_GFX_ELEMENTS; i++)
410      freegfx(machine->gfx[i]);
408      gfx_element_free(machine->gfx[i]);
411409
412410   /* free the snapshot target */
413411   if (global.snap_target != NULL)
r4135r4136
471469
472470static void allocate_graphics(running_machine *machine, const gfx_decode_entry *gfxdecodeinfo)
473471{
474   int i;
472   int curgfx;
475473
476474   /* loop over all elements */
477   for (i = 0; i < MAX_GFX_ELEMENTS && gfxdecodeinfo[i].gfxlayout != NULL; i++)
475   for (curgfx = 0; curgfx < MAX_GFX_ELEMENTS && gfxdecodeinfo[curgfx].gfxlayout != NULL; curgfx++)
478476   {
479      int region_length = 8 * memory_region_length(machine, gfxdecodeinfo[i].memory_region);
480      int xscale = (gfxdecodeinfo[i].xscale == 0) ? 1 : gfxdecodeinfo[i].xscale;
481      int yscale = (gfxdecodeinfo[i].yscale == 0) ? 1 : gfxdecodeinfo[i].yscale;
477      const gfx_decode_entry *gfxdecode = &gfxdecodeinfo[curgfx];
478      UINT32 region_length = 8 * memory_region_length(machine, gfxdecode->memory_region);
479      const UINT8 *region_base = memory_region(machine, gfxdecode->memory_region);
480      UINT32 xscale = (gfxdecode->xscale == 0) ? 1 : gfxdecode->xscale;
481      UINT32 yscale = (gfxdecode->yscale == 0) ? 1 : gfxdecode->yscale;
482482      UINT32 *extpoffs, extxoffs[MAX_ABS_GFX_SIZE], extyoffs[MAX_ABS_GFX_SIZE];
483      gfx_layout glcopy;
484      const gfx_layout *gl = gfxdecodeinfo[i].gfxlayout;
483      const gfx_layout *gl = gfxdecode->gfxlayout;
485484      int israw = (gl->planeoffset[0] == GFX_RAW);
486485      int planes = gl->planes;
487      UINT16 width = gl->width;
488      UINT16 height = gl->height;
486      UINT32 width = gl->width;
487      UINT32 height = gl->height;
489488      UINT32 total = gl->total;
490489      UINT32 charincrement = gl->charincrement;
490      gfx_layout glcopy;
491491      int j;
492492
493493      /* make a copy of the layout */
494      glcopy = *gfxdecodeinfo[i].gfxlayout;
494      glcopy = *gfxdecode->gfxlayout;
495495
496496      /* copy the X and Y offsets into temporary arrays */
497497      memcpy(extxoffs, glcopy.xoffset, sizeof(glcopy.xoffset));
r4135r4136
526526      /* if the character count is a region fraction, compute the effective total */
527527      if (IS_FRAC(total))
528528      {
529         if (region_length == 0)
530            continue;
529         assert(region_length != 0);
531530         total = region_length / charincrement * FRAC_NUM(total) / FRAC_DEN(total);
532531      }
533532
r4135r4136
539538         {
540539            UINT32 value = extpoffs[j];
541540            if (IS_FRAC(value))
541            {
542               assert(region_length != 0);
542543               extpoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
544            }
543545         }
544546
545547         /* loop over all the X/Y offsets, converting fractions */
r4135r4136
547549         {
548550            UINT32 value = extxoffs[j];
549551            if (IS_FRAC(value))
552            {
553               assert(region_length != 0);
550554               extxoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
555            }
551556         }
552557
553558         for (j = 0; j < height; j++)
554559         {
555560            UINT32 value = extyoffs[j];
556561            if (IS_FRAC(value))
562            {
563               assert(region_length != 0);
557564               extyoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
565            }
558566         }
559567      }
560568
561569      /* otherwise, just use the line modulo */
562570      else
563571      {
564         int base = gfxdecodeinfo[i].start;
572         int base = gfxdecode->start;
565573         int end = region_length/8;
566574         int linemod = gl->yoffset[0];
567575         while (total > 0)
r4135r4136
580588      glcopy.total = total;
581589
582590      /* allocate the graphics */
583      machine->gfx[i] = allocgfx(machine, &glcopy);
584
585      /* if we have a remapped colortable, point our local colortable to it */
586      machine->gfx[i]->total_colors = gfxdecodeinfo[i].total_color_codes;
587      machine->gfx[i]->color_base = machine->config->gfxdecodeinfo[i].color_codes_start;
591      machine->gfx[curgfx] = gfx_element_alloc(machine, &glcopy, (region_base != NULL) ? region_base + gfxdecode->start : NULL, gfxdecode->total_color_codes, gfxdecode->color_codes_start);
588592   }
589593}
590594
r4135r4136
610614         /* if we have a valid region, decode it now */
611615         if (gfxdecodeinfo[i].memory_region != NULL)
612616         {
613            UINT8 *region_base = memory_region(machine, gfxdecodeinfo[i].memory_region);
614617            gfx_element *gfx = machine->gfx[i];
615618            int j;
616619
r4135r4136
619622            {
620623               char buffer[200];
621624               int num_to_decode = (j + 1024 < gfx->total_elements) ? 1024 : (gfx->total_elements - j);
622               decodegfx(gfx, region_base + gfxdecodeinfo[i].start, j, num_to_decode);
625               decodegfx(gfx, j, num_to_decode);
623626               curgfx += num_to_decode;
624627
625628               /* display some startup text */
r4135r4136
12751278{
12761279   const device_config *screen = param;
12771280   realloc_screen_bitmaps(screen);
1281   global.movie_next_frame_time = timer_get_time(machine);
12781282}
12791283
12801284
r4135r4136
27272731
27282732
27292733/***************************************************************************
2734    DEBUGGING HELPERS
2735***************************************************************************/
2736
2737/*-------------------------------------------------
2738    video_assert_out_of_range_pixels - assert if
2739    any pixels in the given bitmap contain an
2740    invalid palette index
2741-------------------------------------------------*/
2742
2743void video_assert_out_of_range_pixels(running_machine *machine, bitmap_t *bitmap)
2744{
2745#ifdef MAME_DEBUG
2746   int maxindex = palette_get_max_index(machine->palette);
2747   int x, y;
2748
2749   /* this only applies to indexed16 bitmaps */
2750   if (bitmap->format != BITMAP_FORMAT_INDEXED16)
2751      return;
2752
2753   /* iterate over rows */
2754   for (y = 0; y < bitmap->height; y++)
2755   {
2756      UINT16 *rowbase = BITMAP_ADDR16(bitmap, y, 0);
2757      for (x = 0; x < bitmap->width; x++)
2758         assert(rowbase[x] < maxindex);
2759   }
2760#endif
2761}
2762
2763
2764
2765/***************************************************************************
27302766    SOFTWARE RENDERING
27312767***************************************************************************/
27322768
src/emu/memory.c
r4135r4136
226226   void *               entryd[MAX_BANK_ENTRIES];/* array of decrypted entries for this bank */
227227};
228228
229/* In memory.h: typedef struct _direct_range direct_range; */
230struct _direct_range
231{
232    direct_range *         next;               /* pointer to the next range in the list */
233    offs_t                bytestart;            /* starting byte offset of the range */
234    offs_t               byteend;            /* ending byte offset of the range */
235};
236
229237/* In memory.h: typedef struct _handler_data handler_data */
230238struct _handler_data
231239{
r4135r4136
331339static UINT8 table_assign_handler(const address_space *space, handler_data **table, void *object, genf *handler, const char *handler_name, offs_t bytestart, offs_t byteend, offs_t bytemask);
332340static void table_compute_subhandler(handler_data **table, UINT8 entry, read_or_write readorwrite, int spacebits, int spaceendian, int handlerbits, int handlerunitmask);
333341static void table_populate_range(address_table *tabledata, offs_t bytestart, offs_t byteend, UINT8 handler);
334static void table_populate_range_mirrored(address_table *tabledata, offs_t bytestart, offs_t byteend, offs_t bytemirror, UINT8 handler);
342static void table_populate_range_mirrored(address_space *space, address_table *tabledata, offs_t bytestart, offs_t byteend, offs_t bytemirror, UINT8 handler);
343UINT8 table_derive_range(const address_table *table, offs_t byteaddress, offs_t *bytestart, offs_t *byteend);
335344
336345/* subtable management */
337346static UINT8 subtable_alloc(address_table *tabledata);
r4135r4136
341350static UINT8 *subtable_open(address_table *tabledata, offs_t l1index);
342351static void subtable_close(address_table *tabledata, offs_t l1index);
343352
353/* direct memory ranges */
354static direct_range *direct_range_find(address_space *space, offs_t byteaddress, UINT8 *entry);
355static void direct_range_remove_intersecting(address_space *space, offs_t bytestart, offs_t byteend);
356
344357/* memory block allocation */
345358static void *block_allocate(const address_space *space, offs_t bytestart, offs_t byteend, void *memory);
346359static address_map_entry *block_assign_intersecting(address_space *space, offs_t bytestart, offs_t byteend, UINT8 *base);
r4135r4136
368381INLINE void force_opbase_update(const address_space *space)
369382{
370383   address_space *spacerw = (address_space *)space;
371   spacerw->direct.max = 0;
372   spacerw->direct.min = 1;
384   spacerw->direct.byteend = 0;
385   spacerw->direct.bytestart = 1;
373386}
374387
375388
r4135r4136
875888   address_space *spacerw = (address_space *)space;
876889   UINT8 *base = NULL, *based = NULL;
877890   const handler_data *handlers;
891   direct_range *range;
892   offs_t maskedbits;
878893   UINT8 entry;
879894
880895   /* allow overrides */
r4135r4136
885900         return TRUE;
886901   }
887902
888   /* perform the lookup */
889   byteaddress &= spacerw->bytemask;
890   entry = spacerw->readlookup[LEVEL1_INDEX(byteaddress)];
891   if (entry >= SUBTABLE_BASE)
892      entry = spacerw->readlookup[LEVEL2_INDEX(entry,byteaddress)];
903   /* remove the masked bits (we'll put them back later) */
904   maskedbits = byteaddress & ~spacerw->bytemask;
893905
906   /* find or allocate a matching range */
907   range = direct_range_find(spacerw, byteaddress, &entry);
908
894909   /* keep track of current entry */
895910   spacerw->direct.entry = entry;
896911
897   /* if we don't map to a bank, see if there are any banks we can map to */
912   /* if we don't map to a bank, return FALSE */
898913   if (entry < STATIC_BANK1 || entry >= STATIC_RAM)
899914   {
900      /* loop over banks and find a match */
901      for (entry = 1; entry < STATIC_COUNT; entry++)
902      {
903         bank_info *bank = &memdata->bankdata[entry];
904         if (bank->used && bank_references_space(bank, space) && bank->bytestart < byteaddress && bank->byteend > byteaddress)
905            break;
906      }
907
908      /* if nothing was found, leave everything alone */
909      if (entry == STATIC_COUNT)
910      {
911         logerror("CPU '%s': warning - attempt to direct-map address %08X in %s space\n", space->cpu->tag, byteaddress, space->name);
912         return FALSE;
913      }
915      /* ensure future updates to land here as well until we get back into a bank */
916      spacerw->direct.byteend = 0;
917      spacerw->direct.bytestart = 1;
918      logerror("CPU '%s': warning - attempt to direct-map address %08X in %s space\n", space->cpu->tag, byteaddress, space->name);
919      return FALSE;
914920   }
915921
916922   /* if no decrypted opcodes, point to the same base */
r4135r4136
921927
922928   /* compute the adjusted base */
923929   handlers = spacerw->read.handlers[entry];
924   spacerw->direct.mask = handlers->bytemask;
925   spacerw->direct.raw = base - (handlers->bytestart & spacerw->direct.mask);
926   spacerw->direct.decrypted = based - (handlers->bytestart & spacerw->direct.mask);
927   spacerw->direct.min = handlers->bytestart;
928   spacerw->direct.max = handlers->byteend;
930   spacerw->direct.bytemask = handlers->bytemask;
931   spacerw->direct.raw = base - (handlers->bytestart & spacerw->direct.bytemask);
932   spacerw->direct.decrypted = based - (handlers->bytestart & spacerw->direct.bytemask);
933   spacerw->direct.bytestart = maskedbits | range->bytestart;
934   spacerw->direct.byteend = maskedbits | range->byteend;
929935   return TRUE;
930936}
931937
r4135r4136
15461552
15471553            /* set the direct access information base */
15481554            space->direct.raw = space->direct.decrypted = NULL;
1549            space->direct.mask = space->bytemask;
1550            space->direct.min = 1;
1551            space->direct.max = 0;
1555            space->direct.bytemask = space->bytemask;
1556            space->direct.bytestart = 1;
1557            space->direct.byteend = 0;
15521558            space->direct.entry = STATIC_UNMAP;
15531559            space->directupdate = NULL;
15541560
r4135r4136
18981904   /* free all the address spaces and tables */
18991905   for (space = (address_space *)memdata->spacelist; space != NULL; space = nextspace)
19001906   {
1907      int entry;
1908
19011909      nextspace = (address_space *)space->next;
1910
1911      /* free all direct ranges */
1912      for (entry = 0; entry < ARRAY_LENGTH(space->direct.rangelist); entry++)
1913         while (space->direct.rangelist[entry] != NULL)
1914         {
1915            direct_range *range = space->direct.rangelist[entry];
1916            space->direct.rangelist[entry] = range->next;
1917            free(range);
1918         }
1919
1920      /* free the free list of direct ranges */
1921      while (space->direct.freerangelist != NULL)
1922      {
1923         direct_range *range = space->direct.freerangelist;
1924         space->direct.freerangelist = range->next;
1925         free(range);
1926      }
1927
1928      /* free the address map and tables */
19021929      if (space->map != NULL)
19031930         address_map_free(space->map);
19041931      if (space->read.table != NULL)
19051932         free(space->read.table);
19061933      if (space->write.table != NULL)
19071934         free(space->write.table);
1935
19081936      free(space);
19091937   }
19101938}
r4135r4136
21932221      table_compute_subhandler(tabledata->handlers, entry, readorwrite, space->dbits, space->endianness, handlerbits, handlerunitmask);
21942222
21952223   /* populate it */
2196   table_populate_range_mirrored(tabledata, bytestart, byteend, bytemirror, entry);
2224   table_populate_range_mirrored(space, tabledata, bytestart, byteend, bytemirror, entry);
21972225
21982226   /* reset read/write pointers if necessary (could have moved due to realloc) */
21992227   if (reset_write)
r4135r4136
22052233   if (readorwrite == ROW_READ && entry == space->direct.entry)
22062234   {
22072235      space->direct.entry = STATIC_UNMAP;
2208      space->direct.min = 1;
2209      space->direct.max = 0;
2236      space->direct.bytestart = 1;
2237      space->direct.byteend = 0;
22102238   }
22112239}
22122240
r4135r4136
25512579    including mirrors
25522580-------------------------------------------------*/
25532581
2554static void table_populate_range_mirrored(address_table *tabledata, offs_t bytestart, offs_t byteend, offs_t bytemirror, UINT8 handler)
2582static void table_populate_range_mirrored(address_space *space, address_table *tabledata, offs_t bytestart, offs_t byteend, offs_t bytemirror, UINT8 handler)
25552583{
25562584   offs_t lmirrorbit[LEVEL2_BITS], lmirrorbits, hmirrorbit[32 - LEVEL2_BITS], hmirrorbits, lmirrorcount, hmirrorcount;
25572585   UINT8 prev_entry = STATIC_INVALID;
r4135r4136
25762604         if (hmirrorcount & (1 << i))
25772605            hmirrorbase |= hmirrorbit[i];
25782606
2607      /* invalidate any intersecting cached ranges */
2608      for (lmirrorcount = 0; lmirrorcount < (1 << lmirrorbits); lmirrorcount++)
2609      {
2610         /* compute the base of this mirror */
2611         offs_t lmirrorbase = hmirrorbase;
2612         for (i = 0; i < lmirrorbits; i++)
2613            if (lmirrorcount & (1 << i))
2614               lmirrorbase |= lmirrorbit[i];
2615         direct_range_remove_intersecting(space, bytestart + lmirrorbase, byteend + lmirrorbase);
2616      }
2617
25792618      /* if this is not our first time through, and the level 2 entry matches the previous
25802619           level 2 entry, just do a quick map and get out; note that this only works for entries
25812620           which don't span multiple level 1 table entries */
r4135r4136
26182657}
26192658
26202659
2660/*-------------------------------------------------
2661    table_derive_range - look up the entry for
2662    a memory range, and then compute the extent
2663    of that range based on the lookup tables
2664-------------------------------------------------*/
26212665
2666UINT8 table_derive_range(const address_table *table, offs_t byteaddress, offs_t *bytestart, offs_t *byteend)
2667{
2668   UINT32 curentry, entry, curl1entry, l1entry;
2669   const handler_data *handler;
2670   offs_t minscan, maxscan;
2671
2672   /* look up the initial address to get the entry we care about */
2673   entry = l1entry = table->table[LEVEL1_INDEX(byteaddress)];
2674   if (l1entry >= SUBTABLE_BASE)
2675      entry = table->table[LEVEL2_INDEX(l1entry, byteaddress)];
2676   handler = table->handlers[entry];
2677
2678   /* use the bytemask of the entry to set minimum and maximum bounds */
2679   minscan = handler->bytestart | ((byteaddress - handler->bytestart) & ~handler->bytemask);
2680   maxscan = handler->byteend | ((byteaddress - handler->bytestart) & ~handler->bytemask);
2681
2682   /* first scan backwards to find the start address */
2683   curl1entry = l1entry;
2684   curentry = entry;
2685   *bytestart = byteaddress;
2686   while (1)
2687   {
2688      /* if we need to scan the subtable, do it */
2689      if (curentry != curl1entry)
2690      {
2691         UINT32 minindex = LEVEL2_INDEX(curl1entry, 0);
2692         UINT32 index;
2693
2694         /* scan backwards from the current address, until the previous entry doesn't match */
2695         for (index = LEVEL2_INDEX(curl1entry, *bytestart); index > minindex; index--, *bytestart -= 1)
2696            if (table->table[index - 1] != entry)
2697               break;
2698
2699         /* if we didn't hit the beginning, then we're finished scanning */
2700         if (index != minindex)
2701            break;
2702      }
2703
2704      /* move to the beginning of this L1 entry; stop at the minimum address */
2705      *bytestart &= ~((1 << LEVEL2_BITS) - 1);
2706      if (*bytestart <= minscan)
2707         break;
2708
2709      /* look up the entry of the byte at the end of the previous L1 entry; if it doesn't match, stop */
2710      curentry = curl1entry = table->table[LEVEL1_INDEX(*bytestart - 1)];
2711      if (curl1entry >= SUBTABLE_BASE)
2712         curentry = table->table[LEVEL2_INDEX(curl1entry, *bytestart - 1)];
2713      if (curentry != entry)
2714         break;
2715
2716      /* move into the previous entry and resume searching */
2717      *bytestart -= 1;
2718   }
2719
2720   /* then scan forwards to find the end address */
2721   curl1entry = l1entry;
2722   curentry = entry;
2723   *byteend = byteaddress;
2724   while (1)
2725   {
2726      /* if we need to scan the subtable, do it */
2727      if (curentry != curl1entry)
2728      {
2729         UINT32 maxindex = LEVEL2_INDEX(curl1entry, ~0);
2730         UINT32 index;
2731
2732         /* scan forwards from the current address, until the next entry doesn't match */
2733         for (index = LEVEL2_INDEX(curl1entry, *byteend); index < maxindex; index++, *byteend += 1)
2734            if (table->table[index + 1] != entry)
2735               break;
2736
2737         /* if we didn't hit the end, then we're finished scanning */
2738         if (index != maxindex)
2739            break;
2740      }
2741
2742      /* move to the end of this L1 entry; stop at the maximum address */
2743      *byteend |= (1 << LEVEL2_BITS) - 1;
2744      if (*byteend >= maxscan)
2745         break;
2746
2747      /* look up the entry of the byte at the start of the next L1 entry; if it doesn't match, stop */
2748      curentry = curl1entry = table->table[LEVEL1_INDEX(*byteend + 1)];
2749      if (curl1entry >= SUBTABLE_BASE)
2750         curentry = table->table[LEVEL2_INDEX(curl1entry, *byteend + 1)];
2751      if (curentry != entry)
2752         break;
2753
2754      /* move into the next entry and resume searching */
2755      *byteend += 1;
2756   }
2757
2758   return entry;
2759}
2760
2761
2762
26222763/***************************************************************************
26232764    SUBTABLE MANAGEMENT
26242765***************************************************************************/
r4135r4136
28162957
28172958
28182959/***************************************************************************
2960    DIRECT MEMORY RANGES
2961***************************************************************************/
2962
2963/*-------------------------------------------------
2964    direct_range_find - find a byte address in
2965    a range
2966-------------------------------------------------*/
2967
2968static direct_range *direct_range_find(address_space *space, offs_t byteaddress, UINT8 *entry)
2969{
2970   direct_range **rangelistptr;
2971   direct_range **rangeptr;
2972   direct_range *range;
2973
2974   /* determine which entry */
2975   byteaddress &= space->bytemask;
2976   *entry = space->readlookup[LEVEL1_INDEX(byteaddress)];
2977   if (*entry >= SUBTABLE_BASE)
2978      *entry = space->readlookup[LEVEL2_INDEX(*entry, byteaddress)];
2979   rangelistptr = &space->direct.rangelist[*entry];
2980
2981   /* scan our table */
2982   for (rangeptr = rangelistptr; *rangeptr != NULL; rangeptr = &(*rangeptr)->next)
2983      if (byteaddress >= (*rangeptr)->bytestart && byteaddress <= (*rangeptr)->byteend)
2984      {
2985         /* found a match; move us to the head of the list if we're not already there */
2986         range = *rangeptr;
2987         if (range != *rangelistptr)
2988         {
2989            *rangeptr = range->next;
2990            range->next = *rangelistptr;
2991            *rangelistptr = range;
2992         }
2993         return range;
2994      }
2995
2996   /* didn't find out; allocate a new one */
2997   range = space->direct.freerangelist;
2998   if (range != NULL)
2999      space->direct.freerangelist = range->next;
3000   else
3001      range = malloc_or_die(sizeof(*range));
3002
3003   /* fill in the range */
3004   table_derive_range(&space->read, byteaddress, &range->bytestart, &range->byteend);
3005   range->next = *rangelistptr;
3006   *rangelistptr = range;
3007
3008   return range;
3009}
3010
3011
3012/*-------------------------------------------------
3013    direct_range_remove_intersecting - remove
3014    all cached ranges that intersect the given
3015    address range
3016-------------------------------------------------*/
3017
3018static void direct_range_remove_intersecting(address_space *space, offs_t bytestart, offs_t byteend)
3019{
3020    int entry;
3021
3022    /* loop over all entries */
3023    for (entry = 0; entry < ARRAY_LENGTH(space->read.handlers); entry++)
3024    {
3025        direct_range **rangeptr, **nextrangeptr;
3026
3027        /* loop over all ranges in this entry's list */
3028        for (nextrangeptr = rangeptr = &space->direct.rangelist[entry]; *rangeptr != NULL; rangeptr = nextrangeptr)
3029        {
3030           /* if we intersect, remove and add to the free range list */
3031            if (bytestart <= (*rangeptr)->byteend && byteend >= (*rangeptr)->bytestart)
3032            {
3033                direct_range *range = *rangeptr;
3034                *rangeptr = range->next;
3035                range->next = space->direct.freerangelist;
3036                space->direct.freerangelist = range;
3037            }
3038
3039            /* otherwise advance to the next in the list */
3040            else
3041                nextrangeptr = &(*rangeptr)->next;
3042        }
3043    }
3044}
3045
3046
3047
3048/***************************************************************************
28193049    MEMORY BLOCK ALLOCATION
28203050***************************************************************************/
28213051
r4135r4136
31803410
31813411static void dump_map(FILE *file, const address_space *space, const address_table *table)
31823412{
3183   int l1count = 1 << LEVEL1_BITS;
3184   int l2count = 1 << LEVEL2_BITS;
3185   UINT8 lastentry = STATIC_UNMAP;
3186   int entrymatches = 0;
3187   int i, j;
3413   offs_t byteaddress, bytestart, byteend;
31883414
31893415   /* dump generic information */
31903416   fprintf(file, "  Address bits = %d\n", space->abits);
r4135r4136
31943420   fprintf(file, "  Address mask = %X\n", space->bytemask);
31953421   fprintf(file, "\n");
31963422
3197   /* loop over level 1 entries */
3198   for (i = 0; i < l1count; i++)
3423   /* iterate over addresses */
3424   for (byteaddress = 0; byteaddress <= space->bytemask; byteaddress = byteend + 1)
31993425   {
3200      UINT8 entry = table->table[i];
3201
3202      /* if this entry matches the previous one, just count it */
3203      if (entry < SUBTABLE_BASE && entry == lastentry)
3204      {
3205         entrymatches++;
3206         continue;
3207      }
3208
3209      /* otherwise, print accumulated info */
3210      if (lastentry < SUBTABLE_BASE && lastentry != STATIC_UNMAP)
3211         fprintf(file, "%08X-%08X    = %02X: %s [offset=%08X]\n",
3212                     (i - entrymatches) << LEVEL2_BITS,
3213                     (i << LEVEL2_BITS) - 1,
3214                     lastentry,
3215                     handler_to_string(table, lastentry),
3216                     table->handlers[lastentry]->bytestart);
3217
3218      /* start counting with this entry */
3219      lastentry = entry;
3220      entrymatches = 1;
3221
3222      /* if we're a subtable, we need to drill down */
3223      if (entry >= SUBTABLE_BASE)
3224      {
3225         UINT8 lastentry2 = STATIC_UNMAP;
3226         int entry2matches = 0;
3227
3228         /* loop over level 2 entries */
3229         entry -= SUBTABLE_BASE;
3230         for (j = 0; j < l2count; j++)
3231         {
3232            UINT8 entry2 = table->table[(1 << LEVEL1_BITS) + (entry << LEVEL2_BITS) + j];
3233
3234            /* if this entry matches the previous one, just count it */
3235            if (entry2 < SUBTABLE_BASE && entry2 == lastentry2)
3236            {
3237               entry2matches++;
3238               continue;
3239            }
3240
3241            /* otherwise, print accumulated info */
3242            if (lastentry2 < SUBTABLE_BASE && lastentry2 != STATIC_UNMAP)
3243               fprintf(file, "%08X-%08X    = %02X: %s [offset=%08X]\n",
3244                           ((i << LEVEL2_BITS) | (j - entry2matches)),
3245                           ((i << LEVEL2_BITS) | (j - 1)),
3246                           lastentry2,
3247                           handler_to_string(table, lastentry2),
3248                           table->handlers[lastentry2]->bytestart);
3249
3250            /* start counting with this entry */
3251            lastentry2 = entry2;
3252            entry2matches = 1;
3253         }
3254
3255         /* flush the last entry */
3256         if (lastentry2 < SUBTABLE_BASE && lastentry2 != STATIC_UNMAP)
3257            fprintf(file, "%08X-%08X    = %02X: %s [offset=%08X]\n",
3258                        ((i << LEVEL2_BITS) | (j - entry2matches)),
3259                        ((i << LEVEL2_BITS) | (j - 1)),
3260                        lastentry2,
3261                        handler_to_string(table, lastentry2),
3262                        table->handlers[lastentry2]->bytestart);
3263      }
3426      UINT8 entry = table_derive_range(table, byteaddress, &bytestart, &byteend);
3427      fprintf(file, "%08X-%08X    = %02X: %s [offset=%08X]\n",
3428                  bytestart, byteend, entry, handler_to_string(table, entry), table->handlers[entry]->bytestart);
32643429   }
3265
3266   /* flush the last entry */
3267   if (lastentry < SUBTABLE_BASE && lastentry != STATIC_UNMAP)
3268      fprintf(file, "%08X-%08X    = %02X: %s [offset=%08X]\n",
3269                  (i - entrymatches) << LEVEL2_BITS,
3270                  (i << LEVEL2_BITS) - 1,
3271                  lastentry,
3272                  handler_to_string(table, lastentry),
3273                  table->handlers[lastentry]->bytestart);
32743430}
32753431
32763432
src/emu/video.h
r4135r4136
278278/* select a view for a given target */
279279int video_get_view_for_target(running_machine *machine, render_target *target, const char *viewname, int targetindex, int numtargets);
280280
281
282/* ----- debugging helpers ----- */
283
284/* assert if any pixels in the given bitmap contain an invalid palette index */
285void video_assert_out_of_range_pixels(running_machine *machine, bitmap_t *bitmap);
286
287
281288#endif   /* __VIDEO_H__ */
src/emu/emu.mak
r4135r4136
111111   $(EMUMACHINE)/6522via.o \
112112   $(EMUMACHINE)/6526cia.o \
113113   $(EMUMACHINE)/6821pia.o \
114   $(EMUMACHINE)/6821new.o \
114115   $(EMUMACHINE)/6840ptm.o \
115116   $(EMUMACHINE)/6850acia.o \
116117   $(EMUMACHINE)/68681.o \
src/emu/memory.h
r4135r4136
8888typedef struct _handler_data handler_data;
8989typedef struct _subtable_data subtable_data;
9090
91/* direct_range is an opaque type used to track ranges for direct access */
92typedef struct _direct_range direct_range;
9193
9294/* forward-declare the address_space structure */
9395typedef struct _address_space address_space;
r4135r4136
103105{
104106   UINT8 *               raw;            /* direct access data pointer (raw) */
105107   UINT8 *               decrypted;         /* direct access data pointer (decrypted) */
106   offs_t               mask;            /* address mask */
107   offs_t               min;            /* minimum valid address */
108   offs_t               max;            /* maximum valid address */
108   offs_t               bytemask;         /* byte address mask */
109   offs_t               bytestart;         /* minimum valid byte address */
110   offs_t               byteend;         /* maximum valid byte address */
109111   UINT8                entry;            /* live entry */
112   direct_range *         rangelist[256];      /* list of ranges for each entry */
113   direct_range *         freerangelist;      /* list of recycled range entries */
110114};
111115
112116
r4135r4136
445449#define SMH_ROM                     ((void *)STATIC_ROM)
446450#define SMH_NOP                     ((void *)STATIC_NOP)
447451#define SMH_UNMAP                  ((void *)STATIC_UNMAP)
448#define SMH_BANK(n)                  ((void *)(STATIC_BANK1 + (FPTR)(n) - 1))
452#define SMH_BANK(n)                  ((void *)(STATIC_BANK1 + (n) - 1))
449453#define SMH_BANK1                  SMH_BANK(1)
450454#define SMH_BANK2                  SMH_BANK(2)
451455#define SMH_BANK3                  SMH_BANK(3)
r4135r4136
502506
503507
504508/* opcode range safety check */
505#define address_is_unsafe(S,A)         ((UNEXPECTED((A) < (S)->direct.min) || UNEXPECTED((A) > (S)->direct.max)))
509#define memory_address_outside_direct_region(S,A)   ((UNEXPECTED((A) < (S)->direct.bytestart) || UNEXPECTED((A) > (S)->direct.byteend)))
506510
507511
508512/* wrappers for dynamic read handler installation */
r4135r4136
11081112
11091113INLINE void *memory_decrypted_read_ptr(const address_space *space, offs_t byteaddress)
11101114{
1111   if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1112      return &space->direct.decrypted[byteaddress & space->direct.mask];
1115   if (!memory_address_outside_direct_region(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1116      return &space->direct.decrypted[byteaddress & space->direct.bytemask];
11131117   return NULL;
11141118}
11151119
11161120INLINE UINT8 memory_decrypted_read_byte(const address_space *space, offs_t byteaddress)
11171121{
1118   if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1119      return space->direct.decrypted[byteaddress & space->direct.mask];
1122   if (!memory_address_outside_direct_region(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1123      return space->direct.decrypted[byteaddress & space->direct.bytemask];
11201124   return memory_read_byte(space, byteaddress);
11211125}
11221126
11231127INLINE UINT16 memory_decrypted_read_word(const address_space *space, offs_t byteaddress)
11241128{
1125   if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1126      return *(UINT16 *)&space->direct.decrypted[byteaddress & space->direct.mask];
1129   if (!memory_address_outside_direct_region(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1130      return *(UINT16 *)&space->direct.decrypted[byteaddress & space->direct.bytemask];
11271131   return memory_read_word(space, byteaddress);
11281132}
11291133
11301134INLINE UINT32 memory_decrypted_read_dword(const address_space *space, offs_t byteaddress)
11311135{
1132   if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1133      return *(UINT32 *)&space->direct.decrypted[byteaddress & space->direct.mask];
1136   if (!memory_address_outside_direct_region(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1137      return *(UINT32 *)&space->direct.decrypted[byteaddress & space->direct.bytemask];
11341138   return memory_read_dword(space, byteaddress);
11351139}
11361140
11371141INLINE UINT64 memory_decrypted_read_qword(const address_space *space, offs_t byteaddress)
11381142{
1139   if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1140      return *(UINT64 *)&space->direct.decrypted[byteaddress & space->direct.mask];
1143   if (!memory_address_outside_direct_region(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1144      return *(UINT64 *)&space->direct.decrypted[byteaddress & space->direct.bytemask];
11411145   return memory_read_qword(space, byteaddress);
11421146}
11431147
r4135r4136
11511155
11521156INLINE void *memory_raw_read_ptr(const address_space *space, offs_t byteaddress)
11531157{
1154   if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1155      return &space->direct.raw[byteaddress & space->direct.mask];
1158   if (!memory_address_outside_direct_region(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1159      return &space->direct.raw[byteaddress & space->direct.bytemask];
11561160   return NULL;
11571161}
11581162
11591163INLINE UINT8 memory_raw_read_byte(const address_space *space, offs_t byteaddress)
11601164{
1161   if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1162      return space->direct.raw[byteaddress & space->direct.mask];
1165   if (!memory_address_outside_direct_region(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1166      return space->direct.raw[byteaddress & space->direct.bytemask];
11631167   return memory_read_byte(space, byteaddress);
11641168}
11651169
11661170INLINE UINT16 memory_raw_read_word(const address_space *space, offs_t byteaddress)
11671171{
1168   if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1169      return *(UINT16 *)&space->direct.raw[byteaddress & space->direct.mask];
1172   if (!memory_address_outside_direct_region(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1173      return *(UINT16 *)&space->direct.raw[byteaddress & space->direct.bytemask];
11701174   return memory_read_word(space, byteaddress);
11711175}
11721176
11731177INLINE UINT32 memory_raw_read_dword(const address_space *space, offs_t byteaddress)
11741178{
1175   if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1176      return *(UINT32 *)&space->direct.raw[byteaddress & space->direct.mask];
1179   if (!memory_address_outside_direct_region(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1180      return *(UINT32 *)&space->direct.raw[byteaddress & space->direct.bytemask];
11771181   return memory_read_dword(space, byteaddress);
11781182}
11791183
11801184INLINE UINT64 memory_raw_read_qword(const address_space *space, offs_t byteaddress)
11811185{
1182   if (!address_is_unsafe(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1183      return *(UINT64 *)&space->direct.raw[byteaddress & space->direct.mask];
1186   if (!memory_address_outside_direct_region(space, byteaddress) || memory_set_direct_region(space, byteaddress))
1187      return *(UINT64 *)&space->direct.raw[byteaddress & space->direct.bytemask];
11841188   return memory_read_qword(space, byteaddress);
11851189}
11861190
src/emu/mame.c
r4135r4136
3232                - calls output_init() [output.c] to initialize the output system
3333                - calls state_init() [state.c] to initialize save state system
3434                - calls state_save_allow_registration() [state.c] to allow registrations
35                - calls drawgfx_init() [drawgfx.c] to initialize rendering globals
3635                - calls palette_init() [palette.c] to initialize palette system
3736                - calls render_init() [render.c] to initialize the rendering system
3837                - calls ui_init() [ui.c] to initialize the user interface
r4135r4136
14781477   output_init(machine);
14791478   state_init(machine);
14801479   state_save_allow_registration(machine, TRUE);
1481   drawgfx_init(machine);
14821480   palette_init(machine);
14831481   render_init(machine);
14841482   ui_init(machine);
r4135r4136
15591557
15601558   /* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */
15611559   /* but not if the debugger is enabled (so we can look at the data) */
1562   if (!options_get_bool(mame_options(), OPTION_DEBUG))
1560   if (PREDECODE_GFX && !options_get_bool(mame_options(), OPTION_DEBUG))
15631561      for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = nextrgntag)
15641562      {
15651563         nextrgntag = memory_region_next(machine, rgntag);
src/emu/machine/6821pia.c
r4135r4136
122122   assert_always((which >= 0) && (which < MAX_PIA), "pia_config called on an invalid PIA!");
123123   assert_always(intf, "pia_config called with an invalid interface!");
124124
125   {
126      /* NPW 5-Jan-2009 - Multisession hack */
127      int i;
128      for (i = 0; i < ARRAY_LENGTH(pias); i++)
129      {
130         if ((pias[i].machine != NULL) && (pias[i].machine != machine))
131            memset(&pias[i], 0, sizeof(pias[i]));
132      }
133   }
134
135125   p = &pias[which];
136126   memset(p, 0, sizeof(pias[0]));
137127
src/emu/machine/6821new.c
r0r4136
1/**********************************************************************
2
3    Motorola 6821 PIA interface and emulation
4
5**********************************************************************/
6
7#include "6821new.h"
8
9
10/***************************************************************************
11    TYPE DEFINITIONS
12***************************************************************************/
13
14typedef struct _pia6821 pia6821;
15struct _pia6821
16{
17   UINT8 in_a;
18   UINT8 in_ca1;
19   UINT8 in_ca2;
20   UINT8 out_a;
21   UINT8 out_ca2;
22   UINT8 port_a_z_mask;
23   UINT8 ddr_a;
24   UINT8 ctl_a;
25   UINT8 irq_a1;
26   UINT8 irq_a2;
27   UINT8 irq_a_state;
28
29   UINT8 in_b;
30   UINT8 in_cb1;
31   UINT8 in_cb2;
32   UINT8 out_b;
33   UINT8 out_cb2;
34   UINT8 last_out_cb2_z;
35   UINT8 ddr_b;
36   UINT8 ctl_b;
37   UINT8 irq_b1;
38   UINT8 irq_b2;
39   UINT8 irq_b_state;
40
41   /* variables that indicate if access a line externally -
42       used to for logging purposes ONLY */
43   UINT8 in_a_pushed;
44   UINT8 out_a_needs_pulled;
45   UINT8 in_ca1_pushed;
46   UINT8 in_ca2_pushed;
47   UINT8 out_ca2_needs_pulled;
48   UINT8 in_b_pushed;
49   UINT8 out_b_needs_pulled;
50   UINT8 in_cb1_pushed;
51   UINT8 in_cb2_pushed;
52   UINT8 out_cb2_needs_pulled;
53   UINT8 logged_port_a_not_connected;
54   UINT8 logged_port_b_not_connected;
55   UINT8 logged_ca1_not_connected;
56   UINT8 logged_ca2_not_connected;
57   UINT8 logged_cb1_not_connected;
58   UINT8 logged_cb2_not_connected;
59};
60
61
62/***************************************************************************
63    MACROS
64***************************************************************************/
65
66#define VERBOSE 0
67
68#define LOG(x)   do { if (VERBOSE) logerror x; } while (0)
69
70#define PIA_IRQ1            (0x80)
71#define PIA_IRQ2            (0x40)
72
73#define IRQ1_ENABLED(c)         ( (((c) >> 0) & 0x01))
74#define C1_LOW_TO_HIGH(c)      ( (((c) >> 1) & 0x01))
75#define C1_HIGH_TO_LOW(c)      (!(((c) >> 1) & 0x01))
76#define OUTPUT_SELECTED(c)      ( (((c) >> 2) & 0x01))
77#define IRQ2_ENABLED(c)         ( (((c) >> 3) & 0x01))
78#define STROBE_E_RESET(c)      ( (((c) >> 3) & 0x01))
79#define STROBE_C1_RESET(c)      (!(((c) >> 3) & 0x01))
80#define C2_SET(c)            ( (((c) >> 3) & 0x01))
81#define C2_LOW_TO_HIGH(c)      ( (((c) >> 4) & 0x01))
82#define C2_HIGH_TO_LOW(c)      (!(((c) >> 4) & 0x01))
83#define C2_SET_MODE(c)         ( (((c) >> 4) & 0x01))
84#define C2_STROBE_MODE(c)      (!(((c) >> 4) & 0x01))
85#define C2_OUTPUT(c)         ( (((c) >> 5) & 0x01))
86#define C2_INPUT(c)            (!(((c) >> 5) & 0x01))
87
88
89/***************************************************************************
90    PROTOTYPES
91***************************************************************************/
92/***************************************************************************
93    INLINE FUNCTIONS
94***************************************************************************/
95
96INLINE pia6821 *get_token(const device_config *device)
97{
98   assert(device != NULL);
99   assert((device->type == PIA6821) || (device->type == PIA6822));
100   return (pia6821 *) device->token;
101}
102
103
104INLINE const pia6821_interface *get_interface(const device_config *device)
105{
106   assert(device != NULL);
107   assert((device->type == PIA6821) || (device->type == PIA6822));
108   return (const pia6821_interface *) device->static_config;
109}
110
111
112/***************************************************************************
113    IMPLEMENTATION
114***************************************************************************/
115
116/*-------------------------------------------------
117    DEVICE_START( pia )
118-------------------------------------------------*/
119
120static DEVICE_START( pia )
121{
122   pia6821 *p = get_token(device);
123   memset(p, 0, sizeof(*p));
124
125   state_save_register_device_item(device, 0, p->in_a);
126   state_save_register_device_item(device, 0, p->in_ca1);
127   state_save_register_device_item(device, 0, p->in_ca2);
128   state_save_register_device_item(device, 0, p->out_a);
129   state_save_register_device_item(device, 0, p->out_ca2);
130   state_save_register_device_item(device, 0, p->port_a_z_mask);
131   state_save_register_device_item(device, 0, p->ddr_a);
132   state_save_register_device_item(device, 0, p->ctl_a);
133   state_save_register_device_item(device, 0, p->irq_a1);
134   state_save_register_device_item(device, 0, p->irq_a2);
135   state_save_register_device_item(device, 0, p->irq_a_state);
136   state_save_register_device_item(device, 0, p->in_b);
137   state_save_register_device_item(device, 0, p->in_cb1);
138   state_save_register_device_item(device, 0, p->in_cb2);
139   state_save_register_device_item(device, 0, p->out_b);
140   state_save_register_device_item(device, 0, p->out_cb2);
141   state_save_register_device_item(device, 0, p->last_out_cb2_z);
142   state_save_register_device_item(device, 0, p->ddr_b);
143   state_save_register_device_item(device, 0, p->ctl_b);
144   state_save_register_device_item(device, 0, p->irq_b1);
145   state_save_register_device_item(device, 0, p->irq_b2);
146   state_save_register_device_item(device, 0, p->irq_b_state);
147   state_save_register_device_item(device, 0, p->in_a_pushed);
148   state_save_register_device_item(device, 0, p->out_a_needs_pulled);
149   state_save_register_device_item(device, 0, p->in_ca1_pushed);
150   state_save_register_device_item(device, 0, p->in_ca2_pushed);
151   state_save_register_device_item(device, 0, p->out_ca2_needs_pulled);
152   state_save_register_device_item(device, 0, p->in_b_pushed);
153   state_save_register_device_item(device, 0, p->out_b_needs_pulled);
154   state_save_register_device_item(device, 0, p->in_cb1_pushed);
155   state_save_register_device_item(device, 0, p->in_cb2_pushed);
156   state_save_register_device_item(device, 0, p->out_cb2_needs_pulled);
157
158   return DEVICE_START_OK;
159}
160
161
162/*-------------------------------------------------
163    DEVICE_RESET( pia )
164-------------------------------------------------*/
165
166static DEVICE_RESET( pia )
167{
168   pia6821 *p = get_token(device);
169   const pia6821_interface *intf = get_interface(device);
170
171   memset(p, 0, sizeof(*p));
172
173   /*
174     * set default read values.
175     *
176     * ports A,CA1,CA2 default to 1
177     * ports B,CB1,CB2 are three-state and undefined (set to 0)
178     */
179   p->in_a = 0xff;
180   p->in_ca1 = TRUE;
181   p->in_ca2 = TRUE;
182
183   /* clear the IRQs */
184   if (intf->irq_a_func) (*intf->irq_a_func)(device, FALSE);
185   if (intf->irq_b_func) (*intf->irq_b_func)(device, FALSE);
186}
187
188
189/*-------------------------------------------------
190    update_interrupts
191-------------------------------------------------*/
192
193static void update_interrupts(const device_config *device)
194{
195   pia6821 *p = get_token(device);
196   const pia6821_interface *intf = get_interface(device);
197   int new_state;
198
199   /* start with IRQ A */
200   new_state = (p->irq_a1 && IRQ1_ENABLED(p->ctl_a)) || (p->irq_a2 && IRQ2_ENABLED(p->ctl_a));
201
202   if (new_state != p->irq_a_state)
203   {
204      p->irq_a_state = new_state;
205
206      if (intf->irq_a_func)
207         (*intf->irq_a_func)(device, p->irq_a_state);
208   }
209
210   /* then do IRQ B */
211   new_state = (p->irq_b1 && IRQ1_ENABLED(p->ctl_b)) || (p->irq_b2 && IRQ2_ENABLED(p->ctl_b));
212
213   if (new_state != p->irq_b_state)
214   {
215      p->irq_b_state = new_state;
216
217      if (intf->irq_b_func)
218         (*intf->irq_b_func)(device, p->irq_b_state);
219   }
220}
221
222
223/*-------------------------------------------------
224    get_in_a_value
225-------------------------------------------------*/
226
227static UINT8 get_in_a_value(const device_config *device)
228{
229   pia6821 *p = get_token(device);
230   const pia6821_interface *intf = get_interface(device);
231   UINT8 port_a_data = 0;
232   UINT8 ret;
233
234   /* update the input */
235   if (intf->in_a_func)
236      port_a_data = (*intf->in_a_func)(device, 0);
237   else
238   {
239      if (p->in_a_pushed)
240         port_a_data = p->in_a;
241      else
242      {
243         /* mark all pins disconnected */
244         p->port_a_z_mask = 0xff;
245
246         if (!p->logged_port_a_not_connected && (p->ddr_a != 0xff))
247         {
248            logerror("PIA #%s: Warning! No port A read handler. Assuming pins 0x%02X not connected\n", device->tag, p->ddr_a ^ 0xff);
249            p->logged_port_a_not_connected = TRUE;
250         }
251      }
252   }
253
254   /* - connected pins are always read
255       - disconnected pins read the output buffer in output mode
256       - disconnected pins are HI in input mode */
257   ret = (~p->port_a_z_mask             & port_a_data) |
258         ( p->port_a_z_mask &  p->ddr_a & p->out_a) |
259         ( p->port_a_z_mask & ~p->ddr_a);
260
261   return ret;
262}
263
264
265/*-------------------------------------------------
266    get_in_b_value
267-------------------------------------------------*/
268
269static UINT8 get_in_b_value(const device_config *device)
270{
271   pia6821 *p = get_token(device);
272   const pia6821_interface *intf = get_interface(device);
273   UINT8 ret;
274
275   if (p->ddr_b == 0xff)
276      /* all output, just return buffer */
277      ret = p->out_b;
278   else
279   {
280      UINT8 port_b_data;
281
282      /* update the input */
283      if (intf->in_b_func)
284         port_b_data = (*intf->in_b_func)(device, 0);
285      else
286      {
287         if (p->in_b_pushed)
288            port_b_data = p->in_b;
289         else
290         {
291            if (!p->logged_port_b_not_connected && (p->ddr_b != 0xff))
292            {
293               logerror("PIA #%s: Error! No port B read handler. Three-state pins 0x%02X are undefined\n", device->tag, p->ddr_b ^ 0xff);
294               p->logged_port_b_not_connected = TRUE;
295            }
296
297            /* undefined -- need to return something */
298            port_b_data = 0x00;
299         }
300      }
301
302      /* the DDR determines if the pin or the output buffer is read */
303      ret = (p->out_b & p->ddr_b) | (port_b_data & ~p->ddr_b);
304   }
305
306   return ret;
307}
308
309
310/*-------------------------------------------------
311    get_out_a_value
312-------------------------------------------------*/
313
314static UINT8 get_out_a_value(const device_config *device)
315{
316   pia6821 *p = get_token(device);
317   UINT8 ret;
318
319   if (p->ddr_a == 0xff)
320      /* all output */
321      ret = p->out_a;
322   else
323      /* input pins don't change */
324      ret = (p->out_a & p->ddr_a) | (get_in_a_value(device) & ~p->ddr_a);
325
326   return ret;
327}
328
329
330/*-------------------------------------------------
331    get_out_b_value
332-------------------------------------------------*/
333
334static UINT8 get_out_b_value(const device_config *device)
335{
336   pia6821 *p = get_token(device);
337
338   /* input pins are high-impedance - we just send them as zeros for backwards compatibility */
339   return p->out_b & p->ddr_b;
340}
341
342
343/*-------------------------------------------------
344    set_out_ca2
345-------------------------------------------------*/
346
347static void set_out_ca2(const device_config *device, int data)
348{
349   pia6821 *p = get_token(device);
350   const pia6821_interface *intf = get_interface(device);
351
352   if (data != p->out_ca2)
353   {
354      p->out_ca2 = data;
355
356      /* send to output function */
357      if (intf->out_ca2_func)
358         (*intf->out_ca2_func)(device, 0, p->out_ca2);
359      else
360      {
361         if (p->out_ca2_needs_pulled)
362            logerror("PIA #%s: Warning! No port CA2 write handler. Previous value has been lost!\n", device->tag);
363
364         p->out_ca2_needs_pulled = TRUE;
365      }
366   }
367}
368
369
370/*-------------------------------------------------
371    set_out_cb2
372-------------------------------------------------*/
373
374static void set_out_cb2(const device_config *device, int data)
375{
376   pia6821 *p = get_token(device);
377   const pia6821_interface *intf = get_interface(device);
378
379   int z = pianew_get_output_cb2_z(device);
380
381   if ((data != p->out_cb2) || (z != p->last_out_cb2_z))
382   {
383      p->out_cb2 = data;
384      p->last_out_cb2_z = z;
385
386      /* send to output function */
387      if (intf->out_cb2_func)
388         (*intf->out_cb2_func)(device, 0, p->out_cb2);
389      else
390      {
391         if (p->out_cb2_needs_pulled)
392            logerror("PIA #%s: Warning! No port CB2 write handler. Previous value has been lost!\n", device->tag);
393
394         p->out_cb2_needs_pulled = TRUE;
395      }
396   }
397}
398
399
400/*-------------------------------------------------
401    port_a_r
402-------------------------------------------------*/
403
404static UINT8 port_a_r(const device_config *device)
405{
406   pia6821 *p = get_token(device);
407
408   UINT8 ret = get_in_a_value(device);
409
410   /* IRQ flags implicitly cleared by a read */
411   p->irq_a1 = FALSE;
412   p->irq_a2 = FALSE;
413   update_interrupts(device);
414
415   /* CA2 is configured as output and in read strobe mode */
416   if (C2_OUTPUT(p->ctl_a) && C2_STROBE_MODE(p->ctl_a))
417   {
418      /* this will cause a transition low */
419      set_out_ca2(device, FALSE);
420
421      /* if the CA2 strobe is cleared by the E, reset it right away */
422      if (STROBE_E_RESET(p->ctl_a))
423         set_out_ca2(device, TRUE);
424   }
425
426   LOG(("PIA #%s: port A read = %02X\n", device->tag, ret));
427
428   return ret;
429}
430
431
432/*-------------------------------------------------
433    ddr_a_r
434-------------------------------------------------*/
435
436static UINT8 ddr_a_r(const device_config *device)
437{
438   pia6821 *p = get_token(device);
439
440   UINT8 ret = p->ddr_a;
441
442   LOG(("PIA #%s: DDR A read = %02X\n", device->tag, ret));
443
444   return ret;
445}
446
447
448/*-------------------------------------------------
449    port_b_r
450-------------------------------------------------*/
451
452static UINT8 port_b_r(const device_config *device)
453{
454   pia6821 *p = get_token(device);
455
456   UINT8 ret = get_in_b_value(device);
457
458   /* This read will implicitly clear the IRQ B1 flag.  If CB2 is in write-strobe
459       mode with CB1 restore, and a CB1 active transition set the flag,
460       clearing it will cause CB2 to go high again.  Note that this is different
461       from what happens with port A. */
462   if (p->irq_b1 && C2_STROBE_MODE(p->ctl_b) && STROBE_C1_RESET(p->ctl_b))
463      set_out_cb2(device, TRUE);
464
465   /* IRQ flags implicitly cleared by a read */
466   p->irq_b1 = FALSE;
467   p->irq_b2 = FALSE;
468   update_interrupts(device);
469
470   LOG(("PIA #%s: port B read = %02X\n", device->tag, ret));
471
472   return ret;
473}
474
475
476/*-------------------------------------------------
477    ddr_b_r
478-------------------------------------------------*/
479
480static UINT8 ddr_b_r(const device_config *device)
481{
482   pia6821 *p = get_token(device);
483
484   UINT8 ret = p->ddr_b;
485
486   LOG(("PIA #%s: DDR B read = %02X\n", device->tag, ret));
487
488   return ret;
489}
490
491
492/*-------------------------------------------------
493    control_a_r
494-------------------------------------------------*/
495
496static UINT8 control_a_r(const device_config *device)
497{
498   pia6821 *p = get_token(device);
499   const pia6821_interface *intf = get_interface(device);
500   UINT8 ret;
501
502   /* update CA1 & CA2 if callback exists, these in turn may update IRQ's */
503   if (intf->in_ca1_func)
504      pia_ca1_w(device, 0, (*intf->in_ca1_func)(device, 0));
505   else if (!p->logged_ca1_not_connected && (!p->in_ca1_pushed))
506   {
507      logerror("PIA #%s: Warning! No CA1 read handler. Assuming pin not connected\n", device->tag);
508      p->logged_ca1_not_connected = TRUE;
509   }
510
511   if (intf->in_ca2_func)
512      pia_ca2_w(device, 0, (*intf->in_ca2_func)(device, 0));
513   else if ( !p->logged_ca2_not_connected && C2_INPUT(p->ctl_a) && !p->in_ca2_pushed)
514   {
515      logerror("PIA #%s: Warning! No CA2 read handler. Assuming pin not connected\n", device->tag);
516      p->logged_ca2_not_connected = TRUE;
517   }
518
519   /* read control register */
520   ret = p->ctl_a;
521
522   /* set the IRQ flags if we have pending IRQs */
523   if (p->irq_a1)
524      ret |= PIA_IRQ1;
525
526   if (p->irq_a2 && C2_INPUT(p->ctl_a))
527      ret |= PIA_IRQ2;
528
529   LOG(("PIA #%s: control A read = %02X\n", device->tag, ret));
530
531   return ret;
532}
533
534
535/*-------------------------------------------------
536    control_b_r
537-------------------------------------------------*/
538
539static UINT8 control_b_r(const device_config *device)
540{
541   pia6821 *p = get_token(device);
542   const pia6821_interface *intf = get_interface(device);
543   UINT8 ret;
544
545   /* update CB1 & CB2 if callback exists, these in turn may update IRQ's */
546   if (intf->in_cb1_func)
547      pia_cb1_w(device, 0, (*intf->in_cb1_func)(device, 0));
548   else if (!p->logged_cb1_not_connected && !p->in_cb1_pushed)
549   {
550      logerror("PIA #%s: Error! no CB1 read handler. Three-state pin is undefined\n", device->tag);
551      p->logged_cb1_not_connected = TRUE;
552   }
553
554   if (intf->in_cb2_func)
555      pia_cb2_w(device, 0, (*intf->in_cb2_func)(device, 0));
556   else if (!p->logged_cb2_not_connected && C2_INPUT(p->ctl_b) && !p->in_cb2_pushed)
557   {
558      logerror("PIA #%s: Error! No CB2 read handler. Three-state pin is undefined\n", device->tag);
559      p->logged_cb2_not_connected = TRUE;
560   }
561
562   /* read control register */
563   ret = p->ctl_b;
564
565   /* set the IRQ flags if we have pending IRQs */
566   if (p->irq_b1)
567      ret |= PIA_IRQ1;
568
569   if (p->irq_b2 && C2_INPUT(p->ctl_b))
570      ret |= PIA_IRQ2;
571
572   LOG(("PIA #%s: control B read = %02X\n", device->tag, ret));
573
574   return ret;
575}
576
577
578/*-------------------------------------------------
579    pia_r
580-------------------------------------------------*/
581
582READ8_DEVICE_HANDLER(pia_r)
583{
584   pia6821 *p = get_token(device);
585   UINT8 ret;
586
587   switch (offset & 0x03)
588   {
589      default: /* impossible */
590      case 0x00:
591         if (OUTPUT_SELECTED(p->ctl_a))
592            ret = port_a_r(device);
593         else
594            ret = ddr_a_r(device);
595         break;
596
597      case 0x01:
598         ret = control_a_r(device);
599         break;
600
601      case 0x02:
602         if (OUTPUT_SELECTED(p->ctl_b))
603            ret = port_b_r(device);
604         else
605            ret = ddr_b_r(device);
606         break;
607
608      case 0x03:
609         ret = control_b_r(device);
610         break;
611   }
612
613   return ret;
614}
615
616
617/*-------------------------------------------------
618    pia_alt_r
619-------------------------------------------------*/
620
621READ8_DEVICE_HANDLER(pia_alt_r)
622{
623   return pia_r(device, ((offset << 1) & 0x02) | ((offset >> 1) & 0x01));
624}
625
626
627/*-------------------------------------------------
628    pianew_get_port_b_z_mask
629-------------------------------------------------*/
630
631UINT8 pianew_get_port_b_z_mask(const device_config *device)
632{
633   pia6821 *p = get_token(device);
634   return ~p->ddr_b;
635}
636
637
638/*-------------------------------------------------
639    send_to_out_a_func
640-------------------------------------------------*/
641
642static void send_to_out_a_func(const device_config *device, const char* message)
643{
644   pia6821 *p = get_token(device);
645   const pia6821_interface *intf = get_interface(device);
646
647   /* input pins are pulled high */
648   UINT8 data = get_out_a_value(device);
649
650   LOG(("PIA #%s: %s = %02X\n", device->tag, message, data));
651
652   if (intf->out_a_func)
653      (*intf->out_a_func)(device, 0, data);
654   else
655   {
656      if (p->out_a_needs_pulled)
657         logerror("PIA #%s: Warning! No port A write handler. Previous value has been lost!\n", device->tag);
658
659      p->out_a_needs_pulled = TRUE;
660   }
661}
662
663
664/*-------------------------------------------------
665    send_to_out_b_func
666-------------------------------------------------*/
667
668static void send_to_out_b_func(const device_config *device, const char* message)
669{
670   pia6821 *p = get_token(device);
671   const pia6821_interface *intf = get_interface(device);
672
673   /* input pins are high-impedance - we just send them as zeros for backwards compatibility */
674   UINT8 data = get_out_b_value(device);
675
676   LOG(("PIA #%s: %s = %02X\n", device->tag, message, data));
677
678   if (intf->out_b_func)
679      (*intf->out_b_func)(device, 0, data);
680   else
681   {
682      if (p->out_b_needs_pulled)
683         logerror("PIA #%s: Warning! No port B write handler. Previous value has been lost!\n", device->tag);
684
685      p->out_b_needs_pulled = TRUE;
686   }
687}
688
689
690/*-------------------------------------------------
691    port_a_w
692-------------------------------------------------*/
693
694static void port_a_w(const device_config *device, UINT8 data)
695{
696   pia6821 *p = get_token(device);
697
698   /* buffer the output value */
699   p->out_a = data;
700
701   send_to_out_a_func(device, "port A write");
702}
703
704
705/*-------------------------------------------------
706    ddr_a_w
707-------------------------------------------------*/
708
709static void ddr_a_w(const device_config *device, UINT8 data)
710{
711   pia6821 *p = get_token(device);
712
713   if (data == 0x00)
714      LOG(("PIA #%s: DDR A write = %02X (input mode)\n", device->tag, data));
715   else if (data == 0xff)
716      LOG(("PIA #%s: DDR A write = %02X (output mode)\n", device->tag, data));
717   else
718      LOG(("PIA #%s: DDR A write = %02X (mixed mode)\n", device->tag, data));
719
720   if (p->ddr_a != data)
721   {
722      /* DDR changed, call the callback again */
723      p->ddr_a = data;
724      p->logged_port_a_not_connected = FALSE;
725      send_to_out_a_func(device, "port A write due to DDR change");
726   }
727}
728
729
730/*-------------------------------------------------
731    port_b_w
732-------------------------------------------------*/
733
734static void port_b_w(const device_config *device, UINT8 data)
735{
736   pia6821 *p = get_token(device);
737
738   /* buffer the output value */
739   p->out_b = data;
740
741   send_to_out_b_func(device, "port B write");
742
743   /* CB2 in write strobe mode */
744   if (C2_STROBE_MODE(p->ctl_b))
745   {
746      /* this will cause a transition low */
747      set_out_cb2(device, FALSE);
748
749      /* if the CB2 strobe is cleared by the E, reset it right away */
750      if (STROBE_E_RESET(p->ctl_b))
751         set_out_cb2(device, TRUE);
752   }
753}
754
755
756/*-------------------------------------------------
757    ddr_b_w
758-------------------------------------------------*/
759
760static void ddr_b_w(const device_config *device, UINT8 data)
761{
762   pia6821 *p = get_token(device);
763
764   if (data == 0x00)
765      LOG(("PIA #%s: DDR B write = %02X (input mode)\n", device->tag, data));
766   else if (data == 0xff)
767      LOG(("PIA #%s: DDR B write = %02X (output mode)\n", device->tag, data));
768   else
769      LOG(("PIA #%s: DDR B write = %02X (mixed mode)\n", device->tag, data));
770
771   if (p->ddr_b != data)
772   {
773      /* DDR changed, call the callback again */
774      p->ddr_b = data;
775      p->logged_port_b_not_connected = FALSE;
776      send_to_out_b_func(device, "port B write due to DDR change");
777   }
778}
779
780
781/*-------------------------------------------------
782    control_a_w
783-------------------------------------------------*/
784
785static void control_a_w(const device_config *device, UINT8 data)
786{
787   pia6821 *p = get_token(device);
788
789   /* bit 7 and 6 are read only */
790   data &= 0x3f;
791
792   LOG(("PIA #%s: control A write = %02X\n", device->tag, data));
793
794   /* update the control register */
795   p->ctl_a = data;
796
797   /* CA2 is configured as output */
798   if (C2_OUTPUT(p->ctl_a))
799   {
800      int temp;
801
802      if (C2_SET_MODE(p->ctl_a))
803         /* set/reset mode - bit value determines the new output */
804         temp = C2_SET(p->ctl_a);
805      else
806         /* strobe mode - output is always high unless strobed */
807         temp = TRUE;
808
809      set_out_ca2(device, temp);
810   }
811
812   /* update externals */
813   update_interrupts(device);
814}
815
816
817/*-------------------------------------------------
818    control_b_w
819-------------------------------------------------*/
820
821static void control_b_w(const device_config *device, UINT8 data)
822{
823   pia6821 *p = get_token(device);
824   int temp;
825
826   /* bit 7 and 6 are read only */
827   data &= 0x3f;
828
829   LOG(("PIA #%s: control B write = %02X\n", device->tag, data));
830
831   /* update the control register */
832   p->ctl_b = data;
833
834   if (C2_SET_MODE(p->ctl_b))
835      /* set/reset mode - bit value determines the new output */
836      temp = C2_SET(p->ctl_b);
837   else
838      /* strobe mode - output is always high unless strobed */
839      temp = TRUE;
840
841   set_out_cb2(device, temp);
842
843   /* update externals */
844   update_interrupts(device);
845}
846
847
848/*-------------------------------------------------
849    pia_w
850-------------------------------------------------*/
851
852WRITE8_DEVICE_HANDLER(pia_w)
853{
854   pia6821 *p = get_token(device);
855
856   switch (offset & 0x03)
857   {
858      default: /* impossible */
859      case 0x00:
860         if (OUTPUT_SELECTED(p->ctl_a))
861            port_a_w(device, data);
862         else
863            ddr_a_w(device, data);
864         break;
865
866      case 0x01:
867         control_a_w(device, data);
868         break;
869
870      case 0x02:
871         if (OUTPUT_SELECTED(p->ctl_b))
872            port_b_w(device, data);
873         else
874            ddr_b_w(device, data);
875         break;
876
877      case 0x03:
878         control_b_w(device, data);
879         break;
880   }
881}
882
883
884/*-------------------------------------------------
885    pia_alt_w
886-------------------------------------------------*/
887
888WRITE8_DEVICE_HANDLER(pia_alt_w)
889{
890   pia_w(device, ((offset << 1) & 0x02) | ((offset >> 1) & 0x01), data);
891}
892
893
894/*-------------------------------------------------
895    pianew_set_port_a_z_mask
896-------------------------------------------------*/
897
898void pianew_set_port_a_z_mask(const device_config *device, UINT8 data)
899{
900   pia6821 *p = get_token(device);
901
902   p->port_a_z_mask = data;
903}
904
905
906/*-------------------------------------------------
907    pia_porta_r
908-------------------------------------------------*/
909
910READ8_DEVICE_HANDLER(pia_porta_r)
911{
912   pia6821 *p = get_token(device);
913
914   return p->in_a;
915}
916
917
918/*-------------------------------------------------
919    pianew_set_input_a
920-------------------------------------------------*/
921
922void pianew_set_input_a(const device_config *device, UINT8 data, UINT8 z_mask)
923{
924   pia6821 *p = get_token(device);
925   const pia6821_interface *intf = get_interface(device);
926
927   assert_always(intf->in_a_func == NULL, "pia_porta_w() called when in_a_func implemented");
928
929   LOG(("PIA #%s: set input port A = %02X\n", device->tag, data));
930
931   p->in_a = data;
932   p->port_a_z_mask = z_mask;
933   p->in_a_pushed = TRUE;
934}
935
936
937/*-------------------------------------------------
938    pia_porta_w
939-------------------------------------------------*/
940
941WRITE8_DEVICE_HANDLER(pia_porta_w)
942{
943   pianew_set_input_a(device, data, 0);
944}
945
946
947/*-------------------------------------------------
948    pianew_get_output_a
949-------------------------------------------------*/
950
951UINT8 pianew_get_output_a(const device_config *device)
952{
953   pia6821 *p = get_token(device);
954
955   p->out_a_needs_pulled = FALSE;
956
957   return get_out_a_value(device);
958}
959
960
961/*-------------------------------------------------
962    pia_ca1_r
963-------------------------------------------------*/
964
965READ8_DEVICE_HANDLER(pia_ca1_r)
966{
967   pia6821 *p = get_token(device);
968
969   return p->in_ca1;
970}
971
972
973/*-------------------------------------------------
974    pia_ca1_w
975-------------------------------------------------*/
976
977WRITE8_DEVICE_HANDLER(pia_ca1_w)
978{
979   pia6821 *p = get_token(device);
980
981   /* limit the data to 0 or 1 */
982   data = data ? TRUE : FALSE;
983
984   LOG(("PIA #%s: set input CA1 = %d\n", device->tag, data));
985
986   /* the new state has caused a transition */
987   if ((p->in_ca1 != data) &&
988      ((data && C1_LOW_TO_HIGH(p->ctl_a)) || (!data && C1_HIGH_TO_LOW(p->ctl_a))))
989   {
990      LOG(("PIA #%s: CA1 triggering\n", device->tag));
991
992      /* mark the IRQ */
993      p->irq_a1 = TRUE;
994
995      /* update externals */
996      update_interrupts(device);
997
998      /* CA2 is configured as output and in read strobe mode and cleared by a CA1 transition */
999      if (C2_OUTPUT(p->ctl_a) && C2_STROBE_MODE(p->ctl_a) && STROBE_C1_RESET(p->ctl_a))
1000         set_out_ca2(device, TRUE);
1001   }
1002
1003   /* set the new value for CA1 */
1004   p->in_ca1 = data;
1005   p->in_ca1_pushed = TRUE;
1006}
1007
1008
1009/*-------------------------------------------------
1010    pia_ca2_r
1011-------------------------------------------------*/
1012
1013READ8_DEVICE_HANDLER(pia_ca2_r)
1014{
1015   pia6821 *p = get_token(device);
1016
1017   return p->in_ca2;
1018}
1019
1020
1021/*-------------------------------------------------
1022    pia_ca2_w
1023-------------------------------------------------*/
1024
1025WRITE8_DEVICE_HANDLER(pia_ca2_w)
1026{
1027   pia6821 *p = get_token(device);
1028
1029   /* limit the data to 0 or 1 */
1030   data = data ? 1 : 0;
1031
1032   LOG(("PIA #%s: set input CA2 = %d\n", device->tag, data));
1033
1034   /* if input mode and the new state has caused a transition */
1035   if (C2_INPUT(p->ctl_a) &&
1036      (p->in_ca2 != data) &&
1037      ((data && C2_LOW_TO_HIGH(p->ctl_a)) || (!data && C2_HIGH_TO_LOW(p->ctl_a))))
1038   {
1039      LOG(("PIA #%s: CA2 triggering\n", device->tag));
1040
1041      /* mark the IRQ */
1042      p->irq_a2 = TRUE;
1043
1044      /* update externals */
1045      update_interrupts(device);
1046   }
1047
1048   /* set the new value for CA2 */
1049   p->in_ca2 = data;
1050   p->in_ca2_pushed = TRUE;
1051}
1052
1053
1054/*-------------------------------------------------
1055    pianew_get_output_ca2
1056-------------------------------------------------*/
1057
1058int pianew_get_output_ca2(const device_config *device)
1059{
1060   pia6821 *p = get_token(device);
1061
1062   p->out_ca2_needs_pulled = FALSE;
1063
1064   return p->out_ca2;
1065}
1066
1067
1068/*-------------------------------------------------
1069    pianew_get_output_ca2_z - version of
1070    pianew_get_output_ca2, which takes account of internal
1071    pullup resistor
1072-------------------------------------------------*/
1073
1074int pianew_get_output_ca2_z(const device_config *device)
1075{
1076   pia6821 *p = get_token(device);
1077
1078   p->out_ca2_needs_pulled = FALSE;
1079
1080   // If it's an output, output the bit, if it's an input, it's
1081   // pulled up
1082   return p->out_ca2 |
1083          C2_INPUT(p->ctl_a);
1084}
1085
1086
1087/*-------------------------------------------------
1088    pia_portb_r
1089-------------------------------------------------*/
1090
1091READ8_DEVICE_HANDLER(pia_portb_r)
1092{
1093   pia6821 *p = get_token(device);
1094
1095   return p->in_b;
1096}
1097
1098
1099/*-------------------------------------------------
1100    pia_portb_w
1101-------------------------------------------------*/
1102
1103WRITE8_DEVICE_HANDLER(pia_portb_w)
1104{
1105   pia6821 *p = get_token(device);
1106   const pia6821_interface *intf = get_interface(device);
1107
1108   assert_always(intf->in_b_func == NULL, "pia_set_input_b() called when in_b_func implemented");
1109
1110   LOG(("PIA #%s: set input port B = %02X\n", device->tag, data));
1111
1112   p->in_b = data;
1113   p->in_b_pushed = TRUE;
1114}
1115
1116
1117/*-------------------------------------------------
1118    pianew_get_output_b
1119-------------------------------------------------*/
1120
1121UINT8 pianew_get_output_b(const device_config *device)
1122{
1123   pia6821 *p = get_token(device);
1124
1125   p->out_b_needs_pulled = FALSE;
1126
1127   return get_out_b_value(device);
1128}
1129
1130
1131/*-------------------------------------------------
1132    pia_cb1_r
1133-------------------------------------------------*/
1134
1135READ8_DEVICE_HANDLER(pia_cb1_r)
1136{
1137   pia6821 *p = get_token(device);
1138
1139   return p->in_cb1;
1140}
1141
1142
1143/*-------------------------------------------------
1144    pia_cb1_w
1145-------------------------------------------------*/
1146
1147WRITE8_DEVICE_HANDLER(pia_cb1_w)
1148{
1149   pia6821 *p = get_token(device);
1150
1151   /* limit the data to 0 or 1 */
1152   data = data ? 1 : 0;
1153
1154   LOG(("PIA #%s: set input CB1 = %d\n", device->tag, data));
1155
1156   /* the new state has caused a transition */
1157   if ((p->in_cb1 != data) &&
1158      ((data && C1_LOW_TO_HIGH(p->ctl_b)) || (!data && C1_HIGH_TO_LOW(p->ctl_b))))
1159   {
1160      LOG(("PIA #%s: CB1 triggering\n", device->tag));
1161
1162      /* mark the IRQ */
1163      p->irq_b1 = 1;
1164
1165      /* update externals */
1166      update_interrupts(device);
1167
1168      /* If CB2 is configured as a write-strobe output which is reset by a CB1
1169           transition, this reset will only happen when a read from port B implicitly
1170           clears the IRQ B1 flag.  So we handle the CB2 reset there.  Note that this
1171           is different from what happens with port A. */
1172   }
1173
1174   /* set the new value for CB1 */
1175   p->in_cb1 = data;
1176   p->in_cb1_pushed = TRUE;
1177}
1178
1179
1180/*-------------------------------------------------
1181    pia_cb2_r
1182-------------------------------------------------*/
1183
1184READ8_DEVICE_HANDLER(pia_cb2_r)
1185{
1186   pia6821 *p = get_token(device);
1187
1188   return p->in_cb2;
1189}
1190
1191
1192/*-------------------------------------------------
1193    pia_cb2_w
1194-------------------------------------------------*/
1195
1196WRITE8_DEVICE_HANDLER(pia_cb2_w)
1197{
1198   pia6821 *p = get_token(device);
1199
1200   /* limit the data to 0 or 1 */
1201   data = data ? 1 : 0;
1202
1203   LOG(("PIA #%s: set input CB2 = %d\n", device->tag, data));
1204
1205   /* if input mode and the new state has caused a transition */
1206   if (C2_INPUT(p->ctl_b) &&
1207      (p->in_cb2 != data) &&
1208      ((data && C2_LOW_TO_HIGH(p->ctl_b)) || (!data && C2_HIGH_TO_LOW(p->ctl_b))))
1209   {
1210      LOG(("PIA #%s: CB2 triggering\n", device->tag));
1211
1212      /* mark the IRQ */
1213      p->irq_b2 = 1;
1214
1215      /* update externals */
1216      update_interrupts(device);
1217   }
1218
1219   /* set the new value for CA2 */
1220   p->in_cb2 = data;
1221   p->in_cb2_pushed = TRUE;
1222}
1223
1224
1225/*-------------------------------------------------
1226    pianew_get_output_cb2
1227-------------------------------------------------*/
1228
1229int pianew_get_output_cb2(const device_config *device)
1230{
1231   pia6821 *p = get_token(device);
1232
1233   p->out_cb2_needs_pulled = FALSE;
1234
1235   return p->out_cb2;
1236}
1237
1238
1239/*-------------------------------------------------
1240    pianew_get_output_cb2_z
1241-------------------------------------------------*/
1242
1243int pianew_get_output_cb2_z(const device_config *device)
1244{
1245   pia6821 *p = get_token(device);
1246
1247   return !C2_OUTPUT(p->ctl_b);
1248}
1249
1250
1251/*-------------------------------------------------
1252    pianew_get_irq_a
1253-------------------------------------------------*/
1254
1255int pianew_get_irq_a(const device_config *device)
1256{
1257   pia6821 *p = get_token(device);
1258
1259   return p->irq_a_state;
1260}
1261
1262
1263/*-------------------------------------------------
1264    pianew_get_irq_b
1265-------------------------------------------------*/
1266
1267int pianew_get_irq_b(const device_config *device)
1268{
1269   pia6821 *p = get_token(device);
1270
1271   return p->irq_b_state;
1272}
1273
1274
1275/*-------------------------------------------------
1276    DEVICE_SET_INFO( pia )
1277-------------------------------------------------*/
1278
1279static DEVICE_SET_INFO( pia )
1280{
1281   switch(state)
1282   {
1283   }
1284}
1285
1286
1287/*-------------------------------------------------
1288    DEVICE_GET_INFO( pia6821 )
1289-------------------------------------------------*/
1290
1291DEVICE_GET_INFO(pia6821)
1292{
1293   switch (state)
1294   {
1295      /* --- the following bits of info are returned as 64-bit signed integers --- */
1296      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(pia6821);               break;
1297      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
1298      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
1299
1300      /* --- the following bits of info are returned as pointers to data or functions --- */
1301      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(pia); break;
1302      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(pia);      break;
1303      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
1304      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(pia);      break;
1305
1306      /* --- the following bits of info are returned as NULL-terminated strings --- */
1307      case DEVINFO_STR_NAME:                     strcpy(info->s, "6821 PIA");            break;
1308      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "6821 PIA");            break;
1309      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
1310      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
1311      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
1312   }
1313}
1314
1315
1316/*-------------------------------------------------
1317    DEVICE_GET_INFO( pia6822 )
1318-------------------------------------------------*/
1319
1320DEVICE_GET_INFO(pia6822)
1321{
1322   switch (state)
1323   {
1324      case DEVINFO_STR_NAME:                     strcpy(info->s, "6822 PIA");            break;
1325      default:                               DEVICE_GET_INFO_CALL(pia6821);            break;
1326   }
1327}
src/emu/machine/6821new.h
r0r4136
1/**********************************************************************
2
3    Motorola 6821 PIA interface and emulation
4
5    Notes:
6        * pia_get_port_b_z_mask() gives the caller the bitmask
7          that show which bits are high-impendance when
8          reading port B, thus neither 0 or 1.
9          pia_get_output_cb2_z() returns the same
10          information for the CB2 pin
11        * pia_set_port_a_z_mask allows the input callback to
12          indicate which port A bits are disconnected.
13          For these bit, the read operation will return the
14          output buffer's contents
15        * the 'alt' interface functions are used when the A0 and A1
16          address bits are swapped
17        * all 'int' data or return values are Boolean
18
19**********************************************************************/
20
21#ifndef __6821NEW_H__
22#define __6821NEW_H__
23
24#include "driver.h"
25
26
27/***************************************************************************
28    CONSTANTS
29***************************************************************************/
30
31#define PIA6821      DEVICE_GET_INFO_NAME(pia6821)
32#define PIA6822      DEVICE_GET_INFO_NAME(pia6822)
33
34
35/***************************************************************************
36    TYPE DEFINITIONS
37***************************************************************************/
38
39/*------------- PIA interface structure -----------------*/
40
41typedef struct _pia6821_interface pia6821_interface;
42struct _pia6821_interface
43{
44   read8_device_func in_a_func;
45   read8_device_func in_b_func;
46   read8_device_func in_ca1_func;
47   read8_device_func in_cb1_func;
48   read8_device_func in_ca2_func;
49   read8_device_func in_cb2_func;
50   write8_device_func out_a_func;
51   write8_device_func out_b_func;
52   write8_device_func out_ca2_func;
53   write8_device_func out_cb2_func;
54   void (*irq_a_func)(const device_config *device, int state);
55   void (*irq_b_func)(const device_config *device, int state);
56};
57
58
59/***************************************************************************
60    PROTOTYPES
61***************************************************************************/
62
63DEVICE_GET_INFO(pia6821);
64DEVICE_GET_INFO(pia6822);
65
66READ8_DEVICE_HANDLER(pia_r);
67WRITE8_DEVICE_HANDLER(pia_w);
68
69READ8_DEVICE_HANDLER(pia_alt_r);
70WRITE8_DEVICE_HANDLER(pia_alt_w);
71
72UINT8 pianew_get_port_b_z_mask(const device_config *device);  /* see first note */
73void pianew_set_port_a_z_mask(const device_config *device, UINT8 data);  /* see second note */
74
75READ8_DEVICE_HANDLER(pia_porta_r);
76WRITE8_DEVICE_HANDLER(pia_porta_w);
77void pianew_set_input_a(const device_config *device, UINT8 data, UINT8 z_mask);
78UINT8 pianew_get_output_a(const device_config *device);
79
80READ8_DEVICE_HANDLER(pia_ca1_r);
81WRITE8_DEVICE_HANDLER(pia_ca1_w);
82
83READ8_DEVICE_HANDLER(pia_ca2_r);
84WRITE8_DEVICE_HANDLER(pia_ca2_w);
85int pianew_get_output_ca2(const device_config *device);
86int pianew_get_output_ca2_z(const device_config *device);
87
88READ8_DEVICE_HANDLER(pia_portb_r);
89WRITE8_DEVICE_HANDLER(pia_portb_w);
90UINT8 pianew_get_output_b(const device_config *device);
91
92READ8_DEVICE_HANDLER(pia_cb1_r);
93WRITE8_DEVICE_HANDLER(pia_cb1_w);
94
95READ8_DEVICE_HANDLER(pia_cb2_r);
96WRITE8_DEVICE_HANDLER(pia_cb2_w);
97int pianew_get_output_cb2(const device_config *device);
98int pianew_get_output_cb2_z(const device_config *device);
99
100int pianew_get_irq_a(const device_config *device);
101int pianew_get_irq_b(const device_config *device);
102
103
104/***************************************************************************
105    DEVICE CONFIGURATION MACROS
106***************************************************************************/
107
108#define MDRV_PIA6821_ADD(_tag, _intrf) \
109   MDRV_DEVICE_ADD(_tag, PIA6821, 0) \
110   MDRV_DEVICE_CONFIG(_intrf)
111
112#define MDRV_PIA6821_MODIFY(_tag, _intrf) \
113   MDRV_DEVICE_MODIFY(_tag, PIA6821) \
114   MDRV_DEVICE_CONFIG(_intrf)
115
116#define MDRV_PIA6821_REMOVE(_tag) \
117   MDRV_DEVICE_REMOVE(_tag, PIA6821)
118
119#define MDRV_PIA6822_ADD(_tag, _intrf) \
120   MDRV_DEVICE_ADD(_tag, PIA6822, 0) \
121   MDRV_DEVICE_CONFIG(_intrf)
122
123#define MDRV_PIA6822_MODIFY(_tag, _intrf) \
124   MDRV_DEVICE_MODIFY(_tag, PIA6822) \
125   MDRV_DEVICE_CONFIG(_intrf)
126
127#define MDRV_PIA6822_REMOVE(_tag) \
128   MDRV_DEVICE_REMOVE(_tag, PIA6821)
129
130#endif /* __6821NEW_H__ */
src/emu/machine/f3853.c
r4135r4136
210210}
211211
212212
213DEVICE_SET_INFO( f3853 )
213static DEVICE_SET_INFO( f3853 )
214214{
215215   switch ( state )
216216   {
src/emu/mame.h
r4135r4136
2727#endif /* MESS */
2828
2929
30// temporary: set this to 1 to pre-decode graphics like we used to
31#define PREDECODE_GFX      (0)
3032
33
34
3135/***************************************************************************
3236    CONSTANTS
3337***************************************************************************/
src/emu/sound/es8712.h
r4135r4136
2020WRITE16_HANDLER( es8712_data_2_msb_w );
2121
2222SND_GET_INFO( es8712 );
23#define SOUND_ES8712 SND_GET_INFO_NAME( es8712 )
2324
2425#endif /* __ES8712_H__ */
src/emu/sound/nes_apu.h
r4135r4136
4848WRITE8_HANDLER( nes_psg_1_w );
4949
5050SND_GET_INFO( nesapu );
51#define SOUND_NES SND_GET_INFO_NAME( nesapu )
5152
5253#endif /* __NES_APU_H__ */
src/emu/sound/262intf.h
r4135r4136
2727WRITE8_HANDLER( ymf262_data_b_1_w );
2828
2929SND_GET_INFO( ymf262 );
30#define SOUND_YMF262 SND_GET_INFO_NAME( ymf262 )
3031
3132#endif /* __262INTF_H__ */
src/emu/sound/hc55516.c
r4135r4136
339339   switch (state)
340340   {
341341      /* --- the following bits of info are returned as 64-bit signed integers --- */
342      case SNDINFO_INT_ALIAS:                     info->i = SOUND_HC55516;               break;
342      case SNDINFO_FCT_ALIAS:                     info->type = SOUND_HC55516;               break;
343343
344344      /* --- the following bits of info are returned as pointers to data or functions --- */
345345      case SNDINFO_PTR_START:                     info->start = SND_START_NAME( hc55516 );   break;
src/emu/sound/cdp1869.h
r4135r4136
4141void cdp1869_set_wnoff(int which, int value);
4242
4343SND_GET_INFO( cdp1869 );
44#define SOUND_CDP1869 SND_GET_INFO_NAME( cdp1869 )
4445
4546#endif /* __CDP1869_H__ */
src/emu/sound/sp0256.h
r4135r4136
3737WRITE16_HANDLER( spb640_w );
3838
3939SND_GET_INFO( sp0256 );
40#define SOUND_SP0256 SND_GET_INFO_NAME( sp0256 )
4041
4142#endif /* __SP0256_H__ */
src/emu/sound/hc55516.h
r4135r4136
3838SND_GET_INFO( mc3417 );
3939SND_GET_INFO( mc3418 );
4040
41#define SOUND_HC55516 SND_GET_INFO_NAME( hc55516 )
42#define SOUND_MC3417 SND_GET_INFO_NAME( mc3417 )
43#define SOUND_MC3418 SND_GET_INFO_NAME( mc3418 )
44
4145#endif /* __HC55516_H__ */
src/emu/sound/iremga20.c
r4135r4136
195195   {
196196      case 7:   // voice status.  bit 0 is 1 if active. (routine around 0xccc in rtypeleo)
197197         return chip->channel[channel].play ? 1 : 0;
198         break;
199198
200199      default:
201200         logerror("GA20: read unk. register %d, channel %d\n", offset & 0xf, channel);
r4135r4136
248247
249248   chip->stream = stream_create( device, 0, 2, clock/4, chip, IremGA20_update );
250249
251   state_save_register_device_item_array(device, sndindex, chip->regs);
250   state_save_register_device_item_array(device, 0, chip->regs);
252251   for (i = 0; i < 4; i++)
253252   {
254253      state_save_register_device_item(device, i, chip->channel[i].rate);
src/emu/sound/iremga20.h
r4135r4136
1212READ16_HANDLER( irem_ga20_r );
1313
1414SND_GET_INFO( iremga20 );
15#define SOUND_IREMGA20 SND_GET_INFO_NAME( iremga20 )
1516
1617#endif /* __IREMGA20_H__ */
src/emu/sound/custom.h
r4135r4136
1919#define CUSTOM_RESET(name) void name(const device_config *device, void *token)
2020
2121SND_GET_INFO( custom );
22#define SOUND_CUSTOM SND_GET_INFO_NAME( custom )
2223
2324#endif /* __CUSTOM_H__ */
src/emu/sound/2612intf.h
r4135r4136
3535WRITE8_HANDLER( ym2612_data_port_1_b_w );
3636
3737SND_GET_INFO( ym2612 );
38#define SOUND_YM2612 SND_GET_INFO_NAME( ym2612 )
3839
3940
4041typedef struct _ym3438_interface ym3438_interface;
r4135r4136
6768WRITE8_HANDLER( ym3438_data_port_1_b_w );
6869
6970SND_GET_INFO( ym3438 );
71#define SOUND_YM3438 SND_GET_INFO_NAME( ym3438 )
7072
7173#endif /* __2612INTF_H__ */
src/emu/sound/c352.h
r4135r4136
77WRITE16_HANDLER( c352_0_w );
88
99SND_GET_INFO( c352 );
10#define SOUND_C352 SND_GET_INFO_NAME( c352 )
1011
1112#endif /* __C352_H__ */
1213
src/emu/sound/k051649.h
r4135r4136
1111WRITE8_HANDLER( k052539_waveform_w );
1212
1313SND_GET_INFO( k051649 );
14#define SOUND_K051649 SND_GET_INFO_NAME( k051649 )
1415
1516#endif /* __K051649_H__ */
src/emu/sound/k054539.h
r4135r4136
4646void k054539_set_gain(int chip, int channel, double gain);
4747
4848SND_GET_INFO( k054539 );
49#define SOUND_K054539 SND_GET_INFO_NAME( k054539 )
4950
5051#endif /* __K054539_H__ */
src/emu/sound/msm5205.c
r4135r4136
3333   const msm5205_interface *intf;
3434   const device_config *device;
3535   sound_stream * stream;  /* number of stream system      */
36   INT32 index;
3736   INT32 clock;            /* clock rate */
3837   emu_timer *timer;        /* VCLK callback timer          */
3938   INT32 data;               /* next adpcm data              */
r4135r4136
4746};
4847
4948
49static void msm5205_playmode(struct MSM5205Voice *voice,int select);
50
5051/*
5152 * ADPCM lockup tabe
5253 */
r4135r4136
156157   voice->signal  = 0;
157158   voice->step    = 0;
158159   /* timer and bitwidth set */
159   msm5205_playmode_w(voice->index,voice->intf->select);
160   msm5205_playmode(voice,voice->intf->select);
160161}
161162
162163
r4135r4136
180181   /* save a global pointer to our interface */
181182   voice->intf = config;
182183   voice->device = device;
183   voice->index = sndindex;
184184   voice->clock = clock;
185185
186186   /* compute the difference tables */
r4135r4136
259259void msm5205_playmode_w(int num,int select)
260260{
261261   struct MSM5205Voice *voice = sndti_token(SOUND_MSM5205, num);
262   msm5205_playmode(voice,select);
263}
264
265static void msm5205_playmode(struct MSM5205Voice *voice,int select)
266{
262267   static const int prescaler_table[4] = {96,48,64,0};
263268   int prescaler = prescaler_table[select & 3];
264269   int bitwidth = (select & 4) ? 4 : 3;
src/emu/sound/namco52.h
r4135r4136
3131void namcoio_52xx_write(int data);
3232
3333SND_GET_INFO( namco_52xx );
34#define SOUND_NAMCO_52XX SND_GET_INFO_NAME( namco_52xx )
3435
3536#endif /* __NAMCO52_H__ */
3637
src/emu/sound/c140.h
r4135r4136
2424};
2525
2626SND_GET_INFO( c140 );
27#define SOUND_C140 SND_GET_INFO_NAME( c140 )
2728
2829#endif /* __C140_H__ */
src/emu/sound/msm5205.h
r4135r4136
3737void msm5205_set_volume(int num,int volume);
3838
3939SND_GET_INFO( msm5205 );
40#define SOUND_MSM5205 SND_GET_INFO_NAME( msm5205 )
4041
4142#endif /* __MSM5205_H__ */
src/emu/sound/qsound.h
r4135r4136
1717READ8_HANDLER( qsound_status_r );
1818
1919SND_GET_INFO( qsound );
20#define SOUND_QSOUND SND_GET_INFO_NAME( qsound )
2021
2122#endif /* __QSOUND_H__ */
src/emu/sound/3812intf.c
r4135r4136
372372   void *         chip;
373373   const y8950_interface *intf;
374374   const device_config *device;
375   int            index;
376375};
377376
378377static void IRQHandler_8950(void *param,int irq)
r4135r4136
407406static unsigned char Y8950PortHandler_r(void *param)
408407{
409408   struct y8950_info *info = param;
410   /* temporary hack until this is converted to a device */
411   const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
412409   if (info->intf->portread)
413      return info->intf->portread(space,info->index);
410      return info->intf->portread(info->device,0);
414411   return 0;
415412}
416413
417414static void Y8950PortHandler_w(void *param,unsigned char data)
418415{
419416   struct y8950_info *info = param;
420   /* temporary hack until this is converted to a device */
421   const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
422417   if (info->intf->portwrite)
423      info->intf->portwrite(space,info->index,data);
418      info->intf->portwrite(info->device,0,data);
424419}
425420
426421static unsigned char Y8950KeyboardHandler_r(void *param)
427422{
428423   struct y8950_info *info = param;
429   /* temporary hack until this is converted to a device */
430   const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
431424   if (info->intf->keyboardread)
432      return info->intf->keyboardread(space,info->index);
425      return info->intf->keyboardread(info->device,0);
433426   return 0;
434427}
435428
436429static void Y8950KeyboardHandler_w(void *param,unsigned char data)
437430{
438431   struct y8950_info *info = param;
439   /* temporary hack until this is converted to a device */
440   const address_space *space = memory_find_address_space(info->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
441432   if (info->intf->keyboardwrite)
442      info->intf->keyboardwrite(space,info->index,data);
433      info->intf->keyboardwrite(info->device,0,data);
443434}
444435
445436static STREAM_UPDATE( y8950_stream_update )
r4135r4136
466457
467458   info->intf = config ? config : &dummy;
468459   info->device = device;
469   info->index = sndindex;
470460
471461   /* stream system initialize */
472462   info->chip = y8950_init(device,clock,rate);
src/emu/sound/3812intf.h
r4135r4136
1717{
1818   void (*handler)(running_machine *machine, int linestate);
1919
20   read8_space_func keyboardread;
21   write8_space_func keyboardwrite;
22   read8_space_func portread;
23   write8_space_func portwrite;
20   read8_device_func keyboardread;
21   write8_device_func keyboardwrite;
22   read8_device_func portread;
23   write8_device_func portwrite;
2424};
2525
2626
r4135r4136
3636WRITE8_HANDLER( ym3812_write_port_1_w );
3737
3838SND_GET_INFO( ym3812 );
39#define SOUND_YM3812 SND_GET_INFO_NAME( ym3812 )
3940
4041/* YM3526 */
4142READ8_HANDLER ( ym3526_status_port_0_r );
r4135r4136
4950WRITE8_HANDLER( ym3526_write_port_1_w );
5051
5152SND_GET_INFO( ym3526 );
53#define SOUND_YM3526 SND_GET_INFO_NAME( ym3526 )
5254
5355/* Y8950 */
5456READ8_HANDLER ( y8950_status_port_0_r );
r4135r4136
6264WRITE8_HANDLER( y8950_write_port_1_w );
6365
6466SND_GET_INFO( y8950 );
67#define SOUND_Y8950 SND_GET_INFO_NAME( y8950 )
6568
6669#endif /* __3812INTF_H__ */
src/emu/sound/snkwave.h
r4135r4136
66WRITE8_HANDLER( snkwave_w );
77
88SND_GET_INFO( snkwave );
9#define SOUND_SNKWAVE SND_GET_INFO_NAME( snkwave )
910
1011#endif /* __SNKWAVE_H__ */
11
src/emu/sound/cem3394.c
r4135r4136
108108typedef struct
109109{
110110   sound_stream * stream;         /* our stream */
111   void (*external)(int, int, short *);/* callback to generate external samples */
111   void (*external)(const device_config *, int, short *);/* callback to generate external samples */
112112   double vco_zero_freq;         /* frequency of VCO at 0.0V */
113113   double filter_zero_freq;      /* frequency of filter at 0.0V */
114114
r4135r4136
131131
132132   double inv_sample_rate;
133133   int sample_rate;
134   int index;
134   const device_config *device;
135135
136136   INT16 *mixer_buffer;
137137   INT16 *external_buffer;
r4135r4136
171171      INT16 last_ext = chip->last_ext;
172172
173173      /* fetch the external data */
174      (*chip->external)(chip->index, samples, chip->external_buffer);
174      (*chip->external)(chip->device, samples, chip->external_buffer);
175175
176176      /* compute the modulation depth, and adjust fstep to the maximum frequency */
177177      /* we lop off 13 bits of depth so that we can multiply by stepadjust, below, */
r4135r4136
322322
323323   chip = auto_malloc(sizeof(*chip));
324324   memset(chip, 0, sizeof(*chip));
325   chip->index = sndindex;
325   chip->device = device;
326326
327327   /* copy global parameters */
328328   chip->sample_rate = CEM3394_SAMPLE_RATE;
src/emu/sound/rf5c400.h
r4135r4136
99WRITE16_HANDLER( rf5c400_0_w );
1010
1111SND_GET_INFO( rf5c400 );
12#define SOUND_RF5C400 SND_GET_INFO_NAME( rf5c400 )
1213
1314#endif /* __RF5C400_H__ */
src/emu/sound/digitalk.c
r0r4136
1#include <math.h>
2#include "sndintrf.h"
3#include "streams.h"
4#include "digitalk.h"
5
6/*
7  National Semiconductor's Digitalker, also known as MM54104.
8
9This is a sample decompression chip where the codec is very
10specialized for speech.
11
12        - Driver history
13
14The history of this driver is a little strange.  The real
15reverse-engineering work has been done by Kevin Horton
16(single-stepping the chip and everything) with assistance by Lord
17Nightmare who had done the work (with help from Mr. Horton) on the tsi
18s14001a, a predecessor of the digitalker.  Mr. Horton was not
19interested in publishing his findings, but provided full-rate
20resynthesized samples for the game scorpion.  This driver is the
21result of analyzing these samples.
22
23
24        - The Chip
25
26Pinout from chipdir, added there by Agustin Yado.  Added rompwr.
27Package is DIP40.  Standard osc is 4MHz, maximum is 5Mhz.
28
29            +--()--+
30     osc in | 1  40| vdd
31    osc out | 2  39| speech out
32         cs | 3  38| adr 13
33         wr | 4  37| adr 12
34     rompwr | 5  36| adr 11
35       intr | 6  35| adr 10
36        cms | 7  34| adr 9
37         d0 | 8  33| adr 8
38         d1 | 9  32| adr 7
39         d2 |10  31| adr 6
40         d3 |11  30| adr 5
41         d4 |12  29| adr 4
42         d5 |13  28| adr 3
43         d6 |14  27| adr 2
44         d7 |15  26| adr 1
45    rdata 0 |16  25| adr 0
46    rdata 1 |17  24| rdata 7
47    rdata 2 |18  23| rdata 6
48    rdata 3 |19  22| rdata 5
49        vss |20  21| rdata 4
50            +------+
51
52Pin functions, excerpt from
53http://www.ski.org/Rehab/sktf/vol06no1Winter1985.html, slightly modified
54"Smith-Kettlewell Technical File, Vol 6, No 1, winter 1985"
55
56    On the controller chip, pin 40 is VCC, while pin 20 is ground. VCC
57    for this chip is between 7 and 11 VDC, and pin 40 is bypassed to
58    pin 20 by 0.1uF. Maximum current is listed at 45mA.
59
60    Pin 3 is called "Chip Select Not," and can be taken high to "open"
61    the input address and control lines. This is used in cases where
62    the Digitalker is connected to a computer bus, and the address
63    lines need to be floated while the bus is doing something else. In
64    other words, taking pin 3 high makes the Digitalker turn a deaf
65    ear to all of its inputs.
66
67    Pin 4 is "Write Not," and, as mentioned before, is brought low to
68    load an address into the controller, then brought high again to
69    start speech. In other words, this is the pin by which you
70    "trigger" the Digitalker.
71
72    Pin 5 is "Not ROM-Power Enable," an output which can be used to
73    control the power to the ROM's. This is used in cases of battery
74    supply where current drain is important; the ROM's will have their
75    power controlled by the controller.
76
77    Pin 6 is the "Interrupt Output," (equivalent to the "Busy Line" of
78    the old TSI Speech Board); this line goes low when an address is
79    loaded into the chip, then goes high again when speech is
80    finished. This signal can be used to control the driver circuitry
81    (or other controlling device), in which case it tells the driver
82    to "Hold the phone!" while the speech is running. Pin 7 is called
83    "CMS," and its state controls the action of the "Write Not"
84    line. With pin 7 low, the operation of pin 4 is as described. If
85    pin 7 is brought high, raising pin 4 high after loading an address
86    serves only to reset the interrupt and does not start speech. This
87    facility is probably intended for use where the interrupt line
88    really controls the hardware interrupt of a computer, and where
89    the program taking care of the interrupt may not have another word
90    to say every time the Digitalker is finished. I have found no
91    particular use for pin 7, and I simply ground it for normal
92    operation.
93
94    Pins 8 through 15 are the eight input address lines, with pin 8
95    being the most significant BIT and pin 15 being least
96    significant. These address lines are "active high." They should
97    never be left open. They are TTL-compatible; this means that logic
98    low is ground and logic high is plus 5VDC. (Actually, being MOS
99    inputs, you can take them as high as the VCC on the controller,
100    but a 5V supply is required for the ROM's anyhow -- it's there if
101    you want to use 5V.)
102
103    Pins 16 through 24 are the eight data lines which bring data from
104    the ROMs to the controller, with pin 16 being called "ROM Data
105    1," and pin 24 being "ROM Data 8."
106
107    Pins 25 through 38 are the fourteen address lines which select
108    location in the ROM's to be read by the controller. Pin 25 is
109    "Address 0," pin 38 is "Address 13."
110
111
112        - Codec
113
114The codec stems from the standard model for voiced speech generation:
115a stream of impulses at the pitch frequency followed by an
116articulation filter.  Both of those are considered slowly varying.
117
118        pitch         filter  voiced sound
119        ||||||||||  * /\/\  = ~~~~
120
121The first compression effect is by forcing the filter to be
122zero-phase.  That makes the periods perfectly symmetrical around the
123pitch pulse.  The voiced speech is as a result extracted as a number
124of symmetric periods, centered on the pitch pulses.
125
126Following that, two quantizations are done.  First, the pitch
127frequency is quantized to one of 32 values (see pitch_vals), going
128from ~80 to 200Hz.  Then the volume is selected among 8 possible
129values in an exponential scale, and the amplitudes are quantized as a
1304-bit signed value.  The period is time-warped to make it exactly 128
131samples long.
132
133The next step of the compression is to select which harnomics will be
134kept.  The choices are to keep only the even ones or only the odd
135ones.  Dropping half the harmonics allow to encode the period in only
13632 samples, using the fact that a period, for a zero-phase-at-center,
137half-harmonics signal, looks like:
138
139   even harmonics: /\/\     odd harmonics:  _/\_
140
141Where / = block of 32 samples
142      \ = same block reversed
143      _ = 32 zeroes
144
145So we're left with 32 4-bit samples to encode, which is done using a
1462-bit adpcm.  The adaptative part is done by using a fixed 16-deltas
147table indexed by the current and the previous encoded value.
148
149Added to all that is the possibility of repeating such a period while
150increasing or decreasing the pitch frequency.
151
152
153For non-voiced speech or non-speech an alternative mode is available
154where an equivalent period cutting, frequency and amplitude
155quantization is done, but the whole 128 samples are adpcm-encoded.
156
157
158Finally, silent zones are compressed specifically by storing their
159lenghts.
160
161
162Decoding is simpler.  The 128-samples waveform is decoded using the
163adpcm data and mirroring/zeroing as needed in the voiced case.  The
164pitch is taken into account by modulating a 1MHz (clock/4) signal at
165the pitch frequency multiplied by 128.  pitch_vals in is practice this
166modulation interval, hence its 128us base unit to compute the pitch
167period.
168
169
170        - Rom organization
171
172The rom starts with a vector of 16-bits little endian values which are
173the adresses of the segments table for the samples.  The segments data
174is a vector of 24-bits little-endian values organized as such:
175
176      adr+2    adr+1    adr
177      MMAAAAAA AAAAAAAA ERRRSSSS
178
179  M: Segment base waveforms compression mode (0-3)
180  A: Segment base waveforms data address (0-16383)
181  R: Repeat count (1-8)
182  S: Number of waveforms (1-16)
183  E: Last segment of the sample (flag)
184
185Decoding stops after having decoded a segment with the E bit set.  A
186final 8.192ms silence is systematically added.
187
188A == 0 means silence.  Duration is 5.12ms*(R+1)*(S+1), or in other
189terms a full decode of all-zero waveforms at maximal pitch frequency
190(pitch code 31).
191
192
193A != 0 means sound.  The sound data starts at that offset.  The
194encoding method is selected with M:
195
196  0: odd-harmonics voiced mode
197  2: even-harmonics voiced mode
198  3: unvoiced/non-speech mode
199
200Mode 1 is not supported because it is not present in the available
201samples, hence unknown.
202
203
204  Voiced mode (9 bytes/waveform):
205
206        VVVPPPPP AAAAAAAAx8     - First waveform
207        VVVDCCCC AAAAAAAAx8     - Following waveforms
208
209V: Volume (first index in pcm_levels)
210P: Pitch index
211A: adpcm data
212D: Pitch index change direction (0=increase, 1=decrease)
213C: Pitch index maximum change
214
215The waveforms are encoded with a 2-bit adpcm, lowest pair of bits
216first.  Deltas are a size-16 vector, indexed with the previous adpcm
217value in bits 0&1 and the current in bits 2&3.  Voiced speech modes
218use table delta1 and initial "previous" value 2.
219
220Each waveform is repeated R times at volume V.  First waveform has
221fixed pitch P.  Subsequent waveforms change the pitch index by 1 every
222repeat (including the first) up to a change of C.  D indicates whether
223it's an increment or a decrement.
224
225
226  Unvoiced mode (33 bytes/waveform):
227
228        VVVPPPPP AAAAAAAAx32    - All waveforms
229
230V: Volume (first index in pcm_levels)
231P: Pitch index
232A: adpcm data
233
234Adpcm encoding is identical but using delta2 table and an initial
235value of 1.  Every waveform is played consecutively and the adpcm
236previous value or dac level is not reset between waveforms.  The
237complete set of waveforms is repeated R times.
238
239*/
240
241
242typedef struct {
243   const UINT8 *rom;
244   const device_config *device;
245   sound_stream *stream;
246
247   // Port/lines state
248   UINT8 data, cs, cms, wr, intr;
249
250   // Current decoding state
251   UINT16 bpos, apos;
252   UINT8 mode, cur_segment, cur_repeat, segments, repeats;
253   UINT8 prev_pitch, pitch, pitch_pos;
254   UINT8 stop_after, cur_dac, cur_bits;
255
256   // Zero-range size
257   UINT32 zero_count; // 0 for done
258
259   // Waveform and current index in it
260   UINT8 dac_index; // 128 for done
261   INT16 dac[128];
262
263} digitalker;
264
265// Quantized intensity values, first index is the volume, second the
266// intensity (positive half only, real value goes -8..7)
267static const short pcm_levels[8][8] = {
268   {  473,  945,  1418,  1890,  2363,  2835,  3308,  3781 },
269   {  655, 1310,  1966,  2621,  3276,  3931,  4586,  5242 },
270   {  925, 1851,  2776,  3702,  4627,  5553,  6478,  7404 },
271   { 1249, 2498,  3747,  4996,  6245,  7494,  8743,  9992 },
272   { 1638, 3276,  4914,  6552,  8190,  9828, 11466, 13104 },
273   { 2252, 4504,  6757,  9009, 11261, 13514, 15766, 18018 },
274   { 2989, 5979,  8968, 11957, 14947, 17936, 20925, 23915 },
275   { 4095, 8190, 12285, 16380, 20475, 24570, 28665, 32760 },
276};
277
278static const int delta1[16] = { -4, -4, -1, -1, -2, -2, 0, 0, 0, 0, 2, 2, 1, 1, 4, 4 };
279static const int delta2[16] = { 0, -1, -2, -3, 1, 0, -1, -2, 2, 1, 0, -1, 3, 2, 1, 0 };
280
281// Frequency quantizations, values are in units of 128us.
282
283static const int pitch_vals[32] = {
284   97, 95, 92, 89, 87, 84, 82, 80, 77, 75, 73, 71, 69, 67, 65, 63,
285   61, 60, 58, 56, 55, 53, 52, 50, 49, 48, 46, 45, 43, 42, 41, 40
286};
287
288static void digitalker_write(digitalker *dg, UINT8 *adr, UINT8 vol, INT8 dac)
289{
290   INT16 v;
291   dac &= 15;
292   if(dac >= 9)
293      v = -pcm_levels[vol][15-dac];
294   else if(dac)
295      v = pcm_levels[vol][dac-1];
296   else
297      v = 0;
298   dg->dac[(*adr)++] = v;
299}
300
301static UINT8 digitalker_pitch_next(UINT8 val, UINT8 prev, int step)
302{
303   int delta, nv;
304
305   delta = val & 0xf;
306   if(delta > step + 1)
307      delta = step + 1;
308   if(val & 0x10)
309      delta = -delta;
310
311   nv = prev + delta;
312   if(nv < 0)
313      nv = 0;
314   else if(nv > 31)
315      nv = 31;
316   return nv;
317}
318
319static void digitalker_set_intr(digitalker *dg, UINT8 intr)
320{
321   dg->intr = intr;
322}
323
324static void digitalker_start_command(digitalker *dg, UINT8 cmd)
325{
326   dg->bpos = ((dg->rom[cmd*2] << 8) | dg->rom[cmd*2+1]) & 0x3fff;
327   dg->cur_segment = dg->segments = dg->cur_repeat = dg->repeats = 0;
328   dg->dac_index = 128;
329   dg->zero_count = 0;
330   digitalker_set_intr(dg, 0);
331}
332
333static void digitalker_step_mode_0(digitalker *dg)
334{
335   INT8 dac = 0;
336   int i, k, l;
337   UINT8 wpos = 0;
338   UINT8 h = dg->rom[dg->apos];
339   UINT16 bits = 0x80;
340   UINT8 vol = h >> 5;
341   UINT8 pitch_id = dg->cur_segment ? digitalker_pitch_next(h, dg->prev_pitch, dg->cur_repeat) : h & 0x1f;
342
343   dg->pitch = pitch_vals[pitch_id];
344
345   for(i=0; i<32; i++)
346      dg->dac[wpos++] = 0;
347
348   for(k=1; k != 9; k++) {
349      bits |= dg->rom[dg->apos+k] << 8;
350      for(l=0; l<4; l++) {
351         dac += delta1[(bits >> (6+2*l)) & 15];
352         digitalker_write(dg, &wpos, vol, dac);
353      }
354      bits >>= 8;
355   }
356
357   digitalker_write(dg, &wpos, vol, dac);
358
359   for(k=7; k >= 0; k--) {
360      bits = (bits << 8) | (k ? dg->rom[dg->apos+k] : 0x80);
361      for(l=3; l>=0; l--) {
362         dac -= delta1[(bits >> (6+2*l)) & 15];
363         digitalker_write(dg, &wpos, vol, dac);
364      }
365   }
366
367   for(i=0; i<31; i++)
368      dg->dac[wpos++] = 0;
369
370   dg->cur_repeat++;
371   if(dg->cur_repeat == dg->repeats) {
372      dg->apos += 9;
373      dg->prev_pitch = pitch_id;
374      dg->cur_repeat = 0;
375      dg->cur_segment++;
376   }
377}
378
379static void digitalker_step_mode_1(digitalker *dg)
380{
381   logerror("Digitalker mode 1 unsupported");
382   dg->zero_count = 1;
383   dg->cur_segment = dg->segments;
384}
385
386static void digitalker_step_mode_2(digitalker *dg)
387{
388   INT8 dac = 0;
389   int k, l;
390   UINT8 wpos=0;
391   UINT8 h = dg->rom[dg->apos];
392   UINT16 bits = 0x80;
393   UINT8 vol = h >> 5;
394   UINT8 pitch_id = dg->cur_segment ? digitalker_pitch_next(h, dg->prev_pitch, dg->cur_repeat) : h & 0x1f;
395
396   dg->pitch = pitch_vals[pitch_id];
397
398   for(k=1; k != 9; k++) {
399      bits |= dg->rom[dg->apos+k] << 8;
400      for(l=0; l<4; l++) {
401         dac += delta1[(bits >> (6+2*l)) & 15];
402         digitalker_write(dg, &wpos, vol, dac);
403      }
404      bits >>= 8;
405   }
406
407   digitalker_write(dg, &wpos, vol, dac);
408
409   for(k=7; k >= 0; k--) {
410      bits = (bits << 8) | (k ? dg->rom[dg->apos+k] : 0x80);
411      for(l=3; l>=0; l--) {
412         dac -= delta1[(bits >> (6+2*l)) & 15];
413         digitalker_write(dg, &wpos, vol, dac);
414      }
415   }
416
417   digitalker_write(dg, &wpos, vol, dac);
418
419   for(k=1; k != 9; k++) {
420      bits |= dg->rom[dg->apos+k] << 8;
421      for(l=0; l<4; l++) {
422         dac += delta1[(bits >> (6+2*l)) & 15];
423         digitalker_write(dg, &wpos, vol, dac);
424      }
425      bits >>= 8;
426   }
427
428   digitalker_write(dg, &wpos, vol, dac);
429
430   for(k=7; k >= 0; k--) {
431      bits = (bits << 8) | (k ? dg->rom[dg->apos+k] : 0x80);
432      for(l=3; l>=0; l--) {
433         dac -= delta1[(bits >> (6+2*l)) & 15];
434         digitalker_write(dg, &wpos, vol, dac);
435      }
436   }
437
438   dg->cur_repeat++;
439   if(dg->cur_repeat == dg->repeats) {
440      dg->apos += 9;
441      dg->prev_pitch = pitch_id;
442      dg->cur_repeat = 0;
443      dg->cur_segment++;
444   }
445}
446
447static void digitalker_step_mode_3(digitalker *dg)
448{
449   UINT8 h = dg->rom[dg->apos];
450   UINT8 vol = h >> 5;
451   UINT16 bits;
452   UINT8 dac, apos, wpos;
453   int k, l;
454
455   dg->pitch = pitch_vals[h & 0x1f];
456   if(dg->cur_segment == 0 && dg->cur_repeat == 0) {
457      dg->cur_bits = 0x40;
458      dg->cur_dac = 0;
459   }
460   bits = dg->cur_bits;
461   dac = 0;
462
463   apos = dg->apos + 1 + 32*dg->cur_segment;
464   wpos = 0;
465   for(k=0; k != 32; k++) {
466      bits |= dg->rom[apos++] << 8;
467      for(l=0; l<4; l++) {
468         dac += delta2[(bits >> (6+2*l)) & 15];
469         digitalker_write(dg, &wpos, vol, dac);
470      }
471      bits >>= 8;
472   }
473
474   dg->cur_bits = bits;
475   dg->cur_dac = dac;
476
477   dg->cur_segment++;
478   if(dg->cur_segment == dg->segments) {
479      dg->cur_segment = 0;
480      dg->cur_repeat++;
481   }
482}
483
484static void digitalker_step(digitalker *dg)
485{
486   if(dg->cur_segment == dg->segments || dg->cur_repeat == dg->repeats) {
487      if(dg->stop_after == 0 && dg->bpos == 0xffff)
488         return;
489      if(dg->stop_after == 0) {
490         UINT8 v1 = dg->rom[dg->bpos++];
491         UINT8 v2 = dg->rom[dg->bpos++];
492         UINT8 v3 = dg->rom[dg->bpos++];
493         dg->apos = v2 | ((v3 << 8) & 0x3f00);
494         dg->segments = (v1 & 15) + 1;
495         dg->repeats = ((v1 >> 4) & 7) + 1;
496         dg->mode = (v3 >> 6) & 3;
497         dg->stop_after = (v1 & 0x80) != 0;
498
499         dg->cur_segment = 0;
500         dg->cur_repeat = 0;
501
502         if(!dg->apos) {
503            dg->zero_count = 40*128*dg->segments*dg->repeats;
504            dg->segments = 0;
505            dg->repeats = 0;
506            return;
507         }
508      } else if(dg->stop_after == 1) {
509         dg->bpos = 0xffff;
510         dg->zero_count = 81920;
511         dg->stop_after = 2;
512         dg->cur_segment = 0;
513         dg->cur_repeat = 0;
514         dg->segments = 0;
515         dg->repeats = 0;
516      } else {
517         dg->stop_after = 0;
518         digitalker_set_intr(dg, 1);
519      }
520   }
521
522   switch(dg->mode) {
523   case 0: digitalker_step_mode_0(dg); break;
524   case 1: digitalker_step_mode_1(dg); break;
525   case 2: digitalker_step_mode_2(dg); break;
526   case 3: digitalker_step_mode_3(dg); break;
527   }
528   if(!dg->zero_count)
529      dg->dac_index = 0;
530}
531
532static STREAM_UPDATE(digitalker_update)
533{
534   digitalker *dg = param;
535   stream_sample_t *sout = outputs[0];
536   int cpos = 0;
537   while(cpos != samples) {
538      if(dg->zero_count == 0 && dg->dac_index == 128)
539         digitalker_step(dg);
540
541      if(dg->zero_count) {
542         int n = samples - cpos;
543         int i;
544         if(n > dg->zero_count)
545            n = dg->zero_count;
546         for(i=0; i != n; i++)
547            sout[cpos++] = 0;
548         dg->zero_count -= n;
549
550      } else if(dg->dac_index != 128) {
551         while(cpos != samples && dg->dac_index != 128) {
552            short v = dg->dac[dg->dac_index];
553            int pp = dg->pitch_pos;
554            while(cpos != samples && pp != dg->pitch) {
555               sout[cpos++] = v;
556               pp++;
557            }
558            if(pp == dg->pitch) {
559               pp = 0;
560               dg->dac_index++;
561            }
562            dg->pitch_pos = pp;
563         }
564
565      } else {
566         while(cpos != samples)
567            sout[cpos++] = 0;
568      }
569   }
570}
571
572static void digitalker_data_w(digitalker *dg, UINT8 data)
573{
574   dg->data = data;
575}
576
577static void digitalker_cs_w(digitalker *dg, int line)
578{
579   UINT8 cs = line == ASSERT_LINE ? 1 : 0;
580   if(cs == dg->cs)
581      return;
582   dg->cs = cs;
583   if(cs)
584      return;
585   if(!dg->wr) {
586      if(dg->cms)
587         digitalker_set_intr(dg, 1);
588      else
589         digitalker_start_command(dg, dg->data);
590   }
591}
592
593static void digitalker_cms_w(digitalker *dg, int line)
594{
595   dg->cms = line == ASSERT_LINE ? 1 : 0;
596}
597
598static void digitalker_wr_w(digitalker *dg, int line)
599{
600   UINT8 wr = line == ASSERT_LINE ? 1 : 0;
601   if(wr == dg->wr)
602      return;
603   dg->wr = wr;
604   if(wr || dg->cs)
605      return;
606   if(dg->cms)
607      digitalker_set_intr(dg, 1);
608   else
609      digitalker_start_command(dg, dg->data);
610}
611
612static int digitalker_intr_r(digitalker *dg)
613{
614   return dg->intr ? ASSERT_LINE : CLEAR_LINE;
615}
616
617static void digitalker_register_for_save(digitalker *dg)
618{
619   state_save_register_device_item(dg->device, 0, dg->data);
620   state_save_register_device_item(dg->device, 0, dg->cs);
621   state_save_register_device_item(dg->device, 0, dg->cms);
622   state_save_register_device_item(dg->device, 0, dg->wr);
623   state_save_register_device_item(dg->device, 0, dg->intr);
624   state_save_register_device_item(dg->device, 0, dg->bpos);
625   state_save_register_device_item(dg->device, 0, dg->apos);
626   state_save_register_device_item(dg->device, 0, dg->mode);
627   state_save_register_device_item(dg->device, 0, dg->cur_segment);
628   state_save_register_device_item(dg->device, 0, dg->cur_repeat);
629   state_save_register_device_item(dg->device, 0, dg->segments);
630   state_save_register_device_item(dg->device, 0, dg->repeats);
631   state_save_register_device_item(dg->device, 0, dg->prev_pitch);
632   state_save_register_device_item(dg->device, 0, dg->pitch);
633   state_save_register_device_item(dg->device, 0, dg->pitch_pos);
634   state_save_register_device_item(dg->device, 0, dg->stop_after);
635   state_save_register_device_item(dg->device, 0, dg->cur_dac);
636   state_save_register_device_item(dg->device, 0, dg->cur_bits);
637   state_save_register_device_item(dg->device, 0, dg->zero_count);
638   state_save_register_device_item(dg->device, 0, dg->dac_index);
639   state_save_register_device_item_array(dg->device, 0, dg->dac);
640}
641
642static SND_START(digitalker)
643{
644   digitalker *dg = auto_malloc(sizeof(*dg));
645   memset(dg, 0, sizeof(*dg));
646   dg->device = device;
647   dg->rom = memory_region(device->machine, device->tag);
648   dg->stream = stream_create(device, 0, 1, clock/4, dg, digitalker_update);
649   dg->dac_index = 128;
650   dg->data = 0xff;
651   dg->cs = dg->cms = dg->wr = 1;
652   dg->bpos = 0xffff;
653   digitalker_set_intr(dg, 1);
654
655   digitalker_register_for_save(dg);
656
657   return dg;
658}
659
660static SND_SET_INFO(digitalker)
661{
662   /* no parameters to set */
663}
664
665SND_GET_INFO(digitalker)
666{
667   switch(state) {
668   case SNDINFO_PTR_SET_INFO:      info->set_info = SND_SET_INFO_NAME(digitalker); break;
669   case SNDINFO_PTR_START:         info->start = SND_START_NAME(digitalker); break;
670   case SNDINFO_PTR_STOP:         break;
671   case SNDINFO_PTR_RESET:        break;
672   case SNDINFO_STR_NAME:         strcpy(info->s, "Digitalker"); break;
673   case SNDINFO_STR_CORE_FAMILY:   strcpy(info->s, "National Semiconductor"); break;
674   case SNDINFO_STR_CORE_VERSION:   strcpy(info->s, "1.0"); break;
675   case SNDINFO_STR_CORE_FILE:      strcpy(info->s, __FILE__); break;
676   case SNDINFO_STR_CORE_CREDITS:   strcpy(info->s, "Copyright Olivier Galibert"); break;
677   }
678}
679
680void digitalker_0_cs_w(int line)
681{
682   digitalker *dg = sndti_token(SOUND_DIGITALKER, 0);
683   digitalker_cs_w(dg, line);
684}
685
686void digitalker_0_cms_w(int line)
687{
688   digitalker *dg = sndti_token(SOUND_DIGITALKER, 0);
689   digitalker_cms_w(dg, line);
690}
691
692void digitalker_0_wr_w(int line)
693{
694   digitalker *dg = sndti_token(SOUND_DIGITALKER, 0);
695   digitalker_wr_w(dg, line);
696}
697
698int digitalker_0_intr_r(void)
699{
700   digitalker *dg = sndti_token(SOUND_DIGITALKER, 0);
701   return digitalker_intr_r(dg);
702}
703
704WRITE8_HANDLER(digitalker_0_data_w)
705{
706   digitalker *dg = sndti_token(SOUND_DIGITALKER, 0);
707   digitalker_data_w(dg, data);
708}
src/emu/sound/cem3394.h
r4135r4136
1313{
1414   double vco_zero_freq;            /* frequency at 0V for VCO */
1515   double filter_zero_freq;         /* frequency at 0V for filter */
16   void (*external)(int, int, short *);/* external input source */
16   void (*external)(const device_config *, int, short *);/* external input source */
1717};
1818
1919/* inputs */
r4135r4136
4444double cem3394_get_parameter(int chip, int input);
4545
4646SND_GET_INFO( cem3394 );
47#define SOUND_CEM3394 SND_GET_INFO_NAME( cem3394 )
4748
4849#endif /* __CEM3394_H__ */
src/emu/sound/saa1099.h
r4135r4136
1818WRITE16_HANDLER( saa1099_write_port_1_lsb_w );
1919
2020SND_GET_INFO( saa1099 );
21#define SOUND_SAA1099 SND_GET_INFO_NAME( saa1099 )
2122
2223#endif /* __SAA1099_H__ */
src/emu/sound/digitalk.h
r0r4136
1#ifndef _DIGITALKER_H_
2#define _DIGITALKER_H_
3
4void digitalker_0_cs_w(int line);
5void digitalker_0_cms_w(int line);
6void digitalker_0_wr_w(int line);
7int digitalker_0_intr_r(void);
8WRITE8_HANDLER(digitalker_0_data_w);
9
10SND_GET_INFO(digitalker);
11#define SOUND_DIGITALKER SND_GET_INFO_NAME(digitalker)
12
13#endif
src/emu/sound/ymz280b.c
r4135r4136
9191   void (*irq_callback)(running_machine *, int);      /* IRQ callback */
9292   struct YMZ280BVoice   voice[8];   /* the 8 voices */
9393   UINT32 rom_readback_addr;      /* where the CPU can read the ROM */
94   read8_space_func ext_ram_read;      /* external RAM read handler */
95   write8_space_func ext_ram_write;   /* external RAM write handler */
94   read8_device_func ext_ram_read;      /* external RAM read handler */
95   write8_device_func ext_ram_write;   /* external RAM write handler */
9696
9797#if MAKE_WAVS
9898   void *      wavresample;         /* resampled waveform */
r4135r4136
868868         case 0x87:      /* RAM write */
869869            if (chip->ext_ram_write)
870870            {
871               /* temporary hack until this is converted to a device */
872               const address_space *space = memory_find_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
873               chip->ext_ram_write(space, chip->rom_readback_addr, data);
871               chip->ext_ram_write(chip->device, chip->rom_readback_addr, data);
874872            }
875873            else
876874               logerror("YMZ280B attempted RAM write to %X\n", chip->rom_readback_addr);
r4135r4136
10811079{
10821080   UINT8 data;
10831081   struct YMZ280BChip *chip = sndti_token(SOUND_YMZ280B, 0);
1084   data = chip->ext_ram_read(space, chip->rom_readback_addr - 1);
1082   data = chip->ext_ram_read(chip->device, chip->rom_readback_addr - 1);
10851083   chip->rom_readback_addr++;
10861084   return data;
10871085}
r4135r4136
10901088{
10911089   UINT8 data;
10921090   struct YMZ280BChip *chip = sndti_token(SOUND_YMZ280B, 1);
1093   data = chip->ext_ram_read(space, chip->rom_readback_addr - 1);
1091   data = chip->ext_ram_read(chip->device, chip->rom_readback_addr - 1);
10941092   chip->rom_readback_addr++;
10951093   return data;
10961094}
src/emu/sound/ymz280b.h
r4135r4136
1515struct _ymz280b_interface
1616{
1717   void (*irq_callback)(running_machine *machine, int state);   /* irq callback */
18   read8_space_func ext_read;         /* external RAM read */
19   write8_space_func ext_write;      /* external RAM write */
18   read8_device_func ext_read;         /* external RAM read */
19   write8_device_func ext_write;      /* external RAM write */
2020};
2121
2222READ8_HANDLER ( ymz280b_status_0_r );
r4135r4136
4444WRITE16_HANDLER( ymz280b_data_1_msb_w );
4545
4646SND_GET_INFO( ymz280b );
47#define SOUND_YMZ280B SND_GET_INFO_NAME( ymz280b )
4748
4849#endif /* __YMZ280B_H__ */
src/emu/sound/rf5c68.h
r4135r4136
1414WRITE8_HANDLER( rf5c68_w );
1515
1616SND_GET_INFO( rf5c68 );
17#define SOUND_RF5C68 SND_GET_INFO_NAME( rf5c68 )
1718
1819#endif /* __RF5C68_H__ */
src/emu/sound/ymf262.c
r4135r4136
16351635      {
16361636      case 0x101:   /* test register */
16371637         return;
1638      break;
1638
16391639      case 0x104:   /* 6 channels enable */
16401640         {
16411641            UINT8 prev;
r4135r4136
16751675
16761676         }
16771677         return;
1678      break;
1678
16791679      case 0x105:   /* OPL3 extensions enable register */
16801680
16811681         chip->OPL3_mode = v&0x01;   /* OPL3 mode when bit0=1 otherwise it is OPL2 mode */
r4135r4136
16891689            */
16901690
16911691         return;
1692      break;
16931692
16941693      default:
16951694         if (r < 0x120)
src/emu/sound/k005289.h
r4135r4136
1111WRITE8_HANDLER( k005289_keylatch_B_w );
1212
1313SND_GET_INFO( k005289 );
14#define SOUND_K005289 SND_GET_INFO_NAME( k005289 )
1415
1516#endif /* __K005289_H__ */
src/emu/sound/votrax.h
r4135r4136
77int votrax_status_r(void);
88
99SND_GET_INFO( votrax );
10#define SOUND_VOTRAX SND_GET_INFO_NAME( votrax )
1011
1112#endif /* __VOTRAX_H__ */
src/emu/sound/aica.c
r4135r4136
513513
514514#define log_base_2(n) (log((float) n)/log((float) 2))
515515
516static void AICA_Init(const device_config *device, struct _AICA *AICA, const aica_interface *intf, int sndindex)
516static void AICA_Init(const device_config *device, struct _AICA *AICA, const aica_interface *intf)
517517{
518518   int i;
519519
r4135r4136
524524
525525   // get AICA RAM
526526   {
527      if (sndindex == 0)
528      {
529         AICA->Master=1;
530      }
531      else
532      {
533         AICA->Master=0;
534      }
527      AICA->Master = intf->master;
535528
536529      AICA->AICARAM = device->region;
537530      if (AICA->AICARAM)
r4135r4136
12951288   intf = config;
12961289
12971290   // init the emulation
1298   AICA_Init(device, AICA, intf, sndindex);
1291   AICA_Init(device, AICA, intf);
12991292
13001293   // set up the IRQ callbacks
13011294   {
src/emu/sound/sn76496.c
r4135r4136
392392   switch (state)
393393   {
394394      /* --- the following bits of info are returned as 64-bit signed integers --- */
395      case SNDINFO_INT_ALIAS:                     info->i = SOUND_SN76496;                  break;
395      case SNDINFO_FCT_ALIAS:                     info->type = SOUND_SN76496;                  break;
396396
397397      /* --- the following bits of info are returned as pointers to data or functions --- */
398398      case SNDINFO_PTR_SET_INFO:                  info->set_info = SND_SET_INFO_NAME( sn76496 );   break;
src/emu/sound/aica.h
r4135r4136
1111typedef struct _aica_interface aica_interface;
1212struct _aica_interface
1313{
14   int master;
1415   int roffset;            /* offset in the region */
1516   void (*irq_callback)(running_machine *machine, int state);   /* irq callback */
1617};
r4135r4136
2627READ16_HANDLER( aica_midi_out_r );
2728
2829SND_GET_INFO( aica );
30#define SOUND_AICA SND_GET_INFO_NAME( aica )
2931
3032#endif /* __AICA_H__ */
src/emu/sound/wave.c
r4135r4136
6464   image = device_list_find_by_tag( device->machine->config->devicelist, CASSETTE, device->tag );
6565#endif
6666   stream_create(device, 0, 1, device->machine->sample_rate, (void *)image, wave_sound_update);
67   return (void *) (FPTR)(sndindex | WAVE_TOKEN_MASK);
67   return (void *) (FPTR)(WAVE_TOKEN_MASK);
6868}
6969
7070
src/emu/sound/sn76496.h
r4135r4136
1616SND_GET_INFO( gamegear );
1717SND_GET_INFO( smsiii );
1818
19#define SOUND_SN76496 SND_GET_INFO_NAME( sn76496 )
20#define SOUND_SN76489 SND_GET_INFO_NAME( sn76489 )
21#define SOUND_SN76489A SND_GET_INFO_NAME( sn76489a )
22#define SOUND_SN76494 SND_GET_INFO_NAME( sn76494 )
23#define SOUND_GAMEGEAR SND_GET_INFO_NAME( gamegear )
24#define SOUND_SMSIII SND_GET_INFO_NAME( smsiii )
25
1926#endif /* __SN76496_H__ */
src/emu/sound/wave.h
r4135r4136
1212#endif
1313
1414SND_GET_INFO( wave );
15#define SOUND_WAVE SND_GET_INFO_NAME( wave )
1516
16
1717#endif /* __WAVE_H__ */
src/emu/sound/astrocde.h
r4135r4136
77WRITE8_HANDLER( astrocade_sound2_w );
88
99SND_GET_INFO( astrocade );
10#define SOUND_ASTROCADE SND_GET_INFO_NAME( astrocade )
1011
1112#endif /* __ASTROCDE_H__ */
src/emu/sound/x1_010.h
r4135r4136
2020void seta_sound_enable_w(int);
2121
2222SND_GET_INFO( x1_010 );
23#define SOUND_X1_010 SND_GET_INFO_NAME( x1_010 )
2324
2425#endif /* __X1_010_H__ */
src/emu/sound/ymf271.c
r4135r4136
107107   UINT8 ext_read;
108108
109109   const UINT8 *rom;
110   read8_space_func ext_mem_read;
111   write8_space_func ext_mem_write;
110   read8_device_func ext_mem_read;
111   write8_device_func ext_mem_write;
112112   void (*irq_callback)(running_machine *, int);
113113
114114   UINT32 clock;
r4135r4136
13741374
13751375static UINT8 ymf271_read_ext_memory(YMF271Chip *chip, UINT32 address)
13761376{
1377   /* temporary hack until this is converted to a device */
1378   const address_space *space = memory_find_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
13791377   if( chip->ext_mem_read ) {
1380      return chip->ext_mem_read(space,address);
1378      return chip->ext_mem_read(chip->device,address);
13811379   } else {
13821380      if( address < 0x800000)
13831381         return chip->rom[address];
r4135r4136
13871385
13881386static void ymf271_write_ext_memory(YMF271Chip *chip, UINT32 address, UINT8 data)
13891387{
1390   /* temporary hack until this is converted to a device */
1391   const address_space *space = memory_find_address_space(chip->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
13921388   if( chip->ext_mem_write ) {
1393      chip->ext_mem_write(space, address, data);
1389      chip->ext_mem_write(chip->device, address, data);
13941390   }
13951391}
13961392
r4135r4136
17271723   state_save_register_device_item(device, 0, chip->ext_read);
17281724}
17291725
1730static void ymf271_init(const device_config *device, YMF271Chip *chip, UINT8 *rom, void (*cb)(running_machine *,int), read8_space_func ext_read, write8_space_func ext_write)
1726static void ymf271_init(const device_config *device, YMF271Chip *chip, UINT8 *rom, void (*cb)(running_machine *,int), read8_device_func ext_read, write8_device_func ext_write)
17311727{
17321728   chip->timA = timer_alloc(device->machine, ymf271_timer_a_tick, chip);
17331729   chip->timB = timer_alloc(device->machine, ymf271_timer_b_tick, chip);
src/emu/sound/pokey.c
r4135r4136
204204   attotime clock_period;
205205   attotime ad_time_fast;
206206   attotime ad_time_slow;
207   int index;
208207
209208   UINT8 poly4[0x0f];
210209   UINT8 poly5[0x1f];
r4135r4136
620619      memcpy(&chip->intf, config, sizeof(pokey_interface));
621620   chip->device = device;
622621   chip->clock_period = ATTOTIME_IN_HZ(clock);
623   chip->index = sndindex;
624622
625623   /* calculate the A/D times
626624     * In normal, slow mode (SKCTL bit SK_PADDLE is clear) the conversion
r4135r4136
803801      {
804802         int r = (*p->pot_r[pot])(space, pot);
805803
806         LOG(("POKEY #%d pot_r(%d) returned $%02x\n", p->index, pot, r));
804         LOG(("POKEY %s pot_r(%d) returned $%02x\n", p->device->tag, pot, r));
807805         if( r != -1 )
808806         {
809807            if (r > 228)
src/emu/sound/upd7759.h
r4135r4136
3030READ8_HANDLER( upd7759_0_busy_r );
3131
3232SND_GET_INFO( upd7759 );
33#define SOUND_UPD7759 SND_GET_INFO_NAME( upd7759 )
3334
3435#endif /* __UPD7759_H__ */
src/emu/sound/ymf271.h
r4135r4136
66typedef struct _ymf271_interface ymf271_interface;
77struct _ymf271_interface
88{
9   read8_space_func ext_read;      /* external memory read */
10   write8_space_func ext_write;   /* external memory write */
9   read8_device_func ext_read;      /* external memory read */
10   write8_device_func ext_write;   /* external memory write */
1111   void (*irq_callback)(running_machine *machine, int state);   /* irq callback */
1212};
1313
r4135r4136
1717WRITE8_HANDLER( ymf271_1_w );
1818
1919SND_GET_INFO( ymf271 );
20#define SOUND_YMF271 SND_GET_INFO_NAME( ymf271 )
2021
2122#endif /* __YMF271_H__ */
src/emu/sound/n63701x.h
r4135r4136
66void namco_63701x_write(int offset,int data);
77
88SND_GET_INFO( namco_63701x );
9#define SOUND_NAMCO_63701X SND_GET_INFO_NAME( namco_63701x )
910
1011#endif /* __N63701X_H__ */
src/emu/sound/ay8910.c
r4135r4136
675675   else
676676      info->streams = 3;
677677
678   switch (chip_type)
678   if (chip_type == SOUND_AY8910 || chip_type == SOUND_AY8930)
679679   {
680      case SOUND_AY8910:
681      case SOUND_AY8930:
682         info->step = 2;
683         info->par = &ay8910_param;
684         info->par_env = &ay8910_param;
685         info->zero_is_off = 1;
686         info->env_step_mask = 0x0F;
687         break;
688      case SOUND_YM2149:
689      case SOUND_YM2203:
690      case SOUND_YM2610:
691      case SOUND_YM2610B:
692      case SOUND_YM2608:
693      case SOUND_YMZ284:
694      case SOUND_YMZ294:
695      case SOUND_YM3439:
696      default:
697         info->step = 1;
698         info->par = &ym2149_param;
699         info->par_env = &ym2149_param_env;
700         info->zero_is_off = 0;
701         info->env_step_mask = 0x1F;
702         break;
680      info->step = 2;
681      info->par = &ay8910_param;
682      info->par_env = &ay8910_param;
683      info->zero_is_off = 1;
684      info->env_step_mask = 0x0F;
703685   }
686   else
687   {
688      info->step = 1;
689      info->par = &ym2149_param;
690      info->par_env = &ym2149_param_env;
691      info->zero_is_off = 0;
692      info->env_step_mask = 0x1F;
693   }
704694
705695   build_mixer_table(info);
706696
r4135r4136
867857   switch (state)
868858   {
869859      /* --- the following bits of info are returned as 64-bit signed integers --- */
870      case SNDINFO_INT_ALIAS:                     info->i = SOUND_AY8910;                     break;
860      case SNDINFO_FCT_ALIAS:                     info->type = SOUND_AY8910;                     break;
871861
872862      /* --- the following bits of info are returned as pointers to data or functions --- */
873863      case SNDINFO_PTR_SET_INFO:                  info->set_info = SND_SET_INFO_NAME( ay8910 );   break;
src/emu/sound/pokey.h
r4135r4136
107107void pokey4_kbcode_w (int kbcode, int make);
108108
109109SND_GET_INFO( pokey );
110#define SOUND_POKEY SND_GET_INFO_NAME( pokey )
110111
111112#endif   /* __POKEY_H__ */
src/emu/sound/sp0250.h
r4135r4136
1111UINT8 sp0250_drq_r(void);
1212
1313SND_GET_INFO( sp0250 );
14#define SOUND_SP0250 SND_GET_INFO_NAME( sp0250 )
1415
1516#endif /* __SP0250_H__ */
src/emu/sound/ym2151.c
r4135r4136
1616
1717/*#define FM_EMU*/
1818#ifdef FM_EMU
19   #define INLINE static __inline__
2019   #ifdef USE_MAME_TIMERS
2120      #undef USE_MAME_TIMERS
2221   #endif
src/emu/sound/speaker.h
r4135r4136
2626void speaker_level_w (int which, int new_level);
2727
2828SND_GET_INFO( speaker );
29#define SOUND_SPEAKER SND_GET_INFO_NAME( speaker )
2930
3031#ifdef __cplusplus
3132}
src/emu/sound/ay8910.h
r4135r4136
143143SND_GET_INFO( ymz284 );
144144SND_GET_INFO( ymz294 );
145145
146#define SOUND_AY8910 SND_GET_INFO_NAME( ay8910 )
147#define SOUND_AY8912 SND_GET_INFO_NAME( ay8912 )
148#define SOUND_AY8913 SND_GET_INFO_NAME( ay8913 )
149#define SOUND_AY8930 SND_GET_INFO_NAME( ay8930 )
150#define SOUND_YM2149 SND_GET_INFO_NAME( ym2149 )
151#define SOUND_YM3439 SND_GET_INFO_NAME( ym3439 )
152#define SOUND_YMZ284 SND_GET_INFO_NAME( ymz284 )
153#define SOUND_YMZ294 SND_GET_INFO_NAME( ymz294 )
154
146155#endif /* __AY8910_H__ */
src/emu/sound/cdda.h
r4135r4136
1616int cdda_audio_ended(int num);
1717
1818SND_GET_INFO( cdda );
19#define SOUND_CDDA SND_GET_INFO_NAME( cdda )
1920
2021#endif /* __CDDA_H__ */
src/emu/sound/tms36xx.h
r4135r4136
2727extern void tms3617_enable_w(int chip, int enable);
2828
2929SND_GET_INFO( tms36xx );
30#define SOUND_TMS36XX SND_GET_INFO_NAME( tms36xx )
3031
3132#endif /* __TMS36XX_H__ */
src/emu/sound/discrete.c
r4135r4136
255255   memset(info, 0, sizeof(*info));
256256
257257   info->device = device;
258   info->sndindex = sndindex;
259258
260259   /* If a clock is specified we will use it, otherwise run at the audio sample rate. */
261260   if (clock)
r4135r4136
266265   info->neg_sample_time = - info->sample_time;
267266
268267   /* create the logfile */
269   sprintf(name, "discrete%d.log", info->sndindex);
268   sprintf(name, "discrete%s.log", device->tag);
270269   if (DISCRETE_DEBUGLOG && !info->disclogfile)
271270      info->disclogfile = fopen(name, "w");
272271
r4135r4136
714713
715714   for (log_num = 0; log_num < info->num_csvlogs; log_num++)
716715   {
717      sprintf(name, "discrete%d_%d.csv", info->sndindex, log_num);
716      sprintf(name, "discrete%s_%d.csv", info->device->tag, log_num);
718717      info->disc_csv_file[log_num] = fopen(name, "w");
719718      /* Output some header info */
720719      fprintf(info->disc_csv_file[log_num], "\"MAME Discrete System Node Log\"\n");
r4135r4136
731730
732731   for (log_num = 0; log_num < info->num_wavelogs; log_num++)
733732   {
734      sprintf(name, "discrete%d_%d.wav", info->sndindex, log_num);
733      sprintf(name, "discrete%s_%d.wav", info->device->tag, log_num);
735734      info->disc_wav_file[log_num] = wav_open(name, info->sample_rate, info->wavelog_node[log_num]->active_inputs/2);
736735   }
737736}
src/emu/sound/st0016.h
r4135r4136
1414WRITE8_HANDLER(st0016_snd_w);
1515
1616SND_GET_INFO( st0016 );
17#define SOUND_ST0016 SND_GET_INFO_NAME( st0016 )
1718
1819#endif /* __ST0016_H__ */
src/emu/sound/tiaintf.h
r4135r4136
66WRITE8_HANDLER( tia_sound_w );
77
88SND_GET_INFO( tia );
9#define SOUND_TIA SND_GET_INFO_NAME( tia )
910
1011#endif /* __TIAINTF_H__ */
src/emu/sound/c6280.h
r4135r4136
99READ8_HANDLER( c6280_r );
1010
1111SND_GET_INFO( c6280 );
12#define SOUND_C6280 SND_GET_INFO_NAME( c6280 )
1213
1314#endif /* __C6280_H__ */
src/emu/sound/discrete.h
r4135r4136
31863186 *  Use this to monitor nodes while debugging the driver.  You should
31873187 *  remove these nodes from the final driver.  You can use up to a maximum
31883188 *  DISCRETE_MAX_CSVLOGS.  Each file will be called discreteX_Y.csv,
3189 *  where X is the sndindex.  Y is 0-9, in the order the file is
3189 *  where X is the sound tag.  Y is 0-9, in the order the file is
31903190 *  created in the driver.
31913191 *
31923192 *  This can be used to monitor how multiple nodes relate to each other.
r4135r4136
32093209 *  Use this to monitor nodes while debugging the driver.  You should
32103210 *  remove these nodes from the final driver.  You can use up to a maximum
32113211 *  of DISCRETE_MAX_WAVELOGS.  Each file will be called discreteX_Y.wav,
3212 *  where X is the sndindex.  Y is 0-9, in the order the file is
3212 *  where X is the sound tag.  Y is 0-9, in the order the file is
32133213 *  created in the driver.
32143214 *
32153215 *  This can be used to monitor how a node's input affects it's output.
r4135r4136
35863586   const device_config *device;
35873587
35883588   /* emulation info */
3589   int      sndindex;
35903589   int      sample_rate;
35913590   double   sample_time;
35923591   double   neg_sample_time;
r4135r4136
43064305READ8_HANDLER(discrete_sound_3_r);
43074306
43084307SND_GET_INFO( discrete );
4308#define SOUND_DISCRETE SND_GET_INFO_NAME( discrete )
43094309
43104310#endif /* __DISCRETE_H__ */
src/emu/sound/scsp.c
r4135r4136
509509
510510#define log_base_2(n) (log((double)(n))/log(2.0))
511511
512static void SCSP_Init(const device_config *device, struct _SCSP *SCSP, const scsp_interface *intf, int sndindex)
512static void SCSP_Init(const device_config *device, struct _SCSP *SCSP, const scsp_interface *intf)
513513{
514514   int i;
515515
r4135r4136
521521   SCSP->MidiOutR=SCSP->MidiOutW=0;
522522
523523   // get SCSP RAM
524   if (sndindex == 0)
524   if (strcmp(device->tag, "scsp") == 0 || strcmp(device->tag, "scsp1") == 0)
525525   {
526526      SCSP->Master=1;
527527   }
r4135r4136
12331233   intf = config;
12341234
12351235   // init the emulation
1236   SCSP_Init(device, SCSP, intf, sndindex);
1236   SCSP_Init(device, SCSP, intf);
12371237
12381238   // set up the IRQ callbacks
12391239   {
src/emu/sound/samples.h
r4135r4136
5353struct loaded_samples *readsamples(const char *const *samplenames, const char *name);
5454
5555SND_GET_INFO( samples );
56#define SOUND_SAMPLES SND_GET_INFO_NAME( samples )
5657
5758#endif /* __SAMPLES_H__ */
src/emu/sound/msm5232.h
r4135r4136
1616void msm5232_set_clock(void *chip, int clock);
1717
1818SND_GET_INFO( msm5232 );
19#define SOUND_MSM5232 SND_GET_INFO_NAME( msm5232 )
1920
2021#endif /* __MSM5232_H__ */
src/emu/sound/scsp.h
r4135r4136
2929extern UINT32* stv_scu;
3030
3131SND_GET_INFO( scsp );
32#define SOUND_SCSP SND_GET_INFO_NAME( scsp )
3233
3334#endif /* __SCSP_H__ */
src/emu/sound/flt_rc.h
r4135r4136
5959void filter_rc_set_RC(int num, int type, double R1, double R2, double R3, double C);
6060
6161SND_GET_INFO( filter_rc );
62#define SOUND_FILTER_RC SND_GET_INFO_NAME( filter_rc )
6263
6364#endif /* __FLT_RC_H__ */
src/emu/sound/2610intf.h
r4135r4136
5353SND_GET_INFO( ym2610 );
5454SND_GET_INFO( ym2610b );
5555
56#define SOUND_YM2610 SND_GET_INFO_NAME( ym2610 )
57#define SOUND_YM2610B SND_GET_INFO_NAME( ym2610b )
5658
5759#endif /* __2610INTF_H__ */
src/emu/sound/beep.h
r4135r4136
1212void beep_set_volume(int,int);
1313
1414SND_GET_INFO( beep );
15#define SOUND_BEEP SND_GET_INFO_NAME( beep )
1516
1617#ifdef __cplusplus
1718}
src/emu/sound/ics2115.c
r4135r4136
4545{
4646   const ics2115_interface *intf;
4747   const device_config *device;
48   int index;
4948   UINT8 *rom;
5049   INT16 *ulaw;
5150
r4135r4136
450449
451450   chip->device = device;
452451   chip->intf = config;
453   chip->index = sndindex;
454452   chip->rom = device->region;
455453   chip->timer[0].timer = timer_alloc(device->machine, timer_cb_0, chip);
456454   chip->timer[1].timer = timer_alloc(device->machine, timer_cb_1, chip);
src/emu/sound/tms3615.h
r4135r4136
99#define TMS3615_FOOTAGE_16   1
1010
1111SND_GET_INFO( tms3615 );
12#define SOUND_TMS3615 SND_GET_INFO_NAME( tms3615 )
1213
1314#endif /* __TMS3615_H__ */
src/emu/sound/s14001a.c
r4135r4136
236236
237237typedef struct
238238{
239   int index;
240239   sound_stream * stream;
241240
242241   UINT8 WordInput; // value on word input bus
r4135r4136
565564
566565   chip = auto_malloc(sizeof(*chip));
567566   memset(chip, 0, sizeof(*chip));
568   chip->index = sndindex;
569567
570568   chip->GlobalSilenceState = 1;
571569   chip->OldDelta = 0x02;
src/emu/sound/ics2115.h
r4135r4136
1212WRITE8_HANDLER( ics2115_w );
1313
1414SND_GET_INFO( ics2115 );
15#define SOUND_ICS2115 SND_GET_INFO_NAME( ics2115 )
1516
1617#endif /* __ICS2115_H__ */
src/emu/sound/dac.h
r4135r4136
1616WRITE8_HANDLER( dac_2_signed_data_w );
1717
1818SND_GET_INFO( dac );
19#define SOUND_DAC SND_GET_INFO_NAME( dac )
1920
2021#endif /* __DAC_H__ */
src/emu/sound/s14001a.h
r4135r4136
1010void s14001a_set_volume(int volume);    /* set VSU-1000 volume control */
1111
1212SND_GET_INFO( s14001a );
13#define SOUND_S14001A SND_GET_INFO_NAME( s14001a )
1314
1415#endif /* __S14001A_H__ */
1516
src/emu/sound/gaelco.h
r4135r4136
1818SND_GET_INFO( gaelco_gae1 );
1919SND_GET_INFO( gaelco_cg1v );
2020
21#define SOUND_GAELCO_GAE1 SND_GET_INFO_NAME( gaelco_gae1 )
22#define SOUND_GAELCO_CG1V SND_GET_INFO_NAME( gaelco_cg1v )
23
2124#endif /* __GALELCO_H__ */
src/emu/sound/fm.h
r4135r4136
8585#endif /* OSD_CPU_H */
8686#endif
8787
88#ifndef INLINE
89#define INLINE static __inline__
90#endif
9188
9289
93
94
9590typedef stream_sample_t FMSAMPLE;
9691/*
9792#if (FM_SAMPLE_BITS==16)
src/emu/sound/bsmt2000.h
r4135r4136
1313WRITE16_HANDLER( bsmt2000_data_0_w );
1414
1515SND_GET_INFO( bsmt2000 );
16#define SOUND_BSMT2000 SND_GET_INFO_NAME( bsmt2000 )
1617
1718#endif /* __BSMT2000_H__ */
src/emu/sound/dmadac.h
r4135r4136
1616void dmadac_set_volume(UINT8 first_channel, UINT8 num_channels, UINT16 volume);
1717
1818SND_GET_INFO( dmadac );
19#define SOUND_DMADAC SND_GET_INFO_NAME( dmadac )
1920
2021#endif /* __DMADAC_H__ */
src/emu/sound/okim6376.c
r0r4136
1/**********************************************************************************************
2 *
3 *   OKI MSM6376 ADPCM
4 *   by Mirko Buffoni
5 *
6 *   TODO:
7 *     add BEEP tone generator
8 *     add 2ch handling (for echoing and continuous speech)
9 *
10 **********************************************************************************************/
11
12
13#include <math.h>
14
15#include "sndintrf.h"
16#include "streams.h"
17#include "okim6376.h"
18
19#define MAX_SAMPLE_CHUNK   10000
20#define MAX_WORDS           111
21
22
23/* struct describing a single playing ADPCM voice */
24struct ADPCMVoice
25{
26   UINT8 playing;         /* 1 if we are actively playing */
27
28   UINT32 base_offset;      /* pointer to the base memory location */
29   UINT32 sample;         /* current sample number */
30   UINT32 count;         /* total samples to play */
31
32   UINT32 volume;         /* output volume */
33   INT32 signal;
34   INT32 step;
35};
36
37struct okim6376
38{
39   #define OKIM6376_VOICES      2
40   struct ADPCMVoice voice[OKIM6376_VOICES];
41   INT32 command;
42   UINT8 *region_base;      /* pointer to the base of the region */
43   sound_stream *stream;   /* which stream are we playing on? */
44   UINT32 master_clock;   /* master clock frequency */
45};
46
47/* step size index shift table */
48static const int index_shift[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };
49
50/* lookup table for the precomputed difference */
51static int diff_lookup[49*16];
52
53/* volume lookup table. Upon configuration, the number of ST pulses determine how much
54   attenuation to apply to the sound signal. */
55static int volume_table[4] =
56{
57   0x10,   //   0 dB
58   0x08,   //  -6.0 dB
59   0x04,   // -12.0 dB
60   0x02,   // -24.0 dB
61};
62
63/* tables computed? */
64static int tables_computed = 0;
65
66
67
68/**********************************************************************************************
69
70     compute_tables -- compute the difference tables
71
72***********************************************************************************************/
73
74static void compute_tables(void)
75{
76   /* nibble to bit map */
77   static const int nbl2bit[16][4] =
78   {
79      { 1, 0, 0, 0}, { 1, 0, 0, 1}, { 1, 0, 1, 0}, { 1, 0, 1, 1},
80      { 1, 1, 0, 0}, { 1, 1, 0, 1}, { 1, 1, 1, 0}, { 1, 1, 1, 1},
81      {-1, 0, 0, 0}, {-1, 0, 0, 1}, {-1, 0, 1, 0}, {-1, 0, 1, 1},
82      {-1, 1, 0, 0}, {-1, 1, 0, 1}, {-1, 1, 1, 0}, {-1, 1, 1, 1}
83   };
84
85   int step, nib;
86
87   /* loop over all possible steps */
88   for (step = 0; step <= 48; step++)
89   {
90      /* compute the step value */
91      int stepval = floor(16.0 * pow(11.0 / 10.0, (double)step));
92
93      /* loop over all nibbles and compute the difference */
94      for (nib = 0; nib < 16; nib++)
95      {
96         diff_lookup[step*16 + nib] = nbl2bit[nib][0] *
97            (stepval   * nbl2bit[nib][1] +
98             stepval/2 * nbl2bit[nib][2] +
99             stepval/4 * nbl2bit[nib][3] +
100             stepval/8);
101      }
102   }
103
104   tables_computed = 1;
105}
106
107
108
109/**********************************************************************************************
110
111     reset_adpcm -- reset the ADPCM stream
112
113***********************************************************************************************/
114
115static void reset_adpcm(struct ADPCMVoice *voice)
116{
117   /* make sure we have our tables */
118   if (!tables_computed)
119      compute_tables();
120
121   /* reset the signal/step */
122   voice->signal = -2;
123   voice->step = 0;
124}
125
126
127
128/**********************************************************************************************
129
130     clock_adpcm -- clock the next ADPCM byte
131
132***********************************************************************************************/
133
134static INT16 clock_adpcm(struct ADPCMVoice *voice, UINT8 nibble)
135{
136   voice->signal += diff_lookup[voice->step * 16 + (nibble & 15)];
137
138   /* clamp to the maximum 12bit */
139   if (voice->signal > 4095)
140      voice->signal = 4095;
141   else if (voice->signal < -4096)
142      voice->signal = -4096;
143
144   /* adjust the step size and clamp */
145   voice->step += index_shift[nibble & 7];
146   if (voice->step > 48)
147      voice->step = 48;
148   else if (voice->step < 0)
149      voice->step = 0;
150
151   /* return the signal */
152   return voice->signal;
153}
154
155
156
157/**********************************************************************************************
158
159     generate_adpcm -- general ADPCM decoding routine
160
161***********************************************************************************************/
162
163static void generate_adpcm(struct okim6376 *chip, struct ADPCMVoice *voice, INT16 *buffer, int samples)
164{
165   /* if this voice is active */
166   if (voice->playing)
167   {
168      UINT8 *base = chip->region_base + voice->base_offset;
169      int sample = voice->sample;
170      int count = voice->count;
171
172      /* loop while we still have samples to generate */
173      while (samples)
174      {
175         int nibble;
176
177         if (count == 0)
178         {
179            /* get the number of samples to play */
180            count = (base[sample / 2] & 0x7f) << 1;
181
182            /* end of voice marker */
183            if (count == 0)
184            {
185               voice->playing = 0;
186               break;
187            }
188            else
189            {
190               /* step past the count byte */
191               sample += 2;
192            }
193         }
194
195         /* compute the new amplitude and update the current step */
196         nibble = base[sample / 2] >> (((sample & 1) << 2) ^ 4);
197
198         /* output to the buffer, scaling by the volume */
199         /* signal in range -4096..4095, volume in range 2..16 => signal * volume / 2 in range -32768..32767 */
200         *buffer++ = clock_adpcm(voice, nibble) * voice->volume / 2;
201
202         ++sample;
203         --count;
204         --samples;
205      }
206
207      /* update the parameters */
208      voice->sample = sample;
209      voice->count = count;
210   }
211
212   /* fill the rest with silence */
213   while (samples--)
214      *buffer++ = 0;
215}
216
217
218
219/**********************************************************************************************
220
221     okim6376_update -- update the sound chip so that it is in sync with CPU execution
222
223***********************************************************************************************/
224
225static STREAM_UPDATE( okim6376_update )
226{
227   struct okim6376 *chip = param;
228   int i;
229
230   memset(outputs[0], 0, samples * sizeof(*outputs[0]));
231
232   for (i = 0; i < OKIM6376_VOICES; i++)
233   {
234      struct ADPCMVoice *voice = &chip->voice[i];
235      stream_sample_t *buffer = outputs[0];
236      INT16 sample_data[MAX_SAMPLE_CHUNK];
237      int remaining = samples;
238
239      /* loop while we have samples remaining */
240      while (remaining)
241      {
242         int samples = (remaining > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : remaining;
243         int samp;
244
245         generate_adpcm(chip, voice, sample_data, samples);
246         for (samp = 0; samp < samples; samp++)
247            *buffer++ += sample_data[samp];
248
249         remaining -= samples;
250      }
251   }
252}
253
254
255
256/**********************************************************************************************
257
258     state save support for MAME
259
260***********************************************************************************************/
261
262static void adpcm_state_save_register(struct ADPCMVoice *voice, const device_config *device, int index)
263{
264   state_save_register_device_item(device, index, voice->playing);
265   state_save_register_device_item(device, index, voice->sample);
266   state_save_register_device_item(device, index, voice->count);
267   state_save_register_device_item(device, index, voice->signal);
268   state_save_register_device_item(device, index, voice->step);
269   state_save_register_device_item(device, index, voice->volume);
270   state_save_register_device_item(device, index, voice->base_offset);
271}
272
273static void okim6376_state_save_register(struct okim6376 *info, const device_config *device)
274{
275   int j;
276
277   state_save_register_device_item(device, 0, info->command);
278   for (j = 0; j < OKIM6376_VOICES; j++)
279      adpcm_state_save_register(&info->voice[j], device, j);
280}
281
282
283
284/**********************************************************************************************
285
286     SND_START( okim6376 ) -- start emulation of an OKIM6376-compatible chip
287
288***********************************************************************************************/
289
290static SND_START( okim6376 )
291{
292   struct okim6376 *info;
293   int voice;
294   int divisor = 165;
295
296   info = auto_malloc(sizeof(*info));
297   memset(info, 0, sizeof(*info));
298
299   compute_tables();
300
301   info->command = -1;
302   info->region_base = device->region;
303   info->master_clock = clock;
304
305   /* generate the name and create the stream */
306   info->stream = stream_create(device, 0, 1, clock/divisor, info, okim6376_update);
307
308   /* initialize the voices */
309   for (voice = 0; voice < OKIM6376_VOICES; voice++)
310   {
311      /* initialize the rest of the structure */
312      info->voice[voice].volume = 0;
313      reset_adpcm(&info->voice[voice]);
314   }
315
316   okim6376_state_save_register(info, device);
317
318   /* success */
319   return info;
320}
321
322
323
324/**********************************************************************************************
325
326     SND_RESET( okim6376 ) -- stop emulation of an OKIM6376-compatible chip
327
328***********************************************************************************************/
329
330static SND_RESET( okim6376 )
331{
332   struct okim6376 *info = device->token;
333   int i;
334
335   stream_update(info->stream);
336   for (i = 0; i < OKIM6376_VOICES; i++)
337      info->voice[i].playing = 0;
338}
339
340
341
342
343/**********************************************************************************************
344
345     okim6376_status_r -- read the status port of an OKIM6376-compatible chip
346
347***********************************************************************************************/
348
349static int okim6376_status_r(int num)
350{
351   struct okim6376 *info = sndti_token(SOUND_OKIM6376, num);
352   int i, result;
353
354   result = 0xff;
355
356   /* set the bit to 1 if something is playing on a given channel */
357   stream_update(info->stream);
358   for (i = 0; i < OKIM6376_VOICES; i++)
359   {
360      struct ADPCMVoice *voice = &info->voice[i];
361
362      /* set the bit if it's playing */
363      if (!voice->playing)
364         result ^= 1 << i;
365   }
366
367   return result;
368}
369
370
371
372/**********************************************************************************************
373
374     okim6376_data_w -- write to the data port of an OKIM6376-compatible chip
375
376***********************************************************************************************/
377
378static void okim6376_data_w(int num, int data)
379{
380   struct okim6376 *info = sndti_token(SOUND_OKIM6376, num);
381
382   /* if a command is pending, process the second half */
383   if (info->command != -1)
384   {
385      int temp = data >> 4, i, start;
386      unsigned char *base, *base_end;
387
388
389      /* FIX: Check if it's possible to start multiple voices at the same time */
390      if (temp != 0 && temp != 1 && temp != 2)
391         popmessage("OKI6376 start %x contact MAMEDEV", temp);
392
393      /* update the stream */
394      stream_update(info->stream);
395
396      /* determine which voice(s) (voice is set by a 1 bit in the upper 4 bits of the second byte) */
397      for (i = 0; i < OKIM6376_VOICES; i++, temp >>= 1)
398      {
399         if (temp & 1)
400         {
401            struct ADPCMVoice *voice = &info->voice[i];
402
403            /* determine the start position, max address space is 16Mbit */
404            base = &info->region_base[info->command * 4];
405            base_end = &info->region_base[(MAX_WORDS+1) * 4];
406            start = ((base[0] << 16) + (base[1] << 8) + base[2]) & 0x1fffff;
407
408            if (start == 0)
409            {
410               voice->playing = 0;
411            }
412            else
413            {
414               /* set up the voice to play this sample */
415               if (!voice->playing)
416               {
417                  voice->playing = 1;
418                  voice->base_offset = start;
419                  voice->sample = 0;
420                  voice->count = 0;
421
422                  /* also reset the ADPCM parameters */
423                  reset_adpcm(voice);
424                  /* FIX: no attenuation for now */
425                  voice->volume = volume_table[0];
426               }
427               else
428               {
429                  logerror("OKIM6376:%d requested to play sample %02x on non-stopped voice\n",num,info->command);
430               }
431            }
432         }
433      }
434
435      /* reset the command */
436      info->command = -1;
437   }
438
439   /* if this is the start of a command, remember the sample number for next time */
440   else if (data & 0x80)
441   {
442      // FIX: maximum adpcm words are 111, there are other 8 commands to generate BEEP tone (0x70 to 0x77),
443      // and others for internal testing, that manual explicitly says not to use (0x78 to 0x7f)
444      info->command = data & 0x7f;
445   }
446
447   /* otherwise, see if this is a silence command */
448   else
449   {
450      int temp = data >> 3, i;
451
452      /* update the stream, then turn it off */
453      stream_update(info->stream);
454
455      /* determine which voice(s) (voice is set by a 1 bit in bits 3-6 of the command */
456      for (i = 0; i < OKIM6376_VOICES; i++, temp >>= 1)
457      {
458         if (temp & 1)
459         {
460            struct ADPCMVoice *voice = &info->voice[i];
461
462            voice->playing = 0;
463         }
464      }
465   }
466}
467
468
469
470/**********************************************************************************************
471
472     okim6376_status_0_r -- generic status read functions
473     okim6376_status_1_r
474
475***********************************************************************************************/
476
477READ8_HANDLER( okim6376_status_0_r )
478{
479   return okim6376_status_r(0);
480}
481
482READ8_HANDLER( okim6376_status_1_r )
483{
484   return okim6376_status_r(1);
485}
486
487READ8_HANDLER( okim6376_status_2_r )
488{
489   return okim6376_status_r(2);
490}
491
492READ16_HANDLER( okim6376_status_0_lsb_r )
493{
494   return okim6376_status_r(0);
495}
496
497READ16_HANDLER( okim6376_status_1_lsb_r )
498{
499   return okim6376_status_r(1);
500}
501
502READ16_HANDLER( okim6376_status_2_lsb_r )
503{
504   return okim6376_status_r(2);
505}
506
507READ16_HANDLER( okim6376_status_0_msb_r )
508{
509   return okim6376_status_r(0) << 8;
510}
511
512READ16_HANDLER( okim6376_status_1_msb_r )
513{
514   return okim6376_status_r(1) << 8;
515}
516
517READ16_HANDLER( okim6376_status_2_msb_r )
518{
519   return okim6376_status_r(2) << 8;
520}
521
522
523
524/**********************************************************************************************
525
526     okim6376_data_0_w -- generic data write functions
527     okim6376_data_1_w
528
529***********************************************************************************************/
530
531WRITE8_HANDLER( okim6376_data_0_w )
532{
533   okim6376_data_w(0, data);
534}
535
536WRITE8_HANDLER( okim6376_data_1_w )
537{
538   okim6376_data_w(1, data);
539}
540
541WRITE8_HANDLER( okim6376_data_2_w )
542{
543   okim6376_data_w(2, data);
544}
545
546WRITE16_HANDLER( okim6376_data_0_lsb_w )
547{
548   if (ACCESSING_BITS_0_7)
549      okim6376_data_w(0, data & 0xff);
550}
551
552WRITE16_HANDLER( okim6376_data_1_lsb_w )
553{
554   if (ACCESSING_BITS_0_7)
555      okim6376_data_w(1, data & 0xff);
556}
557
558WRITE16_HANDLER( okim6376_data_2_lsb_w )
559{
560   if (ACCESSING_BITS_0_7)
561      okim6376_data_w(2, data & 0xff);
562}
563
564WRITE16_HANDLER( okim6376_data_0_msb_w )
565{
566   if (ACCESSING_BITS_8_15)
567      okim6376_data_w(0, data >> 8);
568}
569
570WRITE16_HANDLER( okim6376_data_1_msb_w )
571{
572   if (ACCESSING_BITS_8_15)
573      okim6376_data_w(1, data >> 8);
574}
575
576WRITE16_HANDLER( okim6376_data_2_msb_w )
577{
578   if (ACCESSING_BITS_8_15)
579      okim6376_data_w(2, data >> 8);
580}
581
582
583
584/**************************************************************************
585 * Generic get_info
586 **************************************************************************/
587
588static SND_SET_INFO( okim6376 )
589{
590   switch (state)
591   {
592      /* no parameters to set */
593   }
594}
595
596
597SND_GET_INFO( okim6376 )
598{
599   switch (state)
600   {
601      /* --- the following bits of info are returned as 64-bit signed integers --- */
602
603      /* --- the following bits of info are returned as pointers to data or functions --- */
604      case SNDINFO_PTR_SET_INFO:                  info->set_info = SND_SET_INFO_NAME( okim6376 );      break;
605      case SNDINFO_PTR_START:                     info->start = SND_START_NAME( okim6376 );         break;
606      case SNDINFO_PTR_STOP:                     /* nothing */                              break;
607      case SNDINFO_PTR_RESET:                     info->reset = SND_RESET_NAME( okim6376 );         break;
608
609      /* --- the following bits of info are returned as NULL-terminated strings --- */
610      case SNDINFO_STR_NAME:                     strcpy(info->s, "OKI6376");                     break;
611      case SNDINFO_STR_CORE_FAMILY:               strcpy(info->s, "OKI ADPCM");                  break;
612      case SNDINFO_STR_CORE_VERSION:               strcpy(info->s, "1.0");                        break;
613      case SNDINFO_STR_CORE_FILE:                  strcpy(info->s, __FILE__);                     break;
614      case SNDINFO_STR_CORE_CREDITS:               strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
615   }
616}
617
src/emu/sound/okim6295.c
r4135r4136
6161static int diff_lookup[49*16];
6262
6363/* volume lookup table. The manual lists only 9 steps, ~3dB per step. Given the dB values,
64   that seems to map to a 5-bit volume control. What happens for steps after the 9th is not
65    known, we arbitrarily assign a "1" to all those steps. */
66static int volume_table[16] =
64   that seems to map to a 5-bit volume control. Any volume parameter beyond the 9th index
65   results in silent playback. */
66static const int volume_table[16] =
6767{
6868   0x20,   //   0 dB
6969   0x16,   //  -3.2 dB
r4135r4136
7474   0x04,   // -18.0 dB
7575   0x03,   // -20.5 dB
7676   0x02,   // -24.0 dB
77   0x01,   // unknown
78   0x01,   // unknown
79   0x01,   // unknown
80   0x01,   // unknown
81   0x01,   // unknown
82   0x01,   // unknown
83   0x01,   // unknown
77   0x00,
78   0x00,
79   0x00,
80   0x00,
81   0x00,
82   0x00,
83   0x00,
8484};
8585
8686/* tables computed? */
r4135r4136
482482                  /* also reset the ADPCM parameters */
483483                  reset_adpcm(&voice->adpcm);
484484                  voice->volume = volume_table[data & 0x0f];
485
486                  /* the manual only lists 9 volume steps */
487                  if ((data & 0x0f) >= 9)
488                     popmessage("OKI6295 volume %x contact MAMEDEV", data & 0x0f);
489485               }
490486               else
491487               {
src/emu/sound/2608intf.h
r4135r4136
3838WRITE8_HANDLER( ym2608_data_port_1_b_w );
3939
4040SND_GET_INFO( ym2608 );
41#define SOUND_YM2608 SND_GET_INFO_NAME( ym2608 )
4142
4243#endif /* __2608INTF_H__ */
src/emu/sound/es5506.c
r4135r4136
821821
822822***********************************************************************************************/
823823
824static void *es5506_start_common(const device_config *device, int sndindex, int clock, const void *config, sound_type sndtype)
824static void *es5506_start_common(const device_config *device, int clock, const void *config, sound_type sndtype)
825825{
826826   const es5506_interface *intf = config;
827827   struct ES5506Chip *chip;
r4135r4136
876876
877877static SND_START( es5506 )
878878{
879   return es5506_start_common(device, sndindex, clock, config, SOUND_ES5506);
879   return es5506_start_common(device, clock, config, SOUND_ES5506);
880880}
881881
882882
r4135r4136
15131513   es5506intf.irq_callback = intf->irq_callback;
15141514   es5506intf.read_port = intf->read_port;
15151515
1516   return es5506_start_common(device, sndindex, clock, &es5506intf, SOUND_ES5505);
1516   return es5506_start_common(device, clock, &es5506intf, SOUND_ES5505);
15171517}
15181518
15191519
src/emu/sound/okim6376.h
r0r4136
1#pragma once
2
3#ifndef __OKIM6376_H__
4#define __OKIM6376_H__
5
6/* an interface for the OKIM6376 and similar chips */
7
8READ8_HANDLER( okim6376_status_0_r );
9READ8_HANDLER( okim6376_status_1_r );
10READ8_HANDLER( okim6376_status_2_r );
11READ16_HANDLER( okim6376_status_0_lsb_r );
12READ16_HANDLER( okim6376_status_1_lsb_r );
13READ16_HANDLER( okim6376_status_2_lsb_r );
14READ16_HANDLER( okim6376_status_0_msb_r );
15READ16_HANDLER( okim6376_status_1_msb_r );
16READ16_HANDLER( okim6376_status_2_msb_r );
17WRITE8_HANDLER( okim6376_data_0_w );
18WRITE8_HANDLER( okim6376_data_1_w );
19WRITE8_HANDLER( okim6376_data_2_w );
20WRITE16_HANDLER( okim6376_data_0_lsb_w );
21WRITE16_HANDLER( okim6376_data_1_lsb_w );
22WRITE16_HANDLER( okim6376_data_2_lsb_w );
23WRITE16_HANDLER( okim6376_data_0_msb_w );
24WRITE16_HANDLER( okim6376_data_1_msb_w );
25WRITE16_HANDLER( okim6376_data_2_msb_w );
26
27SND_GET_INFO( okim6376 );
28#define SOUND_OKIM6376 SND_GET_INFO_NAME( okim6376 )
29
30#endif /* __OKIM6376_H__ */
src/emu/sound/okim6295.h
r4135r4136
5656INT16 clock_adpcm(struct adpcm_state *state, UINT8 nibble);
5757
5858SND_GET_INFO( okim6295 );
59#define SOUND_OKIM6295 SND_GET_INFO_NAME( okim6295 )
5960
6061#endif /* __OKIM6295_H__ */
src/emu/sound/es5506.h
r4135r4136
2828void es5505_voice_bank_1_w(int voice, int bank);
2929
3030SND_GET_INFO( es5505 );
31#define SOUND_ES5505 SND_GET_INFO_NAME( es5505 )
3132
3233
3334typedef struct _es5506_interface es5506_interface;
r4135r4136
5556void es5506_voice_bank_1_w(int voice, int bank);
5657
5758SND_GET_INFO( es5506 );
59#define SOUND_ES5506 SND_GET_INFO_NAME( es5506 )
5860
5961#endif /* __ES5506_H__ */
src/emu/sound/ymf278b.c
r4135r4136
128128   INT32 mix_level[8];
129129
130130   sound_stream * stream;
131   int index;
132131} YMF278BChip;
133132
134133static INT32 *mix;
r4135r4136
675674
676675   chip = auto_malloc(sizeof(*chip));
677676   memset(chip, 0, sizeof(*chip));
678   chip->index = sndindex;
679677
680678   intf = (config != NULL) ? config : &defintrf;
681679
src/emu/sound/ymf278b.h
r4135r4136
3131WRITE8_HANDLER( ymf278b_data_port_1_c_w );
3232
3333SND_GET_INFO( ymf278b );
34#define SOUND_YMF278B SND_GET_INFO_NAME( ymf278b )
3435
3536#endif /* __YMF278B_H__ */
src/emu/sound/sid6581.h
r4135r4136
3434
3535SND_GET_INFO( sid6581 );
3636SND_GET_INFO( sid8580 );
37#define SOUND_SID6581 SND_GET_INFO_NAME( sid6581 )
38#define SOUND_SID8580 SND_GET_INFO_NAME( sid8580 )
3739
3840#endif /* __SID6581_H__ */
src/emu/sound/5220intf.c
r4135r4136
254254   switch (state)
255255   {
256256      /* --- the following bits of info are returned as 64-bit signed integers --- */
257      case SNDINFO_INT_ALIAS:                     info->i = SOUND_TMS5220;                  break;
257      case SNDINFO_FCT_ALIAS:                     info->type = SOUND_TMS5220;                  break;
258258
259259      /* --- the following bits of info are returned as pointers to data or functions --- */
260260      case SNDINFO_PTR_SET_INFO:                  info->set_info = SND_SET_INFO_NAME( tms5220 );   break;
src/emu/sound/k053260.c
r4135r4136
1717#define BASE_SHIFT   16
1818
1919struct k053260_channel_def {
20   unsigned long      rate;
21   unsigned long      size;
22   unsigned long      start;
23   unsigned long      bank;
24   unsigned long      volume;
20   UINT32      rate;
21   UINT32      size;
22   UINT32      start;
23   UINT32      bank;
24   UINT32      volume;
2525   int               play;
26   unsigned long      pan;
27   unsigned long      pos;
26   UINT32      pan;
27   UINT32      pos;
2828   int               loop;
2929   int               ppcm; /* packed PCM ( 4 bit signed ) */
3030   int               ppcm_data;
r4135r4136
3333   sound_stream *               channel;
3434   int                        mode;
3535   int                        regs[0x30];
36   unsigned char               *rom;
36   UINT8               *rom;
3737   int                        rom_size;
38   unsigned long               *delta_table;
38   UINT32               *delta_table;
3939   struct k053260_channel_def      channels[4];
4040   const k053260_interface         *intf;
4141   const device_config *device;
r4135r4136
4646   int      i;
4747   double   base = ( double )rate;
4848   double   max = (double)(clock); /* Hz */
49   unsigned long val;
49   UINT32 val;
5050
5151   for( i = 0; i < 0x1000; i++ ) {
5252      double v = ( double )( 0x1000 - i );
r4135r4136
5555
5656      if ( target && base ) {
5757         target = fixed / ( base / target );
58         val = ( unsigned long )target;
58         val = ( UINT32 )target;
5959         if ( val == 0 )
6060            val = 1;
6161      } else
r4135r4136
105105
106106   int i, j, lvol[4], rvol[4], play[4], loop[4], ppcm_data[4], ppcm[4];
107107   unsigned char *rom[4];
108   unsigned long delta[4], end[4], pos[4];
108   UINT32 delta[4], end[4], pos[4];
109109   int dataL, dataR;
110110   signed char d;
111111   struct k053260_chip_def *ic = param;
r4135r4136
227227   for ( i = 0; i < 0x30; i++ )
228228      ic->regs[i] = 0;
229229
230   ic->delta_table = ( unsigned long * )auto_malloc( 0x1000 * sizeof( unsigned long ) );
230   ic->delta_table = ( UINT32 * )auto_malloc( 0x1000 * sizeof( UINT32 ) );
231231
232232   ic->channel = stream_create( device, 0, 2, rate, ic, k053260_update );
233233
r4135r4136
258258
259259      ic->channels[channel].size = ic->rom_size - channel_start;
260260   }
261   if (LOG) logerror("K053260: Sample Start = %06x, Sample End = %06x, Sample rate = %04lx, PPCM = %s\n", channel_start, channel_end, ic->channels[channel].rate, ic->channels[channel].ppcm ? "yes" : "no" );
261   if (LOG) logerror("K053260: Sample Start = %06x, Sample End = %06x, Sample rate = %04x, PPCM = %s\n", channel_start, channel_end, ic->channels[channel].rate, ic->channels[channel].ppcm ? "yes" : "no" );
262262}
263263
264264static void k053260_write( const address_space *space, offs_t offset, UINT8 data, int chip )
r4135r4136
395395      break;
396396
397397      case 0x2e: /* read rom */
398         if ( ic->mode & 1 ) {
399            unsigned int offs = ic->channels[0].start + ( ic->channels[0].pos >> BASE_SHIFT ) + ( ic->channels[0].bank << 16 );
398         if ( ic->mode & 1 )
399         {
400            UINT32 offs = ic->channels[0].start + ( ic->channels[0].pos >> BASE_SHIFT ) + ( ic->channels[0].bank << 16 );
400401
401402            ic->channels[0].pos += ( 1 << 16 );
402403
src/emu/sound/flt_vol.h
r4135r4136
66void flt_volume_set_volume(int num, float volume);
77
88SND_GET_INFO( filter_volume );
9#define SOUND_FILTER_VOLUME SND_GET_INFO_NAME( filter_volume )
910
1011#endif /* __FLT_VOL_H__ */
src/emu/sound/5220intf.h
r4135r4136
3434SND_GET_INFO( tmc0285 );
3535SND_GET_INFO( tms5200 );
3636
37#define SOUND_TMS5220 SND_GET_INFO_NAME( tms5220 )
38#define SOUND_TMC0285 SND_GET_INFO_NAME( tmc0285 )
39#define SOUND_TMS5200 SND_GET_INFO_NAME( tms5200 )
40
3741#endif /* __5200INTF_H__ */
src/emu/sound/2151intf.h
r4135r4136
3838WRITE16_HANDLER( ym2151_data_port_2_lsb_w );
3939
4040SND_GET_INFO( ym2151 );
41#define SOUND_YM2151 SND_GET_INFO_NAME( ym2151 )
4142
4243#endif /* __2151INTF_H__ */
4344
src/emu/sound/sound.mak
r4135r4136
336336
337337
338338#-------------------------------------------------
339# National Semiconductor Digitalker
340#-------------------------------------------------
341
342SOUNDDEFS += -DHAS_DIGITALKER=$(if $(filter DIGITALKER,$(SOUNDS)),1,0)
343
344ifneq ($(filter DIGITALKER,$(SOUNDS)),)
345SOUNDOBJS += $(SOUNDOBJ)/digitalk.o
346endif
347
348
349
350#-------------------------------------------------
339351# Nintendo custom sound chips
340352#-------------------------------------------------
341353
r4135r4136
365377
366378SOUNDDEFS += -DHAS_MSM5205=$(if $(filter MSM5205,$(SOUNDS)),1,0)
367379SOUNDDEFS += -DHAS_MSM5232=$(if $(filter MSM5232,$(SOUNDS)),1,0)
380SOUNDDEFS += -DHAS_OKIM6376=$(if $(filter OKIM6376,$(SOUNDS)),1,0)
368381SOUNDDEFS += -DHAS_OKIM6295=$(if $(filter OKIM6295,$(SOUNDS)),1,0)
369382SOUNDDEFS += -DHAS_OKIM6258=$(if $(filter OKIM6258,$(SOUNDS)),1,0)
370383
r4135r4136
376389SOUNDOBJS += $(SOUNDOBJ)/msm5232.o
377390endif
378391
392ifneq ($(filter OKIM6376,$(SOUNDS)),)
393SOUNDOBJS += $(SOUNDOBJ)/okim6376.o
394endif
395
379396ifneq ($(filter OKIM6295,$(SOUNDS)),)
380397SOUNDOBJS += $(SOUNDOBJ)/okim6295.o
381398endif
src/emu/sound/psx.h
r4135r4136
2828};
2929
3030SND_GET_INFO( psxspu );
31#define SOUND_PSXSPU SND_GET_INFO_NAME( psxspu )
3132
3233#endif /* __SOUND_PSX_H__ */
src/emu/sound/k053260.h
r4135r4136
2626READ16_HANDLER( k053260_1_lsb_r );
2727
2828SND_GET_INFO( k053260 );
29#define SOUND_K053260 SND_GET_INFO_NAME( k053260 )
2930
3031#endif /* __K053260_H__ */
src/emu/sound/2413intf.h
r4135r4136
2525WRITE16_HANDLER( ym2413_data_port_3_lsb_w );
2626
2727SND_GET_INFO( ym2413 );
28#define SOUND_YM2413 SND_GET_INFO_NAME( ym2413 )
2829
2930#endif /* __2413INTF_H__ */
src/emu/sound/segapcm.h
r4135r4136
2424READ8_HANDLER( sega_pcm_r );
2525
2626SND_GET_INFO( segapcm );
27#define SOUND_SEGAPCM SND_GET_INFO_NAME( segapcm )
2728
2829#endif /* __SEGAPCM_H__ */
src/emu/sound/vrender0.h
r4135r4136
1616WRITE32_HANDLER(vr0_snd_write);
1717
1818SND_GET_INFO( vrender0 );
19#define SOUND_VRENDER0 SND_GET_INFO_NAME( vrender0 )
1920
2021#endif /* __VRENDER0_H__ */
src/emu/sound/multipcm.h
r4135r4136
1111void multi_pcm_set_bank(int which, UINT32 leftoffs, UINT32 rightoffs);
1212
1313SND_GET_INFO( multipcm );
14#define SOUND_MULTIPCM SND_GET_INFO_NAME( multipcm )
1415
1516#endif /* __MULTIPCM_H__ */
src/emu/sound/namco.h
r4135r4136
3434SND_GET_INFO( namco_15xx );
3535SND_GET_INFO( namco_cus30 );
3636
37#define SOUND_NAMCO SND_GET_INFO_NAME( namco )
38#define SOUND_NAMCO_15XX SND_GET_INFO_NAME( namco_15xx )
39#define SOUND_NAMCO_CUS30 SND_GET_INFO_NAME( namco_cus30 )
40
41
3742#endif /* __NAMCO_H__ */
3843
src/emu/sound/sn76477.h
r4135r4136
125125void sn76477_pitch_voltage_w(int chip, double data);
126126
127127SND_GET_INFO( sn76477 );
128#define SOUND_SN76477 SND_GET_INFO_NAME( sn76477 )
128129
129130#endif/* __SN76477_H__ */
src/emu/sound/5110intf.c
r4135r4136
298298   switch (state)
299299   {
300300      /* --- the following bits of info are returned as 64-bit signed integers --- */
301      case SNDINFO_INT_ALIAS:                     info->i = SOUND_TMS5110;                  break;
301      case SNDINFO_FCT_ALIAS:                     info->type = SOUND_TMS5110;                  break;
302302
303303      /* --- the following bits of info are returned as pointers to data or functions --- */
304304      case SNDINFO_PTR_SET_INFO:                  info->set_info = SND_SET_INFO_NAME( tms5110 );   break;
src/emu/sound/vlm5030.h
r4135r4136
2424void vlm5030_st(int pin );
2525
2626SND_GET_INFO( vlm5030 );
27#define SOUND_VLM5030 SND_GET_INFO_NAME( vlm5030 )
2728
2829#endif /* __VLM5030_H__ */
src/emu/sound/5110intf.h
r4135r4136
3030SND_GET_INFO( cd2802 );
3131SND_GET_INFO( m58817 );
3232
33#define SOUND_TMS5110 SND_GET_INFO_NAME( tms5110 )
34#define SOUND_TMS5100 SND_GET_INFO_NAME( tms5100 )
35#define SOUND_TMS5110A SND_GET_INFO_NAME( tms5110a )
36#define SOUND_CD2801 SND_GET_INFO_NAME( cd2801 )
37#define SOUND_TMC0281 SND_GET_INFO_NAME( tmc0281 )
38#define SOUND_CD2802 SND_GET_INFO_NAME( cd2802 )
39#define SOUND_M58817 SND_GET_INFO_NAME( m58817 )
40
3341#endif /* __5110INTF_H__ */
src/emu/sound/2203intf.h
r4135r4136
6767WRITE8_HANDLER( ym2203_word_1_w );
6868
6969SND_GET_INFO( ym2203 );
70#define SOUND_YM2203 SND_GET_INFO_NAME( ym2203 )
7071
7172#endif /* __2203INTF_H__ */
src/emu/sound/k007232.h
r4135r4136
3333void k007232_set_volume(int chip,int channel,int volumeA,int volumeB);
3434
3535SND_GET_INFO( k007232 );
36#define SOUND_K007232 SND_GET_INFO_NAME( k007232 )
3637
3738#endif /* __K007232_H__ */
src/emu/sound/es5503.c
r4135r4136
6464
6565   UINT8 *docram;
6666
67   int index;
6867   sound_stream * stream;
6968
7069   void (*irq_callback)(running_machine *machine, int);   // IRQ callback
r4135r4136
232231
233232   chip = auto_malloc(sizeof(*chip));
234233   memset(chip, 0, sizeof(*chip));
235   chip->index = sndindex;
236234
237235   intf = config;
238236
r4135r4136
289287      {
290288         case 0:      // freq lo
291289            return (chip->oscillators[osc].freq & 0xff);
292            break;
293290
294291         case 0x20:        // freq hi
295292            return (chip->oscillators[osc].freq >> 8);
296            break;
297293
298294         case 0x40:   // volume
299295            return chip->oscillators[osc].vol;
300            break;
301296
302297         case 0x60:   // data
303298            return chip->oscillators[osc].data;
304            break;
305299
306300         case 0x80:   // wavetable pointer
307301            return (chip->oscillators[osc].wavetblpointer>>8) & 0xff;
308            break;
309302
310303         case 0xa0:   // oscillator control
311304            return chip->oscillators[osc].control;
312            break;
313305
314306         case 0xc0:   // bank select / wavetable size / resolution
315307            retval = 0;
r4135r4136
321313            retval |= (chip->oscillators[osc].wavetblsize<<3);
322314            retval |= chip->oscillators[osc].resolution;
323315            return retval;
324            break;
325316      }
326317   }
327318   else    // global registers
r4135r4136
366357            }
367358
368359            return retval;
369            break;
370360
371361         case 0xe1:   // oscillator enable
372362            return chip->oscsenabled<<1;
373            break;
374363
375364         case 0xe2:   // A/D converter
376365            if (chip->adc_read)
src/emu/sound/okim6258.h
r4135r4136
4646WRITE16_HANDLER( okim6258_ctrl_0_lsb_w );
4747
4848SND_GET_INFO( okim6258 );
49#define SOUND_OKIM6258 SND_GET_INFO_NAME( okim6258 )
4950
5051#endif /* __OKIM6258_H__ */
src/emu/sound/es5503.h
r4135r4136
1616void es5503_set_base_0(UINT8 *wavemem);
1717
1818SND_GET_INFO( es5503 );
19#define SOUND_ES5503 SND_GET_INFO_NAME( es5503 )
1920
2021#endif /* __ES5503_H__ */
src/emu/sound/nile.h
r4135r4136
1111READ16_HANDLER(nile_sndctrl_r);
1212
1313SND_GET_INFO( nile );
14#define SOUND_NILE SND_GET_INFO_NAME( nile )
1415
1516#endif /* __NILE_H__ */
src/emu/profiler.c
r4135r4136
191191      switches = 0;
192192      for (curmem = 0; curmem < ARRAY_LENGTH(global_profiler.data); curmem++)
193193         switches += global_profiler.data[curmem].context_switches;
194      astring_catprintf(string, "%d CPU switches\n", switches / ARRAY_LENGTH(global_profiler.data));
194      astring_catprintf(string, "%d CPU switches\n", switches / (int) ARRAY_LENGTH(global_profiler.data));
195195   }
196196
197197   profiler_mark(PROFILER_END);
src/emu/sndintrf.c
r4135r4136
4141   sound_type      sndtype;       /* type index of this sound chip */
4242   sound_type      aliastype;      /* aliased type index of this sound chip */
4343   device_config *   device;         /* dummy device for now */
44   const char *   tag;          /* tag this sound chip */
4544   int            index;          /* index of this sound chip */
46   int            clock;          /* clock for this sound chip */
4745};
4846
4947
5048
5149/***************************************************************************
52    PROTOTYPES FOR ALL SND ENTRY POINTS
53***************************************************************************/
54
55static SND_GET_INFO( dummy_sound );
56SND_GET_INFO( custom );
57SND_GET_INFO( samples );
58SND_GET_INFO( dac );
59SND_GET_INFO( dmadac );
60SND_GET_INFO( discrete );
61SND_GET_INFO( ay8910 );
62SND_GET_INFO( ay8912 );
63SND_GET_INFO( ay8913 );
64SND_GET_INFO( ay8930 );
65SND_GET_INFO( ym2149 );
66SND_GET_INFO( ym3439 );
67SND_GET_INFO( ymz284 );
68SND_GET_INFO( ymz294 );
69SND_GET_INFO( ym2203 );
70SND_GET_INFO( ym2151 );
71SND_GET_INFO( ym2608 );
72SND_GET_INFO( ym2610 );
73SND_GET_INFO( ym2610b );
74SND_GET_INFO( ym2612 );
75SND_GET_INFO( ym3438 );
76SND_GET_INFO( ym2413 );
77SND_GET_INFO( ym3812 );
78SND_GET_INFO( ym3526 );
79SND_GET_INFO( ymz280b );
80SND_GET_INFO( y8950 );
81SND_GET_INFO( sn76477 );
82SND_GET_INFO( sn76489 );
83SND_GET_INFO( sn76489a );
84SND_GET_INFO( sn76494 );
85SND_GET_INFO( sn76496 );
86SND_GET_INFO( gamegear );
87SND_GET_INFO( smsiii );
88SND_GET_INFO( pokey );
89SND_GET_INFO( nesapu );
90SND_GET_INFO( astrocade );
91SND_GET_INFO( namco );
92SND_GET_INFO( namco_15xx );
93SND_GET_INFO( namco_cus30 );
94SND_GET_INFO( namco_52xx );
95SND_GET_INFO( namco_63701x );
96SND_GET_INFO( snkwave );
97SND_GET_INFO( tms36xx );
98SND_GET_INFO( tms3615 );
99SND_GET_INFO( tms5100 );
100SND_GET_INFO( tms5110 );
101SND_GET_INFO( tms5110a );
102SND_GET_INFO( cd2801 );
103SND_GET_INFO( tmc0281 );
104SND_GET_INFO( cd2802 );
105SND_GET_INFO( m58817 );
106SND_GET_INFO( tmc0285 );
107SND_GET_INFO( tms5200 );
108SND_GET_INFO( tms5220 );
109SND_GET_INFO( vlm5030 );
110SND_GET_INFO( adpcm );
111SND_GET_INFO( okim6295 );
112SND_GET_INFO( okim6258 );
113SND_GET_INFO( msm5205 );
114SND_GET_INFO( msm5232 );
115SND_GET_INFO( upd7759 );
116SND_GET_INFO( hc55516 );
117SND_GET_INFO( mc3417 );
118SND_GET_INFO( mc3418 );
119SND_GET_INFO( k005289 );
120SND_GET_INFO( k007232 );
121SND_GET_INFO( k051649 );
122SND_GET_INFO( k053260 );
123SND_GET_INFO( k054539 );
124SND_GET_INFO( segapcm );
125SND_GET_INFO( rf5c68 );
126SND_GET_INFO( cem3394 );
127SND_GET_INFO( c140 );
128SND_GET_INFO( qsound );
129SND_GET_INFO( saa1099 );
130SND_GET_INFO( iremga20 );
131SND_GET_INFO( es5503 );
132SND_GET_INFO( es5505 );
133SND_GET_INFO( es5506 );
134SND_GET_INFO( bsmt2000 );
135SND_GET_INFO( ymf262 );
136SND_GET_INFO( ymf278b );
137SND_GET_INFO( gaelco_cg1v );
138SND_GET_INFO( gaelco_gae1 );
139SND_GET_INFO( x1_010 );
140SND_GET_INFO( multipcm );
141SND_GET_INFO( c6280 );
142SND_GET_INFO( tia );
143SND_GET_INFO( sp0250 );
144SND_GET_INFO( scsp );
145SND_GET_INFO( psxspu );
146SND_GET_INFO( ymf271 );
147SND_GET_INFO( cdda );
148SND_GET_INFO( ics2115 );
149SND_GET_INFO( st0016 );
150SND_GET_INFO( nile );
151SND_GET_INFO( c352 );
152SND_GET_INFO( vrender0 );
153SND_GET_INFO( votrax );
154SND_GET_INFO( es8712 );
155SND_GET_INFO( rf5c400 );
156SND_GET_INFO( speaker );
157SND_GET_INFO( cdp1869 );
158SND_GET_INFO( beep );
159SND_GET_INFO( wave );
160SND_GET_INFO( sid6581 );
161SND_GET_INFO( sid8580 );
162SND_GET_INFO( sp0256 );
163SND_GET_INFO( s14001a );
164SND_GET_INFO( aica );
165
166SND_GET_INFO( filter_volume );
167SND_GET_INFO( filter_rc );
168
169
170
171/***************************************************************************
172    MASTER SND LIST
173***************************************************************************/
174
175static const struct
176{
177   sound_type   sndtype;
178   snd_get_info_func   get_info;
179} sndintrf_map[] =
180{
181   { SOUND_DUMMY, SND_GET_INFO_NAME( dummy_sound ) },
182#if (HAS_CUSTOM)
183   { SOUND_CUSTOM, SND_GET_INFO_NAME( custom ) },
184#endif
185#if (HAS_SAMPLES)
186   { SOUND_SAMPLES, SND_GET_INFO_NAME( samples ) },
187#endif
188#if (HAS_DAC)
189   { SOUND_DAC, SND_GET_INFO_NAME( dac ) },
190#endif
191#if (HAS_DMADAC)
192   { SOUND_DMADAC, SND_GET_INFO_NAME( dmadac ) },
193#endif
194#if (HAS_DISCRETE)
195   { SOUND_DISCRETE, SND_GET_INFO_NAME( discrete ) },
196#endif
197#if (HAS_AY8910)
198   { SOUND_AY8910, SND_GET_INFO_NAME( ay8910 ) },
199   { SOUND_AY8912, SND_GET_INFO_NAME( ay8912 ) },
200   { SOUND_AY8913, SND_GET_INFO_NAME( ay8913 ) },
201   { SOUND_AY8930, SND_GET_INFO_NAME( ay8930 ) },
202   { SOUND_YM2149, SND_GET_INFO_NAME( ym2149 ) },
203   { SOUND_YM3439, SND_GET_INFO_NAME( ym3439 ) },
204   { SOUND_YMZ284, SND_GET_INFO_NAME( ymz284 ) },
205   { SOUND_YMZ294, SND_GET_INFO_NAME( ymz294 ) },
206#endif
207#if (HAS_YM2203)
208   { SOUND_YM2203, SND_GET_INFO_NAME( ym2203 ) },
209#endif
210#if (HAS_YM2151)
211   { SOUND_YM2151, SND_GET_INFO_NAME( ym2151 ) },
212#endif
213#if (HAS_YM2608)
214   { SOUND_YM2608, SND_GET_INFO_NAME( ym2608 ) },
215#endif
216#if (HAS_YM2610)
217   { SOUND_YM2610, SND_GET_INFO_NAME( ym2610 ) },
218#endif
219#if (HAS_YM2610B)
220   { SOUND_YM2610B, SND_GET_INFO_NAME( ym2610b ) },
221#endif
222#if (HAS_YM2612)
223   { SOUND_YM2612, SND_GET_INFO_NAME( ym2612 ) },
224#endif
225#if (HAS_YM3438)
226   { SOUND_YM3438, SND_GET_INFO_NAME( ym3438 ) },
227#endif
228#if (HAS_YM2413)
229   { SOUND_YM2413, SND_GET_INFO_NAME( ym2413 ) },
230#endif
231#if (HAS_YM3812)
232   { SOUND_YM3812, SND_GET_INFO_NAME( ym3812 ) },
233#endif
234#if (HAS_YM3526)
235   { SOUND_YM3526, SND_GET_INFO_NAME( ym3526 ) },
236#endif
237#if (HAS_YMZ280B)
238   { SOUND_YMZ280B, SND_GET_INFO_NAME( ymz280b ) },
239#endif
240#if (HAS_Y8950)
241   { SOUND_Y8950, SND_GET_INFO_NAME( y8950 ) },
242#endif
243#if (HAS_SN76477)
244   { SOUND_SN76477, SND_GET_INFO_NAME( sn76477 ) },
245#endif
246#if (HAS_SN76496)
247   { SOUND_SN76489, SND_GET_INFO_NAME( sn76489 ) },
248   { SOUND_SN76489A, SND_GET_INFO_NAME( sn76489a ) },
249   { SOUND_SN76494, SND_GET_INFO_NAME( sn76494 ) },
250   { SOUND_SN76496, SND_GET_INFO_NAME( sn76496 ) },
251   { SOUND_GAMEGEAR, SND_GET_INFO_NAME( gamegear ) },
252   { SOUND_SMSIII, SND_GET_INFO_NAME( smsiii ) },
253#endif
254#if (HAS_POKEY)
255   { SOUND_POKEY, SND_GET_INFO_NAME( pokey ) },
256#endif
257#if (HAS_NES)
258   { SOUND_NES, SND_GET_INFO_NAME( nesapu ) },
259#endif
260#if (HAS_ASTROCADE)
261   { SOUND_ASTROCADE, SND_GET_INFO_NAME( astrocade ) },
262#endif
263#if (HAS_NAMCO)
264   { SOUND_NAMCO, SND_GET_INFO_NAME( namco ) },
265#endif
266#if (HAS_NAMCO_15XX)
267   { SOUND_NAMCO_15XX, SND_GET_INFO_NAME( namco_15xx ) },
268#endif
269#if (HAS_NAMCO_CUS30)
270   { SOUND_NAMCO_CUS30, SND_GET_INFO_NAME( namco_cus30 ) },
271#endif
272#if (HAS_NAMCO_52XX)
273   { SOUND_NAMCO_52XX, SND_GET_INFO_NAME( namco_52xx ) },
274#endif
275#if (HAS_NAMCO_63701X)
276   { SOUND_NAMCO_63701X, SND_GET_INFO_NAME( namco_63701x ) },
277#endif
278#if (HAS_SNKWAVE)
279   { SOUND_SNKWAVE, SND_GET_INFO_NAME( snkwave ) },
280#endif
281#if (HAS_TMS36XX)
282   { SOUND_TMS36XX, SND_GET_INFO_NAME( tms36xx ) },
283#endif
284#if (HAS_TMS3615)
285   { SOUND_TMS3615, SND_GET_INFO_NAME( tms3615 ) },
286#endif
287#if (HAS_TMS5100)
288   { SOUND_TMS5100, SND_GET_INFO_NAME( tms5100 ) },
289#endif
290#if (HAS_TMS5110)
291   { SOUND_TMS5110, SND_GET_INFO_NAME( tms5110 ) },
292#endif
293#if (HAS_TMS5110A)
294   { SOUND_TMS5110A, SND_GET_INFO_NAME( tms5110a ) },
295#endif
296#if (HAS_CD2801)
297   { SOUND_CD2801, SND_GET_INFO_NAME( cd2801 ) },
298#endif
299#if (HAS_TMC0281)
300   { SOUND_TMC0281, SND_GET_INFO_NAME( tmc0281 ) },
301#endif
302#if (HAS_CD2802)
303   { SOUND_CD2802, SND_GET_INFO_NAME( cd2802 ) },
304#endif
305#if (HAS_M58817)
306   { SOUND_M58817, SND_GET_INFO_NAME( m58817 ) },
307#endif
308#if (HAS_TMC0285)
309   { SOUND_TMC0285, SND_GET_INFO_NAME( tmc0285 ) },
310#endif
311#if (HAS_TMS5200)
312   { SOUND_TMS5200, SND_GET_INFO_NAME( tms5200 ) },
313#endif
314#if (HAS_TMS5220)
315   { SOUND_TMS5220, SND_GET_INFO_NAME( tms5220 ) },
316#endif
317#if (HAS_VLM5030)
318   { SOUND_VLM5030, SND_GET_INFO_NAME( vlm5030 ) },
319#endif
320#if (HAS_OKIM6295)
321   { SOUND_OKIM6295, SND_GET_INFO_NAME( okim6295 ) },
322#endif
323#if (HAS_OKIM6258)
324   { SOUND_OKIM6258, SND_GET_INFO_NAME( okim6258 ) },
325#endif
326#if (HAS_MSM5205)
327   { SOUND_MSM5205, SND_GET_INFO_NAME( msm5205 ) },
328#endif
329#if (HAS_MSM5232)
330   { SOUND_MSM5232, SND_GET_INFO_NAME( msm5232 ) },
331#endif
332#if (HAS_UPD7759)
333   { SOUND_UPD7759, SND_GET_INFO_NAME( upd7759 ) },
334#endif
335#if (HAS_HC55516)
336   { SOUND_HC55516, SND_GET_INFO_NAME( hc55516 ) },
337   { SOUND_MC3417, SND_GET_INFO_NAME( mc3417 ) },
338   { SOUND_MC3418, SND_GET_INFO_NAME( mc3418 ) },
339#endif
340#if (HAS_K005289)
341   { SOUND_K005289, SND_GET_INFO_NAME( k005289 ) },
342#endif
343#if (HAS_K007232)
344   { SOUND_K007232, SND_GET_INFO_NAME( k007232 ) },
345#endif
346#if (HAS_K051649)
347   { SOUND_K051649, SND_GET_INFO_NAME( k051649 ) },
348#endif
349#if (HAS_K053260)
350   { SOUND_K053260, SND_GET_INFO_NAME( k053260 ) },
351#endif
352#if (HAS_K054539)
353   { SOUND_K054539, SND_GET_INFO_NAME( k054539 ) },
354#endif
355#if (HAS_SEGAPCM)
356   { SOUND_SEGAPCM, SND_GET_INFO_NAME( segapcm ) },
357#endif
358#if (HAS_RF5C68)
359   { SOUND_RF5C68, SND_GET_INFO_NAME( rf5c68 ) },
360#endif
361#if (HAS_CEM3394)
362   { SOUND_CEM3394, SND_GET_INFO_NAME( cem3394 ) },
363#endif
364#if (HAS_C140)
365   { SOUND_C140, SND_GET_INFO_NAME( c140 ) },
366#endif
367#if (HAS_QSOUND)
368   { SOUND_QSOUND, SND_GET_INFO_NAME( qsound ) },
369#endif
370#if (HAS_SAA1099)
371   { SOUND_SAA1099, SND_GET_INFO_NAME( saa1099 ) },
372#endif
373#if (HAS_IREMGA20)
374   { SOUND_IREMGA20, SND_GET_INFO_NAME( iremga20 ) },
375#endif
376#if (HAS_ES5503)
377   { SOUND_ES5503, SND_GET_INFO_NAME( es5503 ) },
378#endif
379#if (HAS_ES5505)
380   { SOUND_ES5505, SND_GET_INFO_NAME( es5505 ) },
381#endif
382#if (HAS_ES5506)
383   { SOUND_ES5506, SND_GET_INFO_NAME( es5506 ) },
384#endif
385#if (HAS_BSMT2000)
386   { SOUND_BSMT2000, SND_GET_INFO_NAME( bsmt2000 ) },
387#endif
388#if (HAS_YMF262)
389   { SOUND_YMF262, SND_GET_INFO_NAME( ymf262 ) },
390#endif
391#if (HAS_YMF278B)
392   { SOUND_YMF278B, SND_GET_INFO_NAME( ymf278b ) },
393#endif
394#if (HAS_GAELCO_CG1V)
395   { SOUND_GAELCO_CG1V, SND_GET_INFO_NAME( gaelco_cg1v ) },
396#endif
397#if (HAS_GAELCO_GAE1)
398   { SOUND_GAELCO_GAE1, SND_GET_INFO_NAME( gaelco_gae1 ) },
399#endif
400#if (HAS_X1_010)
401   { SOUND_X1_010, SND_GET_INFO_NAME( x1_010 ) },
402#endif
403#if (HAS_MULTIPCM)
404   { SOUND_MULTIPCM, SND_GET_INFO_NAME( multipcm ) },
405#endif
406#if (HAS_C6280)
407   { SOUND_C6280, SND_GET_INFO_NAME( c6280 ) },
408#endif
409#if (HAS_TIA)
410   { SOUND_TIA, SND_GET_INFO_NAME( tia ) },
411#endif
412#if (HAS_SP0250)
413   { SOUND_SP0250, SND_GET_INFO_NAME( sp0250 ) },
414#endif
415#if (HAS_SCSP)
416   { SOUND_SCSP, SND_GET_INFO_NAME( scsp ) },
417#endif
418#if (HAS_PSXSPU)
419   { SOUND_PSXSPU, SND_GET_INFO_NAME( psxspu ) },
420#endif
421#if (HAS_YMF271)
422   { SOUND_YMF271, SND_GET_INFO_NAME( ymf271 ) },
423#endif
424#if (HAS_CDDA)
425   { SOUND_CDDA, SND_GET_INFO_NAME( cdda ) },
426#endif
427#if (HAS_ICS2115)
428   { SOUND_ICS2115, SND_GET_INFO_NAME( ics2115 ) },
429#endif
430#if (HAS_ST0016)
431   { SOUND_ST0016, SND_GET_INFO_NAME( st0016 ) },
432#endif
433#if (HAS_NILE)
434   { SOUND_NILE, SND_GET_INFO_NAME( nile ) },
435#endif
436#if (HAS_C352)
437   { SOUND_C352, SND_GET_INFO_NAME( c352 ) },
438#endif
439#if (HAS_VRENDER0)
440   { SOUND_VRENDER0, SND_GET_INFO_NAME( vrender0 ) },
441#endif
442#if (HAS_VOTRAX)
443   { SOUND_VOTRAX, SND_GET_INFO_NAME( votrax ) },
444#endif
445#if (HAS_ES8712)
446   { SOUND_ES8712, SND_GET_INFO_NAME( es8712 ) },
447#endif
448#if (HAS_RF5C400)
449   { SOUND_RF5C400, SND_GET_INFO_NAME( rf5c400 ) },
450#endif
451#if (HAS_SPEAKER)
452   { SOUND_SPEAKER, SND_GET_INFO_NAME( speaker ) },
453#endif
454#if (HAS_CDP1869)
455   { SOUND_CDP1869, SND_GET_INFO_NAME( cdp1869 ) },
456#endif
457#if (HAS_S14001A)
458   { SOUND_S14001A, SND_GET_INFO_NAME( s14001a ) },
459#endif
460#if (HAS_BEEP)
461   { SOUND_BEEP, SND_GET_INFO_NAME( beep ) },
462#endif
463#if (HAS_WAVE)
464   { SOUND_WAVE, SND_GET_INFO_NAME( wave ) },
465#endif
466#if (HAS_SID6581)
467   { SOUND_SID6581, SND_GET_INFO_NAME( sid6581 ) },
468#endif
469#if (HAS_SID8580)
470   { SOUND_SID8580, SND_GET_INFO_NAME( sid8580 ) },
471#endif
472#if (HAS_SP0256)
473   { SOUND_SP0256, SND_GET_INFO_NAME( sp0256 ) },
474#endif
475#if (HAS_AICA)
476   { SOUND_AICA, SND_GET_INFO_NAME( aica ) },
477#endif
478
479   { SOUND_FILTER_VOLUME, SND_GET_INFO_NAME( filter_volume ) },
480   { SOUND_FILTER_RC, SND_GET_INFO_NAME( filter_rc ) },
481};
482
483
484
485/***************************************************************************
48650    VALIDATION MACROS
48751***************************************************************************/
48852
r4135r4136
49054   assert_always(sndnum >= 0 && sndnum < totalsnd, #name "() called with invalid sound num!")
49155
49256#define VERIFY_SNDTI(name) \
493   assert_always(sndtype >= 0 && sndtype < SOUND_COUNT, #name "() called with invalid sound type!"); \
494   assert_always(sndindex >= 0 && sndindex < totalsnd && sound_matrix[sndtype][sndindex] != 0, #name "() called with invalid (type,index) pair!")
57   int sndnum = sndti_to_sndnum(sndtype, sndindex); \
58   assert_always(sndindex >= 0 && sndindex < totalsnd && sndnum != -1, #name "() called with invalid (type,index) pair!")
49559
49660#define VERIFY_SNDTYPE(name) \
497   assert_always(sndtype >= 0 && sndtype < SOUND_COUNT, #name "() called with invalid sound type!")
49861
49962
50063
r4135r4136
50265    GLOBAL VARIABLES
50366***************************************************************************/
50467
505static snd_class_header snd_type_header[SOUND_COUNT];
506
50768static sndintrf_data sound[MAX_SOUND];
50869static sndintrf_data *current_sound_start;
509static UINT8 sound_matrix[SOUND_COUNT][MAX_SOUND];
51070static int totalsnd;
51171
51272
r4135r4136
52383
52484void sndintrf_init(running_machine *machine)
52585{
526   int mapindex;
527
528   /* reset the sndintrf array */
529   memset(snd_type_header, 0, sizeof(snd_type_header));
530
531   /* build the sndintrf array */
532   for (mapindex = 0; mapindex < ARRAY_LENGTH(sndintrf_map); mapindex++)
533   {
534      sound_type sndtype = sndintrf_map[mapindex].sndtype;
535      snd_class_header *header = &snd_type_header[sndtype];
536      sndinfo info;
537
538      /* start with the get_info routine */
539      header->sndtype = sndtype;
540      header->get_info = sndintrf_map[mapindex].get_info;
541
542      /* bootstrap the rest of the function pointers */
543      info.set_info = NULL;
544      (*header->get_info)(NULL, SNDINFO_PTR_SET_INFO, &info);
545      header->set_info = info.set_info;
546
547      info.start = NULL;
548      (*header->get_info)(NULL, SNDINFO_PTR_START, &info);
549      header->start = info.start;
550
551      info.stop = NULL;
552      (*header->get_info)(NULL, SNDINFO_PTR_STOP, &info);
553      header->stop = info.stop;
554
555      info.reset = NULL;
556      (*header->get_info)(NULL, SNDINFO_PTR_RESET, &info);
557      header->reset = info.reset;
558   }
559
560   /* fill in any empty entries with the dummy sound */
561   for (mapindex = 0; mapindex < SOUND_COUNT; mapindex++)
562      if (snd_type_header[mapindex].get_info == NULL)
563         snd_type_header[mapindex] = snd_type_header[SOUND_DUMMY];
564
56586   /* zap the sound data structures */
56687   memset(sound, 0, sizeof(sound));
56788   totalsnd = 0;
568
569   /* reset the (type,index) matrix */
570   memset(sound_matrix, 0, sizeof(sound_matrix));
57189}
57290
57391
r4135r4136
584102
585103int sndintrf_init_sound(running_machine *machine, int sndnum, const char *tag, sound_type sndtype, int clock, const void *config)
586104{
105   snd_start_func start;
587106   sndintrf_data *info = &sound[sndnum];
588107   int index;
108   int sndidx;
589109
590110   info->device = auto_malloc(sizeof(*info->device) + strlen(tag));
591111   memset(info->device, 0, sizeof(*info->device) + strlen(tag));
r4135r4136
600120   info->device->inline_config = info;
601121
602122   /* fill in the type and interface */
603   info->intf = snd_type_header[sndtype];
604   info->tag = tag;
123   info->intf.get_info = sndtype;
124   info->intf.set_info = (snd_set_info_func)sndtype_get_info_fct(sndtype, SNDINFO_PTR_SET_INFO);
605125   info->sndtype = sndtype;
606   info->aliastype = sndtype_get_info_int(sndtype, SNDINFO_INT_ALIAS);
126   info->aliastype = (sound_type)sndtype_get_info_fct(sndtype, SNDINFO_FCT_ALIAS);
607127   if (info->aliastype == 0)
608128      info->aliastype = sndtype;
609   info->clock = clock;
129   info->device->clock = clock;
610130
611   /* find an empty slot in the matrix and add it */
612   totalsnd++;
613   for (index = 0; index < MAX_SOUND; index++)
614      if (sound_matrix[info->aliastype][index] == 0)
615      {
616         sound_matrix[info->aliastype][index] = totalsnd;
617         break;
618      }
131   /* compute the index */
132   for (index = 0, sndidx = 0; sndidx < totalsnd; sndidx++)
133      if (sound[sndidx].aliastype == info->aliastype)
134         index++;
619135   info->index = index;
136   totalsnd++;
620137
621138   /* start the chip, tagging all its streams */
622139   current_sound_start = &sound[sndnum];
623   info->device->token = (*info->intf.start)(info->device, clock, config, info->index);
140   start = (snd_start_func)sndtype_get_info_fct(sndtype, SNDINFO_PTR_START);
141   info->device->token = (*start)(info->device, clock, config);
624142   current_sound_start = NULL;
625143   VPRINTF(("  token = %p\n", info->device->token));
626144
r4135r4136
639157
640158void sndintrf_exit_sound(int sndnum)
641159{
160   sndinfo info;
161
162   info.stop = NULL;
163   (*sound[sndnum].intf.get_info)(NULL, SNDINFO_PTR_STOP, &info);
164
642165   /* stop the chip */
643   if (sound[sndnum].intf.stop)
644      (*sound[sndnum].intf.stop)(sound[sndnum].device);
166   if (info.stop)
167      (*info.stop)(sound[sndnum].device);
645168}
646169
647170
r4135r4136
669192
670193int sndti_exists(sound_type type, int index)
671194{
672   return (sound_matrix[type][index] != 0);
195   return (sndti_to_sndnum(type, index) != -1);
673196}
674197
675198
r4135r4136
680203
681204int sndti_to_sndnum(sound_type type, int index)
682205{
683   return sound_matrix[type][index] - 1;
206   int sndnum;
207   for (sndnum = 0; sndnum < totalsnd; sndnum++)
208      if (sound[sndnum].aliastype == type)
209         if (index-- == 0)
210            return sndnum;
211   return -1;
684212}
685213
686214
r4135r4136
801329
802330void sndnum_reset(int sndnum)
803331{
332   sndinfo info;
333
804334   VERIFY_SNDNUM(sndnum_reset);
805   if (sound[sndnum].intf.reset)
806      (*sound[sndnum].intf.reset)(sound[sndnum].device);
335   info.reset = NULL;
336   (*sound[sndnum].intf.get_info)(NULL, SNDINFO_PTR_RESET, &info);
337   if (info.reset)
338      (info.reset)(sound[sndnum].device);
807339}
808340
809341int sndnum_clock(int sndnum)
810342{
811343   VERIFY_SNDNUM(sndnum_clock);
812   return sound[sndnum].clock;
344   return sound[sndnum].device->clock;
813345}
814346
815347void *sndnum_token(int sndnum)
r4135r4136
831363INT64 sndti_get_info_int(sound_type sndtype, int sndindex, UINT32 state)
832364{
833365   sndinfo info;
834   int sndnum;
835366
836367   VERIFY_SNDTI(sndti_get_info_int);
837   sndnum = sound_matrix[sndtype][sndindex] - 1;
838368   info.i = 0;
839369   (*sound[sndnum].intf.get_info)(sound[sndnum].device, state, &info);
840370   return info.i;
r4135r4136
843373void *sndti_get_info_ptr(sound_type sndtype, int sndindex, UINT32 state)
844374{
845375   sndinfo info;
846   int sndnum;
847376
848377   VERIFY_SNDTI(sndti_get_info_ptr);
849   sndnum = sound_matrix[sndtype][sndindex] - 1;
850378   info.p = NULL;
851379   (*sound[sndnum].intf.get_info)(sound[sndnum].device, state, &info);
852380   return info.p;
r4135r4136
855383genf *sndti_get_info_fct(sound_type sndtype, int sndindex, UINT32 state)
856384{
857385   sndinfo info;
858   int sndnum;
859386
860387   VERIFY_SNDTI(sndti_get_info_fct);
861   sndnum = sound_matrix[sndtype][sndindex] - 1;
862388   info.f = NULL;
863389   (*sound[sndnum].intf.get_info)(sound[sndnum].device, state, &info);
864390   return info.f;
r4135r4136
868394{
869395   extern char *get_temp_string_buffer(void);
870396   sndinfo info;
871   int sndnum;
872397
873398   VERIFY_SNDTI(sndti_get_info_string);
874   sndnum = sound_matrix[sndtype][sndindex] - 1;
875399   info.s = get_temp_string_buffer();
876400   (*sound[sndnum].intf.get_info)(sound[sndnum].device, state, &info);
877401   return info.s;
r4135r4136
885409void sndti_set_info_int(sound_type sndtype, int sndindex, UINT32 state, INT64 data)
886410{
887411   sndinfo info;
888   int sndnum;
889412
890413   VERIFY_SNDTI(sndti_set_info_int);
891   sndnum = sound_matrix[sndtype][sndindex] - 1;
892414   info.i = data;
893415   (*sound[sndnum].intf.set_info)(sound[sndnum].device, state, &info);
894416}
r4135r4136
896418void sndti_set_info_ptr(sound_type sndtype, int sndindex, UINT32 state, void *data)
897419{
898420   sndinfo info;
899   int sndnum;
900421
901422   VERIFY_SNDTI(sndti_set_info_ptr);
902   sndnum = sound_matrix[sndtype][sndindex] - 1;
903423   info.p = data;
904424   (*sound[sndnum].intf.set_info)(sound[sndnum].device, state, &info);
905425}
r4135r4136
907427void sndti_set_info_fct(sound_type sndtype, int sndindex, UINT32 state, genf *data)
908428{
909429   sndinfo info;
910   int sndnum;
911430
912431   VERIFY_SNDTI(sndti_set_info_ptr);
913   sndnum = sound_matrix[sndtype][sndindex] - 1;
914432   info.f = data;
915433   (*sound[sndnum].intf.set_info)(sound[sndnum].device, state, &info);
916434}
r4135r4136
922440
923441void sndti_reset(sound_type sndtype, int sndindex)
924442{
925   int sndnum;
443   sndinfo info;
926444
927445   VERIFY_SNDTI(sndti_reset);
928   sndnum = sound_matrix[sndtype][sndindex] - 1;
929   if (sound[sndnum].intf.reset)
930      (*sound[sndnum].intf.reset)(sound[sndnum].device);
446   info.reset = NULL;
447   (*sound[sndnum].intf.get_info)(NULL, SNDINFO_PTR_RESET, &info);
448
449   if (info.reset)
450      (*info.reset)(sound[sndnum].device);
931451}
932452
933453int sndti_clock(sound_type sndtype, int sndindex)
934454{
935   int sndnum;
936455   VERIFY_SNDTI(sndti_clock);
937   sndnum = sound_matrix[sndtype][sndindex] - 1;
938   return sound[sndnum].clock;
456   return sound[sndnum].device->clock;
939457}
940458
941459void *sndti_token(sound_type sndtype, int sndindex)
942460{
943   int sndnum;
944461   VERIFY_SNDTI(sndti_token);
945   sndnum = sound_matrix[sndtype][sndindex] - 1;
946462   return sound[sndnum].device->token;
947463}
948464
r4135r4136
958474
959475INT64 sndtype_get_info_int(sound_type sndtype, UINT32 state)
960476{
961   snd_class_header *classheader = &snd_type_header[sndtype];
477   snd_get_info_func get_info = sndtype;
962478   sndinfo info;
963479
964480   VERIFY_SNDTYPE(sndtype_get_info_int);
965481   info.i = 0;
966   (*classheader->get_info)(NULL, state, &info);
482   (*get_info)(NULL, state, &info);
967483   return info.i;
968484}
969485
970486void *sndtype_get_info_ptr(sound_type sndtype, UINT32 state)
971487{
972   snd_class_header *classheader = &snd_type_header[sndtype];
488   snd_get_info_func get_info = sndtype;
973489   sndinfo info;
974490
975491   VERIFY_SNDTYPE(sndtype_get_info_ptr);
976492   info.p = NULL;
977   (*classheader->get_info)(NULL, state, &info);
493   (*get_info)(NULL, state, &info);
978494   return info.p;
979495}
980496
981497genf *sndtype_get_info_fct(sound_type sndtype, UINT32 state)
982498{
983   snd_class_header *classheader = &snd_type_header[sndtype];
499   snd_get_info_func get_info = sndtype;
984500   sndinfo info;
985501
986502   VERIFY_SNDTYPE(sndtype_get_info_fct);
987503   info.f = NULL;
988   (*classheader->get_info)(NULL, state, &info);
504   (*get_info)(NULL, state, &info);
989505   return info.f;
990506}
991507
992508const char *sndtype_get_info_string(sound_type sndtype, UINT32 state)
993509{
994510   extern char *get_temp_string_buffer(void);
995   snd_class_header *classheader = &snd_type_header[sndtype];
511   snd_get_info_func get_info = sndtype;
996512   sndinfo info;
997513
998514   VERIFY_SNDTYPE(sndtype_get_info_string);
999515   info.s = get_temp_string_buffer();
1000   (*classheader->get_info)(NULL, state, &info);
516   (*get_info)(NULL, state, &info);
1001517   return info.s;
1002518}
1003
1004
1005
1006/***************************************************************************
1007    DUMMY INTERFACES
1008***************************************************************************/
1009
1010static SND_START( dummy_sound )
1011{
1012   logerror("Warning: starting a dummy sound core -- you are missing a hookup in sndintrf.c!\n");
1013   return auto_malloc(1);
1014}
1015
1016
1017static SND_SET_INFO( dummy_sound )
1018{
1019   switch (state)
1020   {
1021      /* no parameters to set */
1022   }
1023}
1024
1025
1026static SND_GET_INFO( dummy_sound )
1027{
1028   switch (state)
1029   {
1030      /* --- the following bits of info are returned as 64-bit signed integers --- */
1031
1032      /* --- the following bits of info are returned as pointers to data or functions --- */
1033      case SNDINFO_PTR_SET_INFO:                  info->set_info = SND_SET_INFO_NAME( dummy_sound );   break;
1034      case SNDINFO_PTR_START:                     info->start = SND_START_NAME( dummy_sound );      break;
1035      case SNDINFO_PTR_STOP:                     /* Nothing */                     break;
1036      case SNDINFO_PTR_RESET:                     /* Nothing */                     break;
1037
1038      /* --- the following bits of info are returned as NULL-terminated strings --- */
1039      case SNDINFO_STR_NAME:                     strcpy(info->s, "Dummy");            break;
1040      case SNDINFO_STR_CORE_FAMILY:               strcpy(info->s, "Dummy");            break;
1041      case SNDINFO_STR_CORE_VERSION:               strcpy(info->s, "1.0");               break;
1042      case SNDINFO_STR_CORE_FILE:                  strcpy(info->s, __FILE__);            break;
1043      case SNDINFO_STR_CORE_CREDITS:               strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
1044   }
1045}
src/emu/sound.c
r4135r4136
291291      info->sound = msound;
292292
293293      /* start the chip, tagging all its streams */
294      VPRINTF(("sndnum = %d -- sound_type = %d\n", sndnum, msound->type));
294      VPRINTF(("sndnum = %d -- sound_type = %s\n", sndnum, sndtype_get_name(msound->type)));
295295      num_regs = state_save_get_reg_count(machine);
296296      streams_set_tag(machine, info);
297297      if (sndintrf_init_sound(machine, sndnum, msound->tag, msound->type, msound->clock, msound->config) != 0)
r4135r4136
903903
904904   if (sndnum < 0)
905905   {
906      logerror("sndti_set_output_gain called for invalid sound type %d, index %d\n", type, index);
906      logerror("sndti_set_output_gain called for invalid sound type %s, index %d\n", sndtype_get_name(type), index);
907907      return;
908908   }
909909   if (output >= sound[sndnum].outputs)
910910   {
911      logerror("sndti_set_output_gain called for invalid sound output %d (type %d, index %d)\n", output, type, index);
911      logerror("sndti_set_output_gain called for invalid sound output %d (type %s, index %d)\n", output, sndtype_get_name(type), index);
912912      return;
913913   }
914914   stream_set_output_gain(sound[sndnum].output[output].stream, sound[sndnum].output[output].output, gain);
src/emu/sndintrf.h
r4135r4136
2525
2626#define MAX_SOUND 32
2727
28/* Enum listing all the sound chips */
29enum _sound_type
30{
31   SOUND_DUMMY,
32   SOUND_CUSTOM,
33   SOUND_SAMPLES,
34   SOUND_DAC,
35   SOUND_DMADAC,
36   SOUND_DISCRETE,
37   SOUND_AY8910,
38   SOUND_AY8912,
39   SOUND_AY8913,
40   SOUND_AY8930,
41   SOUND_YM2149,
42   SOUND_YM3439,
43   SOUND_YMZ284,
44   SOUND_YMZ294,
45   SOUND_YM2203,
46   SOUND_YM2151,
47   SOUND_YM2608,
48   SOUND_YM2610,
49   SOUND_YM2610B,
50   SOUND_YM2612,
51   SOUND_YM3438,
52   SOUND_YM2413,
53   SOUND_YM3812,
54   SOUND_YM3526,
55   SOUND_YMZ280B,
56   SOUND_Y8950,
57   SOUND_SN76477,
58   SOUND_SN76489,
59   SOUND_SN76489A,
60   SOUND_SN76494,
61   SOUND_SN76496,
62   SOUND_GAMEGEAR,
63   SOUND_SMSIII,
64   SOUND_POKEY,
65   SOUND_NES,
66   SOUND_ASTROCADE,
67   SOUND_NAMCO,
68   SOUND_NAMCO_15XX,
69   SOUND_NAMCO_CUS30,
70   SOUND_NAMCO_52XX,
71   SOUND_NAMCO_63701X,
72   SOUND_SNKWAVE,
73   SOUND_TMS36XX,
74   SOUND_TMS3615,
75   SOUND_TMS5100,
76   SOUND_TMS5110,
77   SOUND_TMS5110A,
78   SOUND_CD2801,
79   SOUND_TMC0281,
80   SOUND_CD2802,
81   SOUND_M58817,
82   SOUND_TMC0285,
83   SOUND_TMS5200,
84   SOUND_TMS5220,
85   SOUND_VLM5030,
86   SOUND_OKIM6295,
87   SOUND_OKIM6258,
88   SOUND_MSM5205,
89   SOUND_MSM5232,
90   SOUND_UPD7759,
91   SOUND_HC55516,
92   SOUND_MC3417,
93   SOUND_MC3418,
94   SOUND_K005289,
95   SOUND_K007232,
96   SOUND_K051649,
97   SOUND_K053260,
98   SOUND_K054539,
99   SOUND_SEGAPCM,
100   SOUND_RF5C68,
101   SOUND_CEM3394,
102   SOUND_C140,
103   SOUND_QSOUND,
104   SOUND_SAA1099,
105   SOUND_IREMGA20,
106   SOUND_ES5503,
107   SOUND_ES5505,
108   SOUND_ES5506,
109   SOUND_BSMT2000,
110   SOUND_YMF262,
111   SOUND_YMF278B,
112   SOUND_GAELCO_CG1V,
113   SOUND_GAELCO_GAE1,
114   SOUND_X1_010,
115   SOUND_MULTIPCM,
116   SOUND_C6280,
117   SOUND_TIA,
118   SOUND_SP0250,
119   SOUND_SCSP,
120   SOUND_PSXSPU,
121   SOUND_YMF271,
122   SOUND_CDDA,
123   SOUND_ICS2115,
124   SOUND_ST0016,
125   SOUND_NILE,
126   SOUND_C352,
127   SOUND_VRENDER0,
128   SOUND_VOTRAX,
129   SOUND_ES8712,
130   SOUND_RF5C400,
131   SOUND_SPEAKER,
132   SOUND_CDP1869,
133   SOUND_BEEP,
134   SOUND_WAVE,
135   SOUND_SID6581,
136   SOUND_SID8580,
137   SOUND_SP0256,
138   SOUND_S14001A,
139   SOUND_AICA,
14028
141   /* filters start here */
142   SOUND_FILTER_VOLUME,
143   SOUND_FILTER_RC,
144   SOUND_FILTER_LOWPASS,
145
146   SOUND_COUNT
147};
148typedef enum _sound_type sound_type;
149
150
15129/* Sound information constants */
15230enum
15331{
15432   /* --- the following bits of info are returned as 64-bit signed integers --- */
15533   SNDINFO_INT_FIRST = DEVINFO_INT_FIRST,
15634
157      SNDINFO_INT_ALIAS = DEVINFO_INT_CLASS_SPECIFIC,      /* R/O: alias to sound type for (type,index) identification */
158
15935   SNDINFO_INT_CORE_SPECIFIC = DEVINFO_INT_DEVICE_SPECIFIC, /* R/W: core-specific values start here */
16036
16137   /* --- the following bits of info are returned as pointers to data or functions --- */
r4135r4136
17046      SNDINFO_PTR_RESET = DEVINFO_FCT_RESET,            /* R/O: void (*reset)(const device_config *device) */
17147
17248      SNDINFO_PTR_SET_INFO = DEVINFO_FCT_CLASS_SPECIFIC,   /* R/O: void (*set_info)(const device_config *device, UINT32 state, sndinfo *info) */
173      SNDINFO_PTR_START,                           /* R/O: void *(*start)(const device_config *device, int clock, const void *config, int sndindex) */
49      SNDINFO_PTR_START,                           /* R/O: void *(*start)(const device_config *device, int clock, const void *config) */
50      SNDINFO_FCT_ALIAS,                           /* R/O: alias to sound type for (type,index) identification */
17451
17552   SNDINFO_FCT_CORE_SPECIFIC = DEVINFO_FCT_DEVICE_SPECIFIC, /* R/W: core-specific values start here */
17653
r4135r4136
20178#define SND_SET_INFO_CALL(name)      SND_SET_INFO_NAME(name)(device, state, info)
20279
20380#define SND_START_NAME(name)      snd_start_##name
204#define SND_START(name)            void *SND_START_NAME(name)(const device_config *device, int clock, const void *config, int sndindex)
205#define SND_START_CALL(name)      SND_START_NAME(name)(device, clock, config, sndindex)
81#define SND_START(name)            void *SND_START_NAME(name)(const device_config *device, int clock, const void *config)
82#define SND_START_CALL(name)      SND_START_NAME(name)(device, clock, config)
20683
20784#define SND_STOP_NAME(name)         snd_stop_##name
20885#define SND_STOP(name)            void SND_STOP_NAME(name)(const device_config *device)
r4135r4136
224101/* define the various callback functions */
225102typedef void (*snd_get_info_func)(const device_config *device, UINT32 state, sndinfo *info);
226103typedef void (*snd_set_info_func)(const device_config *device, UINT32 state, sndinfo *info);
227typedef void *(*snd_start_func)(const device_config *device, int clock, const void *config, int sndindex);
104typedef void *(*snd_start_func)(const device_config *device, int clock, const void *config);
228105typedef void (*snd_stop_func)(const device_config *device);
229106typedef void (*snd_reset_func)(const device_config *device);
230107
108typedef snd_get_info_func sound_type;
231109
110
232111/* sndinfo union used to pass data to/from the get_info/set_info functions */
233112union _sndinfo
234113{
r4135r4136
236115   void *   p;                                 /* generic pointers */
237116   genf *  f;                                 /* generic function pointers */
238117   char *   s;                                 /* generic strings */
118   sound_type type;                           /* generic type */
239119
240120   snd_set_info_func   set_info;                  /* SNDINFO_PTR_SET_INFO */
241121   snd_start_func      start;                     /* SNDINFO_PTR_START */
r4135r4136
246126typedef struct _snd_class_header snd_class_header;
247127struct _snd_class_header
248128{
249   int                  index;               /* index of this SND */
250   sound_type            sndtype;             /* type index of this SND */
251
252129   /* table of core functions */
253130   snd_get_info_func   get_info;
254131   snd_set_info_func   set_info;
255   snd_start_func      start;
256   snd_stop_func      stop;
257   snd_reset_func      reset;
258132};
259133
260134
r4135r4136
351225sound_type sndnum_to_sndti(int sndnum, int *index);
352226int sndtype_count(sound_type sndtype);
353227
228#define SOUND_DUMMY NULL
354229
230
355231#endif   /* __SNDINTRF_H__ */
src/emu/drawgfx.c
r4135r4136
99
1010*********************************************************************/
1111
12#ifndef DECLAREG
13
1412#include "driver.h"
15#include "profiler.h"
13#include "drawgfxm.h"
1614
1715
1816/***************************************************************************
19    CONSTANTS
17    GLOBAL VARIABLES
2018***************************************************************************/
2119
22#ifdef LSB_FIRST
23#define SHIFT0 0
24#define SHIFT1 8
25#define SHIFT2 16
26#define SHIFT3 24
27#else
28#define SHIFT3 0
29#define SHIFT2 8
30#define SHIFT1 16
31#define SHIFT0 24
32#endif
20/* if this line errors during compile, the size of NO_PRIORITY is wrong and I need to use something else */
21UINT8 no_priority_size_is_wrong[2 * (sizeof(NO_PRIORITY) == 3) - 1];
3322
3423
3524
3625/***************************************************************************
37    GLOBAL VARIABLES
26    FUNCTION PROTOTYPES
3827***************************************************************************/
3928
40UINT8 gfx_drawmode_table[256];
41UINT8 gfx_alpharange_table[256];
29void decodechar(const gfx_element *gfx, UINT32 code, const UINT8 *src);
4230
43alpha_cache drawgfx_alpha_cache;
4431
4532
46
4733/***************************************************************************
4834    INLINE FUNCTIONS
4935***************************************************************************/
5036
5137/*-------------------------------------------------
52    write_dword - safely write an unaligned DWORD
53-------------------------------------------------*/
54
55#ifdef ALIGN_INTS /* GSL 980108 read/write nonaligned dword routine for ARM processor etc */
56
57INLINE void write_dword(void *address, UINT32 data)
58{
59     if ((FPTR)address & 3)
60   {
61      *((UINT8 *)address)   = (data>>SHIFT0);
62      *((UINT8 *)address+1) = (data>>SHIFT1);
63      *((UINT8 *)address+2) = (data>>SHIFT2);
64      *((UINT8 *)address+3) = (data>>SHIFT3);
65      return;
66     }
67     else
68      *(UINT32 *)address = data;
69}
70
71#else
72
73#define write_dword(address,data) *(int *)address=data
74
75#endif
76
77
78/*-------------------------------------------------
7938    readbit - read a single bit from a base
8039    offset
8140-------------------------------------------------*/
r4135r4136
8645}
8746
8847
89
90/***************************************************************************
91    INITIALIZATION
92***************************************************************************/
93
94void drawgfx_init(running_machine *machine)
95{
96   /* initialize the alpha drawing table */
97   alpha_set_level(255);
98}
99
100
101
102/***************************************************************************
103    GRAPHICS DECODING
104***************************************************************************/
105
10648/*-------------------------------------------------
107    calc_penusage - calculate the pen usage for
108    a given graphics tile
49    normalize_xscroll - normalize an X scroll
50    value for a bitmap to be positive and less
51    than the width
10952-------------------------------------------------*/
11053
111static void calc_penusage(gfx_element *gfx, int num)
54INLINE INT32 normalize_xscroll(bitmap_t *bitmap, INT32 xscroll)
11255{
113   const UINT8 *dp = gfx->gfxdata + num * gfx->char_modulo;
114   UINT32 usage = 0;
115   int x, y;
116
117   /* if nothing allocated, don't do it */
118   if (!gfx->pen_usage)
119      return;
120
121   /* packed case */
122   if (gfx->flags & GFX_ELEMENT_PACKED)
123      for (y = 0; y < gfx->height; y++)
124      {
125         for (x = 0; x < gfx->width/2; x++)
126            usage |= (1 << (dp[x] & 0x0f)) | (1 << (dp[x] >> 4));
127
128         dp += gfx->line_modulo;
129      }
130
131   /* unpacked case */
132   else
133      for (y = 0; y < gfx->height; y++)
134      {
135         for (x = 0; x < gfx->width; x++)
136            usage |= 1 << dp[x];
137
138         dp += gfx->line_modulo;
139      }
140
141   /* store the final result */
142   gfx->pen_usage[num] = usage;
56   return (xscroll >= 0) ? xscroll % bitmap->width : (bitmap->width - (-xscroll) % bitmap->width);
14357}
14458
14559
14660/*-------------------------------------------------
147    decodechar - decode a single character based
148    on a specified layout
61    normalize_yscroll - normalize a Y scroll
62    value for a bitmap to be positive and less
63    than the height
14964-------------------------------------------------*/
15065
151void decodechar(gfx_element *gfx, int num, const UINT8 *src)
66INLINE INT32 normalize_yscroll(bitmap_t *bitmap, INT32 yscroll)
15267{
153   const gfx_layout *gl = &gfx->layout;
154   int israw = (gl->planeoffset[0] == GFX_RAW);
155   int planes = gl->planes;
156   UINT32 charincrement = gl->charincrement;
157   const UINT32 *poffset = gl->planeoffset;
158   const UINT32 *xoffset = gl->extxoffs ? gl->extxoffs : gl->xoffset;
159   const UINT32 *yoffset = gl->extyoffs ? gl->extyoffs : gl->yoffset;
160   UINT8 *dp = gfx->gfxdata + num * gfx->char_modulo;
161   int plane, x, y;
162
163   assert_always(!israw, "decodechar: raw layouts not supported");
164
165   /* zap the data to 0 */
166   memset(dp, 0, gfx->char_modulo);
167
168   /* packed case */
169   if (gfx->flags & GFX_ELEMENT_PACKED)
170      for (plane = 0; plane < planes; plane++)
171      {
172         int planebit = 1 << (planes - 1 - plane);
173         int planeoffs = num * charincrement + poffset[plane];
174
175         for (y = 0; y < gfx->height; y++)
176         {
177            int yoffs = planeoffs + yoffset[y];
178
179            dp = gfx->gfxdata + num * gfx->char_modulo + y * gfx->line_modulo;
180            for (x = 0; x < gfx->width; x += 2)
181            {
182               if (readbit(src, yoffs + xoffset[x+0]))
183                  dp[x+0] |= planebit;
184               if (readbit(src, yoffs + xoffset[x+1]))
185                  dp[x+1] |= planebit;
186            }
187         }
188      }
189
190   /* unpacked case */
191   else
192      for (plane = 0; plane < planes; plane++)
193      {
194         int planebit = 1 << (planes - 1 - plane);
195         int planeoffs = num * charincrement + poffset[plane];
196
197         for (y = 0; y < gfx->height; y++)
198         {
199            int yoffs = planeoffs + yoffset[y];
200
201            dp = gfx->gfxdata + num * gfx->char_modulo + y * gfx->line_modulo;
202            for (x = 0; x < gfx->width; x++)
203               if (readbit(src, yoffs + xoffset[x]))
204                  dp[x] |= planebit;
205         }
206      }
207
208   /* compute pen usage */
209   calc_penusage(gfx, num);
68   return (yscroll >= 0) ? yscroll % bitmap->height : (bitmap->height - (-yscroll) % bitmap->height);
21069}
21170
21271
21372
21473/***************************************************************************
215    GRAPHICS SETS
74    GRAPHICS ELEMENTS
21675***************************************************************************/
21776
21877/*-------------------------------------------------
219    allocgfx - allocate a gfx_element structure
78    gfx_element_alloc - allocate a gfx_element structure
22079    based on a given layout
22180-------------------------------------------------*/
22281
223gfx_element *allocgfx(running_machine *machine, const gfx_layout *gl)
82gfx_element *gfx_element_alloc(running_machine *machine, const gfx_layout *gl, const UINT8 *srcdata, UINT32 total_colors, UINT32 color_base)
22483{
22584   int israw = (gl->planeoffset[0] == GFX_RAW);
22685   int planes = gl->planes;
r4135r4136
23392   gfx = malloc_or_die(sizeof(*gfx));
23493   memset(gfx, 0, sizeof(*gfx));
23594
95   /* fill in the data */
96   gfx->width = width;
97   gfx->height = height;
98
99   gfx->origwidth = width;
100   gfx->origheight = height;
101   gfx->total_elements = total;
102
103   gfx->color_base = color_base;
104   gfx->color_depth = 1 << planes;
105   gfx->color_granularity = 1 << planes;
106   gfx->total_colors = total_colors;
107
108   gfx->srcdata = srcdata;
236109   gfx->machine = machine;
237110
238111   /* copy the layout */
239112   gfx->layout = *gl;
240   if (gl->extxoffs != NULL)
113   if (gfx->layout.extxoffs != NULL)
241114   {
242      UINT32 *buffer = malloc_or_die(sizeof(buffer[0]) * gl->width);
243      memcpy(buffer, gl->extxoffs, sizeof(gfx->layout.extxoffs[0]) * gl->width);
244      gfx->layout.extxoffs = buffer;
115      if (gfx->layout.width < ARRAY_LENGTH(gfx->layout.xoffset))
116      {
117         memcpy(gfx->layout.xoffset, gfx->layout.extxoffs, sizeof(gfx->layout.xoffset[0]) * gfx->layout.width);
118         gfx->layout.extxoffs = NULL;
119      }
120      else
121      {
122         UINT32 *buffer = malloc_or_die(sizeof(buffer[0]) * gfx->layout.width);
123         memcpy(buffer, gfx->layout.extxoffs, sizeof(gfx->layout.extxoffs[0]) * gfx->layout.width);
124         gfx->layout.extxoffs = buffer;
125      }
245126   }
246127
247   if (gl->extyoffs != NULL)
128   if (gfx->layout.extyoffs != NULL)
248129   {
249      UINT32 *buffer = malloc_or_die(sizeof(buffer[0]) * gl->height);
250      memcpy(buffer, gl->extyoffs, sizeof(gfx->layout.extyoffs[0]) * gl->height);
251      gfx->layout.extyoffs = buffer;
130      if (gfx->layout.height < ARRAY_LENGTH(gfx->layout.yoffset))
131      {
132         memcpy(gfx->layout.yoffset, gfx->layout.extyoffs, sizeof(gfx->layout.yoffset[0]) * gfx->layout.height);
133         gfx->layout.extyoffs = NULL;
134      }
135      else
136      {
137         UINT32 *buffer = malloc_or_die(sizeof(buffer[0]) * gfx->layout.height);
138         memcpy(buffer, gfx->layout.extyoffs, sizeof(gfx->layout.extyoffs[0]) * gfx->layout.height);
139         gfx->layout.extyoffs = buffer;
140      }
252141   }
253142
254   /* fill in the rest */
255   gfx->width = width;
256   gfx->height = height;
257   gfx->total_elements = total;
258   gfx->color_base = 0;
259   gfx->color_depth = 1 << planes;
260   gfx->color_granularity = 1 << planes;
143   /* allocate a pen usage array for entries with 32 pens or less */
261144   if (gfx->color_depth <= 32)
262145      gfx->pen_usage = malloc_or_die(gfx->total_elements * sizeof(*gfx->pen_usage));
263146
147   /* allocate a dirty array */
148   gfx->dirty = malloc_or_die(gfx->total_elements * sizeof(*gfx->dirty));
149   memset(gfx->dirty, 1, gfx->total_elements * sizeof(*gfx->dirty));
150
264151   /* raw graphics case */
265152   if (israw)
266153   {
r4135r4136
272159      gfx->flags |= GFX_ELEMENT_DONT_FREE;
273160      if (planes <= 4)
274161         gfx->flags |= GFX_ELEMENT_PACKED;
162
163      /* RAW graphics must have a pointer up front */
164      gfx->gfxdata = (UINT8 *)gfx->srcdata;
275165   }
276166
277167   /* decoded graphics case */
278168   else
279169   {
280170      /* we get to pick our own modulos */
281      gfx->line_modulo = gfx->width;
282      gfx->char_modulo = gfx->line_modulo * gfx->height;
171      gfx->line_modulo = gfx->origwidth;
172      gfx->char_modulo = gfx->line_modulo * gfx->origheight;
283173
284174      /* allocate memory for the data */
285      gfx->gfxdata = malloc_or_die(gfx->total_elements * gfx->char_modulo * sizeof(UINT8));
175      gfx->gfxdata = malloc_or_die(gfx->total_elements * gfx->char_modulo);
286176   }
287177
288178   return gfx;
r4135r4136
290180
291181
292182/*-------------------------------------------------
293    decodegfx - decode a series of tiles from
294    a particular gfx_element
183    gfx_element_decode - update a single code in
184    a gfx_element
295185-------------------------------------------------*/
296186
297void decodegfx(gfx_element *gfx, const UINT8 *src, UINT32 first, UINT32 count)
187void gfx_element_decode(const gfx_element *gfx, UINT32 code)
298188{
299   int last = first + count - 1;
300   int c;
301
302   assert(gfx);
303   assert(first < gfx->total_elements);
304   assert(last < gfx->total_elements);
305
306   /* if this is raw graphics data, just set the pointer and compute pen usage */
307   if (gfx->flags & GFX_ELEMENT_DONT_FREE)
308   {
309      /* if we got a pointer, set it */
310      if (first == 0 && src)
311         gfx->gfxdata = (UINT8 *)src;
312
313      /* compute pen usage for everything */
314      for (c = first; c <= last; c++)
315         calc_penusage(gfx, c);
316   }
317
318   /* otherwise, we get to manually decode */
319   else
320      for (c = first; c <= last; c++)
321         decodechar(gfx, c, src);
189   decodechar(gfx, code, gfx->srcdata);
322190}
323191
324192
325193/*-------------------------------------------------
326    freegfx - free a gfx_element
194    gfx_element_free - free a gfx_element
327195-------------------------------------------------*/
328196
329void freegfx(gfx_element *gfx)
197void gfx_element_free(gfx_element *gfx)
330198{
331199   /* ignore NULL frees */
332200   if (gfx == NULL)
333201      return;
334202
335203   /* free our data */
336   if (gfx->layout.extyoffs)
204   if (gfx->layout.extyoffs != NULL)
337205      free((void *)gfx->layout.extyoffs);
338   if (gfx->layout.extxoffs)
206   if (gfx->layout.extxoffs != NULL)
339207      free((void *)gfx->layout.extxoffs);
340   if (gfx->pen_usage)
208   if (gfx->pen_usage != NULL)
341209      free(gfx->pen_usage);
210   if (gfx->dirty != NULL)
211      free(gfx->dirty);
342212   if (!(gfx->flags & GFX_ELEMENT_DONT_FREE))
343213      free(gfx->gfxdata);
344214   free(gfx);
345215}
346216
347217
218/*-------------------------------------------------
219    gfx_element_build_temporary - create a
220    temporary one-off gfx_element
221-------------------------------------------------*/
348222
349/***************************************************************************
350    BLOCKMOVE PRIMITIVES
351***************************************************************************/
352
353INLINE void blockmove_NtoN_transpen_noremap16(
354      const UINT16 *srcdata,int srcwidth,int srcheight,int srcmodulo,
355      UINT16 *dstdata,int dstmodulo,
356      int transpen)
223void gfx_element_build_temporary(gfx_element *gfx, running_machine *machine, UINT8 *base, UINT32 width, UINT32 height, UINT32 rowbytes, UINT32 color_base, UINT32 color_granularity, UINT32 flags)
357224{
358   UINT16 *end;
225   static UINT8 not_dirty = 0;
359226
360   srcmodulo -= srcwidth;
361   dstmodulo -= srcwidth;
227   gfx->width = width;
228   gfx->height = height;
229   gfx->startx = 0;
230   gfx->starty = 0;
362231
363   while (srcheight)
364   {
365      end = dstdata + srcwidth;
366      while (dstdata < end)
367      {
368         int col;
232   gfx->origwidth = width;
233   gfx->origheight = height;
234   gfx->flags = flags;
235   gfx->total_elements = 1;
369236
370         col = *(srcdata++);
371         if (col != transpen) *dstdata = col;
372         dstdata++;
373      }
237   gfx->color_base = color_base;
238   gfx->color_depth = color_granularity;
239   gfx->color_granularity = color_granularity;
240   gfx->total_colors = (machine->config->total_colors - color_base) / color_granularity;
374241
375      srcdata += srcmodulo;
376      dstdata += dstmodulo;
377      srcheight--;
378   }
379}
242   gfx->pen_usage = NULL;
380243
381INLINE void blockmove_NtoN_transpen_noremap_flipx16(
382      const UINT16 *srcdata,int srcwidth,int srcheight,int srcmodulo,
383      UINT16 *dstdata,int dstmodulo,
384      int transpen)
385{
386   UINT16 *end;
244   gfx->gfxdata = base;
245   gfx->line_modulo = rowbytes;
246   gfx->char_modulo = 0;
247   gfx->srcdata = base;
248   gfx->dirty = &not_dirty;
249   gfx->dirtyseq = 0;
387250
388   srcmodulo += srcwidth;
389   dstmodulo -= srcwidth;
251   gfx->machine = machine;
252}
390253
391   while (srcheight)
392   {
393      end = dstdata + srcwidth;
394      while (dstdata < end)
395      {
396         int col;
397254
398         col = *(srcdata--);
399         if (col != transpen) *dstdata = col;
400         dstdata++;
401      }
255/*-------------------------------------------------
256    calc_penusage - calculate the pen usage for
257    a given graphics tile
258-------------------------------------------------*/
402259
403      srcdata += srcmodulo;
404      dstdata += dstmodulo;
405      srcheight--;
406   }
407}
408
409INLINE void blockmove_NtoN_transpen_noremap32(
410      const UINT32 *srcdata,int srcwidth,int srcheight,int srcmodulo,
411      UINT32 *dstdata,int dstmodulo,
412      int transpen)
260static void calc_penusage(const gfx_element *gfx, UINT32 code)
413261{
414   UINT32 *end;
262   const UINT8 *dp = gfx->gfxdata + code * gfx->char_modulo;
263   UINT32 usage = 0;
264   int x, y;
415265
416   srcmodulo -= srcwidth;
417   dstmodulo -= srcwidth;
266   /* if nothing allocated, don't do it */
267   if (gfx->pen_usage == NULL)
268      return;
418269
419   while (srcheight)
420   {
421      end = dstdata + srcwidth;
422      while (dstdata < end)
270   /* packed case */
271   if (gfx->flags & GFX_ELEMENT_PACKED)
272      for (y = 0; y < gfx->origheight; y++)
423273      {
424         int col;
274         for (x = 0; x < gfx->origwidth/2; x++)
275            usage |= (1 << (dp[x] & 0x0f)) | (1 << (dp[x] >> 4));
425276
426         col = *(srcdata++);
427         if (col != transpen) *dstdata = col;
428         dstdata++;
277         dp += gfx->line_modulo;
429278      }
430279
431      srcdata += srcmodulo;
432      dstdata += dstmodulo;
433      srcheight--;
434   }
435}
436
437INLINE void blockmove_NtoN_transpen_noremap_flipx32(
438      const UINT32 *srcdata,int srcwidth,int srcheight,int srcmodulo,
439      UINT32 *dstdata,int dstmodulo,
440      int transpen)
441{
442   UINT32 *end;
443
444   srcmodulo += srcwidth;
445   dstmodulo -= srcwidth;
446
447   while (srcheight)
448   {
449      end = dstdata + srcwidth;
450      while (dstdata < end)
280   /* unpacked case */
281   else
282      for (y = 0; y < gfx->origheight; y++)
451283      {
452         int col;
284         for (x = 0; x < gfx->origwidth; x++)
285            usage |= 1 << dp[x];
453286
454         col = *(srcdata--);
455         if (col != transpen) *dstdata = col;
456         dstdata++;
287         dp += gfx->line_modulo;
457288      }
458289
459      srcdata += srcmodulo;
460      dstdata += dstmodulo;
461      srcheight--;
462   }
290   /* store the final result */
291   gfx->pen_usage[code] = usage;
463292}
464293
465294
295/*-------------------------------------------------
296    decodechar - decode a single character based
297    on a specified layout
298-------------------------------------------------*/
466299
467static int afterdrawmask = 31;
468int pdrawgfx_shadow_lowpri = 0;
300void decodechar(const gfx_element *gfx, UINT32 code, const UINT8 *src)
301{
302   const gfx_layout *gl = &gfx->layout;
303   int israw = (gl->planeoffset[0] == GFX_RAW);
304   int planes = gl->planes;
305   UINT32 charincrement = gl->charincrement;
306   const UINT32 *poffset = gl->planeoffset;
307   const UINT32 *xoffset = gl->extxoffs ? gl->extxoffs : gl->xoffset;
308   const UINT32 *yoffset = gl->extyoffs ? gl->extyoffs : gl->yoffset;
309   UINT8 *dp = gfx->gfxdata + code * gfx->char_modulo;
310   int plane, x, y;
469311
470/* 8-bit version (only used to generate the draw_scanline family of functions) */
471#define DATA_TYPE UINT8
472#define DEPTH 8
473#define DECLAREG(function,args,body) void function##8 args body
474#include "drawgfx.c"
475#undef DECLAREG
476#undef DEPTH
477#undef DATA_TYPE
312   if (!israw)
313   {
314      /* zap the data to 0 */
315      memset(dp, 0, gfx->char_modulo);
478316
479/* 16-bit version */
480#define DATA_TYPE UINT16
481#define DEPTH 16
482#define alpha_blend_r alpha_blend_r16
483#define alpha_blend alpha_blend16
317      /* packed case */
318      if (gfx->flags & GFX_ELEMENT_PACKED)
319         for (plane = 0; plane < planes; plane++)
320         {
321            int planebit = 1 << (planes - 1 - plane);
322            int planeoffs = code * charincrement + poffset[plane];
484323
485#define DECLARE(function,args,body)
486#define DECLAREG(function,args,body)
324            for (y = 0; y < gfx->origheight; y++)
325            {
326               int yoffs = planeoffs + yoffset[y];
487327
488#define HMODULO 1
489#define VMODULO dstmodulo
490#define COMMON_ARGS                                          \
491      pen_t *palette_shadow_table,                           \
492      const UINT8 *srcdata,int srcwidth,int srcheight,int srcmodulo,   \
493      int leftskip,int topskip,int flipx,int flipy,               \
494      DATA_TYPE *dstdata,int dstwidth,int dstheight,int dstmodulo
328               dp = gfx->gfxdata + code * gfx->char_modulo + y * gfx->line_modulo;
329               for (x = 0; x < gfx->origwidth; x += 2)
330               {
331                  if (readbit(src, yoffs + xoffset[x+0]))
332                     dp[x+0] |= planebit;
333                  if (readbit(src, yoffs + xoffset[x+1]))
334                     dp[x+1] |= planebit;
335               }
336            }
337         }
495338
496#define RAW 1
497#define COLOR_ARG int color,UINT8 *pridata,UINT32 pmask
498#define INCREMENT_DST(n) {dstdata+=(n);pridata += (n);}
499#define LOOKUP(n) (color + (n))
500#define SETPIXELCOLOR(dest,n) { if (((1 << (pridata[dest] & 0x1f)) & pmask) == 0) { if (pridata[dest] & 0x80) { dstdata[dest] = palette_shadow_table[n];} else { dstdata[dest] = (n);} } pridata[dest] = (pridata[dest] & 0x7f) | afterdrawmask; }
501#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_raw_pri16 args body
502#include "drawgfx.c"
503#undef DECLARE_SWAP_RAW_PRI
504#undef COLOR_ARG
505#undef LOOKUP
506#undef SETPIXELCOLOR
507#undef RAW
339      /* unpacked case */
340      else
341         for (plane = 0; plane < planes; plane++)
342         {
343            int planebit = 1 << (planes - 1 - plane);
344            int planeoffs = code * charincrement + poffset[plane];
508345
509#define RAW 0
510#define COLOR_ARG int colorbase,const pen_t *paldata,UINT8 *pridata,UINT32 pmask
511#define LOOKUP(n) (paldata[n])
512//#define LOOKUP(n) (colorbase + (n))
513#define SETPIXELCOLOR(dest,n) { if (((1 << (pridata[dest] & 0x1f)) & pmask) == 0) { if (pridata[dest] & 0x80) { dstdata[dest] = palette_shadow_table[n];} else { dstdata[dest] = (n);} } pridata[dest] = (pridata[dest] & 0x7f) | afterdrawmask; }
514#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_pri16 args body
515#include "drawgfx.c"
516#undef DECLARE_SWAP_RAW_PRI
517#undef COLOR_ARG
518#undef LOOKUP
519#undef INCREMENT_DST
520#undef SETPIXELCOLOR
521#undef RAW
346            for (y = 0; y < gfx->origheight; y++)
347            {
348               int yoffs = planeoffs + yoffset[y];
522349
523#define RAW 1
524#define COLOR_ARG int color
525#define INCREMENT_DST(n) {dstdata+=(n);}
526#define LOOKUP(n) (color + (n))
527#define SETPIXELCOLOR(dest,n) {dstdata[dest] = (n);}
528#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_raw16 args body
529#include "drawgfx.c"
530#undef DECLARE_SWAP_RAW_PRI
531#undef COLOR_ARG
532#undef LOOKUP
533#undef SETPIXELCOLOR
534#undef RAW
350               dp = gfx->gfxdata + code * gfx->char_modulo + y * gfx->line_modulo;
351               for (x = 0; x < gfx->origwidth; x++)
352                  if (readbit(src, yoffs + xoffset[x]))
353                     dp[x] |= planebit;
354            }
355         }
356   }
535357
536#define RAW 0
537#define COLOR_ARG int colorbase, const pen_t *paldata
538#define LOOKUP(n) (paldata[n])
539//#define LOOKUP(n) (colorbase + (n))
540#define SETPIXELCOLOR(dest,n) {dstdata[dest] = (n);}
541#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##16 args body
542#include "drawgfx.c"
543#undef DECLARE_SWAP_RAW_PRI
544#undef COLOR_ARG
545#undef LOOKUP
546#undef INCREMENT_DST
547#undef SETPIXELCOLOR
358   /* compute pen usage */
359   calc_penusage(gfx, code);
548360
549#undef HMODULO
550#undef VMODULO
551#undef COMMON_ARGS
552#undef DECLARE
553#undef DECLAREG
361   /* no longer dirty */
362   gfx->dirty[code] = 0;
363}
554364
555#define DECLARE(function,args,body) static void function##16 args body
556#define DECLAREG(function,args,body) void function##16 args body
557#define DECLARE_SWAP_RAW_PRI(function,args,body)
558#define BLOCKMOVE(function,flipx,args) \
559   if (flipx) blockmove_##function##_flipx##16 args ; \
560   else blockmove_##function##16 args
561#define BLOCKMOVELU(function,args) \
562   blockmove_##function##16 args
563#define BLOCKMOVERAW(function,args) \
564   blockmove_##function##_raw##16 args
565#define BLOCKMOVEPRI(function,args) \
566   blockmove_##function##_pri##16 args
567#define BLOCKMOVERAWPRI(function,args) \
568   blockmove_##function##_raw_pri##16 args
569#include "drawgfx.c"
570#undef DECLARE
571#undef DECLARE_SWAP_RAW_PRI
572#undef DECLAREG
573#undef BLOCKMOVE
574#undef BLOCKMOVELU
575#undef BLOCKMOVERAW
576#undef BLOCKMOVEPRI
577#undef BLOCKMOVERAWPRI
578365
579#undef RAW
580#undef DEPTH
581#undef DATA_TYPE
582#undef alpha_blend_r
583#undef alpha_blend
366/*-------------------------------------------------
367    decodegfx - decode a series of tiles from
368    a particular gfx_element
369-------------------------------------------------*/
584370
585/* 32-bit version */
586INLINE UINT32 SHADOW32(pen_t *shadow_table, UINT32 c)
371void decodegfx(gfx_element *gfx, UINT32 first, UINT32 count)
587372{
588   return shadow_table[((c >> 9) & 0x7c00) | ((c >> 6) & 0x03e0) | ((c >> 3) & 0x001f)];
589}
373   int last = first + count - 1;
374   int c;
590375
591#define DATA_TYPE UINT32
592#define DEPTH 32
593#define alpha_blend_r alpha_blend_r32
594#define alpha_blend alpha_blend32
376   assert(gfx != NULL);
377   assert(gfx->srcdata != NULL);
378   assert(first < gfx->total_elements);
379   assert(last < gfx->total_elements);
595380
596#define DECLARE(function,args,body)
597#define DECLAREG(function,args,body)
381   /* if this is raw graphics data, just set the pointer and compute pen usage */
382   if (gfx->flags & GFX_ELEMENT_DONT_FREE)
383   {
384      /* if we got a pointer, set it */
385      gfx->gfxdata = (UINT8 *)gfx->srcdata;
598386
599#define HMODULO 1
600#define VMODULO dstmodulo
601#define COMMON_ARGS                                          \
602      pen_t *palette_shadow_table,                           \
603      const UINT8 *srcdata,int srcwidth,int srcheight,int srcmodulo,   \
604      int leftskip,int topskip,int flipx,int flipy,               \
605      DATA_TYPE *dstdata,int dstwidth,int dstheight,int dstmodulo
387      /* compute pen usage for everything */
388      for (c = first; c <= last; c++)
389         calc_penusage(gfx, c);
390   }
606391
607#define RAW 1
608#define COLOR_ARG int color,UINT8 *pridata,UINT32 pmask
609#define INCREMENT_DST(n) {dstdata+=(n);pridata += (n);}
610#define LOOKUP(n) (color + (n))
611#define SETPIXELCOLOR(dest,n) { UINT8 r8=pridata[dest]; if(!(1<<(r8&0x1f)&pmask)){ if(afterdrawmask){ r8&=0x7f; r8|=0x1f; dstdata[dest]=(n); pridata[dest]=r8; } else if(!(r8&0x80)){ dstdata[dest]=SHADOW32(palette_shadow_table,n); pridata[dest]|=0x80; } } }
612#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_raw_pri32 args body
613#include "drawgfx.c"
614#undef DECLARE_SWAP_RAW_PRI
615#undef COLOR_ARG
616#undef LOOKUP
617#undef SETPIXELCOLOR
618#undef RAW
392   /* otherwise, we get to manually decode */
393   else
394      for (c = first; c <= last; c++)
395         decodechar(gfx, c, gfx->srcdata);
396}
619397
620#define RAW 0
621#define COLOR_ARG int colorbase,const pen_t *paldata,UINT8 *pridata,UINT32 pmask
622#define LOOKUP(n) (paldata[n])
623//#define LOOKUP(n) (colorbase + (n))
624#define SETPIXELCOLOR(dest,n) { UINT8 r8=pridata[dest]; if(!(1<<(r8&0x1f)&pmask)){ if(afterdrawmask){ r8&=0x7f; r8|=0x1f; dstdata[dest]=(n); pridata[dest]=r8; } else if(!(r8&0x80)){ dstdata[dest]=SHADOW32(palette_shadow_table,n); pridata[dest]|=0x80; } } }
625#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_pri32 args body
626#include "drawgfx.c"
627#undef DECLARE_SWAP_RAW_PRI
628#undef COLOR_ARG
629#undef LOOKUP
630#undef INCREMENT_DST
631#undef SETPIXELCOLOR
632#undef RAW
633398
634#define RAW 1
635#define COLOR_ARG int color
636#define INCREMENT_DST(n) {dstdata+=(n);}
637#define LOOKUP(n) (color + (n))
638#define SETPIXELCOLOR(dest,n) {dstdata[dest] = (n);}
639#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##_raw32 args body
640#include "drawgfx.c"
641#undef DECLARE_SWAP_RAW_PRI
642#undef COLOR_ARG
643#undef LOOKUP
644#undef SETPIXELCOLOR
645#undef RAW
646399
647#define RAW 0
648#define COLOR_ARG int colorbase, const pen_t *paldata
649#define LOOKUP(n) (paldata[n])
650//#define LOOKUP(n) (colorbase + (n))
651#define SETPIXELCOLOR(dest,n) {dstdata[dest] = (n);}
652#define DECLARE_SWAP_RAW_PRI(function,args,body) static void function##32 args body
653#include "drawgfx.c"
654#undef DECLARE_SWAP_RAW_PRI
655#undef COLOR_ARG
656#undef LOOKUP
657#undef INCREMENT_DST
658#undef SETPIXELCOLOR
400/***************************************************************************
401    DRAWGFX IMPLEMENTATIONS
402***************************************************************************/
659403
660#undef HMODULO
661#undef VMODULO
662#undef COMMON_ARGS
663#undef DECLARE
664#undef DECLAREG
404/*-------------------------------------------------
405    drawgfx - generic drawgfx with legacy
406    interface
407-------------------------------------------------*/
665408
666#define DECLARE(function,args,body) static void function##32 args body
667#define DECLAREG(function,args,body) void function##32 args body
668#define DECLARE_SWAP_RAW_PRI(function,args,body)
669#define BLOCKMOVE(function,flipx,args) \
670   if (flipx) blockmove_##function##_flipx##32 args ; \
671   else blockmove_##function##32 args
672#define BLOCKMOVELU(function,args) \
673   blockmove_##function##32 args
674#define BLOCKMOVERAW(function,args) \
675   blockmove_##function##_raw##32 args
676#define BLOCKMOVEPRI(function,args) \
677   blockmove_##function##_pri##32 args
678#define BLOCKMOVERAWPRI(function,args) \
679   blockmove_##function##_raw_pri##32 args
680#include "drawgfx.c"
681#undef DECLARE
682#undef DECLARE_SWAP_RAW_PRI
683#undef DECLAREG
684#undef BLOCKMOVE
685#undef BLOCKMOVELU
686#undef BLOCKMOVERAW
687#undef BLOCKMOVEPRI
688#undef BLOCKMOVERAWPRI
409void drawgfx(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy,
410      INT32 sx, INT32 sy, const rectangle *cliprect, int transparency, UINT32 transparent_color)
411{
412   switch (transparency)
413   {
414      case TRANSPARENCY_NONE:
415         drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy);
416         break;
689417
690#undef RAW
691#undef DEPTH
692#undef DATA_TYPE
693#undef alpha_blend_r
694#undef alpha_blend
418      case TRANSPARENCY_PEN:
419         drawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, transparent_color);
420         break;
695421
422      case TRANSPARENCY_PENS:
423         drawgfx_transmask(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, transparent_color);
424         break;
696425
697/***************************************************************************
426      default:
427         fatalerror("Invalid transparency specified for drawgfx (%d)", transparency);
428         break;
429   }
430}
698431
699  Draw graphic elements in the specified bitmap.
700432
701  transparency == TRANSPARENCY_NONE - no transparency.
702  transparency == TRANSPARENCY_PEN - bits whose _original_ value is == transparent_color
703                                     are transparent. This is the most common kind of
704                                     transparency.
705  transparency == TRANSPARENCY_PENS - as above, but transparent_color is a mask of
706                                     transparent pens.
707  transparency == TRANSPARENCY_PEN_TABLE - the transparency condition is same as TRANSPARENCY_PEN
708                    A special drawing is done according to gfx_drawmode_table[source pixel].
709                    DRAWMODE_NONE      transparent
710                    DRAWMODE_SOURCE    normal, draw source pixel.
711                    DRAWMODE_SHADOW    destination is changed through palette_shadow_table[]
433/*-------------------------------------------------
434    drawgfx_opaque - render a gfx element with
435    no transparency
436-------------------------------------------------*/
712437
713***************************************************************************/
714
715INLINE void common_drawgfx(bitmap_t *dest,const gfx_element *gfx,
716      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
717      const rectangle *clip,int transparency,int transparent_color,
718      bitmap_t *pri_buffer,UINT32 pri_mask)
438void drawgfx_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
439      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty)
719440{
441   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
442   const pen_t *paldata;
443
720444   assert(dest != NULL);
721   assert((dest->bpp == 16) || (dest->bpp == 32));
445   assert(dest->bpp == 16 || dest->bpp == 32);
722446   assert(gfx != NULL);
723447
448   /* get final code and color, and grab lookup tables */
724449   code %= gfx->total_elements;
450   color %= gfx->total_colors;
451   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
725452
726   if (transparency != TRANSPARENCY_PEN_RAW)
727      color %= gfx->total_colors;
453   /* render based on dest bitmap depth */
454   if (dest->bpp == 16)
455      DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
456   else
457      DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
458}
728459
729   if ((dest->format == BITMAP_FORMAT_INDEXED16 || dest->format == BITMAP_FORMAT_INDEXED32) &&
730      (transparency == TRANSPARENCY_ALPHA || transparency == TRANSPARENCY_ALPHARANGE))
460
461/*-------------------------------------------------
462    drawgfx_transpen - render a gfx element with
463    a single transparent pen
464-------------------------------------------------*/
465
466void drawgfx_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
467      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
468      UINT32 transpen)
469{
470   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
471   const pen_t *paldata;
472
473   /* special case invalid pens to opaque */
474   if (transpen > 0xff)
731475   {
732      transparency = TRANSPARENCY_PEN;
733      transparent_color &= 0xff;
476      drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty);
477      return;
734478   }
735479
736   if (gfx->pen_usage && (transparency == TRANSPARENCY_PEN || transparency == TRANSPARENCY_PENS))
480   assert(dest != NULL);
481   assert(dest->bpp == 16 || dest->bpp == 32);
482   assert(gfx != NULL);
483
484   /* get final code and color, and grab lookup tables */
485   code %= gfx->total_elements;
486   color %= gfx->total_colors;
487   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
488
489   /* use pen usage to optimize */
490   if (gfx->pen_usage != NULL && !gfx->dirty[code])
737491   {
738      int transmask = 0;
492      UINT32 usage = gfx->pen_usage[code];
739493
740      if (transparency == TRANSPARENCY_PEN)
741         transmask = 1 << (transparent_color & 0xff);
742      else   /* transparency == TRANSPARENCY_PENS */
743         transmask = transparent_color;
494      /* fully transparent; do nothing */
495      if ((usage & ~(1 << transpen)) == 0)
496         return;
744497
745      if ((gfx->pen_usage[code] & ~transmask) == 0)
746         /* character is totally transparent, no need to draw */
498      /* fully opaque; draw as such */
499      if ((usage & (1 << transpen)) == 0)
500      {
501         drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty);
747502         return;
748      else if ((gfx->pen_usage[code] & transmask) == 0)
749         /* character is totally opaque, can disable transparency */
750         transparency = TRANSPARENCY_NONE;
503      }
751504   }
752505
506   /* render based on dest bitmap depth */
753507   if (dest->bpp == 16)
754      drawgfx_core16(dest,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,pri_buffer,pri_mask);
508      DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY);
755509   else
756      drawgfx_core32(dest,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,pri_buffer,pri_mask);
510      DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY);
757511}
758512
759void drawgfx(bitmap_t *dest,const gfx_element *gfx,
760      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
761      const rectangle *clip,int transparency,int transparent_color)
762{
763   profiler_mark(PROFILER_DRAWGFX);
764   common_drawgfx(dest,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,NULL,0);
765   profiler_mark(PROFILER_END);
766}
767513
768void pdrawgfx(bitmap_t *dest,const gfx_element *gfx,
769      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
770      const rectangle *clip,int transparency,int transparent_color,UINT32 priority_mask)
771{
772   profiler_mark(PROFILER_DRAWGFX);
773   common_drawgfx(dest,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,priority_bitmap,priority_mask | (1<<31));
774   profiler_mark(PROFILER_END);
775}
514/*-------------------------------------------------
515    drawgfx_transpen_raw - render a gfx element
516    with a single transparent pen and no color
517    lookups
518-------------------------------------------------*/
776519
777void mdrawgfx(bitmap_t *dest,const gfx_element *gfx,
778      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
779      const rectangle *clip,int transparency,int transparent_color,UINT32 priority_mask)
520void drawgfx_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
521      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
522      UINT32 transpen)
780523{
781   profiler_mark(PROFILER_DRAWGFX);
782   common_drawgfx(dest,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,priority_bitmap,priority_mask);
783   profiler_mark(PROFILER_END);
784}
524   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
785525
786
787/***************************************************************************
788
789  Use copybitmap() to copy a bitmap onto another at the given position.
790
791***************************************************************************/
792static void copybitmap_common(bitmap_t *dest,bitmap_t *src,int flipx,int flipy,int sx,int sy,
793      const rectangle *clip,int transparency,int transparent_color)
794{
795526   assert(dest != NULL);
796   assert(src != NULL);
797   assert((dest->bpp == 16) || (dest->bpp == 32));
798   assert(dest->bpp == src->bpp);
527   assert(dest->bpp == 16 || dest->bpp == 32);
528   assert(gfx != NULL);
799529
800   profiler_mark(PROFILER_COPYBITMAP);
530   /* get final code and color, and grab lookup tables */
531   code %= gfx->total_elements;
801532
533   /* early out if completely transparent */
534   if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
535      return;
536
537   /* render based on dest bitmap depth */
802538   if (dest->bpp == 16)
803      copybitmap_core16(dest,src,flipx,flipy,sx,sy,clip,transparency,transparent_color);
539      DRAWGFX_CORE(UINT16, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY);
804540   else
805      copybitmap_core32(dest,src,flipx,flipy,sx,sy,clip,transparency,transparent_color);
806
807   profiler_mark(PROFILER_END);
541      DRAWGFX_CORE(UINT32, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY);
808542}
809543
810void copybitmap(bitmap_t *dest, bitmap_t *src, int flipx, int flipy,
811            int sx, int sy, const rectangle *clip)
812{
813   copybitmap_common(dest,src,flipx,flipy,sx,sy,clip,TRANSPARENCY_NONE,0);
814}
815544
816void copybitmap_trans(bitmap_t *dest, bitmap_t *src, int flipx, int flipy,
817                 int sx, int sy, const rectangle *clip, pen_t transparent_pen)
818{
819   copybitmap_common(dest,src,flipx,flipy,sx,sy,clip,TRANSPARENCY_PEN,transparent_pen);
820}
545/*-------------------------------------------------
546    drawgfx_transmask - render a gfx element
547    with a multiple transparent pens provided as
548    a mask
549-------------------------------------------------*/
821550
822
823
824/***************************************************************************
825
826  Copy a bitmap onto another with scroll and wraparound.
827  This function supports multiple independently scrolling rows/columns.
828  "rows" is the number of indepentently scrolling rows. "rowscroll" is an
829  array of integers telling how much to scroll each row. Same thing for
830  "cols" and "colscroll".
831  If the bitmap cannot scroll in one direction, set rows or columns to 0.
832  If the bitmap scrolls as a whole, set rows and/or cols to 1.
833  Bidirectional scrolling is, of course, supported only if the bitmap
834  scrolls as a whole in at least one direction.
835
836***************************************************************************/
837static void copyscrollbitmap_common(bitmap_t *dest,bitmap_t *src,
838      int rows,const int *rowscroll,int cols,const int *colscroll,
839      const rectangle *clip,int transparency,int transparent_color)
551void drawgfx_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
552      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
553      UINT32 transmask)
840554{
841   int srcwidth,srcheight,destwidth,destheight;
842   rectangle orig_clip;
555   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
556   const pen_t *paldata;
843557
844   assert(dest != NULL);
845   assert(src != NULL);
846   assert((dest->bpp == 16) || (dest->bpp == 32));
847   assert(dest->bpp == src->bpp);
848   assert((rows != 0) || (rowscroll == NULL));
849   assert((rows == 0) || (rowscroll != NULL));
850   assert((cols != 0) || (colscroll == NULL));
851   assert((cols == 0) || (colscroll != NULL));
852
853   if (clip)
558   /* special case 0 mask to opaque */
559   if (transmask == 0)
854560   {
855      orig_clip.min_x = clip->min_x;
856      orig_clip.max_x = clip->max_x;
857      orig_clip.min_y = clip->min_y;
858      orig_clip.max_y = clip->max_y;
859   }
860   else
861   {
862      orig_clip.min_x = 0;
863      orig_clip.max_x = dest->width-1;
864      orig_clip.min_y = 0;
865      orig_clip.max_y = dest->height-1;
866   }
867   clip = &orig_clip;
868
869   if (rows == 0 && cols == 0)
870   {
871      copybitmap_common(dest,src,0,0,0,0,clip,transparency,transparent_color);
561      drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty);
872562      return;
873563   }
874564
875   srcwidth = src->width;
876   srcheight = src->height;
877   destwidth = dest->width;
878   destheight = dest->height;
565   assert(dest != NULL);
566   assert(dest->bpp == 16 || dest->bpp == 32);
567   assert(gfx != NULL);
879568
880   if (rows == 0)
569   /* get final code and color, and grab lookup tables */
570   code %= gfx->total_elements;
571   color %= gfx->total_colors;
572   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
573
574   /* use pen usage to optimize */
575   if (gfx->pen_usage != NULL && !gfx->dirty[code])
881576   {
882      /* scrolling columns */
883      int col,colwidth;
884      rectangle myclip;
577      UINT32 usage = gfx->pen_usage[code];
885578
886      colwidth = srcwidth / cols;
579      /* fully transparent; do nothing */
580      if ((usage & ~transmask) == 0)
581         return;
887582
888      myclip.min_y = clip->min_y;
889      myclip.max_y = clip->max_y;
890
891      col = 0;
892      while (col < cols)
583      /* fully opaque; draw as such */
584      if ((usage & transmask) == 0)
893585      {
894         int cons,scroll;
895
896         /* count consecutive columns scrolled by the same amount */
897         scroll = colscroll[col];
898         cons = 1;
899         while (col + cons < cols &&   colscroll[col + cons] == scroll)
900            cons++;
901
902         if (scroll < 0)
903            scroll = srcheight - (-scroll) % srcheight;
904         else
905            scroll %= srcheight;
906
907         myclip.min_x = col * colwidth;
908         if (myclip.min_x < clip->min_x) myclip.min_x = clip->min_x;
909         myclip.max_x = (col + cons) * colwidth - 1;
910         if (myclip.max_x > clip->max_x) myclip.max_x = clip->max_x;
911
912         copybitmap_common(dest,src,0,0,0,scroll,&myclip,transparency,transparent_color);
913         copybitmap_common(dest,src,0,0,0,scroll - srcheight,&myclip,transparency,transparent_color);
914
915         col += cons;
586         drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty);
587         return;
916588      }
917589   }
918   else if (cols == 0)
919   {
920      /* scrolling rows */
921      int row,rowheight;
922      rectangle myclip;
923590
924      rowheight = srcheight / rows;
591   /* render based on dest bitmap depth */
592   if (dest->bpp == 16)
593      DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY);
594   else
595      DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY);
596}
925597
926      myclip.min_x = clip->min_x;
927      myclip.max_x = clip->max_x;
928598
929      row = 0;
930      while (row < rows)
931      {
932         int cons,scroll;
599/*-------------------------------------------------
600    drawgfx_transtable - render a gfx element
601    using a table to look up which pens are
602    transparent, opaque, or shadowing
603-------------------------------------------------*/
933604
934         /* count consecutive rows scrolled by the same amount */
935         scroll = rowscroll[row];
936         cons = 1;
937         while (row + cons < rows &&   rowscroll[row + cons] == scroll)
938            cons++;
605void drawgfx_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
606      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
607      const UINT8 *pentable, const pen_t *shadowtable)
608{
609   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
610   const pen_t *paldata;
939611
940         if (scroll < 0)
941            scroll = srcwidth - (-scroll) % srcwidth;
942         else
943            scroll %= srcwidth;
612   assert(dest != NULL);
613   assert(dest->bpp == 16 || dest->bpp == 32);
614   assert(gfx != NULL);
615   assert(pentable != NULL);
944616
945         myclip.min_y = row * rowheight;
946         if (myclip.min_y < clip->min_y) myclip.min_y = clip->min_y;
947         myclip.max_y = (row + cons) * rowheight - 1;
948         if (myclip.max_y > clip->max_y) myclip.max_y = clip->max_y;
617   /* get final code and color, and grab lookup tables */
618   code %= gfx->total_elements;
619   color %= gfx->total_colors;
620   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
949621
950         copybitmap_common(dest,src,0,0,scroll,0,&myclip,transparency,transparent_color);
951         copybitmap_common(dest,src,0,0,scroll - srcwidth,0,&myclip,transparency,transparent_color);
622   /* render based on dest bitmap depth */
623   if (dest->bpp == 16)
624      DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSTABLE16, NO_PRIORITY);
625   else
626      DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSTABLE32, NO_PRIORITY);
627}
952628
953         row += cons;
954      }
955   }
956   else if (rows == 1 && cols == 1)
957   {
958      /* XY scrolling playfield */
959      int scrollx,scrolly,sx,sy;
960629
961      if (rowscroll[0] < 0)
962         scrollx = srcwidth - (-rowscroll[0]) % srcwidth;
963      else
964         scrollx = rowscroll[0] % srcwidth;
630/*-------------------------------------------------
631    drawgfx_alpha - render a gfx element with
632    a single transparent pen, alpha blending the
633    remaining pixels with a fixed alpha value
634-------------------------------------------------*/
965635
966      if (colscroll[0] < 0)
967         scrolly = srcheight - (-colscroll[0]) % srcheight;
968      else
969         scrolly = colscroll[0] % srcheight;
636void drawgfx_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
637      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
638      UINT32 transpen, UINT8 alpha)
639{
640   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
641   const pen_t *paldata;
970642
971      for (sx = scrollx - srcwidth;sx < destwidth;sx += srcwidth)
972         for (sy = scrolly - srcheight;sy < destheight;sy += srcheight)
973            copybitmap_common(dest,src,0,0,sx,sy,clip,transparency,transparent_color);
974   }
975   else if (rows == 1)
643   /* special case alpha = 0xff */
644   if (alpha == 0xff)
976645   {
977      /* scrolling columns + horizontal scroll */
978      int col,colwidth;
979      int scrollx;
980      rectangle myclip;
646      drawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, transpen);
647      return;
648   }
981649
982      if (rowscroll[0] < 0)
983         scrollx = srcwidth - (-rowscroll[0]) % srcwidth;
984      else
985         scrollx = rowscroll[0] % srcwidth;
650   assert(dest != NULL);
651   assert(dest->bpp == 16 || dest->bpp == 32);
652   assert(gfx != NULL);
986653
987      colwidth = srcwidth / cols;
654   /* get final code and color, and grab lookup tables */
655   code %= gfx->total_elements;
656   color %= gfx->total_colors;
657   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
988658
989      myclip.min_y = clip->min_y;
990      myclip.max_y = clip->max_y;
659   /* early out if completely transparent */
660   if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
661      return;
991662
992      col = 0;
993      while (col < cols)
994      {
995         int cons,scroll;
663   /* render based on dest bitmap depth */
664   if (dest->bpp == 16)
665      DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_ALPHA16, NO_PRIORITY);
666   else
667      DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32, NO_PRIORITY);
668}
996669
997         /* count consecutive columns scrolled by the same amount */
998         scroll = colscroll[col];
999         cons = 1;
1000         while (col + cons < cols &&   colscroll[col + cons] == scroll)
1001            cons++;
1002670
1003         if (scroll < 0)
1004            scroll = srcheight - (-scroll) % srcheight;
1005         else
1006            scroll %= srcheight;
1007671
1008         myclip.min_x = col * colwidth + scrollx;
1009         if (myclip.min_x < clip->min_x) myclip.min_x = clip->min_x;
1010         myclip.max_x = (col + cons) * colwidth - 1 + scrollx;
1011         if (myclip.max_x > clip->max_x) myclip.max_x = clip->max_x;
672/***************************************************************************
673    DRAWGFXZOOM IMPLEMENTATIONS
674***************************************************************************/
1012675
1013         copybitmap_common(dest,src,0,0,scrollx,scroll,&myclip,transparency,transparent_color);
1014         copybitmap_common(dest,src,0,0,scrollx,scroll - srcheight,&myclip,transparency,transparent_color);
676/*-------------------------------------------------
677    drawgfxzoom - generic drawgfxzoom with legacy
678    interface
679-------------------------------------------------*/
1015680
1016         myclip.min_x = col * colwidth + scrollx - srcwidth;
1017         if (myclip.min_x < clip->min_x) myclip.min_x = clip->min_x;
1018         myclip.max_x = (col + cons) * colwidth - 1 + scrollx - srcwidth;
1019         if (myclip.max_x > clip->max_x) myclip.max_x = clip->max_x;
1020
1021         copybitmap_common(dest,src,0,0,scrollx - srcwidth,scroll,&myclip,transparency,transparent_color);
1022         copybitmap_common(dest,src,0,0,scrollx - srcwidth,scroll - srcheight,&myclip,transparency,transparent_color);
1023
1024         col += cons;
1025      }
1026   }
1027   else if (cols == 1)
681void drawgfxzoom(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy,
682      INT32 sx, INT32 sy, const rectangle *cliprect, int transparency, UINT32 transparent_color,
683      UINT32 scalex, UINT32 scaley)
684{
685   switch (transparency)
1028686   {
1029      /* scrolling rows + vertical scroll */
1030      int row,rowheight;
1031      int scrolly;
1032      rectangle myclip;
687      case TRANSPARENCY_NONE:
688         drawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley);
689         break;
1033690
1034      if (colscroll[0] < 0)
1035         scrolly = srcheight - (-colscroll[0]) % srcheight;
1036      else
1037         scrolly = colscroll[0] % srcheight;
691      case TRANSPARENCY_PEN:
692         drawgfxzoom_transpen(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley, transparent_color);
693         break;
1038694
1039      rowheight = srcheight / rows;
695      case TRANSPARENCY_PENS:
696         drawgfxzoom_transmask(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley, transparent_color);
697         break;
1040698
1041      myclip.min_x = clip->min_x;
1042      myclip.max_x = clip->max_x;
1043
1044      row = 0;
1045      while (row < rows)
1046      {
1047         int cons,scroll;
1048
1049         /* count consecutive rows scrolled by the same amount */
1050         scroll = rowscroll[row];
1051         cons = 1;
1052         while (row + cons < rows &&   rowscroll[row + cons] == scroll)
1053            cons++;
1054
1055         if (scroll < 0)
1056            scroll = srcwidth - (-scroll) % srcwidth;
1057         else
1058            scroll %= srcwidth;
1059
1060         myclip.min_y = row * rowheight + scrolly;
1061         if (myclip.min_y < clip->min_y) myclip.min_y = clip->min_y;
1062         myclip.max_y = (row + cons) * rowheight - 1 + scrolly;
1063         if (myclip.max_y > clip->max_y) myclip.max_y = clip->max_y;
1064
1065         copybitmap_common(dest,src,0,0,scroll,scrolly,&myclip,transparency,transparent_color);
1066         copybitmap_common(dest,src,0,0,scroll - srcwidth,scrolly,&myclip,transparency,transparent_color);
1067
1068         myclip.min_y = row * rowheight + scrolly - srcheight;
1069         if (myclip.min_y < clip->min_y) myclip.min_y = clip->min_y;
1070         myclip.max_y = (row + cons) * rowheight - 1 + scrolly - srcheight;
1071         if (myclip.max_y > clip->max_y) myclip.max_y = clip->max_y;
1072
1073         copybitmap_common(dest,src,0,0,scroll,scrolly - srcheight,&myclip,transparency,transparent_color);
1074         copybitmap_common(dest,src,0,0,scroll - srcwidth,scrolly - srcheight,&myclip,transparency,transparent_color);
1075
1076         row += cons;
1077      }
699      default:
700         fatalerror("Invalid transparency specified for drawgfxzoom (%d)", transparency);
701         break;
1078702   }
1079703}
1080704
1081705
1082void copyscrollbitmap(bitmap_t *dest, bitmap_t *src,
1083                 int rows, const int *rowscroll, int cols, const int *colscroll,
1084                 const rectangle *clip)
1085{
1086   copyscrollbitmap_common(dest,src,rows,rowscroll,cols,colscroll,clip,TRANSPARENCY_NONE,0);
1087}
706/*-------------------------------------------------
707    drawgfxzoom_opaque - render a scaled gfx
708    element with no transparency
709-------------------------------------------------*/
1088710
1089void copyscrollbitmap_trans(bitmap_t *dest, bitmap_t *src,
1090                      int rows, const int *rowscroll, int cols, const int *colscroll,
1091                      const rectangle *clip, pen_t transparent_pen)
711void drawgfxzoom_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
712      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
713      UINT32 scalex, UINT32 scaley)
1092714{
1093   copyscrollbitmap_common(dest,src,rows,rowscroll,cols,colscroll,clip,TRANSPARENCY_PEN,transparent_pen);
1094}
715   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
716   const pen_t *paldata;
1095717
1096
1097/* notes:
1098   - startx and starty MUST be UINT32 for calculations to work correctly
1099   - srcbitmap->width and height are assumed to be a power of 2 to speed up wraparound
1100   */
1101void copyrozbitmap(bitmap_t *dest,bitmap_t *src,
1102      UINT32 startx,UINT32 starty,int incxx,int incxy,int incyx,int incyy,int wraparound,
1103      const rectangle *clip,int transparency,int transparent_color,UINT32 priority)
1104{
1105   assert(dest != NULL);
1106   assert(src != NULL);
1107   assert((dest->bpp == 16) || (dest->bpp == 32));
1108   assert(dest->bpp == src->bpp);
1109
1110   profiler_mark(PROFILER_COPYBITMAP);
1111
1112   /* cheat, the core doesn't support TRANSPARENCY_NONE yet */
1113   if (transparency == TRANSPARENCY_NONE)
718   /* non-zoom case */
719   if (scalex == 0x10000 && scaley == 0x10000)
1114720   {
1115      transparency = TRANSPARENCY_PEN;
1116      transparent_color = -1;
1117   }
1118
1119   if (transparency != TRANSPARENCY_PEN)
1120   {
1121      popmessage("copyrozbitmap unsupported trans %02x",transparency);
721      drawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty);
1122722      return;
1123723   }
1124724
725   assert(dest != NULL);
726   assert(dest->bpp == 16 || dest->bpp == 32);
727   assert(gfx != NULL);
728
729   /* get final code and color, and grab lookup tables */
730   code %= gfx->total_elements;
731   color %= gfx->total_colors;
732   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
733
734   /* render based on dest bitmap depth */
1125735   if (dest->bpp == 16)
1126      copyrozbitmap_core16(dest,src,startx,starty,incxx,incxy,incyx,incyy,wraparound,clip,transparency,transparent_color,priority);
736      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
1127737   else
1128      copyrozbitmap_core32(dest,src,startx,starty,incxx,incxy,incyx,incyy,wraparound,clip,transparency,transparent_color,priority);
1129
1130   profiler_mark(PROFILER_END);
738      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
1131739}
1132740
1133741
742/*-------------------------------------------------
743    drawgfxzoom_transpen - render a scaled gfx
744    element with a single transparent pen
745-------------------------------------------------*/
1134746
1135INLINE void common_drawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
1136      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
1137      const rectangle *clip,int transparency,int transparent_color,
1138      int scalex, int scaley,bitmap_t *pri_buffer,UINT32 pri_mask)
747void drawgfxzoom_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
748      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
749      UINT32 scalex, UINT32 scaley, UINT32 transpen)
1139750{
1140   /* verify arguments */
1141   assert(dest_bmp != NULL);
1142   assert((dest_bmp->bpp == 16) || (dest_bmp->bpp == 32));
1143   assert(gfx != NULL);
751   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
752   const pen_t *paldata;
1144753
1145   if ((scalex == 0) || (scaley == 0)) return;
1146
754   /* non-zoom case */
1147755   if (scalex == 0x10000 && scaley == 0x10000)
1148756   {
1149      common_drawgfx(dest_bmp,gfx,code,color,flipx,flipy,sx,sy,clip,transparency,transparent_color,pri_buffer,pri_mask);
757      drawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, transpen);
1150758      return;
1151759   }
1152760
1153   if ((dest_bmp->format == BITMAP_FORMAT_INDEXED16 || dest_bmp->format == BITMAP_FORMAT_INDEXED32) &&
1154      (transparency == TRANSPARENCY_ALPHA || transparency == TRANSPARENCY_ALPHARANGE))
761   /* special case invalid pens to opaque */
762   if (transpen > 0xff)
1155763   {
1156      transparency = TRANSPARENCY_PEN;
1157      transparent_color &= 0xff;
764      drawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley);
765      return;
1158766   }
1159767
1160   /*
1161    scalex and scaley are 16.16 fixed point numbers
1162    1<<15 : shrink to 50%
1163    1<<16 : uniform scale
1164    1<<17 : double to 200%
1165    */
768   assert(dest != NULL);
769   assert(dest->bpp == 16 || dest->bpp == 32);
770   assert(gfx != NULL);
1166771
1167   /* force clip to bitmap boundary */
1168   if (clip)
772   /* get final code and color, and grab lookup tables */
773   code %= gfx->total_elements;
774   color %= gfx->total_colors;
775   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
776
777   /* use pen usage to optimize */
778   if (gfx->pen_usage != NULL && !gfx->dirty[code])
1169779   {
1170      rectangle myclip;
780      UINT32 usage = gfx->pen_usage[code];
1171781
1172      myclip.min_x = clip->min_x;
1173      myclip.max_x = clip->max_x;
1174      myclip.min_y = clip->min_y;
1175      myclip.max_y = clip->max_y;
782      /* fully transparent; do nothing */
783      if ((usage & ~(1 << transpen)) == 0)
784         return;
1176785
1177      if (myclip.min_x < 0) myclip.min_x = 0;
1178      if (myclip.max_x >= dest_bmp->width) myclip.max_x = dest_bmp->width-1;
1179      if (myclip.min_y < 0) myclip.min_y = 0;
1180      if (myclip.max_y >= dest_bmp->height) myclip.max_y = dest_bmp->height-1;
1181
1182      clip = &myclip;
786      /* fully opaque; draw as such */
787      if ((usage & (1 << transpen)) == 0)
788      {
789         drawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley);
790         return;
791      }
1183792   }
1184793
1185   /* 16-bit destination bitmap */
1186   if (dest_bmp->bpp == 16)
1187   {
1188      int colorbase = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
1189      const pen_t *pal = &gfx->machine->pens[colorbase];
1190      UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
794   /* render based on dest bitmap depth */
795   if (dest->bpp == 16)
796      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY);
797   else
798      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY);
799}
1191800
1192      int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
1193      int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
1194801
1195      if (sprite_screen_width && sprite_screen_height)
1196      {
1197         /* compute sprite increment per screen pixel */
1198         int dx = (gfx->width<<16)/sprite_screen_width;
1199         int dy = (gfx->height<<16)/sprite_screen_height;
802/*-------------------------------------------------
803    drawgfxzoom_transpen_raw - render a scaled gfx
804    element with a single transparent pen and no
805    color lookups
806-------------------------------------------------*/
1200807
1201         int ex = sx+sprite_screen_width;
1202         int ey = sy+sprite_screen_height;
808void drawgfxzoom_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
809      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
810      UINT32 scalex, UINT32 scaley, UINT32 transpen)
811{
812   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
1203813
1204         int x_index_base;
1205         int y_index;
814   /* non-zoom case */
815   if (scalex == 0x10000 && scaley == 0x10000)
816   {
817      drawgfx_transpen_raw(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, transpen);
818      return;
819   }
1206820
1207         if (flipx)
1208         {
1209            x_index_base = (sprite_screen_width-1)*dx;
1210            dx = -dx;
1211         }
1212         else
1213            x_index_base = 0;
821   assert(dest != NULL);
822   assert(dest->bpp == 16 || dest->bpp == 32);
823   assert(gfx != NULL);
1214824
1215         if (flipy)
1216         {
1217            y_index = (sprite_screen_height-1)*dy;
1218            dy = -dy;
1219         }
1220         else
1221            y_index = 0;
825   /* get final code and color, and grab lookup tables */
826   code %= gfx->total_elements;
1222827
1223         if (clip)
1224         {
1225            if (sx < clip->min_x)
1226            { /* clip left */
1227               int pixels = clip->min_x-sx;
1228               sx += pixels;
1229               x_index_base += pixels*dx;
1230            }
828   /* early out if completely transparent */
829   if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
830      return;
1231831
1232            if (sy < clip->min_y)
1233            { /* clip top */
1234               int pixels = clip->min_y-sy;
1235               sy += pixels;
1236               y_index += pixels*dy;
1237            }
832   /* render based on dest bitmap depth */
833   if (dest->bpp == 16)
834      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY);
835   else
836      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY);
837}
1238838
1239            if (ex > clip->max_x + 1)
1240            { /* clip right */
1241               int pixels = ex-clip->max_x-1;
1242               ex -= pixels;
1243            }
1244839
1245            if (ey > clip->max_y + 1)
1246            { /* clip bottom */
1247               int pixels = ey-clip->max_y-1;
1248               ey -= pixels;
1249            }
1250         }
840/*-------------------------------------------------
841    drawgfxzoom_transmask - render a scaled gfx
842    element with a multiple transparent pens
843    provided as a mask
844-------------------------------------------------*/
1251845
1252         if (ex > sx)
1253         { /* skip if inner loop doesn't draw anything */
1254            int y;
846void drawgfxzoom_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
847      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
848      UINT32 scalex, UINT32 scaley, UINT32 transmask)
849{
850   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
851   const pen_t *paldata;
1255852
1256            /* case 0: TRANSPARENCY_NONE */
1257            if (transparency == TRANSPARENCY_NONE)
1258            {
1259               if (pri_buffer)
1260               {
1261                  if (gfx->flags & GFX_ELEMENT_PACKED)
1262                     for (y = sy; y < ey; y++)
1263                     {
1264                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1265                        UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1266                        UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
853   /* non-zoom case */
854   if (scalex == 0x10000 && scaley == 0x10000)
855   {
856      drawgfx_transmask(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, transmask);
857      return;
858   }
1267859
1268                        int x, x_index = x_index_base;
1269                        for (x = sx; x < ex; x++)
1270                        {
1271                           if (((1 << pri[x]) & pri_mask) == 0)
1272                              dest[x] = pal[(source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f];
1273//                                      dest[x] = colorbase + ((source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f);
1274                           pri[x] = 31;
1275                           x_index += dx;
1276                        }
860   /* special case 0 mask to opaque */
861   if (transmask == 0)
862   {
863      drawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley);
864      return;
865   }
1277866
1278                        y_index += dy;
1279                     }
1280                  else
1281                     for (y = sy; y < ey; y++)
1282                     {
1283                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1284                        UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1285                        UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
867   assert(dest != NULL);
868   assert(dest->bpp == 16 || dest->bpp == 32);
869   assert(gfx != NULL);
1286870
1287                        int x, x_index = x_index_base;
1288                        for (x = sx; x < ex; x++)
1289                        {
1290                           if (((1 << pri[x]) & pri_mask) == 0)
1291                              dest[x] = pal[source[x_index>>16]];
1292//                                      dest[x] = colorbase + source[x_index>>16];
1293                           pri[x] = 31;
1294                           x_index += dx;
1295                        }
871   /* get final code and color, and grab lookup tables */
872   code %= gfx->total_elements;
873   color %= gfx->total_colors;
874   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
1296875
1297                        y_index += dy;
1298                     }
1299               }
1300               else
1301               {
1302                  if (gfx->flags & GFX_ELEMENT_PACKED)
1303                     for (y = sy; y < ey; y++)
1304                     {
1305                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1306                        UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
876   /* use pen usage to optimize */
877   if (gfx->pen_usage != NULL && !gfx->dirty[code])
878   {
879      UINT32 usage = gfx->pen_usage[code];
1307880
1308                        int x, x_index = x_index_base;
1309                        for (x = sx; x < ex; x++)
1310                        {
1311                           dest[x] = pal[(source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f];
1312//                                  dest[x] = colorbase + ((source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f);
1313                           x_index += dx;
1314                        }
881      /* fully transparent; do nothing */
882      if ((usage & ~transmask) == 0)
883         return;
1315884
1316                        y_index += dy;
1317                     }
1318                  else
1319                     for (y = sy; y < ey; y++)
1320                     {
1321                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1322                        UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
885      /* fully opaque; draw as such */
886      if ((usage & transmask) == 0)
887      {
888         drawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley);
889         return;
890      }
891   }
1323892
1324                        int x, x_index = x_index_base;
1325                        for (x = sx; x < ex; x++)
1326                        {
1327                           dest[x] = pal[source[x_index>>16]];
1328//                                  dest[x] = colorbase + source[x_index>>16];
1329                           x_index += dx;
1330                        }
893   /* render based on dest bitmap depth */
894   if (dest->bpp == 16)
895      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY);
896   else
897      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY);
898}
1331899
1332                        y_index += dy;
1333                     }
1334               }
1335            }
1336900
1337            /* case 1: TRANSPARENCY_PEN */
1338            if (transparency == TRANSPARENCY_PEN)
1339            {
1340               if (pri_buffer)
1341               {
1342                  if (gfx->flags & GFX_ELEMENT_PACKED)
1343                     for(y = sy; y < ey; y++)
1344                     {
1345                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1346                        UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1347                        UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
901/*-------------------------------------------------
902    drawgfxzoom_transtable - render a scaled gfx
903    element using a table to look up which pens
904    are transparent, opaque, or shadowing
905-------------------------------------------------*/
1348906
1349                        int x, x_index = x_index_base;
1350                        for (x = sx; x < ex; x++)
1351                        {
1352                           int c = (source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f;
1353                           if (c != transparent_color)
1354                           {
1355                              if (((1 << pri[x]) & pri_mask) == 0)
1356                                 dest[x] = pal[c];
1357//                                          dest[x] = colorbase + c;
1358                              pri[x] = 31;
1359                           }
1360                           x_index += dx;
1361                        }
907void drawgfxzoom_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
908      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
909      UINT32 scalex, UINT32 scaley, const UINT8 *pentable, const pen_t *shadowtable)
910{
911   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
912   const pen_t *paldata;
1362913
1363                        y_index += dy;
1364                     }
1365                  else
1366                     for(y = sy; y < ey; y++)
1367                     {
1368                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1369                        UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1370                        UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
914   /* non-zoom case */
915   if (scalex == 0x10000 && scaley == 0x10000)
916   {
917      drawgfx_transtable(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, pentable, shadowtable);
918      return;
919   }
1371920
1372                        int x, x_index = x_index_base;
1373                        for (x = sx; x < ex; x++)
1374                        {
1375                           int c = source[x_index>>16];
1376                           if (c != transparent_color)
1377                           {
1378                              if (((1 << pri[x]) & pri_mask) == 0)
1379                                 dest[x] = pal[c];
1380//                                          dest[x] = colorbase + c;
1381                              pri[x] = 31;
1382                           }
1383                           x_index += dx;
1384                        }
921   assert(dest != NULL);
922   assert(dest->bpp == 16 || dest->bpp == 32);
923   assert(gfx != NULL);
924   assert(pentable != NULL);
1385925
1386                        y_index += dy;
1387                     }
1388               }
1389               else
1390               {
1391                  if (gfx->flags & GFX_ELEMENT_PACKED)
1392                     for (y = sy; y < ey; y++)
1393                     {
1394                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1395                        UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
926   /* get final code and color, and grab lookup tables */
927   code %= gfx->total_elements;
928   color %= gfx->total_colors;
929   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
1396930
1397                        int x, x_index = x_index_base;
1398                        for (x = sx; x < ex; x++)
1399                        {
1400                           int c = (source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f;
1401                           if( c != transparent_color ) dest[x] = pal[c];
1402//                                  if (c != transparent_color) dest[x] = colorbase + c;
1403                           x_index += dx;
1404                        }
931   /* render based on dest bitmap depth */
932   if (dest->bpp == 16)
933      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSTABLE16, NO_PRIORITY);
934   else
935      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSTABLE32, NO_PRIORITY);
936}
1405937
1406                        y_index += dy;
1407                     }
1408                  else
1409                     for (y = sy; y < ey; y++)
1410                     {
1411                        UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1412                        UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1413938
1414                        int x, x_index = x_index_base;
1415                        for (x = sx; x < ex; x++)
1416                        {
1417                           int c = source[x_index>>16];
1418                           if( c != transparent_color ) dest[x] = pal[c];
1419//                                  if (c != transparent_color) dest[x] = colorbase + c;
1420                           x_index += dx;
1421                        }
939/*-------------------------------------------------
940    drawgfxzoom_alpha - render a scaled gfx element
941    with a single transparent pen, alpha blending
942    the remaining pixels with a fixed alpha value
943-------------------------------------------------*/
1422944
1423                        y_index += dy;
1424                     }
1425               }
1426            }
945void drawgfxzoom_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
946      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
947      UINT32 scalex, UINT32 scaley, UINT32 transpen, UINT8 alpha)
948{
949   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
950   const pen_t *paldata;
1427951
1428            /* case 1b: TRANSPARENCY_PEN_RAW */
1429            if (transparency == TRANSPARENCY_PEN_RAW)
1430            {
1431               if (pri_buffer)
1432                  for (y = sy; y < ey; y++)
1433                  {
1434                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1435                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1436                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
952   /* non-zoom case */
953   if (scalex == 0x10000 && scaley == 0x10000)
954   {
955      drawgfx_alpha(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, transpen, alpha);
956      return;
957   }
1437958
1438                     int x, x_index = x_index_base;
1439                     for (x = sx; x < ex; x++)
1440                     {
1441                        int c = source[x_index>>16];
1442                        if (c != transparent_color)
1443                        {
1444                           if (((1 << pri[x]) & pri_mask) == 0)
1445                              dest[x] = color + c;
1446                           pri[x] = 31;
1447                        }
1448                        x_index += dx;
1449                     }
959   /* special case alpha = 0xff */
960   if (alpha == 0xff)
961   {
962      drawgfxzoom_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, transpen);
963      return;
964   }
1450965
1451                     y_index += dy;
1452                  }
1453               else
1454                  for (y = sy; y < ey; y++)
1455                  {
1456                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1457                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
966   assert(dest != NULL);
967   assert(dest->bpp == 16 || dest->bpp == 32);
968   assert(gfx != NULL);
1458969
1459                     int x, x_index = x_index_base;
1460                     for (x = sx; x < ex; x++)
1461                     {
1462                        int c = source[x_index>>16];
1463                        if (c != transparent_color) dest[x] = color + c;
1464                        x_index += dx;
1465                     }
970   /* get final code and color, and grab lookup tables */
971   code %= gfx->total_elements;
972   color %= gfx->total_colors;
973   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
1466974
1467                     y_index += dy;
1468                  }
1469            }
975   /* early out if completely transparent */
976   if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
977      return;
1470978
1471            /* case 2: TRANSPARENCY_PENS */
1472            if (transparency == TRANSPARENCY_PENS)
1473            {
1474               if (pri_buffer)
1475                  for (y = sy; y < ey; y++)
1476                  {
1477                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1478                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1479                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
979   /* render based on dest bitmap depth */
980   if (dest->bpp == 16)
981      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_ALPHA16, NO_PRIORITY);
982   else
983      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32, NO_PRIORITY);
984}
1480985
1481                     int x, x_index = x_index_base;
1482                     for (x = sx; x < ex; x++)
1483                     {
1484                        int c = source[x_index>>16];
1485                        if (((1 << c) & transparent_color) == 0)
1486                        {
1487                           if (((1 << pri[x]) & pri_mask) == 0)
1488                              dest[x] = pal[c];
1489//                                      dest[x] = colorbase + c;
1490                           pri[x] = 31;
1491                        }
1492                        x_index += dx;
1493                     }
1494986
1495                     y_index += dy;
1496                  }
1497               else
1498                  for (y = sy; y < ey; y++)
1499                  {
1500                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1501                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1502987
1503                     int x, x_index = x_index_base;
1504                     for (x = sx; x < ex; x++)
1505                     {
1506                        int c = source[x_index>>16];
1507                        if (((1 << c) & transparent_color) == 0)
1508                           dest[x] = pal[c];
1509//                                  dest[x] = colorbase + c;
1510                        x_index += dx;
1511                     }
988/***************************************************************************
989    PDRAWGFX IMPLEMENTATIONS
990***************************************************************************/
1512991
1513                     y_index += dy;
1514                  }
1515            }
992/*-------------------------------------------------
993    pdrawgfx - generic pdrawgfx with legacy
994    interface
995-------------------------------------------------*/
1516996
1517            /* case 3: TRANSPARENCY_PEN_TABLE */
1518            if (transparency == TRANSPARENCY_PEN_TABLE)
1519            {
1520               pen_t *palette_shadow_table = gfx->machine->shadow_table;
1521               if (pri_buffer)
1522               {
1523                  UINT8 al = (pdrawgfx_shadow_lowpri) ? 0 : 0x80;
997void pdrawgfx(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy,
998      INT32 sx, INT32 sy, const rectangle *cliprect, int transparency, UINT32 transparent_color,
999      UINT32 priority_mask)
1000{
1001   switch (transparency)
1002   {
1003      case TRANSPARENCY_NONE:
1004         pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, priority_bitmap, priority_mask);
1005         break;
15241006
1525                  for (y = sy; y < ey; y++)
1526                  {
1527                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1528                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1529                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
1007      case TRANSPARENCY_PEN:
1008         pdrawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, priority_bitmap, priority_mask, transparent_color);
1009         break;
15301010
1531                     int x, x_index = x_index_base;
1532                     for (x = sx; x < ex; x++)
1533                     {
1534                        int c = source[x_index>>16];
1535                        if (c != transparent_color)
1536                        {
1537                           UINT8 ah;
1011      case TRANSPARENCY_PENS:
1012         pdrawgfx_transmask(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, priority_bitmap, priority_mask, transparent_color);
1013         break;
15381014
1539                           switch(gfx_drawmode_table[c])
1540                           {
1541                           case DRAWMODE_SOURCE:
1542                              ah = pri[x];
1543                              if (((1 << (ah & 0x1f)) & pri_mask) == 0)
1544                              {
1545                                 if (ah & 0x80)
1546                                    dest[x] = palette_shadow_table[pal[c]];
1547//                                              dest[x] = palette_shadow_table[colorbase + c];
1548                                 else
1549                                    dest[x] = pal[c];
1550//                                              dest[x] = colorbase + c;
1551                              }
1552                              pri[x] = (ah & 0x7f) | 31;
1553                              break;
1554                           case DRAWMODE_SHADOW:
1555                              if (((1 << pri[x]) & pri_mask) == 0)
1556                                 dest[x] = palette_shadow_table[dest[x]];
1557                              pri[x] |= al;
1558                              break;
1559                           }
1560                        }
1561                        x_index += dx;
1562                     }
1015      default:
1016         fatalerror("Invalid transparency specified for pdrawgfx (%d)", transparency);
1017         break;
1018   }
1019}
15631020
1564                     y_index += dy;
1565                  }
1566               }
1567               else
1568               {
1569                  for (y = sy; y < ey; y++)
1570                  {
1571                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1572                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
15731021
1574                     int x, x_index = x_index_base;
1575                     for (x = sx; x < ex; x++)
1576                     {
1577                        int c = source[x_index>>16];
1578                        if (c != transparent_color)
1579                        {
1580                           switch(gfx_drawmode_table[c])
1581                           {
1582                           case DRAWMODE_SOURCE:
1583                              dest[x] = pal[c];
1584//                                      dest[x] = colorbase + c;
1585                              break;
1586                           case DRAWMODE_SHADOW:
1587                              dest[x] = palette_shadow_table[dest[x]];
1588                              break;
1589                           }
1590                        }
1591                        x_index += dx;
1592                     }
1022/*-------------------------------------------------
1023    pdrawgfx_opaque - render a gfx element with
1024    no transparency, checking against the priority
1025    bitmap
1026-------------------------------------------------*/
15931027
1594                     y_index += dy;
1595                  }
1596               }
1597            }
1028void pdrawgfx_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1029      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1030      bitmap_t *priority, UINT32 pmask)
1031{
1032   const pen_t *paldata;
15981033
1599            /* case 6: TRANSPARENCY_ALPHA */
1600            if (transparency == TRANSPARENCY_ALPHA)
1601            {
1602               if (pri_buffer)
1603                  for (y = sy; y < ey; y++)
1604                  {
1605                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1606                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1607                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
1034   assert(dest != NULL);
1035   assert(dest->bpp == 16 || dest->bpp == 32);
1036   assert(gfx != NULL);
16081037
1609                     int x, x_index = x_index_base;
1610                     for (x = sx; x < ex; x++)
1611                     {
1612                        int c = source[x_index>>16];
1613                        if (c != transparent_color)
1614                        {
1615                           if (((1 << pri[x]) & pri_mask) == 0)
1616                              dest[x] = alpha_blend16(dest[x], pal[c]);
1617//                                      dest[x] = alpha_blend16(dest[x], colorbase + c);
1618                           pri[x] = 31;
1619                        }
1620                        x_index += dx;
1621                     }
1038   /* get final code and color, and grab lookup tables */
1039   code %= gfx->total_elements;
1040   color %= gfx->total_colors;
1041   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
16221042
1623                     y_index += dy;
1624                  }
1625               else
1626                  for (y = sy; y < ey; y++)
1627                  {
1628                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1629                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1043   /* high bit of the mask is implicitly on */
1044   pmask |= 1 << 31;
16301045
1631                     int x, x_index = x_index_base;
1632                     for (x = sx; x < ex; x++)
1633                     {
1634                        int c = source[x_index>>16];
1635                        if( c != transparent_color ) dest[x] = alpha_blend16(dest[x], pal[c]);
1636//                              if (c != transparent_color) dest[x] = alpha_blend16(dest[x], colorbase + c);
1637                        x_index += dx;
1638                     }
1046   /* render based on dest bitmap depth */
1047   if (dest->bpp == 16)
1048      DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE_PRIORITY, UINT8);
1049   else
1050      DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE_PRIORITY, UINT8);
1051}
16391052
1640                     y_index += dy;
1641                  }
1642            }
16431053
1644            /* case 7: TRANSPARENCY_ALPHARANGE */
1645            if (transparency == TRANSPARENCY_ALPHARANGE)
1646            {
1647               if (pri_buffer)
1648                  for (y = sy; y < ey; y++)
1649                  {
1650                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1651                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1652                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
1054/*-------------------------------------------------
1055    pdrawgfx_transpen - render a gfx element with
1056    a single transparent pen, checking against the
1057    priority bitmap
1058-------------------------------------------------*/
16531059
1654                     int x, x_index = x_index_base;
1655                     for (x = sx; x < ex; x++)
1656                     {
1657                        int c = source[x_index>>16];
1658                        if (c != transparent_color)
1659                        {
1660                           if (((1 << pri[x]) & pri_mask) == 0)
1661                           {
1662                              if (gfx_alpharange_table[c] == 0xff)
1663                                 dest[x] = pal[c];
1664//                                          dest[x] = colorbase + c;
1665                              else
1666                                 dest[x] = alpha_blend_r16(dest[x], pal[c], gfx_alpharange_table[c]);
1667//                                          dest[x] = alpha_blend_r16(dest[x], colorbase + c, gfx_alpharange_table[c]);
1668                           }
1669                           pri[x] = 31;
1670                        }
1671                        x_index += dx;
1672                     }
1060void pdrawgfx_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1061      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1062      bitmap_t *priority, UINT32 pmask, UINT32 transpen)
1063{
1064   const pen_t *paldata;
16731065
1674                     y_index += dy;
1675                  }
1676               else
1677                  for (y = sy; y < ey; y++)
1678                  {
1679                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1680                     UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
1066   /* special case invalid pens to opaque */
1067   if (transpen > 0xff)
1068   {
1069      pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask);
1070      return;
1071   }
16811072
1682                     int x, x_index = x_index_base;
1683                     for (x = sx; x < ex; x++)
1684                     {
1685                        int c = source[x_index>>16];
1686                        if (c != transparent_color)
1687                        {
1688                           if (gfx_alpharange_table[c] == 0xff)
1689                              dest[x] = pal[c];
1690//                                      dest[x] = colorbase + c;
1691                           else
1692                              dest[x] = alpha_blend_r16(dest[x], pal[c], gfx_alpharange_table[c]);
1693//                                      dest[x] = alpha_blend_r16(dest[x], colorbase + c, gfx_alpharange_table[c]);
1694                        }
1695                        x_index += dx;
1696                     }
1073   assert(dest != NULL);
1074   assert(dest->bpp == 16 || dest->bpp == 32);
1075   assert(gfx != NULL);
16971076
1698                     y_index += dy;
1699                  }
1700            }
1701         }
1702      }
1703   }
1077   /* get final code and color, and grab lookup tables */
1078   code %= gfx->total_elements;
1079   color %= gfx->total_colors;
1080   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
17041081
1705   /* 32-bit destination bitmap */
1706   else
1082   /* use pen usage to optimize */
1083   if (gfx->pen_usage != NULL && !gfx->dirty[code])
17071084   {
1708      const pen_t *pal = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
1709      UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
1085      UINT32 usage = gfx->pen_usage[code];
17101086
1711      int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
1712      int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
1087      /* fully transparent; do nothing */
1088      if ((usage & ~(1 << transpen)) == 0)
1089         return;
17131090
1714      if (sprite_screen_width && sprite_screen_height)
1091      /* fully opaque; draw as such */
1092      if ((usage & (1 << transpen)) == 0)
17151093      {
1716         /* compute sprite increment per screen pixel */
1717         int dx = (gfx->width<<16)/sprite_screen_width;
1718         int dy = (gfx->height<<16)/sprite_screen_height;
1094         pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask);
1095         return;
1096      }
1097   }
17191098
1720         int ex = sx+sprite_screen_width;
1721         int ey = sy+sprite_screen_height;
1099   /* high bit of the mask is implicitly on */
1100   pmask |= 1 << 31;
17221101
1723         int x_index_base;
1724         int y_index;
1102   /* render based on dest bitmap depth */
1103   if (dest->bpp == 16)
1104      DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, UINT8);
1105   else
1106      DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, UINT8);
1107}
17251108
1726         if (flipx)
1727         {
1728            x_index_base = (sprite_screen_width-1)*dx;
1729            dx = -dx;
1730         }
1731         else
1732         {
1733            x_index_base = 0;
1734         }
17351109
1736         if (flipy)
1737         {
1738            y_index = (sprite_screen_height-1)*dy;
1739            dy = -dy;
1740         }
1741         else
1742         {
1743            y_index = 0;
1744         }
1110/*-------------------------------------------------
1111    pdrawgfx_transpen_raw - render a gfx element
1112    with a single transparent pen and no color
1113    lookups, checking against the priority bitmap
1114-------------------------------------------------*/
17451115
1746         if (clip)
1747         {
1748            if (sx < clip->min_x)
1749            { /* clip left */
1750               int pixels = clip->min_x-sx;
1751               sx += pixels;
1752               x_index_base += pixels*dx;
1753            }
1116void pdrawgfx_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1117      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1118      bitmap_t *priority, UINT32 pmask, UINT32 transpen)
1119{
1120   assert(dest != NULL);
1121   assert(dest->bpp == 16 || dest->bpp == 32);
1122   assert(gfx != NULL);
17541123
1755            if (sy < clip->min_y)
1756            { /* clip top */
1757               int pixels = clip->min_y-sy;
1758               sy += pixels;
1759               y_index += pixels*dy;
1760            }
1124   /* get final code and color, and grab lookup tables */
1125   code %= gfx->total_elements;
17611126
1762            if (ex > clip->max_x + 1)
1763            { /* clip right */
1764               int pixels = ex-clip->max_x-1;
1765               ex -= pixels;
1766            }
1127   /* early out if completely transparent */
1128   if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
1129      return;
17671130
1768            if (ey > clip->max_y + 1)
1769            { /* clip bottom */
1770               int pixels = ey-clip->max_y-1;
1771               ey -= pixels;
1772            }
1773         }
1131   /* high bit of the mask is implicitly on */
1132   pmask |= 1 << 31;
17741133
1775         if (ex > sx)
1776         { /* skip if inner loop doesn't draw anything */
1777            int y;
1134   /* render based on dest bitmap depth */
1135   if (dest->bpp == 16)
1136      DRAWGFX_CORE(UINT16, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, UINT8);
1137   else
1138      DRAWGFX_CORE(UINT32, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, UINT8);
1139}
17781140
1779            /* case 0: TRANSPARENCY_NONE */
1780            if (transparency == TRANSPARENCY_NONE)
1781            {
1782               if (pri_buffer)
1783                  for (y = sy; y < ey; y++)
1784                  {
1785                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1786                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
1787                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
17881141
1789                     int x, x_index = x_index_base;
1790                     for (x = sx; x < ex; x++)
1791                     {
1792                        if (((1 << pri[x]) & pri_mask) == 0)
1793                           dest[x] = pal[source[x_index>>16]];
1794                        pri[x] = 31;
1795                        x_index += dx;
1796                     }
1142/*-------------------------------------------------
1143    pdrawgfx_transmask - render a gfx element
1144    with a multiple transparent pens provided as
1145    a mask, checking against the priority bitmap
1146-------------------------------------------------*/
17971147
1798                     y_index += dy;
1799                  }
1800               else
1801                  for (y = sy; y < ey; y++)
1802                  {
1803                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1804                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
1148void pdrawgfx_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1149      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1150      bitmap_t *priority, UINT32 pmask, UINT32 transmask)
1151{
1152   const pen_t *paldata;
18051153
1806                     int x, x_index = x_index_base;
1807                     for (x = sx; x < ex; x++)
1808                     {
1809                        dest[x] = pal[source[x_index>>16]];
1810                        x_index += dx;
1811                     }
1154   /* special case 0 mask to opaque */
1155   if (transmask == 0)
1156   {
1157      pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask);
1158      return;
1159   }
18121160
1813                     y_index += dy;
1814                  }
1815            }
1161   assert(dest != NULL);
1162   assert(dest->bpp == 16 || dest->bpp == 32);
1163   assert(gfx != NULL);
18161164
1817            /* case 1: TRANSPARENCY_PEN */
1818            if (transparency == TRANSPARENCY_PEN)
1819            {
1820               if (pri_buffer)
1821                  for (y = sy; y < ey; y++)
1822                  {
1823                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1824                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
1825                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
1165   /* get final code and color, and grab lookup tables */
1166   code %= gfx->total_elements;
1167   color %= gfx->total_colors;
1168   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
18261169
1827                     int x, x_index = x_index_base;
1828                     for (x = sx; x < ex; x++)
1829                     {
1830                        int c = source[x_index>>16];
1831                        if (c != transparent_color)
1832                        {
1833                           if (((1 << pri[x]) & pri_mask) == 0)
1834                              dest[x] = pal[c];
1835                           pri[x] = 31;
1836                        }
1837                        x_index += dx;
1838                     }
1170   /* use pen usage to optimize */
1171   if (gfx->pen_usage != NULL && !gfx->dirty[code])
1172   {
1173      UINT32 usage = gfx->pen_usage[code];
18391174
1840                     y_index += dy;
1841                  }
1842               else
1843                  for (y = sy; y < ey; y++)
1844                  {
1845                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1846                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
1175      /* fully transparent; do nothing */
1176      if ((usage & ~transmask) == 0)
1177         return;
18471178
1848                     int x, x_index = x_index_base;
1849                     for (x = sx; x < ex; x++)
1850                     {
1851                        int c = source[x_index>>16];
1852                        if (c != transparent_color) dest[x] = pal[c];
1853                        x_index += dx;
1854                     }
1179      /* fully opaque; draw as such */
1180      if ((usage & transmask) == 0)
1181      {
1182         pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask);
1183         return;
1184      }
1185   }
18551186
1856                     y_index += dy;
1857                  }
1858            }
1187   /* high bit of the mask is implicitly on */
1188   pmask |= 1 << 31;
18591189
1860            /* case 1b: TRANSPARENCY_PEN_RAW */
1861            if (transparency == TRANSPARENCY_PEN_RAW)
1862            {
1863               if (pri_buffer)
1864                  for (y = sy; y < ey; y++)
1865                  {
1866                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1867                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
1868                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
1190   /* render based on dest bitmap depth */
1191   if (dest->bpp == 16)
1192      DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, UINT8);
1193   else
1194      DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, UINT8);
1195}
18691196
1870                     int x, x_index = x_index_base;
1871                     for (x = sx; x < ex; x++)
1872                     {
1873                        int c = source[x_index>>16];
1874                        if (c != transparent_color)
1875                        {
1876                           if (((1 << pri[x]) & pri_mask) == 0)
1877                              dest[x] = color + c;
1878                           pri[x] = 31;
1879                        }
1880                        x_index += dx;
1881                     }
18821197
1883                     y_index += dy;
1884                  }
1885               else
1886                  for (y = sy; y < ey; y++)
1887                  {
1888                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1889                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
1198/*-------------------------------------------------
1199    pdrawgfx_transtable - render a gfx element
1200    using a table to look up which pens are
1201    transparent, opaque, or shadowing, checking
1202    against the priority bitmap
1203-------------------------------------------------*/
18901204
1891                     int x, x_index = x_index_base;
1892                     for (x = sx; x < ex; x++)
1893                     {
1894                        int c = source[x_index>>16];
1895                        if (c != transparent_color) dest[x] = color + c;
1896                        x_index += dx;
1897                     }
1205void pdrawgfx_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1206      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1207      bitmap_t *priority, UINT32 pmask, const UINT8 *pentable, const pen_t *shadowtable)
1208{
1209   const pen_t *paldata;
18981210
1899                     y_index += dy;
1900                  }
1901            }
1211   assert(dest != NULL);
1212   assert(dest->bpp == 16 || dest->bpp == 32);
1213   assert(gfx != NULL);
1214   assert(pentable != NULL);
19021215
1903            /* case 2: TRANSPARENCY_PENS */
1904            if (transparency == TRANSPARENCY_PENS)
1905            {
1906               if (pri_buffer)
1907                  for (y = sy; y < ey; y++)
1908                  {
1909                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1910                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
1911                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
1216   /* get final code and color, and grab lookup tables */
1217   code %= gfx->total_elements;
1218   color %= gfx->total_colors;
1219   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
19121220
1913                     int x, x_index = x_index_base;
1914                     for (x = sx; x < ex; x++)
1915                     {
1916                        int c = source[x_index>>16];
1917                        if (((1 << c) & transparent_color) == 0)
1918                        {
1919                           if (((1 << pri[x]) & pri_mask) == 0)
1920                              dest[x] = pal[c];
1921                           pri[x] = 31;
1922                        }
1923                        x_index += dx;
1924                     }
1221   /* high bit of the mask is implicitly on */
1222   pmask |= 1 << 31;
19251223
1926                     y_index += dy;
1927                  }
1928               else
1929                  for (y = sy; y < ey; y++)
1930                  {
1931                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
1932                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
1224   /* render based on dest bitmap depth */
1225   if (dest->bpp == 16)
1226      DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSTABLE16_PRIORITY, UINT8);
1227   else
1228      DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY, UINT8);
1229}
19331230
1934                     int x, x_index = x_index_base;
1935                     for (x = sx; x < ex; x++)
1936                     {
1937                        int c = source[x_index>>16];
1938                        if (((1 << c) & transparent_color) == 0)
1939                           dest[x] = pal[c];
1940                        x_index += dx;
1941                     }
19421231
1943                     y_index += dy;
1944                  }
1945            }
1232/*-------------------------------------------------
1233    pdrawgfx_alpha - render a gfx element with
1234    a single transparent pen, alpha blending the
1235    remaining pixels with a fixed alpha value,
1236    checking against the priority bitmap
1237-------------------------------------------------*/
19461238
1947            /* case 3: TRANSPARENCY_PEN_TABLE */
1948            if (transparency == TRANSPARENCY_PEN_TABLE)
1949            {
1950               pen_t *palette_shadow_table = gfx->machine->shadow_table;
1951               UINT8 *source;
1952               UINT8 *pri;
1953               UINT32 *dest;
1954               int c, x, x_index;
1955               UINT8 al, ah;
1239void pdrawgfx_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1240      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1241      bitmap_t *priority, UINT32 pmask, UINT32 transpen, UINT8 alpha)
1242{
1243   const pen_t *paldata;
19561244
1957               if (pri_buffer)
1958                  for (y = sy; y < ey; y++)
1959                  {
1960                     source = source_base + (y_index>>16) * gfx->line_modulo;
1961                     y_index += dy;
1962                     dest = BITMAP_ADDR32(dest_bmp, y, 0);
1963                     pri = BITMAP_ADDR8(pri_buffer, y, 0);
1964                     x_index = x_index_base;
1245   assert(dest != NULL);
1246   assert(dest->bpp == 16 || dest->bpp == 32);
1247   assert(gfx != NULL);
19651248
1966                     for (x = sx; x < ex; x++)
1967                     {
1968                        int ebx = x_index;
1969                        x_index += dx;
1970                        ebx >>= 16;
1971                        al = pri[x];
1972                        c = source[ebx];
1973                        ah = al;
1974                        al &= 0x1f;
1249   /* special case alpha = 0xff */
1250   if (alpha == 0xff)
1251   {
1252      pdrawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, transpen);
1253      return;
1254   }
19751255
1976                        if (gfx_drawmode_table[c] == DRAWMODE_NONE) continue;
1256   /* get final code and color, and grab lookup tables */
1257   code %= gfx->total_elements;
1258   color %= gfx->total_colors;
1259   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
19771260
1978                        if (!(1<<al & pri_mask))
1979                        {
1980                           if (gfx_drawmode_table[c] == DRAWMODE_SOURCE)
1981                           {
1982                              ah &= 0x7f;
1983                              ebx = pal[c];
1984                              ah |= 0x1f;
1985                              dest[x] = ebx;
1986                              pri[x] = ah;
1987                           }
1988                           else if (!(ah & 0x80))
1989                           {
1990                              ebx = SHADOW32(palette_shadow_table,dest[x]);
1991                              pri[x] |= 0x80;
1992                              dest[x] = ebx;
1993                           }
1994                        }
1995                     }
1996                  }
1997               else
1998                  for (y = sy; y < ey; y++)
1999                  {
2000                     source = source_base + (y_index>>16) * gfx->line_modulo;
2001                     y_index += dy;
2002                     dest = BITMAP_ADDR32(dest_bmp, y, 0);
2003                     x_index = x_index_base;
1261   /* early out if completely transparent */
1262   if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
1263      return;
20041264
2005                     for (x = sx; x < ex; x++)
2006                     {
2007                        c = source[x_index>>16];
2008                        x_index += dx;
1265   /* high bit of the mask is implicitly on */
1266   pmask |= 1 << 31;
20091267
2010                        if (gfx_drawmode_table[c] == DRAWMODE_NONE) continue;
2011                        if (gfx_drawmode_table[c] == DRAWMODE_SOURCE)
2012                           dest[x] = pal[c];
2013                        else
2014                           dest[x] = SHADOW32(palette_shadow_table,dest[x]);
2015                     }
2016                  }
2017            }
1268   /* render based on dest bitmap depth */
1269   if (dest->bpp == 16)
1270      DRAWGFX_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_ALPHA16_PRIORITY, UINT8);
1271   else
1272      DRAWGFX_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY, UINT8);
1273}
20181274
2019            /* case 6: TRANSPARENCY_ALPHA */
2020            if (transparency == TRANSPARENCY_ALPHA)
2021            {
2022               if (pri_buffer)
2023                  for (y = sy; y < ey; y++)
2024                  {
2025                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2026                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
2027                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
20281275
2029                     int x, x_index = x_index_base;
2030                     for (x = sx; x < ex; x++)
2031                     {
2032                        int c = source[x_index>>16];
2033                        if (c != transparent_color)
2034                        {
2035                           if (((1 << pri[x]) & pri_mask) == 0)
2036                              dest[x] = alpha_blend32(dest[x], pal[c]);
2037                           pri[x] = 31;
2038                        }
2039                        x_index += dx;
2040                     }
20411276
2042                     y_index += dy;
2043                  }
2044               else
2045                  for (y = sy; y < ey; y++)
2046                  {
2047                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2048                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
1277/***************************************************************************
1278    PDRAWGFXZOOM IMPLEMENTATIONS
1279***************************************************************************/
20491280
2050                     int x, x_index = x_index_base;
2051                     for (x = sx; x < ex; x++)
2052                     {
2053                        int c = source[x_index>>16];
2054                        if (c != transparent_color) dest[x] = alpha_blend32(dest[x], pal[c]);
2055                        x_index += dx;
2056                     }
1281/*-------------------------------------------------
1282    pdrawgfxzoom - generic pdrawgfxzoom with
1283    legacy interface
1284-------------------------------------------------*/
20571285
2058                     y_index += dy;
2059                  }
2060            }
1286void pdrawgfxzoom(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy,
1287      INT32 sx, INT32 sy, const rectangle *cliprect, int transparency, UINT32 transparent_color,
1288      UINT32 scalex, UINT32 scaley, UINT32 priority_mask)
1289{
1290   switch (transparency)
1291   {
1292      case TRANSPARENCY_NONE:
1293         pdrawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley, priority_bitmap, priority_mask);
1294         break;
20611295
2062            /* case 7: TRANSPARENCY_ALPHARANGE */
2063            if (transparency == TRANSPARENCY_ALPHARANGE)
2064            {
2065               if (pri_buffer)
2066                  for (y = sy; y < ey; y++)
2067                  {
2068                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2069                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
2070                     UINT8 *pri = BITMAP_ADDR8(pri_buffer, y, 0);
1296      case TRANSPARENCY_PEN:
1297         pdrawgfxzoom_transpen(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley, priority_bitmap, priority_mask, transparent_color);
1298         break;
20711299
2072                     int x, x_index = x_index_base;
2073                     for (x = sx; x < ex; x++)
2074                     {
2075                        int c = source[x_index>>16];
2076                        if (c != transparent_color)
2077                        {
2078                           if (((1 << pri[x]) & pri_mask) == 0)
2079                           {
2080                              if (gfx_alpharange_table[c] == 0xff)
2081                                 dest[x] = pal[c];
2082                              else
2083                                 dest[x] = alpha_blend_r32(dest[x], pal[c], gfx_alpharange_table[c]);
2084                           }
2085                           pri[x] = 31;
2086                        }
2087                        x_index += dx;
2088                     }
1300      case TRANSPARENCY_PENS:
1301         pdrawgfxzoom_transmask(dest, cliprect, gfx, code, color, flipx, flipy, sx, sy, scalex, scaley, priority_bitmap, priority_mask, transparent_color);
1302         break;
20891303
2090                     y_index += dy;
2091                  }
2092               else
2093                  for (y = sy; y < ey; y++)
2094                  {
2095                     UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
2096                     UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
2097
2098                     int x, x_index = x_index_base;
2099                     for (x = sx; x < ex; x++)
2100                     {
2101                        int c = source[x_index>>16];
2102                        if (c != transparent_color)
2103                        {
2104                           if (gfx_alpharange_table[c] == 0xff)
2105                              dest[x] = pal[c];
2106                           else
2107                              dest[x] = alpha_blend_r32(dest[x], pal[c], gfx_alpharange_table[c]);
2108                        }
2109                        x_index += dx;
2110                     }
2111
2112                     y_index += dy;
2113                  }
2114            }
2115         }
2116      }
1304      default:
1305         fatalerror("Invalid transparency specified for pdrawgfxzoom (%d)", transparency);
1306         break;
21171307   }
21181308}
21191309
2120void drawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
2121      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
2122      const rectangle *clip,int transparency,int transparent_color,int scalex, int scaley)
2123{
2124   profiler_mark(PROFILER_DRAWGFX);
2125   common_drawgfxzoom(dest_bmp,gfx,code,color,flipx,flipy,sx,sy,
2126         clip,transparency,transparent_color,scalex,scaley,NULL,0);
2127   profiler_mark(PROFILER_END);
2128}
21291310
2130void pdrawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
2131      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
2132      const rectangle *clip,int transparency,int transparent_color,int scalex, int scaley,
2133      UINT32 priority_mask)
2134{
2135   profiler_mark(PROFILER_DRAWGFX);
2136   common_drawgfxzoom(dest_bmp,gfx,code,color,flipx,flipy,sx,sy,
2137         clip,transparency,transparent_color,scalex,scaley,priority_bitmap,priority_mask | (1<<31));
2138   profiler_mark(PROFILER_END);
2139}
1311/*-------------------------------------------------
1312    pdrawgfxzoom_opaque - render a scaled gfx
1313    element with no transparency, checking against
1314    the priority bitmap
1315-------------------------------------------------*/
21401316
2141void mdrawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
2142      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
2143      const rectangle *clip,int transparency,int transparent_color,int scalex, int scaley,
2144      UINT32 priority_mask)
1317void pdrawgfxzoom_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1318      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1319      UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask)
21451320{
2146   profiler_mark(PROFILER_DRAWGFX);
2147   common_drawgfxzoom(dest_bmp,gfx,code,color,flipx,flipy,sx,sy,
2148         clip,transparency,transparent_color,scalex,scaley,priority_bitmap,priority_mask);
2149   profiler_mark(PROFILER_END);
2150}
1321   const pen_t *paldata;
21511322
1323   /* non-zoom case */
1324   if (scalex == 0x10000 && scaley == 0x10000)
1325   {
1326      pdrawgfx_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask);
1327      return;
1328   }
21521329
2153#else /* DECLAREG */
1330   assert(dest != NULL);
1331   assert(dest->bpp == 16 || dest->bpp == 32);
1332   assert(gfx != NULL);
21541333
2155#if (DEPTH != 8)
2156/* -------------------- included inline section --------------------- */
2157#define ADJUST_8                                       \
2158   int ydir;                                          \
2159   if (flipy)                                          \
2160   {                                                \
2161      INCREMENT_DST(VMODULO * (dstheight-1))                  \
2162      srcdata += (srcheight - dstheight - topskip) * srcmodulo;   \
2163      ydir = -1;                                       \
2164   }                                                \
2165   else                                             \
2166   {                                                \
2167      srcdata += topskip * srcmodulo;                        \
2168      ydir = 1;                                       \
2169   }                                                \
2170   if (flipx)                                          \
2171   {                                                \
2172      INCREMENT_DST(HMODULO * (dstwidth-1))                  \
2173      srcdata += (srcwidth - dstwidth - leftskip);            \
2174   }                                                \
2175   else                                             \
2176      srcdata += leftskip;                              \
2177   srcmodulo -= dstwidth;
1334   /* get final code and color, and grab lookup tables */
1335   code %= gfx->total_elements;
1336   color %= gfx->total_colors;
1337   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
21781338
1339   /* high bit of the mask is implicitly on */
1340   pmask |= 1 << 31;
21791341
2180#define ADJUST_4                                       \
2181   int ydir;                                          \
2182   if (flipy)                                          \
2183   {                                                \
2184      INCREMENT_DST(VMODULO * (dstheight-1))                  \
2185      srcdata += (srcheight - dstheight - topskip) * srcmodulo;   \
2186      ydir = -1;                                       \
2187   }                                                \
2188   else                                             \
2189   {                                                \
2190      srcdata += topskip * srcmodulo;                        \
2191      ydir = 1;                                       \
2192   }                                                \
2193   if (flipx)                                          \
2194   {                                                \
2195      INCREMENT_DST(HMODULO * (dstwidth-1))                  \
2196      srcdata += (srcwidth - dstwidth - leftskip)/2;            \
2197      leftskip = (srcwidth - dstwidth - leftskip) & 1;         \
2198   }                                                \
2199   else                                             \
2200   {                                                \
2201      srcdata += leftskip/2;                              \
2202      leftskip &= 1;                                    \
2203   }                                                \
2204   srcmodulo -= (dstwidth+leftskip)/2;
1342   /* render based on dest bitmap depth */
1343   if (dest->bpp == 16)
1344      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE_PRIORITY, UINT8);
1345   else
1346      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE_PRIORITY, UINT8);
1347}
22051348
22061349
1350/*-------------------------------------------------
1351    pdrawgfxzoom_transpen - render a scaled gfx
1352    element with a single transparent pen,
1353    checking against the priority bitmap
1354-------------------------------------------------*/
22071355
2208#if (RAW == 0)
2209DECLARE_SWAP_RAW_PRI(blockmove_8toN_opaque,(COMMON_ARGS, COLOR_ARG),
1356void pdrawgfxzoom_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1357      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1358      UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask,
1359      UINT32 transpen)
22101360{
2211   ADJUST_8
1361   const pen_t *paldata;
22121362
2213   (void)palette_shadow_table;
2214
2215   if (flipx)
1363   /* non-zoom case */
1364   if (scalex == 0x10000 && scaley == 0x10000)
22161365   {
2217      DATA_TYPE *end;
2218
2219      while (dstheight)
2220      {
2221         end = dstdata - dstwidth*HMODULO;
2222         while (dstdata >= end + 8*HMODULO)
2223         {
2224            INCREMENT_DST(-8*HMODULO)
2225            SETPIXELCOLOR(8*HMODULO,LOOKUP(srcdata[0]))
2226            SETPIXELCOLOR(7*HMODULO,LOOKUP(srcdata[1]))
2227            SETPIXELCOLOR(6*HMODULO,LOOKUP(srcdata[2]))
2228            SETPIXELCOLOR(5*HMODULO,LOOKUP(srcdata[3]))
2229            SETPIXELCOLOR(4*HMODULO,LOOKUP(srcdata[4]))
2230            SETPIXELCOLOR(3*HMODULO,LOOKUP(srcdata[5]))
2231            SETPIXELCOLOR(2*HMODULO,LOOKUP(srcdata[6]))
2232            SETPIXELCOLOR(1*HMODULO,LOOKUP(srcdata[7]))
2233            srcdata += 8;
2234         }
2235         while (dstdata > end)
2236         {
2237            SETPIXELCOLOR(0,LOOKUP(*srcdata))
2238            srcdata++;
2239            INCREMENT_DST(-HMODULO)
2240         }
2241
2242         srcdata += srcmodulo;
2243         INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
2244         dstheight--;
2245      }
1366      pdrawgfx_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, transpen);
1367      return;
22461368   }
2247   else
2248   {
2249      DATA_TYPE *end;
22501369
2251      while (dstheight)
2252      {
2253         end = dstdata + dstwidth*HMODULO;
2254         while (dstdata <= end - 8*HMODULO)
2255         {
2256            SETPIXELCOLOR(0*HMODULO,LOOKUP(srcdata[0]))
2257            SETPIXELCOLOR(1*HMODULO,LOOKUP(srcdata[1]))
2258            SETPIXELCOLOR(2*HMODULO,LOOKUP(srcdata[2]))
2259            SETPIXELCOLOR(3*HMODULO,LOOKUP(srcdata[3]))
2260            SETPIXELCOLOR(4*HMODULO,LOOKUP(srcdata[4]))
2261            SETPIXELCOLOR(5*HMODULO,LOOKUP(srcdata[5]))
2262            SETPIXELCOLOR(6*HMODULO,LOOKUP(srcdata[6]))
2263            SETPIXELCOLOR(7*HMODULO,LOOKUP(srcdata[7]))
2264            srcdata += 8;
2265            INCREMENT_DST(8*HMODULO)
2266         }
2267         while (dstdata < end)
2268         {
2269            SETPIXELCOLOR(0,LOOKUP(*srcdata))
2270            srcdata++;
2271            INCREMENT_DST(HMODULO)
2272         }
2273
2274         srcdata += srcmodulo;
2275         INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
2276         dstheight--;
2277      }
1370   /* special case invalid pens to opaque */
1371   if (transpen > 0xff)
1372   {
1373      pdrawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, priority, pmask);
1374      return;
22781375   }
2279})
2280#endif
22811376
2282#if (RAW == 0)
2283DECLARE_SWAP_RAW_PRI(blockmove_4toN_opaque,(COMMON_ARGS, COLOR_ARG),
2284{
2285   ADJUST_4
1377   assert(dest != NULL);
1378   assert(dest->bpp == 16 || dest->bpp == 32);
1379   assert(gfx != NULL);
22861380
2287   (void)palette_shadow_table;
1381   /* get final code and color, and grab lookup tables */
1382   code %= gfx->total_elements;
1383   color %= gfx->total_colors;
1384   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
22881385
2289   if (flipx)
1386   /* use pen usage to optimize */
1387   if (gfx->pen_usage != NULL && !gfx->dirty[code])
22901388   {
2291      DATA_TYPE *end;
1389      UINT32 usage = gfx->pen_usage[code];
22921390
2293      while (dstheight)
2294      {
2295         end = dstdata - dstwidth*HMODULO;
2296         if (leftskip)
2297         {
2298            SETPIXELCOLOR(0,LOOKUP(*srcdata>>4))
2299            srcdata++;
2300            INCREMENT_DST(-HMODULO)
2301         }
2302         while (dstdata >= end + 8*HMODULO)
2303         {
2304            INCREMENT_DST(-8*HMODULO)
2305            SETPIXELCOLOR(8*HMODULO,LOOKUP(srcdata[0]&0x0f))
2306            SETPIXELCOLOR(7*HMODULO,LOOKUP(srcdata[0]>>4))
2307            SETPIXELCOLOR(6*HMODULO,LOOKUP(srcdata[1]&0x0f))
2308            SETPIXELCOLOR(5*HMODULO,LOOKUP(srcdata[1]>>4))
2309            SETPIXELCOLOR(4*HMODULO,LOOKUP(srcdata[2]&0x0f))
2310            SETPIXELCOLOR(3*HMODULO,LOOKUP(srcdata[2]>>4))
2311            SETPIXELCOLOR(2*HMODULO,LOOKUP(srcdata[3]&0x0f))
2312            SETPIXELCOLOR(1*HMODULO,LOOKUP(srcdata[3]>>4))
2313            srcdata += 4;
2314         }
2315         while (dstdata > end)
2316         {
2317            SETPIXELCOLOR(0,LOOKUP(*srcdata&0x0f))
2318            INCREMENT_DST(-HMODULO)
2319            if (dstdata > end)
2320            {
2321               SETPIXELCOLOR(0,LOOKUP(*srcdata>>4))
2322               srcdata++;
2323               INCREMENT_DST(-HMODULO)
2324            }
2325         }
1391      /* fully transparent; do nothing */
1392      if ((usage & ~(1 << transpen)) == 0)
1393         return;
23261394
2327         srcdata += srcmodulo;
2328         INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
2329         dstheight--;
1395      /* fully opaque; draw as such */
1396      if ((usage & (1 << transpen)) == 0)
1397      {
1398         pdrawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, priority, pmask);
1399         return;
23301400      }
23311401   }
2332   else
2333   {
2334      DATA_TYPE *end;
23351402
2336      while (dstheight)
2337      {
2338         end = dstdata + dstwidth*HMODULO;
2339         if (leftskip)
2340         {
2341            SETPIXELCOLOR(0,LOOKUP(*srcdata>>4))
2342            srcdata++;
2343            INCREMENT_DST(HMODULO)
2344         }
2345         while (dstdata <= end - 8*HMODULO)
2346         {
2347            SETPIXELCOLOR(0*HMODULO,LOOKUP(srcdata[0]&0x0f))
2348            SETPIXELCOLOR(1*HMODULO,LOOKUP(srcdata[0]>>4))
2349            SETPIXELCOLOR(2*HMODULO,LOOKUP(srcdata[1]&0x0f))
2350            SETPIXELCOLOR(3*HMODULO,LOOKUP(srcdata[1]>>4))
2351            SETPIXELCOLOR(4*HMODULO,LOOKUP(srcdata[2]&0x0f))
2352            SETPIXELCOLOR(5*HMODULO,LOOKUP(srcdata[2]>>4))
2353            SETPIXELCOLOR(6*HMODULO,LOOKUP(srcdata[3]&0x0f))
2354            SETPIXELCOLOR(7*HMODULO,LOOKUP(srcdata[3]>>4))
2355            srcdata += 4;
2356            INCREMENT_DST(8*HMODULO)
2357         }
2358         while (dstdata < end)
2359         {
2360            SETPIXELCOLOR(0,LOOKUP(*srcdata&0x0f))
2361            INCREMENT_DST(HMODULO)
2362            if (dstdata < end)
2363            {
2364               SETPIXELCOLOR(0,LOOKUP(*srcdata>>4))
2365               srcdata++;
2366               INCREMENT_DST(HMODULO)
2367            }
2368         }
1403   /* high bit of the mask is implicitly on */
1404   pmask |= 1 << 31;
23691405
2370         srcdata += srcmodulo;
2371         INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
2372         dstheight--;
2373      }
2374   }
2375})
2376#endif
1406   /* render based on dest bitmap depth */
1407   if (dest->bpp == 16)
1408      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, UINT8);
1409   else
1410      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, UINT8);
1411}
23771412
2378DECLARE_SWAP_RAW_PRI(blockmove_8toN_transpen,(COMMON_ARGS, COLOR_ARG, int transpen),
2379{
2380   ADJUST_8
23811413
2382   (void)palette_shadow_table;
1414/*-------------------------------------------------
1415    pdrawgfxzoom_transpen_raw - render a scaled gfx
1416    element with a single transparent pen and no
1417    color lookups, checking against the priority
1418    bitmap
1419-------------------------------------------------*/
23831420
2384   if (flipx)
1421void pdrawgfxzoom_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1422      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1423      UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask,
1424      UINT32 transpen)
1425{
1426   /* non-zoom case */
1427   if (scalex == 0x10000 && scaley == 0x10000)
23851428   {
2386      DATA_TYPE *end;
2387      int trans4;
2388      UINT32 *sd4;
1429      pdrawgfx_transpen_raw(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, transpen);
1430      return;
1431   }
23891432
2390      trans4 = transpen * 0x01010101;
1433   assert(dest != NULL);
1434   assert(dest->bpp == 16 || dest->bpp == 32);
1435   assert(gfx != NULL);
23911436
2392      while (dstheight)
2393      {
2394         end = dstdata - dstwidth*HMODULO;
2395         while (((FPTR)srcdata & 3) && dstdata > end)   /* longword align */
2396         {
2397            int col;
1437   /* get final code and color, and grab lookup tables */
1438   code %= gfx->total_elements;
23981439
2399            col = *(srcdata++);
2400            if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
2401            INCREMENT_DST(-HMODULO)
2402         }
2403         sd4 = (UINT32 *)srcdata;
2404         while (dstdata >= end + 4*HMODULO)
2405         {
2406            UINT32 col4;
1440   /* early out if completely transparent */
1441   if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
1442      return;
24071443
2408            INCREMENT_DST(-4*HMODULO)
2409            if ((col4 = *(sd4++)) != trans4)
2410            {
2411               UINT32 xod4;
1444   /* high bit of the mask is implicitly on */
1445   pmask |= 1 << 31;
24121446
2413               xod4 = col4 ^ trans4;
2414               if (xod4 & (0xff<<SHIFT0)) SETPIXELCOLOR(4*HMODULO,LOOKUP((col4>>SHIFT0) & 0xff))
2415               if (xod4 & (0xff<<SHIFT1)) SETPIXELCOLOR(3*HMODULO,LOOKUP((col4>>SHIFT1) & 0xff))
2416               if (xod4 & (0xff<<SHIFT2)) SETPIXELCOLOR(2*HMODULO,LOOKUP((col4>>SHIFT2) & 0xff))
2417               if (xod4 & (0xff<<SHIFT3)) SETPIXELCOLOR(1*HMODULO,LOOKUP((col4>>SHIFT3) & 0xff))
2418            }
2419         }
2420         srcdata = (UINT8 *)sd4;
2421         while (dstdata > end)
2422         {
2423            int col;
2424
2425            col = *(srcdata++);
2426            if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
2427            INCREMENT_DST(-HMODULO)
2428         }
2429
2430         srcdata += srcmodulo;
2431         INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO);
2432         dstheight--;
2433      }
2434   }
1447   /* render based on dest bitmap depth */
1448   if (dest->bpp == 16)
1449      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, UINT8);
24351450   else
2436   {
2437      DATA_TYPE *end;
2438      int trans4;
2439      UINT32 *sd4;
1451      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, UINT8);
1452}
24401453
2441      trans4 = transpen * 0x01010101;
24421454
2443      while (dstheight)
2444      {
2445         end = dstdata + dstwidth*HMODULO;
2446         while (((FPTR)srcdata & 3) && dstdata < end)   /* longword align */
2447         {
2448            int col;
1455/*-------------------------------------------------
1456    pdrawgfxzoom_transmask - render a scaled gfx
1457    element with a multiple transparent pens
1458    provided as a mask, checking against the
1459    priority bitmap
1460-------------------------------------------------*/
24491461
2450            col = *(srcdata++);
2451            if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
2452            INCREMENT_DST(HMODULO)
2453         }
2454         sd4 = (UINT32 *)srcdata;
2455         while (dstdata <= end - 4*HMODULO)
2456         {
2457            UINT32 col4;
1462void pdrawgfxzoom_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1463      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1464      UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask,
1465      UINT32 transmask)
1466{
1467   const pen_t *paldata;
24581468
2459            if ((col4 = *(sd4++)) != trans4)
2460            {
2461               UINT32 xod4;
1469   /* non-zoom case */
1470   if (scalex == 0x10000 && scaley == 0x10000)
1471   {
1472      pdrawgfx_transmask(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, transmask);
1473      return;
1474   }
24621475
2463               xod4 = col4 ^ trans4;
2464               if (xod4 & (0xff<<SHIFT0)) SETPIXELCOLOR(0*HMODULO,LOOKUP((col4>>SHIFT0) & 0xff))
2465               if (xod4 & (0xff<<SHIFT1)) SETPIXELCOLOR(1*HMODULO,LOOKUP((col4>>SHIFT1) & 0xff))
2466               if (xod4 & (0xff<<SHIFT2)) SETPIXELCOLOR(2*HMODULO,LOOKUP((col4>>SHIFT2) & 0xff))
2467               if (xod4 & (0xff<<SHIFT3)) SETPIXELCOLOR(3*HMODULO,LOOKUP((col4>>SHIFT3) & 0xff))
2468            }
2469            INCREMENT_DST(4*HMODULO)
2470         }
2471         srcdata = (UINT8 *)sd4;
2472         while (dstdata < end)
2473         {
2474            int col;
2475
2476            col = *(srcdata++);
2477            if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
2478            INCREMENT_DST(HMODULO)
2479         }
2480
2481         srcdata += srcmodulo;
2482         INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO);
2483         dstheight--;
2484      }
1476   /* special case 0 mask to opaque */
1477   if (transmask == 0)
1478   {
1479      pdrawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, priority, pmask);
1480      return;
24851481   }
2486})
24871482
2488DECLARE_SWAP_RAW_PRI(blockmove_4toN_transpen,(COMMON_ARGS, COLOR_ARG, int transpen),
2489{
2490   ADJUST_4
1483   assert(dest != NULL);
1484   assert(dest->bpp == 16 || dest->bpp == 32);
1485   assert(gfx != NULL);
24911486
2492   (void)palette_shadow_table;
1487   /* get final code and color, and grab lookup tables */
1488   code %= gfx->total_elements;
1489   color %= gfx->total_colors;
1490   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
24931491
2494   if (flipx)
1492   /* use pen usage to optimize */
1493   if (gfx->pen_usage != NULL && !gfx->dirty[code])
24951494   {
2496      DATA_TYPE *end;
1495      UINT32 usage = gfx->pen_usage[code];
24971496
2498      while (dstheight)
2499      {
2500         int col;
1497      /* fully transparent; do nothing */
1498      if ((usage & ~transmask) == 0)
1499         return;
25011500
2502         end = dstdata - dstwidth*HMODULO;
2503         if (leftskip)
2504         {
2505            col = *(srcdata++)>>4;
2506            if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
2507            INCREMENT_DST(-HMODULO)
2508         }
2509         while (dstdata > end)
2510         {
2511            col = *(srcdata)&0x0f;
2512            if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
2513            INCREMENT_DST(-HMODULO)
2514            if (dstdata > end)
2515            {
2516               col = *(srcdata++)>>4;
2517               if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
2518               INCREMENT_DST(-HMODULO)
2519            }
2520         }
2521
2522         srcdata += srcmodulo;
2523         INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
2524         dstheight--;
1501      /* fully opaque; draw as such */
1502      if ((usage & transmask) == 0)
1503      {
1504         pdrawgfxzoom_opaque(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, priority, pmask);
1505         return;
25251506      }
25261507   }
2527   else
2528   {
2529      DATA_TYPE *end;
25301508
2531      while (dstheight)
2532      {
2533         int col;
1509   /* high bit of the mask is implicitly on */
1510   pmask |= 1 << 31;
25341511
2535         end = dstdata + dstwidth*HMODULO;
2536         if (leftskip)
2537         {
2538            col = *(srcdata++)>>4;
2539            if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
2540            INCREMENT_DST(HMODULO)
2541         }
2542         while (dstdata < end)
2543         {
2544            col = *(srcdata)&0x0f;
2545            if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
2546            INCREMENT_DST(HMODULO)
2547            if (dstdata < end)
2548            {
2549               col = *(srcdata++)>>4;
2550               if (col != transpen) SETPIXELCOLOR(0,LOOKUP(col))
2551               INCREMENT_DST(HMODULO)
2552            }
2553         }
1512   /* render based on dest bitmap depth */
1513   if (dest->bpp == 16)
1514      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, UINT8);
1515   else
1516      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, UINT8);
1517}
25541518
2555         srcdata += srcmodulo;
2556         INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
2557         dstheight--;
2558      }
2559   }
2560})
25611519
2562#if (RAW == 0)
2563#define PEN_IS_OPAQUE ((1<<col)&transmask) == 0
1520/*-------------------------------------------------
1521    pdrawgfxzoom_transtable - render a scaled gfx
1522    element using a table to look up which pens
1523    are transparent, opaque, or shadowing,
1524    checking against the priority bitmap
1525-------------------------------------------------*/
25641526
2565DECLARE_SWAP_RAW_PRI(blockmove_8toN_transmask,(COMMON_ARGS, COLOR_ARG, int transmask),
1527void pdrawgfxzoom_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1528      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1529      UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask,
1530      const UINT8 *pentable, const pen_t *shadowtable)
25661531{
2567   ADJUST_8
1532   const pen_t *paldata;
25681533
2569   (void)palette_shadow_table;
2570
2571   if (flipx)
1534   /* non-zoom case */
1535   if (scalex == 0x10000 && scaley == 0x10000)
25721536   {
2573      DATA_TYPE *end;
2574      UINT32 *sd4;
1537      pdrawgfx_transtable(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, pentable, shadowtable);
1538      return;
1539   }
25751540
2576      while (dstheight)
2577      {
2578         end = dstdata - dstwidth*HMODULO;
2579         while (((FPTR)srcdata & 3) && dstdata > end)   /* longword align */
2580         {
2581            int col;
1541   assert(dest != NULL);
1542   assert(dest->bpp == 16 || dest->bpp == 32);
1543   assert(gfx != NULL);
1544   assert(pentable != NULL);
25821545
2583            col = *(srcdata++);
2584            if (PEN_IS_OPAQUE) SETPIXELCOLOR(0,LOOKUP(col))
2585            INCREMENT_DST(-HMODULO)
2586         }
2587         sd4 = (UINT32 *)srcdata;
2588         while (dstdata >= end + 4*HMODULO)
2589         {
2590            int col;
2591            UINT32 col4;
1546   /* get final code and color, and grab lookup tables */
1547   code %= gfx->total_elements;
1548   color %= gfx->total_colors;
1549   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
25921550
2593            INCREMENT_DST(-4*HMODULO)
2594            col4 = *(sd4++);
2595            col = (col4 >> SHIFT0) & 0xff;
2596            if (PEN_IS_OPAQUE) SETPIXELCOLOR(4*HMODULO,LOOKUP(col))
2597            col = (col4 >> SHIFT1) & 0xff;
2598            if (PEN_IS_OPAQUE) SETPIXELCOLOR(3*HMODULO,LOOKUP(col))
2599            col = (col4 >> SHIFT2) & 0xff;
2600            if (PEN_IS_OPAQUE) SETPIXELCOLOR(2*HMODULO,LOOKUP(col))
2601            col = (col4 >> SHIFT3) & 0xff;
2602            if (PEN_IS_OPAQUE) SETPIXELCOLOR(1*HMODULO,LOOKUP(col))
2603         }
2604         srcdata = (UINT8 *)sd4;
2605         while (dstdata > end)
2606         {
2607            int col;
1551   /* high bit of the mask is implicitly on */
1552   pmask |= 1 << 31;
26081553
2609            col = *(srcdata++);
2610            if (PEN_IS_OPAQUE) SETPIXELCOLOR(0,LOOKUP(col))
2611            INCREMENT_DST(-HMODULO)
2612         }
2613
2614         srcdata += srcmodulo;
2615         INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
2616         dstheight--;
2617      }
2618   }
1554   /* render based on dest bitmap depth */
1555   if (dest->bpp == 16)
1556      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSTABLE16_PRIORITY, UINT8);
26191557   else
2620   {
2621      DATA_TYPE *end;
2622      UINT32 *sd4;
1558      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY, UINT8);
1559}
26231560
2624      while (dstheight)
2625      {
2626         end = dstdata + dstwidth*HMODULO;
2627         while (((FPTR)srcdata & 3) && dstdata < end)   /* longword align */
2628         {
2629            int col;
26301561
2631            col = *(srcdata++);
2632            if (PEN_IS_OPAQUE) SETPIXELCOLOR(0,LOOKUP(col))
2633            INCREMENT_DST(HMODULO)
2634         }
2635         sd4 = (UINT32 *)srcdata;
2636         while (dstdata <= end - 4*HMODULO)
2637         {
2638            int col;
2639            UINT32 col4;
1562/*-------------------------------------------------
1563    pdrawgfxzoom_alpha - render a scaled gfx
1564    element with a single transparent pen, alpha
1565    blending the remaining pixels with a fixed
1566    alpha value, checking against the priority
1567    bitmap
1568-------------------------------------------------*/
26401569
2641            col4 = *(sd4++);
2642            col = (col4 >> SHIFT0) & 0xff;
2643            if (PEN_IS_OPAQUE) SETPIXELCOLOR(0*HMODULO,LOOKUP(col))
2644            col = (col4 >> SHIFT1) & 0xff;
2645            if (PEN_IS_OPAQUE) SETPIXELCOLOR(1*HMODULO,LOOKUP(col))
2646            col = (col4 >> SHIFT2) & 0xff;
2647            if (PEN_IS_OPAQUE) SETPIXELCOLOR(2*HMODULO,LOOKUP(col))
2648            col = (col4 >> SHIFT3) & 0xff;
2649            if (PEN_IS_OPAQUE) SETPIXELCOLOR(3*HMODULO,LOOKUP(col))
2650            INCREMENT_DST(4*HMODULO)
2651         }
2652         srcdata = (UINT8 *)sd4;
2653         while (dstdata < end)
2654         {
2655            int col;
2656
2657            col = *(srcdata++);
2658            if (PEN_IS_OPAQUE) SETPIXELCOLOR(0,LOOKUP(col))
2659            INCREMENT_DST(HMODULO)
2660         }
2661
2662         srcdata += srcmodulo;
2663         INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
2664         dstheight--;
2665      }
2666   }
2667})
2668#endif
2669
2670#if (RAW == 0)
2671#if (DEPTH == 32)
2672DECLARE_SWAP_RAW_PRI(blockmove_8toN_pen_table,(COMMON_ARGS, COLOR_ARG, int transcolor),
1570void pdrawgfxzoom_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
1571      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
1572      UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask,
1573      UINT32 transpen, UINT8 alpha)
26731574{
2674   ADJUST_8
1575   const pen_t *paldata;
26751576
2676   (void)palette_shadow_table;
2677
2678   if (flipx)
1577   /* non-zoom case */
1578   if (scalex == 0x10000 && scaley == 0x10000)
26791579   {
2680      DATA_TYPE *end;
2681
2682      while (dstheight)
2683      {
2684         end = dstdata - dstwidth*HMODULO;
2685         while (dstdata > end)
2686         {
2687            int col;
2688
2689            col = *(srcdata++);
2690            if (col != transcolor)
2691            {
2692               switch(gfx_drawmode_table[col])
2693               {
2694               case DRAWMODE_SOURCE:
2695                  SETPIXELCOLOR(0,LOOKUP(col))
2696                  break;
2697               case DRAWMODE_SHADOW:
2698                  afterdrawmask = 0;
2699                  SETPIXELCOLOR(0,*dstdata)
2700                  afterdrawmask = 31;
2701                  break;
2702               }
2703            }
2704            INCREMENT_DST(-HMODULO)
2705         }
2706
2707         srcdata += srcmodulo;
2708         INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
2709         dstheight--;
2710      }
1580      pdrawgfx_alpha(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, priority, pmask, transpen, alpha);
1581      return;
27111582   }
2712   else
2713   {
2714      DATA_TYPE *end;
27151583
2716      while (dstheight)
2717      {
2718         end = dstdata + dstwidth*HMODULO;
2719         while (dstdata < end)
2720         {
2721            int col;
2722
2723            col = *(srcdata++);
2724            if (col != transcolor)
2725            {
2726               switch(gfx_drawmode_table[col])
2727               {
2728               case DRAWMODE_SOURCE:
2729                  SETPIXELCOLOR(0,LOOKUP(col))
2730                  break;
2731               case DRAWMODE_SHADOW:
2732                  afterdrawmask = 0;
2733                  SETPIXELCOLOR(0,*dstdata)
2734                  afterdrawmask = 31;
2735                  break;
2736               }
2737            }
2738            INCREMENT_DST(HMODULO)
2739         }
2740
2741         srcdata += srcmodulo;
2742         INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
2743         dstheight--;
2744      }
1584   /* special case alpha = 0xff */
1585   if (alpha == 0xff)
1586   {
1587      pdrawgfxzoom_transpen(dest, cliprect, gfx, code, color, flipx, flipy, destx, desty, scalex, scaley, priority, pmask, transpen);
1588      return;
27451589   }
2746})
2747#else
2748DECLARE_SWAP_RAW_PRI(blockmove_8toN_pen_table,(COMMON_ARGS, COLOR_ARG, int transcolor),
2749{
2750   int eax = (pdrawgfx_shadow_lowpri) ? 0 : 0x80;
27511590
2752   ADJUST_8
1591   assert(dest != NULL);
1592   assert(dest->bpp == 16 || dest->bpp == 32);
1593   assert(gfx != NULL);
27531594
2754   (void)palette_shadow_table;
1595   /* get final code and color, and grab lookup tables */
1596   code %= gfx->total_elements;
1597   color %= gfx->total_colors;
1598   paldata = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * color];
27551599
2756   if (flipx)
2757   {
2758      DATA_TYPE *end;
1600   /* early out if completely transparent */
1601   if (gfx->pen_usage != NULL && !gfx->dirty[code] && (gfx->pen_usage[code] & ~(1 << transpen)) == 0)
1602      return;
27591603
2760      while (dstheight)
2761      {
2762         end = dstdata - dstwidth*HMODULO;
2763         while (dstdata > end)
2764         {
2765            int col;
1604   /* high bit of the mask is implicitly on */
1605   pmask |= 1 << 31;
27661606
2767            col = *(srcdata++);
2768            if (col != transcolor)
2769            {
2770               switch(gfx_drawmode_table[col])
2771               {
2772               case DRAWMODE_SOURCE:
2773                  SETPIXELCOLOR(0,LOOKUP(col))
2774                  break;
2775               case DRAWMODE_SHADOW:
2776                  afterdrawmask = eax;
2777                  SETPIXELCOLOR(0,palette_shadow_table[*dstdata])
2778                  afterdrawmask = 31;
2779                  break;
2780               }
2781            }
2782            INCREMENT_DST(-HMODULO)
2783         }
2784
2785         srcdata += srcmodulo;
2786         INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO)
2787         dstheight--;
2788      }
2789   }
1607   /* render based on dest bitmap depth */
1608   if (dest->bpp == 16)
1609      DRAWGFXZOOM_CORE(UINT16, PIXEL_OP_REMAP_TRANSPEN_ALPHA16_PRIORITY, UINT8);
27901610   else
2791   {
2792      DATA_TYPE *end;
1611      DRAWGFXZOOM_CORE(UINT32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY, UINT8);
1612}
27931613
2794      while (dstheight)
2795      {
2796         end = dstdata + dstwidth*HMODULO;
2797         while (dstdata < end)
2798         {
2799            int col;
28001614
2801            col = *(srcdata++);
2802            if (col != transcolor)
2803            {
2804               switch(gfx_drawmode_table[col])
2805               {
2806               case DRAWMODE_SOURCE:
2807                  SETPIXELCOLOR(0,LOOKUP(col))
2808                  break;
2809               case DRAWMODE_SHADOW:
2810                  afterdrawmask = eax;
2811                  SETPIXELCOLOR(0,palette_shadow_table[*dstdata])
2812                  afterdrawmask = 31;
2813                  break;
2814               }
2815            }
2816            INCREMENT_DST(HMODULO)
2817         }
28181615
2819         srcdata += srcmodulo;
2820         INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO)
2821         dstheight--;
2822      }
2823   }
2824})
2825#endif
2826#endif
1616/***************************************************************************
1617    DRAW_SCANLINE IMPLEMENTATIONS
1618***************************************************************************/
28271619
2828#if (RAW == 0)
2829DECLARE_SWAP_RAW_PRI(blockmove_8toN_alpha,(COMMON_ARGS, COLOR_ARG, int transpen),
1620/*-------------------------------------------------
1621    draw_scanline8 - copy pixels from an 8bpp
1622    buffer to a single scanline of a bitmap
1623-------------------------------------------------*/
1624
1625void draw_scanline8(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT8 *srcptr, const pen_t *paldata)
28301626{
2831   ADJUST_8
1627   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
28321628
2833   (void)palette_shadow_table;
1629   assert(bitmap != NULL);
1630   assert(bitmap->bpp == 16 || bitmap->bpp == 32);
28341631
2835   if (flipx)
1632   /* palette lookup case */
1633   if (paldata != NULL)
28361634   {
2837      DATA_TYPE *end;
2838      int trans4;
2839      UINT32 *sd4;
1635      /* 16bpp case */
1636      if (bitmap->bpp == 16)
1637         DRAWSCANLINE_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
1638      else
1639         DRAWSCANLINE_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
1640   }
28401641
2841      trans4 = transpen * 0x01010101;
1642   /* raw copy case */
1643   else
1644   {
1645      /* 16bpp case */
1646      if (bitmap->bpp == 16)
1647         DRAWSCANLINE_CORE(UINT16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
1648      else
1649         DRAWSCANLINE_CORE(UINT32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
1650   }
1651}
28421652
2843      while (dstheight)
2844      {
2845         end = dstdata - dstwidth*HMODULO;
2846         while (((FPTR)srcdata & 3) && dstdata > end)   /* longword align */
2847         {
2848            int col;
28491653
2850            col = *(srcdata++);
2851            if (col != transpen) SETPIXELCOLOR(0,alpha_blend(*dstdata, LOOKUP(col)));
2852            INCREMENT_DST(-HMODULO);
2853         }
2854         sd4 = (UINT32 *)srcdata;
2855         while (dstdata >= end + 4*HMODULO)
2856         {
2857            UINT32 col4;
1654/*-------------------------------------------------
1655    draw_scanline16 - copy pixels from a 16bpp
1656    buffer to a single scanline of a bitmap
1657-------------------------------------------------*/
28581658
2859            INCREMENT_DST(-4*HMODULO);
2860            if ((col4 = *(sd4++)) != trans4)
2861            {
2862               UINT32 xod4;
1659void draw_scanline16(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT16 *srcptr, const pen_t *paldata)
1660{
1661   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
28631662
2864               xod4 = col4 ^ trans4;
2865               if (xod4 & (0xff<<SHIFT0)) SETPIXELCOLOR(4*HMODULO,alpha_blend(dstdata[4*HMODULO], LOOKUP((col4>>SHIFT0) & 0xff)));
2866               if (xod4 & (0xff<<SHIFT1)) SETPIXELCOLOR(3*HMODULO,alpha_blend(dstdata[3*HMODULO], LOOKUP((col4>>SHIFT1) & 0xff)));
2867               if (xod4 & (0xff<<SHIFT2)) SETPIXELCOLOR(2*HMODULO,alpha_blend(dstdata[2*HMODULO], LOOKUP((col4>>SHIFT2) & 0xff)));
2868               if (xod4 & (0xff<<SHIFT3)) SETPIXELCOLOR(1*HMODULO,alpha_blend(dstdata[1*HMODULO], LOOKUP((col4>>SHIFT3) & 0xff)));
2869            }
2870         }
2871         srcdata = (UINT8 *)sd4;
2872         while (dstdata > end)
2873         {
2874            int col;
1663   assert(bitmap != NULL);
1664   assert(bitmap->bpp == 16 || bitmap->bpp == 32);
28751665
2876            col = *(srcdata++);
2877            if (col != transpen) SETPIXELCOLOR(0,alpha_blend(*dstdata, LOOKUP(col)));
2878            INCREMENT_DST(-HMODULO);
2879         }
2880
2881         srcdata += srcmodulo;
2882         INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO);
2883         dstheight--;
2884      }
1666   /* palette lookup case */
1667   if (paldata != NULL)
1668   {
1669      /* 16bpp case */
1670      if (bitmap->bpp == 16)
1671         DRAWSCANLINE_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
1672      else
1673         DRAWSCANLINE_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
28851674   }
1675
1676   /* raw copy case */
28861677   else
28871678   {
2888      DATA_TYPE *end;
2889      int trans4;
2890      UINT32 *sd4;
1679      /* 16bpp case */
1680      if (bitmap->bpp == 16)
1681         DRAWSCANLINE_CORE(UINT16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
1682      else
1683         DRAWSCANLINE_CORE(UINT32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
1684   }
1685}
28911686
2892      trans4 = transpen * 0x01010101;
28931687
2894      while (dstheight)
2895      {
2896         end = dstdata + dstwidth*HMODULO;
2897         while (((FPTR)srcdata & 3) && dstdata < end)   /* longword align */
2898         {
2899            int col;
1688/*-------------------------------------------------
1689    draw_scanline32 - copy pixels from a 32bpp
1690    buffer to a single scanline of a bitmap
1691-------------------------------------------------*/
29001692
2901            col = *(srcdata++);
2902            if (col != transpen) SETPIXELCOLOR(0,alpha_blend(*dstdata, LOOKUP(col)));
2903            INCREMENT_DST(HMODULO);
2904         }
2905         sd4 = (UINT32 *)srcdata;
2906         while (dstdata <= end - 4*HMODULO)
2907         {
2908            UINT32 col4;
2909
2910            if ((col4 = *(sd4++)) != trans4)
2911            {
2912               UINT32 xod4;
2913
2914               xod4 = col4 ^ trans4;
2915               if (xod4 & (0xff<<SHIFT0)) SETPIXELCOLOR(0*HMODULO,alpha_blend(dstdata[0*HMODULO], LOOKUP((col4>>SHIFT0) & 0xff)));
2916               if (xod4 & (0xff<<SHIFT1)) SETPIXELCOLOR(1*HMODULO,alpha_blend(dstdata[1*HMODULO], LOOKUP((col4>>SHIFT1) & 0xff)));
2917               if (xod4 & (0xff<<SHIFT2)) SETPIXELCOLOR(2*HMODULO,alpha_blend(dstdata[2*HMODULO], LOOKUP((col4>>SHIFT2) & 0xff)));
2918               if (xod4 & (0xff<<SHIFT3)) SETPIXELCOLOR(3*HMODULO,alpha_blend(dstdata[3*HMODULO], LOOKUP((col4>>SHIFT3) & 0xff)));
2919            }
2920            INCREMENT_DST(4*HMODULO);
2921         }
2922         srcdata = (UINT8 *)sd4;
2923         while (dstdata < end)
2924         {
2925            int col;
2926
2927            col = *(srcdata++);
2928            if (col != transpen) SETPIXELCOLOR(0,alpha_blend(*dstdata, LOOKUP(col)));
2929            INCREMENT_DST(HMODULO);
2930         }
2931
2932         srcdata += srcmodulo;
2933         INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO);
2934         dstheight--;
2935      }
2936   }
2937})
2938
2939/* pjp 02/06/02 */
2940DECLARE_SWAP_RAW_PRI(blockmove_8toN_alpharange,(COMMON_ARGS, COLOR_ARG, int transpen),
1693void draw_scanline32(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr, const pen_t *paldata)
29411694{
2942   ADJUST_8
1695   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
29431696
2944   (void)palette_shadow_table;
1697   assert(bitmap != NULL);
1698   assert(bitmap->bpp == 16 || bitmap->bpp == 32);
29451699
2946   if (flipx)
1700   /* palette lookup case */
1701   if (paldata != NULL)
29471702   {
2948      DATA_TYPE *end;
2949
2950      while (dstheight)
2951      {
2952         end = dstdata - dstwidth*HMODULO;
2953         while (dstdata > end) /* Note that I'm missing the optimisations present in the other alpha functions */
2954         {
2955            int col;
2956
2957            col = *(srcdata++);
2958            if (col != transpen)
2959            {
2960               if (gfx_alpharange_table[col] == 0xff)
2961                  SETPIXELCOLOR(0,LOOKUP(col))
2962               else
2963                  SETPIXELCOLOR(0,alpha_blend_r(*dstdata,LOOKUP(col),gfx_alpharange_table[col]))
2964            }
2965            INCREMENT_DST(-HMODULO);
2966         }
2967
2968         srcdata += srcmodulo;
2969         INCREMENT_DST(ydir*VMODULO + dstwidth*HMODULO);
2970         dstheight--;
2971      }
1703      /* 16bpp case */
1704      if (bitmap->bpp == 16)
1705         DRAWSCANLINE_CORE(UINT16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
1706      else
1707         DRAWSCANLINE_CORE(UINT32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY);
29721708   }
1709
1710   /* raw copy case */
29731711   else
29741712   {
2975      DATA_TYPE *end;
1713      /* 16bpp case */
1714      if (bitmap->bpp == 16)
1715         DRAWSCANLINE_CORE(UINT16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
1716      else
1717         DRAWSCANLINE_CORE(UINT32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
1718   }
1719}
29761720
2977      while (dstheight)
2978      {
2979         end = dstdata + dstwidth*HMODULO;
2980         while (dstdata < end)
2981         {
2982            int col;
29831721
2984            col = *(srcdata++);
2985            if (col != transpen)
2986            {
2987               if (gfx_alpharange_table[col] == 0xff)
2988                  SETPIXELCOLOR(0,LOOKUP(col))
2989               else
2990                  SETPIXELCOLOR(0,alpha_blend_r(*dstdata,LOOKUP(col),gfx_alpharange_table[col]))
2991            }
2992            INCREMENT_DST(HMODULO);
2993         }
29941722
2995         srcdata += srcmodulo;
2996         INCREMENT_DST(ydir*VMODULO - dstwidth*HMODULO);
2997         dstheight--;
2998      }
2999   }
3000})
3001#endif
1723/***************************************************************************
1724    EXTRACT_SCANLINE IMPLEMENTATIONS
1725***************************************************************************/
30021726
3003DECLARE(blockmove_NtoN_opaque_noremap,(
3004      const DATA_TYPE *srcdata,int srcwidth,int srcheight,int srcmodulo,
3005      DATA_TYPE *dstdata,int dstmodulo),
3006{
3007   while (srcheight)
3008   {
3009      memcpy(dstdata,srcdata,srcwidth * sizeof(DATA_TYPE));
3010      srcdata += srcmodulo;
3011      dstdata += dstmodulo;
3012      srcheight--;
3013   }
3014})
1727/*-------------------------------------------------
1728    extract_scanline8 - copy pixels from a single
1729    scanline of a bitmap to an 8bpp buffer
1730-------------------------------------------------*/
30151731
3016DECLARE(blockmove_NtoN_opaque_noremap_flipx,(
3017      const DATA_TYPE *srcdata,int srcwidth,int srcheight,int srcmodulo,
3018      DATA_TYPE *dstdata,int dstmodulo),
1732void extract_scanline8(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT8 *destptr)
30191733{
3020   DATA_TYPE *end;
1734   assert(bitmap != NULL);
1735   assert(bitmap->bpp == 16 || bitmap->bpp == 32);
30211736
3022   srcmodulo += srcwidth;
3023   dstmodulo -= srcwidth;
1737   /* 16bpp case */
1738   if (bitmap->bpp == 16)
1739      EXTRACTSCANLINE_CORE(UINT16);
1740   else
1741      EXTRACTSCANLINE_CORE(UINT32);
1742}
30241743
3025   while (srcheight)
3026   {
3027      end = dstdata + srcwidth;
3028      while (dstdata <= end - 8)
3029      {
3030         srcdata -= 8;
3031         dstdata[0] = srcdata[8];
3032         dstdata[1] = srcdata[7];
3033         dstdata[2] = srcdata[6];
3034         dstdata[3] = srcdata[5];
3035         dstdata[4] = srcdata[4];
3036         dstdata[5] = srcdata[3];
3037         dstdata[6] = srcdata[2];
3038         dstdata[7] = srcdata[1];
3039         dstdata += 8;
3040      }
3041      while (dstdata < end)
3042         *(dstdata++) = *(srcdata--);
30431744
3044      srcdata += srcmodulo;
3045      dstdata += dstmodulo;
3046      srcheight--;
3047   }
3048})
1745/*-------------------------------------------------
1746    extract_scanline16 - copy pixels from a single
1747    scanline of a bitmap to a 16bpp buffer
1748-------------------------------------------------*/
30491749
3050
3051DECLARE(drawgfx_core,(
3052      bitmap_t *dest,const gfx_element *gfx,
3053      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
3054      const rectangle *clip,int transparency,int transparent_color,
3055      bitmap_t *pri_buffer,UINT32 pri_mask),
1750void extract_scanline16(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT16 *destptr)
30561751{
3057   int ox;
3058   int oy;
3059   int ex;
3060   int ey;
1752   assert(bitmap != NULL);
1753   assert(bitmap->bpp == 16 || bitmap->bpp == 32);
30611754
3062   /* check bounds */
3063   ox = sx;
3064   oy = sy;
1755   /* 16bpp case */
1756   if (bitmap->bpp == 16)
1757      EXTRACTSCANLINE_CORE(UINT16);
1758   else
1759      EXTRACTSCANLINE_CORE(UINT32);
1760}
30651761
3066   ex = sx + gfx->width-1;
3067   if (sx < 0) sx = 0;
3068   if (clip && sx < clip->min_x) sx = clip->min_x;
3069   if (ex >= dest->width) ex = dest->width-1;
3070   if (clip && ex > clip->max_x) ex = clip->max_x;
3071   if (sx > ex) return;
30721762
3073   ey = sy + gfx->height-1;
3074   if (sy < 0) sy = 0;
3075   if (clip && sy < clip->min_y) sy = clip->min_y;
3076   if (ey >= dest->height) ey = dest->height-1;
3077   if (clip && ey > clip->max_y) ey = clip->max_y;
3078   if (sy > ey) return;
1763/*-------------------------------------------------
1764    extract_scanline32 - copy pixels from a single
1765    scanline of a bitmap to a 32bpp buffer
1766-------------------------------------------------*/
30791767
3080   {
3081      pen_t *st = gfx->machine->shadow_table;
3082      UINT8 *sd = gfx->gfxdata + code * gfx->char_modulo;      /* source data */
3083      int sw = gfx->width;                           /* source width */
3084      int sh = gfx->height;                           /* source height */
3085      int sm = gfx->line_modulo;                        /* source modulo */
3086      int ls = sx-ox;                                 /* left skip */
3087      int ts = sy-oy;                                 /* top skip */
3088      DATA_TYPE *dd = BITMAP_ADDR(dest, DATA_TYPE, sy, sx);   /* dest data */
3089      int dw = ex-sx+1;                              /* dest width */
3090      int dh = ey-sy+1;                              /* dest height */
3091      int dm = dest->rowpixels;                        /* dest modulo */
3092      int colorbase = gfx->color_base + gfx->color_granularity * color;
3093      const pen_t *paldata = &gfx->machine->pens[colorbase];
3094      UINT8 *pribuf = (pri_buffer) ? BITMAP_ADDR8(pri_buffer, sy, sx) : NULL;
1768void extract_scanline32(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT32 *destptr)
1769{
1770   assert(bitmap != NULL);
1771   assert(bitmap->bpp == 16 || bitmap->bpp == 32);
30951772
3096      switch (transparency)
3097      {
3098         case TRANSPARENCY_NONE:
3099            if (gfx->flags & GFX_ELEMENT_PACKED)
3100            {
3101               if (pribuf)
3102                  BLOCKMOVEPRI(4toN_opaque,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask));
3103               else
3104                  BLOCKMOVELU(4toN_opaque,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata));
3105            }
3106            else
3107            {
3108               if (pribuf)
3109                  BLOCKMOVEPRI(8toN_opaque,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask));
3110               else
3111                  BLOCKMOVELU(8toN_opaque,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata));
3112            }
3113            break;
1773   /* 16bpp case */
1774   if (bitmap->bpp == 16)
1775      EXTRACTSCANLINE_CORE(UINT16);
1776   else
1777      EXTRACTSCANLINE_CORE(UINT32);
1778}
31141779
3115         case TRANSPARENCY_PEN:
3116            if (gfx->flags & GFX_ELEMENT_PACKED)
3117            {
3118               if (pribuf)
3119                  BLOCKMOVEPRI(4toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
3120               else
3121                  BLOCKMOVELU(4toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
3122            }
3123            else
3124            {
3125               if (pribuf)
3126                  BLOCKMOVEPRI(8toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
3127               else
3128                  BLOCKMOVELU(8toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
3129            }
3130            break;
31311780
3132         case TRANSPARENCY_PEN_RAW:
3133            if (gfx->flags & GFX_ELEMENT_PACKED)
3134            {
3135               if (pribuf)
3136                  BLOCKMOVERAWPRI(4toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,color,pribuf,pri_mask,transparent_color));
3137               else
3138                  BLOCKMOVERAW(4toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,color,transparent_color));
3139            }
3140            else
3141            {
3142               if (pribuf)
3143                  BLOCKMOVERAWPRI(8toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,color,pribuf,pri_mask,transparent_color));
3144               else
3145                  BLOCKMOVERAW(8toN_transpen,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,color,transparent_color));
3146            }
3147            break;
31481781
3149         case TRANSPARENCY_PENS:
3150            if (pribuf)
3151               BLOCKMOVEPRI(8toN_transmask,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
3152            else
3153               BLOCKMOVELU(8toN_transmask,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
3154            break;
1782/***************************************************************************
1783    COPYBITMAP IMPLEMENTATIONS
1784***************************************************************************/
31551785
3156         case TRANSPARENCY_PEN_TABLE:
3157            if (pribuf)
3158               BLOCKMOVEPRI(8toN_pen_table,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
3159            else
3160               BLOCKMOVELU(8toN_pen_table,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
3161            break;
1786/*-------------------------------------------------
1787    copybitmap - copy from one bitmap to another,
1788    copying all unclipped pixels
1789-------------------------------------------------*/
31621790
3163         case TRANSPARENCY_ALPHA:
3164            if (pribuf)
3165               BLOCKMOVEPRI(8toN_alpha,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
3166            else
3167               BLOCKMOVELU(8toN_alpha,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
3168            break;
1791void copybitmap(bitmap_t *dest, bitmap_t *src, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect)
1792{
1793   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
31691794
3170         case TRANSPARENCY_ALPHARANGE:
3171            if (pribuf)
3172               BLOCKMOVEPRI(8toN_alpharange,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,pribuf,pri_mask,transparent_color));
3173            else
3174               BLOCKMOVELU(8toN_alpharange,(st,sd,sw,sh,sm,ls,ts,flipx,flipy,dd,dw,dh,dm,colorbase,paldata,transparent_color));
3175            break;
1795   assert(dest != NULL);
1796   assert(src != NULL);
1797   assert(dest->bpp == 8 || dest->bpp == 16 || dest->bpp == 32);
1798   assert(src->bpp == dest->bpp);
31761799
3177         default:
3178            if (pribuf)
3179               popmessage("pdrawgfx pen mode not supported");
3180            else
3181               popmessage("drawgfx pen mode not supported");
3182            break;
3183      }
3184   }
3185})
1800   if (dest->bpp == 8)
1801      COPYBITMAP_CORE(UINT8, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
1802   else if (dest->bpp == 16)
1803      COPYBITMAP_CORE(UINT16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
1804   else
1805      COPYBITMAP_CORE(UINT32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
1806}
31861807
3187DECLARE(copybitmap_core,(
3188      bitmap_t *dest,bitmap_t *src,
3189      int flipx,int flipy,int sx,int sy,
3190      const rectangle *clip,int transparency,int transparent_color),
3191{
3192   int ox;
3193   int oy;
3194   int ex;
3195   int ey;
31961808
3197   /* check bounds */
3198   ox = sx;
3199   oy = sy;
1809/*-------------------------------------------------
1810    copybitmap_trans - copy from one bitmap to
1811    another, copying all unclipped pixels except
1812    those that match transpen
1813-------------------------------------------------*/
32001814
3201   ex = sx + src->width-1;
3202   if (sx < 0) sx = 0;
3203   if (clip && sx < clip->min_x) sx = clip->min_x;
3204   if (ex >= dest->width) ex = dest->width-1;
3205   if (clip && ex > clip->max_x) ex = clip->max_x;
3206   if (sx > ex) return;
1815void copybitmap_trans(bitmap_t *dest, bitmap_t *src, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, UINT32 transpen)
1816{
1817   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
32071818
3208   ey = sy + src->height-1;
3209   if (sy < 0) sy = 0;
3210   if (clip && sy < clip->min_y) sy = clip->min_y;
3211   if (ey >= dest->height) ey = dest->height-1;
3212   if (clip && ey > clip->max_y) ey = clip->max_y;
3213   if (sy > ey) return;
1819   assert(dest != NULL);
1820   assert(src != NULL);
1821   assert(dest->bpp == 8 || dest->bpp == 16 || dest->bpp == 32);
1822   assert(src->bpp == dest->bpp);
32141823
1824   if (dest->bpp == 8)
32151825   {
3216      DATA_TYPE *sd = (DATA_TYPE *)src->base;                           /* source data */
3217      int sw = ex-sx+1;                                          /* source width */
3218      int sh = ey-sy+1;                                          /* source height */
3219      int sm = src->rowpixels;                                    /* source modulo */
3220      DATA_TYPE *dd = BITMAP_ADDR(dest, DATA_TYPE, sy, sx);               /* dest data */
3221      int dm = dest->rowpixels;                                    /* dest modulo */
3222
3223      if (flipx)
3224         sd += src->width -1 -(sx-ox);
1826      if (transpen > 0xff)
1827         copybitmap(dest, src, flipx, flipy, destx, desty, cliprect);
32251828      else
3226         sd += (sx-ox);
3227
3228      if (flipy)
3229      {
3230         sd += sm * (src->height -1 -(sy-oy));
3231         sm = -sm;
3232      }
3233      else
3234         sd += sm * (sy-oy);
3235
3236      switch (transparency)
3237      {
3238         case TRANSPARENCY_NONE:
3239            BLOCKMOVE(NtoN_opaque_noremap,flipx,(sd,sw,sh,sm,dd,dm));
3240            break;
3241
3242         case TRANSPARENCY_PEN:
3243            BLOCKMOVE(NtoN_transpen_noremap,flipx,(sd,sw,sh,sm,dd,dm,transparent_color));
3244            break;
3245
3246         default:
3247            popmessage("copybitmap pen mode not supported");
3248            break;
3249      }
1829         COPYBITMAP_CORE(UINT8, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
32501830   }
3251})
3252
3253DECLARE(copyrozbitmap_core,(bitmap_t *bitmap,bitmap_t *srcbitmap,
3254      UINT32 startx,UINT32 starty,int incxx,int incxy,int incyx,int incyy,int wraparound,
3255      const rectangle *clip,int transparency,int transparent_color,UINT32 priority),
3256{
3257   UINT32 cx;
3258   UINT32 cy;
3259   int x;
3260   int sx;
3261   int sy;
3262   int ex;
3263   int ey;
3264   const int xmask = srcbitmap->width-1;
3265   const int ymask = srcbitmap->height-1;
3266   const int widthshifted = srcbitmap->width << 16;
3267   const int heightshifted = srcbitmap->height << 16;
3268   DATA_TYPE *dest;
3269
3270   if (clip)
1831   else if (dest->bpp == 16)
32711832   {
3272      startx += clip->min_x * incxx + clip->min_y * incyx;
3273      starty += clip->min_x * incxy + clip->min_y * incyy;
3274
3275      sx = clip->min_x;
3276      sy = clip->min_y;
3277      ex = clip->max_x;
3278      ey = clip->max_y;
1833      if (transpen > 0xffff)
1834         copybitmap(dest, src, flipx, flipy, destx, desty, cliprect);
1835      else
1836         COPYBITMAP_CORE(UINT16, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
32791837   }
32801838   else
32811839   {
3282      sx = 0;
3283      sy = 0;
3284      ex = bitmap->width-1;
3285      ey = bitmap->height-1;
1840      if (transpen == 0xffffffff)
1841         copybitmap(dest, src, flipx, flipy, destx, desty, cliprect);
1842      else
1843         COPYBITMAP_CORE(UINT32, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
32861844   }
1845}
32871846
32881847
3289   if (incxy == 0 && incyx == 0 && !wraparound)
3290   {
3291      /* optimized loop for the not rotated case */
32921848
3293      if (incxx == 0x10000)
3294      {
3295         /* optimized loop for the not zoomed case */
1849/***************************************************************************
1850    COPYSCROLLBITMAP IMPLEMENTATIONS
1851***************************************************************************/
32961852
3297         /* startx is unsigned */
3298         startx = ((INT32)startx) >> 16;
1853/*-------------------------------------------------
1854    copyscrollbitmap - copy from one bitmap to
1855    another, copying all unclipped pixels, and
1856    applying scrolling to one or more rows/colums
1857-------------------------------------------------*/
32991858
3300         if (startx >= srcbitmap->width)
3301         {
3302            sx += -startx;
3303            startx = 0;
3304         }
1859void copyscrollbitmap(bitmap_t *dest, bitmap_t *src, UINT32 numrows, const INT32 *rowscroll, UINT32 numcols, const INT32 *colscroll, const rectangle *cliprect)
1860{
1861   /* just call through to the transparent case as the underlying copybitmap will
1862       optimize for pen == 0xffffffff */
1863   copyscrollbitmap_trans(dest, src, numrows, rowscroll, numcols, colscroll, cliprect, 0xffffffff);
1864}
33051865
3306         if (sx <= ex)
3307         {
3308            while (sy <= ey)
3309            {
3310               if (starty < heightshifted)
3311               {
3312                  x = sx;
3313                  cx = startx;
3314                  cy = starty >> 16;
3315                  dest = BITMAP_ADDR(bitmap, DATA_TYPE, sy, sx);
3316                  if (priority)
3317                  {
3318                     UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, sx);
3319                     DATA_TYPE *src = BITMAP_ADDR(srcbitmap, DATA_TYPE, cy, 0);
33201866
3321                     while (x <= ex && cx < srcbitmap->width)
3322                     {
3323                        int c = src[cx];
1867/*-------------------------------------------------
1868    copyscrollbitmap_trans - copy from one bitmap
1869    to another, copying all unclipped pixels
1870    except those that match transpen, and applying
1871    scrolling to one or more rows/colums
1872-------------------------------------------------*/
33241873
3325                        if (c != transparent_color)
3326                        {
3327                           *dest = c;
3328                           *pri |= priority;
3329                        }
1874void copyscrollbitmap_trans(bitmap_t *dest, bitmap_t *src, UINT32 numrows, const INT32 *rowscroll, UINT32 numcols, const INT32 *colscroll, const rectangle *cliprect, UINT32 transpen)
1875{
1876   /* no rowscroll and no colscroll means no scroll */
1877   if (numrows == 0 && numcols == 0)
1878   {
1879      copybitmap_trans(dest, src, 0, 0, 0, 0, cliprect, transpen);
1880      return;
1881   }
33301882
3331                        cx++;
3332                        x++;
3333                        dest++;
3334                        pri++;
3335                     }
3336                  }
3337                  else
3338                  {
3339                     DATA_TYPE *src = BITMAP_ADDR(srcbitmap, DATA_TYPE, cy, 0);
1883   assert(dest != NULL);
1884   assert(src != NULL);
1885   assert(dest->bpp == 8 || dest->bpp == 16 || dest->bpp == 32);
1886   assert(dest->bpp == src->bpp);
1887   assert(numrows != 0 || rowscroll == NULL);
1888   assert(numrows == 0 || rowscroll != NULL);
1889   assert(numcols != 0 || colscroll == NULL);
1890   assert(numcols == 0 || colscroll != NULL);
33401891
3341                     while (x <= ex && cx < srcbitmap->width)
3342                     {
3343                        int c = src[cx];
1892   /* NULL clip means use the full bitmap */
1893   if (cliprect == NULL)
1894      cliprect = &dest->cliprect;
33441895
3345                        if (c != transparent_color)
3346                           *dest = c;
1896   /* fully scrolling X,Y playfield */
1897   if (numrows <= 1 && numcols <= 1)
1898   {
1899      INT32 xscroll = normalize_xscroll(src, (numrows == 0) ? 0 : rowscroll[0]);
1900      INT32 yscroll = normalize_yscroll(src, (numcols == 0) ? 0 : colscroll[0]);
1901      INT32 sx, sy;
33471902
3348                        cx++;
3349                        x++;
3350                        dest++;
3351                     }
3352                  }
3353               }
3354               starty += incyy;
3355               sy++;
3356            }
3357         }
3358      }
3359      else
3360      {
3361         while (startx >= widthshifted && sx <= ex)
3362         {
3363            startx += incxx;
3364            sx++;
3365         }
3366
3367         if (sx <= ex)
3368         {
3369            while (sy <= ey)
3370            {
3371               if (starty < heightshifted)
3372               {
3373                  x = sx;
3374                  cx = startx;
3375                  cy = starty >> 16;
3376                  dest = BITMAP_ADDR(bitmap, DATA_TYPE, sy, sx);
3377                  if (priority)
3378                  {
3379                     UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, sx);
3380                     DATA_TYPE *src = BITMAP_ADDR(srcbitmap, DATA_TYPE, cy, 0);
3381
3382                     while (x <= ex && cx < widthshifted)
3383                     {
3384                        int c = src[cx >> 16];
3385
3386                        if (c != transparent_color)
3387                        {
3388                           *dest = c;
3389                           *pri |= priority;
3390                        }
3391
3392                        cx += incxx;
3393                        x++;
3394                        dest++;
3395                        pri++;
3396                     }
3397                  }
3398                  else
3399                  {
3400                     DATA_TYPE *src = BITMAP_ADDR(srcbitmap, DATA_TYPE, cy, 0);
3401
3402                     while (x <= ex && cx < widthshifted)
3403                     {
3404                        int c = src[cx >> 16];
3405
3406                        if (c != transparent_color)
3407                           *dest = c;
3408
3409                        cx += incxx;
3410                        x++;
3411                        dest++;
3412                     }
3413                  }
3414               }
3415               starty += incyy;
3416               sy++;
3417            }
3418         }
3419      }
1903      /* iterate over all portions of the scroll that overlap the destination */
1904      for (sx = xscroll - src->width; sx < dest->width; sx += src->width)
1905         for (sy = yscroll - src->height; sy < dest->height; sy += src->height)
1906            copybitmap_trans(dest, src, 0, 0, sx, sy, cliprect, transpen);
34201907   }
3421   else
1908
1909   /* scrolling columns plus horizontal scroll */
1910   else if (numrows <= 1)
34221911   {
3423      if (wraparound)
3424      {
3425         /* plot with wraparound */
3426         while (sy <= ey)
3427         {
3428            x = sx;
3429            cx = startx;
3430            cy = starty;
3431            dest = BITMAP_ADDR(bitmap, DATA_TYPE, sy, sx);
3432            if (priority)
3433            {
3434               UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, sx);
1912      INT32 xscroll = normalize_xscroll(src, (numrows == 0) ? 0 : rowscroll[0]);
1913      rectangle subclip = *cliprect;
1914      int col, colwidth, groupcols;
34351915
3436               while (x <= ex)
3437               {
3438                  int c = *BITMAP_ADDR(srcbitmap, DATA_TYPE, (cy >> 16) & ymask, (cx >> 16) & xmask);
1916      /* determine width of each column */
1917      colwidth = src->width / numcols;
1918      assert(src->width % colwidth == 0);
34391919
3440                  if (c != transparent_color)
3441                  {
3442                     *dest = c;
3443                     *pri |= priority;
3444                  }
3445
3446                  cx += incxx;
3447                  cy += incxy;
3448                  x++;
3449                  dest++;
3450                  pri++;
3451               }
3452            }
3453            else
3454            {
3455               while (x <= ex)
3456               {
3457                  int c = *BITMAP_ADDR(srcbitmap, DATA_TYPE, (cy >> 16) & ymask, (cx >> 16) & xmask);
3458
3459                  if (c != transparent_color)
3460                     *dest = c;
3461
3462                  cx += incxx;
3463                  cy += incxy;
3464                  x++;
3465                  dest++;
3466               }
3467            }
3468            startx += incyx;
3469            starty += incyy;
3470            sy++;
3471         }
3472      }
3473      else
1920      /* iterate over each column */
1921      for (col = 0; col < numcols; col += groupcols)
34741922      {
3475         while (sy <= ey)
3476         {
3477            x = sx;
3478            cx = startx;
3479            cy = starty;
3480            if (priority)
3481            {
3482               UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, sx);
1923         INT32 yscroll = colscroll[col];
1924         INT32 sx, sy;
34831925
3484               while (x <= ex)
3485               {
3486                  if (cx < widthshifted && cy < heightshifted)
3487                  {
3488                     int c = *BITMAP_ADDR(srcbitmap, DATA_TYPE, cy >> 16, cx >> 16);
1926         /* count consecutive columns scrolled by the same amount */
1927         for (groupcols = 1; col + groupcols < numcols; groupcols++)
1928             if (colscroll[col + groupcols] != yscroll)
1929                break;
34891930
3490                     if (c != transparent_color)
3491                     {
3492                        dest = BITMAP_ADDR(bitmap, DATA_TYPE, sy, x);
3493                        *dest = c;
3494                        *pri |= priority;
3495                     }
3496                  }
1931         /* compute the cliprect for this group */
1932         subclip.min_x = col * colwidth + xscroll;
1933         subclip.max_x = (col + groupcols) * colwidth - 1 + xscroll;
1934         sect_rect(&subclip, cliprect);
34971935
3498                  cx += incxx;
3499                  cy += incxy;
3500                  x++;
3501                  pri++;
3502               }
3503            }
3504            else
3505            {
3506               while (x <= ex)
3507               {
3508                  if (cx < widthshifted && cy < heightshifted)
3509                  {
3510                     int c = *BITMAP_ADDR(srcbitmap, DATA_TYPE, cy >> 16, cx >> 16);
3511
3512                     if (c != transparent_color)
3513                     {
3514                        dest = BITMAP_ADDR(bitmap, DATA_TYPE, sy, x);
3515                        *dest = c;
3516                     }
3517                  }
3518
3519                  cx += incxx;
3520                  cy += incxy;
3521                  x++;
3522               }
3523            }
3524            startx += incyx;
3525            starty += incyy;
3526            sy++;
3527         }
1936         /* iterate over all portions of the scroll that overlap the destination */
1937         for (sy = normalize_yscroll(src, yscroll) - src->height; sy < dest->height; sy += src->height)
1938            for (sx = xscroll - src->width; sx < dest->width; sx += src->width)
1939               copybitmap_trans(dest, src, 0, 0, sx, sy, &subclip, transpen);
35281940      }
35291941   }
3530})
35311942
3532#endif /* (DEPTH != 8) */
3533
3534DECLAREG(draw_scanline, (
3535      bitmap_t *bitmap,int x,int y,int length,
3536      const DATA_TYPE *src,const pen_t *pens,int transparent_pen),
3537{
3538   assert(bitmap != NULL);
3539   assert((bitmap->bpp == 16) || (bitmap->bpp == 32));
3540   assert(src != NULL);
3541   assert(length > 0);
3542   assert(x >= 0);
3543   assert(y >= 0);
3544
3545   /* 16bpp destination */
3546   if (bitmap->bpp == 16)
1943   /* scrolling rows plus vertical scroll */
1944   else if (numcols <= 1)
35471945   {
3548      UINT16 *dst = BITMAP_ADDR16(bitmap, y, x);
3549      int xadv = 1;
1946      INT32 yscroll = normalize_yscroll(src, (numcols == 0) ? 0 : colscroll[0]);
1947      rectangle subclip = *cliprect;
1948      int row, rowheight, grouprows;
35501949
3551      /* with pen lookups */
3552      if (pens)
3553      {
3554         if (transparent_pen == -1)
3555            while (length--)
3556            {
3557               *dst = pens[*src++];
3558               dst += xadv;
3559            }
3560         else
3561            while (length--)
3562            {
3563               UINT32 spixel = *src++;
3564               if (spixel != transparent_pen)
3565                  *dst = pens[spixel];
3566               dst += xadv;
3567            }
3568      }
1950      /* determine width of each rows */
1951      rowheight = src->height / numrows;
1952      assert(src->height % rowheight == 0);
35691953
3570      /* without pen lookups */
3571      else
1954      /* iterate over each row */
1955      for (row = 0; row < numrows; row += grouprows)
35721956      {
3573         if (transparent_pen == -1)
3574            while (length--)
3575            {
3576               *dst = *src++;
3577               dst += xadv;
3578            }
3579         else
3580            while (length--)
3581            {
3582               UINT32 spixel = *src++;
3583               if (spixel != transparent_pen)
3584                  *dst = spixel;
3585               dst += xadv;
3586            }
3587      }
3588   }
1957         INT32 xscroll = rowscroll[row];
1958         INT32 sx, sy;
35891959
3590   /* 32bpp destination */
3591   else
3592   {
3593      UINT32 *dst = BITMAP_ADDR32(bitmap, y, x);
3594      int xadv = 1;
1960         /* count consecutive rows scrolled by the same amount */
1961         for (grouprows = 1; row + grouprows < numrows; grouprows++)
1962             if (rowscroll[row + grouprows] != xscroll)
1963                break;
35951964
3596      /* with pen lookups */
3597      if (pens)
3598      {
3599         if (transparent_pen == -1)
3600            while (length--)
3601            {
3602               *dst = pens[*src++];
3603               dst += xadv;
3604            }
3605         else
3606            while (length--)
3607            {
3608               UINT32 spixel = *src++;
3609               if (spixel != transparent_pen)
3610                  *dst = pens[spixel];
3611               dst += xadv;
3612            }
3613      }
1965         /* compute the cliprect for this group */
1966         subclip.min_y = row * rowheight + yscroll;
1967         subclip.max_y = (row + grouprows) * rowheight - 1 + yscroll;
1968         sect_rect(&subclip, cliprect);
36141969
3615      /* without pen lookups */
3616      else
3617      {
3618         if (transparent_pen == -1)
3619            while (length--)
3620            {
3621               *dst = *src++;
3622               dst += xadv;
3623            }
3624         else
3625            while (length--)
3626            {
3627               UINT32 spixel = *src++;
3628               if (spixel != transparent_pen)
3629                  *dst = spixel;
3630               dst += xadv;
3631            }
1970         /* iterate over all portions of the scroll that overlap the destination */
1971         for (sx = normalize_xscroll(src, xscroll) - src->width; sx < dest->width; sx += src->width)
1972            for (sy = yscroll - src->height; sy < dest->height; sy += src->height)
1973               copybitmap_trans(dest, src, 0, 0, sx, sy, &subclip, transpen);
36321974      }
36331975   }
3634})
1976}
36351977
3636DECLAREG(pdraw_scanline, (
3637      bitmap_t *bitmap,int x,int y,int length,
3638      const DATA_TYPE *src,const pen_t *pens,int transparent_pen,int pri),
3639{
3640   assert(bitmap != NULL);
3641   assert((bitmap->bpp == 16) || (bitmap->bpp == 32));
3642   assert(length > 0);
3643   assert(x >= 0);
3644   assert(y >= 0);
36451978
3646   /* 16bpp destination */
3647   if (bitmap->bpp == 16)
3648   {
3649      UINT16 *dsti = BITMAP_ADDR16(bitmap, y, x);
3650      UINT8 *dstp = BITMAP_ADDR8(priority_bitmap, y, x);
3651      int xadv = 1;
36521979
3653      /* with pen lookups */
3654      if (pens)
3655      {
3656         if (transparent_pen == -1)
3657            while (length--)
3658            {
3659               *dsti = pens[*src++];
3660               *dstp = pri;
3661               dsti += xadv;
3662               dstp += xadv;
3663            }
3664         else
3665            while (length--)
3666            {
3667               UINT32 spixel = *src++;
3668               if (spixel != transparent_pen)
3669               {
3670                  *dsti = pens[spixel];
3671                  *dstp = pri;
3672               }
3673               dsti += xadv;
3674               dstp += xadv;
3675            }
3676      }
1980/***************************************************************************
1981    COPYROZBITMAP IMPLEMENTATIONS
1982***************************************************************************/
36771983
3678      /* without pen lookups */
3679      else
3680      {
3681         if (transparent_pen == -1)
3682            while (length--)
3683            {
3684               *dsti = *src++;
3685               *dstp = pri;
3686               dsti += xadv;
3687               dstp += xadv;
3688            }
3689         else
3690            while (length--)
3691            {
3692               UINT32 spixel = *src++;
3693               if (spixel != transparent_pen)
3694               {
3695                  *dsti = spixel;
3696                  *dstp = pri;
3697               }
3698               dsti += xadv;
3699               dstp += xadv;
3700            }
3701      }
3702   }
1984/*-------------------------------------------------
1985    copyrozbitmap - copy from one bitmap to another,
1986    with zoom and rotation, copying all unclipped
1987    pixels
1988-------------------------------------------------*/
37031989
3704   /* 32bpp destination */
3705   else
3706   {
3707      UINT32 *dsti = BITMAP_ADDR32(bitmap, y, x);
3708      UINT8 *dstp = BITMAP_ADDR8(priority_bitmap, y, x);
3709      int xadv = 1;
1990void copyrozbitmap(bitmap_t *dest, const rectangle *cliprect, bitmap_t *src, INT32 startx, INT32 starty, INT32 incxx, INT32 incxy, INT32 incyx, INT32 incyy, int wraparound)
1991{
1992   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
37101993
3711      /* with pen lookups */
3712      if (pens)
3713      {
3714         if (transparent_pen == -1)
3715            while (length--)
3716            {
3717               *dsti = pens[*src++];
3718               *dstp = pri;
3719               dsti += xadv;
3720               dstp += xadv;
3721            }
3722         else
3723            while (length--)
3724            {
3725               UINT32 spixel = *src++;
3726               if (spixel != transparent_pen)
3727               {
3728                  *dsti = pens[spixel];
3729                  *dstp = pri;
3730               }
3731               dsti += xadv;
3732               dstp += xadv;
3733            }
3734      }
1994   assert(dest != NULL);
1995   assert(src != NULL);
1996   assert(dest->bpp == 8 || dest->bpp == 16 || dest->bpp == 32);
1997   assert(src->bpp == dest->bpp);
37351998
3736      /* without pen lookups */
3737      else
3738      {
3739         if (transparent_pen == -1)
3740            while (length--)
3741            {
3742               *dsti = *src++;
3743               *dstp = pri;
3744               dsti += xadv;
3745               dstp += xadv;
3746            }
3747         else
3748            while (length--)
3749            {
3750               UINT32 spixel = *src++;
3751               if (spixel != transparent_pen)
3752               {
3753                  *dsti = spixel;
3754                  *dstp = pri;
3755               }
3756               dsti += xadv;
3757               dstp += xadv;
3758            }
3759      }
3760   }
1999   if (dest->bpp == 8)
2000      COPYROZBITMAP_CORE(UINT8, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
2001   else if (dest->bpp == 16)
2002      COPYROZBITMAP_CORE(UINT16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
2003   else
2004      COPYROZBITMAP_CORE(UINT32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY);
37612005}
3762)
37632006
3764DECLAREG(extract_scanline, (
3765      bitmap_t *bitmap,int x,int y,int length,
3766      DATA_TYPE *dst),
3767{
3768   assert(bitmap != NULL);
3769   assert((bitmap->bpp == 16) || (bitmap->bpp == 32));
3770   assert(dst != NULL);
3771   assert(length > 0);
3772   assert(x >= 0);
3773   assert(y >= 0);
37742007
3775   /* 16bpp destination */
3776   if (bitmap->bpp == 16)
3777   {
3778      UINT16 *src = BITMAP_ADDR16(bitmap, y, x);
3779      int xadv = 1;
2008/*-------------------------------------------------
2009    copyrozbitmap_trans - copy from one bitmap to
2010    another, with zoom and rotation, copying all
2011    unclipped pixels whose values do not match
2012    transpen
2013-------------------------------------------------*/
37802014
3781      while (length--)
3782      {
3783         *dst++ = *src;
3784         src += xadv;
3785      }
3786   }
2015void copyrozbitmap_trans(bitmap_t *dest, const rectangle *cliprect, bitmap_t *src, INT32 startx, INT32 starty, INT32 incxx, INT32 incxy, INT32 incyx, INT32 incyy, int wraparound, UINT32 transpen)
2016{
2017   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
37872018
3788   /* 32bpp destination */
3789   else
3790   {
3791      UINT32 *src = BITMAP_ADDR32(bitmap, y, x);
3792      int xadv = 1;
2019   assert(dest != NULL);
2020   assert(src != NULL);
2021   assert(dest->bpp == 8 || dest->bpp == 16 || dest->bpp == 32);
2022   assert(src->bpp == dest->bpp);
37932023
3794      while (length--)
3795      {
3796         *dst++ = *src;
3797         src += xadv;
3798      }
3799   }
3800})
3801
3802#endif /* DECLAREG */
2024   if (dest->bpp == 8)
2025      COPYROZBITMAP_CORE(UINT8, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
2026   else if (dest->bpp == 16)
2027      COPYROZBITMAP_CORE(UINT16, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
2028   else
2029      COPYROZBITMAP_CORE(UINT32, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY);
2030}
src/emu/drawgfx.h
r4135r4136
5050{
5151   TRANSPARENCY_NONE,         /* opaque with remapping */
5252   TRANSPARENCY_PEN,         /* single pen transparency with remapping */
53   TRANSPARENCY_PEN_RAW,      /* single pen transparency with no remapping */
5453   TRANSPARENCY_PENS,         /* multiple pen transparency with remapping */
55   TRANSPARENCY_PEN_TABLE,      /* special pen remapping modes (see DRAWMODE_xxx below) with remapping */
56   TRANSPARENCY_ALPHA,         /* single pen transparency, other pens alpha */
57   TRANSPARENCY_ALPHARANGE,   /* single pen transparency, multiple pens alpha depending on array, see psikyosh.c */
5854
5955   TRANSPARENCY_MODES         /* total number of modes; must be last */
6056};
r4135r4136
9995const gfx_layout name = { width, height, RGN_FRAC(1,1), planes, { GFX_RAW }, { 0 }, { linemod }, charmod };
10096
10197
98
10299/***************************************************************************
103100    TYPE DEFINITIONS
104101***************************************************************************/
r4135r4136
122119/* In mamecore.h: typedef struct _gfx_element gfx_element; */
123120struct _gfx_element
124121{
125   UINT16         width;            /* pixel width of each element */
126   UINT16         height;            /* pixel height of each element */
122   UINT16         width;            /* current pixel width of each element (changeble with source clipping) */
123   UINT16         height;            /* current pixel height of each element (changeble with source clipping) */
124   UINT16         startx;            /* current source clip X offset */
125   UINT16         starty;            /* current source clip Y offset */
126
127   UINT16         origwidth;         /* starting pixel width of each element */
128   UINT16         origheight;         /* staring pixel height of each element */
127129   UINT8         flags;            /* one of the GFX_ELEMENT_* flags above */
128130   UINT32          total_elements;      /* total number of decoded elements */
129131
r4135r4136
137139   UINT8 *         gfxdata;         /* pixel data, 8bpp or 4bpp (if GFX_ELEMENT_PACKED) */
138140   UINT32         line_modulo;      /* bytes between each row of data */
139141   UINT32         char_modulo;      /* bytes between each element */
140   running_machine *   machine;      /* pointer to the owning machine */
142   const UINT8 *   srcdata;         /* pointer to the source data for decoding */
143   UINT8 *         dirty;            /* dirty array for detecting tiles that need decoding */
144   UINT32         dirtyseq;         /* sequence number; incremented each time a tile is dirtied */
145
146   running_machine *machine;         /* pointer to the owning machine */
141147   gfx_layout      layout;            /* copy of the original layout */
142148};
143149
r4135r4136
155161};
156162
157163
158typedef struct _alpha_cache alpha_cache;
159struct _alpha_cache
160{
161   int      alphas;
162   int      alphad;
163};
164164
165
166
167165/***************************************************************************
168    GLOBAL VARIABLES
166    FUNCTION PROTOTYPES
169167***************************************************************************/
170168
171/* drawing mode case TRANSPARENCY_ALPHARANGE */
172extern UINT8 gfx_alpharange_table[256];
173169
174/* drawing mode case TRANSPARENCY_PEN_TABLE */
175extern UINT8 gfx_drawmode_table[256];
170/* ----- graphics elements ----- */
176171
177/* By default, when drawing sprites with pdrawgfx, shadows affect the sprites below them. */
178/* Set this flag to 1 to make shadows only affect the background, leaving sprites at full brightness. */
179extern int pdrawgfx_shadow_lowpri;
172/* allocate a gfx_element structure based on a given layout */
173gfx_element *gfx_element_alloc(running_machine *machine, const gfx_layout *gl, const UINT8 *srcdata, UINT32 total_colors, UINT32 color_base);
180174
175/* update a single code in a gfx_element */
176void gfx_element_decode(const gfx_element *gfx, UINT32 code);
181177
178/* free a gfx_element */
179void gfx_element_free(gfx_element *gfx);
182180
183/***************************************************************************
184    FUNCTION PROTOTYPES
185***************************************************************************/
181/* create a temporary one-off gfx_element */
182void gfx_element_build_temporary(gfx_element *gfx, running_machine *machine, UINT8 *base, UINT32 width, UINT32 height, UINT32 rowbytes, UINT32 color_base, UINT32 color_granularity, UINT32 flags);
186183
187void drawgfx_init(running_machine *machine);
188184
189185
190void decodechar(gfx_element *gfx,int num,const unsigned char *src);
191gfx_element *allocgfx(running_machine *machine, const gfx_layout *gl);
192void decodegfx(gfx_element *gfx, const UINT8 *src, UINT32 first, UINT32 count);
193void freegfx(gfx_element *gfx);
186/* ----- core graphics drawing ----- */
194187
188/* generic drawgfx with legacy interface */
189void drawgfx(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, int transparency, UINT32 transparent_color);
195190
196void drawgfx(bitmap_t *dest,const gfx_element *gfx,
197      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
198      const rectangle *clip,int transparency,int transparent_color);
199void pdrawgfx(bitmap_t *dest,const gfx_element *gfx,
200      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
201      const rectangle *clip,int transparency,int transparent_color,
202      UINT32 priority_mask);
203void mdrawgfx(bitmap_t *dest,const gfx_element *gfx,
204      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
205      const rectangle *clip,int transparency,int transparent_color,
206      UINT32 priority_mask);
191/* specific drawgfx implementations for each transparency type */
192void drawgfx_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty);
193void drawgfx_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 transpen);
194void drawgfx_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 transpen);
195void drawgfx_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 transmask);
196void drawgfx_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const UINT8 *pentable, const pen_t *shadowtable);
197void drawgfx_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 transpen, UINT8 alpha);
207198
208199
209void drawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
210      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
211      const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley);
212void pdrawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
213      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
214      const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley,
215      UINT32 priority_mask);
216void mdrawgfxzoom( bitmap_t *dest_bmp,const gfx_element *gfx,
217      unsigned int code,unsigned int color,int flipx,int flipy,int sx,int sy,
218      const rectangle *clip,int transparency,int transparent_color,int scalex,int scaley,
219      UINT32 priority_mask);
220200
201/* ----- zoomed graphics drawing ----- */
221202
222void draw_scanline8(bitmap_t *bitmap,int x,int y,int length,const UINT8 *src,const pen_t *pens,int transparent_pen);
223void draw_scanline16(bitmap_t *bitmap,int x,int y,int length,const UINT16 *src,const pen_t *pens,int transparent_pen);
224void draw_scanline32(bitmap_t *bitmap,int x,int y,int length,const UINT32 *src,const pen_t *pens,int transparent_pen);
225void pdraw_scanline8(bitmap_t *bitmap,int x,int y,int length,const UINT8 *src,const pen_t *pens,int transparent_pen,int pri);
226void pdraw_scanline16(bitmap_t *bitmap,int x,int y,int length,const UINT16 *src,const pen_t *pens,int transparent_pen,int pri);
227void pdraw_scanline32(bitmap_t *bitmap,int x,int y,int length,const UINT32 *src,const pen_t *pens,int transparent_pen,int pri);
228void extract_scanline8(bitmap_t *bitmap,int x,int y,int length,UINT8 *dst);
229void extract_scanline16(bitmap_t *bitmap,int x,int y,int length,UINT16 *dst);
230void extract_scanline32(bitmap_t *bitmap,int x,int y,int length,UINT32 *dst);
203/* generic drawgfxzoom with legacy interface */
204void drawgfxzoom(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, int transparency, UINT32 transparent_color, UINT32 scalex, UINT32 scaley);
231205
206/* specific drawgfxzoom implementations for each transparency type */
207void drawgfxzoom_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley);
208void drawgfxzoom_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen);
209void drawgfxzoom_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen);
210void drawgfxzoom_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transmask);
211void drawgfxzoom_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, const UINT8 *pentable, const pen_t *shadowtable);
212void drawgfxzoom_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, UINT32 transpen, UINT8 alpha);
232213
233void copybitmap(bitmap_t *dest,bitmap_t *src,int flipx,int flipy,
234            int sx,int sy,const rectangle *clip);
235214
236void copybitmap_trans(bitmap_t *dest,bitmap_t *src,int flipx,int flipy,
237                 int sx,int sy,const rectangle *clip,pen_t transparent_pen);
238215
239void copyscrollbitmap(bitmap_t *dest,bitmap_t *src,
240                 int rows,const int *rowscroll,int cols,const int *colscroll,
241                 const rectangle *clip);
216/* ----- priority masked graphics drawing ----- */
242217
243void copyscrollbitmap_trans(bitmap_t *dest,bitmap_t *src,
244                      int rows,const int *rowscroll,int cols,const int *colscroll,
245                      const rectangle *clip,pen_t transparent_pen);
218/* generic pdrawgfx with legacy interface */
219void pdrawgfx(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, int transparency, UINT32 transparent_color, UINT32 pmask);
246220
221/* specific pdrawgfx implementations for each transparency type */
222void pdrawgfx_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask);
223void pdrawgfx_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask, UINT32 transpen);
224void pdrawgfx_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask, UINT32 transpen);
225void pdrawgfx_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask, UINT32 transmask);
226void pdrawgfx_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask, const UINT8 *pentable, const pen_t *shadowtable);
227void pdrawgfx_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, bitmap_t *priority, UINT32 pmask, UINT32 transpen, UINT8 alpha);
247228
229
230
231/* ----- priority masked zoomed graphics drawing ----- */
232
233/* generic pdrawgfxzoom with legacy interface */
234void pdrawgfxzoom(bitmap_t *dest, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, int transparency, UINT32 transparent_color, UINT32 scalex, UINT32 scaley, UINT32 pmask);
235
236/* specific pdrawgfxzoom implementations for each transparency type */
237void pdrawgfxzoom_opaque(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask);
238void pdrawgfxzoom_transpen(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask, UINT32 transpen);
239void pdrawgfxzoom_transpen_raw(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask, UINT32 transpen);
240void pdrawgfxzoom_transmask(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask, UINT32 transmask);
241void pdrawgfxzoom_transtable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask, const UINT8 *pentable, const pen_t *shadowtable);
242void pdrawgfxzoom_alpha(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, UINT32 scalex, UINT32 scaley, bitmap_t *priority, UINT32 pmask, UINT32 transpen, UINT8 alpha);
243
244
245
246/* ----- scanline copying ----- */
247
248/* copy pixels from an 8bpp buffer to a single scanline of a bitmap */
249void draw_scanline8(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT8 *srcptr, const pen_t *paldata);
250
251/* copy pixels from a 16bpp buffer to a single scanline of a bitmap */
252void draw_scanline16(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT16 *srcptr, const pen_t *paldata);
253
254/* copy pixels from a 32bpp buffer to a single scanline of a bitmap */
255void draw_scanline32(bitmap_t *bitmap, INT32 destx, INT32 desty, INT32 length, const UINT32 *srcptr, const pen_t *paldata);
256
257
258
259/* ----- scanline extraction ----- */
260
261/* copy pixels from a single scanline of a bitmap to an 8bpp buffer */
262void extract_scanline8(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT8 *destptr);
263
264/* copy pixels from a single scanline of a bitmap to a 16bpp buffer */
265void extract_scanline16(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT16 *destptr);
266
267/* copy pixels from a single scanline of a bitmap to a 32bpp buffer */
268void extract_scanline32(bitmap_t *bitmap, INT32 srcx, INT32 srcy, INT32 length, UINT32 *destptr);
269
270
271
272/* ----- bitmap copying ----- */
273
274/* copy from one bitmap to another, copying all unclipped pixels */
275void copybitmap(bitmap_t *dest, bitmap_t *src, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect);
276
277/* copy from one bitmap to another, copying all unclipped pixels except those that match transpen */
278void copybitmap_trans(bitmap_t *dest, bitmap_t *src, int flipx, int flipy, INT32 destx, INT32 desty, const rectangle *cliprect, UINT32 transpen);
279
248280/*
249  Copy a bitmap applying rotation, zooming, and arbitrary distortion.
250  This function works in a way that mimics some real hardware like the Konami
251  051316, so it requires little or no further processing on the caller side.
281  Copy a bitmap onto another with scroll and wraparound.
282  These functions support multiple independently scrolling rows/columns.
283  "rows" is the number of indepentently scrolling rows. "rowscroll" is an
284  array of integers telling how much to scroll each row. Same thing for
285  "numcols" and "colscroll".
286  If the bitmap cannot scroll in one direction, set numrows or columns to 0.
287  If the bitmap scrolls as a whole, set numrows and/or numcols to 1.
288  Bidirectional scrolling is, of course, supported only if the bitmap
289  scrolls as a whole in at least one direction.
290*/
252291
253  Two 16.16 fixed point counters are used to keep track of the position on
254  the source bitmap. startx and starty are the initial values of those counters,
255  indicating the source pixel that will be drawn at coordinates (0,0) in the
256  destination bitmap. The destination bitmap is scanned left to right, top to
257  bottom; every time the cursor moves one pixel to the right, incxx is added
258  to startx and incxy is added to starty. Every time the cursor moves to the
259  next line, incyx is added to startx and incyy is added to startyy.
292/* copy from one bitmap to another, copying all unclipped pixels, and applying scrolling to one or more rows/colums */
293void copyscrollbitmap(bitmap_t *dest, bitmap_t *src, UINT32 numrows, const INT32 *rowscroll, UINT32 numcols, const INT32 *colscroll, const rectangle *cliprect);
260294
261  What this means is that if incxy and incyx are both 0, the bitmap will be
262  copied with only zoom and no rotation. If e.g. incxx and incyy are both 0x8000,
263  the source bitmap will be doubled.
295/* copy from one bitmap to another, copying all unclipped pixels except those that match transpen, and applying scrolling to one or more rows/colums */
296void copyscrollbitmap_trans(bitmap_t *dest, bitmap_t *src, UINT32 numrows, const INT32 *rowscroll, UINT32 numcols, const INT32 *colscroll, const rectangle *cliprect, UINT32 transpen);
264297
265  Rotation is performed this way:
266  incxx = 0x10000 * cos(theta)
267  incxy = 0x10000 * -sin(theta)
268  incyx = 0x10000 * sin(theta)
269  incyy = 0x10000 * cos(theta)
270  this will perform a rotation around (0,0), you'll have to adjust startx and
271  starty to move the center of rotation elsewhere.
298/*
299    Copy a bitmap applying rotation, zooming, and arbitrary distortion.
300    This function works in a way that mimics some real hardware like the Konami
301    051316, so it requires little or no further processing on the caller side.
272302
273  Optionally the bitmap can be tiled across the screen instead of doing a single
274  copy. This is obtained by setting the wraparound parameter to true.
275 */
276void copyrozbitmap(bitmap_t *dest,bitmap_t *src,
277      UINT32 startx,UINT32 starty,int incxx,int incxy,int incyx,int incyy,int wraparound,
278      const rectangle *clip,int transparency,int transparent_color,UINT32 priority);
303    Two 16.16 fixed point counters are used to keep track of the position on
304    the source bitmap. startx and starty are the initial values of those counters,
305    indicating the source pixel that will be drawn at coordinates (0,0) in the
306    destination bitmap. The destination bitmap is scanned left to right, top to
307    bottom; every time the cursor moves one pixel to the right, incxx is added
308    to startx and incxy is added to starty. Every time the cursor moves to the
309    next line, incyx is added to startx and incyy is added to startyy.
279310
311    What this means is that if incxy and incyx are both 0, the bitmap will be
312    copied with only zoom and no rotation. If e.g. incxx and incyy are both 0x8000,
313    the source bitmap will be doubled.
280314
315    Rotation is performed this way:
316    incxx = 0x10000 * cos(theta)
317    incxy = 0x10000 * -sin(theta)
318    incyx = 0x10000 * sin(theta)
319    incyy = 0x10000 * cos(theta)
320    this will perform a rotation around (0,0), you'll have to adjust startx and
321    starty to move the center of rotation elsewhere.
281322
323    Optionally the bitmap can be tiled across the screen instead of doing a single
324    copy. This is obtained by setting the wraparound parameter to true.
325*/
326
327/* copy from one bitmap to another, with zoom and rotation, copying all unclipped pixels */
328void copyrozbitmap(bitmap_t *dest, const rectangle *cliprect, bitmap_t *src, INT32 startx, INT32 starty, INT32 incxx, INT32 incxy, INT32 incyx, INT32 incyy, int wraparound);
329
330/* copy from one bitmap to another, with zoom and rotation, copying all unclipped pixels whose values do not match transpen */
331void copyrozbitmap_trans(bitmap_t *dest, const rectangle *cliprect, bitmap_t *src, INT32 startx, INT32 starty, INT32 incxx, INT32 incxy, INT32 incyx, INT32 incyy, int wraparound, UINT32 transparent_color);
332
333
334
282335/***************************************************************************
283336    INLINE FUNCTIONS
284337***************************************************************************/
285338
286/* Alpha blending functions */
287INLINE void alpha_set_level(int level)
339/*-------------------------------------------------
340    gfx_element_set_source - set a pointer to
341    the source of a gfx_element
342-------------------------------------------------*/
343
344INLINE void gfx_element_set_source(gfx_element *gfx, const UINT8 *source)
288345{
289   extern struct _alpha_cache drawgfx_alpha_cache;
290   assert(level >= 0 && level <= 256);
291   drawgfx_alpha_cache.alphas = level;
292   drawgfx_alpha_cache.alphad = 256 - level;
346   gfx->srcdata = source;
347   memset(gfx->dirty, 1, gfx->total_elements);
293348}
294349
295350
296INLINE UINT32 alpha_blend16(UINT32 d, UINT32 s)
351/*-------------------------------------------------
352    gfx_element_get_data - return a pointer to
353    the base of the given code within a
354    gfx_element, decoding it if it is dirty
355-------------------------------------------------*/
356
357INLINE const UINT8 *gfx_element_get_data(const gfx_element *gfx, UINT32 code)
297358{
298   extern struct _alpha_cache drawgfx_alpha_cache;
299   return ((((s & 0x001f) * drawgfx_alpha_cache.alphas + (d & 0x001f) * drawgfx_alpha_cache.alphad) >> 8)) |
300         ((((s & 0x03e0) * drawgfx_alpha_cache.alphas + (d & 0x03e0) * drawgfx_alpha_cache.alphad) >> 8) & 0x03e0) |
301         ((((s & 0x7c00) * drawgfx_alpha_cache.alphas + (d & 0x7c00) * drawgfx_alpha_cache.alphad) >> 8) & 0x7c00);
359   assert(code < gfx->total_elements);
360   if (gfx->dirty[code])
361      gfx_element_decode(gfx, code);
362   return gfx->gfxdata + code * gfx->char_modulo + gfx->starty * gfx->line_modulo + gfx->startx;
302363}
303364
304365
305INLINE UINT32 alpha_blend32(UINT32 d, UINT32 s)
366/*-------------------------------------------------
367    gfx_element_mark_dirty - mark a code of a
368    gfx_element dirty
369-------------------------------------------------*/
370
371INLINE void gfx_element_mark_dirty(gfx_element *gfx, UINT32 code)
306372{
307   extern struct _alpha_cache drawgfx_alpha_cache;
308   return ((((s & 0x0000ff) * drawgfx_alpha_cache.alphas + (d & 0x0000ff) * drawgfx_alpha_cache.alphad) >> 8)) |
309         ((((s & 0x00ff00) * drawgfx_alpha_cache.alphas + (d & 0x00ff00) * drawgfx_alpha_cache.alphad) >> 8) & 0x00ff00) |
310         ((((s & 0xff0000) * drawgfx_alpha_cache.alphas + (d & 0xff0000) * drawgfx_alpha_cache.alphad) >> 8) & 0xff0000);
373   if (code < gfx->total_elements)
374   {
375      gfx->dirty[code] = 1;
376      gfx->dirtyseq++;
377   }
311378}
312379
313380
381/*-------------------------------------------------
382    gfx_element_set_source_clip - set a source
383    clipping area to apply to subsequent renders
384-------------------------------------------------*/
385
386INLINE void gfx_element_set_source_clip(gfx_element *gfx, UINT32 xoffs, UINT32 width, UINT32 yoffs, UINT32 height)
387{
388   assert(xoffs < gfx->origwidth);
389   assert(yoffs < gfx->origheight);
390   assert(xoffs + width <= gfx->origwidth);
391   assert(yoffs + height <= gfx->origheight);
392
393   gfx->width = width;
394   gfx->height = height;
395   gfx->startx = xoffs;
396   gfx->starty = yoffs;
397}
398
399
400/*-------------------------------------------------
401    alpha_blend_r16 - alpha blend two 16-bit
402    5-5-5 RGB pixels
403-------------------------------------------------*/
404
314405INLINE UINT32 alpha_blend_r16(UINT32 d, UINT32 s, UINT8 level)
315406{
316407   int alphad = 256 - level;
r4135r4136
320411}
321412
322413
323INLINE UINT32 alpha_blend_r32( UINT32 d, UINT32 s, UINT8 level )
414/*-------------------------------------------------
415    alpha_blend_r32 - alpha blend two 32-bit
416    8-8-8 RGB pixels
417-------------------------------------------------*/
418
419INLINE UINT32 alpha_blend_r32(UINT32 d, UINT32 s, UINT8 level)
324420{
325421   int alphad = 256 - level;
326422   return ((((s & 0x0000ff) * level + (d & 0x0000ff) * alphad) >> 8)) |
src/emu/mconfig.c
r4135r4136
160160   /* loop over tokens until we hit the end */
161161   while (entrytype != MCONFIG_TOKEN_END)
162162   {
163      int size, offset, type, bits, in, out;
163      int size, offset, bits, in, out;
164164      UINT32 data32, clock, gain;
165165      device_type devtype;
166      sound_type type;
166167      const char *tag;
167168      UINT64 data64;
168169
r4135r4136
360361         /* add/remove/replace sounds */
361362         case MCONFIG_TOKEN_SOUND_ADD:
362363            TOKEN_UNGET_UINT32(tokens);
363            TOKEN_GET_UINT64_UNPACK3(tokens, entrytype, 8, type, 24, clock, 32);
364            TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, clock, 32);
365            type = TOKEN_GET_PTR(tokens, sndtype);
364366            tag = TOKEN_GET_STRING(tokens);
365367            sound = sound_add(config, device_build_tag(tempstring, owner, tag), type, clock);
366368            break;
r4135r4136
384386
385387         case MCONFIG_TOKEN_SOUND_REPLACE:
386388            TOKEN_UNGET_UINT32(tokens);
387            TOKEN_GET_UINT64_UNPACK3(tokens, entrytype, 8, type, 24, clock, 32);
389            TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, clock, 32);
390            type = TOKEN_GET_PTR(tokens, sndtype);
388391            tag = TOKEN_GET_STRING(tokens);
389392            sound = sound_find(config, device_build_tag(tempstring, owner, tag));
390393            if (sound == NULL)
src/emu/drawgfxm.h
r0r4136
1/*********************************************************************
2
3    drawgfxm.h
4
5    Macros implementing drawgfx core operations. Drivers can use
6    these if they need custom behavior not provided by the existing
7    drawgfx functions.
8
9    Copyright Nicola Salmoria and the MAME Team.
10    Visit http://mamedev.org for licensing and usage restrictions.
11
12**********************************************************************
13
14    How to use these macros:
15
16    There are two sets of macros. The PIXEL_OP* macros are simple
17    per-pixel operations, designed to take a SOURCE pixel and
18    copy it to the DEST, perhaps updating the PRIORITY pixel as
19    well. On their own, they are not particularly useful.
20
21    The second set of macros represents the core gfx/bitmap walking
22    and rendering code. These macros generally take the target pixel
23    type (UINT8, UINT16, UINT32), one of the PIXEL_OP* macros,
24    and a priority bitmap pixel type (UINT8, UINT16, UINT32, or the
25    special type NO_PRIORITY).
26
27    Although the code may look inefficient at first, the compiler is
28    able to easily optimize out unused cases due to the way the
29    macros are written, leaving behind just the cases we are
30    interested in.
31
32    The general approach for using these macros is:
33
34    my_drawing_function(params)
35    {
36        // ensure that all the required parameters for the mega
37        // macro are defined (if they are not needed, just declare
38        // the variables and set them equal to a known constant
39        // value to help the compiler)
40
41        // set up any additional variables needed by the PIXEL_OP*
42        // macro you want to use (each macro has its own
43        // requirements)
44
45        MEGA_MACRO(BITMAP_TYPE, PIXEL_OP, PRIORITY_TYPE);
46    }
47
48*********************************************************************/
49
50#pragma once
51
52#ifndef __DRAWGFXM_H__
53#define __DRAWGFXM_H__
54
55#include "profiler.h"
56
57
58/* special priority type meaning "none" */
59typedef struct { char dummy[3]; } NO_PRIORITY;
60
61
62/* macros for using the optional priority */
63#define PRIORITY_VALID(x)      (sizeof(x) != sizeof(NO_PRIORITY))
64#define PRIORITY_ADDR(p,t,y,x)   (PRIORITY_VALID(t) ? BITMAP_ADDR(p, t, y, x) : NULL)
65#define PRIORITY_ADVANCE(t,p,i)   do { if (PRIORITY_VALID(t)) (p) += (i); } while (0)
66
67
68/***************************************************************************
69    PIXEL OPERATIONS
70***************************************************************************/
71
72/*-------------------------------------------------
73    PIXEL_OP_COPY_OPAQUE - render all pixels
74    regardless of pen, copying directly
75-------------------------------------------------*/
76
77#define PIXEL_OP_COPY_OPAQUE(DEST, PRIORITY, SOURCE)                         \
78do                                                               \
79{                                                               \
80   (DEST) = SOURCE;                                                \
81}                                                               \
82while (0)                                                         \
83
84
85/*-------------------------------------------------
86    PIXEL_OP_COPY_TRANSPEN - render all pixels
87    except those matching 'transpen', copying
88    directly
89-------------------------------------------------*/
90
91#define PIXEL_OP_COPY_TRANSPEN(DEST, PRIORITY, SOURCE)                         \
92do                                                               \
93{                                                               \
94   UINT32 srcdata = (SOURCE);                                          \
95   if (srcdata != transpen)                                          \
96      (DEST) = SOURCE;                                             \
97}                                                               \
98while (0)                                                         \
99
100
101/*-------------------------------------------------
102    PIXEL_OP_REMAP_OPAQUE - render all pixels
103    regardless of pen, mapping the pen via the
104    'paldata' array
105-------------------------------------------------*/
106
107#define PIXEL_OP_REMAP_OPAQUE(DEST, PRIORITY, SOURCE)                         \
108do                                                               \
109{                                                               \
110   (DEST) = paldata[SOURCE];                                          \
111}                                                               \
112while (0)                                                         \
113
114#define PIXEL_OP_REMAP_OPAQUE_PRIORITY(DEST, PRIORITY, SOURCE)                   \
115do                                                               \
116{                                                               \
117   if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0)                           \
118      (DEST) = paldata[SOURCE];                                       \
119   (PRIORITY) = 31;                                                \
120}                                                               \
121while (0)                                                         \
122
123
124/*-------------------------------------------------
125    PIXEL_OP_REMAP_TRANSPEN - render all pixels
126    except those matching 'transpen', mapping the
127    pen via the 'paldata' array
128-------------------------------------------------*/
129
130#define PIXEL_OP_REMAP_TRANSPEN(DEST, PRIORITY, SOURCE)                         \
131do                                                               \
132{                                                               \
133   UINT32 srcdata = (SOURCE);                                          \
134   if (srcdata != transpen)                                          \
135      (DEST) = paldata[srcdata];                                       \
136}                                                               \
137while (0)                                                         \
138
139#define PIXEL_OP_REMAP_TRANSPEN_PRIORITY(DEST, PRIORITY, SOURCE)                \
140do                                                               \
141{                                                               \
142   UINT32 srcdata = (SOURCE);                                          \
143   if (srcdata != transpen)                                          \
144   {                                                            \
145      if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0)                        \
146         (DEST) = paldata[srcdata];                                    \
147      (PRIORITY) = 31;                                             \
148   }                                                            \
149}                                                               \
150while (0)                                                         \
151
152
153/*-------------------------------------------------
154    PIXEL_OP_REBASE_TRANSPEN - render all pixels
155    except those matching 'transpen', adding
156    'color' to the pen value
157-------------------------------------------------*/
158
159#define PIXEL_OP_REBASE_TRANSPEN(DEST, PRIORITY, SOURCE)                      \
160do                                                               \
161{                                                               \
162   UINT32 srcdata = (SOURCE);                                          \
163   if (srcdata != transpen)                                          \
164      (DEST) = color + srcdata;                                       \
165}                                                               \
166while (0)                                                         \
167
168#define PIXEL_OP_REBASE_TRANSPEN_PRIORITY(DEST, PRIORITY, SOURCE)                \
169do                                                               \
170{                                                               \
171   UINT32 srcdata = (SOURCE);                                          \
172   if (srcdata != transpen)                                          \
173   {                                                            \
174      if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0)                        \
175         (DEST) = color + srcdata;                                    \
176      (PRIORITY) = 31;                                             \
177   }                                                            \
178}                                                               \
179while (0)                                                         \
180
181
182/*-------------------------------------------------
183    PIXEL_OP_REMAP_TRANSMASK - render all pixels
184    except those matching 'transmask', mapping the
185    pen via the 'paldata' array
186-------------------------------------------------*/
187
188#define PIXEL_OP_REMAP_TRANSMASK(DEST, PRIORITY, SOURCE)                      \
189do                                                               \
190{                                                               \
191   UINT32 srcdata = (SOURCE);                                          \
192   if (((transmask >> srcdata) & 1) == 0)                                 \
193      (DEST) = paldata[srcdata];                                       \
194}                                                               \
195while (0)                                                         \
196
197#define PIXEL_OP_REMAP_TRANSMASK_PRIORITY(DEST, PRIORITY, SOURCE)                \
198do                                                               \
199{                                                               \
200   UINT32 srcdata = (SOURCE);                                          \
201   if (((transmask >> srcdata) & 1) == 0)                                 \
202   {                                                            \
203      if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0)                        \
204         (DEST) = paldata[srcdata];                                    \
205      (PRIORITY) = 31;                                             \
206   }                                                            \
207}                                                               \
208while (0)                                                         \
209
210
211/*-------------------------------------------------
212    PIXEL_OP_REMAP_TRANSTABLE - look up each pen in
213    'pentable'; if the entry is DRAWMODE_NONE,
214    don't draw it; if the entry is DRAWMODE_SOURCE,
215    look up the pen via the 'paldata' array; if the
216    entry is DRAWMODE_SHADOW, generate a shadow of
217    the destination pixel using 'shadowtable'
218-------------------------------------------------*/
219
220#define PIXEL_OP_REMAP_TRANSTABLE16(DEST, PRIORITY, SOURCE)                      \
221do                                                               \
222{                                                               \
223   UINT32 srcdata = (SOURCE);                                          \
224   UINT32 entry = pentable[srcdata];                                    \
225   if (entry != DRAWMODE_NONE)                                          \
226   {                                                            \
227      if (entry == DRAWMODE_SOURCE)                                    \
228         (DEST) = paldata[srcdata];                                    \
229      else                                                      \
230         (DEST) = shadowtable[DEST];                                    \
231   }                                                            \
232}                                                               \
233while (0)                                                         \
234
235#define PIXEL_OP_REMAP_TRANSTABLE32(DEST, PRIORITY, SOURCE)                      \
236do                                                               \
237{                                                               \
238   UINT32 srcdata = (SOURCE);                                          \
239   UINT32 entry = pentable[srcdata];                                    \
240   if (entry != DRAWMODE_NONE)                                          \
241   {                                                            \
242      if (entry == DRAWMODE_SOURCE)                                    \
243         (DEST) = paldata[srcdata];                                    \
244      else                                                      \
245         (DEST) = shadowtable[rgb_to_rgb15(DEST)];                        \
246   }                                                            \
247}                                                               \
248while (0)                                                         \
249
250#define PIXEL_OP_REMAP_TRANSTABLE16_PRIORITY(DEST, PRIORITY, SOURCE)             \
251do                                                               \
252{                                                               \
253   UINT32 srcdata = (SOURCE);                                          \
254   UINT32 entry = pentable[srcdata];                                    \
255   if (entry != DRAWMODE_NONE)                                          \
256   {                                                            \
257      UINT8 pridata = (PRIORITY);                                       \
258      if (((1 << (pridata & 0x1f)) & pmask) == 0)                           \
259      {                                                         \
260         if (entry == DRAWMODE_SOURCE)                                 \
261         {                                                      \
262            (DEST) = paldata[srcdata];                                 \
263            (PRIORITY) = 31;                                       \
264         }                                                      \
265         else if ((pridata & 0x80) == 0)                                 \
266         {                                                      \
267            (DEST) = shadowtable[DEST];                                 \
268            (PRIORITY) = pridata | 0x80;                              \
269         }                                                      \
270      }                                                         \
271   }                                                            \
272}                                                               \
273while (0)                                                         \
274
275#define PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY(DEST, PRIORITY, SOURCE)            \
276do                                                               \
277{                                                               \
278   UINT32 srcdata = (SOURCE);                                          \
279   UINT32 entry = pentable[srcdata];                                    \
280   if (entry != DRAWMODE_NONE)                                          \
281   {                                                            \
282      UINT8 pridata = (PRIORITY);                                       \
283      if (((1 << (pridata & 0x1f)) & pmask) == 0)                           \
284      {                                                         \
285         if (entry == DRAWMODE_SOURCE)                                 \
286         {                                                      \
287            (DEST) = paldata[srcdata];                                 \
288            (PRIORITY) = 31;                                       \
289         }                                                      \
290         else if ((pridata & 0x80) == 0)                                 \
291         {                                                      \
292            (DEST) = shadowtable[rgb_to_rgb15(DEST)];                     \
293            (PRIORITY) = pridata | 0x80;                              \
294         }                                                      \
295      }                                                         \
296   }                                                            \
297}                                                               \
298while (0)                                                         \
299
300
301/*-------------------------------------------------
302    PIXEL_OP_REMAP_TRANSPEN_ALPHA - render all
303    pixels except those matching 'transpen',
304    mapping the pen to via the 'paldata' array;
305    the resulting color is RGB alpha blended
306    against the destination using 'alpha'
307-------------------------------------------------*/
308
309#define PIXEL_OP_REMAP_TRANSPEN_ALPHA16(DEST, PRIORITY, SOURCE)                   \
310do                                                               \
311{                                                               \
312   UINT32 srcdata = (SOURCE);                                          \
313   if (srcdata != transpen)                                          \
314      (DEST) = alpha_blend_r16((DEST), paldata[srcdata], alpha);               \
315}                                                               \
316while (0)                                                         \
317
318#define PIXEL_OP_REMAP_TRANSPEN_ALPHA32(DEST, PRIORITY, SOURCE)                   \
319do                                                               \
320{                                                               \
321   UINT32 srcdata = (SOURCE);                                          \
322   if (srcdata != transpen)                                          \
323      (DEST) = alpha_blend_r32((DEST), paldata[srcdata], alpha);               \
324}                                                               \
325while (0)                                                         \
326
327#define PIXEL_OP_REMAP_TRANSPEN_ALPHA16_PRIORITY(DEST, PRIORITY, SOURCE)          \
328do                                                               \
329{                                                               \
330   UINT32 srcdata = (SOURCE);                                          \
331   if (srcdata != transpen)                                          \
332   {                                                            \
333      if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0)                        \
334         (DEST) = alpha_blend_r16((DEST), paldata[srcdata], alpha);            \
335      (PRIORITY) = 31;                                             \
336   }                                                            \
337}                                                               \
338while (0)                                                         \
339
340#define PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY(DEST, PRIORITY, SOURCE)          \
341do                                                               \
342{                                                               \
343   UINT32 srcdata = (SOURCE);                                          \
344   if (srcdata != transpen)                                          \
345   {                                                            \
346      if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0)                        \
347         (DEST) = alpha_blend_r32((DEST), paldata[srcdata], alpha);            \
348      (PRIORITY) = 31;                                             \
349   }                                                            \
350}                                                               \
351while (0)                                                         \
352
353
354
355/***************************************************************************
356    BASIC DRAWGFX CORE
357***************************************************************************/
358
359/*
360    Assumed input parameters or local variables:
361
362        bitmap_t *dest - the bitmap to render to
363        const rectangle *cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest')
364        const gfx_element *gfx - pointer to the gfx_element to render
365        UINT32 code - index of the entry within gfx_element
366        UINT32 color - index of the color within gfx_element
367        int flipx - non-zero means render right-to-left instead of left-to-right
368        int flipy - non-zero means render bottom-to-top instead of top-to-bottom
369        INT32 destx - the top-left X coordinate to render to
370        INT32 desty - the top-left Y coordinate to render to
371        bitmap_t *priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy)
372*/
373
374
375#define DRAWGFX_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE)                        \
376do {                                                                \
377   profiler_mark(PROFILER_DRAWGFX);                                       \
378   do {                                                             \
379      const UINT8 *srcdata;                                             \
380      INT32 destendx, destendy;                                          \
381      INT32 srcx, srcy;                                                \
382      INT32 curx, cury;                                                \
383      INT32 dy;                                                      \
384                                                                  \
385      assert(dest != NULL);                                             \
386      assert(gfx != NULL);                                             \
387      assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority != NULL);                  \
388      assert(cliprect == NULL || cliprect->min_x >= 0);                        \
389      assert(cliprect == NULL || cliprect->max_x < dest->width);                  \
390      assert(cliprect == NULL || cliprect->min_y >= 0);                        \
391      assert(cliprect == NULL || cliprect->max_y < dest->height);                  \
392                                                                  \
393      /* NULL clip means use the full bitmap */                              \
394      if (cliprect == NULL)                                             \
395         cliprect = &dest->cliprect;                                       \
396                                                                  \
397      /* ignore empty/invalid cliprects */                                 \
398      if (cliprect->min_x > cliprect->max_x || cliprect->min_y > cliprect->max_y)      \
399         break;                                                      \
400                                                                  \
401      /* compute final pixel in X and exit if we are entirely clipped */            \
402      destendx = destx + gfx->width - 1;                                    \
403      if (destx > cliprect->max_x || destendx < cliprect->min_x)                  \
404         break;                                                      \
405                                                                  \
406      /* apply left clip */                                             \
407      srcx = 0;                                                      \
408      if (destx < cliprect->min_x)                                       \
409      {                                                            \
410         srcx = cliprect->min_x - destx;                                    \
411         destx = cliprect->min_x;                                       \
412      }                                                            \
413                                                                  \
414      /* apply right clip */                                             \
415      if (destendx > cliprect->max_x)                                       \
416         destendx = cliprect->max_x;                                       \
417                                                                  \
418      /* compute final pixel in Y and exit if we are entirely clipped */            \
419      destendy = desty + gfx->height - 1;                                    \
420      if (desty > cliprect->max_y || destendy < cliprect->min_y)                  \
421         break;                                                      \
422                                                                  \
423      /* apply top clip */                                             \
424      srcy = 0;                                                      \
425      if (desty < cliprect->min_y)                                       \
426      {                                                            \
427         srcy = cliprect->min_y - desty;                                    \
428         desty = cliprect->min_y;                                       \
429      }                                                            \
430                                                                  \
431      /* apply bottom clip */                                             \
432      if (destendy > cliprect->max_y)                                       \
433         destendy = cliprect->max_y;                                       \
434                                                                  \
435      /* apply X flipping */                                             \
436      if (flipx)                                                      \
437         srcx = gfx->width - 1 - srcx;                                    \
438                                                                  \
439      /* apply Y flipping */                                             \
440      dy = gfx->line_modulo;                                             \
441      if (flipy)                                                      \
442      {                                                            \
443         srcy = gfx->height - 1 - srcy;                                    \
444         dy = -dy;                                                   \
445      }                                                            \
446                                                                  \
447      /* fetch the source data */                                          \
448      srcdata = gfx_element_get_data(gfx, code);                              \
449                                                                  \
450      /* draw normal 8bpp source data */                                    \
451      if (!(gfx->flags & GFX_ELEMENT_PACKED))                                 \
452      {                                                            \
453         /* compute how many blocks of 4 pixels we have */                     \
454         UINT32 numblocks = (destendx + 1 - destx) / 4;                        \
455         UINT32 leftovers = (destendx + 1 - destx) - 4 * numblocks;               \
456                                                                  \
457         /* adjust srcdata to point to the first source pixel of the row */         \
458         srcdata += srcy * gfx->line_modulo + srcx;                           \
459                                                                  \
460         /* non-flipped 8bpp case */                                       \
461         if (!flipx)                                                   \
462         {                                                         \
463            /* iterate over pixels in Y */                                 \
464            for (cury = desty; cury <= destendy; cury++)                     \
465            {                                                      \
466               PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
467               PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx);   \
468               const UINT8 *srcptr = srcdata;                              \
469               srcdata += dy;                                          \
470                                                                  \
471               /* iterate over unrolled blocks of 4 */                        \
472               for (curx = 0; curx < numblocks; curx++)                     \
473               {                                                   \
474                  PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                   \
475                  PIXEL_OP(destptr[1], priptr[1], srcptr[1]);                   \
476                  PIXEL_OP(destptr[2], priptr[2], srcptr[2]);                   \
477                  PIXEL_OP(destptr[3], priptr[3], srcptr[3]);                   \
478                                                                  \
479                  srcptr += 4;                                       \
480                  destptr += 4;                                       \
481                  PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4);                  \
482               }                                                   \
483                                                                  \
484               /* iterate over leftover pixels */                           \
485               for (curx = 0; curx < leftovers; curx++)                     \
486               {                                                   \
487                  PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                   \
488                  srcptr++;                                          \
489                  destptr++;                                          \
490                  PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                  \
491               }                                                   \
492            }                                                      \
493         }                                                         \
494                                                                  \
495         /* flipped 8bpp case */                                          \
496         else                                                       \
497         {                                                         \
498            /* iterate over pixels in Y */                                 \
499            for (cury = desty; cury <= destendy; cury++)                     \
500            {                                                      \
501               PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
502               PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx);   \
503               const UINT8 *srcptr = srcdata;                              \
504               srcdata += dy;                                          \
505                                                                  \
506               /* iterate over unrolled blocks of 4 */                        \
507               for (curx = 0; curx < numblocks; curx++)                     \
508               {                                                   \
509                  PIXEL_OP(destptr[0], priptr[0], srcptr[ 0]);                \
510                  PIXEL_OP(destptr[1], priptr[1], srcptr[-1]);                \
511                  PIXEL_OP(destptr[2], priptr[2], srcptr[-2]);                \
512                  PIXEL_OP(destptr[3], priptr[3], srcptr[-3]);                \
513                                                                  \
514                  srcptr -= 4;                                       \
515                  destptr += 4;                                       \
516                  PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4);                  \
517               }                                                   \
518                                                                  \
519               /* iterate over leftover pixels */                           \
520               for (curx = 0; curx < leftovers; curx++)                     \
521               {                                                   \
522                  PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                \
523                  srcptr--;                                          \
524                  destptr++;                                          \
525                  PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                  \
526               }                                                   \
527            }                                                      \
528         }                                                         \
529      }                                                            \
530                                                                  \
531      /* draw packed 4bpp source data */                                    \
532      else                                                         \
533      {                                                            \
534         /* adjust srcdata to point to the first source pixel of the row */         \
535         srcdata += srcy * gfx->line_modulo + srcx / 2;                        \
536                                                                  \
537         /* non-flipped 4bpp case */                                       \
538         if (!flipx)                                                   \
539         {                                                         \
540            /* compute how many blocks of 2 pixels we have */                  \
541            UINT32 oddstart = srcx & 1;                                    \
542            UINT32 numblocks = (destendx + 1 - destx - oddstart) / 2;            \
543            UINT32 leftovers = (destendx + 1 - destx - oddstart) - 2 * numblocks;   \
544                                                                  \
545            /* iterate over pixels in Y */                                 \
546            for (cury = desty; cury <= destendy; cury++)                     \
547            {                                                      \
548               PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
549               PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx);   \
550               const UINT8 *srcptr = srcdata;                              \
551               srcdata += dy;                                          \
552                                                                  \
553               /* odd starting pixel */                                 \
554               if (oddstart)                                          \
555               {                                                   \
556                  PIXEL_OP(destptr[0], priptr[0], srcptr[0] >> 4);             \
557                  srcptr++;                                          \
558                  destptr++;                                          \
559                  PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                  \
560               }                                                   \
561                                                                  \
562               /* iterate over unrolled blocks of 2 */                        \
563               for (curx = 0; curx < numblocks; curx++)                     \
564               {                                                   \
565                  UINT8 srcbyte = *srcptr++;                              \
566                  PIXEL_OP(destptr[0], priptr[0], srcbyte & 15);                \
567                  PIXEL_OP(destptr[1], priptr[1], srcbyte >> 4);                \
568                  destptr += 2;                                       \
569                  PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 2);                  \
570               }                                                   \
571                                                                  \
572               /* iterate over leftover pixels */                           \
573               if (leftovers > 0)                                       \
574                  PIXEL_OP(destptr[0], priptr[0], srcptr[0] & 15);             \
575            }                                                      \
576         }                                                         \
577                                                                  \
578         /* flipped 4bpp case */                                          \
579         else                                                      \
580         {                                                         \
581            /* compute how many blocks of 2 pixels we have */                  \
582            UINT32 oddstart = ~srcx & 1;                                 \
583            UINT32 numblocks = (destendx + 1 - destx - oddstart) / 2;            \
584            UINT32 leftovers = (destendx + 1 - destx - oddstart) - 2 * numblocks;   \
585                                                                  \
586            /* iterate over pixels in Y */                                 \
587            for (cury = desty; cury <= destendy; cury++)                     \
588            {                                                      \
589               PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
590               PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx);   \
591               const UINT8 *srcptr = srcdata;                              \
592               srcdata += dy;                                          \
593                                                                  \
594               /* odd right pixel */                                    \
595               if (oddstart)                                          \
596               {                                                   \
597                  PIXEL_OP(destptr[0], priptr[0], srcptr[0] & 15);             \
598                  srcptr--;                                          \
599                  destptr++;                                          \
600                  PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                  \
601               }                                                   \
602                                                                  \
603               /* middle pixels */                                       \
604               for (curx = 0; curx < numblocks; curx++)                     \
605               {                                                   \
606                  UINT8 srcbyte = *srcptr--;                              \
607                  PIXEL_OP(destptr[0], priptr[0], srcbyte >> 4);                \
608                  PIXEL_OP(destptr[1], priptr[1], srcbyte & 15);                \
609                  destptr += 2;                                       \
610                  PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 2);                  \
611               }                                                   \
612                                                                  \
613               /* odd left pixel */                                    \
614               if (leftovers > 0)                                       \
615                  PIXEL_OP(destptr[0], priptr[0], srcptr[0] >> 4);             \
616            }                                                      \
617         }                                                         \
618      }                                                            \
619   } while (0);                                                      \
620   profiler_mark(PROFILER_END);                                          \
621} while (0)
622
623
624
625/***************************************************************************
626    BASIC DRAWGFXZOOM CORE
627***************************************************************************/
628
629/*
630    Assumed input parameters or local variables:
631
632        bitmap_t *dest - the bitmap to render to
633        const rectangle *cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest')
634        const gfx_element *gfx - pointer to the gfx_element to render
635        UINT32 code - index of the entry within gfx_element
636        UINT32 color - index of the color within gfx_element
637        int flipx - non-zero means render right-to-left instead of left-to-right
638        int flipy - non-zero means render bottom-to-top instead of top-to-bottom
639        INT32 destx - the top-left X coordinate to render to
640        INT32 desty - the top-left Y coordinate to render to
641        UINT32 scalex - the 16.16 scale factor in the X dimension
642        UINT32 scaley - the 16.16 scale factor in the Y dimension
643        bitmap_t *priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy)
644*/
645
646
647#define DRAWGFXZOOM_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE)                     \
648do {                                                                \
649   profiler_mark(PROFILER_DRAWGFX);                                       \
650   do {                                                             \
651      const UINT8 *srcdata;                                             \
652      UINT32 dstwidth, dstheight;                                          \
653      INT32 destendx, destendy;                                          \
654      INT32 srcx, srcy;                                                \
655      INT32 curx, cury;                                                \
656      INT32 dx, dy;                                                   \
657                                                                  \
658      assert(dest != NULL);                                             \
659      assert(gfx != NULL);                                             \
660      assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority != NULL);                  \
661      assert(cliprect == NULL || cliprect->min_x >= 0);                        \
662      assert(cliprect == NULL || cliprect->max_x < dest->width);                  \
663      assert(cliprect == NULL || cliprect->min_y >= 0);                        \
664      assert(cliprect == NULL || cliprect->max_y < dest->height);                  \
665                                                                  \
666      /* NULL clip means use the full bitmap */                              \
667      if (cliprect == NULL)                                             \
668         cliprect = &dest->cliprect;                                       \
669                                                                  \
670      /* ignore empty/invalid cliprects */                                 \
671      if (cliprect->min_x > cliprect->max_x || cliprect->min_y > cliprect->max_y)      \
672         break;                                                      \
673                                                                  \
674      /* compute scaled size */                                          \
675      dstwidth = (scalex * gfx->width + 0x8000) >> 16;                        \
676      dstheight = (scaley * gfx->height + 0x8000) >> 16;                        \
677      if (dstwidth < 1 || dstheight < 1)                                    \
678         break;                                                      \
679                                                                  \
680      /* compute 16.16 source steps in dx and dy */                           \
681      dx = (gfx->width << 16) / dstwidth;                                    \
682      dy = (gfx->height << 16) / dstheight;                                 \
683                                                                  \
684      /* compute final pixel in X and exit if we are entirely clipped */            \
685      destendx = destx + dstwidth - 1;                                    \
686      if (destx > cliprect->max_x || destendx < cliprect->min_x)                  \
687         break;                                                      \
688                                                                  \
689      /* apply left clip */                                             \
690      srcx = 0;                                                      \
691      if (destx < cliprect->min_x)                                       \
692      {                                                            \
693         srcx = (cliprect->min_x - destx) * dx;                              \
694         destx = cliprect->min_x;                                       \
695      }                                                            \
696                                                                  \
697      /* apply right clip */                                             \
698      if (destendx > cliprect->max_x)                                       \
699         destendx = cliprect->max_x;                                       \
700                                                                  \
701      /* compute final pixel in Y and exit if we are entirely clipped */            \
702      destendy = desty + dstheight - 1;                                    \
703      if (desty > cliprect->max_y || destendy < cliprect->min_y)                  \
704         return;                                                      \
705                                                                  \
706      /* apply top clip */                                             \
707      srcy = 0;                                                      \
708      if (desty < cliprect->min_y)                                       \
709      {                                                            \
710         srcy = (cliprect->min_y - desty) * dy;                              \
711         desty = cliprect->min_y;                                       \
712      }                                                            \
713                                                                  \
714      /* apply bottom clip */                                             \
715      if (destendy > cliprect->max_y)                                       \
716         destendy = cliprect->max_y;                                       \
717                                                                  \
718      /* apply X flipping */                                             \
719      if (flipx)                                                      \
720      {                                                            \
721         srcx = (dstwidth - 1) * dx - srcx;                                 \
722         dx = -dx;                                                   \
723      }                                                            \
724                                                                  \
725      /* apply Y flipping */                                             \
726      if (flipy)                                                      \
727      {                                                            \
728         srcy = (dstheight - 1) * dy - srcy;                                 \
729         dy = -dy;                                                   \
730      }                                                            \
731                                                                  \
732      /* fetch the source data */                                          \
733      srcdata = gfx_element_get_data(gfx, code);                              \
734                                                                  \
735      /* draw normal */                                                \
736      if (!(gfx->flags & GFX_ELEMENT_PACKED))                                 \
737      {                                                            \
738         /* compute how many blocks of 4 pixels we have */                     \
739         UINT32 numblocks = (destendx + 1 - destx) / 4;                        \
740         UINT32 leftovers = (destendx + 1 - destx) - 4 * numblocks;               \
741                                                                  \
742         /* iterate over pixels in Y */                                    \
743         for (cury = desty; cury <= destendy; cury++)                        \
744         {                                                         \
745            PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
746            PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx);      \
747            const UINT8 *srcptr = srcdata + (srcy >> 16) * gfx->line_modulo;      \
748            INT32 cursrcx = srcx;                                       \
749            srcy += dy;                                                \
750                                                                  \
751            /* iterate over unrolled blocks of 4 */                           \
752            for (curx = 0; curx < numblocks; curx++)                        \
753            {                                                      \
754               PIXEL_OP(destptr[0], priptr[0], srcptr[cursrcx >> 16]);          \
755               cursrcx += dx;                                          \
756               PIXEL_OP(destptr[1], priptr[1], srcptr[cursrcx >> 16]);          \
757               cursrcx += dx;                                          \
758               PIXEL_OP(destptr[2], priptr[2], srcptr[cursrcx >> 16]);          \
759               cursrcx += dx;                                          \
760               PIXEL_OP(destptr[3], priptr[3], srcptr[cursrcx >> 16]);          \
761               cursrcx += dx;                                          \
762                                                                  \
763               destptr += 4;                                          \
764               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4);                     \
765            }                                                      \
766                                                                  \
767            /* iterate over leftover pixels */                              \
768            for (curx = 0; curx < leftovers; curx++)                        \
769            {                                                      \
770               PIXEL_OP(destptr[0], priptr[0], srcptr[cursrcx >> 16]);          \
771               cursrcx += dx;                                          \
772               destptr++;                                             \
773               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                     \
774            }                                                      \
775         }                                                         \
776      }                                                            \
777                                                                  \
778      /* draw packed */                                                \
779      else                                                         \
780      {                                                            \
781         /* iterate over pixels in Y */                                    \
782         for (cury = desty; cury <= destendy; cury++)                        \
783         {                                                         \
784            PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
785            PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx);      \
786            const UINT8 *srcptr = srcdata + (srcy >> 16) * gfx->line_modulo;      \
787            INT32 cursrcx = srcx;                                       \
788            srcy += dy;                                                \
789                                                                  \
790            /* iterate over pixels in X */                                 \
791            for (curx = destx; curx <= destendx; curx++)                     \
792            {                                                      \
793               PIXEL_OP(destptr[0], priptr[0], (srcptr[cursrcx >> 17] >> ((cursrcx >> 14) & 4)) & 15); \
794               cursrcx += dx;                                          \
795               destptr++;                                             \
796               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                     \
797            }                                                      \
798         }                                                         \
799      }                                                            \
800   } while (0);                                                      \
801   profiler_mark(PROFILER_END);                                          \
802} while (0)
803
804
805
806/***************************************************************************
807    BASIC COPYBITMAP CORE
808***************************************************************************/
809
810/*
811    Assumed input parameters or local variables:
812
813        bitmap_t *dest - the bitmap to copy to
814        bitmap_t *src - the bitmap to copy from (must be same bpp as dest)
815        const rectangle *cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest')
816        int flipx - non-zero means render right-to-left instead of left-to-right
817        int flipy - non-zero means render bottom-to-top instead of top-to-bottom
818        INT32 destx - the top-left X coordinate to copy to
819        INT32 desty - the top-left Y coordinate to copy to
820        bitmap_t *priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy)
821*/
822
823#define COPYBITMAP_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE)                     \
824do {                                                                \
825   profiler_mark(PROFILER_COPYBITMAP);                                       \
826   do {                                                             \
827      const PIXEL_TYPE *srcdata;                                          \
828      UINT32 numblocks, leftovers;                                       \
829      INT32 destendx, destendy;                                          \
830      INT32 srcx, srcy;                                                \
831      INT32 curx, cury;                                                \
832      INT32 dx, dy;                                                   \
833                                                                  \
834      assert(dest != NULL);                                             \
835      assert(src != NULL);                                             \
836      assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority != NULL);                  \
837      assert(cliprect == NULL || cliprect->min_x >= 0);                        \
838      assert(cliprect == NULL || cliprect->max_x < dest->width);                  \
839      assert(cliprect == NULL || cliprect->min_y >= 0);                        \
840      assert(cliprect == NULL || cliprect->max_y < dest->height);                  \
841                                                                  \
842      /* NULL clip means use the full bitmap */                              \
843      if (cliprect == NULL)                                             \
844         cliprect = &dest->cliprect;                                       \
845                                                                  \
846      /* ignore empty/invalid cliprects */                                 \
847      if (cliprect->min_x > cliprect->max_x || cliprect->min_y > cliprect->max_y)      \
848         break;                                                      \
849                                                                  \
850      /* standard setup; dx counts bytes in X, dy counts pixels in Y */            \
851      dx = 1;                                                         \
852      dy = src->rowpixels;                                             \
853                                                                  \
854      /* compute final pixel in X and exit if we are entirely clipped */            \
855      destendx = destx + src->width - 1;                                    \
856      if (destx > cliprect->max_x || destendx < cliprect->min_x)                  \
857         break;                                                      \
858                                                                  \
859      /* apply left clip */                                             \
860      srcx = 0;                                                      \
861      if (destx < cliprect->min_x)                                       \
862      {                                                            \
863         srcx = cliprect->min_x - destx;                                    \
864         destx = cliprect->min_x;                                       \
865      }                                                            \
866                                                                  \
867      /* apply right clip */                                             \
868      if (destendx > cliprect->max_x)                                       \
869         destendx = cliprect->max_x;                                       \
870                                                                  \
871      /* compute final pixel in Y and exit if we are entirely clipped */            \
872      destendy = desty + src->height - 1;                                    \
873      if (desty > cliprect->max_y || destendy < cliprect->min_y)                  \
874         break;                                                      \
875                                                                  \
876      /* apply top clip */                                             \
877      srcy = 0;                                                      \
878      if (desty < cliprect->min_y)                                       \
879      {                                                            \
880         srcy = cliprect->min_y - desty;                                    \
881         desty = cliprect->min_y;                                       \
882      }                                                            \
883                                                                  \
884      /* apply bottom clip */                                             \
885      if (destendy > cliprect->max_y)                                       \
886         destendy = cliprect->max_y;                                       \
887                                                                  \
888      /* apply X flipping */                                             \
889      if (flipx)                                                      \
890      {                                                            \
891         srcx = src->width - 1 - srcx;                                    \
892         dx = -dx;                                                   \
893      }                                                            \
894                                                                  \
895      /* apply Y flipping */                                             \
896      if (flipy)                                                      \
897      {                                                            \
898         srcy = src->height - 1 - srcy;                                    \
899         dy = -dy;                                                   \
900      }                                                            \
901                                                                  \
902      /* compute how many blocks of 4 pixels we have */                        \
903      numblocks = (destendx + 1 - destx) / 4;                                 \
904      leftovers = (destendx + 1 - destx) - 4 * numblocks;                        \
905                                                                  \
906      /* compute the address of the first source pixel of the first row */         \
907      srcdata = BITMAP_ADDR(src, PIXEL_TYPE, srcy, srcx);                        \
908                                                                  \
909      /* non-flipped case */                                             \
910      if (!flipx)                                                      \
911      {                                                            \
912         /* iterate over pixels in Y */                                    \
913         for (cury = desty; cury <= destendy; cury++)                        \
914         {                                                         \
915            PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
916            PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx);      \
917            const PIXEL_TYPE *srcptr = srcdata;                              \
918            srcdata += dy;                                             \
919                                                                  \
920            /* iterate over unrolled blocks of 4 */                           \
921            for (curx = 0; curx < numblocks; curx++)                        \
922            {                                                      \
923               PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                      \
924               PIXEL_OP(destptr[1], priptr[1], srcptr[1]);                      \
925               PIXEL_OP(destptr[2], priptr[2], srcptr[2]);                      \
926               PIXEL_OP(destptr[3], priptr[3], srcptr[3]);                      \
927                                                                  \
928               srcptr += 4;                                          \
929               destptr += 4;                                          \
930               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4);                     \
931            }                                                      \
932                                                                  \
933            /* iterate over leftover pixels */                              \
934            for (curx = 0; curx < leftovers; curx++)                        \
935            {                                                      \
936               PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                      \
937               srcptr++;                                             \
938               destptr++;                                             \
939               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                     \
940            }                                                      \
941         }                                                         \
942      }                                                            \
943                                                                  \
944      /* flipped case */                                                \
945      else                                                          \
946      {                                                            \
947         /* iterate over pixels in Y */                                    \
948         for (cury = desty; cury <= destendy; cury++)                        \
949         {                                                         \
950            PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \
951            PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, destx);      \
952            const PIXEL_TYPE *srcptr = srcdata;                              \
953            srcdata += dy;                                             \
954                                                                  \
955            /* iterate over unrolled blocks of 4 */                           \
956            for (curx = 0; curx < numblocks; curx++)                        \
957            {                                                      \
958               PIXEL_OP(destptr[0], priptr[0], srcptr[ 0]);                   \
959               PIXEL_OP(destptr[1], priptr[1], srcptr[-1]);                   \
960               PIXEL_OP(destptr[2], priptr[2], srcptr[-2]);                   \
961               PIXEL_OP(destptr[3], priptr[3], srcptr[-3]);                   \
962                                                                  \
963               srcptr -= 4;                                          \
964               destptr += 4;                                          \
965               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4);                     \
966            }                                                      \
967                                                                  \
968            /* iterate over leftover pixels */                              \
969            for (curx = 0; curx < leftovers; curx++)                        \
970            {                                                      \
971               PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                   \
972               srcptr--;                                             \
973               destptr++;                                             \
974               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                     \
975            }                                                      \
976         }                                                         \
977      }                                                            \
978   } while (0);                                                      \
979   profiler_mark(PROFILER_END);                                          \
980} while (0)
981
982
983
984/***************************************************************************
985    BASIC COPYROZBITMAP CORE
986***************************************************************************/
987
988/*
989    Assumed input parameters or local variables:
990
991        bitmap_t *dest - the bitmap to copy to
992        bitmap_t *src - the bitmap to copy from (must be same bpp as dest)
993        const rectangle *cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest')
994        INT32 destx - the 16.16 source X position at destination pixel (0,0)
995        INT32 desty - the 16.16 source Y position at destination pixel (0,0)
996        INT32 incxx - the 16.16 amount to increment in source X for each destination X pixel
997        INT32 incyx - the 16.16 amount to increment in source Y for each destination X pixel
998        INT32 incxy - the 16.16 amount to increment in source X for each destination Y pixel
999        INT32 incyy - the 16.16 amount to increment in source Y for each destination Y pixel
1000        int wraparound - non-zero means wrap when hitting the edges of the source
1001        bitmap_t *priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy)
1002*/
1003
1004#define COPYROZBITMAP_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE)                  \
1005do {                                                             \
1006   UINT32 srcfixwidth, srcfixheight;                                    \
1007   UINT32 numblocks, leftovers;                                       \
1008   INT32 curx, cury;                                                \
1009                                                               \
1010   profiler_mark(PROFILER_COPYBITMAP);                                    \
1011                                                               \
1012   assert(dest != NULL);                                             \
1013   assert(src != NULL);                                             \
1014   assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority != NULL);                  \
1015   assert(cliprect == NULL || cliprect->min_x >= 0);                        \
1016   assert(cliprect == NULL || cliprect->max_x < dest->width);                  \
1017   assert(cliprect == NULL || cliprect->min_y >= 0);                        \
1018   assert(cliprect == NULL || cliprect->max_y < dest->height);                  \
1019   assert(!wraparound || (src->width & (src->width - 1)) == 0);               \
1020   assert(!wraparound || (src->height & (src->height - 1)) == 0);               \
1021                                                               \
1022   /* NULL clip means use the full bitmap */                              \
1023   if (cliprect == NULL)                                             \
1024      cliprect = &dest->cliprect;                                       \
1025                                                               \
1026   /* ignore empty/invalid cliprects */                                 \
1027   if (cliprect->min_x > cliprect->max_x || cliprect->min_y > cliprect->max_y)      \
1028      break;                                                      \
1029                                                               \
1030   /* compute fixed-point 16.16 size of the source bitmap */                  \
1031   srcfixwidth = src->width << 16;                                       \
1032   srcfixheight = src->height << 16;                                    \
1033                                                               \
1034   /* advance the starting coordinates to the top-left of the cliprect */         \
1035   startx += cliprect->min_x * incxx + cliprect->min_y * incyx;               \
1036   starty += cliprect->min_x * incxy + cliprect->min_y * incyy;               \
1037                                                               \
1038   /* compute how many blocks of 4 pixels we have */                        \
1039   numblocks = (cliprect->max_x + 1 - cliprect->min_x) / 4;                  \
1040   leftovers = (cliprect->max_x + 1 - cliprect->min_x) - 4 * numblocks;         \
1041                                                               \
1042   /* if incxy and incyx are 0, then we aren't rotating, just zooming */         \
1043   if (incxy == 0 && incyx == 0)                                       \
1044   {                                                            \
1045      /* zoom-only, non-wraparound case */                              \
1046      if (!wraparound)                                             \
1047      {                                                         \
1048         /* iterate over pixels in Y */                                 \
1049         for (cury = cliprect->min_y; cury <= cliprect->max_y; cury++)         \
1050         {                                                      \
1051            PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect->min_x); \
1052            PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, cliprect->min_x); \
1053            const PIXEL_TYPE *srcptr;                                 \
1054            INT32 srcx = startx;                                    \
1055            INT32 srcy = starty;                                    \
1056                                                               \
1057            starty += incyy;                                       \
1058                                                               \
1059            /* check srcy for the whole row at once */                     \
1060            if ((UINT32)srcy < srcfixheight)                           \
1061            {                                                   \
1062               srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, 0);         \
1063                                                               \
1064               /* iterate over unrolled blocks of 4 */                     \
1065               for (curx = 0; curx < numblocks; curx++)                  \
1066               {                                                \
1067                  if ((UINT32)srcx < srcfixwidth)                        \
1068                     PIXEL_OP(destptr[0], priptr[0], srcptr[srcx >> 16]);   \
1069                  srcx += incxx;                                    \
1070                                                               \
1071                  if ((UINT32)srcx < srcfixwidth)                        \
1072                     PIXEL_OP(destptr[1], priptr[1], srcptr[srcx >> 16]);   \
1073                  srcx += incxx;                                    \
1074                                                               \
1075                  if ((UINT32)srcx < srcfixwidth)                        \
1076                     PIXEL_OP(destptr[2], priptr[2], srcptr[srcx >> 16]);   \
1077                  srcx += incxx;                                    \
1078                                                               \
1079                  if ((UINT32)srcx < srcfixwidth)                        \
1080                     PIXEL_OP(destptr[3], priptr[3], srcptr[srcx >> 16]);   \
1081                  srcx += incxx;                                    \
1082                                                               \
1083                  destptr += 4;                                    \
1084                  PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4);               \
1085               }                                                \
1086                                                               \
1087               /* iterate over leftover pixels */                        \
1088               for (curx = 0; curx < leftovers; curx++)                  \
1089               {                                                \
1090                  if ((UINT32)srcx < srcfixwidth)                        \
1091                     PIXEL_OP(destptr[0], priptr[0], srcptr[srcx >> 16]);    \
1092                  srcx += incxx;                                    \
1093                  destptr++;                                       \
1094                  PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);               \
1095               }                                                \
1096            }                                                   \
1097         }                                                      \
1098      }                                                         \
1099                                                               \
1100      /* zoom-only, wraparound case */                                 \
1101      else                                                      \
1102      {                                                         \
1103         /* convert srcfixwidth/height into a mask and apply */               \
1104         srcfixwidth--;                                             \
1105         srcfixheight--;                                             \
1106         startx &= srcfixwidth;                                       \
1107         starty &= srcfixheight;                                       \
1108                                                               \
1109         /* iterate over pixels in Y */                                 \
1110         for (cury = cliprect->min_y; cury <= cliprect->max_y; cury++)         \
1111         {                                                      \
1112            PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect->min_x); \
1113            PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, cliprect->min_x); \
1114            const PIXEL_TYPE *srcptr = BITMAP_ADDR(src, PIXEL_TYPE, starty >> 16, 0); \
1115            INT32 srcx = startx;                                    \
1116                                                               \
1117            starty = (starty + incyy) & srcfixheight;                     \
1118                                                               \
1119            /* iterate over unrolled blocks of 4 */                        \
1120            for (curx = 0; curx < numblocks; curx++)                     \
1121            {                                                   \
1122               PIXEL_OP(destptr[0], priptr[0], srcptr[srcx >> 16]);          \
1123               srcx = (srcx + incxx) & srcfixwidth;                     \
1124                                                               \
1125               PIXEL_OP(destptr[1], priptr[1], srcptr[srcx >> 16]);          \
1126               srcx = (srcx + incxx) & srcfixwidth;                     \
1127                                                               \
1128               PIXEL_OP(destptr[2], priptr[2], srcptr[srcx >> 16]);          \
1129               srcx = (srcx + incxx) & srcfixwidth;                     \
1130                                                               \
1131               PIXEL_OP(destptr[3], priptr[3], srcptr[srcx >> 16]);         \
1132               srcx = (srcx + incxx) & srcfixwidth;                     \
1133                                                               \
1134               destptr += 4;                                       \
1135               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4);                  \
1136            }                                                   \
1137                                                               \
1138            /* iterate over leftover pixels */                           \
1139            for (curx = 0; curx < leftovers; curx++)                     \
1140            {                                                   \
1141               PIXEL_OP(destptr[0], priptr[0], srcptr[srcx >> 16]);          \
1142               srcx = (srcx + incxx) & srcfixwidth;                     \
1143               destptr++;                                          \
1144               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                  \
1145            }                                                   \
1146         }                                                      \
1147      }                                                         \
1148   }                                                            \
1149                                                               \
1150   /* full rotation case */                                          \
1151   else                                                         \
1152   {                                                            \
1153      /* full rotation, non-wraparound case */                           \
1154      if (!wraparound)                                             \
1155      {                                                         \
1156         /* iterate over pixels in Y */                                 \
1157         for (cury = cliprect->min_y; cury <= cliprect->max_y; cury++)         \
1158         {                                                      \
1159            PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect->min_x); \
1160            PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, cliprect->min_x); \
1161            const PIXEL_TYPE *srcptr;                                 \
1162            INT32 srcx = startx;                                    \
1163            INT32 srcy = starty;                                    \
1164                                                               \
1165            startx += incyx;                                       \
1166            starty += incyy;                                       \
1167                                                               \
1168            /* iterate over unrolled blocks of 4 */                        \
1169            for (curx = 0; curx < numblocks; curx++)                     \
1170            {                                                   \
1171               if ((UINT32)srcx < srcfixwidth && (UINT32)srcy < srcfixheight)   \
1172               {                                                \
1173                  srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
1174                  PIXEL_OP(destptr[0], priptr[0], srcptr[0]);               \
1175               }                                                \
1176               srcx += incxx;                                       \
1177               srcy += incxy;                                       \
1178                                                               \
1179               if ((UINT32)srcx < srcfixwidth && (UINT32)srcy < srcfixheight)   \
1180               {                                                \
1181                  srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
1182                  PIXEL_OP(destptr[1], priptr[1], srcptr[0]);               \
1183               }                                                \
1184               srcx += incxx;                                       \
1185               srcy += incxy;                                       \
1186                                                               \
1187               if ((UINT32)srcx < srcfixwidth && (UINT32)srcy < srcfixheight)   \
1188               {                                                \
1189                  srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
1190                  PIXEL_OP(destptr[2], priptr[2], srcptr[0]);               \
1191               }                                                \
1192               srcx += incxx;                                       \
1193               srcy += incxy;                                       \
1194                                                               \
1195               if ((UINT32)srcx < srcfixwidth && (UINT32)srcy < srcfixheight)   \
1196               {                                                \
1197                  srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
1198                  PIXEL_OP(destptr[3], priptr[3], srcptr[0]);               \
1199               }                                                \
1200               srcx += incxx;                                       \
1201               srcy += incxy;                                       \
1202                                                               \
1203               destptr += 4;                                       \
1204               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4);                  \
1205            }                                                   \
1206                                                               \
1207            /* iterate over leftover pixels */                           \
1208            for (curx = 0; curx < leftovers; curx++)                     \
1209            {                                                   \
1210               if ((UINT32)srcx < srcfixwidth && (UINT32)srcy < srcfixheight)   \
1211               {                                                \
1212                  srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16); \
1213                  PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                \
1214               }                                                \
1215               srcx += incxx;                                       \
1216               srcy += incxy;                                       \
1217               destptr++;                                          \
1218               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                  \
1219            }                                                   \
1220         }                                                      \
1221      }                                                         \
1222                                                               \
1223      /* zoom-only, wraparound case */                                 \
1224      else                                                      \
1225      {                                                         \
1226         /* convert srcfixwidth/height into a mask and apply */               \
1227         srcfixwidth--;                                             \
1228         srcfixheight--;                                             \
1229         startx &= srcfixwidth;                                       \
1230         starty &= srcfixheight;                                       \
1231                                                               \
1232         /* iterate over pixels in Y */                                 \
1233         for (cury = cliprect->min_y; cury <= cliprect->max_y; cury++)         \
1234         {                                                      \
1235            PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect->min_x); \
1236            PIXEL_TYPE *destptr = BITMAP_ADDR(dest, PIXEL_TYPE, cury, cliprect->min_x); \
1237            const PIXEL_TYPE *srcptr;                                 \
1238            INT32 srcx = startx;                                    \
1239            INT32 srcy = starty;                                    \
1240                                                               \
1241            startx = (startx + incyx) & srcfixwidth;                     \
1242            starty = (starty + incyy) & srcfixheight;                     \
1243                                                               \
1244            /* iterate over unrolled blocks of 4 */                        \
1245            for (curx = 0; curx < numblocks; curx++)                     \
1246            {                                                   \
1247               srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16);   \
1248               PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                  \
1249               srcx = (srcx + incxx) & srcfixwidth;                     \
1250               srcy = (srcy + incxy) & srcfixheight;                     \
1251                                                               \
1252               srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16);   \
1253               PIXEL_OP(destptr[1], priptr[1], srcptr[0]);                  \
1254               srcx = (srcx + incxx) & srcfixwidth;                     \
1255               srcy = (srcy + incxy) & srcfixheight;                     \
1256                                                               \
1257               srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16);   \
1258               PIXEL_OP(destptr[2], priptr[2], srcptr[0]);                  \
1259               srcx = (srcx + incxx) & srcfixwidth;                     \
1260               srcy = (srcy + incxy) & srcfixheight;                     \
1261                                                               \
1262               srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16);   \
1263               PIXEL_OP(destptr[3], priptr[3], srcptr[0]);                  \
1264               srcx = (srcx + incxx) & srcfixwidth;                     \
1265               srcy = (srcy + incxy) & srcfixheight;                     \
1266                                                               \
1267               destptr += 4;                                       \
1268               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4);                  \
1269            }                                                   \
1270                                                               \
1271            /* iterate over leftover pixels */                           \
1272            for (curx = 0; curx < leftovers; curx++)                     \
1273            {                                                   \
1274               srcptr = BITMAP_ADDR(src, PIXEL_TYPE, srcy >> 16, srcx >> 16);   \
1275               PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                  \
1276               srcx = (srcx + incxx) & srcfixwidth;                     \
1277               srcy = (srcy + incxy) & srcfixheight;                     \
1278               destptr++;                                          \
1279               PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                  \
1280            }                                                   \
1281         }                                                      \
1282      }                                                         \
1283   }                                                            \
1284   profiler_mark(PROFILER_END);                                       \
1285} while (0)
1286
1287
1288
1289/***************************************************************************
1290    BASIC DRAWSCANLINE CORE
1291***************************************************************************/
1292
1293/*
1294    Assumed input parameters or local variables:
1295
1296        bitmap_t *bitmap - the bitmap to copy to
1297        INT32 destx - the X coordinate to copy to
1298        INT32 desty - the Y coordinate to copy to
1299        INT32 length - the total number of pixels to copy
1300        const UINTx *srcptr - pointer to memory containing the source pixels
1301        bitmap_t *priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy)
1302*/
1303
1304#define DRAWSCANLINE_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE)                  \
1305do {                                                             \
1306   assert(bitmap != NULL);                                             \
1307   assert(destx >= 0);                                                \
1308   assert(destx + length <= bitmap->width);                              \
1309   assert(desty >= 0);                                                \
1310   assert(desty < bitmap->height);                                       \
1311   assert(srcptr != NULL);                                             \
1312   assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority != NULL);                  \
1313                                                               \
1314   {                                                            \
1315      PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, desty, destx); \
1316      PIXEL_TYPE *destptr = BITMAP_ADDR(bitmap, PIXEL_TYPE, desty, destx);      \
1317                                                               \
1318      /* iterate over unrolled blocks of 4 */                              \
1319      while (length >= 4)                                             \
1320      {                                                         \
1321         PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                      \
1322         PIXEL_OP(destptr[1], priptr[1], srcptr[1]);                      \
1323         PIXEL_OP(destptr[2], priptr[2], srcptr[2]);                      \
1324         PIXEL_OP(destptr[3], priptr[3], srcptr[3]);                      \
1325                                                               \
1326         length -= 4;                                             \
1327         srcptr += 4;                                             \
1328         destptr += 4;                                             \
1329         PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4);                        \
1330      }                                                         \
1331                                                               \
1332      /* iterate over leftover pixels */                                 \
1333      while (length-- > 0)                                          \
1334      {                                                         \
1335         PIXEL_OP(destptr[0], priptr[0], srcptr[0]);                      \
1336         srcptr++;                                                \
1337         destptr++;                                                \
1338         PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1);                        \
1339      }                                                         \
1340   }                                                            \
1341} while (0)
1342
1343
1344
1345/***************************************************************************
1346    BASIC EXTRACTSCANLINE CORE
1347***************************************************************************/
1348
1349/*
1350    Assumed input parameters:
1351
1352        bitmap_t *bitmap - the bitmap to extract from
1353        INT32 srcx - the X coordinate to begin extraction
1354        INT32 srcy - the Y coordinate to begin extraction
1355        INT32 length - the total number of pixels to extract
1356        UINTx *destptr - pointer to memory to receive the extracted pixels
1357*/
1358
1359#define EXTRACTSCANLINE_CORE(PIXEL_TYPE)                                 \
1360do {                                                             \
1361   assert(bitmap != NULL);                                             \
1362   assert(srcx >= 0);                                                \
1363   assert(srcx + length <= bitmap->width);                                 \
1364   assert(srcy >= 0);                                                \
1365   assert(srcy < bitmap->height);                                       \
1366   assert(destptr != NULL);                                          \
1367                                                               \
1368   {                                                            \
1369      const PIXEL_TYPE *srcptr = BITMAP_ADDR(bitmap, PIXEL_TYPE, srcy, srcx);      \
1370                                                               \
1371      /* iterate over unrolled blocks of 4 */                              \
1372      while (length >= 4)                                             \
1373      {                                                         \
1374         destptr[0] = srcptr[0];                                        \
1375         destptr[1] = srcptr[1];                                        \
1376         destptr[2] = srcptr[2];                                        \
1377         destptr[3] = srcptr[3];                                        \
1378         length -= 4;                                             \
1379         srcptr += 4;                                             \
1380         destptr += 4;                                             \
1381      }                                                         \
1382                                                               \
1383      /* iterate over leftover pixels */                                 \
1384      while (length > 0)                                             \
1385      {                                                         \
1386         destptr[0] = srcptr[0];                                        \
1387         length--;                                                \
1388         srcptr++;                                                \
1389         destptr++;                                                \
1390      }                                                         \
1391   }                                                            \
1392} while (0)
1393
1394
1395#endif   /* __DRAWGFXM_H__ */
src/emu/mconfig.h
r4135r4136
1616
1717#include "devintrf.h"
1818#include "cpuexec.h"
19#include "sndintrf.h"
1920#include <stddef.h>
2021
2122
r4135r4136
132133
133134   palette_init_func      init_palette;         /* one-time palette init callback  */
134135   video_start_func      video_start;         /* one-time video start callback */
135   sound_reset_func      video_reset;         /* video reset callback */
136   video_reset_func      video_reset;         /* video reset callback */
136137   video_eof_func         video_eof;            /* end-of-frame video callback */
137138   video_update_func       video_update;          /* video update callback */
138139
r4135r4136
172173   palette_init_func palette_init;
173174   video_eof_func video_eof;
174175   video_update_func video_update;
176   sound_type sndtype;
175177};
176178
177179
r4135r4136
375377
376378/* add/remove/replace sounds */
377379#define MDRV_SOUND_ADD(_tag, _type, _clock) \
378   TOKEN_UINT64_PACK3(MCONFIG_TOKEN_SOUND_ADD, 8, SOUND_##_type, 24, _clock, 32), \
380   TOKEN_UINT64_PACK2(MCONFIG_TOKEN_SOUND_ADD, 8, _clock, 32), \
381   TOKEN_PTR(sndtype, SOUND_##_type), \
379382   TOKEN_STRING(_tag),
380383
381384#define MDRV_SOUND_REMOVE(_tag) \
r4135r4136
391394   TOKEN_PTR(voidptr, &(_config)),
392395
393396#define MDRV_SOUND_REPLACE(_tag, _type, _clock) \
394   TOKEN_UINT64_PACK3(MCONFIG_TOKEN_SOUND_REPLACE, 8, SOUND_##_type, 24, _clock, 32), \
397   TOKEN_UINT64_PACK2(MCONFIG_TOKEN_SOUND_REPLACE, 8, _clock, 32), \
398   TOKEN_PTR(sndtype, SOUND_##_type), \
395399   TOKEN_STRING(_tag),
396400
397401#define MDRV_SOUND_ROUTE_EX(_output, _target, _gain, _input)         \
src/emu/emupal.h
r4135r4136
7474
7575    1) declare MDRV_VIDEO_ATTRIBUTES( ... VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS ... )
7676
77    2) set gfx_drawmode_table[0-n] to DRAWMODE_NONE, DRAWMODE_SOURCE or DRAWMODE_SHADOW
77    2) make a pen table fill with DRAWMODE_NONE, DRAWMODE_SOURCE or DRAWMODE_SHADOW
7878
7979    3) (optional) set shadow darkness or highlight brightness by
8080        palette_set_shadow_factor(0.0-1.0) or
r4135r4136
8484        palette_set_shadow_mode(0) to arm shadows or
8585        palette_set_shadow_mode(1) to arm highlights
8686
87    5) call drawgfx with the TRANSPARENCY_PEN_TABLE flag
88        drawgfx( ..., cliprect, TRANSPARENCY_PEN_TABLE, transparent_color )
87    5) call drawgfx_transtable
88        drawgfx_transtable( ..., pentable )
8989
9090******************************************************************************/
9191
src/lib/util/palette.c
r4135r4136
230230
231231
232232/*-------------------------------------------------
233    palette_get_max_index - return the maximum
234    allowed index (i.e., length of arrays returned
235    by palette_entry_list*)
236-------------------------------------------------*/
237
238int palette_get_max_index(palette_t *palette)
239{
240   return palette->numcolors * palette->numgroups + 2;
241}
242
243
244/*-------------------------------------------------
233245    palette_get_black_entry - return the index of
234246    the black entry
235247-------------------------------------------------*/
src/lib/util/palette.h
r4135r4136
8181/* return the number of groups managed by the palette */
8282int palette_get_num_groups(palette_t *palette);
8383
84/* return the maximum allowed index (i.e., length of arrays returned by palette_entry_list*) */
85int palette_get_max_index(palette_t *palette);
86
8487/* return the index of the black entry */
8588UINT32 palette_get_black_entry(palette_t *palette);
8689
src/lib/util/bitmap.c
r4135r4136
7272   bitmap->bpp = bpp;
7373   bitmap->rowpixels = rowpixels;
7474   bitmap->base = (UINT8 *)bitmap->alloc + (rowpixels * yslop + xslop) * (bpp / 8);
75   bitmap->cliprect.min_x = 0;
76   bitmap->cliprect.max_x = width - 1;
77   bitmap->cliprect.min_y = 0;
78   bitmap->cliprect.max_y = height - 1;
7579
7680   return bitmap;
7781}
r4135r4136
104108   bitmap->bpp = bpp;
105109   bitmap->rowpixels = rowpixels;
106110   bitmap->base = base;
111   bitmap->cliprect.min_x = 0;
112   bitmap->cliprect.max_x = width - 1;
113   bitmap->cliprect.min_y = 0;
114   bitmap->cliprect.max_y = height - 1;
107115
108116   return bitmap;
109117}
r4135r4136
164172
165173void bitmap_fill(bitmap_t *dest, const rectangle *cliprect, UINT32 color)
166174{
167   rectangle fill;
175   rectangle fill = dest->cliprect;
168176   int x, y;
169177
170   /* default to the whole bitmap */
171   fill.min_x = fill.min_y = 0;
172   fill.max_x = dest->width - 1;
173   fill.max_y = dest->height - 1;
174
175178   /* if we have a cliprect, intersect with that */
176179   if (cliprect != NULL)
177180      sect_rect(&fill, cliprect);
src/lib/util/bitmap.h
r4135r4136
6161   bitmap_format   format;         /* format of the bitmap */
6262   int            bpp;         /* bits per pixel */
6363   palette_t *      palette;      /* optional palette */
64   rectangle      cliprect;      /* a clipping rectangle covering the full bitmap */
6465};
6566
6667
src/mess/video/pdp1.c
r4135r4136
378378   for (y=0; y<typewriter_window_height-typewriter_scroll_step; y++)
379379   {
380380      extract_scanline8(typewriter_bitmap, 0, y+typewriter_scroll_step, typewriter_window_width, buf);
381      draw_scanline8(typewriter_bitmap, 0, y, typewriter_window_width, buf, machine->pens, -1);
381      draw_scanline8(typewriter_bitmap, 0, y, typewriter_window_width, buf, machine->pens);
382382   }
383383
384384   bitmap_fill(typewriter_bitmap, &typewriter_scroll_clear_window, pen_typewriter_bg);
src/mess/video/mbee.c
r4135r4136
7777      int chr = 0x80 + offset / 16;
7878      pcgram[0x0800+offset] = data;
7979      /* decode character graphics again */
80      decodechar(space->machine->gfx[0], chr, pcgram);
80      gfx_element_mark_dirty(space->machine->gfx[0], chr);
8181   }
8282}
8383
r4135r4136
9090         int chr = 0x80 + offset / 16;
9191         pcgram[0x0800+offset] = data;
9292         /* decode character graphics again */
93         decodechar(space->machine->gfx[0], chr, pcgram);
93         gfx_element_mark_dirty(space->machine->gfx[0], chr);
9494      }
9595   }
9696   else
r4135r4136
352352      addr = 0x17000+((data & 32) << 6);
353353      memcpy(pcgram, memory_region(space->machine, "main")+addr, 0x800);
354354      for (i = 0; i < 128; i++)
355         decodechar(space->machine->gfx[0],i, pcgram);
355         gfx_element_mark_dirty(space->machine->gfx[0], i);
356356      break;
357357   case 13:
358358      crt.screen_address_lo = data;
r4135r4136
475475   for ( i = 0; i < ARRAY_LENGTH(mc6845_cursor); i++)
476476      pcgram[0x1000+i] = pcgram[(videoram[cursor]<<4) + i] ^ mc6845_cursor[i];
477477
478   decodechar(screen->machine->gfx[0],256, pcgram);         // and into machine graphics
478   gfx_element_mark_dirty(screen->machine->gfx[0],256);         // and into machine graphics
479479
480480   for( i = 0; i < bytes; i++ )
481481   {
r4135r4136
517517   for ( i = 0; i < ARRAY_LENGTH(mc6845_cursor); i++)
518518      pcgram[0x1000+i] = pcgram[(videoram[cursor]<<4) + i] ^ mc6845_cursor[i];
519519
520   decodechar(screen->machine->gfx[0],256, pcgram);         // and into machine graphics
520   gfx_element_mark_dirty(screen->machine->gfx[0],256);         // and into machine graphics
521521
522522   for( i = 0; i < bytes; i++ )
523523   {
src/mess/video/thomson.c
r4135r4136
989989   ypos = thom_bheight /* * scale */;
990990   for ( y = 0; y < 200; v += xwidth, y++ , ypos ++ /* += scale */ )
991991   {
992      draw_scanline16( bitmap, xbleft, ypos, xwidth, v, NULL, -1 );
992      draw_scanline16( bitmap, xbleft, ypos, xwidth, v, NULL );
993993#if 0
994994      if ( thom_hires )
995         draw_scanline16( bitmap, xbleft, ypos+1, xwidth, v, NULL, -1 );
995         draw_scanline16( bitmap, xbleft, ypos+1, xwidth, v, NULL );
996996#endif
997997   }
998998
src/mess/video/x68k.c
r4135r4136
958958         break;
959959
960960   /* create the char set (gfx will then be updated dynamically from RAM) */
961   machine->gfx[gfx_index] = allocgfx(machine, &x68k_pcg_8);
962   decodegfx(machine->gfx[gfx_index] , memory_region(machine, "user1"), 0, 256);
963   machine->gfx[gfx_index]->total_colors = 32;
961   machine->gfx[gfx_index] = gfx_element_alloc(machine, &x68k_pcg_8, memory_region(machine, "user1"), 32, 0);
964962
965963   gfx_index++;
966964
967   machine->gfx[gfx_index] = allocgfx(machine, &x68k_pcg_16);
968   decodegfx(machine->gfx[gfx_index] , memory_region(machine, "user1"), 0, 256);
965   machine->gfx[gfx_index] = gfx_element_alloc(machine, &x68k_pcg_16, memory_region(machine, "user1"), 32, 0);
969966   machine->gfx[gfx_index]->total_colors = 32;
970967
971968   /* Tilemaps */
r4135r4136
10241021   {
10251022      if(sys.video.tile16_dirty[x] != 0)
10261023      {
1027         decodechar(screen->machine->gfx[1], x, rom);
1024         gfx_element_mark_dirty(screen->machine->gfx[1], x);
10281025         sys.video.tile16_dirty[x] = 0;
10291026      }
10301027      if(sys.video.tile8_dirty[x] != 0)
10311028      {
1032         decodechar(screen->machine->gfx[0], x, rom);
1029         gfx_element_mark_dirty(screen->machine->gfx[0], x);
10331030         sys.video.tile8_dirty[x] = 0;
10341031      }
10351032   }
src/mess/video/spectrum.c
r4135r4136
118118
119119    for (count=0;count<32*8;count++)
120120    {
121         decodechar( screen->machine->gfx[0],count,spectrum_characterram);
122         decodechar( screen->machine->gfx[1],count,&spectrum_characterram[0x800]);
123         decodechar( screen->machine->gfx[2],count,&spectrum_characterram[0x1000]);
121      gfx_element_mark_dirty( screen->machine->gfx[0],count);
122      gfx_element_mark_dirty( screen->machine->gfx[1],count);
123      gfx_element_mark_dirty( screen->machine->gfx[2],count);
124124   }
125125
126126    for (count=0;count<32*8;count++)
src/mess/video/tx0.c
r4135r4136
363363   for (y=0; y<typewriter_window_height-typewriter_scroll_step; y++)
364364   {
365365      extract_scanline8(typewriter_bitmap, 0, y+typewriter_scroll_step, typewriter_window_width, buf);
366      draw_scanline8(typewriter_bitmap, 0, y, typewriter_window_width, buf, machine->pens, -1);
366      draw_scanline8(typewriter_bitmap, 0, y, typewriter_window_width, buf, machine->pens);
367367   }
368368
369369   bitmap_fill(typewriter_bitmap, &typewriter_scroll_clear_window, pen_typewriter_bg);
src/mess/video/vdc8563.c
r4135r4136
565565      {
566566         if (full_refresh||vdc.fontdirty[i])
567567         {
568            decodechar(screen->machine->gfx[0],i,vdc.ram+(vdc.fontram_start&vdc.mask));
568            gfx_element_mark_dirty(screen->machine->gfx[0],i);
569569            vdc.fontdirty[i]=0;
570570         }
571571      }
src/mess/video/amstrad.c
r4135r4136
940940         xloc += rect.min_x;
941941         yloc = amstrad_plus_asic_ram[sprptr+2] + (amstrad_plus_asic_ram[sprptr+3] << 8);
942942         yloc += rect.min_y;
943         decodechar(machine->gfx[0],spr,amstrad_plus_asic_ram);
944943         drawgfxzoom(scr_bitmap,machine->gfx[0],spr,0,0,0,xloc,yloc,&rect,
945944            TRANSPARENCY_PEN,0,xmag,ymag);
946945      }
src/mess/video/avigo.c
r4135r4136
116116
117117   /* allocate video memory */
118118   avigo_video_memory = auto_malloc(((AVIGO_SCREEN_WIDTH>>3)*AVIGO_SCREEN_HEIGHT));
119   machine->gfx[0] = stylus_pointer = allocgfx(machine, &pointerlayout);
119   machine->gfx[0] = stylus_pointer = gfx_element_alloc(machine, &pointerlayout, pointermask, machine->config->total_colors / 16, 0);
120120
121   decodegfx(stylus_pointer, pointermask, 0, 1);
122121   stylus_pointer->total_colors = 3;
123122}
124123
src/mess/video/ted7360.c
r4135r4136
951951   return val;
952952}
953953
954static void ted7360_video_stop(running_machine *machine)
955{
956   freegfx(cursorelement);
957}
958
959954VIDEO_START( ted7360 )
960955{
961956   const device_config *screen = video_screen_first(machine->config);
962957   int width = video_screen_get_width(screen);
963958   int height = video_screen_get_height(screen);
964959
965   cursorelement = allocgfx(machine, &cursorlayout);
966   decodegfx(cursorelement, cursormask, 0, 1);
960   cursorelement = gfx_element_alloc(machine, &cursorlayout, cursormask, machine->config->total_colors / 16, 0);
967961   /* 7-Sep-2007 - After 0.118u5, you cannot revector the color table */
968962   /* cursorelement->colortable = cursorcolortable; */
969963   cursorcolortable[1] = 1;
970964   cursorelement->total_colors = 2;
971965   ted7360_bitmap = auto_bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED16);
972   add_exit_callback(machine, ted7360_video_stop);
973966}
974967
975968static void ted7360_draw_character (running_machine *machine, int ybegin, int yend, int ch, int yoff, int xoff,
src/mess/video/733_asr.c
r4135r4136
224224   for (y=asr_window_offset_y; y<asr_window_offset_y+asr_window_height-asr_scroll_step; y++)
225225   {
226226      extract_scanline8(asr[unit].bitmap, asr_window_offset_x, y+asr_scroll_step, asr_window_width, buf);
227      draw_scanline8(asr[unit].bitmap, asr_window_offset_x, y, asr_window_width, buf, machine->pens, -1);
227      draw_scanline8(asr[unit].bitmap, asr_window_offset_x, y, asr_window_width, buf, machine->pens);
228228   }
229229
230230   bitmap_fill(asr[unit].bitmap, &asr_scroll_clear_window, 0);
src/mess/machine/apple3.c
r4135r4136
662662   if ((address & 0xFF00) == 0x0000)
663663   {
664664      opptr = apple3_get_zpa_addr(address);
665      direct->mask = ~0;
665      direct->bytemask = ~0;
666666      direct->raw = direct->decrypted = opptr - address;
667      direct->min = address;
668      direct->max = address;
667      direct->bytestart = address;
668      direct->byteend = address;
669669      address = ~0;
670670   }
671671   return address;
src/mess/machine/cdp1871.c
r4135r4136
206206   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
207207   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
208208   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
209   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('�')
209   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR(0xFFFD)
210210
211211   PORT_START("D2")
212212   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
src/mess/machine/osborne1.c
r4135r4136
219219   {
220220      if ( ! osborne1.bank2_enabled )
221221      {
222         direct->mask = 0x0fff;
222         direct->bytemask = 0x0fff;
223223         direct->decrypted = mess_ram + 0x2000;
224224         direct->raw = mess_ram + 0x2000;
225         direct->min = 0x2000;
226         direct->max = 0x2fff;
225         direct->bytestart = 0x2000;
226         direct->byteend = 0x2fff;
227227         return ~0;
228228      }
229229   }
src/mess/machine/apple2gs.c
r4135r4136
16011601
16021602      if (opptr != NULL)
16031603      {
1604         direct->mask = ~0;
1604         direct->bytemask = ~0;
16051605         direct->raw = direct->decrypted = opptr - address;
1606         direct->min = address;
1607         direct->max = address;
1606         direct->bytestart = address;
1607         direct->byteend = address;
16081608         address = ~0;
16091609      }
16101610   }
src/mess/machine/lisa.c
r4135r4136
925925      for (x = 0; x < resx; x++)
926926//         line_buffer[x] = (v[(x+y*resx)>>4] & (0x8000 >> ((x+y*resx) & 0xf))) ? 0 : 1;
927927         line_buffer[x] = (v[(x+y*resx)>>4] & (0x8000 >> (x & 0xf))) ? 0 : 1;
928      draw_scanline8(bitmap, 0, y, resx, line_buffer, screen->machine->pens, -1);
928      draw_scanline8(bitmap, 0, y, resx, line_buffer, screen->machine->pens);
929929   }
930930   return 0;
931931}
r4135r4136
956956         }
957957         else
958958         {   /* system ROMs */
959            direct->mask = 0xffffff;
959            direct->bytemask = 0xffffff;
960960            direct->raw = direct->decrypted = lisa_rom_ptr - (address & 0xffc000);
961            direct->min = (address & 0xffc000);
962            direct->max = (address & 0xffc000) + 0x003fff;
961            direct->bytestart = (address & 0xffc000);
962            direct->byteend = (address & 0xffc000) + 0x003fff;
963963            /*logerror("ROM (setup mode)\n");*/
964964         }
965965
r4135r4136
988988            /* out of segment limits : bus error */
989989            logerror("illegal opbase address%lX\n", (long) address);
990990         }
991         direct->mask = 0xffffff;
991         direct->bytemask = 0xffffff;
992992         direct->raw = direct->decrypted = lisa_ram_ptr + mapped_address - address;
993         direct->min = (address & 0xffc000);
994         direct->max = (address & 0xffc000) + 0x003fff;
993         direct->bytestart = (address & 0xffc000);
994         direct->byteend = (address & 0xffc000) + 0x003fff;
995995         /*logerror("RAM\n");*/
996996         break;
997997
r4135r4136
10041004         break;
10051005
10061006      case special_IO:
1007         direct->mask = 0xffffff;
1007         direct->bytemask = 0xffffff;
10081008         direct->raw = direct->decrypted = lisa_rom_ptr + (mapped_address & 0x003fff) - address;
1009         direct->min = (address & 0xffc000);
1010         direct->max = (address & 0xffc000) + 0x003fff;
1009         direct->bytestart = (address & 0xffc000);
1010         direct->byteend = (address & 0xffc000) + 0x003fff;
10111011         /*logerror("ROM\n");*/
10121012         break;
10131013      }
src/mess/machine/c64.c
r4135r4136
11041104   {
11051105      if (c64_io_enabled)
11061106      {
1107         direct->mask = 0x0fff;
1107         direct->bytemask = 0x0fff;
11081108         direct->decrypted = c64_io_mirror;
11091109         direct->raw = c64_io_mirror;
1110         direct->min = 0x0000;
1111         direct->max = 0xcfff;
1110         direct->bytestart = 0x0000;
1111         direct->byteend = 0xcfff;
11121112         c64_io_mirror[address & 0x0fff] = c64_read_io( space, address & 0x0fff );
11131113      }
11141114      else
11151115      {
1116         direct->mask = 0x0fff;
1116         direct->bytemask = 0x0fff;
11171117         direct->decrypted = c64_io_ram_r_ptr;
11181118         direct->raw = c64_io_ram_r_ptr;
1119         direct->min = 0x0000;
1120         direct->max = 0xcfff;
1119         direct->bytestart = 0x0000;
1120         direct->byteend = 0xcfff;
11211121      }
11221122      return ~0;
11231123   }
src/mess/mess.mak
r4135r4136
176176CPUS += V810
177177#CPUS += M37702
178178#CPUS += M37710
179#CPUS += POWERPC
179CPUS += POWERPC
180180#CPUS += SE3208
181181#CPUS += MC68HC11
182182#CPUS += ADSP21062
r4135r4136
185185#CPUS += ALPHA8201
186186#CPUS += ALPHA8301
187187CPUS += CDP1802
188#CPUS += COP401
189#CPUS += COP410
190CPUS += COP411
191#CPUS += COP402
192CPUS += COP420
193#CPUS += COP421
194#CPUS += COP422
195#CPUS += COP404
196#CPUS += COP424
197#CPUS += COP425
198#CPUS += COP426
199#CPUS += COP444
200#CPUS += COP445
188CPUS += COP400
201189#CPUS += TLCS90
202190#CPUS += MB8841
203191#CPUS += MB8842
r4135r4136
218206CPUS += TMS7000_EXL
219207CPUS += SM8500
220208CPUS += MINX
209#CPUS += COP401
210#CPUS += COP410
211CPUS += COP411
212#CPUS += COP402
213CPUS += COP420
214#CPUS += COP421
215#CPUS += COP422
216#CPUS += COP404
217#CPUS += COP424
218#CPUS += COP425
219#CPUS += COP426
220#CPUS += COP444
221#CPUS += COP445
221222CPUS += I8035
222223#CPUS += I8041
223224CPUS += I8048
r4135r4136
233234CPUS += I8042
234235#CPUS += I8242
235236#CPUS += I8742
236CPUS += POWERPC
237237#CPUS += PPC403GA
238238#CPUS += PPC403GCX
239239#CPUS += PPC601
r4135r4136
323323#SOUNDS += MSM5232
324324SOUNDS += OKIM6258
325325SOUNDS += OKIM6295
326#SOUNDS += OKIM6376
326327#SOUNDS += UPD7759
327328#SOUNDS += HC55516
328329#SOUNDS += K005289
r4135r4136
363364SOUNDS += SID6581
364365SOUNDS += SID8580
365366SOUNDS += SP0256
367#SOUNDS += DIGITALKER
366368
367369
368370#-------------------------------------------------
src/mess/drivers/zx.c
r4135r4136
2727
2828#include "driver.h"
2929#include "cpu/z80/z80.h"
30#include "sound/dac.h"
31#include "sound/wave.h"
3032#include "includes/zx.h"
3133#include "devices/cassette.h"
3234#include "formats/zx81_p.h"
src/mess/drivers/jaguar.c
r4135r4136
4949#include "includes/jaguar.h"
5050#include "devices/cartslot.h"
5151#include "devices/snapquik.h"
52#include "sound/dac.h"
5253
5354#define JAGUAR_CLOCK      XTAL_52MHz
5455#define R3000_CLOCK         XTAL_40MHz
src/mess/drivers/apple2gs.c
r4135r4136
5656#include "machine/mockngbd.h"
5757#include "machine/8530scc.h"
5858#include "sound/ay8910.h"
59#include "sound/dac.h"
5960
6061static const gfx_layout apple2gs_text_layout =
6162{
src/mess/drivers/hp48.c
r4135r4136
1414#include "devices/xmodem.h"
1515#include "devices/kermit.h"
1616#include "cpu/saturn/saturn.h"
17#include "sound/dac.h"
1718
1819#include "includes/hp48.h"
1920
src/mess/drivers/dai.c
r4135r4136
6060
6161#include "driver.h"
6262#include "cpu/i8085/i8085.h"
63#include "sound/wave.h"
6364#include "machine/8255ppi.h"
6465#include "includes/dai.h"
6566#include "machine/pit8253.h"
src/mess/drivers/atari.c
r4135r4136
1414#include "sound/pokey.h"
1515#include "machine/6821pia.h"
1616#include "video/gtia.h"
17#include "sound/dac.h"
1718
1819/******************************************************************************
1920    Atari 800 memory map (preliminary)
src/mess/drivers/mbee.c
r4135r4136
4646
4747#include "driver.h"
4848#include "cpu/z80/z80.h"
49#include "cpu/z80/z80daisy.h"
50#include "sound/speaker.h"
51#include "sound/wave.h"
4952#include "machine/z80pio.h"
50#include "cpu/z80/z80daisy.h"
5153#include "machine/wd17xx.h"
5254#include "includes/mbee.h"
5355#include "devices/snapquik.h"
r4135r4136
5557#include "devices/cartslot.h"
5658#include "devices/cassette.h"
5759#include "devices/z80bin.h"
58#include "sound/speaker.h"
5960
6061static const device_config *cassette_device_image(running_machine *machine)
6162{
src/mess/drivers/coco.c
r4135r4136
1313#include "driver.h"
1414#include "cpu/m6809/m6809.h"
1515#include "cpu/hd6309/hd6309.h"
16#include "sound/wave.h"
1617#include "machine/6821pia.h"
1718#include "video/m6847.h"
1819#include "machine/msm6242.h"
r4135r4136
3233#include "devices/cartslot.h"
3334#include "devices/coco_vhd.h"
3435#include "sound/ay8910.h"
36#include "sound/dac.h"
3537#include "coco3.lh"
3638
3739#define SHOW_FULL_AREA         0
src/mess/drivers/ti99_8.c
r4135r4136
161161#include "devices/cartslot.h"
162162#include "machine/smartmed.h"
163163#include "sound/5220intf.h"
164#include "sound/sn76496.h"
165#include "sound/wave.h"
164166#include "devices/harddriv.h"
165167#include "machine/idectrl.h"
166168
src/mess/drivers/kim1.c
r4135r4136
8181
8282#include "driver.h"
8383#include "cpu/m6502/m6502.h"
84#include "sound/dac.h"
8485#include "machine/6530miot.h"
8586#include "devices/cassette.h"
8687#include "formats/kim1_cas.h"
src/mess/drivers/msx.c
r4135r4136
290290#include "devices/cassette.h"
291291#include "formats/fmsx_cas.h"
292292#include "sound/ay8910.h"
293#include "sound/dac.h"
294#include "sound/wave.h"
295#include "sound/k051649.h"
296#include "sound/2413intf.h"
293297
294298static ADDRESS_MAP_START (readmem, ADDRESS_SPACE_PROGRAM, 8)
295299   AM_RANGE( 0x0000, 0x1fff) AM_READ( SMH_BANK1 )
src/mess/drivers/tmc600.c
r4135r4136
8585#include "devices/cassette.h"
8686#include "devices/snapquik.h"
8787#include "cpu/cdp1802/cdp1802.h"
88#include "sound/cdp1869.h"
8889#include "includes/tmc600.h"
8990#include "video/cdp1869.h"
9091
src/mess/drivers/advision.c
r4135r4136
2121#include "cpu/mcs48/mcs48.h"
2222#include "cpu/cop400/cop400.h"
2323#include "devices/cartslot.h"
24#include "sound/dac.h"
2425
2526/* Memory Maps */
2627 
src/mess/drivers/radio86.c
r4135r4136
99
1010#include "driver.h"
1111#include "cpu/i8085/i8085.h"
12#include "sound/wave.h"
1213#include "machine/8255ppi.h"
1314#include "machine/8257dma.h"
1415#include "video/i8275.h"
r4135r4136
316317static DIRECT_UPDATE_HANDLER( radio16_direct )
317318{   
318319   if (address >= 0x4000 && address <=0x7FFF) {
319         direct->mask = 0xffff;
320         direct->bytemask = 0xffff;
320321         direct->raw = radio16_io_mirror;
321322         direct->decrypted = radio16_io_mirror;
322         direct->min = 0x4000;
323         direct->max = 0x7fff;
323         direct->bytestart = 0x4000;
324         direct->byteend = 0x7fff;
324325         radio16_io_mirror[address] = cpu_get_reg(space->machine->cpu[0], I8085_STATUS);
325326   }
326327   return address;
src/mess/drivers/mz700.c
r4135r4136
6666/* Core includes */
6767#include "driver.h"
6868#include "cpu/z80/z80.h"
69#include "sound/speaker.h"
70#include "sound/wave.h"
6971#include "machine/8255ppi.h"
7072#include "includes/mz700.h"
7173#include "machine/pit8253.h"
src/mess/drivers/vectrex.c
r4135r4136
1515#include "includes/vectrex.h"
1616#include "devices/cartslot.h"
1717#include "sound/ay8910.h"
18#include "sound/dac.h"
1819
1920static ADDRESS_MAP_START(vectrex_map, ADDRESS_SPACE_PROGRAM, 8)
2021   AM_RANGE(0x0000, 0x7fff) AM_ROM
src/mess/drivers/tm990189.c
r4135r4136
4444#include "video/tms9928a.h"
4545#include "devices/cassette.h"
4646#include "sound/speaker.h"
47#include "sound/wave.h"
4748
4849
4950static int load_state;
src/mess/drivers/dc.c
r4135r4136
126126static const aica_interface dc_aica_interface =
127127{
128128   0,
129   0,
129130   aica_irq
130131};
131132
src/mess/drivers/lisa.c
r4135r4136
1515#include "devices/sonydriv.h"
1616#include "machine/applefdc.h"
1717#include "machine/6522via.h"
18#include "sound/speaker.h"
1819
1920
2021/***************************************************************************
src/mess/drivers/sym1.c
r4135r4136
99
1010#include "driver.h"
1111#include "cpu/m6502/m6502.h"
12#include "sound/speaker.h"
1213#include "includes/sym1.h"
1314
1415/* Peripheral chips */
src/mess/drivers/cgenie.c
r4135r4136
3333#include "devices/cartslot.h"
3434#include "devices/cassette.h"
3535#include "sound/ay8910.h"
36#include "sound/dac.h"
3637#include "formats/cgen_cas.h"
3738
3839
src/mess/drivers/pmd85.c
r4135r4136
171171
172172#include "driver.h"
173173#include "cpu/i8085/i8085.h"
174#include "sound/wave.h"
174175#include "devices/cassette.h"
175176#include "includes/pmd85.h"
176177#include "machine/8255ppi.h"
src/mess/drivers/apexc.c
r4135r4136
576576   for (y=teletyper_window_offset_y; y<teletyper_window_offset_y+teletyper_window_height-teletyper_scroll_step; y++)
577577   {
578578      extract_scanline8(apexc_bitmap, teletyper_window_offset_x, y+teletyper_scroll_step, teletyper_window_width, buf);
579      draw_scanline8(apexc_bitmap, teletyper_window_offset_x, y, teletyper_window_width, buf, machine->pens, -1);
579      draw_scanline8(apexc_bitmap, teletyper_window_offset_x, y, teletyper_window_width, buf, machine->pens);
580580   }
581581
582582   bitmap_fill(apexc_bitmap, &teletyper_scroll_clear_window, 0);
src/mess/drivers/spectrum.c
r4135r4136
146146
147147#include "driver.h"
148148#include "cpu/z80/z80.h"
149#include "sound/speaker.h"
150#include "sound/wave.h"
149151#include "includes/spectrum.h"
150152#include "eventlst.h"
151153#include "devices/snapquik.h"
152154#include "devices/cartslot.h"
153155#include "devices/cassette.h"
154#include "sound/speaker.h"
155156#include "formats/tzx_cas.h"
156157
157158
src/mess/drivers/ondra.c
r4135r4136
99
1010#include "driver.h"
1111#include "cpu/z80/z80.h"
12#include "sound/wave.h"
1213#include "devices/cassette.h"
1314#include "includes/ondra.h"
1415
src/mess/drivers/super80.c
r4135r4136
22
33#include "driver.h"
44#include "cpu/z80/z80.h"
5#include "cpu/z80/z80daisy.h"
6#include "sound/wave.h"
57#include "machine/z80pio.h"
6#include "cpu/z80/z80daisy.h"
78#include "devices/snapquik.h"
89#include "devices/cartslot.h"
910#include "devices/cassette.h"
r4135r4136
153154         pcgram[0x800+offset] = data;
154155
155156         /* decode character graphics again */
156         decodechar(space->machine->gfx[0], chr, pcgram);
157         gfx_element_mark_dirty(space->machine->gfx[0], chr);
157158      }
158159   }
159160}
r4135r4136
306307      for ( i = 0; i < ARRAY_LENGTH(mc6845_cursor); i++)
307308         pcgram[0x1000+i] = pcgram[(videoram[cursor])*16 + i] ^ mc6845_cursor[i];
308309
309   decodechar(screen->machine->gfx[0],256, pcgram);         // and into machine graphics
310   gfx_element_mark_dirty(screen->machine->gfx[0],256);         // and into machine graphics
310311
311312   for( i = 0; i < bytes; i++ )
312313   {
src/mess/drivers/n64.c
r4135r4136
1010#include "cpu/rsp/rsp.h"
1111#include "cpu/mips/mips3.h"
1212#include "sound/custom.h"
13#include "sound/dmadac.h"
1314#include "devices/cartslot.h"
1415#include "includes/n64.h"
1516
src/mess/drivers/geneve.c
r4135r4136
199199
200200#include "driver.h"
201201#include "cpu/tms9900/tms9900.h"
202#include "sound/sn76496.h"
202203#include "deprecat.h"
203204#include "video/v9938.h"
204205#include "includes/geneve.h"
src/mess/drivers/ip22.c
r4135r4136
4040
4141#include "driver.h"
4242#include "cpu/mips/mips3.h"
43#include "sound/cdda.h"
4344#include "machine/sgi.h"
4445#include "machine/pckeybrd.h"
4546#include "includes/pc_mouse.h"
src/mess/drivers/c128.c
r4135r4136
174174#include "cpu/z80/z80.h"
175175#include "cpu/m6502/m6502.h"
176176#include "sound/sid6581.h"
177#include "sound/dac.h"
177178#include "machine/6526cia.h"
178179
179180#include "machine/cbmipt.h"
src/mess/drivers/lviv.c
r4135r4136
282282
283283#include "driver.h"
284284#include "cpu/i8085/i8085.h"
285#include "sound/speaker.h"
286#include "sound/wave.h"
285287#include "machine/8255ppi.h"
286288#include "includes/lviv.h"
287289#include "devices/snapquik.h"
src/mess/drivers/exidy.c
r4135r4136
135135So far, it has been tested to work at 300 baud.
136136
137137********************************************************************************/
138
138139#include "driver.h"
140#include "cpu/z80/z80.h"
141#include "sound/speaker.h"
142#include "sound/wave.h"
139143#include "includes/exidy.h"
140144#include "machine/centroni.h"
141#include "cpu/z80/z80.h"
142145#include "machine/wd17xx.h"
143146#include "devices/basicdsk.h"
144147#include "devices/cassette.h"
r4135r4136
146149#include "devices/cartslot.h"
147150#include "devices/printer.h"
148151#include "devices/z80bin.h"
149#include "sound/speaker.h"
150152#include "machine/ay31015.h"
151153
152154
src/mess/drivers/pc8801.c
r4135r4136
66
77#include "driver.h"
88#include "cpu/z80/z80.h"
9#include "sound/beep.h"
910#include "machine/8255ppi.h"
1011#include "includes/pc8801.h"
1112#include "machine/nec765.h"
src/mess/drivers/p2000t.c
r4135r4136
2929#include "driver.h"
3030#include "includes/p2000t.h"
3131#include "cpu/z80/z80.h"
32#include "sound/speaker.h"
3233#include "video/saa5050.h"
3334
3435
src/mess/drivers/a2600.c
r4135r4136
77#include "driver.h"
88#include "machine/6532riot.h"
99#include "cpu/m6502/m6502.h"
10#include "sound/wave.h"
1011#include "sound/tiaintf.h"
1112#include "devices/cartslot.h"
1213#include "devices/cassette.h"
r4135r4136
738739static DIRECT_UPDATE_HANDLER( modeSS_opbase )
739740{
740741   if ( address & 0x1000 ) {
741      direct->mask = 0x7ff;
742      direct->min = ( address & 0xf800 );
743      direct->max = ( address & 0xf800 ) | 0x7ff;
742      direct->bytemask = 0x7ff;
743      direct->bytestart = ( address & 0xf800 );
744      direct->byteend = ( address & 0xf800 ) | 0x7ff;
744745      if ( address & 0x800 ) {
745746         direct->decrypted = bank_base[2];
746747         direct->raw = bank_base[2];
src/mess/drivers/oric.c
r4135r4136
1818
1919#include "driver.h"
2020#include "cpu/m6502/m6502.h"
21#include "sound/wave.h"
2122#include "includes/oric.h"
2223#include "machine/centroni.h"
2324#include "devices/printer.h"
src/mess/drivers/orao.c
r4135r4136
1313#include "driver.h"
1414#include "cpu/m6502/m6502.h"
1515#include "sound/dac.h"
16#include "sound/wave.h"
1617#include "includes/orao.h"
1718#include "devices/cassette.h"
1819#include "formats/orao_cas.h"
src/mess/drivers/mc10.c
r4135r4136
1010
1111#include "driver.h"
1212#include "cpu/m6800/m6800.h"
13#include "sound/dac.h"
1314#include "video/m6847.h"
1415#include "includes/mc10.h"
1516#include "devices/cassette.h"
src/mess/drivers/atom.c
r4135r4136
7474#include "devices/printer.h"
7575#include "devices/cassette.h"
7676#include "devices/snapquik.h"
77#include "sound/speaker.h"
7778
7879#include "includes/atom.h"
7980
src/mess/drivers/mekd2.c
r4135r4136
2828
2929#include "driver.h"
3030#include "cpu/m6800/m6800.h"
31#include "sound/dac.h"
3132#include "devices/cartslot.h"
3233#include "includes/mekd2.h"
3334
src/mess/drivers/at.c
r4135r4136
5252#include "machine/pci.h"
5353#include "machine/kb_keytro.h"
5454
55#include "sound/dac.h"
56#include "sound/speaker.h"
57#include "sound/saa1099.h"
58
5559/* window resizing with dirtybuffering traping in xmess window */
5660
5761#define ym3812_StdClock 3579545
src/mess/drivers/vector06.c
r4135r4136
1010#include "driver.h"
1111#include "cpu/z80/z80.h"
1212#include "cpu/i8085/i8085.h"
13#include "sound/wave.h"
1314#include "machine/8255ppi.h"
1415#include "machine/wd17xx.h"
1516#include "devices/cassette.h"
src/mess/drivers/vc20.c
r4135r4136
8484
8585#include "driver.h"
8686#include "cpu/m6502/m6502.h"
87#include "sound/dac.h"
8788
8889#include "machine/6522via.h"
8990#include "includes/vc1541.h"
src/mess/drivers/partner.c
r4135r4136
99
1010#include "driver.h"
1111#include "cpu/i8085/i8085.h"
12#include "sound/wave.h"
1213#include "machine/8255ppi.h"
1314#include "machine/8257dma.h"
1415#include "machine/wd17xx.h"
src/mess/drivers/electron.c
r4135r4136
2727#include "includes/electron.h"
2828#include "devices/cassette.h"
2929#include "formats/uef_cas.h"
30#include "sound/beep.h"
3031
3132static const rgb_t electron_palette[8]=
3233{
src/mess/drivers/mikrosha.c
r4135r4136
99
1010#include "driver.h"
1111#include "cpu/i8085/i8085.h"
12#include "sound/wave.h"
1213#include "machine/8255ppi.h"
1314#include "machine/8257dma.h"
1415#include "machine/pit8253.h"
r4135r4136
136137static DIRECT_UPDATE_HANDLER( mikrosha_direct )
137138{     
138139   if (address >= 0x8000 && address <=0xFFFF) {
139         direct->mask = 0xffff;
140         direct->bytemask = 0xffff;
140141         direct->raw = mikrosha_io_mirror;
141142         direct->decrypted = mikrosha_io_mirror;
142         direct->min = 0x8000;
143         direct->max = 0xffff;
143         direct->bytestart = 0x8000;
144         direct->byteend = 0xffff;
144145         mikrosha_io_mirror[address] = cpu_get_reg(space->machine->cpu[0], I8085_STATUS);
145146   }
146147   return address;
src/mess/drivers/amiga.c
r4135r4136
3030#include "machine/amigacd.h"
3131#include "machine/amigacrt.h"
3232#include "machine/msm6242.h"
33#include "sound/cdda.h"
3334
3435/* Devices */
3536#include "devices/chd_cd.h"
src/mess/drivers/ti990_10.c
r4135r4136
7070#include "driver.h"
7171
7272#include "cpu/tms9900/tms9900.h"
73#include "sound/beep.h"
7374#include "machine/ti990.h"
7475#include "machine/990_hd.h"
7576#include "machine/990_tap.h"
src/mess/drivers/orion.c
r4135r4136
1111#include "driver.h"
1212#include "cpu/z80/z80.h"
1313#include "cpu/i8085/i8085.h"
14#include "sound/ay8910.h"
15#include "sound/speaker.h"
16#include "sound/wave.h"
1417#include "machine/8255ppi.h"
1518#include "machine/mc146818.h"
1619#include "machine/wd17xx.h"
r4135r4136
1821#include "devices/cassette.h"
1922#include "devices/cartslot.h"
2023#include "formats/rk_cas.h"
21#include "sound/ay8910.h"
22#include "sound/speaker.h"
2324#include "includes/orion.h"
2425#include "includes/radio86.h"
2526
src/mess/drivers/bk.c
r4135r4136
99
1010#include "driver.h"
1111#include "cpu/t11/t11.h"
12#include "sound/wave.h"
1213#include "includes/bk.h"
1314#include "devices/cassette.h"
1415#include "formats/rk_cas.h"
src/mess/drivers/bebox.c
r4135r4136
1616#include "video/pc_vga.h"
1717#include "video/cirrus.h"
1818#include "cpu/powerpc/ppc.h"
19#include "sound/3812intf.h"
1920#include "machine/ins8250.h"
2021#include "machine/pic8259.h"
2122#include "machine/mc146818.h"
src/mess/drivers/a7800.c
r4135r4136
1515#include "driver.h"
1616#include "deprecat.h"
1717#include "cpu/m6502/m6502.h"
18#include "sound/pokey.h"
1819#include "sound/tiaintf.h"
1920#include "devices/cartslot.h"
2021#include "machine/6532riot.h"
src/mess/drivers/apogee.c
r4135r4136
99
1010#include "driver.h"
1111#include "cpu/i8085/i8085.h"
12#include "sound/wave.h"
1213#include "machine/8255ppi.h"
1314#include "machine/8257dma.h"
1415#include "video/i8275.h"
src/mess/drivers/microtan.c
r4135r4136
4242
4343/* Components */
4444#include "sound/ay8910.h"
45#include "sound/dac.h"
46#include "sound/wave.h"
4547#include "machine/6522via.h"
4648#include "machine/6551.h"
4749
src/mess/drivers/special.c
r4135r4136
1111#include "driver.h"
1212#include "cpu/z80/z80.h"
1313#include "cpu/i8085/i8085.h"
14#include "sound/dac.h"
15#include "sound/wave.h"
1416#include "includes/special.h"
1517#include "machine/8255ppi.h"
1618#include "machine/pit8253.h"
17#include "sound/dac.h"
1819#include "devices/cassette.h"
1920#include "devices/basicdsk.h"
2021#include "formats/rk_cas.h"
src/mess/drivers/jupiter.c
r4135r4136
240240   jupiter_charram[offset] = data;
241241
242242   /* decode character graphics again */
243   decodechar(space->machine->gfx[0], offset / 8, jupiter_charram);
244   decodechar(space->machine->gfx[1], offset / 8, jupiter_charram);
243   gfx_element_mark_dirty(space->machine->gfx[0], offset / 8);
244   gfx_element_mark_dirty(space->machine->gfx[1], offset / 8);
245245}
246246
247247
src/mess/drivers/osborne1.c
r4135r4136
3636
3737#include "driver.h"
3838#include "cpu/z80/z80.h"
39#include "cpu/z80/z80daisy.h"
40#include "sound/beep.h"
3941#include "devices/basicdsk.h"
4042#include "machine/wd17xx.h"
41#include "cpu/z80/z80daisy.h"
4243#include "includes/osborne1.h"
4344
4445
src/mess/drivers/mikro80.c
r4135r4136
99
1010#include "driver.h"
1111#include "cpu/i8085/i8085.h"
12#include "sound/wave.h"
1213#include "machine/8255ppi.h"
1314#include "includes/mikro80.h"
1415#include "devices/cassette.h"
src/mess/drivers/ssystem3.c
r4135r4136
3838#include "includes/ssystem3.h"
3939#include "machine/6522via.h"
4040#include "cpu/m6502/m6502.h"
41//#include "attotime.h"
41#include "sound/dac.h"
4242
4343static struct {
4444  UINT8 porta;
src/mess/drivers/vtech1.c
r4135r4136
101101/* Core includes */
102102#include "driver.h"
103103#include "cpu/z80/z80.h"
104#include "sound/wave.h"
104105#include "includes/vtech1.h"
105106
106107/* Components */
src/mess/drivers/amstrad.c
r4135r4136
8787#include "video/m6845.h"      /* CRTC display */
8888#include "machine/nec765.h"   /* for floppy disc controller */
8989#include "sound/ay8910.h"
90#include "sound/wave.h"
9091#include "machine/mc146818.h"  /* Aleste RTC */
9192
9293/* Devices */
src/mess/drivers/mz80.c
r4135r4136
88
99#include "driver.h"
1010#include "cpu/z80/z80.h"
11#include "sound/speaker.h"
12#include "sound/wave.h"
1113#include "machine/8255ppi.h"
1214#include "machine/pit8253.h"
1315#include "devices/cassette.h"
14#include "sound/speaker.h"
1516#include "includes/mz80.h"
1617 
1718static INPUT_PORTS_START( mz80k )
src/mess/drivers/a310.c
r4135r4136
296296   // if the boot ROM is mapped in, do some trickery to make it show up
297297   if (a310_latchrom)
298298   {
299      direct->mask = 0x1fffff;
300      direct->min = 0;
301      direct->max = 0x1fffff;
299      direct->bytemask = 0x1fffff;
300      direct->bytestart = 0;
301      direct->byteend = 0x1fffff;
302302      direct->raw = direct->decrypted = memory_region(space->machine, "main");
303303   }
304304   else   // executing from logical memory
305305   {
306306      UINT32 page = address / page_sizes[a310_pagesize];
307307
308      direct->mask = page_sizes[a310_pagesize]-1;
309      direct->min = page * page_sizes[a310_pagesize];
310      direct->max = direct->min + direct->mask;
308      direct->bytemask = page_sizes[a310_pagesize]-1;
309      direct->bytestart = page * page_sizes[a310_pagesize];
310      direct->byteend = direct->bytestart + direct->bytemask;
311311      direct->raw = direct->decrypted = (UINT8 *)&a310_physmem[(a310_pages[page] * page_sizes[a310_pagesize])>>2];
312312   }
313313
src/mess/drivers/ut88.c
r4135r4136
1010
1111#include "driver.h"
1212#include "cpu/i8085/i8085.h"
13#include "sound/dac.h"
14#include "sound/wave.h"
1315#include "includes/ut88.h"
14#include "sound/dac.h"
1516#include "devices/cassette.h"
1617#include "formats/rk_cas.h"
1718#include "ut88mini.lh"
src/mess/drivers/tutor.c
r4135r4136
160160
161161#include "driver.h"
162162#include "cpu/tms9900/tms9900.h"
163#include "sound/wave.h"
163164#include "video/tms9928a.h"
164165#include "devices/cartslot.h"
165166#include "devices/cassette.h"
src/mess/drivers/comx35.c
r4135r4136
1313#include "driver.h"
1414#include "includes/comx35.h"
1515#include "cpu/cdp1802/cdp1802.h"
16#include "sound/cdp1869.h"
17#include "sound/wave.h"
1618#include "devices/basicdsk.h"
1719#include "devices/cassette.h"
1820#include "devices/printer.h"
src/mess/drivers/cybiko.c
r4135r4136
1212
1313/* Core includes */
1414#include "driver.h"
15#include "sound/speaker.h"
1516#include "includes/cybiko.h"
1617
1718/* Components */
src/mess/drivers/trs80.c
r4135r4136
7878
7979/* Core includes */
8080#include "driver.h"
81#include "deprecat.h"
8182#include "cpu/z80/z80.h"
82#include "deprecat.h"
83#include "sound/wave.h"
8384#include "includes/trs80.h"
8485
8586/* Components */
src/mess/drivers/apple2.c
r4135r4136
195195#include "machine/applefdc.h"
196196#include "machine/mockngbd.h"
197197#include "sound/ay8910.h"
198#include "sound/dac.h"
198199
199200
200201
src/mess/drivers/primo.c
r4135r4136
102102*******************************************************************************/
103103
104104#include "driver.h"
105#include "sound/speaker.h"
106#include "sound/wave.h"
105107#include "includes/primo.h"
106108#include "cpu/z80/z80.h"
107109#include "devices/cassette.h"
src/mess/drivers/ti85.c
r4135r4136
134134
135135#include "driver.h"
136136#include "cpu/z80/z80.h"
137#include "sound/speaker.h"
137138#include "includes/ti85.h"
138139#include "devices/snapquik.h"
139140
src/mess/drivers/c64.c
r4135r4136
325325#include "driver.h"
326326#include "cpu/m6502/m6502.h"
327327#include "sound/sid6581.h"
328#include "sound/dac.h"
328329#include "machine/6526cia.h"
329330
330331#include "machine/cbmipt.h"
src/mess/drivers/svi318.c
r4135r4136
1111
1212#include "driver.h"
1313#include "cpu/z80/z80.h"
14#include "sound/wave.h"
1415#include "video/mc6845.h"
1516#include "includes/svi318.h"
1617#include "video/tms9928a.h"
src/mess/drivers/ti99_4p.c
r4135r4136
2727*/
2828
2929#include "driver.h"
30#include "deprecat.h"
3031#include "cpu/tms9900/tms9900.h"
31#include "deprecat.h"
32#include "sound/dac.h"
33#include "sound/sn76496.h"
3234#include "video/v9938.h"
3335
3436#include "machine/ti99_4x.h"
src/mess/drivers/pc.c
r4135r4136
109109#include "driver.h"
110110#include "cpu/nec/nec.h"
111111#include "cpu/i86/i86.h"
112#include "sound/speaker.h"
113#include "sound/saa1099.h"
112114#include "deprecat.h"
113115
114116#include "machine/8255ppi.h"
src/mess/drivers/pecom.c
r4135r4136
88
99#include "driver.h"
1010#include "cpu/cdp1802/cdp1802.h"
11#include "sound/cdp1869.h"
12#include "sound/wave.h"
1113#include "video/cdp1869.h"
1214#include "devices/cassette.h"
1315#include "includes/pecom.h"
src/mess/drivers/pce.c
r4135r4136
5959#include "devices/cartslot.h"
6060#include "devices/chd_cd.h"
6161#include "sound/c6280.h"
62#include "sound/cdda.h"
6263#include "sound/msm5205.h"
6364#include "hash.h"
6465
src/mess/drivers/ti99_4x.c
r4135r4136
1919*/
2020
2121#include "driver.h"
22#include "deprecat.h"
2223#include "cpu/tms9900/tms9900.h"
23#include "deprecat.h"
24#include "sound/sn76496.h"
25#include "sound/wave.h"
2426#include "video/v9938.h"
2527#include "machine/ti99_4x.h"
2628#include "machine/tms9901.h"
src/mess/drivers/ip20.c
r4135r4136
1818
1919#include "driver.h"
2020#include "cpu/mips/mips3.h"
21#include "sound/cdda.h"
2122#include "machine/8530scc.h"
2223#include "machine/sgi.h"
2324#include "machine/eeprom.h"
src/mess/drivers/galaxy.c
r4135r4136
2323
2424#include "driver.h"
2525#include "cpu/z80/z80.h"
26#include "sound/wave.h"
2627#include "includes/galaxy.h"
2728#include "devices/snapquik.h"
2829#include "devices/cassette.h"
src/mess/drivers/bbc.c
r4135r4136
2222#include "devices/cassette.h"
2323#include "formats/uef_cas.h"
2424#include "formats/csw_cas.h"
25#include "sound/sn76496.h"
2526
2627
2728/******************************************************************************
src/mess/drivers/gamepock.c
r4135r4136
11#include "driver.h"
22#include "cpu/upd7810/upd7810.h"
3#include "sound/speaker.h"
34#include "devices/cartslot.h"
45#include "includes/gamepock.h"
56#include "gamepock.lh"
src/mess/drivers/vtech2.c
r4135r4136
6565
6666#include "driver.h"
6767#include "cpu/z80/z80.h"
68#include "sound/speaker.h"
69#include "sound/wave.h"
6870#include "includes/vtech2.h"
6971#include "devices/cartslot.h"
7072#include "devices/cassette.h"
src/mess/drivers/kc.c
r4135r4136
2121#include "machine/z80sio.h"
2222#include "cpu/z80/z80.h"
2323#include "cpu/z80/z80daisy.h"
24#include "sound/speaker.h"
25#include "sound/wave.h"
2426#include "machine/nec765.h"
2527
2628/* Devices */
docs/messnew.txt
r4135r4136
22
33New System Drivers Supported (in no particular order):
44------------------------------------------------------
5Intelligent Software Enterprise 64  [Dirk Best]
6Hegener & Glaser Mephisto PHC 64  [Dirk Best]
5- Intelligent Software Enterprise 64  [Dirk Best]
6- Hegener & Glaser Mephisto PHC 64  [Dirk Best]
77
88
99
1010System Driver Changes:
1111----------------------
12- [X68000] Added better implementation of 1024x1024 graphic layer.  [Barry Rodewald]
13
1412- [TI81, TI85, TI86] Added the new ROM_DEFAULT_BIOS feature to select the most
1513  recent rom versions.  [Hobie Troxell]
1614
15- [X68000] Added better implementation of 1024x1024 graphic layer.  [Barry Rodewald]
1716
1817
18
1919User Interface Changes:
2020-----------------------
2121(none)
r4135r4136
3030
3131Source Changes:
3232----------------
33- The core is based on MAME 0.129u1.  This incorporates all features of the
34  update to this core.  [MAME team]
35
3336- Changed the DS1315 implementation to be a device.  [Nathan Woods]
34- Changed the AT45DBxx and SST39VFxx to be a device [Miodrag Milanovic]
3537
38- Changed the AT45DBxx and SST39VFxx to be a device. [Miodrag Milanovic]
39
3640- Fixed a bug that caused the day of the week to not be properly returned by
3741  the DS1315.  (bug #1755) [Nathan Woods]
3842

Previous 15994 Revisions Next


© 1998-2018 The MESS Team