Previous 15994 Revisions Next

r11161 Wednesday 13th April, 2011 at 19:57:15 UTC by Miodrag Milanović
Sync with MAME (r12119),also moved some non mame things from mame.a in mess.mak (no whatsnew)
[src/emu]info.c
[src/emu/drivers]xtal.h
[src/mame]mame.mak mamedriv.c
[src/mame/audio]beezer.c cage.c cage.h dcs.c dcs.h exidy440.c exidy440.h gorf.c m72.c m72.h mcr.c scramble.c segasnd.c segasnd.h taito_en.c williams.c williams.h wow.c
[src/mame/drivers]2mindril.c 4enraya.c alien.c* arcadecl.c astrocde.c atarigt.c atarisy1.c badlands.c batman.c blitz68k.c blstroid.c calchase.c cave.c cesclass.c* corona.c cps3.c csplayh5.c cyberbal.c dambustr.c dec0.c eprom.c exidy440.c expro02.c famibox.c* funworld.c fuukifg2.c fuukifg3.c galaxian.c galaxold.c galdrvr.c galpani2.c galpani3.c gamecstl.c gauntlet.c hornet.c igs011.c jchan.c kaneko16.c kinst.c klax.c lordgun.c m72.c m90.c majorpkr.c* mcr68.c mediagx.c metalmx.c metro.c midvunit.c midyunit.c namcos21.c namcos22.c namcos23.c nwk-tr.c offtwall.c pcxt.c photoply.c quakeat.c quizo.c rampart.c relief.c sandscrp.c scobra.c scramble.c seattle.c segag80r.c segag80v.c shisen.c shuuz.c sigmab98.c skullxbo.c spoker.c subsino.c subsino2.c suprnova.c system16.c taito_f3.c taitowlf.c thunderj.c toobin.c vegas.c vigilant.c vindictr.c xybots.c zaxxon.c
[src/mame/includes]4enraya.h astrocde.h cave.h exidy440.h fastfred.h fuukifg2.h fuukifg3.h galaxian.h galaxold.h galpani2.h galpanic.h kaneko16.h lordgun.h m72.h namcos21.h namcos22.h psikyosh.h scramble.h* segag80v.h suprnova.h taito_f3.h vertigo.h
[src/mame/layout]jollycrd.lay majorpkr.lay*
[src/mame/machine]atarigen.c atarigen.h galaxold.c kaneko16.c midtunit.c midwayic.c midwunit.c midxunit.c midyunit.c naomibd.c pcshare.c scramble.c subsino.c* subsino.h* vertigo.c
[src/mame/video]arcadecl.c astrocde.c atarig42.c atarimo.c atarimo.h atarisy1.c atarisy2.c badlands.c batman.c blstroid.c cave.c cyberbal.c decospr.c eprom.c fastfred.c funworld.c fuukifg2.c fuukifg3.c galaxian.c galaxold.c galpani2.c gauntlet.c kaneko16.c klax.c lordgun.c namcos21.c namcos22.c offtwall.c psikyosh.c rampart.c relief.c shuuz.c skullxbo.c suprnova.c taito_f3.c thunderj.c toobin.c vindictr.c xybots.c
[src/mess]mess.mak
[src/mess/drivers]astrocde.c
[src/osd/windows]windows.mak winmisc.c

src/mame/audio/gorf.c
r11160r11161
106106 "galaxy.wav","got.wav","power.wav","try.wav","supreme.wav","all.wav",
107107 "hail.wav","emperor.wav",
108108 0
109} ;
109};
110110
111111
112/* Total word to join the phonemes together - Global to make it easier to use */
113static char totalword[256], *totalword_ptr;
114static char oldword[256];
115static int plural = 0;
116
117112READ8_HANDLER( gorf_speech_r )
118113{
114   astrocde_state *state = space->machine().driver_data<astrocde_state>();
119115   device_t *samples = space->machine().device("samples");
120    int Phoneme,Intonation;
121    int i = 0;
122
116   int Phoneme, Intonation;
117   int i = 0;
123118   UINT8 data = offset >> 8;
124119   offset &= 0xff;
125120
126    totalword_ptr = totalword;
121   state->m_totalword_ptr = state->m_totalword;
127122
128    Phoneme = data & 0x3F;
129    Intonation = data >> 6;
123   Phoneme = data & 0x3F;
124   Intonation = data >> 6;
130125
131    logerror("Date : %d Speech : %s at intonation %d\n",Phoneme, PhonemeTable[Phoneme],Intonation);
126   logerror("Date : %d Speech : %s at intonation %d\n",Phoneme, PhonemeTable[Phoneme],Intonation);
132127
133    if(Phoneme==63) {
128   if(Phoneme==63) {
134129      sample_stop(samples, 0);
135                if (strlen(totalword)>2) logerror("Clearing sample %s\n",totalword);
136                totalword[0] = 0;               /* Clear the total word stack */
137                return data;
138    }
130      if (strlen(state->m_totalword)>2) logerror("Clearing sample %s\n",state->m_totalword);
131      state->m_totalword[0] = 0;               /* Clear the total word stack */
132      return data;
133   }
139134
140/* Phoneme to word translation */
135   /* Phoneme to word translation */
141136
142    if (strlen(totalword) == 0) {
143       strcpy(totalword,PhonemeTable[Phoneme]);                      /* Copy over the first phoneme */
144       if (plural != 0) {
145          logerror("found a possible plural at %d\n",plural-1);
146          if (!strcmp("S",totalword)) {         /* Plural check */
147             sample_start(samples, 0, num_samples-2, 0);      /* play the sample at position of word */
148             sample_set_freq(samples, 0, 11025);    /* play at correct rate */
149             totalword[0] = 0;               /* Clear the total word stack */
150             oldword[0] = 0;               /* Clear the total word stack */
151             return data;
152          } else {
153             plural=0;
154          }
155       }
156    } else
157       strcat(totalword,PhonemeTable[Phoneme]);                      /* Copy over the first phoneme */
137   if (strlen(state->m_totalword) == 0) {
138      strcpy(state->m_totalword,PhonemeTable[Phoneme]);                      /* Copy over the first phoneme */
139      if (state->m_plural != 0) {
140         logerror("found a possible plural at %d\n",state->m_plural-1);
141         if (!strcmp("S",state->m_totalword)) {         /* Plural check */
142            sample_start(samples, 0, num_samples-2, 0);      /* play the sample at position of word */
143            sample_set_freq(samples, 0, 11025);    /* play at correct rate */
144            state->m_totalword[0] = 0;               /* Clear the total word stack */
145            state->m_oldword[0] = 0;               /* Clear the total word stack */
146            return data;
147         } else {
148            state->m_plural=0;
149         }
150      }
151   } else
152      strcat(state->m_totalword,PhonemeTable[Phoneme]);                      /* Copy over the first phoneme */
158153
159    logerror("Total word = %s\n",totalword);
154   logerror("Total word = %s\n",state->m_totalword);
160155
161    for (i=0; GorfWordTable[i]; i++) {
162       if (!strcmp(GorfWordTable[i],totalword)) {         /* Scan the word (sample) table for the complete word */
163          if ((!strcmp("GDTO1RFYA2N",totalword)) || (!strcmp("RO1U1BAH1T",totalword)) || (!strcmp("KO1UH3I3E1N",totalword)) || (!strcmp("WORAYY1EH3R",totalword)) || (!strcmp("IN",totalword)) ) {              /* May be plural */
164             plural=i+1;
165             strcpy(oldword,totalword);
166        logerror("Storing sample position %d and copying string %s\n",plural,oldword);
167          } else {
168             plural=0;
169          }
170          sample_start(samples, 0, i, 0);                      /* play the sample at position of word */
171          sample_set_freq(samples, 0, 11025);       /* play at correct rate */
172          logerror("Playing sample %d",i);
173          totalword[0] = 0;               /* Clear the total word stack */
174          return data;
175       }
176    }
156   for (i=0; GorfWordTable[i]; i++) {
157      if (!strcmp(GorfWordTable[i],state->m_totalword)) {         /* Scan the word (sample) table for the complete word */
158         if ((!strcmp("GDTO1RFYA2N",state->m_totalword)) || (!strcmp("RO1U1BAH1T",state->m_totalword)) || (!strcmp("KO1UH3I3E1N",state->m_totalword)) || (!strcmp("WORAYY1EH3R",state->m_totalword)) || (!strcmp("IN",state->m_totalword)) ) {              /* May be state->m_plural */
159            state->m_plural=i+1;
160            strcpy(state->m_oldword,state->m_totalword);
161            logerror("Storing sample position %d and copying string %s\n",state->m_plural,state->m_oldword);
162         } else {
163            state->m_plural=0;
164         }
165         sample_start(samples, 0, i, 0);                      /* play the sample at position of word */
166         sample_set_freq(samples, 0, 11025);       /* play at correct rate */
167         logerror("Playing sample %d",i);
168         state->m_totalword[0] = 0;               /* Clear the total word stack */
169         return data;
170      }
171   }
177172
178    /* Note : We should really also use volume in this as well as frequency */
179    return data;                               /* Return nicely */
173   /* Note : We should really also use volume in this as well as frequency */
174   return data;                               /* Return nicely */
180175}
181176
182177
src/mame/audio/cage.c
r11160r11161
3333 *
3434 *************************************/
3535
36static cpu_device *cage_cpu;
37static attotime cage_cpu_h1_clock_period;
3836
39static UINT8 cpu_to_cage_ready;
40static UINT8 cage_to_cpu_ready;
37typedef struct
38{
39   cpu_device *cpu;
40   attotime cpu_h1_clock_period;
4141
42static void (*cage_irqhandler)(running_machine &, int);
42   UINT8 cpu_to_cage_ready;
43   UINT8 cage_to_cpu_ready;
4344
44static attotime serial_period_per_word;
45   void (*irqhandler)(running_machine &, int);
4546
46static UINT8 dma_enabled;
47static UINT8 dma_timer_enabled;
48static timer_device *dma_timer;
47   attotime serial_period_per_word;
4948
50static UINT8 cage_timer_enabled[2];
51static timer_device *timer[2];
49   UINT8 dma_enabled;
50   UINT8 dma_timer_enabled;
51   timer_device *dma_timer;
5252
53static UINT32 *tms32031_io_regs;
53   UINT8 timer_enabled[2];
54   timer_device *timer[2];
55   
56   UINT32 tms32031_io_regs[0x100];
57   UINT16 from_main;
58   UINT16 control;
5459
55static UINT16 cage_from_main;
56static UINT16 cage_control;
60   UINT32 *speedup_ram;
61   dmadac_sound_device *dmadac[DAC_BUFFER_CHANNELS];
62} cage_t;
5763
58static UINT32 *speedup_ram;
64static cage_t cage;
5965
60static dmadac_sound_device *dmadac[DAC_BUFFER_CHANNELS];
6166
6267
63
6468/*************************************
6569 *
6670 *  I/O port definitions
r11160r11161
155159
156160void cage_init(running_machine &machine, offs_t speedup)
157161{
162   cage_t *state = &cage;
158163   attotime cage_cpu_clock_period;
159164   int chan;
160165
161   cage_irqhandler = NULL;
166   state->irqhandler = NULL;
162167
163168   memory_set_bankptr(machine, "bank10", machine.region("cageboot")->base());
164169   memory_set_bankptr(machine, "bank11", machine.region("cage")->base());
165170
166   cage_cpu = machine.device<cpu_device>("cage");
167   cage_cpu_clock_period = attotime::from_hz(cage_cpu->clock());
168   cage_cpu_h1_clock_period = cage_cpu_clock_period * 2;
171   state->cpu = machine.device<cpu_device>("cage");
172   cage_cpu_clock_period = attotime::from_hz(state->cpu->clock());
173   state->cpu_h1_clock_period = cage_cpu_clock_period * 2;
169174
170   dma_timer = machine.device<timer_device>("cage_dma_timer");
171   timer[0] = machine.device<timer_device>("cage_timer0");
172   timer[1] = machine.device<timer_device>("cage_timer1");
175   state->dma_timer = machine.device<timer_device>("cage_dma_timer");
176   state->timer[0] = machine.device<timer_device>("cage_timer0");
177   state->timer[1] = machine.device<timer_device>("cage_timer1");
173178
174179   if (speedup)
175      speedup_ram = cage_cpu->memory().space(AS_PROGRAM)->install_legacy_write_handler(speedup, speedup, FUNC(speedup_w));
180      state->speedup_ram = state->cpu->memory().space(AS_PROGRAM)->install_legacy_write_handler(speedup, speedup, FUNC(speedup_w));
176181
177182   for (chan = 0; chan < DAC_BUFFER_CHANNELS; chan++)
178183   {
179184      char buffer[10];
180185      sprintf(buffer, "dac%d", chan + 1);
181      dmadac[chan] = machine.device<dmadac_sound_device>(buffer);
186      state->dmadac[chan] = machine.device<dmadac_sound_device>(buffer);
182187   }
183188
184   state_save_register_global(machine, cpu_to_cage_ready);
185   state_save_register_global(machine, cage_to_cpu_ready);
186   state_save_register_global(machine, serial_period_per_word);
187   state_save_register_global(machine, dma_enabled);
188   state_save_register_global(machine, dma_timer_enabled);
189   state_save_register_global_array(machine, cage_timer_enabled);
190   state_save_register_global(machine, cage_from_main);
191   state_save_register_global(machine, cage_control);
189   state_save_register_global(machine, cage.cpu_to_cage_ready);
190   state_save_register_global(machine, cage.cage_to_cpu_ready);
191   state_save_register_global(machine, cage.serial_period_per_word);
192   state_save_register_global(machine, cage.dma_enabled);
193   state_save_register_global(machine, cage.dma_timer_enabled);
194   state_save_register_global_array(machine, cage.timer_enabled);
195   state_save_register_global(machine, cage.from_main);
196   state_save_register_global(machine, cage.control);
192197}
193198
194199
195200void cage_set_irq_handler(void (*irqhandler)(running_machine &, int))
196201{
197   cage_irqhandler = irqhandler;
202   cage_t *state = &cage;
203   state->irqhandler = irqhandler;
198204}
199205
200206
201void cage_reset_w(int state)
207void cage_reset_w(address_space *space, int state)
202208{
209   cage_t *sndstate = &cage;
203210   if (state)
204      cage_control_w(cage_cpu->machine(), 0);
205   device_set_input_line(cage_cpu, INPUT_LINE_RESET, state ? ASSERT_LINE : CLEAR_LINE);
211      cage_control_w(space->machine(), 0);
212   device_set_input_line(sndstate->cpu, INPUT_LINE_RESET, state ? ASSERT_LINE : CLEAR_LINE);
206213}
207214
208215
r11160r11161
215222
216223static TIMER_DEVICE_CALLBACK( dma_timer_callback )
217224{
225   cage_t *state = &cage;
226   UINT32 *tms32031_io_regs = state->tms32031_io_regs;
227
218228   /* if we weren't enabled, don't do anything, just shut ourself off */
219   if (!dma_enabled)
229   if (!state->dma_enabled)
220230   {
221      if (dma_timer_enabled)
231      if (state->dma_timer_enabled)
222232      {
223233         timer.adjust(attotime::never);
224         dma_timer_enabled = 0;
234         state->dma_timer_enabled = 0;
225235      }
226236      return;
227237   }
r11160r11161
231241   tms32031_io_regs[DMA_SOURCE_ADDR] = param;
232242
233243   /* set the interrupt */
234   device_set_input_line(cage_cpu, TMS3203X_DINT, ASSERT_LINE);
235   dma_enabled = 0;
244   device_set_input_line(state->cpu, TMS3203X_DINT, ASSERT_LINE);
245   state->dma_enabled = 0;
236246}
237247
238248
239249static void update_dma_state(address_space *space)
240250{
251   cage_t *state = &cage;
252   UINT32 *tms32031_io_regs = state->tms32031_io_regs;
253
241254   /* determine the new enabled state */
242255   int enabled = ((tms32031_io_regs[DMA_GLOBAL_CTL] & 3) == 3) && (tms32031_io_regs[DMA_TRANSFER_COUNT] != 0);
243256
244257   /* see if we turned on */
245   if (enabled && !dma_enabled)
258   if (enabled && !state->dma_enabled)
246259   {
247260      INT16 sound_data[STACK_SOUND_BUFSIZE];
248261      UINT32 addr, inc;
r11160r11161
262275         sound_data[i % STACK_SOUND_BUFSIZE] = space->read_dword(addr * 4);
263276         addr += inc;
264277         if (i % STACK_SOUND_BUFSIZE == STACK_SOUND_BUFSIZE - 1)
265            dmadac_transfer(&dmadac[0], DAC_BUFFER_CHANNELS, 1, DAC_BUFFER_CHANNELS, STACK_SOUND_BUFSIZE / DAC_BUFFER_CHANNELS, sound_data);
278            dmadac_transfer(&state->dmadac[0], DAC_BUFFER_CHANNELS, 1, DAC_BUFFER_CHANNELS, STACK_SOUND_BUFSIZE / DAC_BUFFER_CHANNELS, sound_data);
266279      }
267280      if (tms32031_io_regs[DMA_TRANSFER_COUNT] % STACK_SOUND_BUFSIZE != 0)
268         dmadac_transfer(&dmadac[0], DAC_BUFFER_CHANNELS, 1, DAC_BUFFER_CHANNELS, (tms32031_io_regs[DMA_TRANSFER_COUNT] % STACK_SOUND_BUFSIZE) / DAC_BUFFER_CHANNELS, sound_data);
281         dmadac_transfer(&state->dmadac[0], DAC_BUFFER_CHANNELS, 1, DAC_BUFFER_CHANNELS, (tms32031_io_regs[DMA_TRANSFER_COUNT] % STACK_SOUND_BUFSIZE) / DAC_BUFFER_CHANNELS, sound_data);
269282
270283      /* compute the time of the interrupt and set the timer */
271      if (!dma_timer_enabled)
284      if (!state->dma_timer_enabled)
272285      {
273         attotime period = serial_period_per_word * tms32031_io_regs[DMA_TRANSFER_COUNT];
274         dma_timer->adjust(period, addr, period);
275         dma_timer_enabled = 1;
286         attotime period = state->serial_period_per_word * tms32031_io_regs[DMA_TRANSFER_COUNT];
287         state->dma_timer->adjust(period, addr, period);
288         state->dma_timer_enabled = 1;
276289      }
277290   }
278291
279292   /* see if we turned off */
280   else if (!enabled && dma_enabled)
293   else if (!enabled && state->dma_enabled)
281294   {
282      dma_timer->reset();
283      dma_timer_enabled = 0;
295      state->dma_timer->reset();
296      state->dma_timer_enabled = 0;
284297   }
285298
286299   /* set the new state */
287   dma_enabled = enabled;
300   state->dma_enabled = enabled;
288301}
289302
290303
r11160r11161
297310
298311static TIMER_DEVICE_CALLBACK( cage_timer_callback )
299312{
313   cage_t *state = &cage;
300314   int which = param;
301315
302316   /* set the interrupt */
303   device_set_input_line(cage_cpu, TMS3203X_TINT0 + which, ASSERT_LINE);
304   cage_timer_enabled[which] = 0;
317   device_set_input_line(state->cpu, TMS3203X_TINT0 + which, ASSERT_LINE);
318   state->timer_enabled[which] = 0;
305319   update_timer(which);
306320}
307321
308322
309323static void update_timer(int which)
310324{
325   cage_t *state = &cage;
326   UINT32 *tms32031_io_regs = state->tms32031_io_regs;
327
311328   /* determine the new enabled state */
312329   int base = 0x10 * which;
313330   int enabled = ((tms32031_io_regs[base + TIMER0_GLOBAL_CTL] & 0xc0) == 0xc0);
314331
315332   /* see if we turned on */
316   if (enabled && !cage_timer_enabled[which])
333   if (enabled && !state->timer_enabled[which])
317334   {
318      attotime period = cage_cpu_h1_clock_period * (2 * tms32031_io_regs[base + TIMER0_PERIOD]);
335      attotime period = state->cpu_h1_clock_period * (2 * tms32031_io_regs[base + TIMER0_PERIOD]);
319336
320337      /* make sure our assumptions are correct */
321338      if (tms32031_io_regs[base + TIMER0_GLOBAL_CTL] != 0x2c1)
322339         logerror("CAGE TIMER%d: unexpected timer config %08X!\n", which, tms32031_io_regs[base + TIMER0_GLOBAL_CTL]);
323340
324      timer[which]->adjust(period, which);
341      state->timer[which]->adjust(period, which);
325342   }
326343
327344   /* see if we turned off */
328   else if (!enabled && cage_timer_enabled[which])
345   else if (!enabled && state->timer_enabled[which])
329346   {
330      timer[which]->adjust(attotime::never, which);
347      state->timer[which]->adjust(attotime::never, which);
331348   }
332349
333350   /* set the new state */
334   cage_timer_enabled[which] = enabled;
351   state->timer_enabled[which] = enabled;
335352}
336353
337354
r11160r11161
344361
345362static void update_serial(running_machine &machine)
346363{
364   cage_t *state = &cage;
365   UINT32 *tms32031_io_regs = state->tms32031_io_regs;
347366   attotime serial_clock_period, bit_clock_period;
348367   UINT32 freq;
349368
350369   /* we start out at half the H1 frequency (or 2x the H1 period) */
351   serial_clock_period = cage_cpu_h1_clock_period * 2;
370   serial_clock_period = state->cpu_h1_clock_period * 2;
352371
353372   /* if we're in clock mode, muliply by another factor of 2 */
354373   if (tms32031_io_regs[SPORT_GLOBAL_CTL] & 4)
r11160r11161
358377   bit_clock_period = serial_clock_period * (tms32031_io_regs[SPORT_TIMER_PERIOD] & 0xffff);
359378
360379   /* and times the number of bits per sample */
361   serial_period_per_word = bit_clock_period * (8 * (((tms32031_io_regs[SPORT_GLOBAL_CTL] >> 18) & 3) + 1));
380   state->serial_period_per_word = bit_clock_period * (8 * (((tms32031_io_regs[SPORT_GLOBAL_CTL] >> 18) & 3) + 1));
362381
363382   /* compute the step value to stretch this to the sample_rate */
364   freq = ATTOSECONDS_TO_HZ(serial_period_per_word.attoseconds) / DAC_BUFFER_CHANNELS;
383   freq = ATTOSECONDS_TO_HZ(state->serial_period_per_word.attoseconds) / DAC_BUFFER_CHANNELS;
365384   if (freq > 0 && freq < 100000)
366385   {
367      dmadac_set_frequency(&dmadac[0], DAC_BUFFER_CHANNELS, freq);
368      dmadac_enable(&dmadac[0], DAC_BUFFER_CHANNELS, 1);
386      dmadac_set_frequency(&state->dmadac[0], DAC_BUFFER_CHANNELS, freq);
387      dmadac_enable(&state->dmadac[0], DAC_BUFFER_CHANNELS, 1);
369388   }
370389}
371390
r11160r11161
379398
380399static READ32_HANDLER( tms32031_io_r )
381400{
401   cage_t *state = &cage;
402   UINT32 *tms32031_io_regs = state->tms32031_io_regs;
382403   UINT16 result = tms32031_io_regs[offset];
383404
384405   switch (offset)
385406   {
386407      case DMA_GLOBAL_CTL:
387         result = (result & ~0xc) | (dma_enabled ? 0xc : 0x0);
408         result = (result & ~0xc) | (state->dma_enabled ? 0xc : 0x0);
388409         break;
389410   }
390411
r11160r11161
396417
397418static WRITE32_HANDLER( tms32031_io_w )
398419{
420   cage_t *state = &cage;
421   UINT32 *tms32031_io_regs = state->tms32031_io_regs;
422
399423   COMBINE_DATA(&tms32031_io_regs[offset]);
400424
401425   if (LOG_32031_IOPORTS)
r11160r11161
430454
431455      case SPORT_DATA_TX:
432456#if (DAC_BUFFER_CHANNELS == 4)
433         if ((int)ATTOSECONDS_TO_HZ(serial_period_per_word.attoseconds) == 22050*4 && (tms32031_io_regs[SPORT_RX_CTL] & 0xff) == 0x62)
457         if ((int)ATTOSECONDS_TO_HZ(state->serial_period_per_word.attoseconds) == 22050*4 && (tms32031_io_regs[SPORT_RX_CTL] & 0xff) == 0x62)
434458            tms32031_io_regs[SPORT_RX_CTL] ^= 0x800;
435459#endif
436460         break;
r11160r11161
453477
454478static void update_control_lines(running_machine &machine)
455479{
480   cage_t *state = &cage;
456481   int val;
457482
458483   /* set the IRQ to the main CPU */
459   if (cage_irqhandler)
484   if (state->irqhandler)
460485   {
461486      int reason = 0;
462487
463      if ((cage_control & 3) == 3 && !cpu_to_cage_ready)
488      if ((state->control & 3) == 3 && !state->cpu_to_cage_ready)
464489         reason |= CAGE_IRQ_REASON_BUFFER_EMPTY;
465      if ((cage_control & 2) && cage_to_cpu_ready)
490      if ((state->control & 2) && state->cage_to_cpu_ready)
466491         reason |= CAGE_IRQ_REASON_DATA_READY;
467492
468      (*cage_irqhandler)(machine, reason);
493      (*state->irqhandler)(machine, reason);
469494   }
470495
471496   /* set the IOF input lines */
472   val = cpu_get_reg(cage_cpu, TMS3203X_IOF);
497   val = cpu_get_reg(state->cpu, TMS3203X_IOF);
473498   val &= ~0x88;
474   if (cpu_to_cage_ready) val |= 0x08;
475   if (cage_to_cpu_ready) val |= 0x80;
476   cage_cpu->set_state(TMS3203X_IOF, val);
499   if (state->cpu_to_cage_ready) val |= 0x08;
500   if (state->cage_to_cpu_ready) val |= 0x80;
501   state->cpu->set_state(TMS3203X_IOF, val);
477502}
478503
479504
480505static READ32_HANDLER( cage_from_main_r )
481506{
507   cage_t *state = &cage;
482508   if (LOG_COMM)
483      logerror("%06X:CAGE read command = %04X\n", cpu_get_pc(&space->device()), cage_from_main);
484   cpu_to_cage_ready = 0;
509      logerror("%06X:CAGE read command = %04X\n", cpu_get_pc(&space->device()), state->from_main);
510   state->cpu_to_cage_ready = 0;
485511   update_control_lines(space->machine());
486   device_set_input_line(cage_cpu, TMS3203X_IRQ0, CLEAR_LINE);
487   return cage_from_main;
512   device_set_input_line(state->cpu, TMS3203X_IRQ0, CLEAR_LINE);
513   return state->from_main;
488514}
489515
490516
491517static WRITE32_HANDLER( cage_from_main_ack_w )
492518{
493519   if (LOG_COMM)
494      logerror("%06X:CAGE ack command = %04X\n", cpu_get_pc(&space->device()), cage_from_main);
520   {
521      cage_t *state = &cage;
522      logerror("%06X:CAGE ack command = %04X\n", cpu_get_pc(&space->device()), state->from_main);
523   }
495524}
496525
497526
498527static WRITE32_HANDLER( cage_to_main_w )
499528{
529   cage_t *state = &cage;
500530   if (LOG_COMM)
501531      logerror("%06X:Data from CAGE = %04X\n", cpu_get_pc(&space->device()), data);
502532   soundlatch_word_w(space, 0, data, mem_mask);
503   cage_to_cpu_ready = 1;
533   state->cage_to_cpu_ready = 1;
504534   update_control_lines(space->machine());
505535}
506536
507537
508538static READ32_HANDLER( cage_io_status_r )
509539{
540   cage_t *state = &cage;
510541   int result = 0;
511   if (cpu_to_cage_ready)
542   if (state->cpu_to_cage_ready)
512543      result |= 0x80;
513   if (!cage_to_cpu_ready)
544   if (!state->cage_to_cpu_ready)
514545      result |= 0x40;
515546   return result;
516547}
517548
518549
519UINT16 main_from_cage_r(address_space *space)
550UINT16 cage_main_r(address_space *space)
520551{
552   cage_t *state = &cage;
521553   if (LOG_COMM)
522554      logerror("%s:main read data = %04X\n", space->machine().describe_context(), soundlatch_word_r(space, 0, 0));
523   cage_to_cpu_ready = 0;
555   state->cage_to_cpu_ready = 0;
524556   update_control_lines(space->machine());
525557   return soundlatch_word_r(space, 0, 0xffff);
526558}
527559
528560
529static TIMER_CALLBACK( deferred_cage_w )
561static TIMER_CALLBACK( cage_deferred_w )
530562{
531   cage_from_main = param;
532   cpu_to_cage_ready = 1;
563   cage_t *state = &cage;
564   state->from_main = param;
565   state->cpu_to_cage_ready = 1;
533566   update_control_lines(machine);
534   device_set_input_line(cage_cpu, TMS3203X_IRQ0, ASSERT_LINE);
567   device_set_input_line(state->cpu, TMS3203X_IRQ0, ASSERT_LINE);
535568}
536569
537570
538void main_to_cage_w(UINT16 data)
571void cage_main_w(address_space *space, UINT16 data)
539572{
540   running_machine &machine = cage_cpu->machine();
541573   if (LOG_COMM)
542      logerror("%s:Command to CAGE = %04X\n", machine.describe_context(), data);
543   machine.scheduler().synchronize(FUNC(deferred_cage_w), data);
574      logerror("%s:Command to CAGE = %04X\n", space->machine().describe_context(), data);
575   space->machine().scheduler().synchronize(FUNC(cage_deferred_w), data);
544576}
545577
546578
547UINT16 cage_control_r(void)
579UINT16 cage_control_r(running_machine &machine)
548580{
581   cage_t *state = &cage;
549582   UINT16 result = 0;
550583
551   if (cpu_to_cage_ready)
584   if (state->cpu_to_cage_ready)
552585      result |= 2;
553   if (cage_to_cpu_ready)
586   if (state->cage_to_cpu_ready)
554587      result |= 1;
555588
556589   return result;
r11160r11161
559592
560593void cage_control_w(running_machine &machine, UINT16 data)
561594{
562   cage_control = data;
595   cage_t *state = &cage;
596   UINT32 *tms32031_io_regs = state->tms32031_io_regs;
563597
598   state->control = data;
599
564600   /* CPU is reset if both control lines are 0 */
565   if (!(cage_control & 3))
601   if (!(state->control & 3))
566602   {
567      device_set_input_line(cage_cpu, INPUT_LINE_RESET, ASSERT_LINE);
603      device_set_input_line(state->cpu, INPUT_LINE_RESET, ASSERT_LINE);
568604
569      dma_enabled = 0;
570      dma_timer_enabled = 0;
571      dma_timer->reset();
605      state->dma_enabled = 0;
606      state->dma_timer_enabled = 0;
607      state->dma_timer->reset();
572608
573      cage_timer_enabled[0] = 0;
574      cage_timer_enabled[1] = 0;
575      timer[0]->reset();
576      timer[1]->reset();
609      state->timer_enabled[0] = 0;
610      state->timer_enabled[1] = 0;
611      state->timer[0]->reset();
612      state->timer[1]->reset();
577613
578614      memset(tms32031_io_regs, 0, 0x60 * 4);
579615
580      cpu_to_cage_ready = 0;
581      cage_to_cpu_ready = 0;
616      state->cpu_to_cage_ready = 0;
617      state->cage_to_cpu_ready = 0;
582618   }
583619   else
584      device_set_input_line(cage_cpu, INPUT_LINE_RESET, CLEAR_LINE);
620      device_set_input_line(state->cpu, INPUT_LINE_RESET, CLEAR_LINE);
585621
586622   /* update the control state */
587623   update_control_lines(machine);
r11160r11161
597633
598634static WRITE32_HANDLER( speedup_w )
599635{
636   cage_t *state = &cage;
637
600638   device_eat_cycles(&space->device(), 100);
601   COMBINE_DATA(&speedup_ram[offset]);
639   COMBINE_DATA(&state->speedup_ram[offset]);
602640}
603641
604642
r11160r11161
619657   AM_RANGE(0x000000, 0x00ffff) AM_RAM
620658   AM_RANGE(0x200000, 0x200000) AM_WRITENOP
621659   AM_RANGE(0x400000, 0x47ffff) AM_ROMBANK("bank10")
622   AM_RANGE(0x808000, 0x8080ff) AM_READWRITE(tms32031_io_r, tms32031_io_w) AM_BASE(&tms32031_io_regs)
660   AM_RANGE(0x808000, 0x8080ff) AM_READWRITE(tms32031_io_r, tms32031_io_w)
623661   AM_RANGE(0x809800, 0x809fff) AM_RAM
624662   AM_RANGE(0xa00000, 0xa00000) AM_READWRITE(cage_from_main_r, cage_to_main_w)
625663   AM_RANGE(0xc00000, 0xffffff) AM_ROMBANK("bank11")
r11160r11161
630668   AM_RANGE(0x000000, 0x00ffff) AM_RAM
631669   AM_RANGE(0x200000, 0x200000) AM_WRITENOP
632670   AM_RANGE(0x400000, 0x47ffff) AM_ROMBANK("bank10")
633   AM_RANGE(0x808000, 0x8080ff) AM_READWRITE(tms32031_io_r, tms32031_io_w) AM_BASE(&tms32031_io_regs)
671   AM_RANGE(0x808000, 0x8080ff) AM_READWRITE(tms32031_io_r, tms32031_io_w)
634672   AM_RANGE(0x809800, 0x809fff) AM_RAM
635673   AM_RANGE(0xa00000, 0xa00000) AM_READWRITE(cage_from_main_r, cage_from_main_ack_w)
636674   AM_RANGE(0xa00001, 0xa00001) AM_WRITE(cage_to_main_w)
src/mame/audio/cage.h
r11160r11161
1212
1313void cage_init(running_machine &machine, offs_t speedup);
1414void cage_set_irq_handler(void (*irqhandler)(running_machine &, int));
15void cage_reset_w(int state);
15void cage_reset_w(address_space *space, int state);
1616
17UINT16 main_from_cage_r(address_space *space);
18UINT16 cage_control_r(void);
19void main_to_cage_w(UINT16 data);
17UINT16 cage_main_r(address_space *space);
18void cage_main_w(address_space *space, UINT16 data);
19
20UINT16 cage_control_r(running_machine &machine);
2021void cage_control_w(running_machine &machine, UINT16 data);
src/mame/audio/segasnd.c
r11160r11161
8080{
8181   sound_stream *      stream;            /* output stream */
8282   device_t *cpu;            /* CPU index of the 8035 */
83   device_t *maincpu;
8384   UINT8            in_latch;         /* input latch */
8485   UINT8            out_latch;         /* output latch */
8586   UINT8            last_p2_value;      /* current P2 output value */
r11160r11161
99100   filter_state      noise_filters[5];
100101};
101102
102
103
104/***************************************************************************
105    GLOBAL VARIABLES
106***************************************************************************/
107
108103/* SP0250-based speech board */
109static UINT8 speech_latch, speech_t0, speech_p2, speech_drq;
104typedef struct _speech_state speech_state;
105struct _speech_state
106{
107   UINT8 latch, t0, p2, drq;
108   UINT8 *speech;
109};
110110
111/* Universal sound board */
112static usb_state usb;
113111
114112
115
116113/***************************************************************************
117114    INLINE FUNCTIONS
118115***************************************************************************/
r11160r11161
144141    SPEECH BOARD
145142***************************************************************************/
146143
144DECLARE_LEGACY_SOUND_DEVICE(SEGASPEECH, speech_sound);
147145
146INLINE speech_state *get_safe_speech(device_t *device)
147{
148   assert(device != NULL);
149   assert(device->type() == SEGASPEECH);
150
151   return (speech_state *)downcast<legacy_device_base *>(device)->token();
152}
153
154static DEVICE_START( speech_sound )
155{
156   speech_state *state = get_safe_speech(device);
157
158   state->speech = device->machine().region("speech")->base();
159}
160
161
162DEVICE_GET_INFO( speech_sound )
163{
164   switch (state)
165   {
166      /* --- the following bits of info are returned as 64-bit signed integers --- */
167      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(speech_state);         break;
168
169      /* --- the following bits of info are returned as pointers to data or functions --- */
170      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(speech_sound);      break;
171
172      /* --- the following bits of info are returned as NULL-terminated strings --- */
173      case DEVINFO_STR_NAME:                     strcpy(info->s, "Sega Speech Sound Board");   break;
174      case DEVINFO_STR_SOURCE_FILE:                  strcpy(info->s, __FILE__);                  break;
175   }
176}
177
178DEFINE_LEGACY_SOUND_DEVICE(SEGASPEECH, speech_sound);
179
180
181
148182/*************************************
149183 *
150184 *  i8035 port accessors
151185 *
152186 *************************************/
153187
154static READ8_HANDLER( speech_t0_r )
188
189
190static READ8_DEVICE_HANDLER( speech_t0_r )
155191{
156   return speech_t0;
192   speech_state *state = get_safe_speech(device);
193
194   return state->t0;
157195}
158196
159static READ8_HANDLER( speech_t1_r )
197static READ8_DEVICE_HANDLER( speech_t1_r )
160198{
161   return speech_drq;
199   speech_state *state = get_safe_speech(device);
200
201   return state->drq;
162202}
163203
164static READ8_HANDLER( speech_p1_r )
204static READ8_DEVICE_HANDLER( speech_p1_r )
165205{
166   return speech_latch & 0x7f;
206   speech_state *state = get_safe_speech(device);
207
208   return state->latch & 0x7f;
167209}
168210
169static READ8_HANDLER( speech_rom_r )
211static READ8_DEVICE_HANDLER( speech_rom_r )
170212{
171   return space->machine().region("speech")->base()[0x100 * (speech_p2 & 0x3f) + offset];
213   speech_state *state = get_safe_speech(device);
214
215   return state->speech[0x100 * (state->p2 & 0x3f) + offset];
172216}
173217
174static WRITE8_HANDLER( speech_p1_w )
218static WRITE8_DEVICE_HANDLER( speech_p1_w )
175219{
220   speech_state *state = get_safe_speech(device);
221
176222   if (!(data & 0x80))
177      speech_t0 = 0;
223      state->t0 = 0;
178224}
179225
180static WRITE8_HANDLER( speech_p2_w )
226static WRITE8_DEVICE_HANDLER( speech_p2_w )
181227{
182   speech_p2 = data;
228   speech_state *state = get_safe_speech(device);
229
230   state->p2 = data;
183231}
184232
185233
r11160r11161
192240
193241static void speech_drq_w(device_t *device, int level)
194242{
195   speech_drq = (level == ASSERT_LINE);
243   device_t *speech = device->machine().device("segaspeech");
244   speech_state *state = get_safe_speech(speech);
245
246   state->drq = (level == ASSERT_LINE);
196247}
197248
198249
r11160r11161
206257static TIMER_CALLBACK( delayed_speech_w )
207258{
208259   int data = param;
209   UINT8 old = speech_latch;
260   speech_state *state = (speech_state *)ptr;
261   UINT8 old = state->latch;
210262
211263   /* all 8 bits are latched */
212   speech_latch = data;
264   state->latch = data;
213265
214266   /* the high bit goes directly to the INT line */
215267   cputag_set_input_line(machine, "audiocpu", 0, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
216268
217269   /* a clock on the high bit clocks a 1 into T0 */
218270   if (!(old & 0x80) && (data & 0x80))
219      speech_t0 = 1;
271      state->t0 = 1;
220272}
221273
222274
223WRITE8_HANDLER( sega_speech_data_w )
275WRITE8_DEVICE_HANDLER( sega_speech_data_w )
224276{
225   space->machine().scheduler().synchronize(FUNC(delayed_speech_w), data);
277   speech_state *state = get_safe_speech(device);
278
279   device->machine().scheduler().synchronize(FUNC(delayed_speech_w), data, state);
226280}
227281
228282
229WRITE8_HANDLER( sega_speech_control_w )
283WRITE8_DEVICE_HANDLER( sega_speech_control_w )
230284{
231285   LOG(("Speech control = %X\n", data));
232286}
r11160r11161
245299
246300
247301static ADDRESS_MAP_START( speech_portmap, AS_IO, 8 )
248   AM_RANGE(0x00, 0xff) AM_READ(speech_rom_r)
302   AM_RANGE(0x00, 0xff) AM_DEVREAD("segaspeech", speech_rom_r)
249303   AM_RANGE(0x00, 0xff) AM_DEVWRITE("speech", sp0250_w)
250   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(speech_p1_r, speech_p1_w)
251   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(speech_p2_w)
252   AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(speech_t0_r)
253   AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(speech_t1_r)
304   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_DEVREADWRITE("segaspeech", speech_p1_r, speech_p1_w)
305   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_DEVWRITE("segaspeech", speech_p2_w)
306   AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_DEVREAD("segaspeech", speech_t0_r)
307   AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_DEVREAD("segaspeech", speech_t1_r)
254308ADDRESS_MAP_END
255309
256310
r11160r11161
282336   MCFG_CPU_IO_MAP(speech_portmap)
283337
284338   /* sound hardware */
339   MCFG_SOUND_ADD("segaspeech", SEGASPEECH, 0)
285340   MCFG_SOUND_ADD("speech", SP0250, SPEECH_MASTER_CLOCK)
286341   MCFG_SOUND_CONFIG(sp0250_interface)
287342   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
r11160r11161
293348    UNIVERSAL SOUND BOARD
294349***************************************************************************/
295350
351static DECLARE_LEGACY_SOUND_DEVICE(SEGAUSB, usb_sound);
296352
353INLINE usb_state *get_safe_token(device_t *device)
354{
355   assert(device != NULL);
356   assert(device->type() == SEGAUSB);
357
358   return (usb_state *)downcast<legacy_device_base *>(device)->token();
359}
360
297361/*************************************
298362 *
299363 *  Initialization/reset
r11160r11161
302366
303367static TIMER_DEVICE_CALLBACK( increment_t1_clock )
304368{
369   device_t *usbsnd = timer.machine().device("usbsnd");
370   usb_state *usb = get_safe_token(usbsnd);
371
305372   /* only increment if it is not being forced clear */
306   if (!(usb.last_p2_value & 0x80))
307      usb.t1_clock++;
373   if (!(usb->last_p2_value & 0x80))
374      usb->t1_clock++;
308375}
309376
310377
311void sega_usb_reset(running_machine &machine, UINT8 t1_clock_mask)
378static DEVICE_RESET( usb_sound )
312379{
380   usb_state *usb = get_safe_token(device);
381
313382   /* halt the USB CPU at reset time */
314   device_set_input_line(usb.cpu, INPUT_LINE_RESET, ASSERT_LINE);
383   device_set_input_line(usb->cpu, INPUT_LINE_RESET, ASSERT_LINE);
315384
316385   /* start the clock timer */
317   usb.t1_clock_mask = t1_clock_mask;
386   usb->t1_clock_mask = 0x10;
318387}
319388
320389
r11160r11161
325394 *
326395 *************************************/
327396
328READ8_HANDLER( sega_usb_status_r )
397READ8_DEVICE_HANDLER( sega_usb_status_r )
329398{
330   LOG(("%04X:usb_data_r = %02X\n", cpu_get_pc(&space->device()), (usb.out_latch & 0x81) | (usb.in_latch & 0x7e)));
399   usb_state *usb = get_safe_token(device);
331400
332   device_adjust_icount(&space->device(), -200);
401   LOG(("%04X:usb_data_r = %02X\n", cpu_get_pc(usb->maincpu), (usb->out_latch & 0x81) | (usb->in_latch & 0x7e)));
333402
403   device_adjust_icount(usb->maincpu, -200);
404
334405   /* only bits 0 and 7 are controlled by the I8035; the remaining */
335406   /* bits 1-6 reflect the current input latch values */
336   return (usb.out_latch & 0x81) | (usb.in_latch & 0x7e);
407   return (usb->out_latch & 0x81) | (usb->in_latch & 0x7e);
337408}
338409
339410
340411static TIMER_CALLBACK( delayed_usb_data_w )
341412{
413   usb_state *usb = (usb_state *)ptr;
342414   int data = param;
343415
344416   /* look for rising/falling edges of bit 7 to control the RESET line */
345   device_set_input_line(usb.cpu, INPUT_LINE_RESET, (data & 0x80) ? ASSERT_LINE : CLEAR_LINE);
417   device_set_input_line(usb->cpu, INPUT_LINE_RESET, (data & 0x80) ? ASSERT_LINE : CLEAR_LINE);
346418
347419   /* if the CLEAR line is set, the low 7 bits of the input are ignored */
348   if ((usb.last_p2_value & 0x40) == 0)
420   if ((usb->last_p2_value & 0x40) == 0)
349421      data &= ~0x7f;
350422
351423   /* update the effective input latch */
352   usb.in_latch = data;
424   usb->in_latch = data;
353425}
354426
355427
356WRITE8_HANDLER( sega_usb_data_w )
428WRITE8_DEVICE_HANDLER( sega_usb_data_w )
357429{
358   LOG(("%04X:usb_data_w = %02X\n", cpu_get_pc(&space->device()), data));
359   space->machine().scheduler().synchronize(FUNC(delayed_usb_data_w), data);
430   usb_state *usb = get_safe_token(device);
360431
432   LOG(("%04X:usb_data_w = %02X\n", cpu_get_pc(usb->maincpu), data));
433   device->machine().scheduler().synchronize(FUNC(delayed_usb_data_w), data, usb);
434
361435   /* boost the interleave so that sequences can be sent */
362   space->machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(250));
436   device->machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(250));
363437}
364438
365439
366READ8_HANDLER( sega_usb_ram_r )
440READ8_DEVICE_HANDLER( sega_usb_ram_r )
367441{
368   return usb.program_ram[offset];
442   usb_state *usb = get_safe_token(device);
443
444   return usb->program_ram[offset];
369445}
370446
371447
372WRITE8_HANDLER( sega_usb_ram_w )
448WRITE8_DEVICE_HANDLER( sega_usb_ram_w )
373449{
374   if (usb.in_latch & 0x80)
375      usb.program_ram[offset] = data;
450   usb_state *usb = get_safe_token(device);
451
452   if (usb->in_latch & 0x80)
453      usb->program_ram[offset] = data;
376454   else
377      LOG(("%04X:sega_usb_ram_w(%03X) = %02X while /LOAD disabled\n", cpu_get_pc(&space->device()), offset, data));
455      LOG(("%04X:sega_usb_ram_w(%03X) = %02X while /LOAD disabled\n", cpu_get_pc(usb->maincpu), offset, data));
378456}
379457
380458
r11160r11161
385463 *
386464 *************************************/
387465
388static READ8_HANDLER( usb_p1_r )
466static READ8_DEVICE_HANDLER( usb_p1_r )
389467{
468   usb_state *usb = get_safe_token(device);
469
390470   /* bits 0-6 are inputs and map to bits 0-6 of the input latch */
391   if ((usb.in_latch & 0x7f) != 0)
392      LOG(("%03X: P1 read = %02X\n", cpu_get_pc(&space->device()), usb.in_latch & 0x7f));
393   return usb.in_latch & 0x7f;
471   if ((usb->in_latch & 0x7f) != 0)
472      LOG(("%03X: P1 read = %02X\n", cpu_get_pc(usb->maincpu), usb->in_latch & 0x7f));
473   return usb->in_latch & 0x7f;
394474}
395475
396476
397static WRITE8_HANDLER( usb_p1_w )
477static WRITE8_DEVICE_HANDLER( usb_p1_w )
398478{
479   usb_state *usb = get_safe_token(device);
480
399481   /* bit 7 maps to bit 0 on the output latch */
400   usb.out_latch = (usb.out_latch & 0xfe) | (data >> 7);
401   LOG(("%03X: P1 write = %02X\n", cpu_get_pc(&space->device()), data));
482   usb->out_latch = (usb->out_latch & 0xfe) | (data >> 7);
483   LOG(("%03X: P1 write = %02X\n", cpu_get_pc(usb->maincpu), data));
402484}
403485
404486
405static WRITE8_HANDLER( usb_p2_w )
487static WRITE8_DEVICE_HANDLER( usb_p2_w )
406488{
407   UINT8 old = usb.last_p2_value;
408   usb.last_p2_value = data;
489   usb_state *usb = get_safe_token(device);
490   UINT8 old = usb->last_p2_value;
491   usb->last_p2_value = data;
409492
410493   /* low 2 bits control the bank of work RAM we are addressing */
411   usb.work_ram_bank = data & 3;
494   usb->work_ram_bank = data & 3;
412495
413496   /* bit 6 controls the "ready" bit output to the host */
414497   /* it also clears the input latch from the host (active low) */
415   usb.out_latch = ((data & 0x40) << 1) | (usb.out_latch & 0x7f);
498   usb->out_latch = ((data & 0x40) << 1) | (usb->out_latch & 0x7f);
416499   if ((data & 0x40) == 0)
417      usb.in_latch = 0;
500      usb->in_latch = 0;
418501
419502   /* bit 7 controls the reset on the upper counter at U33 */
420503   if ((old & 0x80) && !(data & 0x80))
421      usb.t1_clock = 0;
504      usb->t1_clock = 0;
422505
423   LOG(("%03X: P2 write -> bank=%d ready=%d clock=%d\n", cpu_get_pc(&space->device()), data & 3, (data >> 6) & 1, (data >> 7) & 1));
506   LOG(("%03X: P2 write -> bank=%d ready=%d clock=%d\n", cpu_get_pc(usb->maincpu), data & 3, (data >> 6) & 1, (data >> 7) & 1));
424507}
425508
426509
427static READ8_HANDLER( usb_t1_r )
510static READ8_DEVICE_HANDLER( usb_t1_r )
428511{
512   usb_state *usb = get_safe_token(device);
513
429514   /* T1 returns 1 based on the value of the T1 clock; the exact */
430515   /* pattern is determined by one or more jumpers on the board. */
431   return (usb.t1_clock & usb.t1_clock_mask) != 0;
516   return (usb->t1_clock & usb->t1_clock_mask) != 0;
432517}
433518
434519
r11160r11161
482567
483568static STREAM_UPDATE( usb_stream_update )
484569{
570   usb_state *usb = get_safe_token(device);
485571   stream_sample_t *dest = outputs[0];
486572
487573   /* iterate over samples */
r11160r11161
503589       */
504590
505591      /* update the noise source */
506      for (step = USB_2MHZ_CLOCK / SAMPLE_RATE; step >= usb.noise_subcount; step -= usb.noise_subcount)
592      for (step = USB_2MHZ_CLOCK / SAMPLE_RATE; step >= usb->noise_subcount; step -= usb->noise_subcount)
507593      {
508         usb.noise_shift = (usb.noise_shift << 1) | (((usb.noise_shift >> 13) ^ (usb.noise_shift >> 16)) & 1);
509         usb.noise_state = (usb.noise_shift >> 16) & 1;
510         usb.noise_subcount = USB_2MHZ_CLOCK / MM5837_CLOCK;
594         usb->noise_shift = (usb->noise_shift << 1) | (((usb->noise_shift >> 13) ^ (usb->noise_shift >> 16)) & 1);
595         usb->noise_state = (usb->noise_shift >> 16) & 1;
596         usb->noise_subcount = USB_2MHZ_CLOCK / MM5837_CLOCK;
511597      }
512      usb.noise_subcount -= step;
598      usb->noise_subcount -= step;
513599
514600      /* update the filtered noise value -- this is just an approximation to the pink noise filter */
515601      /* being applied on the PCB, but it sounds pretty close */
516      usb.noise_filters[0].capval = 0.99765 * usb.noise_filters[0].capval + usb.noise_state * 0.0990460;
517      usb.noise_filters[1].capval = 0.96300 * usb.noise_filters[1].capval + usb.noise_state * 0.2965164;
518      usb.noise_filters[2].capval = 0.57000 * usb.noise_filters[2].capval + usb.noise_state * 1.0526913;
519      noiseval = usb.noise_filters[0].capval + usb.noise_filters[1].capval + usb.noise_filters[2].capval + usb.noise_state * 0.1848;
602      usb->noise_filters[0].capval = 0.99765 * usb->noise_filters[0].capval + usb->noise_state * 0.0990460;
603      usb->noise_filters[1].capval = 0.96300 * usb->noise_filters[1].capval + usb->noise_state * 0.2965164;
604      usb->noise_filters[2].capval = 0.57000 * usb->noise_filters[2].capval + usb->noise_state * 1.0526913;
605      noiseval = usb->noise_filters[0].capval + usb->noise_filters[1].capval + usb->noise_filters[2].capval + usb->noise_state * 0.1848;
520606
521607      /* final output goes through a CR filter; the scaling factor is arbitrary to get the noise to the */
522608      /* correct relative volume */
523      noiseval = step_cr_filter(&usb.noise_filters[4], noiseval);
609      noiseval = step_cr_filter(&usb->noise_filters[4], noiseval);
524610      noiseval *= 0.075;
525611
526612      /* there are 3 identical groups of circuits, each with its own 8253 */
527613      for (group = 0; group < 3; group++)
528614      {
529         timer8253 *g = &usb.timer_group[group];
615         timer8253 *g = &usb->timer_group[group];
530616         double chan0, chan1, chan2, mix;
531617
532618
r11160r11161
601687         }
602688
603689         /* the exponents for the gate filters are determined by channel 2's output */
604         g->gate1.exponent = usb.gate_rc1_exp[g->chan[2].output];
605         g->gate2.exponent = usb.gate_rc2_exp[g->chan[2].output];
690         g->gate1.exponent = usb->gate_rc1_exp[g->chan[2].output];
691         g->gate2.exponent = usb->gate_rc2_exp[g->chan[2].output];
606692
607693         /* based on the envelope mode, we do one of two things with source 2 */
608694         if (g->config == 0)
r11160r11161
631717          WEIGHT
632718
633719       */
634       *dest++ = 4000 * step_cr_filter(&usb.final_filter, sample);
720       *dest++ = 4000 * step_cr_filter(&usb->final_filter, sample);
635721   }
636722}
637723
638724
639725static DEVICE_START( usb_sound )
640726{
727   usb_state *usb = get_safe_token(device);
641728   running_machine &machine = device->machine();
642729   filter_state temp;
643730   int tchan, tgroup;
644731
645732   /* find the CPU we are associated with */
646   usb.cpu = machine.device("usbcpu");
647   assert(usb.cpu != NULL);
733   usb->maincpu = machine.device("maincpu");
734   assert(usb->maincpu != NULL);
735   usb->cpu = machine.device("usbcpu");
736   assert(usb->cpu != NULL);
648737
649   /* allocate work RAM */
650   usb.work_ram = auto_alloc_array(machine, UINT8, 0x400);
738   /* allocate RAM */
739   usb->program_ram = (UINT8 *)memory_get_shared(device->machine(), "pgmram");
740   usb->work_ram = auto_alloc_array(machine, UINT8, 0x400);
651741
652742   /* create a sound stream */
653   usb.stream = device->machine().sound().stream_alloc(*device, 0, 1, SAMPLE_RATE, NULL, usb_stream_update);
743   usb->stream = device->machine().sound().stream_alloc(*device, 0, 1, SAMPLE_RATE, NULL, usb_stream_update);
654744
655745   /* initialize state */
656   usb.noise_shift = 0x15555;
746   usb->noise_shift = 0x15555;
657747
658748   for (tgroup = 0; tgroup < 3; tgroup++)
659749   {
660      timer8253 *g = &usb.timer_group[tgroup];
750      timer8253 *g = &usb->timer_group[tgroup];
661751      configure_filter(&g->chan_filter[0], 10e3, 1e-6);
662752      configure_filter(&g->chan_filter[1], 10e3, 1e-6);
663753      configure_filter(&g->gate1, 100e3, 0.01e-6);
r11160r11161
665755   }
666756
667757   configure_filter(&temp, 100e3, 0.01e-6);
668   usb.gate_rc1_exp[0] = temp.exponent;
758   usb->gate_rc1_exp[0] = temp.exponent;
669759   configure_filter(&temp, 1e3, 0.01e-6);
670   usb.gate_rc1_exp[1] = temp.exponent;
760   usb->gate_rc1_exp[1] = temp.exponent;
671761   configure_filter(&temp, 2 * 100e3, 0.01e-6);
672   usb.gate_rc2_exp[0] = temp.exponent;
762   usb->gate_rc2_exp[0] = temp.exponent;
673763   configure_filter(&temp, 2 * 1e3, 0.01e-6);
674   usb.gate_rc2_exp[1] = temp.exponent;
764   usb->gate_rc2_exp[1] = temp.exponent;
675765
676   configure_filter(&usb.noise_filters[0], 2.7e3 + 2.7e3, 1.0e-6);
677   configure_filter(&usb.noise_filters[1], 2.7e3 + 1e3, 0.30e-6);
678   configure_filter(&usb.noise_filters[2], 2.7e3 + 270, 0.15e-6);
679   configure_filter(&usb.noise_filters[3], 2.7e3 + 0, 0.082e-6);
680   configure_filter(&usb.noise_filters[4], 33e3, 0.1e-6);
766   configure_filter(&usb->noise_filters[0], 2.7e3 + 2.7e3, 1.0e-6);
767   configure_filter(&usb->noise_filters[1], 2.7e3 + 1e3, 0.30e-6);
768   configure_filter(&usb->noise_filters[2], 2.7e3 + 270, 0.15e-6);
769   configure_filter(&usb->noise_filters[3], 2.7e3 + 0, 0.082e-6);
770   configure_filter(&usb->noise_filters[4], 33e3, 0.1e-6);
681771
682   configure_filter(&usb.final_filter, 100e3, 4.7e-6);
772   configure_filter(&usb->final_filter, 100e3, 4.7e-6);
683773
684774   /* register for save states */
685   state_save_register_item(machine, "usb", NULL, 0, usb.in_latch);
686   state_save_register_item(machine, "usb", NULL, 0, usb.out_latch);
687   state_save_register_item(machine, "usb", NULL, 0, usb.last_p2_value);
688   state_save_register_item(machine, "usb", NULL, 0, usb.work_ram_bank);
689   state_save_register_item(machine, "usb", NULL, 0, usb.t1_clock);
775   state_save_register_item(machine, "usb", NULL, 0, usb->in_latch);
776   state_save_register_item(machine, "usb", NULL, 0, usb->out_latch);
777   state_save_register_item(machine, "usb", NULL, 0, usb->last_p2_value);
778   state_save_register_item(machine, "usb", NULL, 0, usb->work_ram_bank);
779   state_save_register_item(machine, "usb", NULL, 0, usb->t1_clock);
690780
691781   for (tgroup = 0; tgroup < 3; tgroup++)
692782   {
693      timer8253 *group = &usb.timer_group[tgroup];
783      timer8253 *group = &usb->timer_group[tgroup];
694784      for (tchan = 0; tchan < 3; tchan++)
695785      {
696786         timer8253_channel *channel = &group->chan[tchan];
r11160r11161
714804      state_save_register_item(machine, "usb", NULL, tgroup, group->config);
715805   }
716806
717   state_save_register_item_array(machine, "usb", NULL, 0, usb.timer_mode);
718   state_save_register_item(machine, "usb", NULL, 0, usb.noise_shift);
719   state_save_register_item(machine, "usb", NULL, 0, usb.noise_state);
720   state_save_register_item(machine, "usb", NULL, 0, usb.noise_subcount);
721   state_save_register_item(machine, "usb", NULL, 0, usb.final_filter.capval);
722   state_save_register_item(machine, "usb", NULL, 0, usb.noise_filters[0].capval);
723   state_save_register_item(machine, "usb", NULL, 0, usb.noise_filters[1].capval);
724   state_save_register_item(machine, "usb", NULL, 0, usb.noise_filters[2].capval);
725   state_save_register_item(machine, "usb", NULL, 0, usb.noise_filters[3].capval);
726   state_save_register_item(machine, "usb", NULL, 0, usb.noise_filters[4].capval);
807   state_save_register_item_array(machine, "usb", NULL, 0, usb->timer_mode);
808   state_save_register_item(machine, "usb", NULL, 0, usb->noise_shift);
809   state_save_register_item(machine, "usb", NULL, 0, usb->noise_state);
810   state_save_register_item(machine, "usb", NULL, 0, usb->noise_subcount);
811   state_save_register_item(machine, "usb", NULL, 0, usb->final_filter.capval);
812   state_save_register_item(machine, "usb", NULL, 0, usb->noise_filters[0].capval);
813   state_save_register_item(machine, "usb", NULL, 0, usb->noise_filters[1].capval);
814   state_save_register_item(machine, "usb", NULL, 0, usb->noise_filters[2].capval);
815   state_save_register_item(machine, "usb", NULL, 0, usb->noise_filters[3].capval);
816   state_save_register_item(machine, "usb", NULL, 0, usb->noise_filters[4].capval);
727817}
728818
729819
r11160r11161
731821{
732822   switch (state)
733823   {
824      /* --- the following bits of info are returned as 64-bit signed integers --- */
825      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(usb_state);         break;
826
734827      /* --- the following bits of info are returned as pointers to data or functions --- */
735828      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(usb_sound);      break;
829      case DEVINFO_FCT_RESET:                     info->start = DEVICE_RESET_NAME(usb_sound);      break;
736830
737831      /* --- the following bits of info are returned as NULL-terminated strings --- */
738832      case DEVINFO_STR_NAME:                     strcpy(info->s, "Sega Universal Sound Board");   break;
r11160r11161
740834   }
741835}
742836
743DECLARE_LEGACY_SOUND_DEVICE(SEGAUSB, usb_sound);
744837DEFINE_LEGACY_SOUND_DEVICE(SEGAUSB, usb_sound);
745838
746839
r11160r11161
751844 *
752845 *************************************/
753846
754static void timer_w(int which, UINT8 offset, UINT8 data)
847static void timer_w(usb_state *usb, int which, UINT8 offset, UINT8 data)
755848{
756   timer8253 *g = &usb.timer_group[which];
849   timer8253 *g = &usb->timer_group[which];
757850   timer8253_channel *ch;
758851   int was_holding;
759852
760   usb.stream->update();
853   usb->stream->update();
761854
762855   /* switch off the offset */
763856   switch (offset)
r11160r11161
820913}
821914
822915
823static void env_w(int which, UINT8 offset, UINT8 data)
916static void env_w(usb_state *usb, int which, UINT8 offset, UINT8 data)
824917{
825   timer8253 *g = &usb.timer_group[which];
918   timer8253 *g = &usb->timer_group[which];
826919
827   usb.stream->update();
920   usb->stream->update();
828921
829922   if (offset < 3)
830923      g->env[offset] = (double)data;
r11160r11161
840933 *
841934 *************************************/
842935
843static READ8_HANDLER( usb_workram_r )
936static READ8_DEVICE_HANDLER( usb_workram_r )
844937{
845   offset += 256 * usb.work_ram_bank;
846   return usb.work_ram[offset];
938   usb_state *usb = get_safe_token(device);
939
940   offset += 256 * usb->work_ram_bank;
941   return usb->work_ram[offset];
847942}
848943
849944
850static WRITE8_HANDLER( usb_workram_w )
945static WRITE8_DEVICE_HANDLER( usb_workram_w )
851946{
852   offset += 256 * usb.work_ram_bank;
853   usb.work_ram[offset] = data;
947   usb_state *usb = get_safe_token(device);
854948
949   offset += 256 * usb->work_ram_bank;
950   usb->work_ram[offset] = data;
951
855952   /* writes to the low 32 bytes go to various controls */
856953   switch (offset & ~3)
857954   {
858955      case 0x00:   /* CTC0 */
859         timer_w(0, offset & 3, data);
956         timer_w(usb, 0, offset & 3, data);
860957         break;
861958
862959      case 0x04:   /* ENV0 */
863         env_w(0, offset & 3, data);
960         env_w(usb, 0, offset & 3, data);
864961         break;
865962
866963      case 0x08:   /* CTC1 */
867         timer_w(1, offset & 3, data);
964         timer_w(usb, 1, offset & 3, data);
868965         break;
869966
870967      case 0x0c:   /* ENV1 */
871         env_w(1, offset & 3, data);
968         env_w(usb, 1, offset & 3, data);
872969         break;
873970
874971      case 0x10:   /* CTC2 */
875         timer_w(2, offset & 3, data);
972         timer_w(usb, 2, offset & 3, data);
876973         break;
877974
878975      case 0x14:   /* ENV2 */
879         env_w(2, offset & 3, data);
976         env_w(usb, 2, offset & 3, data);
880977         break;
881978   }
882979}
r11160r11161
890987 *************************************/
891988
892989static ADDRESS_MAP_START( usb_map, AS_PROGRAM, 8 )
893   AM_RANGE(0x0000, 0x0fff) AM_RAM AM_BASE(&usb.program_ram)
990   AM_RANGE(0x0000, 0x0fff) AM_RAM AM_SHARE("pgmram")
894991ADDRESS_MAP_END
895992
896993
r11160r11161
900997
901998
902999static ADDRESS_MAP_START( usb_portmap, AS_IO, 8 )
903   AM_RANGE(0x00, 0xff) AM_READWRITE(usb_workram_r, usb_workram_w)
904   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(usb_p1_r, usb_p1_w)
905   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(usb_p2_w)
906   AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(usb_t1_r)
1000   AM_RANGE(0x00, 0xff) AM_DEVREADWRITE("usbsnd", usb_workram_r, usb_workram_w)
1001   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_DEVREADWRITE("usbsnd", usb_p1_r, usb_p1_w)
1002   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_DEVWRITE("usbsnd", usb_p2_w)
1003   AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_DEVREAD("usbsnd", usb_t1_r)
9071004ADDRESS_MAP_END
9081005
9091006
src/mame/audio/segasnd.h
r11160r11161
66
77MACHINE_CONFIG_EXTERN( sega_speech_board );
88
9WRITE8_HANDLER( sega_speech_data_w );
10WRITE8_HANDLER( sega_speech_control_w );
9WRITE8_DEVICE_HANDLER( sega_speech_data_w );
10WRITE8_DEVICE_HANDLER( sega_speech_control_w );
1111
1212
1313
1414MACHINE_CONFIG_EXTERN( sega_universal_sound_board );
1515MACHINE_CONFIG_EXTERN( sega_universal_sound_board_rom );
1616
17void sega_usb_reset(running_machine &machine, UINT8 t1_clock_mask);
18
19READ8_HANDLER( sega_usb_status_r );
20WRITE8_HANDLER( sega_usb_data_w );
21READ8_HANDLER( sega_usb_ram_r );
22WRITE8_HANDLER( sega_usb_ram_w );
17READ8_DEVICE_HANDLER( sega_usb_status_r );
18WRITE8_DEVICE_HANDLER( sega_usb_data_w );
19READ8_DEVICE_HANDLER( sega_usb_ram_r );
20WRITE8_DEVICE_HANDLER( sega_usb_ram_w );
src/mame/audio/taito_en.c
r11160r11161
238238   }
239239}
240240
241static UINT16 *sound_ram;
242
243241static ADDRESS_MAP_START( f3_sound_map, AS_PROGRAM, 16 )
244   AM_RANGE(0x000000, 0x00ffff) AM_RAM AM_MIRROR(0x30000) AM_SHARE("share1") AM_BASE(&sound_ram)
242   AM_RANGE(0x000000, 0x00ffff) AM_RAM AM_MIRROR(0x30000) AM_SHARE("share1")
245243   AM_RANGE(0x140000, 0x140fff) AM_READWRITE(f3_68000_share_r, f3_68000_share_w)
246244   AM_RANGE(0x200000, 0x20001f) AM_DEVREADWRITE("ensoniq", es5505_r, es5505_w)
247245   AM_RANGE(0x260000, 0x2601ff) AM_READWRITE(es5510_dsp_r, es5510_dsp_w)
r11160r11161
258256{
259257   /* Sound cpu program loads to 0xc00000 so we use a bank */
260258   UINT16 *ROM = (UINT16 *)machine.region("audiocpu")->base();
259   UINT16 *sound_ram = (UINT16 *)memory_get_shared(machine, "share1");
261260   memory_set_bankptr(machine, "bank1",&ROM[0x80000]);
262261   memory_set_bankptr(machine, "bank2",&ROM[0x90000]);
263262   memory_set_bankptr(machine, "bank3",&ROM[0xa0000]);
src/mame/audio/scramble.c
r11160r11161
1717#include "sound/flt_rc.h"
1818#include "sound/tms5110.h"
1919#include "sound/ay8910.h"
20#include "includes/galaxold.h"
20#include "includes/scramble.h"
2121
2222#define AD2083_TMS5110_CLOCK      XTAL_640kHz
2323
src/mame/audio/dcs.c
r11160r11161
216216
217217
218218/* these macros are used to reference the SDRC ASIC */
219#define SDRC_ROM_ST      ((sdrc.reg[0] >> 0) & 3)   /* 0=0000, 1=3000, 2=3400, 3=none */
220#define SDRC_ROM_SZ      ((sdrc.reg[0] >> 4) & 1)   /* 0=4k, 1=1k */
221#define SDRC_ROM_MS      ((sdrc.reg[0] >> 5) & 1)   /* 0=/BMS, 1=/DMS */
222#define SDRC_ROM_PG      ((sdrc.reg[0] >> 7) & 7)
223#define SDRC_SM_EN      ((sdrc.reg[0] >> 11) & 1)
224#define SDRC_SM_BK      ((sdrc.reg[0] >> 12) & 1)
225#define SDRC_SMODE      ((sdrc.reg[0] >> 13) & 7)
219#define SDRC_ROM_ST      ((dcs.sdrc.reg[0] >> 0) & 3)   /* 0=0000, 1=3000, 2=3400, 3=none */
220#define SDRC_ROM_SZ      ((dcs.sdrc.reg[0] >> 4) & 1)   /* 0=4k, 1=1k */
221#define SDRC_ROM_MS      ((dcs.sdrc.reg[0] >> 5) & 1)   /* 0=/BMS, 1=/DMS */
222#define SDRC_ROM_PG      ((dcs.sdrc.reg[0] >> 7) & 7)
223#define SDRC_SM_EN      ((dcs.sdrc.reg[0] >> 11) & 1)
224#define SDRC_SM_BK      ((dcs.sdrc.reg[0] >> 12) & 1)
225#define SDRC_SMODE      ((dcs.sdrc.reg[0] >> 13) & 7)
226226
227#define SDRC_DM_ST      ((sdrc.reg[1] >> 0) & 3)   /* 0=none, 1=0000, 2=3000, 3=3400 */
228#define SDRC_DM_REF      ((sdrc.reg[1] >> 4) & 3)
229#define SDRC_DM_3WS      ((sdrc.reg[1] >> 7) & 1)
230#define SDRC_TFS_INV   ((sdrc.reg[1] >> 8) & 1)
231#define SDRC_RES_TFS   ((sdrc.reg[1] >> 10) & 3)
232#define SDRC_LED      ((sdrc.reg[1] >> 13) & 1)
233#define SDRC_MUTE      ((sdrc.reg[1] >> 14) & 1)
234#define SDRC_AREF_ACT   ((sdrc.reg[1] >> 15) & 1)
227#define SDRC_DM_ST      ((dcs.sdrc.reg[1] >> 0) & 3)   /* 0=none, 1=0000, 2=3000, 3=3400 */
228#define SDRC_DM_REF      ((dcs.sdrc.reg[1] >> 4) & 3)
229#define SDRC_DM_3WS      ((dcs.sdrc.reg[1] >> 7) & 1)
230#define SDRC_TFS_INV   ((dcs.sdrc.reg[1] >> 8) & 1)
231#define SDRC_RES_TFS   ((dcs.sdrc.reg[1] >> 10) & 3)
232#define SDRC_LED      ((dcs.sdrc.reg[1] >> 13) & 1)
233#define SDRC_MUTE      ((dcs.sdrc.reg[1] >> 14) & 1)
234#define SDRC_AREF_ACT   ((dcs.sdrc.reg[1] >> 15) & 1)
235235
236#define SDRC_DM_PG      ((sdrc.reg[2] >> 0) & 0x7ff)
237#define SDRC_EPM_PG      ((sdrc.reg[2] >> 0) & 0x1fff)
236#define SDRC_DM_PG      ((dcs.sdrc.reg[2] >> 0) & 0x7ff)
237#define SDRC_EPM_PG      ((dcs.sdrc.reg[2] >> 0) & 0x1fff)
238238
239239
240240/* these macros are used to reference the DSIO ASIC */
241#define DSIO_EMPTY_FIFO   ((dsio.reg[1] >> 0) & 1)
242#define DSIO_CUR_OUTPUT   ((dsio.reg[1] >> 4) & 1)
243#define DSIO_RES_TFS   ((dsio.reg[1] >> 10) & 1)
244#define DSIO_LED      ((dsio.reg[1] >> 13) & 1)
245#define DSIO_MUTE      ((dsio.reg[1] >> 14) & 1)
241#define DSIO_EMPTY_FIFO   ((dcs.dsio.reg[1] >> 0) & 1)
242#define DSIO_CUR_OUTPUT   ((dcs.dsio.reg[1] >> 4) & 1)
243#define DSIO_RES_TFS   ((dcs.dsio.reg[1] >> 10) & 1)
244#define DSIO_LED      ((dcs.dsio.reg[1] >> 13) & 1)
245#define DSIO_MUTE      ((dcs.dsio.reg[1] >> 14) & 1)
246246
247#define DSIO_DM_PG      ((dsio.reg[2] >> 0) & 0x7ff)
247#define DSIO_DM_PG      ((dcs.dsio.reg[2] >> 0) & 0x7ff)
248248
249249
250250/* these macros are used to reference the DENVER ASIC */
251#define DENV_DSP_SPEED   ((dsio.reg[1] >> 2) & 3)   /* read only: 1=33.33MHz */
252#define DENV_RES_TFS   ((dsio.reg[1] >> 10) & 1)
253#define DENV_CHANNELS   ((dsio.reg[1] >> 11) & 3)   /* 0=2ch, 1=4ch, 2=6ch */
254#define DENV_LED      ((dsio.reg[1] >> 13) & 1)
255#define DENV_MUTE      ((dsio.reg[1] >> 14) & 1)
251#define DENV_DSP_SPEED   ((dcs.dsio.reg[1] >> 2) & 3)   /* read only: 1=33.33MHz */
252#define DENV_RES_TFS   ((dcs.dsio.reg[1] >> 10) & 1)
253#define DENV_CHANNELS   ((dcs.dsio.reg[1] >> 11) & 3)   /* 0=2ch, 1=4ch, 2=6ch */
254#define DENV_LED      ((dcs.dsio.reg[1] >> 13) & 1)
255#define DENV_MUTE      ((dcs.dsio.reg[1] >> 14) & 1)
256256
257#define DENV_DM_PG      ((dsio.reg[2] >> 0) & 0x7ff)
257#define DENV_DM_PG      ((dcs.dsio.reg[2] >> 0) & 0x7ff)
258258
259259
260260
r11160r11161
281281};
282282
283283
284typedef struct _hle_transfer_state hle_transfer_state;
285struct _hle_transfer_state
286{
287   UINT8      hle_enabled;
288   INT32      dcs_state;
289   INT32      state;
290   INT32      start;
291   INT32      stop;
292   INT32      type;
293   INT32      temp;
294   INT32      writes_left;
295   UINT16      sum;
296   INT32      fifo_entries;
297   timer_device *watchdog;
298};
299
300
284301typedef struct _dcs_state dcs_state;
285302struct _dcs_state
286303{
r11160r11161
334351   UINT32      timer_scale;
335352   UINT32      timer_period;
336353   UINT32      timers_fired;
337};
338354
355   UINT16 *sram;
356   UINT16 *polling_base;
357   UINT32 *internal_program_ram;
358   UINT32 *external_program_ram;
339359
340typedef struct _hle_transfer_state hle_transfer_state;
341struct _hle_transfer_state
342{
343   UINT8      hle_enabled;
344   INT32      dcs_state;
345   INT32      state;
346   INT32      start;
347   INT32      stop;
348   INT32      type;
349   INT32      temp;
350   INT32      writes_left;
351   UINT16      sum;
352   INT32      fifo_entries;
353   timer_device *watchdog;
360   sdrc_state sdrc;
361   dsio_state dsio;
362   hle_transfer_state transfer;
354363};
355364
356365
r11160r11161
362371 *************************************/
363372
364373static dcs_state dcs;
365static sdrc_state sdrc;
366static dsio_state dsio;
367static hle_transfer_state transfer;
368374
369static UINT16 *dcs_sram;
370375
371static UINT16 *dcs_polling_base;
372376
373static UINT32 *dcs_internal_program_ram;
374static UINT32 *dcs_external_program_ram;
375
376
377
378377/*************************************
379378 *
380379 *  Prototypes
r11160r11161
390389static WRITE16_HANDLER( sdrc_w );
391390static STATE_POSTLOAD( sdrc_postload );
392391
393static void dsio_reset(void);
392static void dsio_reset(running_machine &machine);
394393static READ16_HANDLER( dsio_r );
395394static WRITE16_HANDLER( dsio_w );
396395
397static void denver_reset(void);
396static void denver_reset(running_machine &machine);
398397static READ16_HANDLER( denver_r );
399398static WRITE16_HANDLER( denver_w );
400399
r11160r11161
432431
433432/* DCS 2k memory map */
434433static ADDRESS_MAP_START( dcs_2k_program_map, AS_PROGRAM, 32 )
435   AM_RANGE(0x0000, 0x03ff) AM_RAM AM_BASE(&dcs_internal_program_ram)
436   AM_RANGE(0x0800, 0x0fff) AM_RAM AM_SHARE("share1") AM_BASE(&dcs_external_program_ram)
437   AM_RANGE(0x1000, 0x17ff) AM_RAM AM_SHARE("share1")
438   AM_RANGE(0x1800, 0x1fff) AM_RAM AM_SHARE("share1")
434   AM_RANGE(0x0000, 0x03ff) AM_RAM AM_SHARE("dcsint")
435   AM_RANGE(0x0800, 0x0fff) AM_RAM AM_SHARE("dcsext")
436   AM_RANGE(0x1000, 0x17ff) AM_RAM AM_SHARE("dcsext")
437   AM_RANGE(0x1800, 0x1fff) AM_RAM AM_SHARE("dcsext")
439438ADDRESS_MAP_END
440439
441440static ADDRESS_MAP_START( dcs_2k_data_map, AS_DATA, 16 )
r11160r11161
463462
464463/* DCS 8k memory map */
465464static ADDRESS_MAP_START( dcs_8k_program_map, AS_PROGRAM, 32 )
466   AM_RANGE(0x0000, 0x03ff) AM_RAM AM_BASE(&dcs_internal_program_ram)
467   AM_RANGE(0x0800, 0x1fff) AM_RAM AM_BASE(&dcs_external_program_ram)
465   AM_RANGE(0x0000, 0x03ff) AM_RAM AM_SHARE("dcsint")
466   AM_RANGE(0x0800, 0x1fff) AM_RAM AM_SHARE("dcsext")
468467ADDRESS_MAP_END
469468
470469static ADDRESS_MAP_START( dcs_8k_data_map, AS_DATA, 16 )
r11160r11161
487486
488487static ADDRESS_MAP_START( dcs2_2115_program_map, AS_PROGRAM, 32 )
489488   ADDRESS_MAP_UNMAP_HIGH
490   AM_RANGE(0x0000, 0x03ff) AM_RAM   AM_BASE(&dcs_internal_program_ram)
489   AM_RANGE(0x0000, 0x03ff) AM_RAM   AM_SHARE("dcsint")
491490ADDRESS_MAP_END
492491
493492static ADDRESS_MAP_START( dcs2_2104_program_map, AS_PROGRAM, 32 )
494493   ADDRESS_MAP_UNMAP_HIGH
495   AM_RANGE(0x0000, 0x01ff) AM_RAM   AM_BASE(&dcs_internal_program_ram)
494   AM_RANGE(0x0000, 0x01ff) AM_RAM   AM_SHARE("dcsint")
496495ADDRESS_MAP_END
497496
498497
r11160r11161
530529
531530static ADDRESS_MAP_START( dsio_program_map, AS_PROGRAM, 32 )
532531   ADDRESS_MAP_UNMAP_HIGH
533   AM_RANGE(0x0000, 0x3fff) AM_RAM   AM_BASE(&dcs_internal_program_ram)
532   AM_RANGE(0x0000, 0x3fff) AM_RAM   AM_SHARE("dcsint")
534533ADDRESS_MAP_END
535534
536535
r11160r11161
562561
563562static ADDRESS_MAP_START( denver_program_map, AS_PROGRAM, 32 )
564563   ADDRESS_MAP_UNMAP_HIGH
565   AM_RANGE(0x0000, 0x3fff) AM_RAM   AM_BASE(&dcs_internal_program_ram)
564   AM_RANGE(0x0000, 0x3fff) AM_RAM   AM_SHARE("dcsint")
566565ADDRESS_MAP_END
567566
568567
r11160r11161
750749 *
751750 *************************************/
752751
753static void dcs_boot(void)
752static void dcs_boot(running_machine &machine)
754753{
755754   UINT8 buffer[0x1000];
756755   UINT32 max_banks;
r11160r11161
769768         /* convert from 16-bit data to 8-bit data and boot */
770769         for (i = 0; i < 0x1000; i++)
771770            buffer[i] = base[i];
772         dcs.cpu->load_boot_data(buffer, dcs_internal_program_ram);
771         dcs.cpu->load_boot_data(buffer, dcs.internal_program_ram);
773772         break;
774773
775774      /* rev 2: use the ROM page in the SDRC to boot from */
r11160r11161
790789         /* convert from 16-bit data to 8-bit data and boot */
791790         for (i = 0; i < 0x1000; i++)
792791            buffer[i] = base[i];
793         dcs.cpu->load_boot_data(buffer, dcs_internal_program_ram);
792         dcs.cpu->load_boot_data(buffer, dcs.internal_program_ram);
794793         break;
795794
796795      /* rev 3/4: HALT the ADSP-2181 until program is downloaded via IDMA */
797796      case 3:
798797      case 4:
799798         device_set_input_line(dcs.cpu, INPUT_LINE_HALT, ASSERT_LINE);
800         dsio.start_on_next_write = 0;
799         dcs.dsio.start_on_next_write = 0;
801800         break;
802801   }
803802}
r11160r11161
831830
832831      /* rev 3: reset the DSIO ASIC */
833832      case 3:
834         dsio_reset();
833         dsio_reset(machine);
835834         break;
836835
837836      /* rev 4: reset the Denver ASIC */
838837      case 4:
839         denver_reset();
838         denver_reset(machine);
840839         break;
841840   }
842841
r11160r11161
862861      (*dcs.output_full_cb)(machine, dcs.last_output_full = 0);
863862
864863   /* boot */
865   dcs_boot();
864   dcs_boot(machine);
866865
867866   /* reset timers */
868867   dcs.timer_enable = 0;
r11160r11161
874873      dcs.sport_timer->adjust(attotime::from_hz(1000), 0, attotime::from_hz(1000));
875874
876875   /* reset the HLE transfer states */
877   transfer.dcs_state = transfer.state = 0;
876   dcs.transfer.dcs_state = dcs.transfer.state = 0;
878877}
879878
880879
r11160r11161
887886
888887static void dcs_register_state(running_machine &machine)
889888{
890   state_save_register_global_array(machine, sdrc.reg);
891   state_save_register_global(machine, sdrc.seed);
889   state_save_register_global_array(machine, dcs.sdrc.reg);
890   state_save_register_global(machine, dcs.sdrc.seed);
892891
893   state_save_register_global_array(machine, dsio.reg);
894   state_save_register_global(machine, dsio.start_on_next_write);
895   state_save_register_global(machine, dsio.channelbits);
892   state_save_register_global_array(machine, dcs.dsio.reg);
893   state_save_register_global(machine, dcs.dsio.start_on_next_write);
894   state_save_register_global(machine, dcs.dsio.channelbits);
896895
897896   state_save_register_global(machine, dcs.channels);
898897   state_save_register_global(machine, dcs.size);
r11160r11161
921920   state_save_register_global(machine, dcs.timer_period);
922921   state_save_register_global(machine, dcs.timers_fired);
923922
924   state_save_register_global(machine, transfer.dcs_state);
925   state_save_register_global(machine, transfer.state);
926   state_save_register_global(machine, transfer.start);
927   state_save_register_global(machine, transfer.stop);
928   state_save_register_global(machine, transfer.type);
929   state_save_register_global(machine, transfer.temp);
930   state_save_register_global(machine, transfer.writes_left);
931   state_save_register_global(machine, transfer.sum);
932   state_save_register_global(machine, transfer.fifo_entries);
923   state_save_register_global(machine, dcs.transfer.dcs_state);
924   state_save_register_global(machine, dcs.transfer.state);
925   state_save_register_global(machine, dcs.transfer.start);
926   state_save_register_global(machine, dcs.transfer.stop);
927   state_save_register_global(machine, dcs.transfer.type);
928   state_save_register_global(machine, dcs.transfer.temp);
929   state_save_register_global(machine, dcs.transfer.writes_left);
930   state_save_register_global(machine, dcs.transfer.sum);
931   state_save_register_global(machine, dcs.transfer.fifo_entries);
933932
934   if (dcs_sram != NULL)
935      state_save_register_global_pointer(machine, dcs_sram, 0x8000*4 / sizeof(dcs_sram[0]));
933   if (dcs.sram != NULL)
934      state_save_register_global_pointer(machine, dcs.sram, 0x8000*4 / sizeof(dcs.sram[0]));
936935
937936   if (dcs.rev == 2)
938937      machine.state().register_postload(sdrc_postload, NULL);
r11160r11161
941940void dcs_init(running_machine &machine)
942941{
943942   memset(&dcs, 0, sizeof(dcs));
944   dcs_sram = NULL;
943   dcs.sram = NULL;
945944
945   dcs.internal_program_ram = (UINT32 *)memory_get_shared(machine, "dcsint");
946   dcs.external_program_ram = (UINT32 *)memory_get_shared(machine, "dcsext");
947
946948   /* find the DCS CPU and the sound ROMs */
947949   dcs.cpu = machine.device<adsp21xx_device>("dcs");
948950   dcs.program = dcs.cpu->space(AS_PROGRAM);
r11160r11161
979981   int soundbank_words;
980982
981983   memset(&dcs, 0, sizeof(dcs));
984   dcs.internal_program_ram = (UINT32 *)memory_get_shared(machine, "dcsint");
985   dcs.external_program_ram = (UINT32 *)memory_get_shared(machine, "dcsext");
982986
983987   /* find the DCS CPU and the sound ROMs */
984988   dcs.cpu = machine.device<adsp21xx_device>("dcs2");
r11160r11161
10221026      memory_configure_bank(machine, "databank", 0, dcs.sounddata_banks, dcs.sounddata, soundbank_words*2);
10231027
10241028   /* allocate memory for the SRAM */
1025   dcs_sram = auto_alloc_array(machine, UINT16, 0x8000*4/2);
1029   dcs.sram = auto_alloc_array(machine, UINT16, 0x8000*4/2);
10261030
10271031   /* create the timers */
10281032   dcs.internal_timer = machine.device<timer_device>("dcs_int_timer");
r11160r11161
10351039   /* install the speedup handler */
10361040   dcs.polling_offset = polling_offset;
10371041   if (polling_offset)
1038      dcs_polling_base = dcs.cpu->space(AS_DATA)->install_legacy_readwrite_handler(polling_offset, polling_offset, FUNC(dcs_polling_r), FUNC(dcs_polling_w));
1042      dcs.polling_base = dcs.cpu->space(AS_DATA)->install_legacy_readwrite_handler(dcs.polling_offset, dcs.polling_offset, FUNC(dcs_polling_r), FUNC(dcs_polling_w));
10391043
10401044   /* allocate a watchdog timer for HLE transfers */
1041   transfer.hle_enabled = (ENABLE_HLE_TRANSFERS && dram_in_mb != 0);
1042   if (transfer.hle_enabled)
1043      transfer.watchdog = machine.device<timer_device>("dcs_hle_timer");
1045   dcs.transfer.hle_enabled = (ENABLE_HLE_TRANSFERS && dram_in_mb != 0);
1046   if (dcs.transfer.hle_enabled)
1047      dcs.transfer.watchdog = machine.device<timer_device>("dcs_hle_timer");
10441048
10451049   /* register for save states */
10461050   dcs_register_state(machine);
r11160r11161
10501054}
10511055
10521056
1053void dcs_set_auto_ack(int state)
1057void dcs_set_auto_ack(running_machine &machine, int state)
10541058{
10551059   dcs.auto_ack = state;
10561060}
r11160r11161
10651069
10661070static READ16_HANDLER( dcs_dataram_r )
10671071{
1068   return dcs_external_program_ram[offset] >> 8;
1072   return dcs.external_program_ram[offset] >> 8;
10691073}
10701074
10711075
10721076static WRITE16_HANDLER( dcs_dataram_w )
10731077{
1074   UINT16 newdata = dcs_external_program_ram[offset] >> 8;
1078   UINT16 newdata = dcs.external_program_ram[offset] >> 8;
10751079   COMBINE_DATA(&newdata);
1076   dcs_external_program_ram[offset] = (newdata << 8) | (dcs_external_program_ram[offset] & 0xff);
1080   dcs.external_program_ram[offset] = (newdata << 8) | (dcs.external_program_ram[offset] & 0xff);
10771081}
10781082
10791083
r11160r11161
11341138   else
11351139   {
11361140      /* first start with a clean program map */
1137      dcs.program->install_ram(0x0800, 0x3fff, dcs_sram + 0x4800);
1141      dcs.program->install_ram(0x0800, 0x3fff, dcs.sram + 0x4800);
11381142
11391143      /* set up the data map based on the SRAM banking */
11401144      /* map 0: ram from 0800-37ff */
11411145      if (SDRC_SM_BK == 0)
11421146      {
1143         dcs.data->install_ram(0x0800, 0x17ff, dcs_sram + 0x0000);
1144         dcs.data->install_ram(0x1800, 0x27ff, dcs_sram + 0x1000);
1145         dcs.data->install_ram(0x2800, 0x37ff, dcs_sram + 0x2000);
1147         dcs.data->install_ram(0x0800, 0x17ff, dcs.sram + 0x0000);
1148         dcs.data->install_ram(0x1800, 0x27ff, dcs.sram + 0x1000);
1149         dcs.data->install_ram(0x2800, 0x37ff, dcs.sram + 0x2000);
11461150      }
11471151
11481152      /* map 1: nothing from 0800-17ff, alternate RAM at 1800-27ff, same RAM at 2800-37ff */
11491153      else
11501154      {
11511155         dcs.data->unmap_readwrite(0x0800, 0x17ff);
1152         dcs.data->install_ram(0x1800, 0x27ff, dcs_sram + 0x3000);
1153         dcs.data->install_ram(0x2800, 0x37ff, dcs_sram + 0x2000);
1156         dcs.data->install_ram(0x1800, 0x27ff, dcs.sram + 0x3000);
1157         dcs.data->install_ram(0x2800, 0x37ff, dcs.sram + 0x2000);
11541158      }
11551159   }
11561160
r11160r11161
11741178
11751179   /* reinstall the polling hotspot */
11761180   if (dcs.polling_offset)
1177      dcs_polling_base = dcs.cpu->space(AS_DATA)->install_legacy_readwrite_handler(dcs.polling_offset, dcs.polling_offset, FUNC(dcs_polling_r), FUNC(dcs_polling_w));
1181      dcs.polling_base = dcs.cpu->space(AS_DATA)->install_legacy_readwrite_handler(dcs.polling_offset, dcs.polling_offset, FUNC(dcs_polling_r), FUNC(dcs_polling_w));
11781182}
11791183
11801184
r11160r11161
11861190
11871191static void sdrc_reset(running_machine &machine)
11881192{
1189   memset(sdrc.reg, 0, sizeof(sdrc.reg));
1193   memset(dcs.sdrc.reg, 0, sizeof(dcs.sdrc.reg));
11901194   sdrc_remap_memory(machine);
11911195}
11921196
r11160r11161
12001204
12011205static READ16_HANDLER( sdrc_r )
12021206{
1207   sdrc_state &sdrc = dcs.sdrc;
12031208   UINT16 result = sdrc.reg[offset];
12041209
12051210   /* offset 3 is for security */
r11160r11161
12481253
12491254static WRITE16_HANDLER( sdrc_w )
12501255{
1256   sdrc_state &sdrc = dcs.sdrc;
12511257   UINT16 diff = sdrc.reg[offset] ^ data;
12521258
12531259   switch (offset)
r11160r11161
12641270      /* offset 1 controls RAM mapping */
12651271      case 1:
12661272         sdrc.reg[1] = data;
1267//          dmadac_enable(&dcs.dmadac[0], dcs.channels, SDRC_MUTE);
1273         //dmadac_enable(&dcs.dmadac[0], dcs.channels, SDRC_MUTE);
12681274         if (diff & 0x0003)
12691275            sdrc_remap_memory(space->machine());
12701276         break;
r11160r11161
13201326 *
13211327 *************************************/
13221328
1323static void dsio_reset(void)
1329static void dsio_reset(running_machine &machine)
13241330{
1325   memset(&dsio, 0, sizeof(dsio));
1331   memset(&dcs.dsio, 0, sizeof(dcs.dsio));
13261332}
13271333
13281334
13291335static READ16_HANDLER( dsio_r )
13301336{
1337   dsio_state &dsio = dcs.dsio;
13311338   UINT16 result = dsio.reg[offset];
13321339
13331340   if (offset == 1)
r11160r11161
13421349
13431350static WRITE16_HANDLER( dsio_w )
13441351{
1352   dsio_state &dsio = dcs.dsio;
1353
13451354   switch (offset)
13461355   {
13471356      /* offset 1 controls I/O */
r11160r11161
13711380 *
13721381 *************************************/
13731382
1374static void denver_reset(void)
1383static void denver_reset(running_machine &machine)
13751384{
1376   memset(&dsio, 0, sizeof(dsio));
1385   memset(&dcs.dsio, 0, sizeof(dcs.dsio));
13771386}
13781387
13791388
13801389static READ16_HANDLER( denver_r )
13811390{
1382   UINT16 result = dsio.reg[offset];
1391   UINT16 result = dcs.dsio.reg[offset];
13831392
13841393   if (offset == 3)
13851394   {
r11160r11161
13921401
13931402static WRITE16_HANDLER( denver_w )
13941403{
1404   dsio_state &dsio = dcs.dsio;
13951405   int enable, channels, chan;
13961406
13971407   switch (offset)
r11160r11161
14441454
14451455WRITE32_HANDLER( dsio_idma_addr_w )
14461456{
1457   dsio_state &dsio = dcs.dsio;
14471458   if (LOG_DCS_TRANSFERS)
14481459      logerror("%08X:IDMA_addr = %04X\n", cpu_get_pc(&space->device()), data);
14491460   downcast<adsp2181_device *>(dcs.cpu)->idma_addr_w(data);
r11160r11161
14541465
14551466WRITE32_HANDLER( dsio_idma_data_w )
14561467{
1468   dsio_state &dsio = dcs.dsio;
14571469   UINT32 pc = cpu_get_pc(&space->device());
14581470   if (ACCESSING_BITS_0_15)
14591471   {
r11160r11161
15041516}
15051517
15061518
1507int dcs_control_r(void)
1519int dcs_control_r(running_machine &machine)
15081520{
15091521   /* only boost for DCS2 boards */
1510   if (!dcs.auto_ack && !transfer.hle_enabled)
1511      dcs.cpu->machine().scheduler().boost_interleave(attotime::from_nsec(500), attotime::from_usec(5));
1522   if (!dcs.auto_ack && !dcs.transfer.hle_enabled)
1523      machine.scheduler().boost_interleave(attotime::from_nsec(500), attotime::from_usec(5));
15121524   return dcs.latch_control;
15131525}
15141526
15151527
1516void dcs_reset_w(int state)
1528void dcs_reset_w(running_machine &machine, int state)
15171529{
15181530   /* going high halts the CPU */
15191531   if (state)
15201532   {
1521      logerror("%s: DCS reset = %d\n", dcs.cpu->machine().describe_context(), state);
1533      logerror("%s: DCS reset = %d\n", machine.describe_context(), state);
15221534
15231535      /* just run through the init code again */
1524      dcs.cpu->machine().scheduler().synchronize(FUNC(dcs_reset));
1536      machine.scheduler().synchronize(FUNC(dcs_reset));
15251537      device_set_input_line(dcs.cpu, INPUT_LINE_RESET, ASSERT_LINE);
15261538   }
15271539
r11160r11161
15381550      result |= 0x80;
15391551   if (IS_OUTPUT_EMPTY())
15401552      result |= 0x40;
1541   if (dcs.fifo_status_r != NULL && (!transfer.hle_enabled || transfer.state == 0))
1553   if (dcs.fifo_status_r != NULL && (!dcs.transfer.hle_enabled || dcs.transfer.state == 0))
15421554      result |= (*dcs.fifo_status_r)(dcs.cpu) & 0x38;
1543   if (transfer.hle_enabled && transfer.state != 0)
1555   if (dcs.transfer.hle_enabled && dcs.transfer.state != 0)
15441556      result |= 0x08;
15451557   return result;
15461558}
r11160r11161
15871599}
15881600
15891601
1590void dcs_data_w(int data)
1602void dcs_data_w(running_machine &machine, int data)
15911603{
15921604   /* preprocess the write */
1593   if (preprocess_write(dcs.cpu->machine(), data))
1605   if (preprocess_write(machine, data))
15941606      return;
15951607
15961608   /* if we are DCS1, set a timer to latch the data */
15971609   if (dcs.sport_timer == NULL)
1598      dcs.cpu->machine().scheduler().synchronize(FUNC(dcs_delayed_data_w_callback), data);
1610      machine.scheduler().synchronize(FUNC(dcs_delayed_data_w_callback), data);
15991611   else
1600      dcs_delayed_data_w(dcs.cpu->machine(), data);
1612      dcs_delayed_data_w(machine, data);
16011613}
16021614
16031615
r11160r11161
16421654}
16431655
16441656
1645static void delayed_ack_w(void)
1657static void delayed_ack_w(running_machine &machine)
16461658{
16471659   SET_OUTPUT_EMPTY();
16481660}
r11160r11161
16501662
16511663static TIMER_CALLBACK( delayed_ack_w_callback )
16521664{
1653   delayed_ack_w();
1665   delayed_ack_w(machine);
16541666}
16551667
16561668
1657void dcs_ack_w(void)
1669void dcs_ack_w(running_machine &machine)
16581670{
1659   dcs.cpu->machine().scheduler().synchronize(FUNC(delayed_ack_w_callback));
1671   machine.scheduler().synchronize(FUNC(delayed_ack_w_callback));
16601672}
16611673
16621674
1663int dcs_data_r(void)
1675int dcs_data_r(running_machine &machine)
16641676{
16651677   /* data is actually only 8 bit (read from d8-d15) */
16661678   if (dcs.last_output_full && dcs.output_full_cb)
1667      (*dcs.output_full_cb)(dcs.cpu->machine(), dcs.last_output_full = 0);
1679      (*dcs.output_full_cb)(machine, dcs.last_output_full = 0);
16681680   if (dcs.auto_ack)
1669      delayed_ack_w();
1681      delayed_ack_w(machine);
16701682
16711683   if (LOG_DCS_IO)
1672      logerror("%s:dcs_data_r(%04X)\n", dcs.cpu->machine().describe_context(), dcs.output_data);
1684      logerror("%s:dcs_data_r(%04X)\n", machine.describe_context(), dcs.output_data);
16731685   return dcs.output_data;
16741686}
16751687
r11160r11161
17031715}
17041716
17051717
1706int dcs_data2_r(void)
1718int dcs_data2_r(running_machine &machine)
17071719{
17081720   return dcs.output_control;
17091721}
r11160r11161
18031815   dcs.timer_ignore = 0;
18041816   if (enable)
18051817   {
1806//      mame_printf_debug("Timer enabled @ %d cycles/int, or %f Hz\n", dcs.timer_scale * (dcs.timer_period + 1), 1.0 / dcs.cpu->cycles_to_attotime(dcs.timer_scale * (dcs.timer_period + 1)));
1818      //mame_printf_debug("Timer enabled @ %d cycles/int, or %f Hz\n", dcs.timer_scale * (dcs.timer_period + 1), 1.0 / dcs.cpu->cycles_to_attotime(dcs.timer_scale * (dcs.timer_period + 1)));
18071819      reset_timer(device.machine());
18081820   }
18091821   else
18101822   {
1811//      mame_printf_debug("Timer disabled\n");
1823      //mame_printf_debug("Timer disabled\n");
18121824      dcs.internal_timer->reset();
18131825   }
18141826}
r11160r11161
18791891         {
18801892            logerror("%04X:Rebooting DCS due to SYSCONTROL write\n", cpu_get_pc(&space->device()));
18811893            device_set_input_line(dcs.cpu, INPUT_LINE_RESET, PULSE_LINE);
1882            dcs_boot();
1894            dcs_boot(space->machine());
18831895            dcs.control_regs[SYSCONTROL_REG] = 0;
18841896         }
18851897
r11160r11161
20742086{
20752087   if (dcs.polling_count++ > 5)
20762088      device_eat_cycles(&space->device(), 10000);
2077   return *dcs_polling_base;
2089   return *dcs.polling_base;
20782090}
20792091
20802092
20812093static WRITE16_HANDLER( dcs_polling_w )
20822094{
20832095   dcs.polling_count = 0;
2084   COMBINE_DATA(dcs_polling_base);
2096   COMBINE_DATA(dcs.polling_base);
20852097}
20862098
20872099
r11160r11161
20902102    DATA TRANSFER HLE MECHANISM
20912103****************************************************************************/
20922104
2093void dcs_fifo_notify(int count, int max)
2105void dcs_fifo_notify(running_machine &machine, int count, int max)
20942106{
2107   hle_transfer_state &transfer = dcs.transfer;
2108
20952109   /* skip if not in mid-transfer */
20962110   if (!transfer.hle_enabled || transfer.state == 0 || !dcs.fifo_data_r)
20972111   {
r11160r11161
21042118   if (transfer.state != 5 || transfer.fifo_entries == transfer.writes_left || transfer.fifo_entries >= 256)
21052119   {
21062120      for ( ; transfer.fifo_entries; transfer.fifo_entries--)
2107         preprocess_write(dcs.cpu->machine(), (*dcs.fifo_data_r)(dcs.cpu));
2121         preprocess_write(machine, (*dcs.fifo_data_r)(dcs.cpu));
21082122   }
21092123}
21102124
21112125
21122126static TIMER_DEVICE_CALLBACK( transfer_watchdog_callback )
21132127{
2128   hle_transfer_state &transfer = dcs.transfer;
21142129   int starting_writes_left = param;
21152130
21162131   if (transfer.fifo_entries && starting_writes_left == transfer.writes_left)
r11160r11161
21522167
21532168static int preprocess_stage_1(running_machine &machine, UINT16 data)
21542169{
2170   hle_transfer_state &transfer = dcs.transfer;
2171
21552172   switch (transfer.state)
21562173   {
21572174      case 0:
r11160r11161
22232240         {
22242241            if (transfer.type == 1 && SDRC_SM_BK == 1)
22252242            {
2226               sdrc.reg[0] &= ~0x1000;
2243               dcs.sdrc.reg[0] &= ~0x1000;
22272244               sdrc_remap_memory(machine);
22282245            }
22292246            if (transfer.type == 2 && SDRC_SM_BK == 0)
22302247            {
2231               sdrc.reg[0] |= 0x1000;
2248               dcs.sdrc.reg[0] |= 0x1000;
22322249               sdrc_remap_memory(machine);
22332250            }
22342251            return 1;
r11160r11161
22882305
22892306static int preprocess_stage_2(running_machine &machine, UINT16 data)
22902307{
2308   hle_transfer_state &transfer = dcs.transfer;
2309
22912310   switch (transfer.state)
22922311   {
22932312      case 0:
r11160r11161
23882407
23892408static int preprocess_write(running_machine &machine, UINT16 data)
23902409{
2410   hle_transfer_state &transfer = dcs.transfer;
23912411   int result;
23922412
23932413   /* if we're not DCS2, skip */
src/mame/audio/dcs.h
r11160r11161
1414
1515void dcs_init(running_machine &machine);
1616void dcs2_init(running_machine &machine, int dram_in_mb, offs_t polling_offset);
17void dcs_set_auto_ack(int state);
17void dcs_set_auto_ack(running_machine &machine, int state);
1818
1919void dcs_set_fifo_callbacks(UINT16 (*fifo_data_r)(device_t *device), UINT16 (*fifo_status_r)(device_t *device));
2020void dcs_set_io_callbacks(void (*output_full_cb)(running_machine &, int), void (*input_empty_cb)(running_machine &, int));
2121
22int dcs_data_r(void);
23void dcs_ack_w(void);
24int dcs_data2_r(void);
25int dcs_control_r(void);
22int dcs_data_r(running_machine &machine);
23void dcs_ack_w(running_machine &machine);
24int dcs_data2_r(running_machine &machine);
25int dcs_control_r(running_machine &machine);
2626
27void dcs_data_w(int data);
28void dcs_reset_w(int state);
27void dcs_data_w(running_machine &machine, int data);
28void dcs_reset_w(running_machine &machine, int state);
2929
30void dcs_fifo_notify(int count, int max);
30void dcs_fifo_notify(running_machine &machine, int count, int max);
3131
3232WRITE32_HANDLER( dsio_idma_addr_w );
3333WRITE32_HANDLER( dsio_idma_data_w );
src/mame/audio/wow.c
r11160r11161
100100};
101101
102102
103/* Total word to join the phonemes together - Global to make it easier to use */
104
105static char totalword[256], *totalword_ptr;
106static char oldword[256];
107static int plural;
108
109103READ8_HANDLER( wow_speech_r )
110104{
105   astrocde_state *state = space->machine().driver_data<astrocde_state>();
111106   device_t *samples = space->machine().device("samples");
112107   int Phoneme/*, Intonation*/;
113108   int i = 0;
114
115109   UINT8 data = offset >> 8;
116110   offset &= 0xff;
117111
118   totalword_ptr = totalword;
112   state->m_totalword_ptr = state->m_totalword;
119113
120114   Phoneme = data & 0x3F;
121//  Intonation = data >> 6;
115   //Intonation = data >> 6;
122116
123//  logerror("Data : %d Speech : %s at intonation %d\n",Phoneme, PhonemeTable[Phoneme],Intonation);
117   //logerror("Data : %d Speech : %s at intonation %d\n",Phoneme, PhonemeTable[Phoneme],Intonation);
124118
125119   if(Phoneme==63) {
126120      sample_stop(samples, 0);
127//              logerror("Clearing sample %s\n",totalword);
128            totalword[0] = 0;               /* Clear the total word stack */
129            return data;
121      //logerror("Clearing sample %s\n",state->m_totalword);
122      state->m_totalword[0] = 0;               /* Clear the total word stack */
123      return data;
130124   }
131125   if (Phoneme==3)                     /* We know PA0 is never part of a word */
132            totalword[0] = 0;               /* Clear the total word stack */
126      state->m_totalword[0] = 0;               /* Clear the total word stack */
133127
134/* Phoneme to word translation */
128   /* Phoneme to word translation */
135129
136   if (strlen(totalword) == 0) {
137      strcpy(totalword,PhonemeTable[Phoneme]);                      /* Copy over the first phoneme */
138      if (plural != 0) {
139//        logerror("found a possible plural at %d\n",plural-1);
140        if (!strcmp("S",totalword)) {         /* Plural check */
141          sample_start(samples, 0, num_samples-2, 0);      /* play the sample at position of word */
142          sample_set_freq(samples, 0, 11025);    /* play at correct rate */
143          totalword[0] = 0;               /* Clear the total word stack */
144          oldword[0] = 0;               /* Clear the total word stack */
145          return data;
146        } else {
147          plural=0;
148        }
149      }
130   if (strlen(state->m_totalword) == 0) {
131      strcpy(state->m_totalword,PhonemeTable[Phoneme]);                      /* Copy over the first phoneme */
132      if (state->m_plural != 0) {
133         //logerror("found a possible plural at %d\n",state->m_plural-1);
134         if (!strcmp("S",state->m_totalword)) {         /* Plural check */
135            sample_start(samples, 0, num_samples-2, 0);      /* play the sample at position of word */
136            sample_set_freq(samples, 0, 11025);    /* play at correct rate */
137            state->m_totalword[0] = 0;               /* Clear the total word stack */
138            state->m_oldword[0] = 0;               /* Clear the total word stack */
139            return data;
140         } else {
141             state->m_plural=0;
142         }
143      }
150144   } else
151      strcat(totalword,PhonemeTable[Phoneme]);                      /* Copy over the first phoneme */
145      strcat(state->m_totalword,PhonemeTable[Phoneme]);                      /* Copy over the first phoneme */
152146
153//  logerror("Total word = %s\n",totalword);
147   //logerror("Total word = %s\n",state->m_totalword);
154148
155149   for (i=0; wowWordTable[i]; i++) {
156      if (!strcmp(wowWordTable[i],totalword)) {         /* Scan the word (sample) table for the complete word */
157     /* WOW has Dungeon */
158        if ((!strcmp("GDTO1RFYA2N",totalword)) || (!strcmp("RO1U1BAH1T",totalword)) || (!strcmp("KO1UH3I3E1N",totalword))) {         /* May be plural */
159          plural=i+1;
160          strcpy(oldword,totalword);
161//       logerror("Storing sample position %d and copying string %s\n",plural,oldword);
162        } else {
163          plural=0;
164        }
165        sample_start(samples, 0, i, 0);                      /* play the sample at position of word */
166        sample_set_freq(samples, 0, 11025);         /* play at correct rate */
167//        logerror("Playing sample %d\n",i);
168        totalword[0] = 0;               /* Clear the total word stack */
169        return data;
170      }
150      if (!strcmp(wowWordTable[i],state->m_totalword)) {         /* Scan the word (sample) table for the complete word */
151         /* WOW has Dungeon */
152         if ((!strcmp("GDTO1RFYA2N",state->m_totalword)) || (!strcmp("RO1U1BAH1T",state->m_totalword)) || (!strcmp("KO1UH3I3E1N",state->m_totalword))) {         /* May be plural */
153            state->m_plural=i+1;
154            strcpy(state->m_oldword,state->m_totalword);
155            //logerror("Storing sample position %d and copying string %s\n",state->m_plural,state->m_oldword);
156         } else {
157            state->m_plural=0;
158         }
159         sample_start(samples, 0, i, 0);                      /* play the sample at position of word */
160         sample_set_freq(samples, 0, 11025);         /* play at correct rate */
161         //logerror("Playing sample %d\n",i);
162         state->m_totalword[0] = 0;               /* Clear the total word stack */
163         return data;
164      }
171165   }
172166
173167   /* Note : We should really also use volume in this as well as frequency */
src/mame/audio/exidy440.c
r11160r11161
7171
7272
7373
74/* local allocated storage */
75static UINT8 sound_command;
76static UINT8 sound_command_ack;
77static UINT8 *sound_banks;
78static UINT8 *m6844_data;
79static UINT8 *sound_volume;
80static INT32 *mixer_buffer_left;
81static INT32 *mixer_buffer_right;
82static sound_cache_entry *sound_cache;
83static sound_cache_entry *sound_cache_end;
84static sound_cache_entry *sound_cache_max;
74typedef struct
75{
76   UINT8 sound_command;
77   UINT8 sound_command_ack;
8578
86/* 6844 description */
87static m6844_channel_data m6844_channel[4];
88static UINT8 m6844_priority;
89static UINT8 m6844_interrupt;
90static UINT8 m6844_chain;
79   UINT8 sound_banks[4];
80   UINT8 m6844_data[0x20];
81   UINT8 sound_volume[0x10];
82   INT32 *mixer_buffer_left;
83   INT32 *mixer_buffer_right;
84   sound_cache_entry *sound_cache;
85   sound_cache_entry *sound_cache_end;
86   sound_cache_entry *sound_cache_max;
9187
92/* sound interface parameters */
93static sound_stream *stream;
94static sound_channel_data sound_channel[4];
88   /* 6844 description */
89   m6844_channel_data m6844_channel[4];
90   UINT8 m6844_priority;
91   UINT8 m6844_interrupt;
92   UINT8 m6844_chain;
9593
96/* debugging */
97static FILE *debuglog;
94   /* sound interface parameters */
95   sound_stream *stream;
96   sound_channel_data sound_channel[4];
9897
99/* channel frequency is configurable */
100static int channel_frequency[4];
98   /* debugging */
99   FILE *debuglog;
101100
101   /* channel frequency is configurable */
102   int channel_frequency[4];
103}  exidy440_audio_state;
104
102105/* constant channel parameters */
103106static const int channel_bits[4] =
104107{
r11160r11161
109112
110113/* function prototypes */
111114static STREAM_UPDATE( channel_update );
112static void m6844_finished(int ch);
113static void play_cvsd(running_machine &machine, int ch);
114static void stop_cvsd(int ch);
115static void m6844_finished(m6844_channel_data *channel);
116static void play_cvsd(device_t *device, int ch);
117static void stop_cvsd(device_t *device, int ch);
115118
116static void reset_sound_cache(void);
117static INT16 *add_to_sound_cache(UINT8 *input, int address, int length, int bits, int frequency);
118static INT16 *find_or_add_to_sound_cache(running_machine &machine, int address, int length, int bits, int frequency);
119static void reset_sound_cache(device_t *device);
120static INT16 *add_to_sound_cache(device_t *device, UINT8 *input, int address, int length, int bits, int frequency);
121static INT16 *find_or_add_to_sound_cache(device_t *device, int address, int length, int bits, int frequency);
119122
120static void decode_and_filter_cvsd(UINT8 *data, int bytes, int maskbits, int frequency, INT16 *dest);
121static void fir_filter(INT32 *input, INT16 *output, int count);
123static void decode_and_filter_cvsd(device_t *device, UINT8 *data, int bytes, int maskbits, int frequency, INT16 *dest);
124static void fir_filter(device_t *device, INT32 *input, INT16 *output, int count);
122125
123126
127DECLARE_LEGACY_SOUND_DEVICE(EXIDY440, exidy440_sound);
124128
125129/*************************************
126130 *
r11160r11161
128132 *
129133 *************************************/
130134
135INLINE exidy440_audio_state *get_safe_token(device_t *device)
136{
137   assert(device != NULL);
138        assert(device->type() == EXIDY440);
139
140        return (exidy440_audio_state *)downcast<legacy_device_base *>(device)->token();
141}
142
131143static DEVICE_START( exidy440_sound )
132144{
145   exidy440_audio_state *state = get_safe_token(device);
133146   running_machine &machine = device->machine();
134147   int i, length;
135148
136149   /* reset the system */
137   sound_command = 0;
138   sound_command_ack = 1;
139   state_save_register_global(machine, sound_command);
140   state_save_register_global(machine, sound_command_ack);
150   state->sound_command = 0;
151   state->sound_command_ack = 1;
152   state_save_register_global(machine, state->sound_command);
153   state_save_register_global(machine, state->sound_command_ack);
141154
142155   /* reset the 6844 */
143156   for (i = 0; i < 4; i++)
144157   {
145      m6844_channel[i].active = 0;
146      m6844_channel[i].control = 0x00;
158      state->m6844_channel[i].active = 0;
159      state->m6844_channel[i].control = 0x00;
147160   }
148   m6844_priority = 0x00;
149   m6844_interrupt = 0x00;
150   m6844_chain = 0x00;
161   state->m6844_priority = 0x00;
162   state->m6844_interrupt = 0x00;
163   state->m6844_chain = 0x00;
151164
152   state_save_register_global(machine, m6844_priority);
153   state_save_register_global(machine, m6844_interrupt);
154   state_save_register_global(machine, m6844_chain);
165   state_save_register_global(machine, state->m6844_priority);
166   state_save_register_global(machine, state->m6844_interrupt);
167   state_save_register_global(machine, state->m6844_chain);
155168
156   channel_frequency[0] = device->clock();   /* channels 0 and 1 are run by FCLK */
157   channel_frequency[1] = device->clock();
158   channel_frequency[2] = device->clock()/2; /* channels 2 and 3 are run by SCLK */
159   channel_frequency[3] = device->clock()/2;
169   state->channel_frequency[0] = device->clock();   /* channels 0 and 1 are run by FCLK */
170   state->channel_frequency[1] = device->clock();
171   state->channel_frequency[2] = device->clock()/2; /* channels 2 and 3 are run by SCLK */
172   state->channel_frequency[3] = device->clock()/2;
160173
161174   /* get stream channels */
162   stream = device->machine().sound().stream_alloc(*device, 0, 2, device->clock(), NULL, channel_update);
175   state->stream = device->machine().sound().stream_alloc(*device, 0, 2, device->clock(), NULL, channel_update);
163176
164177   /* allocate the sample cache */
165178   length = machine.region("cvsd")->bytes() * 16 + MAX_CACHE_ENTRIES * sizeof(sound_cache_entry);
166   sound_cache = (sound_cache_entry *)auto_alloc_array(machine, UINT8, length);
179   state->sound_cache = (sound_cache_entry *)auto_alloc_array(machine, UINT8, length);
167180
168181   /* determine the hard end of the cache and reset */
169   sound_cache_max = (sound_cache_entry *)((UINT8 *)sound_cache + length);
170   reset_sound_cache();
182   state->sound_cache_max = (sound_cache_entry *)((UINT8 *)state->sound_cache + length);
183   reset_sound_cache(device);
171184
172185   /* allocate the mixer buffer */
173   mixer_buffer_left = auto_alloc_array(machine, INT32, 2 * device->clock());
174   mixer_buffer_right = mixer_buffer_left + device->clock();
186   state->mixer_buffer_left = auto_alloc_array(machine, INT32, 2 * device->clock());
187   state->mixer_buffer_right = state->mixer_buffer_left + device->clock();
175188
176189   if (SOUND_LOG)
177      debuglog = fopen("sound.log", "w");
190      state->debuglog = fopen("sound.log", "w");
178191}
179192
180193
r11160r11161
187200
188201static DEVICE_STOP( exidy440_sound )
189202{
190   if (SOUND_LOG && debuglog)
191      fclose(debuglog);
203   exidy440_audio_state *state = get_safe_token(device);
204   if (SOUND_LOG && state->debuglog)
205      fclose(state->debuglog);
192206}
193207
194208
r11160r11161
199213 *
200214 *************************************/
201215
202static void add_and_scale_samples(int ch, INT32 *dest, int samples, int volume)
216static void add_and_scale_samples(device_t *device, int ch, INT32 *dest, int samples, int volume)
203217{
204   sound_channel_data *channel = &sound_channel[ch];
218   exidy440_audio_state *state = get_safe_token(device);
219   sound_channel_data *channel = &state->sound_channel[ch];
205220   INT16 *srcdata;
206221   int i;
207222
r11160r11161
243258 *
244259 *************************************/
245260
246static void mix_to_16(int length, stream_sample_t *dest_left, stream_sample_t *dest_right)
261static void mix_to_16(device_t *device, int length, stream_sample_t *dest_left, stream_sample_t *dest_right)
247262{
248   INT32 *mixer_left = mixer_buffer_left;
249   INT32 *mixer_right = mixer_buffer_right;
263   exidy440_audio_state *state = get_safe_token(device);
264   INT32 *mixer_left = state->mixer_buffer_left;
265   INT32 *mixer_right = state->mixer_buffer_right;
250266   int i, clippers = 0;
251267
252268   for (i = 0; i < length; i++)
r11160r11161
274290
275291static STREAM_UPDATE( channel_update )
276292{
293   exidy440_audio_state *state = get_safe_token(device);
277294   int ch;
278295
279296   /* reset the mixer buffers */
280   memset(mixer_buffer_left, 0, samples * sizeof(INT32));
281   memset(mixer_buffer_right, 0, samples * sizeof(INT32));
297   memset(state->mixer_buffer_left, 0, samples * sizeof(INT32));
298   memset(state->mixer_buffer_right, 0, samples * sizeof(INT32));
282299
283300   /* loop over channels */
284301   for (ch = 0; ch < 4; ch++)
285302   {
286      sound_channel_data *channel = &sound_channel[ch];
303      sound_channel_data *channel = &state->sound_channel[ch];
287304      int length, volume, left = samples;
288305      int effective_offset;
289306
r11160r11161
295312      length = (left > channel->remaining) ? channel->remaining : left;
296313
297314      /* get a pointer to the sample data and copy to the left */
298      volume = sound_volume[2 * ch + 0];
315      volume = state->sound_volume[2 * ch + 0];
299316      if (volume)
300         add_and_scale_samples(ch, mixer_buffer_left, length, volume);
317         add_and_scale_samples(device, ch, state->mixer_buffer_left, length, volume);
301318
302319      /* get a pointer to the sample data and copy to the left */
303      volume = sound_volume[2 * ch + 1];
320      volume = state->sound_volume[2 * ch + 1];
304321      if (volume)
305         add_and_scale_samples(ch, mixer_buffer_right, length, volume);
322         add_and_scale_samples(device, ch, state->mixer_buffer_right, length, volume);
306323
307324      /* update our counters */
308325      channel->offset += length;
r11160r11161
311328
312329      /* update the MC6844 */
313330      effective_offset = (ch & 2) ? channel->offset / 2 : channel->offset;
314      m6844_channel[ch].address = m6844_channel[ch].start_address + effective_offset / 8;
315      m6844_channel[ch].counter = m6844_channel[ch].start_counter - effective_offset / 8;
316      if (m6844_channel[ch].counter <= 0)
331      state->m6844_channel[ch].address = state->m6844_channel[ch].start_address + effective_offset / 8;
332      state->m6844_channel[ch].counter = state->m6844_channel[ch].start_counter - effective_offset / 8;
333      if (state->m6844_channel[ch].counter <= 0)
317334      {
318         if (SOUND_LOG && debuglog)
319            fprintf(debuglog, "Channel %d finished\n", ch);
320         m6844_finished(ch);
335         if (SOUND_LOG && state->debuglog)
336            fprintf(state->debuglog, "Channel %d finished\n", ch);
337         m6844_finished(&state->m6844_channel[ch]);
321338      }
322339   }
323340
324341   /* all done, time to mix it */
325   mix_to_16(samples, outputs[0], outputs[1]);
342   mix_to_16(device, samples, outputs[0], outputs[1]);
326343}
327344
328345
r11160r11161
333350 *
334351 *************************************/
335352
336static READ8_HANDLER( sound_command_r )
353static READ8_DEVICE_HANDLER( sound_command_r )
337354{
355   exidy440_audio_state *state = get_safe_token(device);
338356   /* clear the FIRQ that got us here and acknowledge the read to the main CPU */
339   cputag_set_input_line(space->machine(), "audiocpu", 1, CLEAR_LINE);
340   sound_command_ack = 1;
357   cputag_set_input_line(device->machine(), "audiocpu", 1, CLEAR_LINE);
358   state->sound_command_ack = 1;
341359
342   return sound_command;
360   return state->sound_command;
343361}
344362
345363
346void exidy440_sound_command(running_machine &machine, UINT8 param)
364void exidy440_sound_command(device_t *device, UINT8 param)
347365{
348   sound_command = param;
349   sound_command_ack = 0;
350   cputag_set_input_line(machine, "audiocpu", INPUT_LINE_IRQ1, ASSERT_LINE);
366   exidy440_audio_state *state = get_safe_token(device);
367   state->sound_command = param;
368   state->sound_command_ack = 0;
369   cputag_set_input_line(device->machine(), "audiocpu", INPUT_LINE_IRQ1, ASSERT_LINE);
351370}
352371
353372
354UINT8 exidy440_sound_command_ack(void)
373UINT8 exidy440_sound_command_ack(device_t *device)
355374{
356   return sound_command_ack;
375   exidy440_audio_state *state = get_safe_token(device);
376   return state->sound_command_ack;
357377}
358378
359379
r11160r11161
364384 *
365385 *************************************/
366386
367static WRITE8_HANDLER( sound_volume_w )
387static READ8_DEVICE_HANDLER( sound_volume_r )
368388{
369   if (SOUND_LOG && debuglog)
370      fprintf(debuglog, "Volume %02X=%02X\n", offset, data);
389   exidy440_audio_state *state = get_safe_token(device);
390   return state->sound_volume[offset];
391}
371392
393static WRITE8_DEVICE_HANDLER( sound_volume_w )
394{
395   exidy440_audio_state *state = get_safe_token(device);
396   if (SOUND_LOG && state->debuglog)
397      fprintf(state->debuglog, "Volume %02X=%02X\n", offset, data);
398
372399   /* update the stream */
373   stream->update();
400   state->stream->update();
374401
375402   /* set the new volume */
376   sound_volume[offset] = ~data;
403   state->sound_volume[offset] = ~data;
377404}
378405
379406
r11160r11161
384411 *
385412 *************************************/
386413
387static WRITE8_HANDLER( sound_interrupt_clear_w )
414static WRITE8_DEVICE_HANDLER( sound_interrupt_clear_w )
388415{
389   cputag_set_input_line(space->machine(), "audiocpu", 0, CLEAR_LINE);
416   cputag_set_input_line(device->machine(), "audiocpu", 0, CLEAR_LINE);
390417}
391418
392419
r11160r11161
397424 *
398425 *************************************/
399426
400static void m6844_update(void)
427static void m6844_update(device_t *device)
401428{
429   exidy440_audio_state *state = get_safe_token(device);
402430   /* update the stream */
403   stream->update();
431   state->stream->update();
404432}
405433
406434
407static void m6844_finished(int ch)
435static void m6844_finished(m6844_channel_data *channel)
408436{
409   m6844_channel_data *channel = &m6844_channel[ch];
410
411437   /* mark us inactive */
412438   channel->active = 0;
413439
r11160r11161
428454 *
429455 *************************************/
430456
431static READ8_HANDLER( m6844_r )
457static READ8_DEVICE_HANDLER( m6844_r )
432458{
459   exidy440_audio_state *state = get_safe_token(device);
460   m6844_channel_data *m6844_channel = state->m6844_channel;
433461   int result = 0;
434462
435463   /* first update the current state of the DMA transfers */
436   m6844_update();
464   m6844_update(device);
437465
438466   /* switch off the offset we were given */
439467   switch (offset)
r11160r11161
483511
484512      /* priority control */
485513      case 0x14:
486         result = m6844_priority;
514         result = state->m6844_priority;
487515         break;
488516
489517      /* interrupt control */
490518      case 0x15:
491519
492520         /* update the global DMA end flag */
493         m6844_interrupt &= ~0x80;
494         m6844_interrupt |= (m6844_channel[0].control & 0x80) |
521         state->m6844_interrupt &= ~0x80;
522         state->m6844_interrupt |= (m6844_channel[0].control & 0x80) |
495523                            (m6844_channel[1].control & 0x80) |
496524                            (m6844_channel[2].control & 0x80) |
497525                            (m6844_channel[3].control & 0x80);
498526
499         result = m6844_interrupt;
527         result = state->m6844_interrupt;
500528         break;
501529
502530      /* chaining control */
503531      case 0x16:
504         result = m6844_chain;
532         result = state->m6844_chain;
505533         break;
506534
507535      /* 0x17-0x1f not used */
r11160r11161
512540}
513541
514542
515static WRITE8_HANDLER( m6844_w )
543static WRITE8_DEVICE_HANDLER( m6844_w )
516544{
545   exidy440_audio_state *state = get_safe_token(device);
546   m6844_channel_data *m6844_channel = state->m6844_channel;
517547   int i;
518548
519549   /* first update the current state of the DMA transfers */
520   m6844_update();
550   m6844_update(device);
521551
522552   /* switch off the offset we were given */
523553   switch (offset)
r11160r11161
564594
565595      /* priority control */
566596      case 0x14:
567         m6844_priority = data;
597         state->m6844_priority = data;
568598
569599         /* update the sound playback on each channel */
570600         for (i = 0; i < 4; i++)
r11160r11161
584614               m6844_channel[i].start_counter = m6844_channel[i].counter;
585615
586616               /* generate and play the sample */
587               play_cvsd(space->machine(), i);
617               play_cvsd(device, i);
588618            }
589619
590620            /* if we're going inactive... */
r11160r11161
594624               m6844_channel[i].active = 0;
595625
596626               /* stop playing the sample */
597               stop_cvsd(i);
627               stop_cvsd(device, i);
598628            }
599629         }
600630         break;
601631
602632      /* interrupt control */
603633      case 0x15:
604         m6844_interrupt = (m6844_interrupt & 0x80) | (data & 0x7f);
634         state->m6844_interrupt = (state->m6844_interrupt & 0x80) | (data & 0x7f);
605635         break;
606636
607637      /* chaining control */
608638      case 0x16:
609         m6844_chain = data;
639         state->m6844_chain = data;
610640         break;
611641
612642      /* 0x17-0x1f not used */
r11160r11161
622652 *
623653 *************************************/
624654
625static void reset_sound_cache(void)
655static void reset_sound_cache(device_t *device)
626656{
627   sound_cache_end = sound_cache;
657   exidy440_audio_state *state = get_safe_token(device);
658   state->sound_cache_end = state->sound_cache;
628659}
629660
630661
631static INT16 *add_to_sound_cache(UINT8 *input, int address, int length, int bits, int frequency)
662static INT16 *add_to_sound_cache(device_t *device, UINT8 *input, int address, int length, int bits, int frequency)
632663{
633   sound_cache_entry *current = sound_cache_end;
664   exidy440_audio_state *state = get_safe_token(device);
665   sound_cache_entry *current = state->sound_cache_end;
634666
635667   /* compute where the end will be once we add this entry */
636   sound_cache_end = (sound_cache_entry *)((UINT8 *)current + sizeof(sound_cache_entry) + length * 16);
668   state->sound_cache_end = (sound_cache_entry *)((UINT8 *)current + sizeof(sound_cache_entry) + length * 16);
637669
638670   /* if this will overflow the cache, reset and re-add */
639   if (sound_cache_end > sound_cache_max)
671   if (state->sound_cache_end > state->sound_cache_max)
640672   {
641      reset_sound_cache();
642      return add_to_sound_cache(input, address, length, bits, frequency);
673      reset_sound_cache(device);
674      return add_to_sound_cache(device, input, address, length, bits, frequency);
643675   }
644676
645677   /* fill in this entry */
646   current->next = sound_cache_end;
678   current->next = state->sound_cache_end;
647679   current->address = address;
648680   current->length = length;
649681   current->bits = bits;
650682   current->frequency = frequency;
651683
652684   /* decode the data into the cache */
653   decode_and_filter_cvsd(input, length, bits, frequency, current->data);
685   decode_and_filter_cvsd(device, input, length, bits, frequency, current->data);
654686   return current->data;
655687}
656688
657689
658static INT16 *find_or_add_to_sound_cache(running_machine &machine, int address, int length, int bits, int frequency)
690static INT16 *find_or_add_to_sound_cache(device_t *device, int address, int length, int bits, int frequency)
659691{
692   exidy440_audio_state *state = get_safe_token(device);
660693   sound_cache_entry *current;
661694
662   for (current = sound_cache; current < sound_cache_end; current = current->next)
695   for (current = state->sound_cache; current < state->sound_cache_end; current = current->next)
663696      if (current->address == address && current->length == length && current->bits == bits && current->frequency == frequency)
664697         return current->data;
665698
666   return add_to_sound_cache(&machine.region("cvsd")->base()[address], address, length, bits, frequency);
699   return add_to_sound_cache(device, &device->machine().region("cvsd")->base()[address], address, length, bits, frequency);
667700}
668701
669702
r11160r11161
674707 *
675708 *************************************/
676709
677static void play_cvsd(running_machine &machine, int ch)
710static void play_cvsd(device_t *device, int ch)
678711{
679   sound_channel_data *channel = &sound_channel[ch];
680   int address = m6844_channel[ch].address;
681   int length = m6844_channel[ch].counter;
712   exidy440_audio_state *state = get_safe_token(device);
713   sound_channel_data *channel = &state->sound_channel[ch];
714   int address = state->m6844_channel[ch].address;
715   int length = state->m6844_channel[ch].counter;
682716   INT16 *base;
683717
684718   /* add the bank number to the address */
685   if (sound_banks[ch] & 1)
719   if (state->sound_banks[ch] & 1)
686720      address += 0x00000;
687   else if (sound_banks[ch] & 2)
721   else if (state->sound_banks[ch] & 2)
688722      address += 0x08000;
689   else if (sound_banks[ch] & 4)
723   else if (state->sound_banks[ch] & 4)
690724      address += 0x10000;
691   else if (sound_banks[ch] & 8)
725   else if (state->sound_banks[ch] & 8)
692726      address += 0x18000;
693727
694728   /* compute the base address in the converted samples array */
695   base = find_or_add_to_sound_cache(machine, address, length, channel_bits[ch], channel_frequency[ch]);
729   base = find_or_add_to_sound_cache(device, address, length, channel_bits[ch], state->channel_frequency[ch]);
696730   if (!base)
697731      return;
698732
r11160r11161
702736      channel->base = base;
703737      channel->offset = length;
704738      channel->remaining = 0;
705      m6844_finished(ch);
739      m6844_finished(&state->m6844_channel[ch]);
706740      return;
707741   }
708742
709   if (SOUND_LOG && debuglog)
710      fprintf(debuglog, "Sound channel %d play at %02X,%04X, length = %04X, volume = %02X/%02X\n",
711            ch, sound_banks[ch], m6844_channel[ch].address,
712            m6844_channel[ch].counter, sound_volume[ch * 2], sound_volume[ch * 2 + 1]);
743   if (SOUND_LOG && state->debuglog)
744      fprintf(state->debuglog, "Sound channel %d play at %02X,%04X, length = %04X, volume = %02X/%02X\n",
745            ch, state->sound_banks[ch],
746            state->m6844_channel[ch].address, state->m6844_channel[ch].counter,
747            state->sound_volume[ch * 2], state->sound_volume[ch * 2 + 1]);
713748
714749   /* set the pointer and count */
715750   channel->base = base;
r11160r11161
721756}
722757
723758
724static void stop_cvsd(int ch)
759static void stop_cvsd(device_t *device, int ch)
725760{
761   exidy440_audio_state *state = get_safe_token(device);
726762   /* the DMA channel is marked inactive; that will kill the audio */
727   sound_channel[ch].remaining = 0;
728   stream->update();
763   state->sound_channel[ch].remaining = 0;
764   state->stream->update();
729765
730   if (SOUND_LOG && debuglog)
731      fprintf(debuglog, "Channel %d stop\n", ch);
766   if (SOUND_LOG && state->debuglog)
767      fprintf(state->debuglog, "Channel %d stop\n", ch);
732768}
733769
734770
r11160r11161
739775 *
740776 *************************************/
741777
742static void fir_filter(INT32 *input, INT16 *output, int count)
778static void fir_filter(device_t *device, INT32 *input, INT16 *output, int count)
743779{
744780   while (count--)
745781   {
r11160r11161
774810 *
775811 *************************************/
776812
777static void decode_and_filter_cvsd(UINT8 *input, int bytes, int maskbits, int frequency, INT16 *output)
813static void decode_and_filter_cvsd(device_t *device, UINT8 *input, int bytes, int maskbits, int frequency, INT16 *output)
778814{
779815   INT32 buffer[SAMPLE_BUFFER_LENGTH + FIR_HISTORY_LENGTH];
780816   int total_samples = bytes * 8;
r11160r11161
873909      }
874910
875911      /* all done with this chunk, run the filter on it */
876      fir_filter(&buffer[FIR_HISTORY_LENGTH], &output[chunk_start], chunk_bytes * 8);
912      fir_filter(device, &buffer[FIR_HISTORY_LENGTH], &output[chunk_start], chunk_bytes * 8);
877913
878914      /* copy the last few input samples down to the start for a new history */
879915      memcpy(&buffer[0], &buffer[SAMPLE_BUFFER_LENGTH], FIR_HISTORY_LENGTH * sizeof(INT32));
r11160r11161
895931}
896932
897933
934static WRITE8_DEVICE_HANDLER( sound_banks_w )
935{
936   exidy440_audio_state *state = get_safe_token(device);
937   state->sound_banks[offset] = data;
938}
898939
940
899941/*************************************
900942 *
901943 *  Memory handlers
r11160r11161
904946
905947static ADDRESS_MAP_START( exidy440_audio_map, AS_PROGRAM, 8 )
906948   AM_RANGE(0x0000, 0x7fff) AM_NOP
907   AM_RANGE(0x8000, 0x801f) AM_MIRROR(0x03e0) AM_READWRITE(m6844_r, m6844_w) AM_BASE(&m6844_data)
908   AM_RANGE(0x8400, 0x840f) AM_MIRROR(0x03f0) AM_RAM_WRITE(sound_volume_w) AM_BASE(&sound_volume)
909   AM_RANGE(0x8800, 0x8800) AM_MIRROR(0x03ff) AM_READ(sound_command_r) AM_WRITENOP
949   AM_RANGE(0x8000, 0x801f) AM_MIRROR(0x03e0) AM_DEVREADWRITE("custom", m6844_r, m6844_w)
950   AM_RANGE(0x8400, 0x840f) AM_MIRROR(0x03f0) AM_DEVREADWRITE("custom", sound_volume_r, sound_volume_w)
951   AM_RANGE(0x8800, 0x8800) AM_MIRROR(0x03ff) AM_DEVREAD("custom", sound_command_r) AM_WRITENOP
910952   AM_RANGE(0x8c00, 0x93ff) AM_NOP
911   AM_RANGE(0x9400, 0x9403) AM_MIRROR(0x03fc) AM_READNOP AM_WRITEONLY AM_BASE(&sound_banks)
912   AM_RANGE(0x9800, 0x9800) AM_MIRROR(0x03ff) AM_READNOP AM_WRITE(sound_interrupt_clear_w)
953   AM_RANGE(0x9400, 0x9403) AM_MIRROR(0x03fc) AM_READNOP AM_DEVWRITE("custom", sound_banks_w)
954   AM_RANGE(0x9800, 0x9800) AM_MIRROR(0x03ff) AM_READNOP AM_DEVWRITE("custom", sound_interrupt_clear_w)
913955   AM_RANGE(0x9c00, 0x9fff) AM_NOP
914956   AM_RANGE(0xa000, 0xbfff) AM_RAM
915957   AM_RANGE(0xc000, 0xdfff) AM_NOP
r11160r11161
928970{
929971   switch (state)
930972   {
973      /* --- the following bits of info are returned as 64-bit signed integers --- */
974      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(exidy440_audio_state);               break;
975
931976      /* --- the following bits of info are returned as pointers to data or functions --- */
932977      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(exidy440_sound);   break;
933978      case DEVINFO_FCT_STOP:                     info->stop = DEVICE_STOP_NAME(exidy440_sound);   break;
r11160r11161
939984}
940985
941986
942DECLARE_LEGACY_SOUND_DEVICE(EXIDY440, exidy440_sound);
943987DEFINE_LEGACY_SOUND_DEVICE(EXIDY440, exidy440_sound);
944988
945989
src/mame/audio/exidy440.h
r11160r11161
1void exidy440_sound_command(running_machine &machine, UINT8 param);
2UINT8 exidy440_sound_command_ack(void);
1void exidy440_sound_command(device_t *device, UINT8 param);
2UINT8 exidy440_sound_command_ack(device_t *device);
33
44MACHINE_CONFIG_EXTERN( exidy440_audio );
src/mame/audio/mcr.c
r11160r11161
193193   /* Advanced Audio */
194194   if (mcr_sound_config & MCR_WILLIAMS_SOUND)
195195   {
196      williams_cvsd_reset_w(1);
197      williams_cvsd_reset_w(0);
196      williams_cvsd_reset_w(machine, 1);
197      williams_cvsd_reset_w(machine, 0);
198198   }
199199}
200200
src/mame/audio/m72.c
r11160r11161
6767   Z80_CLEAR
6868};
6969
70static UINT8 irqvector;
71static UINT32 sample_addr;
70typedef struct _m72_audio_state m72_audio_state;
71struct _m72_audio_state
72{
73   UINT8 irqvector;
74   UINT32 sample_addr;
75   UINT8 *samples;
76   UINT32 samples_size;
77   address_space *space;
78   device_t *dac;
79};
7280
81INLINE m72_audio_state *get_safe_token(device_t *device)
82{
83   assert(device != NULL);
84   assert(device->type() == M72);
85
86   return (m72_audio_state *)downcast<legacy_device_base *>(device)->token();
87}
88
89
7390static TIMER_CALLBACK( setvector_callback )
7491{
92   m72_audio_state *state = (m72_audio_state *)ptr;
93
7594   switch(param)
7695   {
7796      case VECTOR_INIT:
78         irqvector = 0xff;
97         state->irqvector = 0xff;
7998         break;
8099
81100      case YM2151_ASSERT:
82         irqvector &= 0xef;
101         state->irqvector &= 0xef;
83102         break;
84103
85104      case YM2151_CLEAR:
86         irqvector |= 0x10;
105         state->irqvector |= 0x10;
87106         break;
88107
89108      case Z80_ASSERT:
90         irqvector &= 0xdf;
109         state->irqvector &= 0xdf;
91110         break;
92111
93112      case Z80_CLEAR:
94         irqvector |= 0x20;
113         state->irqvector |= 0x20;
95114         break;
96115   }
97116
98   if (irqvector == 0)
117   if (state->irqvector == 0)
99118      logerror("You didn't call m72_init_sound()\n");
100119
101   if (irqvector == 0xff)   /* no IRQs pending */
102      cputag_set_input_line_and_vector(machine, "soundcpu",0,CLEAR_LINE, irqvector);
103   else   /* IRQ pending */
104      cputag_set_input_line_and_vector(machine, "soundcpu",0,ASSERT_LINE, irqvector);
120   cputag_set_input_line_and_vector(machine, "soundcpu", 0, (state->irqvector == 0xff) ? CLEAR_LINE : ASSERT_LINE, state->irqvector);
105121}
106122
107SOUND_START( m72 )
123static DEVICE_START( m72_audio )
108124{
109   state_save_register_global(machine, irqvector);
110   state_save_register_global(machine, sample_addr);
125   m72_audio_state *state = get_safe_token(device);
126
127   state->samples = device->machine().region("samples")->base();
128   state->samples_size = device->machine().region("samples")->bytes();
129   state->space = device->machine().device("soundcpu")->memory().space(AS_IO);
130   state->dac = device->machine().device("dac");
131
132   device->save_item(NAME(state->irqvector));
133   device->save_item(NAME(state->sample_addr));
111134}
112135
113SOUND_RESET( m72 )
136static DEVICE_RESET( m72_audio )
114137{
115   setvector_callback(machine, NULL, VECTOR_INIT);
138   m72_audio_state *state = get_safe_token(device);
139
140   setvector_callback(device->machine(), state, VECTOR_INIT);
116141}
117142
118143void m72_ym2151_irq_handler(device_t *device, int irq)
119144{
120   if (irq)
121      device->machine().scheduler().synchronize(FUNC(setvector_callback), YM2151_ASSERT);
122   else
123      device->machine().scheduler().synchronize(FUNC(setvector_callback), YM2151_CLEAR);
145   device_t *audio = device->machine().device("m72");
146   m72_audio_state *state = get_safe_token(audio);
147
148   device->machine().scheduler().synchronize(FUNC(setvector_callback), irq ? YM2151_ASSERT : YM2151_CLEAR, state);
124149}
125150
126WRITE16_HANDLER( m72_sound_command_w )
151WRITE16_DEVICE_HANDLER( m72_sound_command_w )
127152{
128153   if (ACCESSING_BITS_0_7)
129154   {
130      soundlatch_w(space,offset,data);
131      space->machine().scheduler().synchronize(FUNC(setvector_callback), Z80_ASSERT);
155      m72_audio_state *state = get_safe_token(device);
156
157      soundlatch_w(state->space, offset, data);
158      device->machine().scheduler().synchronize(FUNC(setvector_callback), Z80_ASSERT, state);
132159   }
133160}
134161
135WRITE8_HANDLER( m72_sound_command_byte_w )
162WRITE8_DEVICE_HANDLER( m72_sound_command_byte_w )
136163{
137   soundlatch_w(space,offset,data);
138   space->machine().scheduler().synchronize(FUNC(setvector_callback), Z80_ASSERT);
164   m72_audio_state *state = get_safe_token(device);
165
166   soundlatch_w(state->space, offset, data);
167   device->machine().scheduler().synchronize(FUNC(setvector_callback), Z80_ASSERT, state);
139168}
140169
141WRITE8_HANDLER( m72_sound_irq_ack_w )
170WRITE8_DEVICE_HANDLER( m72_sound_irq_ack_w )
142171{
143   space->machine().scheduler().synchronize(FUNC(setvector_callback), Z80_CLEAR);
172   m72_audio_state *state = get_safe_token(device);
173
174   device->machine().scheduler().synchronize(FUNC(setvector_callback), Z80_CLEAR, state);
144175}
145176
146177
147178
148void m72_set_sample_start(int start)
179void m72_set_sample_start(device_t *device, int start)
149180{
150   sample_addr = start;
181   m72_audio_state *state = get_safe_token(device);
182
183   state->sample_addr = start;
151184}
152185
153WRITE8_HANDLER( vigilant_sample_addr_w )
186WRITE8_DEVICE_HANDLER( vigilant_sample_addr_w )
154187{
188   m72_audio_state *state = get_safe_token(device);
189
155190   if (offset == 1)
156      sample_addr = (sample_addr & 0x00ff) | ((data << 8) & 0xff00);
191      state->sample_addr = (state->sample_addr & 0x00ff) | ((data << 8) & 0xff00);
157192   else
158      sample_addr = (sample_addr & 0xff00) | ((data << 0) & 0x00ff);
193      state->sample_addr = (state->sample_addr & 0xff00) | ((data << 0) & 0x00ff);
159194}
160195
161WRITE8_HANDLER( shisen_sample_addr_w )
196WRITE8_DEVICE_HANDLER( shisen_sample_addr_w )
162197{
163   sample_addr >>= 2;
198   m72_audio_state *state = get_safe_token(device);
164199
200   state->sample_addr >>= 2;
201
165202   if (offset == 1)
166      sample_addr = (sample_addr & 0x00ff) | ((data << 8) & 0xff00);
203      state->sample_addr = (state->sample_addr & 0x00ff) | ((data << 8) & 0xff00);
167204   else
168      sample_addr = (sample_addr & 0xff00) | ((data << 0) & 0x00ff);
205      state->sample_addr = (state->sample_addr & 0xff00) | ((data << 0) & 0x00ff);
169206
170   sample_addr <<= 2;
207   state->sample_addr <<= 2;
171208}
172209
173WRITE8_HANDLER( rtype2_sample_addr_w )
210WRITE8_DEVICE_HANDLER( rtype2_sample_addr_w )
174211{
175   sample_addr >>= 5;
212   m72_audio_state *state = get_safe_token(device);
176213
214   state->sample_addr >>= 5;
215
177216   if (offset == 1)
178      sample_addr = (sample_addr & 0x00ff) | ((data << 8) & 0xff00);
217      state->sample_addr = (state->sample_addr & 0x00ff) | ((data << 8) & 0xff00);
179218   else
180      sample_addr = (sample_addr & 0xff00) | ((data << 0) & 0x00ff);
219      state->sample_addr = (state->sample_addr & 0xff00) | ((data << 0) & 0x00ff);
181220
182   sample_addr <<= 5;
221   state->sample_addr <<= 5;
183222}
184223
185WRITE8_HANDLER( poundfor_sample_addr_w )
224WRITE8_DEVICE_HANDLER( poundfor_sample_addr_w )
186225{
226   m72_audio_state *state = get_safe_token(device);
227
187228   /* poundfor writes both sample start and sample END - a first for Irem...
188229       we don't handle the end written here, 00 marks the sample end as usual. */
189230   if (offset > 1) return;
190231
191   sample_addr >>= 4;
232   state->sample_addr >>= 4;
192233
193234   if (offset == 1)
194      sample_addr = (sample_addr & 0x00ff) | ((data << 8) & 0xff00);
235      state->sample_addr = (state->sample_addr & 0x00ff) | ((data << 8) & 0xff00);
195236   else
196      sample_addr = (sample_addr & 0xff00) | ((data << 0) & 0x00ff);
237      state->sample_addr = (state->sample_addr & 0xff00) | ((data << 0) & 0x00ff);
197238
198   sample_addr <<= 4;
239   state->sample_addr <<= 4;
199240}
200241
201READ8_HANDLER( m72_sample_r )
242READ8_DEVICE_HANDLER( m72_sample_r )
202243{
203   return space->machine().region("samples")->base()[sample_addr];
244   m72_audio_state *state = get_safe_token(device);
245
246   return state->samples[state->sample_addr];
204247}
205248
206249WRITE8_DEVICE_HANDLER( m72_sample_w )
207250{
208   dac_signed_data_w(device, data);
209   sample_addr = (sample_addr + 1) & (device->machine().region("samples")->bytes() - 1);
251   m72_audio_state *state = get_safe_token(device);
252
253   dac_signed_data_w(state->dac, data);
254   state->sample_addr = (state->sample_addr + 1) & (state->samples_size - 1);
210255}
256
257DEVICE_GET_INFO( m72_audio )
258{
259   switch (state)
260   {
261      /* --- the following bits of info are returned as 64-bit signed integers --- */
262      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(m72_audio_state);         break;
263
264      /* --- the following bits of info are returned as pointers to data or functions --- */
265      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(m72_audio);   break;
266      case DEVINFO_FCT_RESET:                     info->start = DEVICE_RESET_NAME(m72_audio);   break;
267
268      /* --- the following bits of info are returned as NULL-terminated strings --- */
269      case DEVINFO_STR_NAME:                     strcpy(info->s, "M72 Custom");            break;
270      case DEVINFO_STR_SOURCE_FILE:                  strcpy(info->s, __FILE__);                  break;
271   }
272}
273
274DEFINE_LEGACY_SOUND_DEVICE(M72, m72_audio);
src/mame/audio/m72.h
r11160r11161
44
55****************************************************************************/
66
7SOUND_START( m72 );
8SOUND_RESET( m72 );
97void m72_ym2151_irq_handler(device_t *device, int irq);
10WRITE8_HANDLER( m72_sound_command_byte_w );
11WRITE16_HANDLER( m72_sound_command_w );
12WRITE8_HANDLER( m72_sound_irq_ack_w );
13READ8_HANDLER( m72_sample_r );
8WRITE8_DEVICE_HANDLER( m72_sound_command_byte_w );
9WRITE16_DEVICE_HANDLER( m72_sound_command_w );
10WRITE8_DEVICE_HANDLER( m72_sound_irq_ack_w );
11READ8_DEVICE_HANDLER( m72_sample_r );
1412WRITE8_DEVICE_HANDLER( m72_sample_w );
1513
1614/* the port goes to different address bits depending on the game */
17void m72_set_sample_start(int start);
18WRITE8_HANDLER( vigilant_sample_addr_w );
19WRITE8_HANDLER( shisen_sample_addr_w );
20WRITE8_HANDLER( rtype2_sample_addr_w );
21WRITE8_HANDLER( poundfor_sample_addr_w );
15void m72_set_sample_start(device_t *device, int start);
16WRITE8_DEVICE_HANDLER( vigilant_sample_addr_w );
17WRITE8_DEVICE_HANDLER( shisen_sample_addr_w );
18WRITE8_DEVICE_HANDLER( rtype2_sample_addr_w );
19WRITE8_DEVICE_HANDLER( poundfor_sample_addr_w );
20
21DECLARE_LEGACY_SOUND_DEVICE(M72, m72_audio);
src/mame/audio/beezer.c
r11160r11161
1616     a silence waveform for 55516, alternating zeroes and ones.
1717    * The channel mixing is done additively at the moment rather than
1818     emulating the original multiplexer, which is actually not that hard to do
19    but adds a bit of complexity to the render loop.
1920    * The 'FM OR AM' output of the audio via (pb1) appears to control some sort
2021     of suppression or filtering change of the post-DAC amplifier when enabled,
2122     only during the TIMER1 OUT time-slot of the multiplexer, see page 1B 3-3
2223     of schematics. This will be a MESS to emulate since theres a lot of analog
2324     crap involved.
2425    * The /INT line and related logic of the 6840 is not emulated, and should
25     be hooked to the audio 6809
26     be hooked to the audio 6809.
2627    * Convert this to a modern device instead of a deprecated old style device
2728
2829
r11160r11161
3132     of 74ls670 4x4 register files wired up as four 8-bit words;
3233     The four words are used as the volumes for four 1-bit channels by inversion
3334     of the MSB of the 8 bit value.
35   NOISE is the output of an MM5837 whitenoise generator, a self-clocked (at
36    around 100khz) LFSR with taps on bits (base-0) 16 and 13.
3437    The four channels are:
3538    CNT1 CNT0
3639    0    0    6522 pin 7 output (squarewave); 'FM or AM' affects this slot only
r11160r11161
211214   for (i = 0; i < clocks; i++)
212215   {
213216      state->m_sh6840_LFSR_clocks++;
214      if (state->m_sh6840_LFSR_clocks >= 10) // about 10 clocks per 6840 clock
217      if (state->m_sh6840_LFSR_clocks >= 10) // about 10 clocks per 6840 clock, as MM5837 runs at around 100kHz, while clock is 1MHz
215218      {
216219         state->m_sh6840_LFSR_clocks = 0;
217220         /* shift the LFSR. finally or in the result and see if we've
r11160r11161
360363      sample += (((sample1*0x80)^(state->m_sh6840_volume[1]&0x80))?-1:1)*(state->m_sh6840_volume[1]&0x7F);
361364      sample += (((sample2*0x80)^(state->m_sh6840_volume[2]&0x80))?-1:1)*(state->m_sh6840_volume[2]&0x7F);
362365      sample += (((sample3*0x80)^(state->m_sh6840_volume[3]&0x80))?-1:1)*(state->m_sh6840_volume[3]&0x7F);
363      *buffer++ = sample*64; // adding 3 numbers ranging from -128 to 127 yields a range of -512 to 508; to scale that to '-32768 to 32767' we multiply by 64
366      *buffer++ = sample*64; // adding 4 numbers ranging from -128 to 127 yields a range of -512 to 508; to scale that to '-32768 to 32767' we multiply by 64
364367   }
365368}
366369
src/mame/audio/williams.c
r11160r11161
4747    STATIC GLOBALS
4848****************************************************************************/
4949
50static UINT8 williams_sound_int_state;
50typedef struct _williams_audio_state williams_audio_state;
51struct _williams_audio_state
52{
53   UINT8 sound_int_state;
5154
52static UINT8 audio_talkback;
53static UINT8 audio_sync;
55   UINT8 audio_talkback;
56   UINT8 audio_sync;
5457
55static device_t *sound_cpu;
56static device_t *soundalt_cpu;
58   device_t *sound_cpu;
59   device_t *soundalt_cpu;
60};
5761
62static williams_audio_state audio;
5863
59
6064/***************************************************************************
6165    FUNCTION PROTOTYPES
6266****************************************************************************/
r11160r11161
266270
267271void williams_cvsd_init(running_machine &machine)
268272{
273   williams_audio_state *state = &audio;
269274   UINT8 *ROM;
270275   int bank;
271276
272277   /* configure the CPU */
273   sound_cpu = machine.device("cvsdcpu");
274   soundalt_cpu = NULL;
278   state->sound_cpu = machine.device("cvsdcpu");
279   state->soundalt_cpu = NULL;
275280
276281   /* configure master CPU banks */
277282   ROM = machine.region("cvsdcpu")->base();
r11160r11161
291296   pia6821_ca1_w(machine.device("cvsdpia"), 1);
292297
293298   /* register for save states */
294   state_save_register_global(machine, williams_sound_int_state);
295   state_save_register_global(machine, audio_talkback);
299   state_save_register_global(machine, state->sound_int_state);
300   state_save_register_global(machine, state->audio_talkback);
296301}
297302
298303
299304void williams_narc_init(running_machine &machine)
300305{
306   williams_audio_state *state = &audio;
301307   UINT8 *ROM;
302308   int bank;
303309
304310   /* configure the CPU */
305   sound_cpu = machine.device("narc1cpu");
306   soundalt_cpu = machine.device("narc2cpu");
311   state->sound_cpu = machine.device("narc1cpu");
312   state->soundalt_cpu = machine.device("narc2cpu");
307313
308314   /* configure master CPU banks */
309315   ROM = machine.region("narc1cpu")->base();
r11160r11161
334340   memory_set_bankptr(machine, "bank8", &ROM[0x10000 + 0x4000 + 0x8000 + 0x10000 + 0x20000 * 3]);
335341
336342   /* register for save states */
337   state_save_register_global(machine, williams_sound_int_state);
338   state_save_register_global(machine, audio_talkback);
339   state_save_register_global(machine, audio_sync);
343   state_save_register_global(machine, state->sound_int_state);
344   state_save_register_global(machine, state->audio_talkback);
345   state_save_register_global(machine, state->audio_sync);
340346}
341347
342348
343349void williams_adpcm_init(running_machine &machine)
344350{
351   williams_audio_state *state = &audio;
345352   UINT8 *ROM;
346353
347354   /* configure the CPU */
348   sound_cpu = machine.device("adpcm");
349   soundalt_cpu = NULL;
355   state->sound_cpu = machine.device("adpcm");
356   state->soundalt_cpu = NULL;
350357
351358   /* configure banks */
352359   ROM = machine.region("adpcm")->base();
r11160r11161
373380   memcpy(ROM + 0x020000, ROM + 0x060000, 0x20000);
374381
375382   /* register for save states */
376   state_save_register_global(machine, williams_sound_int_state);
377   state_save_register_global(machine, audio_talkback);
383   state_save_register_global(machine, state->sound_int_state);
384   state_save_register_global(machine, state->audio_talkback);
378385}
379386
380387
381388static void init_audio_state(running_machine &machine)
382389{
390   williams_audio_state *state = &audio;
391   device_t *sound_cpu = state->sound_cpu;
392   device_t *soundalt_cpu = state->soundalt_cpu;
393
383394   /* reset the YM2151 state */
384395   devtag_reset(machine, "ymsnd");
385396
386397   /* clear all the interrupts */
387   williams_sound_int_state = 0;
398   state->sound_int_state = 0;
388399   if (sound_cpu != NULL)
389400   {
390401      device_set_input_line(sound_cpu, M6809_FIRQ_LINE, CLEAR_LINE);
r11160r11161
413424
414425static WRITE_LINE_DEVICE_HANDLER( cvsd_irqa )
415426{
416   device_set_input_line(sound_cpu, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
427   williams_audio_state *sndstate = &audio;
428
429   device_set_input_line(sndstate->sound_cpu, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
417430}
418431
419432
420433static WRITE_LINE_DEVICE_HANDLER( cvsd_irqb )
421434{
422   device_set_input_line(sound_cpu, INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE);
435   williams_audio_state *sndstate = &audio;
436
437   device_set_input_line(sndstate->sound_cpu, INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE);
423438}
424439
425440
r11160r11161
430445
431446static void adpcm_ym2151_irq(device_t *device, int state)
432447{
433   device_set_input_line(sound_cpu, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
448   williams_audio_state *sndstate = &audio;
449
450   device_set_input_line(sndstate->sound_cpu, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
434451}
435452
436453
r11160r11161
447464
448465static WRITE8_DEVICE_HANDLER( cvsd_talkback_w )
449466{
450   audio_talkback = data;
467   williams_audio_state *state = &audio;
468
469   state->audio_talkback = data;
451470   logerror("CVSD Talkback = %02X\n", data);
452471}
453472
r11160r11161
484503}
485504
486505
487void williams_cvsd_reset_w(int state)
506void williams_cvsd_reset_w(running_machine &machine, int state)
488507{
489   address_space *space = sound_cpu->memory().space(AS_PROGRAM);
508   williams_audio_state *sndstate = &audio;
509   address_space *space = sndstate->sound_cpu->memory().space(AS_PROGRAM);
490510
491511   /* going high halts the CPU */
492512   if (state)
r11160r11161
520540
521541static READ8_HANDLER( narc_command_r )
522542{
523   device_set_input_line(sound_cpu, M6809_IRQ_LINE, CLEAR_LINE);
524   williams_sound_int_state = 0;
543   williams_audio_state *state = &audio;
544
545   device_set_input_line(state->sound_cpu, M6809_IRQ_LINE, CLEAR_LINE);
546   state->sound_int_state = 0;
525547   return soundlatch_r(space, 0);
526548}
527549
528550
529551static WRITE8_HANDLER( narc_command2_w )
530552{
553   williams_audio_state *state = &audio;
554
531555   soundlatch2_w(space, 0, data & 0xff);
532   device_set_input_line(soundalt_cpu, M6809_FIRQ_LINE, ASSERT_LINE);
556   device_set_input_line(state->soundalt_cpu, M6809_FIRQ_LINE, ASSERT_LINE);
533557}
534558
535559
536560static READ8_HANDLER( narc_command2_r )
537561{
538   device_set_input_line(soundalt_cpu, M6809_FIRQ_LINE, CLEAR_LINE);
562   williams_audio_state *state = &audio;
563
564   device_set_input_line(state->soundalt_cpu, M6809_FIRQ_LINE, CLEAR_LINE);
539565   return soundlatch2_r(space, 0);
540566}
541567
542568
543569static WRITE8_HANDLER( narc_master_talkback_w )
544570{
545   audio_talkback = data;
571   williams_audio_state *state = &audio;
572
573   state->audio_talkback = data;
546574   logerror("Master Talkback = %02X\n", data);
547575}
548576
549577
550578static TIMER_CALLBACK( narc_sync_clear )
551579{
552   audio_sync &= ~param;
580   williams_audio_state *state = &audio;
581
582   state->audio_sync &= ~param;
553583}
554584
555585static WRITE8_HANDLER( narc_master_sync_w )
556586{
587   williams_audio_state *state = &audio;
588
557589   space->machine().scheduler().timer_set(attotime::from_double(TIME_OF_74LS123(180000, 0.000001)), FUNC(narc_sync_clear), 0x01);
558   audio_sync |= 0x01;
590   state->audio_sync |= 0x01;
559591   logerror("Master sync = %02X\n", data);
560592}
561593
r11160r11161
568600
569601static WRITE8_HANDLER( narc_slave_sync_w )
570602{
603   williams_audio_state *state = &audio;
604
571605   space->machine().scheduler().timer_set(attotime::from_double(TIME_OF_74LS123(180000, 0.000001)), FUNC(narc_sync_clear), 0x02);
572   audio_sync |= 0x02;
606   state->audio_sync |= 0x02;
573607   logerror("Slave sync = %02X\n", data);
574608}
575609
r11160r11161
579613    NARC COMMUNICATIONS
580614****************************************************************************/
581615
582void williams_narc_data_w(int data)
616void williams_narc_data_w(running_machine &machine, int data)
583617{
618   williams_audio_state *state = &audio;
619   device_t *sound_cpu = state->sound_cpu;
584620   address_space *space = sound_cpu->memory().space(AS_PROGRAM);
585621
586622   soundlatch_w(space, 0, data & 0xff);
r11160r11161
588624   if (!(data & 0x200))
589625   {
590626      device_set_input_line(sound_cpu, M6809_IRQ_LINE, ASSERT_LINE);
591      williams_sound_int_state = 1;
627      state->sound_int_state = 1;
592628   }
593629}
594630
595631
596void williams_narc_reset_w(int state)
632void williams_narc_reset_w(running_machine &machine, int state)
597633{
634   williams_audio_state *sndstate = &audio;
635   device_t *sound_cpu = sndstate->sound_cpu;
636   device_t *soundalt_cpu = sndstate->soundalt_cpu;
637
598638   /* going high halts the CPU */
599639   if (state)
600640   {
r11160r11161
614654}
615655
616656
617int williams_narc_talkback_r(void)
657int williams_narc_talkback_r(running_machine &machine)
618658{
619   return audio_talkback | (audio_sync << 8);
659   williams_audio_state *state = &audio;
660
661   return state->audio_talkback | (state->audio_sync << 8);
620662}
621663
622664
r11160r11161
639681
640682static TIMER_CALLBACK( clear_irq_state )
641683{
642   williams_sound_int_state = 0;
684   williams_audio_state *state = &audio;
685
686   state->sound_int_state = 0;
643687}
644688
645689
646690static READ8_HANDLER( adpcm_command_r )
647691{
692   williams_audio_state *state = &audio;
693   device_t *sound_cpu = state->sound_cpu;
648694   device_set_input_line(sound_cpu, M6809_IRQ_LINE, CLEAR_LINE);
649695
650696   /* don't clear the external IRQ state for a short while; this allows the
r11160r11161
656702
657703static WRITE8_HANDLER( adpcm_talkback_w )
658704{
659   audio_talkback = data;
705   williams_audio_state *state = &audio;
706   state->audio_talkback = data;
660707   logerror("ADPCM Talkback = %02X\n", data);
661708}
662709
r11160r11161
666713    ADPCM COMMUNICATIONS
667714****************************************************************************/
668715
669void williams_adpcm_data_w(int data)
716void williams_adpcm_data_w(running_machine &machine, int data)
670717{
718   williams_audio_state *state = &audio;
719   device_t *sound_cpu = state->sound_cpu;
671720   address_space *space = sound_cpu->memory().space(AS_PROGRAM);
672721   soundlatch_w(space, 0, data & 0xff);
673722   if (!(data & 0x200))
674723   {
675724      device_set_input_line(sound_cpu, M6809_IRQ_LINE, ASSERT_LINE);
676      williams_sound_int_state = 1;
725      state->sound_int_state = 1;
677726      space->machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(100));
678727   }
679728}
680729
681730
682void williams_adpcm_reset_w(int state)
731void williams_adpcm_reset_w(running_machine &machine, int state)
683732{
733   williams_audio_state *sndstate = &audio;
734   device_t *sound_cpu = sndstate->sound_cpu;
735
684736   /* going high halts the CPU */
685737   if (state)
686738   {
r11160r11161
695747}
696748
697749
698int williams_adpcm_sound_irq_r(void)
750int williams_adpcm_sound_irq_r(running_machine &machine)
699751{
700   return williams_sound_int_state;
752   williams_audio_state *state = &audio;
753   return state->sound_int_state;
701754}
src/mame/audio/williams.h
r11160r11161
1010
1111void williams_cvsd_init(running_machine &machine);
1212void williams_cvsd_data_w(running_machine &machine, int data);
13void williams_cvsd_reset_w(int state);
13void williams_cvsd_reset_w(running_machine &machine, int state);
1414
1515void williams_adpcm_init(running_machine &machine);
16void williams_adpcm_data_w(int data);
17void williams_adpcm_reset_w(int state);
18int williams_adpcm_sound_irq_r(void);
16void williams_adpcm_data_w(running_machine &machine, int data);
17void williams_adpcm_reset_w(running_machine &machine, int state);
18int williams_adpcm_sound_irq_r(running_machine &machine);
1919
2020void williams_narc_init(running_machine &machine);
21void williams_narc_data_w(int data);
22void williams_narc_reset_w(int state);
23int williams_narc_talkback_r(void);
21void williams_narc_data_w(running_machine &machine, int data);
22void williams_narc_reset_w(running_machine &machine, int state);
23int williams_narc_talkback_r(running_machine &machine);
src/mame/machine/midyunit.c
r11160r11161
178178   if (offset == 0)
179179      state->m_term2_analog_select = (data >> 12) & 3;
180180
181   williams_adpcm_reset_w((~data & 0x100) >> 1);
182   williams_adpcm_data_w(data);
181   williams_adpcm_reset_w(space->machine(), (~data & 0x100) >> 1);
182   williams_adpcm_data_w(space->machine(), data);
183183}
184184
185185
r11160r11161
569569   switch (state->m_chip_type)
570570   {
571571      case SOUND_NARC:
572         williams_narc_reset_w(1);
573         williams_narc_reset_w(0);
572         williams_narc_reset_w(machine, 1);
573         williams_narc_reset_w(machine, 0);
574574         break;
575575
576576      case SOUND_CVSD:
577577      case SOUND_CVSD_SMALL:
578         williams_cvsd_reset_w(1);
579         williams_cvsd_reset_w(0);
578         williams_cvsd_reset_w(machine, 1);
579         williams_cvsd_reset_w(machine, 0);
580580         break;
581581
582582      case SOUND_ADPCM:
583         williams_adpcm_reset_w(1);
584         williams_adpcm_reset_w(0);
583         williams_adpcm_reset_w(machine, 1);
584         williams_adpcm_reset_w(machine, 0);
585585         break;
586586
587587      case SOUND_YAWDIM:
r11160r11161
612612      switch (state->m_chip_type)
613613      {
614614         case SOUND_NARC:
615            williams_narc_data_w(data);
615            williams_narc_data_w(space->machine(), data);
616616            break;
617617
618618         case SOUND_CVSD_SMALL:
619619         case SOUND_CVSD:
620            williams_cvsd_reset_w((~data & 0x100) >> 8);
620            williams_cvsd_reset_w(space->machine(), (~data & 0x100) >> 8);
621621            williams_cvsd_data_w(space->machine(), (data & 0xff) | ((data & 0x200) >> 1));
622622            break;
623623
624624         case SOUND_ADPCM:
625            williams_adpcm_reset_w((~data & 0x100) >> 8);
626            williams_adpcm_data_w(data);
625            williams_adpcm_reset_w(space->machine(), (~data & 0x100) >> 8);
626            williams_adpcm_data_w(space->machine(), data);
627627            break;
628628
629629         case SOUND_YAWDIM:
src/mame/machine/midwayic.c
r11160r11161
820820      if (LOG_FIFO)
821821         logerror("fifo_w(%04X): out of space!\n", data);
822822   }
823   dcs_fifo_notify(ioasic.fifo_bytes, FIFO_SIZE);
823   dcs_fifo_notify(machine, ioasic.fifo_bytes, FIFO_SIZE);
824824}
825825
826826
r11160r11161
830830      logerror("fifo_full_w(%04X)\n", data);
831831   ioasic.force_fifo_full = 1;
832832   update_ioasic_irq(machine);
833   dcs_fifo_notify(ioasic.fifo_bytes, FIFO_SIZE);
833   dcs_fifo_notify(machine, ioasic.fifo_bytes, FIFO_SIZE);
834834}
835835
836836
r11160r11161
894894         result = 0;
895895         if (ioasic.has_dcs)
896896         {
897            result |= ((dcs_control_r() >> 4) ^ 0x40) & 0x00c0;
897            result |= ((dcs_control_r(space->machine()) >> 4) ^ 0x40) & 0x00c0;
898898            result |= ioasic_fifo_status_r(&space->device()) & 0x0038;
899            result |= dcs_data2_r() & 0xff00;
899            result |= dcs_data2_r(space->machine()) & 0xff00;
900900         }
901901         else if (ioasic.has_cage)
902902         {
903            result |= (cage_control_r() << 6) ^ 0x80;
903            result |= (cage_control_r(space->machine()) << 6) ^ 0x80;
904904         }
905905         else
906906            result |= 0x48;
r11160r11161
910910         result = 0;
911911         if (ioasic.has_dcs)
912912         {
913            result = dcs_data_r();
913            result = dcs_data_r(space->machine());
914914            if (ioasic.auto_ack)
915               dcs_ack_w();
915               dcs_ack_w(space->machine());
916916         }
917917         else if (ioasic.has_cage)
918            result = main_from_cage_r(space);
918            result = cage_main_r(space);
919919         else
920920         {
921921            static UINT16 val = 0;
r11160r11161
994994         /* sound reset? */
995995         if (ioasic.has_dcs)
996996         {
997            dcs_reset_w(~newreg & 1);
997            dcs_reset_w(space->machine(), ~newreg & 1);
998998         }
999999         else if (ioasic.has_cage)
10001000         {
r11160r11161
10121012
10131013      case IOASIC_SOUNDOUT:
10141014         if (ioasic.has_dcs)
1015            dcs_data_w(newreg);
1015            dcs_data_w(space->machine(), newreg);
10161016         else if (ioasic.has_cage)
1017            main_to_cage_w(newreg);
1017            cage_main_w(space, newreg);
10181018         break;
10191019
10201020      case IOASIC_SOUNDIN:
1021         dcs_ack_w();
1021         dcs_ack_w(space->machine());
10221022         /* acknowledge data read */
10231023         break;
10241024
src/mame/machine/scramble.c
r11160r11161
1010#include "emu.h"
1111#include "cpu/z80/z80.h"
1212#include "machine/8255ppi.h"
13#include "includes/galaxold.h"
13#include "includes/scramble.h"
1414
15static UINT8 cavelon_bank;
1615
17static UINT8 security_2B_counter;
18
1916MACHINE_RESET( scramble )
2017{
18   scramble_state *state = machine.driver_data<scramble_state>();
2119   MACHINE_RESET_CALL(galaxold);
2220
2321   if (machine.device("audiocpu") != NULL)
2422      scramble_sh_init(machine);
2523
26  security_2B_counter = 0;
24   state->m_security_2B_counter = 0;
2725}
2826
2927MACHINE_RESET( explorer )
r11160r11161
5149}
5250
5351/* state of the security PAL (6J) */
54static UINT8 xb;
5552
5653static WRITE8_DEVICE_HANDLER( scramble_protection_w )
5754{
58   xb = data;
55   scramble_state *state = device->machine().driver_data<scramble_state>();
56   state->m_xb = data;
5957}
6058
6159static READ8_DEVICE_HANDLER( scramble_protection_r )
r11160r11161
107105
108106static void cavelon_banksw(running_machine &machine)
109107{
108   scramble_state *state = machine.driver_data<scramble_state>();
110109   /* any read/write access in the 0x8000-0xffff region causes a bank switch.
111110       Only the lower 0x2000 is switched but we switch the whole region
112111       to keep the CPU core happy at the boundaries */
113112
114   cavelon_bank = !cavelon_bank;
115   memory_set_bank(machine, "bank1", cavelon_bank);
113   state->m_cavelon_bank = !state->m_cavelon_bank;
114   memory_set_bank(machine, "bank1", state->m_cavelon_bank);
116115}
117116
118117static READ8_HANDLER( cavelon_banksw_r )
r11160r11161
325324
326325DRIVER_INIT( cavelon )
327326{
327   scramble_state *state = machine.driver_data<scramble_state>();
328328   UINT8 *ROM = machine.region("maincpu")->base();
329329
330330   /* banked ROM */
r11160r11161
338338   machine.device("maincpu")->memory().space(AS_PROGRAM)->nop_write(0x2000, 0x2000);   /* ??? */
339339   machine.device("maincpu")->memory().space(AS_PROGRAM)->nop_write(0x3800, 0x3801);  /* looks suspicously like
340340                                                               an AY8910, but not sure */
341   state_save_register_global(machine, cavelon_bank);
341   state_save_register_global(machine, state->m_cavelon_bank);
342342}
343343
344344
r11160r11161
395395}
396396
397397
398static int bit(int i,int n)
398INLINE int bit(int i,int n)
399399{
400400   return ((i >> n) & 1);
401401}
src/mame/machine/midtunit.c
r11160r11161
577577   {
578578      case SOUND_ADPCM:
579579      case SOUND_ADPCM_LARGE:
580         williams_adpcm_reset_w(1);
581         williams_adpcm_reset_w(0);
580         williams_adpcm_reset_w(machine, 1);
581         williams_adpcm_reset_w(machine, 0);
582582         break;
583583
584584      case SOUND_DCS:
585         dcs_reset_w(1);
586         dcs_reset_w(0);
585         dcs_reset_w(machine, 1);
586         dcs_reset_w(machine, 0);
587587         break;
588588   }
589589}
r11160r11161
601601/*  logerror("%08X:Sound status read\n", cpu_get_pc(&space->device()));*/
602602
603603   if (chip_type == SOUND_DCS)
604      return dcs_control_r() >> 4;
604      return dcs_control_r(space->machine()) >> 4;
605605
606606   if (fake_sound_state)
607607   {
r11160r11161
616616   logerror("%08X:Sound data read\n", cpu_get_pc(&space->device()));
617617
618618   if (chip_type == SOUND_DCS)
619      return dcs_data_r() & 0xff;
619      return dcs_data_r(space->machine()) & 0xff;
620620
621621   return ~0;
622622}
r11160r11161
636636      {
637637         case SOUND_ADPCM:
638638         case SOUND_ADPCM_LARGE:
639            williams_adpcm_reset_w(~data & 0x100);
640            williams_adpcm_data_w(data & 0xff);
639            williams_adpcm_reset_w(space->machine(), ~data & 0x100);
640            williams_adpcm_data_w(space->machine(), data & 0xff);
641641
642642            /* the games seem to check for $82 loops, so this should be just barely enough */
643643            fake_sound_state = 128;
r11160r11161
645645
646646         case SOUND_DCS:
647647            logerror("%08X:Sound write = %04X\n", cpu_get_pc(&space->device()), data);
648            dcs_reset_w(~data & 0x100);
649            dcs_data_w(data & 0xff);
648            dcs_reset_w(space->machine(), ~data & 0x100);
649            dcs_data_w(space->machine(), data & 0xff);
650650            /* the games seem to check for $82 loops, so this should be just barely enough */
651651            fake_sound_state = 128;
652652            break;
src/mame/machine/midxunit.c
r11160r11161
104104   int offs = offset / 0x40000;
105105
106106   if (offs == 1 && ACCESSING_BITS_0_7)
107      dcs_reset_w(data & 2);
107      dcs_reset_w(space->machine(), data & 2);
108108
109109   if (ACCESSING_BITS_0_7 && offset % 0x40000 == 0)
110110      logerror("%08X:midxunit_unknown_w @ %d = %02X\n", cpu_get_pc(&space->device()), offs, data & 0xff);
r11160r11161
274274         break;
275275
276276      case 5:   /* register 5 write seems to reset things */
277         dcs_data_r();
277         dcs_data_r(space->machine());
278278         break;
279279
280280      default: /* everyone else just stores themselves */
r11160r11161
342342   int i;
343343
344344   /* reset sound */
345   dcs_reset_w(1);
346   dcs_reset_w(0);
345   dcs_reset_w(machine, 1);
346   dcs_reset_w(machine, 0);
347347
348348   /* reset I/O shuffling */
349349   for (i = 0; i < 16; i++)
r11160r11161
392392{
393393   logerror("%08X:Sound read\n", cpu_get_pc(&space->device()));
394394
395   return dcs_data_r() & 0xff;
395   return dcs_data_r(space->machine()) & 0xff;
396396}
397397
398398
399399READ16_HANDLER( midxunit_sound_state_r )
400400{
401   return dcs_control_r();
401   return dcs_control_r(space->machine());
402402}
403403
404404
r11160r11161
415415   if (ACCESSING_BITS_0_7)
416416   {
417417      logerror("%08X:Sound write = %04X\n", cpu_get_pc(&space->device()), data);
418      dcs_data_w(data & 0xff);
418      dcs_data_w(space->machine(), data & 0xff);
419419   }
420420}
src/mame/machine/vertigo.c
r11160r11161
169169
170170static TIMER_CALLBACK( sound_command_w )
171171{
172   exidy440_sound_command(machine, param);
172   vertigo_state *state = machine.driver_data<vertigo_state>();
173   exidy440_sound_command(state->m_custom, param);
173174
174175   /* It is important that the sound cpu ACKs the sound command
175176       quickly. Otherwise the main CPU gives up with sound. Boosting
r11160r11161
188189
189190READ16_HANDLER( vertigo_sio_r )
190191{
191   return exidy440_sound_command_ack() ? 0xfc : 0xfd;
192   vertigo_state *state = space->machine().driver_data<vertigo_state>();
193   return exidy440_sound_command_ack(state->m_custom) ? 0xfc : 0xfd;
192194}
193195
194196
r11160r11161
202204MACHINE_START( vertigo )
203205{
204206   vertigo_state *state = machine.driver_data<vertigo_state>();
207
208   state->m_custom = machine.device("custom");
209   state->m_ttl74148 = machine.device("74148");
210
205211   state_save_register_global(machine, state->m_irq_state);
206212   state_save_register_global(machine, state->m_adc_result);
207213   state_save_register_global(machine, state->m_irq4_time);
r11160r11161
214220   vertigo_state *state = machine.driver_data<vertigo_state>();
215221   int i;
216222
217   state->m_ttl74148 = machine.device("74148");
218223   ttl74148_enable_input_w(state->m_ttl74148, 0);
219224
220225   for (i = 0; i < 8; i++)
src/mame/machine/subsino.c
r0r11161
1/***************************************************************************
2
3Subsino XOR + Bitswap Encryption
4by David Haywood
5
6***************************************************************************/
7
8#include "emu.h"
9
10// XORs:
11
12extern const UINT8 crsbingo_xors[8] = { 0xbb, 0xcc, 0xcc, 0xdd, 0xaa, 0x11, 0x44, 0xee };
13extern const UINT8 sharkpy_xors [8] = { 0xcc, 0xaa, 0x66, 0xaa, 0xee, 0x33, 0xff, 0xff };
14extern const UINT8 victor5_xors [8] = { 0x99, 0x99, 0x33, 0x44, 0xbb, 0x88, 0x88, 0xbb };
15extern const UINT8 victor21_xors[8] = { 0x44, 0xbb, 0x66, 0x44, 0xaa, 0x55, 0x88, 0x22 };
16
17// Bitswaps:
18
19void crsbingo_bitswaps(UINT8 *decrypt, int i)
20{
21   if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 );
22   if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 );
23   if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i], 3,2,5,0,7,6,1,4 );
24   if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,0,3,6,1,4 );
25   if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i], 7,6,5,0,3,2,1,4 );
26   if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,4,3,6,5,0 );
27   if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 );
28   if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,0,7,6,5,4 );
29}
30
31void sharkpy_bitswaps(UINT8 *decrypt, int i)
32{
33   if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,0,7,6,5,4 );
34   if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 );
35   if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,4,3,6,5,0 );
36   if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i], 3,6,1,0,7,2,5,4 );
37   if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 );
38   if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i], 3,2,5,4,7,6,1,0 );
39   if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i], 7,6,1,4,3,2,5,0 );
40   if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i], 3,6,1,4,7,2,5,0 );
41}
42
43void victor5_bitswaps(UINT8 *decrypt, int i)
44{
45   if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 );
46   if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i], 7,6,5,0,3,2,1,4 );
47   if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 );
48   if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 );
49   if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,0,7,6,5,4 );
50   if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i], 7,6,5,0,3,2,1,4 );
51   if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i], 3,6,1,0,7,2,5,4 );
52   if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,4,3,6,5,0 );
53}
54
55void victor21_bitswaps(UINT8 *decrypt, int i)
56{
57   if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i], 7,2,1,0,3,6,5,4 );
58   if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i], 3,6,1,4,7,2,5,0 );
59   if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,4,7,6,5,0 );
60   if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 );
61   if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i], 7,2,5,4,3,6,1,0 );
62   if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i], 3,6,5,0,7,2,1,4 );
63   if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i], 7,6,5,4,3,2,1,0 );
64   if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i], 3,2,1,4,7,6,5,0 );
65}
66
67// Decrypt:
68
69#if 0
70void dump_decrypted(running_machine& machine, UINT8* decrypt)
71{
72    FILE *fp;
73    char filename[256];
74    sprintf(filename,"dat_%s", machine.system().name);
75    fp=fopen(filename, "w+b");
76    if (fp)
77    {
78        fwrite(decrypt, 0x10000, 1, fp);
79        fclose(fp);
80    }
81}
82#endif
83
84void subsino_decrypt(running_machine& machine, void (*bitswaps)(UINT8 *decrypt, int i), const UINT8 *xors, int size)
85{
86   int i;
87   UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000);
88   UINT8* region = machine.region("maincpu")->base();
89
90   for (i=0;i<0x10000;i++)
91   {
92      if (i<size)
93      {
94         decrypt[i] = region[i]^xors[i&7];
95         bitswaps(decrypt, i);
96      }
97      else
98      {
99         decrypt[i] = region[i];
100      }
101   }
102//  dump_decrypted(machine, decrypt);
103   memcpy(region, decrypt, 0x10000);
104}
src/mame/machine/pcshare.c
r11160r11161
264264   cputag_set_input_line(device->machine(), "maincpu", 0, state ? HOLD_LINE : CLEAR_LINE);
265265}
266266
267static READ8_DEVICE_HANDLER( get_slave_ack )
268{
269   if (offset==2) { // IRQ = 2
270      return pic8259_acknowledge(device->machine().device("pic8259_2"));
271   }
272   return 0x00;
273}
274
267275static const struct pic8259_interface pic8259_1_config =
268276{
269   DEVCB_LINE(pic8259_1_set_int_line)
277   DEVCB_LINE(pic8259_1_set_int_line),
278   DEVCB_LINE_VCC,
279   DEVCB_HANDLER(get_slave_ack)
270280};
271281
272282static const struct pic8259_interface pic8259_2_config =
273283{
274   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w)
284   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w),
285   DEVCB_LINE_GND,
286   DEVCB_NULL
275287};
276288
277289IRQ_CALLBACK(pcat_irq_callback)
278290{
279   int r = 0;
280   r = pic8259_acknowledge(device->machine().device("pic8259_2"));
281   if (r==0)
282   {
283      r = pic8259_acknowledge(device->machine().device("pic8259_1"));
284   }
285   return r;
291   return pic8259_acknowledge(device->machine().device("pic8259_1"));
286292}
287293
288294static WRITE_LINE_DEVICE_HANDLER( at_pit8254_out0_changed )
src/mame/machine/subsino.h
r0r11161
1#ifndef __MACHINE_SUBSINO__
2#define __MACHINE_SUBSINO__
3
4#include "emu.h"
5
6extern const UINT8 crsbingo_xors[8];
7extern const UINT8 sharkpy_xors [8];
8extern const UINT8 victor5_xors [8];
9extern const UINT8 victor21_xors[8];
10
11void crsbingo_bitswaps(UINT8 *decrypt, int i);
12void sharkpy_bitswaps (UINT8 *decrypt, int i);
13void victor5_bitswaps (UINT8 *decrypt, int i);
14void victor21_bitswaps(UINT8 *decrypt, int i);
15
16void subsino_decrypt(running_machine& machine, void (*bitswaps)(UINT8 *decrypt, int i), const UINT8 *xors, int size);
17
18#endif
src/mame/machine/atarigen.c
r11160r11161
4545#include "sound/tms5220.h"
4646#include "sound/okim6295.h"
4747#include "sound/pokey.h"
48#include "video/atarimo.h"
4849#include "includes/slapstic.h"
4950#include "atarigen.h"
5051
src/mame/machine/atarigen.h
r11160r11161
4141#define __MACHINE_ATARIGEN__
4242
4343#include "machine/nvram.h"
44#include "video/atarimo.h"
4544#include "machine/er2055.h"
4645
4746
src/mame/machine/midwunit.c
r11160r11161
9797         logerror("%08X:Control W @ %05X = %04X\n", cpu_get_pc(&space->device()), offset, data);
9898
9999         /* bit 4 reset sound CPU */
100         dcs_reset_w(newword & 0x10);
100         dcs_reset_w(space->machine(), newword & 0x10);
101101
102102         /* bit 5 (active low) reset security chip */
103103         midway_serial_pic_reset_w(newword & 0x20);
r11160r11161
378378   int i;
379379
380380   /* reset sound */
381   dcs_reset_w(1);
382   dcs_reset_w(0);
381   dcs_reset_w(machine, 1);
382   dcs_reset_w(machine, 0);
383383
384384   /* reset I/O shuffling */
385385   for (i = 0; i < 16; i++)
r11160r11161
418418{
419419   logerror("%08X:Sound read\n", cpu_get_pc(&space->device()));
420420
421   return dcs_data_r() & 0xff;
421   return dcs_data_r(space->machine()) & 0xff;
422422}
423423
424424
425425READ16_HANDLER( midwunit_sound_state_r )
426426{
427   return dcs_control_r();
427   return dcs_control_r(space->machine());
428428}
429429
430430
r11160r11161
441441   if (ACCESSING_BITS_0_7)
442442   {
443443      logerror("%08X:Sound write = %04X\n", cpu_get_pc(&space->device()), data);
444      dcs_data_w(data & 0xff);
444      dcs_data_w(space->machine(), data & 0xff);
445445   }
446446}
src/mame/machine/naomibd.c
r11160r11161
516516
517517// Streaming M2/M3 protection and decompression
518518
519INLINE UINT16 bswap16(UINT16 in)
519INLINE UINT16 naomi_bswap16(UINT16 in)
520520{
521521    return ((in>>8) | (in<<8));
522522}
523523
524524static UINT16 naomibd_get_decrypted_stream(naomibd_state *naomibd)
525525{
526   UINT16 wordn = bswap16(naomibd->prot.ptr[naomibd->prot.count++]);
526   UINT16 wordn = naomi_bswap16(naomibd->prot.ptr[naomibd->prot.count++]);
527527
528528   naomibd->prot.aux_word = block_decrypt(naomibd->dc_gamekey, naomibd->dc_seqkey, naomibd->prot.seed++, wordn);
529529   wordn = (naomibd->prot.last_word&~3) | (naomibd->prot.aux_word&3);
src/mame/machine/galaxold.c
r11160r11161
1111#include "machine/7474.h"
1212#include "includes/galaxold.h"
1313
14static int irq_line;
1514
16static UINT8 _4in1_bank;
17
1815static IRQ_CALLBACK(hunchbkg_irq_callback)
1916{
17   //galaxold_state *state = device->machine().driver_data<galaxold_state>();
2018   /* for some reason a call to cputag_set_input_line
2119     * is significantly delayed ....
2220     *
r11160r11161
2523     * Therefore we reset the line without any detour ....
2624     */
2725   device_set_input_line(device->machine().firstcpu, 0, CLEAR_LINE);
28   //cpu_set_info(device->machine().firstcpu, CPUINFO_INT_INPUT_STATE + irq_line, CLEAR_LINE);
26   //cpu_set_info(device->machine().firstcpu, CPUINFO_INT_INPUT_STATE + state->m_irq_line, CLEAR_LINE);
2927   return 0x03;
3028}
3129
r11160r11161
3937
4038WRITE_LINE_DEVICE_HANDLER( galaxold_7474_9m_1_callback )
4139{
40   galaxold_state *drvstate = device->machine().driver_data<galaxold_state>();
4241   /* Q goes to the NMI line */
43   cputag_set_input_line(device->machine(), "maincpu", irq_line, state ? CLEAR_LINE : ASSERT_LINE);
42   cputag_set_input_line(device->machine(), "maincpu", drvstate->m_irq_line, state ? CLEAR_LINE : ASSERT_LINE);
4443}
4544
4645WRITE8_HANDLER( galaxold_nmi_enable_w )
r11160r11161
6867
6968static void machine_reset_common(running_machine &machine, int line)
7069{
70   galaxold_state *state = machine.driver_data<galaxold_state>();
7171    device_t *ttl7474_9m_1 = machine.device("7474_9m_1");
7272    device_t *ttl7474_9m_2 = machine.device("7474_9m_2");
73   irq_line = line;
73   state->m_irq_line = line;
7474
7575   /* initalize main CPU interrupt generator flip-flops */
7676   ttl7474_preset_w(ttl7474_9m_2, 1);
r11160r11161
249249
250250WRITE8_HANDLER( _4in1_bank_w )
251251{
252   _4in1_bank = data & 0x03;
253   galaxold_gfxbank_w(space, 0, _4in1_bank);
254   memory_set_bank(space->machine(), "bank1", _4in1_bank);
252   galaxold_state *state = space->machine().driver_data<galaxold_state>();
253   state->m__4in1_bank = data & 0x03;
254   galaxold_gfxbank_w(space, 0, state->m__4in1_bank);
255   memory_set_bank(space->machine(), "bank1", state->m__4in1_bank);
255256}
256257
257258CUSTOM_INPUT( _4in1_fake_port_r )
258259{
260   galaxold_state *state = field->port->machine().driver_data<galaxold_state>();
259261   static const char *const portnames[] = { "FAKE1", "FAKE2", "FAKE3", "FAKE4" };
260262   int bit_mask = (FPTR)param;
261263
262   return (input_port_read(field->port->machine(), portnames[_4in1_bank]) & bit_mask) ? 0x01 : 0x00;
264   return (input_port_read(field->port->machine(), portnames[state->m__4in1_bank]) & bit_mask) ? 0x01 : 0x00;
263265}
264266
265267#ifdef UNUSED_FUNCTION
r11160r11161
397399
398400DRIVER_INIT( 4in1 )
399401{
402   galaxold_state *state = machine.driver_data<galaxold_state>();
400403   address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
401404   offs_t i, len = machine.region("maincpu")->bytes();
402405   UINT8 *RAM = machine.region("maincpu")->base();
r11160r11161
410413
411414   _4in1_bank_w(space, 0, 0); /* set the initial CPU bank */
412415
413   state_save_register_global(machine, _4in1_bank);
416   state_save_register_global(machine, state->m__4in1_bank);
414417}
415418
416419INTERRUPT_GEN( hunchbks_vh_interrupt )
src/mame/machine/kaneko16.c
r11160r11161
2121
2222#define CALC3_VERBOSE_OUTPUT 0
2323
24#define MCU_RESPONSE(d) memcpy(&kaneko16_mcu_ram[mcu_offset], d, sizeof(d))
24#define MCU_RESPONSE(d) memcpy(&state->m_mcu_ram[mcu_offset], d, sizeof(d))
2525
26UINT16 *kaneko16_mcu_ram;
27
2826/***************************************************************************
2927                                Gals Panic (set 2)
3028                                Gals Panic (set 3)
r11160r11161
4038static READ16_HANDLER(shogwarr_calc_r);
4139static WRITE16_HANDLER(shogwarr_calc_w);
4240
43static struct {
44   UINT16 x1p, y1p, x1s, y1s;
45   UINT16 x2p, y2p, x2s, y2s;
46
47   INT16 x12, y12, x21, y21;
48
49   UINT16 mult_a, mult_b;
50} hit;
51
5241READ16_HANDLER(galpanib_calc_r) /* Simulation of the CALC1 MCU */
5342{
43   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
44   calc1_hit_t &hit = state->m_hit;
5445   UINT16 data = 0;
5546
5647   switch (offset)
r11160r11161
10394
10495WRITE16_HANDLER(galpanib_calc_w)
10596{
97   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
98   calc1_hit_t &hit = state->m_hit;
99
106100   switch (offset)
107101   {
108102      // p is position, s is size
r11160r11161
124118
125119WRITE16_HANDLER(bloodwar_calc_w)
126120{
127
121   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
122   calc1_hit_t &hit = state->m_hit;
128123   int isbrap = ( !strcmp(space->machine().system().name,"brapboysj") || !strcmp(space->machine().system().name,"brapboys"));
129124
130125   /* our implementation is incomplete, b.rap boys requires some modifications */
r11160r11161
164159  result      <---------->  |     <-------->     |       <---->
165160*/
166161
167static INT16 calc_compute_x(void)
162static INT16 calc_compute_x(calc1_hit_t &hit)
168163{
169164   INT16 x_coll;
170165
r11160r11161
179174   return x_coll;
180175}
181176
182static INT16 calc_compute_y(void)
177static INT16 calc_compute_y(calc1_hit_t &hit)
183178{
184179   INT16 y_coll;
185180
r11160r11161
196191
197192READ16_HANDLER(bloodwar_calc_r)
198193{
194   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
195   calc1_hit_t &hit = state->m_hit;
199196   UINT16 data = 0;
200197   INT16 x_coll, y_coll;
201198
r11160r11161
207204      return shogwarr_calc_r(space,offset,mem_mask);
208205   }
209206
210   x_coll = calc_compute_x();
211   y_coll = calc_compute_y();
207   x_coll = calc_compute_x(hit);
208   y_coll = calc_compute_y(hit);
212209
213210   switch (offset)
214211   {
r11160r11161
269266*/
270267
271268
272static struct {
273   int x1p, y1p, z1p, x1s, y1s, z1s;
274   int x2p, y2p, z2p, x2s, y2s, z2s;
275
276   int x1po, y1po, z1po, x1so, y1so, z1so;
277   int x2po, y2po, z2po, x2so, y2so, z2so;
278
279   int x12, y12, z12, x21, y21, z21;
280
281   int x_coll, y_coll, z_coll;
282
283   int x1tox2, y1toy2, z1toz2;
284
285   UINT16 mult_a, mult_b;
286
287   UINT16 flags;
288   UINT16 mode;
289
290} shogwarr_hit;
291
292
293269//calculate simple intersection of two segments
294270
295271static int shogwarr_calc_compute(int x1, int w1, int x2, int w2)
r11160r11161
340316   //x1 is the left most coord, s1 = width
341317}
342318
343static void shogwarr_recalc_collisions(void)
319static void shogwarr_recalc_collisions(calc3_hit_t &hit3)
344320{
345321   //calculate positions and sizes
346322
347   int mode=shogwarr_hit.mode;
323   int mode=hit3.mode;
348324
349   shogwarr_hit.flags=0;
325   hit3.flags=0;
350326
351   shogwarr_calc_org(mode&3, shogwarr_hit.x1po, shogwarr_hit.x1so, &shogwarr_hit.x1p, &shogwarr_hit.x1s);
352   mode>>=2;
353   shogwarr_calc_org(mode&3, shogwarr_hit.y1po, shogwarr_hit.y1so, &shogwarr_hit.y1p, &shogwarr_hit.y1s);
354   mode>>=2;
355   shogwarr_calc_org(mode&3, shogwarr_hit.z1po, shogwarr_hit.z1so, &shogwarr_hit.z1p, &shogwarr_hit.z1s);
327   shogwarr_calc_org((mode>>0)&3, hit3.x1po, hit3.x1so, &hit3.x1p, &hit3.x1s);
328   shogwarr_calc_org((mode>>2)&3, hit3.y1po, hit3.y1so, &hit3.y1p, &hit3.y1s);
329   shogwarr_calc_org((mode>>4)&3, hit3.z1po, hit3.z1so, &hit3.z1p, &hit3.z1s);
356330
357   mode>>=4;
331   shogwarr_calc_org((mode>>8)&3, hit3.x2po, hit3.x2so, &hit3.x2p, &hit3.x2s);
332   shogwarr_calc_org((mode>>10)&3, hit3.y2po, hit3.y2so, &hit3.y2p, &hit3.y2s);
333   shogwarr_calc_org((mode>>12)&3, hit3.z2po, hit3.z2so, &hit3.z2p, &hit3.z2s);
358334
359   shogwarr_calc_org(mode&3, shogwarr_hit.x2po, shogwarr_hit.x2so, &shogwarr_hit.x2p, &shogwarr_hit.x2s);
360   mode>>=2;
361   shogwarr_calc_org(mode&3, shogwarr_hit.y2po, shogwarr_hit.y2so, &shogwarr_hit.y2p, &shogwarr_hit.y2s);
362   mode>>=2;
363   shogwarr_calc_org(mode&3, shogwarr_hit.z2po, shogwarr_hit.z2so, &shogwarr_hit.z2p, &shogwarr_hit.z2s);
364335
336   hit3.x1tox2=abs(hit3.x2po-hit3.x1po);
337   hit3.y1toy2=abs(hit3.y2po-hit3.y1po);
338   hit3.z1toz2=abs(hit3.z2po-hit3.z1po);
365339
366   shogwarr_hit.x1tox2=abs(shogwarr_hit.x2po-shogwarr_hit.x1po);
367   shogwarr_hit.y1toy2=abs(shogwarr_hit.y2po-shogwarr_hit.y1po);
368   shogwarr_hit.z1toz2=abs(shogwarr_hit.z2po-shogwarr_hit.z1po);
369340
341   hit3.x_coll = shogwarr_calc_compute(hit3.x1p, hit3.x1s, hit3.x2p, hit3.x2s);
342   hit3.y_coll = shogwarr_calc_compute(hit3.y1p, hit3.y1s, hit3.y2p, hit3.y2s);
343   hit3.z_coll = shogwarr_calc_compute(hit3.z1p, hit3.z1s, hit3.z2p, hit3.z2s);
370344
371   shogwarr_hit.x_coll = shogwarr_calc_compute(shogwarr_hit.x1p, shogwarr_hit.x1s, shogwarr_hit.x2p, shogwarr_hit.x2s);
372   shogwarr_hit.y_coll = shogwarr_calc_compute(shogwarr_hit.y1p, shogwarr_hit.y1s, shogwarr_hit.y2p, shogwarr_hit.y2s);
373   shogwarr_hit.z_coll = shogwarr_calc_compute(shogwarr_hit.z1p, shogwarr_hit.z1s, shogwarr_hit.z2p, shogwarr_hit.z2s);
374345
375
376346   // 4th nibble: Y Absolute Collision -> possible values = 9,8,4,3,2
377   if      (shogwarr_hit.y1p >  shogwarr_hit.y2p)   shogwarr_hit.flags |= 0x2000;
378   else if (shogwarr_hit.y1p == shogwarr_hit.y2p)   shogwarr_hit.flags |= 0x4000;
379   else if (shogwarr_hit.y1p <  shogwarr_hit.y2p)   shogwarr_hit.flags |= 0x8000;
380   if (shogwarr_hit.y_coll<0) shogwarr_hit.flags |= 0x1000;
347   if      (hit3.y1p >  hit3.y2p)   hit3.flags |= 0x2000;
348   else if (hit3.y1p == hit3.y2p)   hit3.flags |= 0x4000;
349   else if (hit3.y1p <  hit3.y2p)   hit3.flags |= 0x8000;
350   if (hit3.y_coll<0) hit3.flags |= 0x1000;
381351
382352   // 3rd nibble: X Absolute Collision -> possible values = 9,8,4,3,2
383   if      (shogwarr_hit.x1p >  shogwarr_hit.x2p)   shogwarr_hit.flags |= 0x0200;
384   else if (shogwarr_hit.x1p == shogwarr_hit.x2p)   shogwarr_hit.flags |= 0x0400;
385   else if (shogwarr_hit.x1p <  shogwarr_hit.x2p)   shogwarr_hit.flags |= 0x0800;
386   if (shogwarr_hit.x_coll<0) shogwarr_hit.flags |= 0x0100;
353   if      (hit3.x1p >  hit3.x2p)   hit3.flags |= 0x0200;
354   else if (hit3.x1p == hit3.x2p)   hit3.flags |= 0x0400;
355   else if (hit3.x1p <  hit3.x2p)   hit3.flags |= 0x0800;
356   if (hit3.x_coll<0) hit3.flags |= 0x0100;
387357
388358   // 2nd nibble: Z Absolute Collision -> possible values = 9,8,4,3,2
389   if      (shogwarr_hit.z1p >  shogwarr_hit.z2p)   shogwarr_hit.flags |= 0x0020;
390   else if (shogwarr_hit.z1p == shogwarr_hit.z2p)   shogwarr_hit.flags |= 0x0040;
391   else if (shogwarr_hit.z1p <  shogwarr_hit.z2p)   shogwarr_hit.flags |= 0x0080;
392   if (shogwarr_hit.z_coll<0) shogwarr_hit.flags |= 0x0010;
359   if      (hit3.z1p >  hit3.z2p)   hit3.flags |= 0x0020;
360   else if (hit3.z1p == hit3.z2p)   hit3.flags |= 0x0040;
361   else if (hit3.z1p <  hit3.z2p)   hit3.flags |= 0x0080;
362   if (hit3.z_coll<0) hit3.flags |= 0x0010;
393363
394364   // 1st nibble: XYZ Overlap Collision
395   if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.y_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0008;
396   if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0004;
397   if ((shogwarr_hit.y_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0002;
398   if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.y_coll>=0)) shogwarr_hit.flags |= 0x0001;
365   if ((hit3.x_coll>=0)&&(hit3.y_coll>=0)&&(hit3.z_coll>=0)) hit3.flags |= 0x0008;
366   if ((hit3.x_coll>=0)&&(hit3.z_coll>=0)) hit3.flags |= 0x0004;
367   if ((hit3.y_coll>=0)&&(hit3.z_coll>=0)) hit3.flags |= 0x0002;
368   if ((hit3.x_coll>=0)&&(hit3.y_coll>=0)) hit3.flags |= 0x0001;
399369}
400370
401371
402372static WRITE16_HANDLER(shogwarr_calc_w)
403373{
374   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
375   calc3_hit_t &hit3 = state->m_hit3;
404376   int idx=offset*4;
405377   switch (idx)
406378   {
r11160r11161
408380      case 0x00:
409381      case 0x28:
410382
411               shogwarr_hit.x1po = data; break;
383               hit3.x1po = data; break;
412384
413385      case 0x04:
414386      case 0x2c:
415               shogwarr_hit.x1so = data; break;
387               hit3.x1so = data; break;
416388
417389      case 0x08:
418390      case 0x30:
419               shogwarr_hit.y1po = data; break;
391               hit3.y1po = data; break;
420392
421393      case 0x0c:
422394      case 0x34:
423               shogwarr_hit.y1so = data; break;
395               hit3.y1so = data; break;
424396
425397      case 0x10:
426398      case 0x58:
427               shogwarr_hit.x2po = data; break;
399               hit3.x2po = data; break;
428400
429401      case 0x14:
430402      case 0x5c:
431               shogwarr_hit.x2so = data; break;
403               hit3.x2so = data; break;
432404
433405      case 0x18:
434406      case 0x60:
435               shogwarr_hit.y2po = data; break;
407               hit3.y2po = data; break;
436408
437409      case 0x1c:
438410      case 0x64:
439               shogwarr_hit.y2so = data; break;
411               hit3.y2so = data; break;
440412
441413      case 0x38:
442414      case 0x50:
443               shogwarr_hit.z1po = data; break;
415               hit3.z1po = data; break;
444416      case 0x3c:
445417      case 0x54:
446               shogwarr_hit.z1so = data; break;
418               hit3.z1so = data; break;
447419
448420      case 0x20:
449421      case 0x68:
450               shogwarr_hit.z2po = data; break;
422               hit3.z2po = data; break;
451423
452424      case 0x24:
453425      case 0x6c:
454               shogwarr_hit.z2so = data; break;
426               hit3.z2so = data; break;
455427
456428      case 0x70:
457               shogwarr_hit.mode=data;break;
429               hit3.mode=data;break;
458430
459431      default:
460432         logerror("CPU #0 PC %06x: warning - write unmapped hit address %06x [ %06x] = %06x\n",cpu_get_pc(&space->device()),offset<<1, idx, data);
461433   }
462434
463   shogwarr_recalc_collisions();
435   shogwarr_recalc_collisions(hit3);
464436}
465437
466438
467439static READ16_HANDLER(shogwarr_calc_r)
468440{
469
441   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
442   calc3_hit_t &hit3 = state->m_hit3;
470443   int idx=offset*4;
471444
472445   switch (idx)
473446   {
474447      case 0x00: // X distance
475448      case 0x10:
476         return shogwarr_hit.x_coll;
449         return hit3.x_coll;
477450
478451      case 0x04: // Y distance
479452      case 0x14:
480         return shogwarr_hit.y_coll;
453         return hit3.y_coll;
481454
482455      case 0x18: // Z distance
483         return shogwarr_hit.z_coll;
456         return hit3.z_coll;
484457
485458      case 0x08:
486459      case 0x1c:
487460
488         return shogwarr_hit.flags;
461         return hit3.flags;
489462
490463      case 0x28:
491464         return (space->machine().rand() & 0xffff);
492465
493      case 0x40: return shogwarr_hit.x1po;
494      case 0x44: return shogwarr_hit.x1so;
495      case 0x48: return shogwarr_hit.y1po;
496      case 0x4c: return shogwarr_hit.y1so;
497      case 0x50: return shogwarr_hit.z1po;
498      case 0x54: return shogwarr_hit.z1so;
466      case 0x40: return hit3.x1po;
467      case 0x44: return hit3.x1so;
468      case 0x48: return hit3.y1po;
469      case 0x4c: return hit3.y1so;
470      case 0x50: return hit3.z1po;
471      case 0x54: return hit3.z1so;
499472
500      case 0x58: return shogwarr_hit.x2po;
501      case 0x5c: return shogwarr_hit.x2so;
502      case 0x60: return shogwarr_hit.y2po;
503      case 0x64: return shogwarr_hit.y2so;
504      case 0x68: return shogwarr_hit.z2po;
505      case 0x6c: return shogwarr_hit.z2so;
473      case 0x58: return hit3.x2po;
474      case 0x5c: return hit3.x2so;
475      case 0x60: return hit3.y2po;
476      case 0x64: return hit3.y2so;
477      case 0x68: return hit3.z2po;
478      case 0x6c: return hit3.z2so;
506479
507      case 0x80: return shogwarr_hit.x1tox2;
508      case 0x84: return shogwarr_hit.y1toy2;
509      case 0x88: return shogwarr_hit.z1toz2;
480      case 0x80: return hit3.x1tox2;
481      case 0x84: return hit3.y1toy2;
482      case 0x88: return hit3.z1toz2;
510483
511484      default:
512485         logerror("CPU #0 PC %06x: warning - read unmapped calc address %06x [ %06x]\n",cpu_get_pc(&space->device()),offset<<1, idx);
r11160r11161
549522*/
550523
551524
552static int calc3_mcu_status, calc3_mcu_command_offset;
553
554
555void calc3_mcu_init(void)
525void calc3_mcu_init(running_machine &machine)
556526{
557   calc3_mcu_status = 0;
558   calc3_mcu_command_offset = 0;
527   kaneko16_state *state = machine.driver_data<kaneko16_state>();
528   calc3_t &calc3 = state->m_calc3;
529   calc3.mcu_status = 0;
530   calc3.mcu_command_offset = 0;
559531}
560532
561533WRITE16_HANDLER( calc3_mcu_ram_w )
562534{
563   COMBINE_DATA(&kaneko16_mcu_ram[offset]);
564   //calc3_mcu_run(space->machine());
535   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
536   COMBINE_DATA(&state->m_mcu_ram[offset]);
537   //calc3_mcu_run(space->machine);
565538}
566539
567#define CALC3_MCU_COM_W(_n_)            \
568WRITE16_HANDLER( calc3_mcu_com##_n_##_w )   \
569{                                 \
570   logerror("calc3w %d %04x %04x\n",_n_, data,mem_mask); \
571   calc3_mcu_status |= (1 << _n_);         \
540INLINE void calc3_mcu_com_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
541{
542   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
543   calc3_t &calc3 = state->m_calc3;
544   logerror("calc3w %d %04x %04x\n", _n_, data, mem_mask);
545   calc3.mcu_status |= (1 << _n_);
572546}
573547
574CALC3_MCU_COM_W(0)
575CALC3_MCU_COM_W(1)
576CALC3_MCU_COM_W(2)
577CALC3_MCU_COM_W(3)
548WRITE16_HANDLER( calc3_mcu_com0_w) { calc3_mcu_com_w(space, offset, data, mem_mask, 0); }
549WRITE16_HANDLER( calc3_mcu_com1_w) { calc3_mcu_com_w(space, offset, data, mem_mask, 1); }
550WRITE16_HANDLER( calc3_mcu_com2_w) { calc3_mcu_com_w(space, offset, data, mem_mask, 2); }
551WRITE16_HANDLER( calc3_mcu_com3_w) { calc3_mcu_com_w(space, offset, data, mem_mask, 3); }
578552
579553
580554/***************************************************************************
r11160r11161
632606*/
633607
634608
635static UINT16 calc3_mcu_crc;
636609
637610/* decryption tables */
638611
r11160r11161
16721645  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
16731646};
16741647
1675// global so we can use them in the filename when we save out the data (debug..)
1676static UINT8 calc3_decryption_key_byte;
1677static UINT8 calc3_alternateswaps;
1678static UINT8 calc3_shift;
1679static UINT8 calc3_subtracttype;
1680static UINT8 calc3_mode;
1681static UINT8 calc3_blocksize_offset;
1682static UINT16 calc3_dataend;
1683static UINT16 calc3_database;
1684
1685static int data_header[2];
1686
1687static UINT32 calc3_writeaddress;
1688static UINT32 calc3_writeaddress_current;
1689static UINT16 calc3_dsw_addr = 0x00;
1690static UINT16 calc3_eeprom_addr;
1691static UINT16 calc3_poll_addr;
1692static UINT16 cakc3_checkumaddress;
1693
16941648static UINT8 shift_bits(UINT8 dat, int bits)
16951649{
16961650   bits &=0x7;
r11160r11161
17101664// endian safe? you're having a laugh
17111665static int calc3_decompress_table(running_machine& machine, int tabnum, UINT8* dstram, int dstoffset)
17121666{
1713
1714
1715
1716
1667   kaneko16_state *state = machine.driver_data<kaneko16_state>();
1668   calc3_t &calc3 = state->m_calc3;
17171669   address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
17181670   UINT8* rom = machine.region("cpu1")->base();
17191671   UINT8 numregions;
r11160r11161
17451697   {
17461698      UINT16 inline_table_base = 0;
17471699      UINT16 inline_table_size = 0;
1748      calc3_database = offset;
1749      calc3_blocksize_offset =    rom[offset+0]; // location of the 'block length'
1750      calc3_mode =                rom[offset+1];
1751      calc3_alternateswaps =             rom[offset+2];
1752      calc3_shift = (calc3_alternateswaps &0xf0)>>4;
1753      calc3_subtracttype = (calc3_alternateswaps &0x03);
1754      calc3_alternateswaps &= 0x0c;
1755      calc3_alternateswaps >>=2;
1700      calc3.database = offset;
1701      calc3.blocksize_offset =    rom[offset+0]; // location of the 'block length'
1702      calc3.mode =                rom[offset+1];
1703      calc3.alternateswaps =             rom[offset+2];
1704      calc3.shift = (calc3.alternateswaps &0xf0)>>4;
1705      calc3.subtracttype = (calc3.alternateswaps &0x03);
1706      calc3.alternateswaps &= 0x0c;
1707      calc3.alternateswaps >>=2;
17561708
1757      calc3_decryption_key_byte = rom[offset+3];
1709      calc3.decryption_key_byte = rom[offset+3];
17581710
17591711
17601712      // if blocksize_offset > 3, it appears to specify the encryption table as 'inline' which can be of any size (odd or even) and loops over the bytes to decrypt
17611713      // the decryption key specified seems to be ignored?
1762      if (calc3_blocksize_offset>3)
1714      if (calc3.blocksize_offset>3)
17631715      {
17641716         inline_table_base = offset+4;
1765         inline_table_size = calc3_blocksize_offset-3;
1717         inline_table_size = calc3.blocksize_offset-3;
17661718      }
17671719
1768      offset+= calc3_blocksize_offset+1;
1720      offset+= calc3.blocksize_offset+1;
17691721      length = rom[offset+0] | (rom[offset+1]<<8);
17701722      offset+=2;
17711723
17721724#if CALC3_VERBOSE_OUTPUT
17731725      if (inline_table_size)
17741726      {
1775         printf("Block %02x Found Base %04x - Inline Encryption (size %02x) - Mode? %02x Shift %01x Subtract Type %01x AltSwaps %01x Key (unused?) %02x Length %04x\n", tabnum, calc3_database, inline_table_size, calc3_shift, calc3_mode, calc3_subtracttype, calc3_alternateswaps, calc3_decryption_key_byte, length);
1727         printf("Block %02x Found Base %04x - Inline Encryption (size %02x) - Mode? %02x Shift %01x Subtract Type %01x AltSwaps %01x Key (unused?) %02x Length %04x\n", tabnum, calc3.database, inline_table_size, calc3.shift, calc3.mode, calc3.subtracttype, calc3.alternateswaps, calc3.decryption_key_byte, length);
17761728      }
17771729      else
17781730      {
1779         printf("Block %02x Found Base %04x - Mode? %02x Shift %01x Subtract Type %01x AltSwaps %01x Key %02x Length %04x\n", tabnum, calc3_database, calc3_mode, calc3_shift, calc3_subtracttype, calc3_alternateswaps, calc3_decryption_key_byte, length);
1731         printf("Block %02x Found Base %04x - Mode? %02x Shift %01x Subtract Type %01x AltSwaps %01x Key %02x Length %04x\n", tabnum, calc3.database, calc3.mode, calc3.shift, calc3.subtracttype, calc3.alternateswaps, calc3.decryption_key_byte, length);
17801732      }
17811733#endif
17821734      // copy + decrypt the table to the specified memory area
r11160r11161
17991751
18001752            // !dstram is used because we don't want to process these during our initial table scan, only when the game asks!
18011753
1802            if (calc3_mode==0x06)
1754            if (calc3.mode==0x06)
18031755            {
1804               calc3_writeaddress_current = 0x202000; // this is reasoanble for brapboys, not sure about shogun, needs emulating properly!
1805               //calc3_writeaddress_current = 0x20c000;
1756               calc3.writeaddress_current = 0x202000; // this is reasoanble for brapboys, not sure about shogun, needs emulating properly!
1757               //calc3.writeaddress_current = 0x20c000;
18061758            }
1807            else if (calc3_mode==0x07)
1759            else if (calc3.mode==0x07)
18081760            {
18091761               // also calls empty table with Mode? 07
18101762               // maybe they reset to different points?
18111763            }
1812            else if (calc3_mode==0x08 && !dstram)
1764            else if (calc3.mode==0x08 && !dstram)
18131765            {
18141766               //printf("save to eeprom\n");
18151767
r11160r11161
18181770
18191771                  for (i=0;i<0x80;i++)
18201772                  {
1821                     eeprom_space->write_byte(i, space->read_byte(calc3_eeprom_addr+0x200000+i));
1773                     eeprom_space->write_byte(i, space->read_byte(calc3.eeprom_addr+0x200000+i));
18221774                  }
18231775
18241776               }
r11160r11161
18451797
18461798
18471799               /* special case for Shogun Warriors table 0x40 */
1848               if (calc3_subtracttype==3 && calc3_alternateswaps ==0)
1800               if (calc3.subtracttype==3 && calc3.alternateswaps ==0)
18491801               {
18501802                  UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
18511803                  dat = rom[offset+i];
r11160r11161
18661818                        UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
18671819                        dat = rom[offset+i];
18681820                        dat -= inlinet;
1869                        dat = shift_bits(dat, calc3_shift);
1821                        dat = shift_bits(dat, calc3.shift);
18701822                     }
18711823                     else
18721824                     {
r11160r11161
18741826                        UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
18751827                        dat = rom[offset+i];
18761828
1877                        if (calc3_subtracttype!=0x02)
1829                        if (calc3.subtracttype!=0x02)
18781830                        {
18791831                           dat -= inlinet;
18801832                           dat -= extra[(i%inline_table_size)>>1];
r11160r11161
18851837                           dat += extra[(i%inline_table_size)>>1];
18861838                        }
18871839
1888                        dat = shift_bits(dat, 8-calc3_shift);
1840                        dat = shift_bits(dat, 8-calc3.shift);
18891841                     }
18901842                  }
18911843                  else
r11160r11161
18951847                        UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
18961848                        dat = rom[offset+i];
18971849                        dat -= inlinet;
1898                        dat = shift_bits(dat, calc3_shift);
1850                        dat = shift_bits(dat, calc3.shift);
18991851                     }
19001852                     else
19011853                     {
19021854                        dat = rom[offset+i];
19031855
1904                        if (calc3_subtracttype!=0x02)
1856                        if (calc3.subtracttype!=0x02)
19051857                        {
19061858                           dat -= extra2[(i%inline_table_size)>>1];
19071859                        }
r11160r11161
19091861                        {
19101862                           dat += extra2[(i%inline_table_size)>>1];
19111863                        }
1912                        dat = shift_bits(dat, 8-calc3_shift);
1864                        dat = shift_bits(dat, 8-calc3.shift);
19131865                     }
19141866                  }
19151867               }
r11160r11161
19281880                  }
19291881               }
19301882               else
1931                  data_header[local_counter]=dat;
1883                  calc3.data_header[local_counter]=dat;
19321884
19331885               ++local_counter;
19341886            }
19351887         }
19361888         else
19371889         {
1938            const INT16* key = calc3_keydata+(calc3_decryption_key_byte*0x40);
1890            const INT16* key = calc3_keydata+(calc3.decryption_key_byte*0x40);
19391891
19401892            if (key[0] == -1)
19411893            {
r11160r11161
19481900               UINT8 keydat = (UINT8)key[i&0x3f];
19491901
19501902               {
1951                  if (calc3_subtracttype==0)
1903                  if (calc3.subtracttype==0)
19521904                  {
19531905                     //dat = dat;
19541906                  }
1955                  else if (calc3_subtracttype==1)
1907                  else if (calc3.subtracttype==1)
19561908                  {
19571909                     if ((i&1)==1) dat += keydat;
19581910                     else dat -= keydat;
19591911                  }
1960                  else if (calc3_subtracttype==2)
1912                  else if (calc3.subtracttype==2)
19611913                  {
19621914                     if ((i&1)==0) dat += keydat;
19631915                     else dat -= keydat;
19641916                  }
1965                  else if (calc3_subtracttype==3)
1917                  else if (calc3.subtracttype==3)
19661918                  {
19671919                     dat -= keydat;
19681920                  }
19691921
1970                  if (calc3_alternateswaps == 0)
1922                  if (calc3.alternateswaps == 0)
19711923                  {
1972                     if ((i&1)==0) dat = shift_bits(dat, 8-calc3_shift);
1973                     else          dat = shift_bits(dat, calc3_shift);
1924                     if ((i&1)==0) dat = shift_bits(dat, 8-calc3.shift);
1925                     else          dat = shift_bits(dat, calc3.shift);
19741926                  }
1975                  else if (calc3_alternateswaps==1)
1927                  else if (calc3.alternateswaps==1)
19761928                  {
1977                     dat = shift_bits(dat, 8-calc3_shift);
1929                     dat = shift_bits(dat, 8-calc3.shift);
19781930                  }
1979                  else if (calc3_alternateswaps==2)
1931                  else if (calc3.alternateswaps==2)
19801932                  {
1981                     dat = shift_bits(dat, calc3_shift);
1933                     dat = shift_bits(dat, calc3.shift);
19821934                  }
1983                  else if (calc3_alternateswaps==3)
1935                  else if (calc3.alternateswaps==3)
19841936                  {
19851937                     // same as 0
1986                     if ((i&1)==0) dat = shift_bits(dat, 8-calc3_shift);
1987                     else          dat = shift_bits(dat, calc3_shift);
1938                     if ((i&1)==0) dat = shift_bits(dat, 8-calc3.shift);
1939                     else          dat = shift_bits(dat, calc3.shift);
19881940                  }
19891941               }
19901942
r11160r11161
20021954                  }
20031955               }
20041956               else
2005                  data_header[local_counter]=dat;
1957                  calc3.data_header[local_counter]=dat;
20061958
20071959               ++local_counter;
20081960
r11160r11161
20111963         }
20121964      }
20131965
2014      calc3_dataend = offset+length+1;
1966      calc3.dataend = offset+length+1;
20151967   }
20161968
2017   //printf("data base %04x data end %04x\n", calc3_database, calc3_dataend);
1969   //printf("data base %04x data end %04x\n", calc3.database, calc3.dataend);
20181970
20191971   return length;
20201972
r11160r11161
20241976
20251977DRIVER_INIT(calc3_scantables)
20261978{
1979   kaneko16_state *state = machine.driver_data<kaneko16_state>();
1980   calc3_t &calc3 = state->m_calc3;
20271981   UINT8* rom = machine.region("cpu1")->base();
20281982   UINT8 numregions;
20291983
20301984   int x;
20311985
2032   calc3_mcu_crc = 0;
1986   calc3.mcu_crc = 0;
20331987   for (x=0;x<0x20000;x++)
20341988   {
2035      calc3_mcu_crc+=rom[x];
1989      calc3.mcu_crc+=rom[x];
20361990   }
2037   //printf("crc %04x\n",calc3_mcu_crc);
1991   //printf("crc %04x\n",calc3.mcu_crc);
20381992   numregions = rom[0];
20391993
20401994   for (x=0;x<numregions;x++)
r11160r11161
20542008         FILE *fp;
20552009         char filename[256];
20562010
2057         if (calc3_blocksize_offset==3)
2011         if (calc3.blocksize_offset==3)
20582012         {
20592013            sprintf(filename,"data_%s_table_%04x k%02x m%02x u%02x length %04x",
2060                  machine.system().name,
2061                  x, calc3_decryption_key_byte, calc3_mode, calc3_alternateswaps, length);
2014                  machine().system().name,
2015                  x, calc3.decryption_key_byte, calc3.mode, calc3.alternateswaps, length);
20622016         }
20632017         else
20642018         {
20652019            sprintf(filename,"data_%s_table_%04x k%02x (use indirect size %02x) m%02x u%02x length %04x",
2066               machine.system().name,
2067               x, calc3_decryption_key_byte, calc3_blocksize_offset-3, calc3_mode, calc3_alternateswaps, length);
2020               machine().system().name,
2021               x, calc3.decryption_key_byte, calc3.blocksize_offset-3, calc3.mode, calc3.alternateswaps, length);
20682022         }
20692023
20702024         fp=fopen(filename, "w+b");
r11160r11161
20942048      fp=fopen(filename, "w+b");
20952049      if (fp)
20962050      {
2097         fwrite(&rom[calc3_dataend], 0x1000, 1, fp);
2051         fwrite(&rom[calc3.dataend], 0x1000, 1, fp);
20982052         fclose(fp);
20992053      }
21002054   }
r11160r11161
21052059
21062060void calc3_mcu_run(running_machine &machine)
21072061{
2062   kaneko16_state *state = machine.driver_data<kaneko16_state>();
2063   calc3_t &calc3 = state->m_calc3;
21082064   UINT16 mcu_command;
21092065   int i;
21102066   address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
21112067
2112   if ( calc3_mcu_status != (1|2|4|8) )   return;
2068   if ( calc3.mcu_status != (1|2|4|8) )   return;
21132069
2114   if (calc3_dsw_addr) space->write_byte(calc3_dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame
2070   if (calc3.dsw_addr) space->write_byte(calc3.dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame
21152071
21162072
2117   //calc3_mcu_status = 0;
2073   //calc3.mcu_status = 0;
21182074
2119   mcu_command = kaneko16_mcu_ram[calc3_mcu_command_offset/2 + 0];
2075   mcu_command = state->m_mcu_ram[calc3.mcu_command_offset/2 + 0];
21202076
21212077   if (mcu_command == 0) return;
21222078
21232079   logerror("%s : MCU executed command at %04X: %04X\n",
2124      machine.describe_context(),calc3_mcu_command_offset,mcu_command);
2080      machine.describe_context(),calc3.mcu_command_offset,mcu_command);
21252081
21262082
21272083   if (mcu_command>0)
r11160r11161
21312087      {
21322088
21332089         // clear old command (handshake to main cpu)
2134         kaneko16_mcu_ram[(calc3_mcu_command_offset>>1)+0] = 0x0000;
2090         state->m_mcu_ram[(calc3.mcu_command_offset>>1)+0] = 0x0000;
21352091
21362092
2137         calc3_dsw_addr =           kaneko16_mcu_ram[(0>>1) + 1];
2138         calc3_eeprom_addr =        kaneko16_mcu_ram[(0>>1) + 2];
2139         calc3_mcu_command_offset = kaneko16_mcu_ram[(0>>1) + 3];
2140         calc3_poll_addr =          kaneko16_mcu_ram[(0>>1) + 4];
2141         cakc3_checkumaddress =     kaneko16_mcu_ram[(0>>1) + 5];
2142         calc3_writeaddress =      (kaneko16_mcu_ram[(0>>1) + 6] << 16) |
2143                                   (kaneko16_mcu_ram[(0>>1) + 7]);
2093         calc3.dsw_addr =           state->m_mcu_ram[(0>>1) + 1];
2094         calc3.eeprom_addr =        state->m_mcu_ram[(0>>1) + 2];
2095         calc3.mcu_command_offset = state->m_mcu_ram[(0>>1) + 3];
2096         calc3.poll_addr =          state->m_mcu_ram[(0>>1) + 4];
2097         calc3.checksumaddress =    state->m_mcu_ram[(0>>1) + 5];
2098         calc3.writeaddress =      (state->m_mcu_ram[(0>>1) + 6] << 16) |
2099                                   (state->m_mcu_ram[(0>>1) + 7]);
21442100
21452101         // set our current write / stack pointer to the address specified
2146         calc3_writeaddress_current = calc3_writeaddress;
2102         calc3.writeaddress_current = calc3.writeaddress;
21472103#if CALC3_VERBOSE_OUTPUT
2148         printf("Calc 3 Init Command - %04x DSW addr\n",  calc3_dsw_addr);
2149         printf("Calc 3 Init Command - %04x Eeprom Address\n",  calc3_eeprom_addr);
2150         printf("Calc 3 Init Command - %04x Future Commands Base\n",  calc3_mcu_command_offset);
2151         printf("Calc 3 Init Command - %04x Poll / Busy Address\n",  calc3_poll_addr);
2152         printf("Calc 3 Init Command - %04x ROM Checksum Address\n",  cakc3_checkumaddress);
2153         printf("Calc 3 Init Command - %08x Data Write Address\n",  calc3_writeaddress);
2104         printf("Calc 3 Init Command - %04x DSW addr\n",  calc3.dsw_addr);
2105         printf("Calc 3 Init Command - %04x Eeprom Address\n",  calc3.eeprom_addr);
2106         printf("Calc 3 Init Command - %04x Future Commands Base\n",  calc3.mcu_command_offset);
2107         printf("Calc 3 Init Command - %04x Poll / Busy Address\n",  calc3.poll_addr);
2108         printf("Calc 3 Init Command - %04x ROM Checksum Address\n",  calc3.checksumaddress);
2109         printf("Calc 3 Init Command - %08x Data Write Address\n",  calc3.writeaddress);
21542110#endif
2155   //      space->write_byte(calc3_dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame
2111   //      space->write_byte(calc3.dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame
21562112
2157         kaneko16_mcu_ram[cakc3_checkumaddress / 2] = calc3_mcu_crc;            // MCU Rom Checksum!
2113         state->m_mcu_ram[calc3.checksumaddress / 2] = calc3.mcu_crc;            // MCU Rom Checksum!
21582114
2159         /*
2160            for (i=0;i<0x40;i++)
2161            {
2162                kaneko16_mcu_ram[(calc3_eeprom_addr / 2)+i] = kaneko16_eeprom_data[i];//((eepromData[i]&0xff00)>>8) |  ((eepromData[i]&0x00ff)<<8);
2163            }
2164            */
2165
2115#if 0
2116         for (i=0;i<0x40;i++)
21662117         {
2118            state->m_mcu_ram[(calc3.eeprom_addr / 2)+i] = kaneko16_eeprom_data[i];//((eepromData[i]&0xff00)>>8) |  ((eepromData[i]&0x00ff)<<8);
2119         }
2120#endif
2121         {
21672122            address_space *eeprom_space = space->machine().device<eeprom_device>("eeprom")->space();
21682123
21692124            for (i=0;i<0x80;i++)
21702125            {
2171               space->write_byte(calc3_eeprom_addr+0x200000+i, eeprom_space->read_byte(i));
2126               space->write_byte(calc3.eeprom_addr+0x200000+i, eeprom_space->read_byte(i));
21722127            }
21732128
21742129         }
r11160r11161
21812136         int i;
21822137
21832138         // clear old command (handshake to main cpu)
2184         kaneko16_mcu_ram[calc3_mcu_command_offset>>1] = 0x0000;;
2139         state->m_mcu_ram[calc3.mcu_command_offset>>1] = 0x0000;;
21852140
21862141         logerror("Calc3 transfer request, %d transfers\n", num_transfers);
21872142
21882143         for (i=0;i<num_transfers;i++)
21892144         {
2190            int param1 = kaneko16_mcu_ram[(calc3_mcu_command_offset>>1) + 1 + (2*i)];
2191            int param2 = kaneko16_mcu_ram[(calc3_mcu_command_offset>>1) + 2 + (2*i)];
2145            int param1 = state->m_mcu_ram[(calc3.mcu_command_offset>>1) + 1 + (2*i)];
2146            int param2 = state->m_mcu_ram[(calc3.mcu_command_offset>>1) + 2 + (2*i)];
21922147            UINT8  commandtabl = (param1&0xff00) >> 8;
21932148            UINT16 commandaddr =param2;// (param1&0x00ff) | (param2&0xff00);
21942149            UINT8  commandunk =  (param1&0x00ff); // brap boys sets.. seems to cause further writebasck address displacement?? (when tested on hw it looked like a simple +, but that doesn't work for brapboys...)
r11160r11161
21982153            {
21992154               int length;
22002155
2201               length = calc3_decompress_table(machine, commandtabl, 0, calc3_writeaddress_current-2);
2156               length = calc3_decompress_table(machine, commandtabl, 0, calc3.writeaddress_current-2);
22022157
22032158               if (length)
22042159               {
22052160                  int write=commandaddr;
22062161#if CALC3_VERBOSE_OUTPUT
2207                  printf("writing back address %08x to %08x %08x\n", calc3_writeaddress_current, commandaddr,write);
2162                  printf("writing back address %08x to %08x %08x\n", calc3.writeaddress_current, commandaddr,write);
22082163#endif
22092164
2210                  space->write_byte(write+0x200000, data_header[0]);
2211                  space->write_byte(write+0x200001, data_header[1]);
2165                  space->write_byte(write+0x200000, calc3.data_header[0]);
2166                  space->write_byte(write+0x200001, calc3.data_header[1]);
22122167
22132168                  write=commandaddr+(char)commandunk;
2214                  space->write_word(write+0x200000, (calc3_writeaddress_current>>16)&0xffff);
2215                  space->write_word(write+0x200002,  (calc3_writeaddress_current&0xffff));
2169                  space->write_word(write+0x200000, (calc3.writeaddress_current>>16)&0xffff);
2170                  space->write_word(write+0x200002,  (calc3.writeaddress_current&0xffff));
22162171
2217                  calc3_writeaddress_current += ((length+3)&(~1));
2172                  calc3.writeaddress_current += ((length+3)&(~1));
22182173               }
22192174
22202175            }
r11160r11161
23962351}
23972352
23982353
2399void (*toybox_mcu_run)(running_machine &machine);
2400
2401static UINT16 toybox_mcu_com[4];
2402
2403void toybox_mcu_init(void)
2354void toybox_mcu_init(running_machine &machine)
24042355{
2405   memset(toybox_mcu_com, 0, 4 * sizeof( UINT16) );
2356   kaneko16_state *state = machine.driver_data<kaneko16_state>();
2357   memset(state->m_toybox_mcu_com, 0, 4 * sizeof( UINT16) );
24062358}
24072359
2408#define TOYBOX_MCU_COM_W(_n_)                     \
2409WRITE16_HANDLER( toybox_mcu_com##_n_##_w )            \
2410{                                          \
2411   COMBINE_DATA(&toybox_mcu_com[_n_]);               \
2412   if (toybox_mcu_com[0] != 0xFFFF)   return;         \
2413   if (toybox_mcu_com[1] != 0xFFFF)   return;         \
2414   if (toybox_mcu_com[2] != 0xFFFF)   return;         \
2415   if (toybox_mcu_com[3] != 0xFFFF)   return;         \
2416                                          \
2417   memset(toybox_mcu_com, 0, 4 * sizeof( UINT16 ) );   \
2418   toybox_mcu_run(space->machine());                     \
2360INLINE void toybox_mcu_com_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
2361{
2362   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
2363   COMBINE_DATA(&state->m_toybox_mcu_com[_n_]);
2364   if (state->m_toybox_mcu_com[0] != 0xFFFF)   return;
2365   if (state->m_toybox_mcu_com[1] != 0xFFFF)   return;
2366   if (state->m_toybox_mcu_com[2] != 0xFFFF)   return;
2367   if (state->m_toybox_mcu_com[3] != 0xFFFF)   return;
2368
2369   memset(state->m_toybox_mcu_com, 0, 4 * sizeof( UINT16 ) );
2370   (*state->m_toybox_mcu_run)(space->machine());
24192371}
24202372
2421TOYBOX_MCU_COM_W(0)
2422TOYBOX_MCU_COM_W(1)
2423TOYBOX_MCU_COM_W(2)
2424TOYBOX_MCU_COM_W(3)
2373WRITE16_HANDLER( toybox_mcu_com0_w ) { toybox_mcu_com_w(space, offset, data, mem_mask, 0); }
2374WRITE16_HANDLER( toybox_mcu_com1_w ) { toybox_mcu_com_w(space, offset, data, mem_mask, 1); }
2375WRITE16_HANDLER( toybox_mcu_com2_w ) { toybox_mcu_com_w(space, offset, data, mem_mask, 2); }
2376WRITE16_HANDLER( toybox_mcu_com3_w ) { toybox_mcu_com_w(space, offset, data, mem_mask, 3); }
24252377
24262378/*
24272379    bonkadv and bloodwar test bit 0
r11160r11161
24392391
24402392void bloodwar_mcu_run(running_machine &machine)
24412393{
2394   kaneko16_state *state = machine.driver_data<kaneko16_state>();
2395   UINT16 *kaneko16_mcu_ram = state->m_mcu_ram;
24422396   UINT16 mcu_command   =   kaneko16_mcu_ram[0x0010/2];
24432397   UINT16 mcu_offset   =   kaneko16_mcu_ram[0x0012/2] / 2;
24442398   UINT16 mcu_data      =   kaneko16_mcu_ram[0x0014/2];
r11160r11161
24472401   {
24482402      case 0x02:   // Read from NVRAM
24492403      {
2450         memcpy(&kaneko16_mcu_ram[mcu_offset], kaneko16_nvram_save, sizeof(kaneko16_nvram_save));
2404         memcpy(&kaneko16_mcu_ram[mcu_offset], state->m_nvram_save, sizeof(state->m_nvram_save));
24512405         logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
24522406      }
24532407      break;
24542408
24552409      case 0x42:   // Write to NVRAM
24562410      {
2457         memcpy(kaneko16_nvram_save, &kaneko16_mcu_ram[mcu_offset], sizeof(kaneko16_nvram_save));
2411         memcpy(state->m_nvram_save, &kaneko16_mcu_ram[mcu_offset], sizeof(state->m_nvram_save));
24582412         logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
24592413      }
24602414      break;
r11160r11161
24872441
24882442void bonkadv_mcu_run(running_machine &machine)
24892443{
2444   kaneko16_state *state = machine.driver_data<kaneko16_state>();
2445   UINT16 *kaneko16_mcu_ram = state->m_mcu_ram;
24902446   UINT16 mcu_command   =   kaneko16_mcu_ram[0x0010/2];
24912447   UINT16 mcu_offset   =   kaneko16_mcu_ram[0x0012/2] / 2;
24922448   UINT16 mcu_data      =   kaneko16_mcu_ram[0x0014/2];
r11160r11161
24962452
24972453      case 0x02:   // Read from NVRAM
24982454      {
2499         memcpy(&kaneko16_mcu_ram[mcu_offset], kaneko16_nvram_save, sizeof(kaneko16_nvram_save));
2455         memcpy(&kaneko16_mcu_ram[mcu_offset], state->m_nvram_save, sizeof(state->m_nvram_save));
25002456         logerror("%s : MCU executed command: %04X %04X (load NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
25012457      }
25022458      break;
25032459
25042460      case 0x42:   // Write to NVRAM
25052461      {
2506         memcpy(kaneko16_nvram_save, &kaneko16_mcu_ram[mcu_offset], sizeof(kaneko16_nvram_save));
2462         memcpy(state->m_nvram_save, &kaneko16_mcu_ram[mcu_offset], sizeof(state->m_nvram_save));
25072463         logerror("%s : MCU executed command: %04X %04X (save NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
25082464      }
25092465      break;
25102466
25112467      case 0x43:   // Initialize NVRAM - MCU writes Default Data Set directly to NVRAM
25122468      {
2513         memcpy(kaneko16_nvram_save, bonkadv_mcu_43, sizeof(bonkadv_mcu_43));
2469         memcpy(state->m_nvram_save, bonkadv_mcu_43, sizeof(bonkadv_mcu_43));
25142470         logerror("%s : MCU executed command: %04X %04X (restore default NVRAM settings)\n", machine.describe_context(), mcu_command, mcu_offset*2);
25152471      }
25162472      break;
r11160r11161
25652521
25662522void gtmr_mcu_run(running_machine &machine)
25672523{
2524   kaneko16_state *state = machine.driver_data<kaneko16_state>();
2525   UINT16 *kaneko16_mcu_ram = state->m_mcu_ram;
25682526   UINT16 mcu_command   =   kaneko16_mcu_ram[0x0010/2];
25692527   UINT16 mcu_offset   =   kaneko16_mcu_ram[0x0012/2] / 2;
25702528   UINT16 mcu_data      =   kaneko16_mcu_ram[0x0014/2];
r11160r11161
25762534
25772535      case 0x02:   // Read from NVRAM
25782536      {
2579         memcpy(&kaneko16_mcu_ram[mcu_offset], kaneko16_nvram_save, sizeof(kaneko16_nvram_save));
2537         memcpy(&kaneko16_mcu_ram[mcu_offset], state->m_nvram_save, sizeof(state->m_nvram_save));
25802538      }
25812539      break;
25822540
25832541      case 0x42:   // Write to NVRAM
25842542      {
2585         memcpy(kaneko16_nvram_save, &kaneko16_mcu_ram[mcu_offset], sizeof(kaneko16_nvram_save));
2543         memcpy(state->m_nvram_save, &kaneko16_mcu_ram[mcu_offset], sizeof(state->m_nvram_save));
25862544      }
25872545      break;
25882546
src/mame/mamedriv.c
r11160r11161
12511251   DRIVER( supergm3 )  /* 1996 */
12521252   DRIVER( cham24 )   /* 2002 */
12531253
1254        /* Famicom Box */
1255   DRIVER( famibox )   /* 1986 */
1256
12541257   /* Nintendo Super System Games */
12551258   DRIVER( nss )
12561259   DRIVER( nss_ssoc )   /* 1992 Human Inc. */
r11160r11161
12731276   //pss63 - Super Donkey Kong / Super Tetris 2 + Bombliss
12741277   //pss64 - Super Donkey Kong / Super Bomberman 2
12751278
1276
1277
12781279   /* SNES-based hacks */
12791280   DRIVER( kinstb )   /* bootleg */
12801281   DRIVER( ffight2b )   /* bootleg */
r11160r11161
31543155   DRIVER( warzarda )   /* 23/10/1996 (c) 1996 (Japan) */
31553156   DRIVER( sfiii )   /* 04/02/1997 (c) 1997 (USA) */
31563157   DRIVER( sfiiij )   /* 04/02/1997 (c) 1997 (Japan) */
3158   DRIVER( sfiiih )   /* 04/02/1997 (c) 1997 (Hispanic) */
31573159   DRIVER( sfiii2 )   /* 30/09/1997 (c) 1997 (USA) */
31583160   DRIVER( sfiii2j )   /* 30/09/1997 (c) 1997 (Japan) */
31593161   DRIVER( jojo )   /* 08/01/1999 (c) 1998 (USA) */
r11160r11161
32113213   DRIVER( strider2a )   /* Strider 2 (ASIA 991213) */
32123214   DRIVER( shiryu2 )   /* Strider Hiryu 2 (JAPAN 991213) */
32133215
3216   DRIVER( alien )      /* (c) 2005 */
3217   /* Alien Danger */
3218
32143219   /* Tecmo ZN1 */
32153220   DRIVER( tps )
32163221   DRIVER( glpracr2 )   /* Gallop Racer 2 (USA) */
r11160r11161
59495954   DRIVER( sscope )   /* GX830 (c)1999 */
59505955   DRIVER( sscopea )   /* GX830 (c)1999 */
59515956   DRIVER( sscopeb )   /* GX830 (c)1999 */
5957   DRIVER( sscopec )   /* GX830 (c)1999 */
59525958   DRIVER( sscope2 )   /* GX931 (c)2000 */
59535959   DRIVER( racingj )   /* GX676 (c)1998 */
5954   DRIVER( racingj2 )   /* GX888 (c)1999 */
5960   DRIVER( racingj2 )   /* GX888 (c)1999 (EAE) */
5961   DRIVER( racingj2j )   /* GX888 (c)1999 (JAE) */
59555962   DRIVER( thrilld )   /* GX713 (c)1998 Japan JAE */
59565963   DRIVER( thrilldb )   /* GX713 (c)1998 Japan JAB */
5964    DRIVER( thrilldae ) /* GX713 (c)1998 Europe EAA */
59575965   DRIVER( midnrun )   /* GX476 (c)1995 */
59585966   DRIVER( windheat )   /* GX677 (c)1996 */
59595967   DRIVER( windheatu )   /* GX677 (c)1996 */
r11160r11161
73287336   DRIVER( galgbios )   /* (c) 1998 Creative Electronics & Software (CES) */
73297337   DRIVER( galgame2 )   /* (c) 1998 Creative Electronics & Software (CES) / Namco */
73307338
7339   /* Creative Electronics & Software */
7340   DRIVER( hrclass )
7341   DRIVER( ccclass )
7342   DRIVER( tsclass )
7343
73317344   /* Cinematronics raster games */
73327345   DRIVER( embargo )
73337346   DRIVER( tripool )   /* (c) 1981 Noma (Casino Tech license) */
r11160r11161
93699382   DRIVER( othello )   /* (c) 1984 Success */
93709383   DRIVER( sothello )   /* (c) 1986 Success / Fujiwara */
93719384   DRIVER( quake )      /* (c) 19?? Lazer-Tron / iD Software  */
9385   DRIVER( majorpkr )   /* (c) 1994 PAL System. */
93729386
93739387   /* Multi Amenity Cassette System */
93749388   DRIVER( macsbios )
r11160r11161
95419555   DRIVER( soccernw )   /* 199? bootleg */
95429556   DRIVER( saloon )   /* 199? unknown */
95439557   DRIVER( funquiz )   /* (c) 198? Funworld */
9558   DRIVER( witchryl )   /* (c) 199? Video Klein */
95449559   DRIVER( photoply )
95459560
95469561   /* Sandii' */
r11160r11161
96259640   DRIVER( victor6 )   /* (c) 1995 Subsino (Alpha license) */
96269641   DRIVER( victor6a )   /* (c) 1995 Subsino (Alpha license) */
96279642   DRIVER( victor6b )   /* (c) 1995 Subsino (Alpha license) */
9643   DRIVER( mtrain )   /* (c) 1996 Subsino */
9644   DRIVER( mtrainnv )   /* (c) 1996 Subsino */
96289645   DRIVER( sharkpy )   /* (c) 1996 Subsino */
96299646   DRIVER( sharkpya )   /* (c) 1996 Subsino */
96309647   DRIVER( sharkpye )   /* (c) 1996 Subsino (Alpha license) */
96319648   DRIVER( smoto20 )   /* (c) 1996 Subsino */
96329649   DRIVER( smoto16 )   /* (c) 1996 Subsino */
9633   DRIVER( mtrain )   /* (c) 1996 Subsino */
9634   DRIVER( mtrainnv )   /* (c) 1996 Subsino */
9650   DRIVER( wtrnymph )   /* (c) 1996 Subsino */
96359651   DRIVER( expcard )   /* (c) 1998 American Alpha */
96369652   DRIVER( saklove )   /* (c) 1998 Subsino */
96379653   DRIVER( bishjan )   /* (c) 1999 Subsino */
src/mame/includes/galpani2.h
r11160r11161
1class galpani2_state : public driver_device
1#include "includes/kaneko16.h"
2
3class galpani2_state : public kaneko16_state
24{
35public:
46   galpani2_state(running_machine &machine, const driver_device_config_base &config)
5      : driver_device(machine, config) { }
7      : kaneko16_state(machine, config) { }
68
7   UINT16 *m_bg8_0;
8   UINT16 *m_bg8_1;
9   UINT16 *m_palette_0;
10   UINT16 *m_palette_1;
11   UINT16 *m_bg8_0_scrollx;
12   UINT16 *m_bg8_1_scrollx;
13   UINT16 *m_bg8_0_scrolly;
14   UINT16 *m_bg8_1_scrolly;
9   UINT16 *m_bg8[2];
10   UINT16 *m_palette[2];
11   UINT16 *m_bg8_scrollx[2];
12   UINT16 *m_bg8_scrolly[2];
1513   UINT16 *m_bg15;
1614   UINT16 m_eeprom_word;
1715   UINT16 *m_ram;
r11160r11161
1917   UINT16 m_old_mcu_nmi1;
2018   UINT16 m_old_mcu_nmi2;
2119   UINT16 *m_rombank;
22   bitmap_t *m_bg8_bitmap_0;
23   bitmap_t *m_bg8_bitmap_1;
20   bitmap_t *m_bg8_bitmap[2];
2421   bitmap_t *m_bg15_bitmap;
2522};
2623
src/mame/includes/suprnova.h
r11160r11161
1/*----------- defined in drivers/suprnova.c -----------*/
1typedef struct
2{
3   UINT16 x1p, y1p, z1p, x1s, y1s, z1s;
4   UINT16 x2p, y2p, z2p, x2s, y2s, z2s;
5   UINT16 org;
26
7   UINT16 x1_p1, x1_p2, y1_p1, y1_p2, z1_p1, z1_p2;
8   UINT16 x2_p1, x2_p2, y2_p1, y2_p2, z2_p1, z2_p2;
9   UINT16 x1tox2, y1toy2, z1toz2;
10   INT16 x_in, y_in, z_in;
11   UINT16 flag;
12
13   UINT8 disconnect;
14} hit_t;
15
16
317class skns_state : public driver_device
418{
519public:
r11160r11161
721      : driver_device(machine, config) { }
822
923   sknsspr_device* m_spritegen;
24   UINT32 *m_tilemapA_ram;
25   UINT32 *m_tilemapB_ram;
26   UINT32 *m_v3slc_ram;
27   UINT32 *m_palette_ram;
28   UINT32 *m_pal_regs;
29   UINT32 *m_v3_regs;
30   UINT32 *m_spc_regs;
31   UINT32 *m_v3t_ram;
32   UINT32 *m_main_ram;
33   UINT32 *m_cache_ram;
34   hit_t m_hit;
35   UINT32 m_timer_0_temp[4];
36   bitmap_t *m_sprite_bitmap;
37   bitmap_t *m_tilemap_bitmap_lower;
38   bitmap_t *m_tilemap_bitmapflags_lower;
39   bitmap_t *m_tilemap_bitmap_higher;
40   bitmap_t *m_tilemap_bitmapflags_higher;
41   int m_depthA;
42   int m_depthB;
43   int m_use_spc_bright;
44   int m_use_v3_bright;
45   UINT8 m_bright_spc_b;
46   UINT8 m_bright_spc_g;
47   UINT8 m_bright_spc_r;
48   UINT8 m_bright_spc_b_trans;
49   UINT8 m_bright_spc_g_trans;
50   UINT8 m_bright_spc_r_trans;
51   UINT8 m_bright_v3_b;
52   UINT8 m_bright_v3_g;
53   UINT8 m_bright_v3_r;
54   UINT8 m_bright_v3_b_trans;
55   UINT8 m_bright_v3_g_trans;
56   UINT8 m_bright_v3_r_trans;
57   int m_spc_changed;
58   int m_v3_changed;
59   int m_palette_updated;
60   int m_alt_enable_background;
61   int m_alt_enable_sprites;
62   tilemap_t *m_tilemap_A;
63   tilemap_t *m_tilemap_B;
1064};
1165
12extern UINT32 *skns_tilemapA_ram, *skns_tilemapB_ram, *skns_v3slc_ram;
13extern UINT32 *skns_palette_ram;
14extern UINT32 *skns_pal_regs, *skns_v3_regs, *skns_spc_regs;
1566
1667/*----------- defined in video/suprnova.c -----------*/
1768
src/mame/includes/vertigo.h
r11160r11161
8585
8686   UINT16 *m_vectorram;
8787   device_t *m_ttl74148;
88   device_t *m_custom;
8889   attotime m_irq4_time;
8990   UINT8 m_irq_state;
9091   UINT8 m_adc_result;
src/mame/includes/fastfred.h
r11160r11161
55
66***************************************************************************/
77
8class fastfred_state : public driver_device
8#include "includes/galaxold.h"
9
10class fastfred_state : public galaxold_state
911{
1012public:
1113   fastfred_state(running_machine &machine, const driver_device_config_base &config)
12      : driver_device(machine, config) { }
14      : galaxold_state(machine, config) { }
1315
1416   UINT8 m_imago_sprites[0x800*3];
1517   UINT16 m_imago_sprites_address;
src/mame/includes/galpanic.h
r11160r11161
1class galpanic_state : public driver_device
1#include "includes/kaneko16.h"
2
3class galpanic_state : public kaneko16_state
24{
35public:
46   galpanic_state(running_machine &machine, const driver_device_config_base &config)
5      : driver_device(machine, config) { }
7      : kaneko16_state(machine, config) { }
68
79   UINT16 *m_bgvideoram;
810   UINT16 *m_fgvideoram;
src/mame/includes/kaneko16.h
r11160r11161
44
55***************************************************************************/
66
7#ifndef __KANEKO16_H__
8#define __KANEKO16_H__
9
710#include "machine/nvram.h"
811
12typedef struct
13{
14   int VIEW2_2_pri;
15   int sprite[4];
16} kaneko16_priority_t;
17
18
19typedef struct
20{
21   UINT16 x1p, y1p, x1s, y1s;
22   UINT16 x2p, y2p, x2s, y2s;
23
24   INT16 x12, y12, x21, y21;
25
26   UINT16 mult_a, mult_b;
27} calc1_hit_t;
28
29typedef struct
30{
31   int x1p, y1p, z1p, x1s, y1s, z1s;
32   int x2p, y2p, z2p, x2s, y2s, z2s;
33
34   int x1po, y1po, z1po, x1so, y1so, z1so;
35   int x2po, y2po, z2po, x2so, y2so, z2so;
36
37   int x12, y12, z12, x21, y21, z21;
38
39   int x_coll, y_coll, z_coll;
40
41   int x1tox2, y1toy2, z1toz2;
42
43   UINT16 mult_a, mult_b;
44
45   UINT16 flags;
46   UINT16 mode;
47} calc3_hit_t;
48
49typedef struct
50{
51   int mcu_status;
52   int mcu_command_offset;
53   UINT16 mcu_crc;
54   UINT8 decryption_key_byte;
55   UINT8 alternateswaps;
56   UINT8 shift;
57   UINT8 subtracttype;
58   UINT8 mode;
59   UINT8 blocksize_offset;
60   UINT16 dataend;
61   UINT16 database;
62   int data_header[2];
63   UINT32 writeaddress;
64   UINT32 writeaddress_current;
65   UINT16 dsw_addr;
66   UINT16 eeprom_addr;
67   UINT16 poll_addr;
68   UINT16 checksumaddress;
69} calc3_t;
70
71class kaneko16_state : public driver_device
72{
73public:
74   kaneko16_state(running_machine &machine, const driver_device_config_base &config)
75      : driver_device(machine, config) { }
76
77   UINT16 *m_mcu_ram;
78   UINT8 m_nvram_save[128];
79   UINT16 *m_vram[4];
80   UINT16 *m_layers_0_regs;
81   UINT16 *m_layers_1_regs;
82   UINT16 *m_vscroll[4];
83   int m_sprite_type;
84   int m_sprite_fliptype;
85   UINT16 m_sprite_xoffs;
86   UINT16 m_sprite_flipx;
87   UINT16 m_sprite_yoffs;
88   UINT16 m_sprite_flipy;
89   UINT16 *m_sprites_regs;
90   UINT16 *m_bg15_select;
91   UINT16 *m_bg15_reg;
92   struct tempsprite *m_first_sprite;
93   kaneko16_priority_t m_priority;
94   UINT16* m_galsnew_bg_pixram;
95   UINT16* m_galsnew_fg_pixram;
96   UINT16* m_mainram;
97   calc1_hit_t m_hit;
98   calc3_hit_t m_hit3;
99   calc3_t m_calc3;
100   void (*m_toybox_mcu_run)(running_machine &machine);
101   UINT16 m_toybox_mcu_com[4];
102   UINT16 m_disp_enable;
103   tilemap_t *m_tmap[4];
104   int m_keep_sprites;
105   bitmap_t *m_bg15_bitmap;
106   bitmap_t *m_sprites_bitmap;
107};
108
109
9110/*----------- defined in machine/kaneko16.c -----------*/
10111
11extern UINT16 *kaneko16_mcu_ram; /* for calc3 and toybox */
12extern UINT8 kaneko16_nvram_save[128];
13
14112READ16_HANDLER( galpanib_calc_r );
15113WRITE16_HANDLER( galpanib_calc_w );
16114
17115READ16_HANDLER( bloodwar_calc_r );
18116WRITE16_HANDLER( bloodwar_calc_w );
19117
20void calc3_mcu_init(void);
118void calc3_mcu_init(running_machine &machine);
21119WRITE16_HANDLER( calc3_mcu_ram_w );
22120WRITE16_HANDLER( calc3_mcu_com0_w );
23121WRITE16_HANDLER( calc3_mcu_com1_w );
24122WRITE16_HANDLER( calc3_mcu_com2_w );
25123WRITE16_HANDLER( calc3_mcu_com3_w );
26124
27void toybox_mcu_init(void);
125void toybox_mcu_init(running_machine &machine);
28126WRITE16_HANDLER( toybox_mcu_com0_w );
29127WRITE16_HANDLER( toybox_mcu_com1_w );
30128WRITE16_HANDLER( toybox_mcu_com2_w );
31129WRITE16_HANDLER( toybox_mcu_com3_w );
32130READ16_HANDLER( toybox_mcu_status_r );
33131
34extern void (*toybox_mcu_run)(running_machine &machine);   /* one of the following */
35132void bloodwar_mcu_run(running_machine &machine);
36133void bonkadv_mcu_run(running_machine &machine);
37134void gtmr_mcu_run(running_machine &machine);
38135void calc3_mcu_run(running_machine &machine);
39136
40void toxboy_handle_04_subcommand(running_machine& machine,UINT8 mcu_subcmd, UINT16*mcu_ram);
137void toxboy_handle_04_subcommand(running_machine& machine, UINT8 mcu_subcmd, UINT16*mcu_ram);
41138
42139DRIVER_INIT( decrypt_toybox_rom );
43140DRIVER_INIT( decrypt_toybox_rom_alt );
r11160r11161
53150
54151WRITE16_HANDLER( kaneko16_display_enable );
55152
56/* Tile Layers: */
57
58extern UINT16 *kaneko16_vram_0,    *kaneko16_vram_1,    *kaneko16_layers_0_regs;
59extern UINT16 *kaneko16_vscroll_0, *kaneko16_vscroll_1;
60extern UINT16 *kaneko16_vram_2,    *kaneko16_vram_3,    *kaneko16_layers_1_regs;
61extern UINT16 *kaneko16_vscroll_2, *kaneko16_vscroll_3;
62
63153WRITE16_HANDLER( kaneko16_vram_0_w );
64154WRITE16_HANDLER( kaneko16_vram_1_w );
65155WRITE16_HANDLER( kaneko16_vram_2_w );
r11160r11161
68158WRITE16_HANDLER( kaneko16_layers_0_regs_w );
69159WRITE16_HANDLER( kaneko16_layers_1_regs_w );
70160
71
72/* Sprites: */
73
74extern int kaneko16_sprite_type;
75extern int kaneko16_sprite_fliptype;
76extern UINT16 kaneko16_sprite_xoffs, kaneko16_sprite_flipx;
77extern UINT16 kaneko16_sprite_yoffs, kaneko16_sprite_flipy;
78extern UINT16 *kaneko16_sprites_regs;
79
80161READ16_HANDLER ( kaneko16_sprites_regs_r );
81162WRITE16_HANDLER( kaneko16_sprites_regs_w );
82163
83164void kaneko16_draw_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
84165
85/* Pixel Layer: */
86
87extern UINT16 *kaneko16_bg15_select, *kaneko16_bg15_reg;
88
89166READ16_HANDLER ( kaneko16_bg15_select_r );
90167WRITE16_HANDLER( kaneko16_bg15_select_w );
91168
r11160r11161
94171
95172PALETTE_INIT( berlwall );
96173
97
98/* Priorities: */
99
100typedef struct
101{
102   int VIEW2_2_pri;
103   int sprite[4];
104}   kaneko16_priority_t;
105
106extern kaneko16_priority_t kaneko16_priority;
107
108
109/* Machine */
110
111
112174VIDEO_START( kaneko16_sprites );
113175VIDEO_START( kaneko16_1xVIEW2_tilemaps );
114176VIDEO_START( kaneko16_1xVIEW2 );
r11160r11161
125187VIDEO_START( galsnew );
126188SCREEN_UPDATE( galsnew );
127189
128extern UINT16* galsnew_bg_pixram;
129extern UINT16* galsnew_fg_pixram;
190#endif
src/mame/includes/galaxian.h
r11160r11161
2525#define GALAXIAN_VBEND         (16)
2626#define GALAXIAN_VBSTART      (224+16)
2727
28/* video extension callbacks */
29typedef void (*galaxian_extend_tile_info_func)(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
30typedef void (*galaxian_extend_sprite_info_func)(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
31typedef void (*galaxian_draw_bullet_func)(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y);
32typedef void (*galaxian_draw_background_func)(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
33
34
2835class galaxian_state : public driver_device
2936{
3037public:
r11160r11161
3239      : driver_device(machine, config) { }
3340
3441   UINT8 *m_videoram;
42   int m_counter_74ls161[2];
43   int m_direction[2];
44   UINT8 m_gmgalax_selected_game;
45   UINT8 m_zigzag_ay8910_latch;
46   UINT8 m_kingball_speech_dip;
47   UINT8 m_kingball_sound;
48   UINT8 m_mshuttle_ay8910_cs;
49   UINT16 m_protection_state;
50   UINT8 m_protection_result;
51   UINT8 m_konami_sound_control;
52   UINT8 m_sfx_sample_control;
53   UINT8 m_moonwar_port_select;
54   UINT8 m_irq_enabled;
55   int m_irq_line;
56   int m_tenspot_current_game;
57   UINT8 m_frogger_adjust;
58   UINT8 m_sfx_tilemap;
59   galaxian_extend_tile_info_func m_extend_tile_info_ptr;
60   galaxian_extend_sprite_info_func m_extend_sprite_info_ptr;
61   galaxian_draw_bullet_func m_draw_bullet_ptr;
62   galaxian_draw_background_func m_draw_background_ptr;
63   tilemap_t *m_bg_tilemap;
64   UINT8 m_flipscreen_x;
65   UINT8 m_flipscreen_y;
66   UINT8 m_background_enable;
67   UINT8 m_background_red;
68   UINT8 m_background_green;
69   UINT8 m_background_blue;
70   UINT32 m_star_rng_origin;
71   UINT32 m_star_rng_origin_frame;
72   rgb_t m_star_color[64];
73   UINT8 *m_stars;
74   UINT8 m_stars_enabled;
75   UINT8 m_stars_blink_state;
76   rgb_t m_bullet_color[8];
77   UINT8 m_gfxbank[5];
3578};
3679
3780
3881/*----------- defined in video/galaxian.c -----------*/
3982
40extern UINT8 galaxian_frogger_adjust;
41extern UINT8 galaxian_sfx_tilemap;
42
4383PALETTE_INIT( galaxian );
4484PALETTE_INIT( moonwar );
4585
r11160r11161
64104
65105TIMER_DEVICE_CALLBACK( galaxian_stars_blink_timer );
66106
67/* video extension callbacks */
68typedef void (*galaxian_extend_tile_info_func)(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
69typedef void (*galaxian_extend_sprite_info_func)(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
70typedef void (*galaxian_draw_bullet_func)(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y);
71typedef void (*galaxian_draw_background_func)(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
72
73extern galaxian_extend_tile_info_func galaxian_extend_tile_info_ptr;
74extern galaxian_extend_sprite_info_func galaxian_extend_sprite_info_ptr;
75extern galaxian_draw_bullet_func galaxian_draw_bullet_ptr;
76extern galaxian_draw_background_func galaxian_draw_background_ptr;
77
78107/* special purpose background rendering */
79108void galaxian_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
80109void frogger_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
r11160r11161
91120void theend_draw_bullet(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y);
92121
93122/* generic extensions */
94void upper_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
95void upper_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
123void upper_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
124void upper_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
96125
97126/* Frogger extensions */
98void frogger_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
99void frogger_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
127void frogger_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
128void frogger_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
100129
101130/* Ghostmuncher Galaxian extensions */
102void gmgalax_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
103void gmgalax_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
131void gmgalax_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
132void gmgalax_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
104133
105134/* Pisces extensions */
106void pisces_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
107void pisces_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
135void pisces_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
136void pisces_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
108137
109138/* Batman Part 2 extensions */
110void batman2_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
139void batman2_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
111140
112141/* Moon Cresta extensions */
113void mooncrst_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
114void mooncrst_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
142void mooncrst_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
143void mooncrst_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
115144
116145/* Moon Quasar extensions */
117void moonqsr_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
118void moonqsr_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
146void moonqsr_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
147void moonqsr_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
119148
120149/* Moon Shuttle extensions */
121void mshuttle_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
122void mshuttle_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
150void mshuttle_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
151void mshuttle_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
123152
124153/* Calipso extensions */
125void calipso_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
154void calipso_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
126155
127156/* Jumpbug extensions */
128void jumpbug_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
129void jumpbug_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
157void jumpbug_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x);
158void jumpbug_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color);
130159
131160/*----------- defined in drivers/galaxian.c -----------*/
132161
src/mame/includes/4enraya.h
r11160r11161
1111      : driver_device(machine, config) { }
1212
1313   /* memory pointers */
14   UINT8 *    m_videoram;
15   size_t     m_videoram_size;
14   UINT8       m_videoram[0x1000];
15   UINT8      m_workram[0x1000];
1616
1717   /* video-related */
1818   tilemap_t    *m_bg_tilemap;
src/mame/includes/lordgun.h
r11160r11161
2121   UINT8 m_aliencha_dip_sel;
2222   UINT16 *m_priority_ram;
2323   UINT16 m_priority;
24   UINT16 *m_vram_0;
25   UINT16 *m_scroll_x_0;
26   UINT16 *m_scroll_y_0;
27   UINT16 *m_vram_1;
28   UINT16 *m_scroll_x_1;
29   UINT16 *m_scroll_y_1;
30   UINT16 *m_vram_2;
31   UINT16 *m_scroll_x_2;
32   UINT16 *m_scroll_y_2;
33   UINT16 *m_vram_3;
34   UINT16 *m_scroll_x_3;
35   UINT16 *m_scroll_y_3;
24   UINT16 *m_vram[4];
25   UINT16 *m_scroll_x[4];
26   UINT16 *m_scroll_y[4];
3627   UINT16 *m_scrollram;
3728   int m_whitescreen;
3829   lordgun_gun_data m_gun[2];
39   tilemap_t *m_tilemap_0;
40   tilemap_t *m_tilemap_1;
41   tilemap_t *m_tilemap_2;
42   tilemap_t *m_tilemap_3;
30   tilemap_t *m_tilemap[4];
4331   bitmap_t *m_bitmaps[5];
4432   UINT16 *m_spriteram;
4533   size_t m_spriteram_size;
src/mame/includes/scramble.h
r0r11161
1#include "machine/8255ppi.h"
2#include "includes/galaxold.h"
3
4class scramble_state : public galaxold_state
5{
6public:
7   scramble_state(running_machine &machine, const driver_device_config_base &config)
8      : galaxold_state(machine, config) { }
9
10   UINT8 *m_soundram;
11   UINT8 m_cavelon_bank;
12   UINT8 m_security_2B_counter;
13   UINT8 m_xb;
14};
15
16
17/*----------- defined in machine/scramble.c -----------*/
18
19extern const ppi8255_interface scramble_ppi_0_intf;
20extern const ppi8255_interface scramble_ppi_1_intf;
21extern const ppi8255_interface stratgyx_ppi_1_intf;
22extern const ppi8255_interface scramble_protection_ppi_1_intf;
23extern const ppi8255_interface mrkougar_ppi_1_intf;
24
25
26DRIVER_INIT( scramble_ppi );
27DRIVER_INIT( stratgyx );
28DRIVER_INIT( tazmani2 );
29DRIVER_INIT( ckongs );
30DRIVER_INIT( mariner );
31DRIVER_INIT( devilfsh );
32DRIVER_INIT( mars );
33DRIVER_INIT( hotshock );
34DRIVER_INIT( cavelon );
35DRIVER_INIT( darkplnt );
36DRIVER_INIT( mimonkey );
37DRIVER_INIT( mimonsco );
38DRIVER_INIT( mimonscr );
39DRIVER_INIT( rescue );
40DRIVER_INIT( minefld );
41DRIVER_INIT( hustler );
42DRIVER_INIT( hustlerd );
43DRIVER_INIT( billiard );
44DRIVER_INIT( mrkougar );
45DRIVER_INIT( mrkougb );
46DRIVER_INIT( ad2083 );
47
48MACHINE_RESET( scramble );
49MACHINE_RESET( explorer );
50
51READ8_HANDLER( triplep_pip_r );
52READ8_HANDLER( triplep_pap_r );
53
54READ8_HANDLER( hunchbks_mirror_r );
55WRITE8_HANDLER( hunchbks_mirror_w );
56
57CUSTOM_INPUT( darkplnt_custom_r );
58
59
60/*----------- defined in audio/scramble.c -----------*/
61
62void scramble_sh_init(running_machine &machine);
63WRITE_LINE_DEVICE_HANDLER( scramble_sh_7474_q_callback );
64
65WRITE8_HANDLER( scramble_filter_w );
66WRITE8_HANDLER( frogger_filter_w );
67
68READ8_DEVICE_HANDLER( scramble_portB_r );
69READ8_DEVICE_HANDLER( frogger_portB_r );
70
71READ8_DEVICE_HANDLER( hotshock_soundlatch_r );
72
73WRITE8_DEVICE_HANDLER( scramble_sh_irqtrigger_w );
74WRITE8_DEVICE_HANDLER( mrkougar_sh_irqtrigger_w );
75WRITE8_HANDLER( hotshock_sh_irqtrigger_w );
76
77MACHINE_CONFIG_EXTERN( ad2083_audio );
78
src/mame/includes/namcos21.h
r11160r11161
55#define NAMCOS21_POLY_FRAME_WIDTH 496
66#define NAMCOS21_POLY_FRAME_HEIGHT 480
77
8#define WINRUN_MAX_POLY_PARAM (1+256*3)
9
10#define DSP_BUF_MAX (4096*12)
11struct dsp_state
12{
13   unsigned masterSourceAddr;
14   UINT16 slaveInputBuffer[DSP_BUF_MAX];
15   unsigned slaveBytesAvailable;
16   unsigned slaveBytesAdvertised;
17   unsigned slaveInputStart;
18   UINT16 slaveOutputBuffer[DSP_BUF_MAX];
19   unsigned slaveOutputSize;
20   UINT16 masterDirectDrawBuffer[256];
21   unsigned masterDirectDrawSize;
22   int masterFinished;
23   int slaveActive;
24};
25
826class namcos21_state : public driver_device
927{
1028public:
r11160r11161
1230      : driver_device(machine, config) { }
1331
1432   UINT8 *m_videoram;
33   UINT16 *m_winrun_dspbios;
34   UINT16 *m_winrun_dspcomram;
35   UINT16 m_winrun_poly_buf[WINRUN_MAX_POLY_PARAM];
36   int m_winrun_poly_index;
37   UINT32 m_winrun_pointrom_addr;
38   UINT16 *m_winrun_polydata;
39   int m_winrun_dsp_alive;
40   UINT16 *m_winrun_gpucomram;
41   UINT16 m_winrun_dspcomram_control[8];
42   UINT16 m_video_enable;
43   UINT8 *m_pointram;
44   int m_pointram_idx;
45   UINT16 *m_dspram16;
46   UINT16 *m_mpDataROM;
47   UINT16 *m_mpSharedRAM1;
48   UINT8 *m_mpDualPortRAM;
49   UINT16 m_pointram_control;
50   dsp_state *m_mpDspState;
51   int m_mbNeedsKickstart;
52   UINT16 *m_master_dsp_code;
53   UINT32 m_pointrom_idx;
54   UINT8 m_mPointRomMSB;
55   int m_mbPointRomDataAvailable;
56   int m_irq_enable;
57   UINT8 m_depthcue[2][0x400];
58   UINT16 *m_mpPolyFrameBufferPens;
59   UINT16 *m_mpPolyFrameBufferZ;
60   UINT16 *m_mpPolyFrameBufferPens2;
61   UINT16 *m_mpPolyFrameBufferZ2;
62   UINT16 m_winrun_color;
63   UINT16 m_winrun_gpu_register[0x10/2];
1564};
1665
1766
1867/*----------- defined in video/namcos21.c -----------*/
1968
20extern void namcos21_ClearPolyFrameBuffer( void );
21extern void namcos21_DrawQuad( int sx[4], int sy[4], int zcode[4], int color );
69extern void namcos21_ClearPolyFrameBuffer( running_machine &machine );
70extern void namcos21_DrawQuad( running_machine &machine, int sx[4], int sy[4], int zcode[4], int color );
2271
2372extern READ16_HANDLER(winrun_gpu_color_r);
2473extern WRITE16_HANDLER(winrun_gpu_color_w);
src/mame/includes/namcos22.h
r11160r11161
1#include "video/poly.h"
2
13#define USE_NAMCOS22_SPEED_HACK
24
5#define MAX_LIT_SURFACES 32
6#define MAX_RENDER_CMD_SEQ 0x1c
7
8
39#define GFX_CHAR               0
410#define GFX_TEXTURE_TILE       1
511#define GFX_SPRITE             2
612
7extern enum namcos22_gametype
13enum
814{
915   NAMCOS22_AIR_COMBAT22,
1016   NAMCOS22_ALPINE_RACER,
r11160r11161
2228   NAMCOS22_TOKYO_WARS,
2329   NAMCOS22_AQUA_JET,
2430   NAMCOS22_DIRT_DASH
25} namcos22_gametype;
31};
2632
2733#define NAMCOS22_NUM_ROWS 30
2834#define NAMCOS22_NUM_COLS 40
2935
3036#define NAMCOS22_PALETTE_SIZE 0x8000
3137
38
3239class namcos22_state : public driver_device
3340{
3441public:
r11160r11161
3643      : driver_device(machine, config) { }
3744
3845   UINT32 *m_spriteram;
46   int m_mbEnableDspIrqs;
47   UINT32 *m_shareram;
48   UINT32 *m_system_controller;
49   UINT32 *m_nvmem;
50   size_t m_nvmem_size;
51   UINT16 m_mMasterBIOZ;
52   UINT32 *m_mpPointRAM;
53   UINT32 m_old_coin_state;
54   UINT32 m_credits1;
55   UINT32 m_credits2;
56   UINT16 *m_mpSlaveExternalRAM;
57   UINT32 m_mPointAddr;
58   UINT32 m_mPointData;
59   UINT16 *m_mpMasterExternalRAM;
60   UINT16 m_mSerialDataSlaveToMasterNext;
61   UINT16 m_mSerialDataSlaveToMasterCurrent;
62   int m_mRenderBufSize;
63   UINT16 m_mRenderBufData[MAX_RENDER_CMD_SEQ];
64   UINT32 m_mSys22PortBits;
65   int m_mFrameCount;
66   UINT8 m_stick_input;
67   UINT8 m_prev_stick_state;
68   int m_mDspUploadState;
69   int m_mUploadDestIdx;
70   UINT32 m_mAlpineSurferProtData;
71   int m_p4;
72   UINT16 m_su_82;
73   int m_gametype;
74   int m_mbSuperSystem22;
75   UINT32 *m_cgram;
76   UINT32 *m_textram;
77   UINT32 *m_polygonram;
78   UINT32 *m_gamma;
79   UINT32 *m_vics_data;
80   UINT32 *m_vics_control;
81   UINT32 *m_czattr;
82   UINT32 *m_tilemapattr;
83   int m_mbSpotlightEnable;
84   UINT16 *m_czram[4];
85   poly_manager *m_poly;
86   UINT16 *m_mpTextureTileMap16;
87   UINT8 *m_mpTextureTileMapAttr;
88   UINT8 *m_mpTextureTileData;
89   UINT8 m_mXYAttrToPixel[16][16][16];
90   UINT16 m_dspram_bank;
91   UINT16 m_mUpperWordLatch;
92   int m_mbDSPisActive;
93   INT32 m_mAbsolutePriority;
94   INT32 m_mObjectShiftValue22;
95   UINT16 m_mPrimitiveID;
96   float m_mViewMatrix[4][4];
97   UINT8 m_mLitSurfaceInfo[MAX_LIT_SURFACES];
98   INT32 m_mSurfaceNormalFormat;
99   unsigned m_mLitSurfaceCount;
100   unsigned m_mLitSurfaceIndex;
101   int m_mPtRomSize;
102   const UINT8 *m_mpPolyH;
103   const UINT8 *m_mpPolyM;
104   const UINT8 *m_mpPolyL;
105   UINT8 *m_dirtypal;
106   tilemap_t *m_bgtilemap;
39107};
40108
41109
42110/*----------- defined in video/namcos22.c -----------*/
43111
44extern UINT32 *namcos22_cgram;
45extern UINT32 *namcos22_textram;
46extern UINT32 *namcos22_polygonram;
47extern UINT32 *namcos22_gamma;
48extern UINT32 *namcos22_vics_data;
49extern UINT32 *namcos22_vics_control;
50extern UINT32 *namcos22_czattr;
51extern UINT32 *namcos22_tilemapattr;
52
53112WRITE16_HANDLER( namcos22_dspram16_bank_w );
54113READ16_HANDLER( namcos22_dspram16_r );
55114WRITE16_HANDLER( namcos22_dspram16_w );
r11160r11161
82141SCREEN_UPDATE( namcos22s );
83142
84143void namcos22_draw_direct_poly( running_machine &machine, const UINT16 *pSource );
85extern UINT32 namcos22_point_rom_r( offs_t offs );
86extern void namcos22_enable_slave_simulation( void );
144UINT32 namcos22_point_rom_r( running_machine &machine, offs_t offs );
145void namcos22_enable_slave_simulation( running_machine &machine );
src/mame/includes/galaxold.h
r11160r11161
11/***************************************************************************
22
3  Galaxian hardware family
3  Galaxian hardware family (old)
44
55  This include file is used by the following drivers:
6    - galaxian.c
6    - dambustr.c
7    - galaxold.c
78    - scramble.c
89    - scobra.c
9    - frogger.c
10    - amidar.c
11    - dambustr.c
1210
1311***************************************************************************/
1412
15#include "machine/8255ppi.h"
13#ifndef __GALAXOLD_H__
14#define __GALAXOLD_H__
1615
17/*----------- defined in video/galaxold.c -----------*/
16/* star circuit */
17#define STAR_COUNT  252
18struct star
19{
20   int x, y, color;
21};
1822
19extern UINT8 *galaxold_videoram;
20extern UINT8 *galaxold_spriteram;
21extern UINT8 *galaxold_spriteram2;
22extern UINT8 *galaxold_attributesram;
23extern UINT8 *galaxold_bulletsram;
24extern UINT8 *rockclim_videoram;
25extern UINT8 *racknrol_tiles_bank;
23class galaxold_state : public driver_device
24{
25public:
26   galaxold_state(running_machine &machine, const driver_device_config_base &config)
27      : driver_device(machine, config) { }
2628
29   UINT8 *m_videoram;
30   UINT8 *m_spriteram;
31   UINT8 *m_spriteram2;
32   UINT8 *m_attributesram;
33   UINT8 *m_bulletsram;
34   UINT8 *m_rockclim_videoram;
35   UINT8 *m_racknrol_tiles_bank;
36   size_t m_spriteram_size;
37   size_t m_spriteram2_size;
38   size_t m_bulletsram_size;
39   int m_irq_line;
40   UINT8 m__4in1_bank;
41   tilemap_t *m_bg_tilemap;
42   tilemap_t *m_rockclim_tilemap;
43   int m_mooncrst_gfxextend;
44   int m_spriteram2_present;
45   UINT8 m_gfxbank[5];
46   UINT8 m_flipscreen_x;
47   UINT8 m_flipscreen_y;
48   UINT8 m_color_mask;
49   tilemap_t *m_dambustr_tilemap2;
50   UINT8 *m_dambustr_videoram2;
51   void (*m_modify_charcode)(running_machine &machine, UINT16 *code, UINT8 x);      /* function to call to do character banking */
52   void (*m_modify_spritecode)(running_machine &machine, UINT8 *spriteram, int*, int*, int*, int);   /* function to call to do sprite banking */
53   void (*m_modify_color)(UINT8 *color);   /* function to call to do modify how the color codes map to the PROM */
54   void (*m_modify_ypos)(UINT8*);   /* function to call to do modify how vertical positioning bits are connected */
55   void (*m_tilemap_set_scroll)( tilemap_t *, int col, int value );
2756
28extern size_t galaxold_spriteram_size;
29extern size_t galaxold_spriteram2_size;
30extern size_t galaxold_bulletsram_size;
31extern UINT8 galaxold_stars_on;
57   UINT8 m_timer_adjusted;
58   UINT8 m_darkplnt_bullet_color;
59   void (*m_draw_bullets)(running_machine &,bitmap_t *,const rectangle *, int, int, int);   /* function to call to draw a bullet */
3260
61   UINT8 m_background_enable;
62   UINT8 m_background_red;
63   UINT8 m_background_green;
64   UINT8 m_background_blue;
65   void (*m_draw_background)(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);   /* function to call to draw the background */
66   UINT16 m_rockclim_v;
67   UINT16 m_rockclim_h;
68   int m_dambustr_bg_split_line;
69   int m_dambustr_bg_color_1;
70   int m_dambustr_bg_color_2;
71   int m_dambustr_bg_priority;
72   int m_dambustr_char_bank;
73   bitmap_t *m_dambustr_tmpbitmap;
74
75   void (*m_draw_stars)(running_machine &machine, bitmap_t *, const rectangle *);      /* function to call to draw the star layer */
76   int m_stars_colors_start;
77   INT32 m_stars_scrollpos;
78   UINT8 m_stars_on;
79   UINT8 m_stars_blink_state;
80   emu_timer *m_stars_blink_timer;
81   emu_timer *m_stars_scroll_timer;
82   struct star m_stars[STAR_COUNT];
83};
84
85
86/*----------- defined in video/galaxold.c -----------*/
87
3388PALETTE_INIT( galaxold );
3489PALETTE_INIT( scrambold );
3590PALETTE_INIT( darkplnt );
r11160r11161
77132VIDEO_START( mimonkey );
78133VIDEO_START( mariner );
79134VIDEO_START( ckongs );
80VIDEO_START( newsin7 );
81135VIDEO_START( rockclim );
82136VIDEO_START( drivfrcg );
83137VIDEO_START( bongo );
r11160r11161
127181
128182INTERRUPT_GEN( hunchbks_vh_interrupt );
129183
130
131/*----------- defined in machine/scramble.c -----------*/
132
133extern const ppi8255_interface scramble_ppi_0_intf;
134extern const ppi8255_interface scramble_ppi_1_intf;
135extern const ppi8255_interface stratgyx_ppi_1_intf;
136extern const ppi8255_interface scramble_protection_ppi_1_intf;
137extern const ppi8255_interface mrkougar_ppi_1_intf;
138
139
140DRIVER_INIT( scramble_ppi );
141DRIVER_INIT( stratgyx );
142DRIVER_INIT( tazmani2 );
143DRIVER_INIT( ckongs );
144DRIVER_INIT( mariner );
145DRIVER_INIT( devilfsh );
146DRIVER_INIT( mars );
147DRIVER_INIT( hotshock );
148DRIVER_INIT( cavelon );
149DRIVER_INIT( darkplnt );
150DRIVER_INIT( mimonkey );
151DRIVER_INIT( mimonsco );
152DRIVER_INIT( mimonscr );
153DRIVER_INIT( rescue );
154DRIVER_INIT( minefld );
155DRIVER_INIT( hustler );
156DRIVER_INIT( hustlerd );
157DRIVER_INIT( billiard );
158DRIVER_INIT( mrkougar );
159DRIVER_INIT( mrkougb );
160DRIVER_INIT( ad2083 );
161
162MACHINE_RESET( scramble );
163MACHINE_RESET( explorer );
164
165READ8_HANDLER( triplep_pip_r );
166READ8_HANDLER( triplep_pap_r );
167
168READ8_HANDLER( hunchbks_mirror_r );
169WRITE8_HANDLER( hunchbks_mirror_w );
170
171CUSTOM_INPUT( darkplnt_custom_r );
172
173
174/*----------- defined in audio/scramble.c -----------*/
175
176void scramble_sh_init(running_machine &machine);
177WRITE_LINE_DEVICE_HANDLER( scramble_sh_7474_q_callback );
178
179WRITE8_HANDLER( scramble_filter_w );
180WRITE8_HANDLER( frogger_filter_w );
181
182READ8_DEVICE_HANDLER( scramble_portB_r );
183READ8_DEVICE_HANDLER( frogger_portB_r );
184
185READ8_DEVICE_HANDLER( hotshock_soundlatch_r );
186
187WRITE8_DEVICE_HANDLER( scramble_sh_irqtrigger_w );
188WRITE8_DEVICE_HANDLER( mrkougar_sh_irqtrigger_w );
189WRITE8_HANDLER( hotshock_sh_irqtrigger_w );
190
191MACHINE_CONFIG_EXTERN( ad2083_audio );
192
184#endif
src/mame/includes/segag80v.h
r11160r11161
1313      : driver_device(machine, config) { }
1414
1515   UINT8 *m_mainram;
16   UINT8 m_has_usb;
16   device_t *m_usb;
1717   UINT8 m_mult_data[2];
1818   UINT16 m_mult_result;
1919   UINT8 m_spinner_select;
src/mame/includes/astrocde.h
r11160r11161
1919      : driver_device(machine, config) { }
2020
2121   UINT8 *m_videoram;
22   UINT8 m_video_config;
23   UINT8 m_sparkle[4];
24   char m_totalword[256];
25   char *m_totalword_ptr;
26   char m_oldword[256];
27   int m_plural;
28   UINT8 *m_protected_ram;
29   UINT8 m_port_1_last;
30   UINT8 m_port_2_last;
31   UINT8 m_ram_write_enable;
32   UINT8 m_input_select;
33   UINT8 m_profpac_bank;
34   UINT8 *m_sparklestar;
35   UINT8 m_interrupt_enabl;
36   UINT8 m_interrupt_vector;
37   UINT8 m_interrupt_scanline;
38   UINT8 m_vertical_feedback;
39   UINT8 m_horizontal_feedback;
40   emu_timer *m_scanline_timer;
41   UINT8 m_colors[8];
42   UINT8 m_colorsplit;
43   UINT8 m_bgdata;
44   UINT8 m_vblank;
45   UINT8 m_video_mode;
46   UINT8 m_funcgen_expand_color[2];
47   UINT8 m_funcgen_control;
48   UINT8 m_funcgen_expand_count;
49   UINT8 m_funcgen_rotate_count;
50   UINT8 m_funcgen_rotate_data[4];
51   UINT8 m_funcgen_shift_prev_data;
52   UINT8 m_funcgen_intercept;
53   UINT16 m_pattern_source;
54   UINT8 m_pattern_mode;
55   UINT16 m_pattern_dest;
56   UINT8 m_pattern_skip;
57   UINT8 m_pattern_width;
58   UINT8 m_pattern_height;
59   UINT16 *m_profpac_videoram;
60   UINT16 m_profpac_palette[16];
61   UINT8 m_profpac_colormap[4];
62   UINT8 m_profpac_intercept;
63   UINT8 m_profpac_vispage;
64   UINT8 m_profpac_readpage;
65   UINT8 m_profpac_readshift;
66   UINT8 m_profpac_writepage;
67   UINT8 m_profpac_writemode;
68   UINT16 m_profpac_writemask;
69   UINT8 m_profpac_vw;
2270};
2371
2472
2573/*----------- defined in video/astrocde.c -----------*/
2674
27extern UINT8 astrocade_video_config;
28extern UINT8 astrocade_sparkle[4];
29
3075PALETTE_INIT( astrocde );
3176PALETTE_INIT( profpac );
3277
src/mame/includes/exidy440.h
r11160r11161
3030   UINT8 m_palettebank_io;
3131   UINT8 m_palettebank_vis;
3232   UINT8 *m_spriteram;
33   device_t *m_custom;
3334};
3435
3536
src/mame/includes/m72.h
r11160r11161
3737   INT32 m_scrolly2;
3838   INT32 m_video_off;
3939   int m_majtitle_rowscroll;
40   device_t *m_audio;
4041};
4142
4243
src/mame/includes/psikyosh.h
r11160r11161
3636   bitmap_t       *m_z_bitmap;
3737   bitmap_t       *m_bg_bitmap;
3838   UINT16         *m_bg_zoom;
39//  UINT8          *m_alphatable;
39   UINT8          m_alphatable[256];
4040
4141   /* misc */
4242   UINT32         m_sample_offs;   // only used if ROMTEST = 1
src/mame/includes/fuukifg2.h
r11160r11161
77      : driver_device(machine, config) { }
88
99   /* memory pointers */
10   UINT16 *    m_vram_0;
11   UINT16 *    m_vram_1;
12   UINT16 *    m_vram_2;
13   UINT16 *    m_vram_3;
10   UINT16 *    m_vram[4];
1411   UINT16 *    m_vregs;
1512   UINT16 *    m_priority;
1613   UINT16 *    m_unknown;
r11160r11161
1916   size_t      m_spriteram_size;
2017
2118   /* video-related */
22   tilemap_t     *m_tilemap_0;
23   tilemap_t     *m_tilemap_1;
24   tilemap_t     *m_tilemap_2;
25   tilemap_t     *m_tilemap_3;
19   tilemap_t     *m_tilemap[4];
2620
2721   /* misc */
2822   emu_timer   *m_raster_interrupt_timer;
src/mame/includes/taito_f3.h
r11160r11161
3636   POPNPOP,   /* E51 */
3737   LANDMAKR,   /* E61 */
3838   RECALH,      /* prototype */
39   COMMANDW   /* prototype */
39   COMMANDW,   /* prototype */
40   TMDRILL
4041};
4142
4243class taito_f3_state : public driver_device
r11160r11161
4546   taito_f3_state(running_machine &machine, const driver_device_config_base &config)
4647      : driver_device(machine, config) { }
4748
48   UINT32 *m_videoram;
49   UINT32 *m_spriteram;
50   size_t m_spriteram_size;
49   UINT16 *m_videoram;
50   UINT16 *m_spriteram;
51//   size_t m_spriteram_size;
5152   UINT32 m_coin_word[2];
5253   UINT32 *m_f3_ram;
5354   int m_f3_game;
54   UINT32 *m_f3_vram;
55   UINT32 *m_f3_line_ram;
56   UINT32 *m_f3_pf_data;
57   UINT32 *m_f3_pivot_ram;
55   UINT16 *m_f3_vram;
56   UINT16 *m_f3_line_ram;
57   UINT16 *m_f3_pf_data;
58   UINT16 *m_f3_pivot_ram;
5859   tilemap_t *m_pf1_tilemap;
5960   tilemap_t *m_pf2_tilemap;
6061   tilemap_t *m_pf3_tilemap;
6162   tilemap_t *m_pf4_tilemap;
63   tilemap_t *m_pf5_tilemap;
64   tilemap_t *m_pf6_tilemap;
65   tilemap_t *m_pf7_tilemap;
66   tilemap_t *m_pf8_tilemap;
6267   tilemap_t *m_pixel_layer;
6368   tilemap_t *m_vram_layer;
64   UINT32 *m_spriteram32_buffered;
65   UINT32 m_f3_control_0[8];
66   UINT32 m_f3_control_1[8];
69   UINT16 *m_spriteram16_buffered;
70   UINT16 m_f3_control_0[8];
71   UINT16 m_f3_control_1[8];
6772   int m_flipscreen;
6873   UINT8 m_sprite_extra_planes;
6974   UINT8 m_sprite_pen_mask;
70   UINT32 *m_f3_pf_data_1;
71   UINT32 *m_f3_pf_data_2;
72   UINT32 *m_f3_pf_data_3;
73   UINT32 *m_f3_pf_data_4;
75   UINT16 *m_f3_pf_data_1;
76   UINT16 *m_f3_pf_data_2;
77   UINT16 *m_f3_pf_data_3;
78   UINT16 *m_f3_pf_data_4;
79   UINT16 *m_f3_pf_data_5;
80   UINT16 *m_f3_pf_data_6;
81   UINT16 *m_f3_pf_data_7;
82   UINT16 *m_f3_pf_data_8;
7483   int m_f3_skip_this_frame;
7584   int m_sprite_lag;
7685   UINT8 m_sprite_pri_usage;
r11160r11161
8897   int m_twidth_mask;
8998   int m_twidth_mask_bit;
9099   UINT8 *m_tile_opaque_sp;
91   UINT8 *m_tile_opaque_pf[4];
100   UINT8 *m_tile_opaque_pf[8];
92101   UINT8 m_add_sat[256][256];
93102   int m_alpha_s_1_1;
94103   int m_alpha_s_1_2;
r11160r11161
193202SCREEN_UPDATE( f3 );
194203SCREEN_EOF( f3 );
195204
196WRITE32_HANDLER( f3_control_0_w );
197WRITE32_HANDLER( f3_control_1_w );
205WRITE16_HANDLER( f3_control_0_w );
206WRITE16_HANDLER( f3_control_1_w );
198207WRITE32_HANDLER( f3_palette_24bit_w );
199WRITE32_HANDLER( f3_pf_data_w );
200WRITE32_HANDLER( f3_vram_w );
201WRITE32_HANDLER( f3_pivot_w );
202WRITE32_HANDLER( f3_lineram_w );
203WRITE32_HANDLER( f3_videoram_w );
208WRITE16_HANDLER( f3_pf_data_w );
209WRITE16_HANDLER( f3_vram_w );
210WRITE16_HANDLER( f3_pivot_w );
211WRITE16_HANDLER( f3_lineram_w );
212WRITE16_HANDLER( f3_videoram_w );
213WRITE16_HANDLER( f3_spriteram_w );
204214
205
215READ16_HANDLER( f3_pf_data_r );
216READ16_HANDLER( f3_vram_r );
217READ16_HANDLER( f3_pivot_r );
218READ16_HANDLER( f3_lineram_r );
219READ16_HANDLER( f3_videoram_r );
220READ16_HANDLER( f3_spriteram_r );
src/mame/includes/cave.h
r11160r11161
2929
3030   /* memory pointers */
3131   UINT16 *     m_videoregs;
32   UINT16 *     m_vram_0;
33   UINT16 *     m_vram_1;
34   UINT16 *     m_vram_2;
35   UINT16 *     m_vram_3;
36   UINT16 *     m_vctrl_0;
37   UINT16 *     m_vctrl_1;
38   UINT16 *     m_vctrl_2;
39   UINT16 *     m_vctrl_3;
32   UINT16 *     m_vram[4];
33   UINT16 *     m_vctrl[4];
4034   UINT16 *     m_spriteram;
4135   UINT16 *     m_spriteram_2;
4236   UINT16 *     m_paletteram;
r11160r11161
6054   void (*m_get_sprite_info)(running_machine &machine);
6155   void (*m_sprite_draw)(running_machine &machine, int priority);
6256
63   tilemap_t    *m_tilemap_0;
64   tilemap_t    *m_tilemap_1;
65   tilemap_t    *m_tilemap_2;
66   tilemap_t    *m_tilemap_3;
67   int          m_tiledim_0;
68   int          m_old_tiledim_0;
69   int          m_tiledim_1;
70   int          m_old_tiledim_1;
71   int          m_tiledim_2;
72   int          m_old_tiledim_2;
73   int          m_tiledim_3;
74   int          m_old_tiledim_3;
57   tilemap_t    *m_tilemap[4];
58   int          m_tiledim[4];
59   int          m_old_tiledim[4];
7560
7661   bitmap_t     *m_sprite_zbuf;
7762   UINT16       m_sprite_zbuf_baseval;
src/mame/includes/fuukifg3.h
r11160r11161
1616      : driver_device(machine, config) { }
1717
1818   /* memory pointers */
19   UINT32 *    m_vram_0;
20   UINT32 *    m_vram_1;
21   UINT32 *    m_vram_2;
22   UINT32 *    m_vram_3;
19   UINT32 *    m_vram[4];
2320   UINT32 *    m_vregs;
2421   UINT32 *    m_priority;
2522   UINT32 *    m_tilebank;
r11160r11161
3027   size_t      m_spriteram_size;
3128
3229   /* video-related */
33   tilemap_t     *m_tilemap_0;
34   tilemap_t     *m_tilemap_1;
35   tilemap_t     *m_tilemap_2;
36   tilemap_t     *m_tilemap_3;
30   tilemap_t     *m_tilemap[4];
3731   UINT32      m_spr_buffered_tilebank[2];
3832
3933   /* misc */
src/mame/mame.mak
r11160r11161
506506$(MAMEOBJ)/capcom.a: \
507507   $(DRIVERS)/1942.o $(VIDEO)/1942.o \
508508   $(DRIVERS)/1943.o $(VIDEO)/1943.o \
509   $(DRIVERS)/alien.o \
509510   $(DRIVERS)/bionicc.o $(VIDEO)/bionicc.o \
510511   $(DRIVERS)/blktiger.o $(VIDEO)/blktiger.o \
511512   $(DRIVERS)/cbasebal.o $(VIDEO)/cbasebal.o \
r11160r11161
10341035   $(DRIVERS)/playch10.o $(MACHINE)/playch10.o $(VIDEO)/playch10.o \
10351036   $(DRIVERS)/popeye.o $(VIDEO)/popeye.o \
10361037   $(DRIVERS)/punchout.o $(VIDEO)/punchout.o \
1038        $(DRIVERS)/famibox.o \
10371039   $(DRIVERS)/sfcbox.o \
10381040   $(DRIVERS)/snesb.o \
10391041   $(DRIVERS)/spacefb.o $(AUDIO)/spacefb.o  $(VIDEO)/spacefb.o \
r11160r11161
12701272   $(DRIVERS)/lastfght.o \
12711273   $(DRIVERS)/subsino.o \
12721274   $(DRIVERS)/subsino2.o \
1275   $(MACHINE)/subsino.o \
12731276
12741277$(MAMEOBJ)/sun.a: \
12751278   $(DRIVERS)/arabian.o $(VIDEO)/arabian.o \
r11160r11161
15871590   $(DRIVERS)/39in1.o \
15881591   $(DRIVERS)/1945kiii.o \
15891592   $(DRIVERS)/2mindril.o \
1590   $(DRIVERS)/3super8.o \
15911593   $(DRIVERS)/4enraya.o $(VIDEO)/4enraya.o \
15921594   $(DRIVERS)/4roses.o \
15931595   $(DRIVERS)/5clown.o \
r11160r11161
16141616   $(DRIVERS)/cave.o $(VIDEO)/cave.o \
16151617   $(DRIVERS)/cb2001.o \
16161618   $(DRIVERS)/cdi.o $(VIDEO)/mcd212.o $(MACHINE)/cdi070.o $(MACHINE)/cdislave.o $(MACHINE)/cdicdic.o \
1619   $(DRIVERS)/cesclass.o \
16171620   $(DRIVERS)/chsuper.o \
16181621   $(DRIVERS)/cidelsa.o $(VIDEO)/cidelsa.o \
16191622   $(DRIVERS)/coinmstr.o \
r11160r11161
16871690   $(DRIVERS)/magicfly.o \
16881691   $(DRIVERS)/magictg.o \
16891692   $(DRIVERS)/magtouch.o \
1693   $(DRIVERS)/majorpkr.o \
16901694   $(DRIVERS)/malzak.o $(VIDEO)/malzak.o \
16911695   $(DRIVERS)/mcatadv.o $(VIDEO)/mcatadv.o \
16921696   $(DRIVERS)/micro3d.o $(MACHINE)/micro3d.o $(VIDEO)/micro3d.o $(AUDIO)/micro3d.o \
r11160r11161
18851889$(DRIVERS)/magic10.o:   $(LAYOUT)/sgsafari.lh \
18861890                  $(LAYOUT)/musicsrt.lh
18871891
1892$(DRIVERS)/majorpkr.o:   $(LAYOUT)/majorpkr.lh
1893
18881894$(DRIVERS)/maxaflex.o:   $(LAYOUT)/maxaflex.lh
18891895
18901896$(DRIVERS)/mcr3.o:      $(LAYOUT)/turbotag.lh
src/mame/video/eprom.c
r11160r11161
55****************************************************************************/
66
77#include "emu.h"
8#include "video/atarimo.h"
89#include "includes/eprom.h"
910
1011
src/mame/video/rampart.c
r11160r11161
66
77#include "emu.h"
88#include "machine/atarigen.h"
9#include "video/atarimo.h"
910#include "includes/rampart.h"
1011
1112
src/mame/video/galpani2.c
r11160r11161
2626
2727
2828#ifdef UNUSED_DEFINITION
29#define galpani2_BG8_REGS_R( _n_ ) \
30READ16_HANDLER( galpani2_bg8_regs_##_n_##_r ) \
31{ \
32   galpani2_state *state = space->machine().driver_data<galpani2_state>(); \
33   switch (offset * 2) \
34   { \
35      case 0x16:   return space->machine().rand() & 1; \
36      default: \
37         logerror("CPU #0 PC %06X : Warning, bg8 #%d screen reg %04X read\n",cpu_get_pc(&space->device()),_n_,offset*2); \
38   } \
39   return state->m_bg8_regs_##_n_[offset]; \
29INLINE UINT16 galpani2_bg8_regs_r(address_space *space, offs_t offset, int n)
30{
31   galpani2_state *state = space->machine().driver_data<galpani2_state>();
32   switch (offset * 2)
33   {
34      case 0x16:   return space->machine().rand() & 1;
35      default:
36         logerror("CPU #0 PC %06X : Warning, bg8 #%d screen reg %04X read\n",cpu_get_pc(space->cpu),_n_,offset*2);
37   }
38   return state->m_bg8_regs[_n_][offset];
4039}
4140
4241/*
r11160r11161
4645    c04         0003 flip, 0300 flip?
4746    c1c/e       01ff scroll, 3000 ?
4847*/
49#define galpani2_BG8_REGS_W( _n_ ) \
50WRITE16_HANDLER( galpani2_bg8_regs_##_n_##_w ) \
51{ \
52   galpani2_state *state = space->machine().driver_data<galpani2_state>(); \
53   COMBINE_DATA(&state->m_bg8_regs_##_n_[offset]); \
48INLINE void galpani2_bg8_regs_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
49{
50   galpani2_state *state = space->machine().driver_data<galpani2_state>();
51   COMBINE_DATA(&state->m_bg8_regs[_n_][offset]);
5452}
53
54READ16_HANDLER( galpani2_bg8_regs_0_r ) { return galpani2_bg8_regs_r(space, offset, 0); }
55READ16_HANDLER( galpani2_bg8_regs_1_r ) { return galpani2_bg8_regs_r(space, offset, 1); }
56
57WRITE16_HANDLER( galpani2_bg8_regs_0_w ) { galpani2_bg8_regs_w(space, offset, data, mem_mask, 0); }
58WRITE16_HANDLER( galpani2_bg8_regs_1_w ) { galpani2_bg8_regs_w(space, offset, data, mem_mask, 1); }
5559#endif
5660
57#define galpani2_BG8_W( _n_ ) \
58WRITE16_HANDLER( galpani2_bg8_##_n_##_w ) \
59{ \
60   galpani2_state *state = space->machine().driver_data<galpani2_state>(); \
61   int x,y,pen; \
62   UINT16 newword = COMBINE_DATA(&state->m_bg8_##_n_[offset]); \
63   pen   =   newword & 0xff; \
64   x   =   (offset % 512);   /* 512 x 256 */ \
65   y   =   (offset / 512); \
66   *BITMAP_ADDR16(state->m_bg8_bitmap_##_n_, y, x) = 0x4000 + pen; \
61INLINE void galpani2_bg8_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
62{
63   galpani2_state *state = space->machine().driver_data<galpani2_state>();
64   int x,y,pen;
65   UINT16 newword = COMBINE_DATA(&state->m_bg8[_n_][offset]);
66   pen   =   newword & 0xff;
67   x   =   (offset % 512);   /* 512 x 256 */
68   y   =   (offset / 512);
69   *BITMAP_ADDR16(state->m_bg8_bitmap[_n_], y, x) = 0x4000 + pen;
6770}
6871
69#define galpani2_BG8_PALETTE_W( _n_ ) \
70WRITE16_HANDLER( galpani2_palette_##_n_##_w ) \
71{ \
72   galpani2_state *state = space->machine().driver_data<galpani2_state>(); \
73   UINT16 newword = COMBINE_DATA(&state->m_palette_##_n_[offset]); \
74   palette_set_color_rgb( space->machine(), offset + 0x4000 + _n_ * 0x100, pal5bit(newword >> 5), pal5bit(newword >> 10), pal5bit(newword >> 0) ); \
72WRITE16_HANDLER( galpani2_bg8_0_w ) { galpani2_bg8_w(space, offset, data, mem_mask, 0); }
73WRITE16_HANDLER( galpani2_bg8_1_w ) { galpani2_bg8_w(space, offset, data, mem_mask, 1); }
74
75INLINE void galpani2_palette_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
76{
77   galpani2_state *state = space->machine().driver_data<galpani2_state>();
78   UINT16 newword = COMBINE_DATA(&state->m_palette[_n_][offset]);
79   palette_set_color_rgb( space->machine(), offset + 0x4000 + _n_ * 0x100, pal5bit(newword >> 5), pal5bit(newword >> 10), pal5bit(newword >> 0) );
7580}
7681
77#ifdef UNUSED_FUNCTION
78galpani2_BG8_REGS_R( 0 )
79galpani2_BG8_REGS_R( 1 )
82WRITE16_HANDLER( galpani2_palette_0_w ) { galpani2_palette_w(space, offset, data, mem_mask, 0); }
83WRITE16_HANDLER( galpani2_palette_1_w ) { galpani2_palette_w(space, offset, data, mem_mask, 1); }
8084
81galpani2_BG8_REGS_W( 0 )
82galpani2_BG8_REGS_W( 1 )
83#endif
8485
85galpani2_BG8_W( 0 )
86galpani2_BG8_W( 1 )
87
88galpani2_BG8_PALETTE_W( 0 )
89galpani2_BG8_PALETTE_W( 1 )
90
91
9286/***************************************************************************
9387
9488
r11160r11161
132126{
133127   galpani2_state *state = machine.driver_data<galpani2_state>();
134128   state->m_bg15_bitmap  = auto_bitmap_alloc(machine, 256*8, 256, BITMAP_FORMAT_INDEXED16);
135   state->m_bg8_bitmap_0 = auto_bitmap_alloc(machine, 512, 256, BITMAP_FORMAT_INDEXED16);
136   state->m_bg8_bitmap_1 = auto_bitmap_alloc(machine, 512, 256, BITMAP_FORMAT_INDEXED16);
129   state->m_bg8_bitmap[0] = auto_bitmap_alloc(machine, 512, 256, BITMAP_FORMAT_INDEXED16);
130   state->m_bg8_bitmap[1] = auto_bitmap_alloc(machine, 512, 256, BITMAP_FORMAT_INDEXED16);
137131
138132   VIDEO_START_CALL(kaneko16_sprites);
139133}
r11160r11161
184178
185179   if (layers_ctrl & 0x2)
186180   {
187      int x = - ( *state->m_bg8_0_scrollx + 0x200 - 0x0f5 );
188      int y = - ( *state->m_bg8_0_scrolly + 0x200 - 0x1be );
189      copyscrollbitmap_trans(bitmap, state->m_bg8_bitmap_0,
181      int x = - ( *state->m_bg8_scrollx[0] + 0x200 - 0x0f5 );
182      int y = - ( *state->m_bg8_scrolly[0] + 0x200 - 0x1be );
183      copyscrollbitmap_trans(bitmap, state->m_bg8_bitmap[0],
190184                        1, &x, 1, &y,
191185                        cliprect,0x4000 + 0);
192186   }
193187
194188   if (layers_ctrl & 0x4)
195189   {
196      int x = - ( *state->m_bg8_1_scrollx + 0x200 - 0x0f5 );
197      int y = - ( *state->m_bg8_1_scrolly + 0x200 - 0x1be );
198      copyscrollbitmap_trans(bitmap, state->m_bg8_bitmap_1,
190      int x = - ( *state->m_bg8_scrollx[1] + 0x200 - 0x0f5 );
191      int y = - ( *state->m_bg8_scrolly[1] + 0x200 - 0x1be );
192      copyscrollbitmap_trans(bitmap, state->m_bg8_bitmap[1],
199193                        1, &x, 1, &y,
200194                        cliprect,0x4000 + 0);
201195   }
src/mame/video/suprnova.c
r11160r11161
44#include "video/sknsspr.h"
55#include "includes/suprnova.h"
66
7static bitmap_t *sprite_bitmap;
87
9static bitmap_t *tilemap_bitmap_lower;
10static bitmap_t *tilemap_bitmapflags_lower;
11
12static bitmap_t *tilemap_bitmap_higher;
13static bitmap_t *tilemap_bitmapflags_higher;
14
15
168/* draws ROZ with linescroll OR columnscroll to 16-bit indexed bitmap */
179static void suprnova_draw_roz(bitmap_t* bitmap, bitmap_t* bitmapflags, const rectangle *cliprect, tilemap_t *tmap, UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound, int columnscroll, UINT32* scrollram)
1810{
r11160r11161
9688}
9789
9890
99static int depthA=0;
100static int depthB=0;
101
102
103static int use_spc_bright, use_v3_bright; // makes sarukani rather dark, but should be default..
104static UINT8 bright_spc_b=0x00, bright_spc_g=0x00, bright_spc_r=0x00;
105
106static UINT8 bright_spc_b_trans=0x00, bright_spc_g_trans=0x00, bright_spc_r_trans=0x00;
107
108
109static UINT8 bright_v3_b=0x00,  bright_v3_g=0x00,  bright_v3_r=0x00;
110static UINT8 bright_v3_b_trans = 0x00, bright_v3_g_trans = 0x00, bright_v3_r_trans = 0x00;
111
112// This ignores the alpha values atm.
113static int spc_changed=0, v3_changed=0, palette_updated=0;
114static int suprnova_alt_enable_background;
115int suprnova_alt_enable_sprites;
116
11791WRITE32_HANDLER ( skns_pal_regs_w )
11892{
119   COMBINE_DATA(&skns_pal_regs[offset]);
120   palette_updated =1;
93   skns_state *state = space->machine().driver_data<skns_state>();
94   COMBINE_DATA(&state->m_pal_regs[offset]);
95   state->m_palette_updated =1;
12196
12297   switch ( offset )
12398   {
12499   /* RWRA regs are for SPRITES */
125100
126101   case (0x00/4): // RWRA0
127      if( use_spc_bright != (data&1) ) {
128         use_spc_bright = data&1;
129         spc_changed = 1;
102      if( state->m_use_spc_bright != (data&1) ) {
103         state->m_use_spc_bright = data&1;
104         state->m_spc_changed = 1;
130105      }
131      suprnova_alt_enable_sprites = (data>>8)&1;
106      state->m_alt_enable_sprites = (data>>8)&1;
132107
133108
134109      break;
135110   case (0x04/4): // RWRA1
136      if( bright_spc_g != (data&0xff) ) {
137         bright_spc_g = data&0xff;
138         spc_changed = 1;
111      if( state->m_bright_spc_g != (data&0xff) ) {
112         state->m_bright_spc_g = data&0xff;
113         state->m_spc_changed = 1;
139114      }
140      bright_spc_g_trans = (data>>8) &0xff;
115      state->m_bright_spc_g_trans = (data>>8) &0xff;
141116
142117
143118      break;
144119   case (0x08/4): // RWRA2
145      if( bright_spc_r != (data&0xff) ) {
146         bright_spc_r = data&0xff;
147         spc_changed = 1;
120      if( state->m_bright_spc_r != (data&0xff) ) {
121         state->m_bright_spc_r = data&0xff;
122         state->m_spc_changed = 1;
148123      }
149      bright_spc_r_trans = (data>>8) &0xff;
124      state->m_bright_spc_r_trans = (data>>8) &0xff;
150125
151126      break;
152127   case (0x0C/4): // RWRA3
153      if( bright_spc_b != (data&0xff) ) {
154         bright_spc_b = data&0xff;
155         spc_changed = 1;
128      if( state->m_bright_spc_b != (data&0xff) ) {
129         state->m_bright_spc_b = data&0xff;
130         state->m_spc_changed = 1;
156131      }
157      bright_spc_b_trans = (data>>8)&0xff;
132      state->m_bright_spc_b_trans = (data>>8)&0xff;
158133
159134
160135      break;
r11160r11161
162137   /* RWRB regs are for BACKGROUND */
163138
164139   case (0x10/4): // RWRB0
165      if( use_v3_bright != (data&1) ) {
166         use_v3_bright = data&1;
167         v3_changed = 1;
140      if( state->m_use_v3_bright != (data&1) ) {
141         state->m_use_v3_bright = data&1;
142         state->m_v3_changed = 1;
168143      }
169144
170      suprnova_alt_enable_background = (data>>8)&1;
145      state->m_alt_enable_background = (data>>8)&1;
171146
172147      break;
173148   case (0x14/4): // RWRB1
174      if( bright_v3_g != (data&0xff) ) {
175         bright_v3_g = data&0xff;
176         v3_changed = 1;
149      if( state->m_bright_v3_g != (data&0xff) ) {
150         state->m_bright_v3_g = data&0xff;
151         state->m_v3_changed = 1;
177152      }
178153
179      bright_v3_g_trans = (data>>8)&0xff;
154      state->m_bright_v3_g_trans = (data>>8)&0xff;
180155
181156      break;
182157   case (0x18/4): // RWRB2
183      if( bright_v3_r != (data&0xff) ) {
184         bright_v3_r = data&0xff;
185         v3_changed = 1;
158      if( state->m_bright_v3_r != (data&0xff) ) {
159         state->m_bright_v3_r = data&0xff;
160         state->m_v3_changed = 1;
186161      }
187162
188      bright_v3_r_trans = (data>>8)&0xff;
163      state->m_bright_v3_r_trans = (data>>8)&0xff;
189164
190165      break;
191166   case (0x1C/4): // RWRB3
192      if( bright_v3_b != (data&0xff) ) {
193         bright_v3_b = data&0xff;
194         v3_changed = 1;
167      if( state->m_bright_v3_b != (data&0xff) ) {
168         state->m_bright_v3_b = data&0xff;
169         state->m_v3_changed = 1;
195170      }
196171
197      bright_v3_b_trans = (data>>8)&0xff;
172      state->m_bright_v3_b_trans = (data>>8)&0xff;
198173
199174      break;
200175   }
r11160r11161
203178
204179WRITE32_HANDLER ( skns_palette_ram_w )
205180{
181   skns_state *state = space->machine().driver_data<skns_state>();
206182   int r,g,b;
207183   int brightness_r, brightness_g, brightness_b/*, alpha*/;
208184   int use_bright;
209185
210   COMBINE_DATA(&skns_palette_ram[offset]);
186   COMBINE_DATA(&state->m_palette_ram[offset]);
211187
212   b = ((skns_palette_ram[offset] >> 0  ) & 0x1f);
213   g = ((skns_palette_ram[offset] >> 5  ) & 0x1f);
214   r = ((skns_palette_ram[offset] >> 10  ) & 0x1f);
188   b = ((state->m_palette_ram[offset] >> 0  ) & 0x1f);
189   g = ((state->m_palette_ram[offset] >> 5  ) & 0x1f);
190   r = ((state->m_palette_ram[offset] >> 10  ) & 0x1f);
215191
216   //alpha = ((skns_palette_ram[offset] >> 15  ) & 0x1);
192   //alpha = ((state->m_palette_ram[offset] >> 15  ) & 0x1);
217193
218194   if(offset<(0x40*256)) { // 1st half is for Sprites
219      use_bright = use_spc_bright;
220      brightness_b = bright_spc_b;
221      brightness_g = bright_spc_g;
222      brightness_r = bright_spc_r;
195      use_bright = state->m_use_spc_bright;
196      brightness_b = state->m_bright_spc_b;
197      brightness_g = state->m_bright_spc_g;
198      brightness_r = state->m_bright_spc_r;
223199   } else { // V3 bg's
224      use_bright = use_v3_bright;
225      brightness_b = bright_v3_b;
226      brightness_g = bright_v3_g;
227      brightness_r = bright_v3_r;
200      use_bright = state->m_use_v3_bright;
201      brightness_b = state->m_bright_v3_b;
202      brightness_g = state->m_bright_v3_g;
203      brightness_r = state->m_bright_v3_r;
228204   }
229205
230206   if(use_bright) {
r11160r11161
246222
247223static void palette_set_rgb_brightness (running_machine &machine, int offset, UINT8 brightness_r, UINT8 brightness_g, UINT8 brightness_b)
248224{
225   skns_state *state = machine.driver_data<skns_state>();
249226   int use_bright, r, g, b/*, alpha*/;
250227
251   b = ((skns_palette_ram[offset] >> 0  ) & 0x1f);
252   g = ((skns_palette_ram[offset] >> 5  ) & 0x1f);
253   r = ((skns_palette_ram[offset] >> 10  ) & 0x1f);
228   b = ((state->m_palette_ram[offset] >> 0  ) & 0x1f);
229   g = ((state->m_palette_ram[offset] >> 5  ) & 0x1f);
230   r = ((state->m_palette_ram[offset] >> 10  ) & 0x1f);
254231
255   //alpha = ((skns_palette_ram[offset] >> 15  ) & 0x1);
232   //alpha = ((state->m_palette_ram[offset] >> 15  ) & 0x1);
256233
257234   if(offset<(0x40*256)) { // 1st half is for Sprites
258      use_bright = use_spc_bright;
235      use_bright = state->m_use_spc_bright;
259236   } else { // V3 bg's
260      use_bright = use_v3_bright;
237      use_bright = state->m_use_v3_bright;
261238   }
262239
263240   if(use_bright) {
r11160r11161
279256
280257static void palette_update(running_machine &machine)
281258{
259   skns_state *state = machine.driver_data<skns_state>();
282260   int i;
283261
284   if (palette_updated)
262   if (state->m_palette_updated)
285263   {
286      if(spc_changed)
264      if(state->m_spc_changed)
287265         for(i=0; i<=((0x40*256)-1); i++)
288            palette_set_rgb_brightness (machine, i, bright_spc_r, bright_spc_g, bright_spc_b);
266            palette_set_rgb_brightness (machine, i, state->m_bright_spc_r, state->m_bright_spc_g, state->m_bright_spc_b);
289267
290      if(v3_changed)
268      if(state->m_v3_changed)
291269         for(i=(0x40*256); i<=((0x80*256)-1); i++)
292            palette_set_rgb_brightness (machine, i, bright_v3_r, bright_v3_g, bright_v3_b);
293      palette_updated =0;
270            palette_set_rgb_brightness (machine, i, state->m_bright_v3_r, state->m_bright_v3_g, state->m_bright_v3_b);
271      state->m_palette_updated =0;
294272   }
295273}
296274
297275
298static tilemap_t *skns_tilemap_A;
299static tilemap_t *skns_tilemap_B;
300276
301277static TILE_GET_INFO( get_tilemap_A_tile_info )
302278{
303   int code = ((skns_tilemapA_ram[tile_index] & 0x001fffff) >> 0 );
304   int colr = ((skns_tilemapA_ram[tile_index] & 0x3f000000) >> 24 );
305   int pri  = ((skns_tilemapA_ram[tile_index] & 0x00e00000) >> 21 );
306   int depth = (skns_v3_regs[0x0c/4] & 0x0001) << 1;
279   skns_state *state = machine.driver_data<skns_state>();
280   int code = ((state->m_tilemapA_ram[tile_index] & 0x001fffff) >> 0 );
281   int colr = ((state->m_tilemapA_ram[tile_index] & 0x3f000000) >> 24 );
282   int pri  = ((state->m_tilemapA_ram[tile_index] & 0x00e00000) >> 21 );
283   int depth = (state->m_v3_regs[0x0c/4] & 0x0001) << 1;
307284   int flags = 0;
308285
309   if(skns_tilemapA_ram[tile_index] & 0x80000000) flags |= TILE_FLIPX;
310   if(skns_tilemapA_ram[tile_index] & 0x40000000) flags |= TILE_FLIPY;
286   if(state->m_tilemapA_ram[tile_index] & 0x80000000) flags |= TILE_FLIPX;
287   if(state->m_tilemapA_ram[tile_index] & 0x40000000) flags |= TILE_FLIPY;
311288
312289   SET_TILE_INFO(
313290         0+depth,
r11160r11161
321298
322299WRITE32_HANDLER ( skns_tilemapA_w )
323300{
324   COMBINE_DATA(&skns_tilemapA_ram[offset]);
325   tilemap_mark_tile_dirty(skns_tilemap_A,offset);
301   skns_state *state = space->machine().driver_data<skns_state>();
302   COMBINE_DATA(&state->m_tilemapA_ram[offset]);
303   tilemap_mark_tile_dirty(state->m_tilemap_A,offset);
326304}
327305
328306static TILE_GET_INFO( get_tilemap_B_tile_info )
329307{
330   int code = ((skns_tilemapB_ram[tile_index] & 0x001fffff) >> 0 );
331   int colr = ((skns_tilemapB_ram[tile_index] & 0x3f000000) >> 24 );
332   int pri  = ((skns_tilemapB_ram[tile_index] & 0x00e00000) >> 21 );
333   int depth = (skns_v3_regs[0x0c/4] & 0x0100) >> 7;
308   skns_state *state = machine.driver_data<skns_state>();
309   int code = ((state->m_tilemapB_ram[tile_index] & 0x001fffff) >> 0 );
310   int colr = ((state->m_tilemapB_ram[tile_index] & 0x3f000000) >> 24 );
311   int pri  = ((state->m_tilemapB_ram[tile_index] & 0x00e00000) >> 21 );
312   int depth = (state->m_v3_regs[0x0c/4] & 0x0100) >> 7;
334313   int flags = 0;
335314
336   if(skns_tilemapB_ram[tile_index] & 0x80000000) flags |= TILE_FLIPX;
337   if(skns_tilemapB_ram[tile_index] & 0x40000000) flags |= TILE_FLIPY;
315   if(state->m_tilemapB_ram[tile_index] & 0x80000000) flags |= TILE_FLIPX;
316   if(state->m_tilemapB_ram[tile_index] & 0x40000000) flags |= TILE_FLIPY;
338317
339318   SET_TILE_INFO(
340319         1+depth,
r11160r11161
348327
349328WRITE32_HANDLER ( skns_tilemapB_w )
350329{
351   COMBINE_DATA(&skns_tilemapB_ram[offset]);
352   tilemap_mark_tile_dirty(skns_tilemap_B,offset);
330   skns_state *state = space->machine().driver_data<skns_state>();
331   COMBINE_DATA(&state->m_tilemapB_ram[offset]);
332   tilemap_mark_tile_dirty(state->m_tilemap_B,offset);
353333}
354334
355335WRITE32_HANDLER ( skns_v3_regs_w )
356336{
357   COMBINE_DATA(&skns_v3_regs[offset]);
337   skns_state *state = space->machine().driver_data<skns_state>();
338   COMBINE_DATA(&state->m_v3_regs[offset]);
358339
359340   /* if the depth changes we need to dirty the tilemap */
360341   if (offset == 0x0c/4)
361342   {
362      int old_depthA = depthA;
363      int old_depthB = depthB;
343      int old_depthA = state->m_depthA;
344      int old_depthB = state->m_depthB;
364345
365      depthA = (skns_v3_regs[0x0c/4] & 0x0001) << 1;
366      depthB = (skns_v3_regs[0x0c/4] & 0x0100) >> 7;
346      state->m_depthA = (state->m_v3_regs[0x0c/4] & 0x0001) << 1;
347      state->m_depthB = (state->m_v3_regs[0x0c/4] & 0x0100) >> 7;
367348
368      if (old_depthA != depthA)   tilemap_mark_all_tiles_dirty (skns_tilemap_A);
369      if (old_depthB != depthB)   tilemap_mark_all_tiles_dirty (skns_tilemap_B);
349      if (old_depthA != state->m_depthA)   tilemap_mark_all_tiles_dirty (state->m_tilemap_A);
350      if (old_depthB != state->m_depthB)   tilemap_mark_all_tiles_dirty (state->m_tilemap_B);
370351
371352   }
372353}
r11160r11161
378359
379360   state->m_spritegen = machine.device<sknsspr_device>("spritegen");
380361
381   skns_tilemap_A = tilemap_create(machine, get_tilemap_A_tile_info,tilemap_scan_rows,16,16,64, 64);
382      tilemap_set_transparent_pen(skns_tilemap_A,0);
362   state->m_tilemap_A = tilemap_create(machine, get_tilemap_A_tile_info,tilemap_scan_rows,16,16,64, 64);
363      tilemap_set_transparent_pen(state->m_tilemap_A,0);
383364
384   skns_tilemap_B = tilemap_create(machine, get_tilemap_B_tile_info,tilemap_scan_rows,16,16,64, 64);
385      tilemap_set_transparent_pen(skns_tilemap_B,0);
365   state->m_tilemap_B = tilemap_create(machine, get_tilemap_B_tile_info,tilemap_scan_rows,16,16,64, 64);
366      tilemap_set_transparent_pen(state->m_tilemap_B,0);
386367
387   sprite_bitmap = auto_bitmap_alloc(machine,1024,1024,BITMAP_FORMAT_INDEXED16);
368   state->m_sprite_bitmap = auto_bitmap_alloc(machine,1024,1024,BITMAP_FORMAT_INDEXED16);
388369
389   tilemap_bitmap_lower = auto_bitmap_alloc(machine,320,240,BITMAP_FORMAT_INDEXED16);
390   tilemap_bitmapflags_lower = auto_bitmap_alloc(machine,320,240,BITMAP_FORMAT_INDEXED8);
370   state->m_tilemap_bitmap_lower = auto_bitmap_alloc(machine,320,240,BITMAP_FORMAT_INDEXED16);
371   state->m_tilemap_bitmapflags_lower = auto_bitmap_alloc(machine,320,240,BITMAP_FORMAT_INDEXED8);
391372
392   tilemap_bitmap_higher = auto_bitmap_alloc(machine,320,240,BITMAP_FORMAT_INDEXED16);
393   tilemap_bitmapflags_higher = auto_bitmap_alloc(machine,320,240,BITMAP_FORMAT_INDEXED8);
373   state->m_tilemap_bitmap_higher = auto_bitmap_alloc(machine,320,240,BITMAP_FORMAT_INDEXED16);
374   state->m_tilemap_bitmapflags_higher = auto_bitmap_alloc(machine,320,240,BITMAP_FORMAT_INDEXED8);
394375
395376   machine.gfx[2]->color_granularity=256;
396377   machine.gfx[3]->color_granularity=256;
r11160r11161
398379
399380VIDEO_RESET( skns )
400381{
401   depthA = depthB = 0;
402   use_spc_bright = use_v3_bright = 1;
403   bright_spc_b= bright_spc_g = bright_spc_r = 0x00;
404   bright_spc_b_trans = bright_spc_g_trans = bright_spc_r_trans = 0x00;
405   bright_v3_b = bright_v3_g = bright_v3_r = 0x00;
406   bright_v3_b_trans = bright_v3_g_trans = bright_v3_r_trans = 0x00;
382   skns_state *state = machine.driver_data<skns_state>();
383   state->m_depthA = state->m_depthB = 0;
384   state->m_use_spc_bright = state->m_use_v3_bright = 1;
385   state->m_bright_spc_b= state->m_bright_spc_g = state->m_bright_spc_r = 0x00;
386   state->m_bright_spc_b_trans = state->m_bright_spc_g_trans = state->m_bright_spc_r_trans = 0x00;
387   state->m_bright_v3_b = state->m_bright_v3_g = state->m_bright_v3_r = 0x00;
388   state->m_bright_v3_b_trans = state->m_bright_v3_g_trans = state->m_bright_v3_r_trans = 0x00;
407389
408   spc_changed = v3_changed = palette_updated = 0;
409   suprnova_alt_enable_background = suprnova_alt_enable_sprites = 1;
390   state->m_spc_changed = state->m_v3_changed = state->m_palette_updated = 0;
391   state->m_alt_enable_background = state->m_alt_enable_sprites = 1;
410392}
411393
412static void supernova_draw_a( bitmap_t *bitmap, bitmap_t* bitmap_flags, const rectangle *cliprect, int tran )
394static void supernova_draw_a( running_machine &machine, bitmap_t *bitmap, bitmap_t* bitmap_flags, const rectangle *cliprect, int tran )
413395{
414   int enable_a  = (skns_v3_regs[0x10/4] >> 0) & 0x0001;
415   int nowrap_a = (skns_v3_regs[0x10/4] >> 0) & 0x0004;
396   skns_state *state = machine.driver_data<skns_state>();
397   int enable_a  = (state->m_v3_regs[0x10/4] >> 0) & 0x0001;
398   int nowrap_a = (state->m_v3_regs[0x10/4] >> 0) & 0x0004;
416399
417400
418401   UINT32 startx,starty;
r11160r11161
421404
422405   //if(nowrap_a) printf("a\n");
423406
424   if (enable_a && suprnova_alt_enable_background)
407   if (enable_a && state->m_alt_enable_background)
425408   {
426      startx = skns_v3_regs[0x1c/4];
427      incyy  = skns_v3_regs[0x30/4]&0x7ffff;
409      startx = state->m_v3_regs[0x1c/4];
410      incyy  = state->m_v3_regs[0x30/4]&0x7ffff;
428411      if (incyy&0x40000) incyy = incyy-0x80000; // level 3 boss in sengekis
429      incyx  = skns_v3_regs[0x2c/4];
430      starty = skns_v3_regs[0x20/4];
431      incxy  = skns_v3_regs[0x28/4];
432      incxx  = skns_v3_regs[0x24/4]&0x7ffff;
412      incyx  = state->m_v3_regs[0x2c/4];
413      starty = state->m_v3_regs[0x20/4];
414      incxy  = state->m_v3_regs[0x28/4];
415      incxx  = state->m_v3_regs[0x24/4]&0x7ffff;
433416      if (incxx&0x40000) incxx = incxx-0x80000;
434417
435      columnscroll = (skns_v3_regs[0x0c/4] >> 1) & 0x0001;
418      columnscroll = (state->m_v3_regs[0x0c/4] >> 1) & 0x0001;
436419
437      suprnova_draw_roz(bitmap,bitmap_flags,cliprect, skns_tilemap_A, startx << 8,starty << 8,   incxx << 8,incxy << 8,incyx << 8,incyy << 8, !nowrap_a, columnscroll, &skns_v3slc_ram[0]);
438      //tilemap_copy_bitmap(bitmap, tilemap_bitmap_lower, tilemap_bitmapflags_lower);
420      suprnova_draw_roz(bitmap,bitmap_flags,cliprect, state->m_tilemap_A, startx << 8,starty << 8,   incxx << 8,incxy << 8,incyx << 8,incyy << 8, !nowrap_a, columnscroll, &state->m_v3slc_ram[0]);
421      //tilemap_copy_bitmap(bitmap, state->m_tilemap_bitmap_lower, state->m_tilemap_bitmapflags_lower);
439422   }
440423}
441424
442static void supernova_draw_b( bitmap_t *bitmap, bitmap_t* bitmap_flags, const rectangle *cliprect, int tran )
425static void supernova_draw_b( running_machine &machine, bitmap_t *bitmap, bitmap_t* bitmap_flags, const rectangle *cliprect, int tran )
443426{
444   int enable_b  = (skns_v3_regs[0x34/4] >> 0) & 0x0001;
445   int nowrap_b = (skns_v3_regs[0x34/4] >> 0) & 0x0004;
427   skns_state *state = machine.driver_data<skns_state>();
428   int enable_b  = (state->m_v3_regs[0x34/4] >> 0) & 0x0001;
429   int nowrap_b = (state->m_v3_regs[0x34/4] >> 0) & 0x0004;
446430
447431
448432   UINT32 startx,starty;
r11160r11161
451435
452436   //if(nowrap_b) printf("b\n");
453437
454   if (enable_b && suprnova_alt_enable_background)
438   if (enable_b && state->m_alt_enable_background)
455439   {
456      startx = skns_v3_regs[0x40/4];
457      incyy  = skns_v3_regs[0x54/4]&0x7ffff;
440      startx = state->m_v3_regs[0x40/4];
441      incyy  = state->m_v3_regs[0x54/4]&0x7ffff;
458442      if (incyy&0x40000) incyy = incyy-0x80000;
459      incyx  = skns_v3_regs[0x50/4];
460      starty = skns_v3_regs[0x44/4];
461      incxy  = skns_v3_regs[0x4c/4];
462      incxx  = skns_v3_regs[0x48/4]&0x7ffff;
443      incyx  = state->m_v3_regs[0x50/4];
444      starty = state->m_v3_regs[0x44/4];
445      incxy  = state->m_v3_regs[0x4c/4];
446      incxx  = state->m_v3_regs[0x48/4]&0x7ffff;
463447      if (incxx&0x40000) incxx = incxx-0x80000;
464      columnscroll = (skns_v3_regs[0x0c/4] >> 9) & 0x0001; // selects column scroll or rowscroll
465      suprnova_draw_roz(bitmap,bitmap_flags, cliprect, skns_tilemap_B, startx << 8,starty << 8,   incxx << 8,incxy << 8,incyx << 8,incyy << 8, !nowrap_b, columnscroll, &skns_v3slc_ram[0x1000/4]);
448      columnscroll = (state->m_v3_regs[0x0c/4] >> 9) & 0x0001; // selects column scroll or rowscroll
449      suprnova_draw_roz(bitmap,bitmap_flags, cliprect, state->m_tilemap_B, startx << 8,starty << 8,   incxx << 8,incxy << 8,incyx << 8,incyy << 8, !nowrap_b, columnscroll, &state->m_v3slc_ram[0x1000/4]);
466450
467451      //popmessage("%08x %08x %08x %08x %08x %08x", startx, starty, incxx, incyy, incxy, incyx);
468452
r11160r11161
476460   palette_update(screen->machine());
477461
478462   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine()));
479   bitmap_fill(tilemap_bitmap_lower, NULL, 0);
480   bitmap_fill(tilemap_bitmapflags_lower, NULL, 0);
481   bitmap_fill(tilemap_bitmap_higher, NULL, 0);
482   bitmap_fill(tilemap_bitmapflags_higher, NULL, 0);
463   bitmap_fill(state->m_tilemap_bitmap_lower, NULL, 0);
464   bitmap_fill(state->m_tilemap_bitmapflags_lower, NULL, 0);
465   bitmap_fill(state->m_tilemap_bitmap_higher, NULL, 0);
466   bitmap_fill(state->m_tilemap_bitmapflags_higher, NULL, 0);
483467
484468   {
485469      int supernova_pri_a;
486470      int supernova_pri_b;
487471      int tran = 0;
488472
489      supernova_pri_a = (skns_v3_regs[0x10/4] & 0x0002)>>1;
490      supernova_pri_b = (skns_v3_regs[0x34/4] & 0x0002)>>1;
473      supernova_pri_a = (state->m_v3_regs[0x10/4] & 0x0002)>>1;
474      supernova_pri_b = (state->m_v3_regs[0x34/4] & 0x0002)>>1;
491475
492476      //popmessage("pri %d %d\n", supernova_pri_a, supernova_pri_b);
493477
494478      /*if (!supernova_pri_b) { */
495      supernova_draw_b(tilemap_bitmap_lower, tilemap_bitmapflags_lower, cliprect,tran);// tran = 1;
496      supernova_draw_a(tilemap_bitmap_higher,tilemap_bitmapflags_higher,cliprect,tran);// tran = 1;
479      supernova_draw_b(screen->machine(), state->m_tilemap_bitmap_lower, state->m_tilemap_bitmapflags_lower, cliprect,tran);// tran = 1;
480      supernova_draw_a(screen->machine(), state->m_tilemap_bitmap_higher,state->m_tilemap_bitmapflags_higher,cliprect,tran);// tran = 1;
497481
498482      {
499483         int x,y;
r11160r11161
508492
509493         for (y=0;y<240;y++)
510494         {
511            src = BITMAP_ADDR16(tilemap_bitmap_lower, y, 0);
512            srcflags = BITMAP_ADDR8(tilemap_bitmapflags_lower, y, 0);
495            src = BITMAP_ADDR16(state->m_tilemap_bitmap_lower, y, 0);
496            srcflags = BITMAP_ADDR8(state->m_tilemap_bitmapflags_lower, y, 0);
513497
514            src2 = BITMAP_ADDR16(tilemap_bitmap_higher, y, 0);
515            src2flags = BITMAP_ADDR8(tilemap_bitmapflags_higher, y, 0);
498            src2 = BITMAP_ADDR16(state->m_tilemap_bitmap_higher, y, 0);
499            src2flags = BITMAP_ADDR8(state->m_tilemap_bitmapflags_higher, y, 0);
516500
517            src3 = BITMAP_ADDR16(sprite_bitmap, y, 0);
501            src3 = BITMAP_ADDR16(state->m_sprite_bitmap, y, 0);
518502
519503            dst = BITMAP_ADDR32(bitmap, y, 0);
520504
r11160r11161
583567                  if (pendata3&0xff)
584568                  {
585569
586                     UINT16 palvalue = skns_palette_ram[pendata3];
570                     UINT16 palvalue = state->m_palette_ram[pendata3];
587571
588572                     coldat = clut[pendata3];
589573
r11160r11161
603587                        g2 = (dstcolour & 0x0000ff00)>> 8;
604588                        b2 = (dstcolour & 0x00ff0000)>> 16;
605589
606                        r2 = (r2 * bright_spc_r_trans) >> 8;
607                        g2 = (g2 * bright_spc_g_trans) >> 8;
608                        b2 = (b2 * bright_spc_b_trans) >> 8;
590                        r2 = (r2 * state->m_bright_spc_r_trans) >> 8;
591                        g2 = (g2 * state->m_bright_spc_g_trans) >> 8;
592                        b2 = (b2 * state->m_bright_spc_b_trans) >> 8;
609593
610594                        r = (r+r2);
611595                        if (r>255) r = 255;
r11160r11161
644628      }
645629   }
646630
647   bitmap_fill(sprite_bitmap, cliprect, 0x0000);
631   bitmap_fill(state->m_sprite_bitmap, cliprect, 0x0000);
648632
649   if (suprnova_alt_enable_sprites)
650      state->m_spritegen->skns_draw_sprites(screen->machine(), sprite_bitmap, cliprect, screen->machine().generic.spriteram.u32, screen->machine().generic.spriteram_size, screen->machine().region("gfx1")->base(), screen->machine().region ("gfx1")->bytes(), skns_spc_regs );
633   if (state->m_alt_enable_sprites)
634      state->m_spritegen->skns_draw_sprites(screen->machine(), state->m_sprite_bitmap, cliprect, screen->machine().generic.spriteram.u32, screen->machine().generic.spriteram_size, screen->machine().region("gfx1")->base(), screen->machine().region ("gfx1")->bytes(), state->m_spc_regs );
651635
652636
653637   return 0;
src/mame/video/fastfred.c
r11160r11161
99#include "emu.h"
1010#include "video/resnet.h"
1111#include "includes/fastfred.h"
12#include "includes/galaxold.h"
1312
1413
1514
1615static const rectangle spritevisiblearea =
1716{
18      2*8, 32*8-1,
19      2*8, 30*8-1
17   2*8, 32*8-1,
18   2*8, 30*8-1
2019};
2120
2221static const rectangle spritevisibleareaflipx =
r11160r11161
371370
372371   /* the game has a galaxian starfield */
373372   galaxold_init_stars(machine, 256);
374   galaxold_stars_on = 1;
373   state->m_stars_on = 1;
375374
376375   /* web colors */
377376   palette_set_color(machine,256+64+0,MAKE_RGB(0x50,0x00,0x00));
src/mame/video/shuuz.c
r11160r11161
55****************************************************************************/
66
77#include "emu.h"
8#include "video/atarimo.h"
89#include "includes/shuuz.h"
910
1011
src/mame/video/kaneko16.c
r11160r11161
3535#include "includes/kaneko16.h"
3636#include "kan_pand.h"
3737
38static UINT16 kaneko16_disp_enable;
3938
40
41static tilemap_t *kaneko16_tmap_0, *kaneko16_tmap_1;
42static tilemap_t *kaneko16_tmap_2, *kaneko16_tmap_3;
43UINT16 *kaneko16_vram_0,    *kaneko16_vram_1,    *kaneko16_layers_0_regs;
44UINT16 *kaneko16_vscroll_0, *kaneko16_vscroll_1;
45UINT16 *kaneko16_vram_2,    *kaneko16_vram_3,    *kaneko16_layers_1_regs;
46UINT16 *kaneko16_vscroll_2, *kaneko16_vscroll_3;
47
48UINT16* galsnew_bg_pixram;
49UINT16* galsnew_fg_pixram;
50
51int kaneko16_sprite_type;
52int kaneko16_sprite_fliptype;
53static int kaneko16_keep_sprites;
54UINT16 kaneko16_sprite_xoffs, kaneko16_sprite_flipx;
55UINT16 kaneko16_sprite_yoffs, kaneko16_sprite_flipy;
56UINT16 *kaneko16_sprites_regs;
57
58UINT8 kaneko16_nvram_save[128];
59
60UINT16 *kaneko16_bg15_select, *kaneko16_bg15_reg;
61static bitmap_t *kaneko16_bg15_bitmap;
62static bitmap_t *sprites_bitmap; /* bitmap used for to keep sprites on screen (mgcrystl 1st boss) */
63
6439struct tempsprite
6540{
6641   int code,color;
r11160r11161
7045   int priority;
7146};
7247
73static struct
74{
75   struct tempsprite *first_sprite;
76}   spritelist;
7748
78
79kaneko16_priority_t kaneko16_priority;
80
81
8249WRITE16_HANDLER( kaneko16_display_enable )
8350{
84   COMBINE_DATA(&kaneko16_disp_enable);
51   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
52   COMBINE_DATA(&state->m_disp_enable);
8553}
8654
8755/***************************************************************************
r11160r11161
10371
10472***************************************************************************/
10573
106#define KANEKO16_LAYER(_N_) \
107static TILE_GET_INFO( get_tile_info_##_N_ ) \
108{ \
109   UINT16 code_hi = kaneko16_vram_##_N_[ 2 * tile_index + 0]; \
110   UINT16 code_lo = kaneko16_vram_##_N_[ 2 * tile_index + 1]; \
111   SET_TILE_INFO(1 + _N_/2, code_lo, (code_hi >> 2) & 0x3f, TILE_FLIPXY( code_hi & 3 )); \
112   tileinfo->category   =   (code_hi >> 8) & 7; \
113} \
114\
115WRITE16_HANDLER( kaneko16_vram_##_N_##_w ) \
116{ \
117   COMBINE_DATA(&kaneko16_vram_##_N_[offset]); \
118   tilemap_mark_tile_dirty(kaneko16_tmap_##_N_, offset/2); \
74INLINE void get_tile_info(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, int _N_)
75{
76   kaneko16_state *state = machine.driver_data<kaneko16_state>();
77   UINT16 code_hi = state->m_vram[_N_][ 2 * tile_index + 0];
78   UINT16 code_lo = state->m_vram[_N_][ 2 * tile_index + 1];
79   SET_TILE_INFO(1 + _N_/2, code_lo, (code_hi >> 2) & 0x3f, TILE_FLIPXY( code_hi & 3 ));
80   tileinfo->category   =   (code_hi >> 8) & 7;
11981}
12082
83static TILE_GET_INFO( get_tile_info_0 ) { get_tile_info(machine, tileinfo, tile_index, 0); }
84static TILE_GET_INFO( get_tile_info_1 ) { get_tile_info(machine, tileinfo, tile_index, 1); }
85static TILE_GET_INFO( get_tile_info_2 ) { get_tile_info(machine, tileinfo, tile_index, 2); }
86static TILE_GET_INFO( get_tile_info_3 ) { get_tile_info(machine, tileinfo, tile_index, 3); }
12187
122KANEKO16_LAYER(0)
123KANEKO16_LAYER(1)
124KANEKO16_LAYER(2)
125KANEKO16_LAYER(3)
88INLINE void kaneko16_vram_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int _N_)
89{
90   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
91   COMBINE_DATA(&state->m_vram[_N_][offset]);
92   tilemap_mark_tile_dirty(state->m_tmap[_N_], offset/2);
93}
12694
95WRITE16_HANDLER( kaneko16_vram_0_w ) { kaneko16_vram_w(space, offset, data, mem_mask, 0); }
96WRITE16_HANDLER( kaneko16_vram_1_w ) { kaneko16_vram_w(space, offset, data, mem_mask, 1); }
97WRITE16_HANDLER( kaneko16_vram_2_w ) { kaneko16_vram_w(space, offset, data, mem_mask, 2); }
98WRITE16_HANDLER( kaneko16_vram_3_w ) { kaneko16_vram_w(space, offset, data, mem_mask, 3); }
99
127100VIDEO_START( kaneko16_sprites )
128101{
129   kaneko16_disp_enable = 1;   // default enabled for games not using it
130   kaneko16_keep_sprites = 0;   // default disabled for games not using it
102   kaneko16_state *state = machine.driver_data<kaneko16_state>();
103   state->m_disp_enable = 1;   // default enabled for games not using it
104   state->m_keep_sprites = 0;   // default disabled for games not using it
131105
132106   /* 0x400 sprites max */
133   spritelist.first_sprite = auto_alloc_array(machine, struct tempsprite, 0x400);
107   state->m_first_sprite = auto_alloc_array(machine, struct tempsprite, 0x400);
134108}
135109
136110VIDEO_START( kaneko16_1xVIEW2_tilemaps )
137111{
138   kaneko16_disp_enable = 1; // default enabled for games not using it
139   kaneko16_keep_sprites = 0;   // default disabled for games not using it
112   kaneko16_state *state = machine.driver_data<kaneko16_state>();
113   state->m_disp_enable = 1; // default enabled for games not using it
114   state->m_keep_sprites = 0;   // default disabled for games not using it
140115
141   kaneko16_tmap_0 = tilemap_create(   machine, get_tile_info_0, tilemap_scan_rows,
116   state->m_tmap[0] = tilemap_create(   machine, get_tile_info_0, tilemap_scan_rows,
142117                               16,16, 0x20,0x20   );
143   kaneko16_tmap_1 = tilemap_create(   machine, get_tile_info_1, tilemap_scan_rows,
118   state->m_tmap[1] = tilemap_create(   machine, get_tile_info_1, tilemap_scan_rows,
144119                               16,16, 0x20,0x20   );
145120
146   kaneko16_tmap_2 = 0;
121   state->m_tmap[2] = 0;
147122
148   kaneko16_tmap_3 = 0;
123   state->m_tmap[3] = 0;
149124
150   sprites_bitmap = machine.primary_screen->alloc_compatible_bitmap();
125   state->m_sprites_bitmap = machine.primary_screen->alloc_compatible_bitmap();
151126
152127   {
153128      int dx, dy;
r11160r11161
168143         default:      dy = 0;
169144      }
170145
171      tilemap_set_scrolldx( kaneko16_tmap_0, -dx,      xdim + dx -1        );
172      tilemap_set_scrolldx( kaneko16_tmap_1, -(dx+2),   xdim + (dx + 2) - 1 );
146      tilemap_set_scrolldx( state->m_tmap[0], -dx,      xdim + dx -1        );
147      tilemap_set_scrolldx( state->m_tmap[1], -(dx+2),   xdim + (dx + 2) - 1 );
173148
174      tilemap_set_scrolldy( kaneko16_tmap_0, -dy,      ydim + dy -1 );
175      tilemap_set_scrolldy( kaneko16_tmap_1, -dy,      ydim + dy -1 );
149      tilemap_set_scrolldy( state->m_tmap[0], -dy,      ydim + dy -1 );
150      tilemap_set_scrolldy( state->m_tmap[1], -dy,      ydim + dy -1 );
176151
177      tilemap_set_transparent_pen(kaneko16_tmap_0, 0);
178      tilemap_set_transparent_pen(kaneko16_tmap_1, 0);
152      tilemap_set_transparent_pen(state->m_tmap[0], 0);
153      tilemap_set_transparent_pen(state->m_tmap[1], 0);
179154
180      tilemap_set_scroll_rows(kaneko16_tmap_0, 0x200);   // Line Scroll
181      tilemap_set_scroll_rows(kaneko16_tmap_1, 0x200);
155      tilemap_set_scroll_rows(state->m_tmap[0], 0x200);   // Line Scroll
156      tilemap_set_scroll_rows(state->m_tmap[1], 0x200);
182157   }
183158
184159}
r11160r11161
193168
194169VIDEO_START( kaneko16_2xVIEW2 )
195170{
171   kaneko16_state *state = machine.driver_data<kaneko16_state>();
196172   VIDEO_START_CALL(kaneko16_1xVIEW2);
197173
198   kaneko16_tmap_2 = tilemap_create(   machine, get_tile_info_2, tilemap_scan_rows,
174   state->m_tmap[2] = tilemap_create(   machine, get_tile_info_2, tilemap_scan_rows,
199175                               16,16, 0x20,0x20   );
200   kaneko16_tmap_3 = tilemap_create(   machine, get_tile_info_3, tilemap_scan_rows,
176   state->m_tmap[3] = tilemap_create(   machine, get_tile_info_3, tilemap_scan_rows,
201177                               16,16, 0x20,0x20   );
202178
203179   {
r11160r11161
219195         default:      dy = 0;
220196      }
221197
222      tilemap_set_scrolldx( kaneko16_tmap_2, -dx,      xdim + dx -1        );
223      tilemap_set_scrolldx( kaneko16_tmap_3, -(dx+2),   xdim + (dx + 2) - 1 );
198      tilemap_set_scrolldx( state->m_tmap[2], -dx,      xdim + dx -1        );
199      tilemap_set_scrolldx( state->m_tmap[3], -(dx+2),   xdim + (dx + 2) - 1 );
224200
225      tilemap_set_scrolldy( kaneko16_tmap_2, -dy,      ydim + dy -1 );
226      tilemap_set_scrolldy( kaneko16_tmap_3, -dy,      ydim + dy -1 );
201      tilemap_set_scrolldy( state->m_tmap[2], -dy,      ydim + dy -1 );
202      tilemap_set_scrolldy( state->m_tmap[3], -dy,      ydim + dy -1 );
227203
228      tilemap_set_transparent_pen(kaneko16_tmap_2, 0);
229      tilemap_set_transparent_pen(kaneko16_tmap_3, 0);
204      tilemap_set_transparent_pen(state->m_tmap[2], 0);
205      tilemap_set_transparent_pen(state->m_tmap[3], 0);
230206
231      tilemap_set_scroll_rows(kaneko16_tmap_2, 0x200);   // Line Scroll
232      tilemap_set_scroll_rows(kaneko16_tmap_3, 0x200);
207      tilemap_set_scroll_rows(state->m_tmap[2], 0x200);   // Line Scroll
208      tilemap_set_scroll_rows(state->m_tmap[3], 0x200);
233209   }
234210}
235211
236212VIDEO_START( sandscrp_1xVIEW2 )
237213{
214   kaneko16_state *state = machine.driver_data<kaneko16_state>();
238215   VIDEO_START_CALL(kaneko16_1xVIEW2);
239216
240   tilemap_set_scrolldy( kaneko16_tmap_0, 0, 256 - 1 );
241   tilemap_set_scrolldy( kaneko16_tmap_1, 0, 256 - 1 );
217   tilemap_set_scrolldy( state->m_tmap[0], 0, 256 - 1 );
218   tilemap_set_scrolldy( state->m_tmap[1], 0, 256 - 1 );
242219}
243220
244221
r11160r11161
258235
259236VIDEO_START( berlwall )
260237{
238   kaneko16_state *state = machine.driver_data<kaneko16_state>();
261239   int sx, x,y;
262240   UINT8 *RAM   =   machine.region("gfx3")->base();
263241
264242   /* Render the hi-color static backgrounds held in the ROMs */
265243
266   kaneko16_bg15_bitmap = auto_bitmap_alloc(machine, 256 * 32, 256 * 1, BITMAP_FORMAT_INDEXED16);
244   state->m_bg15_bitmap = auto_bitmap_alloc(machine, 256 * 32, 256 * 1, BITMAP_FORMAT_INDEXED16);
267245
268246/*
269247    8aba is used as background color
r11160r11161
296274         if ((r & 0x10) && (b & 0x10))
297275            g = (g - 1) & 0x1f;      /* decrease with wraparound */
298276
299         *BITMAP_ADDR16(kaneko16_bg15_bitmap, y, sx * 256 + x) = 2048 + ((g << 10) | (r << 5) | b);
277         *BITMAP_ADDR16(state->m_bg15_bitmap, y, sx * 256 + x) = 2048 + ((g << 10) | (r << 5) | b);
300278     }
301279
302280   VIDEO_START_CALL(kaneko16_1xVIEW2);
r11160r11161
304282
305283VIDEO_START( galsnew )
306284{
285   kaneko16_state *state = machine.driver_data<kaneko16_state>();
307286   VIDEO_START_CALL(kaneko16_sprites);
308287
309   kaneko16_tmap_0 = tilemap_create(   machine, get_tile_info_0, tilemap_scan_rows,
288   state->m_tmap[0] = tilemap_create(   machine, get_tile_info_0, tilemap_scan_rows,
310289                               16,16, 0x20,0x20   );
311   kaneko16_tmap_1 = tilemap_create(   machine, get_tile_info_1, tilemap_scan_rows,
290   state->m_tmap[1] = tilemap_create(   machine, get_tile_info_1, tilemap_scan_rows,
312291                               16,16, 0x20,0x20   );
313292
314   kaneko16_tmap_2 = 0;
293   state->m_tmap[2] = 0;
315294
316   kaneko16_tmap_3 = 0;
295   state->m_tmap[3] = 0;
317296
318   sprites_bitmap = machine.primary_screen->alloc_compatible_bitmap();
297   state->m_sprites_bitmap = machine.primary_screen->alloc_compatible_bitmap();
319298
320299   {
321300      int dx = 0x5b, dy = 8;
r11160r11161
323302      int xdim = machine.primary_screen->width();
324303      int ydim = machine.primary_screen->height();
325304
326      tilemap_set_scrolldx( kaneko16_tmap_0, -dx,      xdim + dx -1        );
327      tilemap_set_scrolldx( kaneko16_tmap_1, -(dx+2),   xdim + (dx + 2) - 1 );
305      tilemap_set_scrolldx( state->m_tmap[0], -dx,      xdim + dx -1        );
306      tilemap_set_scrolldx( state->m_tmap[1], -(dx+2),   xdim + (dx + 2) - 1 );
328307
329      tilemap_set_scrolldy( kaneko16_tmap_0, -dy,      ydim + dy -1 );
330      tilemap_set_scrolldy( kaneko16_tmap_1, -dy,      ydim + dy -1 );
308      tilemap_set_scrolldy( state->m_tmap[0], -dy,      ydim + dy -1 );
309      tilemap_set_scrolldy( state->m_tmap[1], -dy,      ydim + dy -1 );
331310
332      tilemap_set_transparent_pen(kaneko16_tmap_0, 0);
333      tilemap_set_transparent_pen(kaneko16_tmap_1, 0);
311      tilemap_set_transparent_pen(state->m_tmap[0], 0);
312      tilemap_set_transparent_pen(state->m_tmap[1], 0);
334313
335      tilemap_set_scroll_rows(kaneko16_tmap_0, 0x200);   // Line Scroll
336      tilemap_set_scroll_rows(kaneko16_tmap_1, 0x200);
314      tilemap_set_scroll_rows(state->m_tmap[0], 0x200);   // Line Scroll
315      tilemap_set_scroll_rows(state->m_tmap[1], 0x200);
337316   }
338317}
339318
r11160r11161
391370
392371static int kaneko16_parse_sprite_type012(running_machine &machine, int i, struct tempsprite *s)
393372{
373   kaneko16_state *state = machine.driver_data<kaneko16_state>();
394374   UINT16 *spriteram16 = machine.generic.spriteram.u16;
395375   int attr, xoffs, offs;
396376
397   if (kaneko16_sprite_type == 2)   offs = i * 16/2 + 0x8/2;
377   if (state->m_sprite_type == 2)   offs = i * 16/2 + 0x8/2;
398378   else                     offs = i * 8/2;
399379
400380   if (offs >= (machine.generic.spriteram_size/2))   return -1;
r11160r11161
404384   s->x         =      spriteram16[offs + 2];
405385   s->y         =      spriteram16[offs + 3];
406386
407   if (kaneko16_sprite_type == 1)
387   if (state->m_sprite_type == 1)
408388   {
409389   s->color      =      (attr & 0x003f);
410390   s->priority      =      (attr & 0x00c0) >> 6;
r11160r11161
420400   s->priority      =      (attr & 0x0300) >> 8;
421401   }
422402   xoffs         =      (attr & 0x1800) >> 11;
423   s->yoffs      =      kaneko16_sprites_regs[0x10/2 + xoffs*2 + 1];
424   s->xoffs      =      kaneko16_sprites_regs[0x10/2 + xoffs*2 + 0];
403   s->yoffs      =      state->m_sprites_regs[0x10/2 + xoffs*2 + 1];
404   s->xoffs      =      state->m_sprites_regs[0x10/2 + xoffs*2 + 0];
425405
426if (kaneko16_sprite_flipy)
406if (state->m_sprite_flipy)
427407{
428   s->yoffs      -=      kaneko16_sprites_regs[0x2/2];
408   s->yoffs      -=      state->m_sprites_regs[0x2/2];
429409   s->yoffs      -=      machine.primary_screen->visible_area().min_y<<6;
430410}
431411else
432412{
433   s->yoffs      -=      kaneko16_sprites_regs[0x2/2];
413   s->yoffs      -=      state->m_sprites_regs[0x2/2];
434414   s->yoffs      +=      machine.primary_screen->visible_area().min_y<<6;
435415}
436416
r11160r11161
542522
543523void kaneko16_draw_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
544524{
525   kaneko16_state *state = machine.driver_data<kaneko16_state>();
545526   /* Sprites *must* be parsed from the first in RAM to the last,
546527       because of the multisprite feature. But they *must* be drawn
547528       from the last in RAM (frontmost) to the first in order to
r11160r11161
554535   int max   =   (machine.primary_screen->width() > 0x100) ? (0x200<<6) : (0x100<<6);
555536
556537   int i = 0;
557   struct tempsprite *s = spritelist.first_sprite;
538   struct tempsprite *s = state->m_first_sprite;
558539
559540   /* These values are latched from the last sprite. */
560541   int x         =   0;
r11160r11161
571552   {
572553      int flags;
573554
574      switch( kaneko16_sprite_type )
555      switch( state->m_sprite_type )
575556      {
576557         case 0:
577558         case 1:
r11160r11161
595576         s->xoffs      =   xoffs;
596577         s->yoffs      =   yoffs;
597578
598         if (kaneko16_sprite_fliptype==0)
579         if (state->m_sprite_fliptype==0)
599580         {
600581            s->flipx      =   flipx;
601582            s->flipy      =   flipy;
r11160r11161
608589         xoffs      =   s->xoffs;
609590         yoffs      =   s->yoffs;
610591
611         if (kaneko16_sprite_fliptype==0)
592         if (state->m_sprite_fliptype==0)
612593         {
613594            flipx = s->flipx;
614595            flipy = s->flipy;
r11160r11161
616597      }
617598
618599      // brap boys explicitly doesn't want the flip to be latched, maybe there is a different bit to enable that behavior?
619      if (kaneko16_sprite_fliptype==1)
600      if (state->m_sprite_fliptype==1)
620601      {
621602         flipx      =   s->flipx;
622603         flipy      =   s->flipy;
r11160r11161
636617      s->x   =   s->xoffs + s->x;
637618      s->y   =   s->yoffs + s->y;
638619
639      s->x   +=   kaneko16_sprite_xoffs;
640      s->y   +=   kaneko16_sprite_yoffs;
620      s->x   +=   state->m_sprite_xoffs;
621      s->y   +=   state->m_sprite_yoffs;
641622
642      if (kaneko16_sprite_flipx)   { s->x = max - s->x - (16<<6);   s->flipx = !s->flipx;   }
643      if (kaneko16_sprite_flipy)   { s->y = max - s->y - (16<<6);   s->flipy = !s->flipy;   }
623      if (state->m_sprite_flipx)   { s->x = max - s->x - (16<<6);   s->flipx = !s->flipx;   }
624      if (state->m_sprite_flipy)   { s->y = max - s->y - (16<<6);   s->flipy = !s->flipy;   }
644625
645626      s->x      =      ( (s->x & 0x7fc0) - (s->x & 0x8000) ) / 0x40;
646627      s->y      =      ( (s->y & 0x7fc0) - (s->y & 0x8000) ) / 0x40;
r11160r11161
653634   /* Let's finally draw the sprites we buffered, in reverse order
654635       (for pdrawgfx) */
655636
656   for (s--; s >= spritelist.first_sprite; s--)
637   for (s--; s >= state->m_first_sprite; s--)
657638   {
658639      int curr_pri = s->priority;
659640
660      UINT32 primask = kaneko16_priority.sprite[curr_pri];
641      UINT32 primask = state->m_priority.sprite[curr_pri];
661642
662643      kaneko16_draw_sprites_custom(
663644                              bitmap,cliprect,machine.gfx[0],
r11160r11161
741722
742723READ16_HANDLER( kaneko16_sprites_regs_r )
743724{
744   return kaneko16_sprites_regs[offset];
725   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
726   return state->m_sprites_regs[offset];
745727}
746728
747729WRITE16_HANDLER( kaneko16_sprites_regs_w )
748730{
731   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
749732   UINT16 new_data;
750733
751   COMBINE_DATA(&kaneko16_sprites_regs[offset]);
752   new_data  = kaneko16_sprites_regs[offset];
734   COMBINE_DATA(&state->m_sprites_regs[offset]);
735   new_data  = state->m_sprites_regs[offset];
753736
754737   switch (offset)
755738   {
756739      case 0:
757740         if (ACCESSING_BITS_0_7)
758741         {
759            kaneko16_sprite_flipx = new_data & 2;
760            kaneko16_sprite_flipy = new_data & 1;
742            state->m_sprite_flipx = new_data & 2;
743            state->m_sprite_flipy = new_data & 1;
761744
762            if(kaneko16_sprite_type == 0 || kaneko16_sprite_type == 2)
763               kaneko16_keep_sprites = ~new_data & 4;
745            if(state->m_sprite_type == 0 || state->m_sprite_type == 2)
746               state->m_keep_sprites = ~new_data & 4;
764747         }
765748
766749         break;
r11160r11161
824807
825808WRITE16_HANDLER( kaneko16_layers_0_regs_w )
826809{
827   COMBINE_DATA(&kaneko16_layers_0_regs[offset]);
810   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
811   COMBINE_DATA(&state->m_layers_0_regs[offset]);
828812}
829813
830814WRITE16_HANDLER( kaneko16_layers_1_regs_w )
831815{
832   COMBINE_DATA(&kaneko16_layers_1_regs[offset]);
816   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
817   COMBINE_DATA(&state->m_layers_1_regs[offset]);
833818}
834819
835820
r11160r11161
838823/* Select the high color background image (out of 32 in the ROMs) */
839824READ16_HANDLER( kaneko16_bg15_select_r )
840825{
841   return kaneko16_bg15_select[0];
826   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
827   return state->m_bg15_select[0];
842828}
843829WRITE16_HANDLER( kaneko16_bg15_select_w )
844830{
845   COMBINE_DATA(&kaneko16_bg15_select[0]);
831   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
832   COMBINE_DATA(&state->m_bg15_select[0]);
846833}
847834
848835/* ? */
849836READ16_HANDLER( kaneko16_bg15_reg_r )
850837{
851   return kaneko16_bg15_reg[0];
838   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
839   return state->m_bg15_reg[0];
852840}
853841WRITE16_HANDLER( kaneko16_bg15_reg_w )
854842{
855   COMBINE_DATA(&kaneko16_bg15_reg[0]);
843   kaneko16_state *state = space->machine().driver_data<kaneko16_state>();
844   COMBINE_DATA(&state->m_bg15_reg[0]);
856845}
857846
858847
r11160r11161
868857
869858static void kaneko16_prepare_first_tilemap_chip(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
870859{
860   kaneko16_state *state = machine.driver_data<kaneko16_state>();
871861   /* Set Up FIRST Tilemap chip */
872862   int layers_flip_0;
873863   UINT16 layer0_scrollx, layer0_scrolly;
874864   UINT16 layer1_scrollx, layer1_scrolly;
875865   int i;
876866
877   layers_flip_0 = kaneko16_layers_0_regs[ 4 ];
867   layers_flip_0 = state->m_layers_0_regs[ 4 ];
878868
879869   /* Enable layers */
880   tilemap_set_enable(kaneko16_tmap_0, ~layers_flip_0 & 0x1000);
881   tilemap_set_enable(kaneko16_tmap_1, ~layers_flip_0 & 0x0010);
870   tilemap_set_enable(state->m_tmap[0], ~layers_flip_0 & 0x1000);
871   tilemap_set_enable(state->m_tmap[1], ~layers_flip_0 & 0x0010);
882872
883873   /* Flip layers */
884   tilemap_set_flip(kaneko16_tmap_0,   ((layers_flip_0 & 0x0100) ? TILEMAP_FLIPY : 0) |
874   tilemap_set_flip(state->m_tmap[0],   ((layers_flip_0 & 0x0100) ? TILEMAP_FLIPY : 0) |
885875                              ((layers_flip_0 & 0x0200) ? TILEMAP_FLIPX : 0) );
886   tilemap_set_flip(kaneko16_tmap_1,   ((layers_flip_0 & 0x0100) ? TILEMAP_FLIPY : 0) |
876   tilemap_set_flip(state->m_tmap[1],   ((layers_flip_0 & 0x0100) ? TILEMAP_FLIPY : 0) |
887877                              ((layers_flip_0 & 0x0200) ? TILEMAP_FLIPX : 0) );
888878
889879   /* Scroll layers */
890   layer0_scrollx      =   kaneko16_layers_0_regs[ 2 ];
891   layer0_scrolly      =   kaneko16_layers_0_regs[ 3 ] >> 6;
892   layer1_scrollx      =   kaneko16_layers_0_regs[ 0 ];
893   layer1_scrolly      =   kaneko16_layers_0_regs[ 1 ] >> 6;
880   layer0_scrollx      =   state->m_layers_0_regs[ 2 ];
881   layer0_scrolly      =   state->m_layers_0_regs[ 3 ] >> 6;
882   layer1_scrollx      =   state->m_layers_0_regs[ 0 ];
883   layer1_scrolly      =   state->m_layers_0_regs[ 1 ] >> 6;
894884
895   tilemap_set_scrolly(kaneko16_tmap_0,0,layer0_scrolly);
896   tilemap_set_scrolly(kaneko16_tmap_1,0,layer1_scrolly);
885   tilemap_set_scrolly(state->m_tmap[0],0,layer0_scrolly);
886   tilemap_set_scrolly(state->m_tmap[1],0,layer1_scrolly);
897887
898888   for (i=0; i<0x200; i++)
899889   {
900890      UINT16 scroll;
901      scroll = (layers_flip_0 & 0x0800) ? kaneko16_vscroll_0[i] : 0;
902      tilemap_set_scrollx(kaneko16_tmap_0,i,(layer0_scrollx + scroll) >> 6 );
903      scroll = (layers_flip_0 & 0x0008) ? kaneko16_vscroll_1[i] : 0;
904      tilemap_set_scrollx(kaneko16_tmap_1,i,(layer1_scrollx + scroll) >> 6 );
891      scroll = (layers_flip_0 & 0x0800) ? state->m_vscroll[0][i] : 0;
892      tilemap_set_scrollx(state->m_tmap[0],i,(layer0_scrollx + scroll) >> 6 );
893      scroll = (layers_flip_0 & 0x0008) ? state->m_vscroll[1][i] : 0;
894      tilemap_set_scrollx(state->m_tmap[1],i,(layer1_scrollx + scroll) >> 6 );
905895   }
906896
907897}
908898
909899static void kaneko16_prepare_second_tilemap_chip(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
910900{
901   kaneko16_state *state = machine.driver_data<kaneko16_state>();
911902   /* Set Up SECOND Tilemap chip */
912903   int layers_flip_1 = 0;
913904   UINT16 layer0_scrollx, layer0_scrolly;
914905   UINT16 layer1_scrollx, layer1_scrolly;
915906   int i;
916907
917   if (kaneko16_tmap_2)
908   if (state->m_tmap[2])
918909   {
919      layers_flip_1 = kaneko16_layers_1_regs[ 4 ];
910      layers_flip_1 = state->m_layers_1_regs[ 4 ];
920911
921      tilemap_set_enable(kaneko16_tmap_2, ~layers_flip_1 & 0x1000);
922      tilemap_set_enable(kaneko16_tmap_3, ~layers_flip_1 & 0x0010);
912      tilemap_set_enable(state->m_tmap[2], ~layers_flip_1 & 0x1000);
913      tilemap_set_enable(state->m_tmap[3], ~layers_flip_1 & 0x0010);
923914
924      tilemap_set_flip(kaneko16_tmap_2,   ((layers_flip_1 & 0x0100) ? TILEMAP_FLIPY : 0) |
915      tilemap_set_flip(state->m_tmap[2],   ((layers_flip_1 & 0x0100) ? TILEMAP_FLIPY : 0) |
925916                                 ((layers_flip_1 & 0x0200) ? TILEMAP_FLIPX : 0) );
926      tilemap_set_flip(kaneko16_tmap_3,   ((layers_flip_1 & 0x0100) ? TILEMAP_FLIPY : 0) |
917      tilemap_set_flip(state->m_tmap[3],   ((layers_flip_1 & 0x0100) ? TILEMAP_FLIPY : 0) |
927918                                 ((layers_flip_1 & 0x0200) ? TILEMAP_FLIPX : 0) );
928919
929      layer0_scrollx      =   kaneko16_layers_1_regs[ 2 ];
930      layer0_scrolly      =   kaneko16_layers_1_regs[ 3 ] >> 6;
931      layer1_scrollx      =   kaneko16_layers_1_regs[ 0 ];
932      layer1_scrolly      =   kaneko16_layers_1_regs[ 1 ] >> 6;
920      layer0_scrollx      =   state->m_layers_1_regs[ 2 ];
921      layer0_scrolly      =   state->m_layers_1_regs[ 3 ] >> 6;
922      layer1_scrollx      =   state->m_layers_1_regs[ 0 ];
923      layer1_scrolly      =   state->m_layers_1_regs[ 1 ] >> 6;
933924
934      tilemap_set_scrolly(kaneko16_tmap_2,0,layer0_scrolly);
935      tilemap_set_scrolly(kaneko16_tmap_3,0,layer1_scrolly);
925      tilemap_set_scrolly(state->m_tmap[2],0,layer0_scrolly);
926      tilemap_set_scrolly(state->m_tmap[3],0,layer1_scrolly);
936927
937928      for (i=0; i<0x200; i++)
938929      {
939930         UINT16 scroll;
940         scroll = (layers_flip_1 & 0x0800) ? kaneko16_vscroll_2[i] : 0;
941         tilemap_set_scrollx(kaneko16_tmap_2,i,(layer0_scrollx + scroll) >> 6 );
942         scroll = (layers_flip_1 & 0x0008) ? kaneko16_vscroll_3[i] : 0;
943         tilemap_set_scrollx(kaneko16_tmap_3,i,(layer1_scrollx + scroll) >> 6 );
931         scroll = (layers_flip_1 & 0x0800) ? state->m_vscroll[2][i] : 0;
932         tilemap_set_scrollx(state->m_tmap[2],i,(layer0_scrollx + scroll) >> 6 );
933         scroll = (layers_flip_1 & 0x0008) ? state->m_vscroll[3][i] : 0;
934         tilemap_set_scrollx(state->m_tmap[3],i,(layer1_scrollx + scroll) >> 6 );
944935      }
945936   }
946937}
947938
948939static void kaneko16_render_first_tilemap_chip(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int pri)
949940{
950   tilemap_draw_primask(bitmap,cliprect, kaneko16_tmap_0, pri, pri, 0);
951   tilemap_draw_primask(bitmap,cliprect, kaneko16_tmap_1, pri, pri, 0);
941   kaneko16_state *state = machine.driver_data<kaneko16_state>();
942   tilemap_draw_primask(bitmap,cliprect, state->m_tmap[0], pri, pri, 0);
943   tilemap_draw_primask(bitmap,cliprect, state->m_tmap[1], pri, pri, 0);
952944}
953945
954946static void kaneko16_render_second_tilemap_chip(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int pri)
955947{
956   if (kaneko16_tmap_2)
948   kaneko16_state *state = machine.driver_data<kaneko16_state>();
949   if (state->m_tmap[2])
957950   {
958      tilemap_draw_primask(bitmap,cliprect, kaneko16_tmap_2, pri, kaneko16_priority.VIEW2_2_pri ? pri : 0, 0);
959      tilemap_draw_primask(bitmap,cliprect, kaneko16_tmap_3, pri, kaneko16_priority.VIEW2_2_pri ? pri : 0, 0);
951      tilemap_draw_primask(bitmap,cliprect, state->m_tmap[2], pri, state->m_priority.VIEW2_2_pri ? pri : 0, 0);
952      tilemap_draw_primask(bitmap,cliprect, state->m_tmap[3], pri, state->m_priority.VIEW2_2_pri ? pri : 0, 0);
960953   }
961954}
962955
963956static void kaneko16_render_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
964957{
958   kaneko16_state *state = machine.driver_data<kaneko16_state>();
965959   /* Sprites last (rendered with pdrawgfx, so they can slip
966960       in between the layers) */
967961
968   if(kaneko16_keep_sprites)
962   if(state->m_keep_sprites)
969963   {
970964      /* keep sprites on screen */
971      kaneko16_draw_sprites(machine,sprites_bitmap,cliprect);
972      copybitmap_trans(bitmap,sprites_bitmap,0,0,0,0,cliprect,0);
965      kaneko16_draw_sprites(machine,state->m_sprites_bitmap,cliprect);
966      copybitmap_trans(bitmap,state->m_sprites_bitmap,0,0,0,0,cliprect,0);
973967   }
974968   else
975969   {
976      bitmap_fill(sprites_bitmap,cliprect,0);
970      bitmap_fill(state->m_sprites_bitmap,cliprect,0);
977971      kaneko16_draw_sprites(machine,bitmap,cliprect);
978972   }
979973}
980974
981975static void kaneko16_render_15bpp_bitmap(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
982976{
983   if (kaneko16_bg15_bitmap)
977   kaneko16_state *state = machine.driver_data<kaneko16_state>();
978   if (state->m_bg15_bitmap)
984979   {
985      int select   =   kaneko16_bg15_select[ 0 ];
986//      int reg     =   kaneko16_bg15_reg[ 0 ];
980      int select   =   state->m_bg15_select[ 0 ];
981//      int reg     =   state->m_bg15_reg[ 0 ];
987982      int flip   =   select & 0x20;
988983      int sx, sy;
989984
r11160r11161
992987      sx      =   (select & 0x1f) * 256;
993988      sy      =   0;
994989
995      copybitmap(bitmap, kaneko16_bg15_bitmap, flip, flip, -sx, -sy, cliprect);
990      copybitmap(bitmap, state->m_bg15_bitmap, flip, flip, -sx, -sy, cliprect);
996991
997992//      flag = 0;
998993   }
r11160r11161
1000995
1001996static void kaneko16_fill_bitmap(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
1002997{
1003   if(kaneko16_sprite_type == 1)
998   kaneko16_state *state = machine.driver_data<kaneko16_state>();
999   if(state->m_sprite_type == 1)
10041000      bitmap_fill(bitmap,cliprect,0x7f00);
10051001   else
10061002      /* Fill the bitmap with pen 0. This is wrong, but will work most of
r11160r11161
10291025
10301026SCREEN_UPDATE(berlwall)
10311027{
1028   kaneko16_state *state = screen->machine().driver_data<kaneko16_state>();
10321029   // berlwall uses a 15bpp bitmap as a bg, not a solid fill
10331030   kaneko16_render_15bpp_bitmap(screen->machine(),bitmap,cliprect);
10341031
10351032   // if the display is disabled, do nothing?
1036   if (!kaneko16_disp_enable) return 0;
1033   if (!state->m_disp_enable) return 0;
10371034
10381035   SCREEN_UPDATE_CALL(common);
10391036   kaneko16_render_sprites(screen->machine(),bitmap,cliprect);
r11160r11161
10431040
10441041SCREEN_UPDATE( jchan_view2 )
10451042{
1043   kaneko16_state *state = screen->machine().driver_data<kaneko16_state>();
10461044   int dx,dy;
10471045
10481046   SCREEN_UPDATE_CALL(common);
r11160r11161
10501048   /* override the offsets set in common - tuned to char select in jchan2 */
10511049   dx = 25;dy = 11;
10521050
1053   tilemap_set_scrolldx( kaneko16_tmap_0, -dx,      320 + dx -1        );
1054   tilemap_set_scrolldx( kaneko16_tmap_1, -(dx+2),   320 + (dx + 2) - 1 );
1051   tilemap_set_scrolldx( state->m_tmap[0], -dx,      320 + dx -1        );
1052   tilemap_set_scrolldx( state->m_tmap[1], -(dx+2),   320 + (dx + 2) - 1 );
10551053
1056   tilemap_set_scrolldy( kaneko16_tmap_0, -dy,      240 + dy -1 );
1057   tilemap_set_scrolldy( kaneko16_tmap_1, -dy,      240 + dy -1 );
1054   tilemap_set_scrolldy( state->m_tmap[0], -dy,      240 + dy -1 );
1055   tilemap_set_scrolldy( state->m_tmap[1], -dy,      240 + dy -1 );
10581056
10591057   return 0;
10601058}
r11160r11161
10621060
10631061SCREEN_UPDATE( kaneko16 )
10641062{
1063   kaneko16_state *state = screen->machine().driver_data<kaneko16_state>();
10651064   kaneko16_fill_bitmap(screen->machine(),bitmap,cliprect);
10661065
10671066   // if the display is disabled, do nothing?
1068   if (!kaneko16_disp_enable) return 0;
1067   if (!state->m_disp_enable) return 0;
10691068
10701069   SCREEN_UPDATE_CALL(common);
10711070   kaneko16_render_sprites(screen->machine(),bitmap,cliprect);
r11160r11161
10741073
10751074SCREEN_UPDATE( galsnew )
10761075{
1076   kaneko16_state *state = screen->machine().driver_data<kaneko16_state>();
10771077//  kaneko16_fill_bitmap(screen->machine(),bitmap,cliprect);
10781078   int y,x;
10791079   int count;
r11160r11161
10861086
10871087      for (x=0;x<256;x++)
10881088      {
1089         UINT16 dat = (galsnew_fg_pixram[count] & 0xfffe)>>1;
1089         UINT16 dat = (state->m_galsnew_fg_pixram[count] & 0xfffe)>>1;
10901090         dat+=2048;
10911091         dest[x] = dat;
10921092         count++;
r11160r11161
11001100
11011101      for (x=0;x<256;x++)
11021102      {
1103         UINT16 dat = (galsnew_bg_pixram[count]);
1103         UINT16 dat = (state->m_galsnew_bg_pixram[count]);
11041104         //dat &=0x3ff;
11051105         if (dat)
11061106            dest[x] = dat;
r11160r11161
11111111
11121112
11131113   // if the display is disabled, do nothing?
1114   if (!kaneko16_disp_enable) return 0;
1114   if (!state->m_disp_enable) return 0;
11151115
11161116   SCREEN_UPDATE_CALL(common);
11171117
r11160r11161
11221122
11231123SCREEN_UPDATE( sandscrp )
11241124{
1125   kaneko16_state *state = screen->machine().driver_data<kaneko16_state>();
11251126   device_t *pandora = screen->machine().device("pandora");
11261127   kaneko16_fill_bitmap(screen->machine(),bitmap,cliprect);
11271128
11281129   // if the display is disabled, do nothing?
1129   if (!kaneko16_disp_enable) return 0;
1130   if (!state->m_disp_enable) return 0;
11301131
11311132   SCREEN_UPDATE_CALL(common);
11321133
src/mame/video/gauntlet.c
r11160r11161
66
77#include "emu.h"
88#include "machine/atarigen.h"
9#include "video/atarimo.h"
910#include "includes/gauntlet.h"
1011
1112
src/mame/video/atarimo.c
r11160r11161
9494   int               codehighshift;      /* shift count for the upper code */
9595
9696   atarimo_entry *      spriteram;         /* pointer to sprite RAM */
97   UINT16 **         slipram;         /* pointer to the SLIP RAM pointer */
97   UINT16 *         sprite_ram;         /* pointer to the sprite RAM */
98   UINT16 *         slip_ram;         /* pointer to the SLIP RAM */
9899   UINT16 *         codelookup;         /* lookup table for codes */
99100   UINT8 *            colorlookup;      /* lookup table for colors */
100101   UINT8 *            gfxlookup;         /* lookup table for graphics */
r11160r11161
125126
126127
127128/***************************************************************************
128    GLOBAL VARIABLES
129***************************************************************************/
130
131UINT16 *atarimo_0_spriteram;
132UINT16 *atarimo_0_slipram;
133
134UINT16 *atarimo_1_spriteram;
135UINT16 *atarimo_1_slipram;
136
137
138
139/***************************************************************************
140129    STATIC VARIABLES
141130***************************************************************************/
142131
r11160r11161
403392   mo->specialcb     = desc->specialcb;
404393   mo->codehighshift = compute_log(round_to_powerof2(mo->codemask.mask));
405394
406   mo->slipram       = (map == 0) ? &atarimo_0_slipram : &atarimo_1_slipram;
395   mo->sprite_ram    = auto_alloc_array_clear(machine, UINT16, 0x2000);
396   mo->slip_ram      = auto_alloc_array_clear(machine, UINT16, 0x80);
407397
408398   /* allocate the temp bitmap */
409399   mo->bitmap        = auto_bitmap_alloc(machine, machine.primary_screen->width(), machine.primary_screen->height(), BITMAP_FORMAT_INDEXED16);
r11160r11161
684674      else
685675      {
686676         int slipentry = band & mo->sliprammask;
687         link = ((*mo->slipram)[slipentry] >> mo->linkmask.shift) & mo->linkmask.mask;
677         link = (mo->slip_ram[slipentry] >> mo->linkmask.shift) & mo->linkmask.mask;
688678
689679         /* start with the cliprect */
690680         bandclip = *cliprect;
r11160r11161
983973
984974
985975/*---------------------------------------------------------------
976    atarimo_0_spriteram_r: Read handler for the spriteram.
977---------------------------------------------------------------*/
978
979READ16_HANDLER( atarimo_0_spriteram_r )
980{
981   atarimo_data *mo = &atarimo[0];
982   return mo->sprite_ram[offset] & mem_mask;
983}
984
985
986/*---------------------------------------------------------------
986987    atarimo_0_spriteram_w: Write handler for the spriteram.
987988---------------------------------------------------------------*/
988989
989990WRITE16_HANDLER( atarimo_0_spriteram_w )
990991{
991992   int entry, idx, bank;
993   atarimo_data *mo = &atarimo[0];
992994
993   COMBINE_DATA(&atarimo_0_spriteram[offset]);
994   if (atarimo[0].split)
995   COMBINE_DATA(&mo->sprite_ram[offset]);
996   if (mo->split)
995997   {
996      entry = offset & atarimo[0].linkmask.mask;
997      idx = (offset >> atarimo[0].entrybits) & 3;
998      entry = offset & mo->linkmask.mask;
999      idx = (offset >> mo->entrybits) & 3;
9981000   }
9991001   else
10001002   {
1001      entry = (offset >> 2) & atarimo[0].linkmask.mask;
1003      entry = (offset >> 2) & mo->linkmask.mask;
10021004      idx = offset & 3;
10031005   }
1004   bank = offset >> (2 + atarimo[0].entrybits);
1005   COMBINE_DATA(&atarimo[0].spriteram[(bank << atarimo[0].entrybits) + entry].data[idx]);
1006   bank = offset >> (2 + mo->entrybits);
1007   COMBINE_DATA(&mo->spriteram[(bank << mo->entrybits) + entry].data[idx]);
10061008}
10071009
10081010
10091011/*---------------------------------------------------------------
1012    atarimo_1_spriteram_r: Read handler for the spriteram.
1013---------------------------------------------------------------*/
1014
1015READ16_HANDLER( atarimo_1_spriteram_r )
1016{
1017   atarimo_data *mo = &atarimo[1];
1018   return mo->sprite_ram[offset] & mem_mask;
1019}
1020
1021
1022/*---------------------------------------------------------------
10101023    atarimo_1_spriteram_w: Write handler for the spriteram.
10111024---------------------------------------------------------------*/
10121025
10131026WRITE16_HANDLER( atarimo_1_spriteram_w )
10141027{
10151028   int entry, idx, bank;
1029   atarimo_data *mo = &atarimo[1];
10161030
1017   COMBINE_DATA(&atarimo_1_spriteram[offset]);
1018   if (atarimo[1].split)
1031   COMBINE_DATA(&mo->sprite_ram[offset]);
1032   if (mo->split)
10191033   {
1020      entry = offset & atarimo[1].linkmask.mask;
1021      idx = (offset >> atarimo[1].entrybits) & 3;
1034      entry = offset & mo->linkmask.mask;
1035      idx = (offset >> mo->entrybits) & 3;
10221036   }
10231037   else
10241038   {
1025      entry = (offset >> 2) & atarimo[1].linkmask.mask;
1039      entry = (offset >> 2) & mo->linkmask.mask;
10261040      idx = offset & 3;
10271041   }
1028   bank = offset >> (2 + atarimo[1].entrybits);
1029   COMBINE_DATA(&atarimo[1].spriteram[(bank << atarimo[1].entrybits) + entry].data[idx]);
1042   bank = offset >> (2 + mo->entrybits);
1043   COMBINE_DATA(&mo->spriteram[(bank << mo->entrybits) + entry].data[idx]);
10301044}
10311045
10321046
r11160r11161
10381052WRITE16_HANDLER( atarimo_0_spriteram_expanded_w )
10391053{
10401054   int entry, idx, bank;
1055   atarimo_data *mo = &atarimo[0];
10411056
1042   COMBINE_DATA(&atarimo_0_spriteram[offset]);
1057   COMBINE_DATA(&mo->sprite_ram[offset]);
10431058   if (!(offset & 1))
10441059   {
10451060      offset >>= 1;
1046      if (atarimo[0].split)
1061      if (mo->split)
10471062      {
1048         entry = offset & atarimo[0].linkmask.mask;
1049         idx = (offset >> atarimo[0].entrybits) & 3;
1063         entry = offset & mo->linkmask.mask;
1064         idx = (offset >> mo->entrybits) & 3;
10501065      }
10511066      else
10521067      {
1053         entry = (offset >> 2) & atarimo[0].linkmask.mask;
1068         entry = (offset >> 2) & mo->linkmask.mask;
10541069         idx = offset & 3;
10551070      }
1056      bank = offset >> (2 + atarimo[0].entrybits);
1057      COMBINE_DATA(&atarimo[0].spriteram[(bank << atarimo[0].entrybits) + entry].data[idx]);
1071      bank = offset >> (2 + mo->entrybits);
1072      COMBINE_DATA(&mo->spriteram[(bank << mo->entrybits) + entry].data[idx]);
10581073   }
10591074}
10601075
10611076
10621077/*---------------------------------------------------------------
1078    atarimo_set_slipram: Set slipram pointer.
1079---------------------------------------------------------------*/
1080
1081void atarimo_set_slipram(int map, UINT16 *ram)
1082{
1083   atarimo_data *mo = &atarimo[map];
1084   mo->slip_ram = ram;
1085}
1086
1087
1088/*---------------------------------------------------------------
1089    atarimo_0_slipram_r: Read handler for the slipram.
1090---------------------------------------------------------------*/
1091
1092READ16_HANDLER( atarimo_0_slipram_r )
1093{
1094   atarimo_data *mo = &atarimo[0];
1095   logerror("READ: %04x:%04x\n", offset, mo->slip_ram[offset] & mem_mask);
1096   return mo->slip_ram[offset] & mem_mask;
1097}
1098
1099
1100/*---------------------------------------------------------------
10631101    atarimo_0_slipram_w: Write handler for the slipram.
10641102---------------------------------------------------------------*/
10651103
10661104WRITE16_HANDLER( atarimo_0_slipram_w )
10671105{
1068   COMBINE_DATA(&atarimo_0_slipram[offset]);
1106   atarimo_data *mo = &atarimo[0];
1107   logerror("WRITE: %04x:%04x:%04x:%04x\n", offset, mo->slip_ram[offset], data, mem_mask);
1108   COMBINE_DATA(&mo->slip_ram[offset]);
10691109}
10701110
10711111
10721112/*---------------------------------------------------------------
1113    atarimo_1_slipram_r: Read handler for the slipram.
1114---------------------------------------------------------------*/
1115
1116READ16_HANDLER( atarimo_1_slipram_r )
1117{
1118   atarimo_data *mo = &atarimo[1];
1119   return mo->slip_ram[offset] & mem_mask;
1120}
1121
1122
1123/*---------------------------------------------------------------
10731124    atarimo_1_slipram_w: Write handler for the slipram.
10741125---------------------------------------------------------------*/
10751126
10761127WRITE16_HANDLER( atarimo_1_slipram_w )
10771128{
1078   COMBINE_DATA(&atarimo_1_slipram[offset]);
1129   atarimo_data *mo = &atarimo[1];
1130   COMBINE_DATA(&mo->slip_ram[offset]);
10791131}
10801132
10811133
src/mame/video/atarimo.h
r11160r11161
106106void atarimo_set_bank(int map, int bank);
107107void atarimo_set_xscroll(int map, int xscroll);
108108void atarimo_set_yscroll(int map, int yscroll);
109void atarimo_set_slipram(int map, UINT16 *ram);
109110
110111/* atrribute getters */
111112int atarimo_get_bank(int map);
112113int atarimo_get_xscroll(int map);
113114int atarimo_get_yscroll(int map);
114115
115/* write handlers */
116/* read/write handlers */
117READ16_HANDLER( atarimo_0_spriteram_r );
118READ16_HANDLER( atarimo_0_slipram_r );
119
120READ16_HANDLER( atarimo_1_spriteram_r );
121READ16_HANDLER( atarimo_1_slipram_r );
122
116123WRITE16_HANDLER( atarimo_0_spriteram_w );
117124WRITE16_HANDLER( atarimo_0_spriteram_expanded_w );
118125WRITE16_HANDLER( atarimo_0_slipram_w );
r11160r11161
123130void atarimo_mark_high_palette(bitmap_t *bitmap, UINT16 *pf, UINT16 *mo, int x, int y);
124131
125132
126/***************************************************************************
127    GLOBAL VARIABLES
128***************************************************************************/
129
130extern UINT16 *atarimo_0_spriteram;
131extern UINT16 *atarimo_0_slipram;
132
133extern UINT16 *atarimo_1_spriteram;
134extern UINT16 *atarimo_1_slipram;
135
136
137133#endif
src/mame/video/galaxian.c
r11160r11161
230230
231231/*************************************
232232 *
233 *  Global variables
234 *
235 *************************************/
236
237/* rendering callbacks */
238galaxian_draw_bullet_func galaxian_draw_bullet_ptr;
239galaxian_draw_background_func galaxian_draw_background_ptr;
240
241/* tile/sprite modification callbacks */
242galaxian_extend_tile_info_func galaxian_extend_tile_info_ptr;
243galaxian_extend_sprite_info_func galaxian_extend_sprite_info_ptr;
244
245/* global tweaks */
246UINT8 galaxian_frogger_adjust;
247UINT8 galaxian_sfx_tilemap;
248
249
250
251/*************************************
252 *
253 *  Local variables
254 *
255 *************************************/
256
257static tilemap_t *bg_tilemap;
258
259static UINT8 flipscreen_x;
260static UINT8 flipscreen_y;
261
262static UINT8 background_enable;
263static UINT8 background_red;
264static UINT8 background_green;
265static UINT8 background_blue;
266
267static UINT32 star_rng_origin;
268static UINT32 star_rng_origin_frame;
269static rgb_t star_color[64];
270static UINT8 *stars;
271static UINT8 stars_enabled;
272static UINT8 stars_blink_state;
273
274static rgb_t bullet_color[8];
275
276static UINT8 gfxbank[5];
277
278
279
280/*************************************
281 *
282233 *  Function prototypes
283234 *
284235 *************************************/
r11160r11161
290241
291242static void stars_init(running_machine &machine);
292243static void stars_update_origin(running_machine &machine);
293static void stars_draw_row(bitmap_t *bitmap, int maxx, int y, UINT32 star_offs, UINT8 starmask);
244static void stars_draw_row(galaxian_state *state, bitmap_t *bitmap, int maxx, int y, UINT32 star_offs, UINT8 starmask);
294245
295246static void bullets_draw(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *base);
296247
r11160r11161
304255
305256PALETTE_INIT( galaxian )
306257{
258   galaxian_state *state = machine.driver_data<galaxian_state>();
307259   static const int rgb_resistances[3] = { 1000, 470, 220 };
308260   double rweights[3], gweights[3], bweights[2];
309261   int i, minval, midval, maxval, len;
r11160r11161
412364      b = starmap[(bit1 << 1) | bit0];
413365
414366      /* set the RGB color */
415      star_color[i] = MAKE_RGB(r, g, b);
367      state->m_star_color[i] = MAKE_RGB(r, g, b);
416368   }
417369
418370   /* default bullet colors are white for the first 7, and yellow for the last one */
419371   for (i = 0; i < 7; i++)
420      bullet_color[i] = MAKE_RGB(0xff,0xff,0xff);
421   bullet_color[7] = MAKE_RGB(0xff,0xff,0x00);
372      state->m_bullet_color[i] = MAKE_RGB(0xff,0xff,0xff);
373   state->m_bullet_color[7] = MAKE_RGB(0xff,0xff,0x00);
422374}
423375
424376PALETTE_INIT( moonwar )
425377{
378   galaxian_state *state = machine.driver_data<galaxian_state>();
426379   PALETTE_INIT_CALL(galaxian);
427380
428381   /* wire mod to connect the bullet blue output to the 220 ohm resistor */
429   bullet_color[7] = MAKE_RGB(0xef,0xef,0x97);
382   state->m_bullet_color[7] = MAKE_RGB(0xef,0xef,0x97);
430383}
431384
432385/*************************************
r11160r11161
437390
438391VIDEO_START( galaxian )
439392{
393   galaxian_state *state = machine.driver_data<galaxian_state>();
440394   /* create a tilemap for the background */
441   if (!galaxian_sfx_tilemap)
395   if (!state->m_sfx_tilemap)
442396   {
443397      /* normal galaxian hardware is row-based and individually scrolling columns */
444      bg_tilemap = tilemap_create(machine, bg_get_tile_info, tilemap_scan_rows, GALAXIAN_XSCALE*8,8, 32,32);
445      tilemap_set_scroll_cols(bg_tilemap, 32);
446      tilemap_set_scrolldx(bg_tilemap, 0, -GALAXIAN_XSCALE * 128);
447      tilemap_set_scrolldy(bg_tilemap, 0, 8);
398      state->m_bg_tilemap = tilemap_create(machine, bg_get_tile_info, tilemap_scan_rows, GALAXIAN_XSCALE*8,8, 32,32);
399      tilemap_set_scroll_cols(state->m_bg_tilemap, 32);
400      tilemap_set_scrolldx(state->m_bg_tilemap, 0, -GALAXIAN_XSCALE * 128);
401      tilemap_set_scrolldy(state->m_bg_tilemap, 0, 8);
448402   }
449403   else
450404   {
451405      /* sfx hardware is column-based and individually scrolling rows */
452      bg_tilemap = tilemap_create(machine, bg_get_tile_info, tilemap_scan_cols, GALAXIAN_XSCALE*8,8, 32,32);
453      tilemap_set_scroll_rows(bg_tilemap, 32);
454      tilemap_set_scrolldx(bg_tilemap, 0, -GALAXIAN_XSCALE * 128);
455      tilemap_set_scrolldy(bg_tilemap, 0, 8);
406      state->m_bg_tilemap = tilemap_create(machine, bg_get_tile_info, tilemap_scan_cols, GALAXIAN_XSCALE*8,8, 32,32);
407      tilemap_set_scroll_rows(state->m_bg_tilemap, 32);
408      tilemap_set_scrolldx(state->m_bg_tilemap, 0, -GALAXIAN_XSCALE * 128);
409      tilemap_set_scrolldy(state->m_bg_tilemap, 0, 8);
456410   }
457   tilemap_set_transparent_pen(bg_tilemap, 0);
411   tilemap_set_transparent_pen(state->m_bg_tilemap, 0);
458412
459413   /* initialize globals */
460   flipscreen_x = 0;
461   flipscreen_y = 0;
462   background_enable = 0;
463   background_blue = 0;
464   background_red = 0;
465   background_green = 0;
414   state->m_flipscreen_x = 0;
415   state->m_flipscreen_y = 0;
416   state->m_background_enable = 0;
417   state->m_background_blue = 0;
418   state->m_background_red = 0;
419   state->m_background_green = 0;
466420
467421   /* initialize stars */
468422   stars_init(machine);
r11160r11161
474428
475429static void state_save_register(running_machine &machine)
476430{
477   state_save_register_global(machine, flipscreen_x);
478   state_save_register_global(machine, flipscreen_y);
479   state_save_register_global(machine, background_enable);
480   state_save_register_global(machine, background_red);
481   state_save_register_global(machine, background_green);
482   state_save_register_global(machine, background_blue);
431   galaxian_state *state = machine.driver_data<galaxian_state>();
432   state_save_register_global(machine, state->m_flipscreen_x);
433   state_save_register_global(machine, state->m_flipscreen_y);
434   state_save_register_global(machine, state->m_background_enable);
435   state_save_register_global(machine, state->m_background_red);
436   state_save_register_global(machine, state->m_background_green);
437   state_save_register_global(machine, state->m_background_blue);
483438
484   state_save_register_global_array(machine, gfxbank);
439   state_save_register_global_array(machine, state->m_gfxbank);
485440
486   state_save_register_global(machine, stars_enabled);
487   state_save_register_global(machine, star_rng_origin);
488   state_save_register_global(machine, star_rng_origin_frame);
489   state_save_register_global(machine, stars_blink_state);
441   state_save_register_global(machine, state->m_stars_enabled);
442   state_save_register_global(machine, state->m_star_rng_origin);
443   state_save_register_global(machine, state->m_star_rng_origin_frame);
444   state_save_register_global(machine, state->m_stars_blink_state);
490445}
491446
492447
r11160r11161
499454
500455SCREEN_UPDATE( galaxian )
501456{
457   galaxian_state *state = screen->machine().driver_data<galaxian_state>();
502458   /* draw the background layer (including stars) */
503   (*galaxian_draw_background_ptr)(screen->machine(), bitmap, cliprect);
459   (*state->m_draw_background_ptr)(screen->machine(), bitmap, cliprect);
504460
505461   /* draw the tilemap characters over top */
506   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
462   tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0);
507463
508464   /* render the sprites next */
509465   sprites_draw(screen->machine(), bitmap, cliprect, &screen->machine().generic.spriteram.u8[0x40]);
510466
511467   /* if we have bullets to draw, render them following */
512   if (galaxian_draw_bullet_ptr != NULL)
468   if (state->m_draw_bullet_ptr != NULL)
513469      bullets_draw(screen->machine(), bitmap, cliprect, &screen->machine().generic.spriteram.u8[0x60]);
514470
515471   return 0;
r11160r11161
544500   UINT8 attrib = machine.generic.spriteram.u8[x*2+1];
545501   UINT8 color = attrib & 7;
546502
547   if (galaxian_extend_tile_info_ptr != NULL)
548      (*galaxian_extend_tile_info_ptr)(&code, &color, attrib, x);
503   if (state->m_extend_tile_info_ptr != NULL)
504      (*state->m_extend_tile_info_ptr)(machine, &code, &color, attrib, x);
549505
550506   SET_TILE_INFO(0, code, color, 0);
551507}
r11160r11161
560516
561517   /* store the data and mark the corresponding tile dirty */
562518   videoram[offset] = data;
563   tilemap_mark_tile_dirty(bg_tilemap, offset);
519   tilemap_mark_tile_dirty(state->m_bg_tilemap, offset);
564520}
565521
566522
567523WRITE8_HANDLER( galaxian_objram_w )
568524{
525   galaxian_state *state = space->machine().driver_data<galaxian_state>();
569526   /* update any video up to the current scanline */
570527   space->machine().primary_screen->update_now();
571528
r11160r11161
579536      if ((offset & 0x01) == 0)
580537      {
581538         /* Frogger: top and bottom 4 bits swapped entering the adder */
582         if (galaxian_frogger_adjust)
539         if (state->m_frogger_adjust)
583540            data = (data >> 4) | (data << 4);
584         if (!galaxian_sfx_tilemap)
585            tilemap_set_scrolly(bg_tilemap, offset >> 1, data);
541         if (!state->m_sfx_tilemap)
542            tilemap_set_scrolly(state->m_bg_tilemap, offset >> 1, data);
586543         else
587            tilemap_set_scrollx(bg_tilemap, offset >> 1, GALAXIAN_XSCALE*data);
544            tilemap_set_scrollx(state->m_bg_tilemap, offset >> 1, GALAXIAN_XSCALE*data);
588545      }
589546
590547      /* odd entries control the color base for the row */
591548      else
592549      {
593550         for (offset >>= 1; offset < 0x0400; offset += 32)
594            tilemap_mark_tile_dirty(bg_tilemap, offset);
551            tilemap_mark_tile_dirty(state->m_bg_tilemap, offset);
595552      }
596553   }
597554}
r11160r11161
606563
607564static void sprites_draw(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *spritebase)
608565{
566   galaxian_state *state = machine.driver_data<galaxian_state>();
609567   rectangle clip = *cliprect;
610568   int sprnum;
611569
612570   /* 16 of the 256 pixels of the sprites are hard-clipped at the line buffer */
613571   /* according to the schematics, it should be the first 16 pixels */
614   clip.min_x = MAX(clip.min_x, (!flipscreen_x) * 16 * GALAXIAN_XSCALE);
615   clip.max_x = MIN(clip.max_x, (256 - flipscreen_x * 16) * GALAXIAN_XSCALE - 1);
572   clip.min_x = MAX(clip.min_x, (!state->m_flipscreen_x) * 16 * GALAXIAN_XSCALE);
573   clip.max_x = MIN(clip.max_x, (256 - state->m_flipscreen_x * 16) * GALAXIAN_XSCALE - 1);
616574
617575   /* The line buffer is only written if it contains a '0' currently; */
618576   /* it is cleared during the visible area, and populated during HBLANK */
r11160r11161
622580   {
623581      const UINT8 *base = &spritebase[sprnum * 4];
624582      /* Frogger: top and bottom 4 bits swapped entering the adder */
625      UINT8 base0 = galaxian_frogger_adjust ? ((base[0] >> 4) | (base[0] << 4)) : base[0];
583      UINT8 base0 = state->m_frogger_adjust ? ((base[0] >> 4) | (base[0] << 4)) : base[0];
626584      /* the first three sprites match against y-1 */
627585      UINT8 sy = 240 - (base0 - (sprnum < 3));
628586      UINT16 code = base[1] & 0x3f;
r11160r11161
632590      UINT8 sx = base[3] + 1;
633591
634592      /* extend the sprite information */
635      if (galaxian_extend_sprite_info_ptr != NULL)
636         (*galaxian_extend_sprite_info_ptr)(base, &sx, &sy, &flipx, &flipy, &code, &color);
593      if (state->m_extend_sprite_info_ptr != NULL)
594         (*state->m_extend_sprite_info_ptr)(machine, base, &sx, &sy, &flipx, &flipy, &code, &color);
637595
638596      /* apply flipscreen in X direction */
639      if (flipscreen_x)
597      if (state->m_flipscreen_x)
640598      {
641599         sx = 240 - sx;
642600         flipx = !flipx;
643601      }
644602
645603      /* apply flipscreen in Y direction */
646      if (flipscreen_y)
604      if (state->m_flipscreen_y)
647605      {
648606         sy = 240 - sy;
649607         flipy = !flipy;
r11160r11161
668626
669627static void bullets_draw(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *base)
670628{
629   galaxian_state *state = machine.driver_data<galaxian_state>();
671630   int y;
672631
673632   /* iterate over scanlines */
r11160r11161
678637      int which;
679638
680639      /* the first 3 entries match Y-1 */
681      effy = flipscreen_y ? ((y - 1) ^ 255) : (y - 1);
640      effy = state->m_flipscreen_y ? ((y - 1) ^ 255) : (y - 1);
682641      for (which = 0; which < 3; which++)
683642         if ((UINT8)(base[which*4+1] + effy) == 0xff)
684643            shell = which;
685644
686645      /* remaining entries match Y */
687      effy = flipscreen_y ? (y ^ 255) : y;
646      effy = state->m_flipscreen_y ? (y ^ 255) : y;
688647      for (which = 3; which < 8; which++)
689648         if ((UINT8)(base[which*4+1] + effy) == 0xff)
690649         {
r11160r11161
696655
697656      /* draw the shell */
698657      if (shell != 0xff)
699         (*galaxian_draw_bullet_ptr)(machine, bitmap, cliprect, shell, 255 - base[shell*4+3], y);
658         (*state->m_draw_bullet_ptr)(machine, bitmap, cliprect, shell, 255 - base[shell*4+3], y);
700659      if (missile != 0xff)
701         (*galaxian_draw_bullet_ptr)(machine, bitmap, cliprect, missile, 255 - base[missile*4+3], y);
660         (*state->m_draw_bullet_ptr)(machine, bitmap, cliprect, missile, 255 - base[missile*4+3], y);
702661   }
703662}
704663
r11160r11161
712671
713672WRITE8_HANDLER( galaxian_flip_screen_x_w )
714673{
715   if (flipscreen_x != (data & 0x01))
674   galaxian_state *state = space->machine().driver_data<galaxian_state>();
675   if (state->m_flipscreen_x != (data & 0x01))
716676   {
717677      space->machine().primary_screen->update_now();
718678
r11160r11161
721681      /* frame before we flip */
722682      stars_update_origin(space->machine());
723683
724      flipscreen_x = data & 0x01;
725      tilemap_set_flip(bg_tilemap, (flipscreen_x ? TILEMAP_FLIPX : 0) | (flipscreen_y ? TILEMAP_FLIPY : 0));
684      state->m_flipscreen_x = data & 0x01;
685      tilemap_set_flip(state->m_bg_tilemap, (state->m_flipscreen_x ? TILEMAP_FLIPX : 0) | (state->m_flipscreen_y ? TILEMAP_FLIPY : 0));
726686   }
727687}
728688
729689WRITE8_HANDLER( galaxian_flip_screen_y_w )
730690{
731   if (flipscreen_y != (data & 0x01))
691   galaxian_state *state = space->machine().driver_data<galaxian_state>();
692   if (state->m_flipscreen_y != (data & 0x01))
732693   {
733694      space->machine().primary_screen->update_now();
734      flipscreen_y = data & 0x01;
735      tilemap_set_flip(bg_tilemap, (flipscreen_x ? TILEMAP_FLIPX : 0) | (flipscreen_y ? TILEMAP_FLIPY : 0));
695      state->m_flipscreen_y = data & 0x01;
696      tilemap_set_flip(state->m_bg_tilemap, (state->m_flipscreen_x ? TILEMAP_FLIPX : 0) | (state->m_flipscreen_y ? TILEMAP_FLIPY : 0));
736697   }
737698}
738699
r11160r11161
752713
753714WRITE8_HANDLER( galaxian_stars_enable_w )
754715{
755   if ((stars_enabled ^ data) & 0x01)
716   galaxian_state *state = space->machine().driver_data<galaxian_state>();
717   if ((state->m_stars_enabled ^ data) & 0x01)
756718      space->machine().primary_screen->update_now();
757719
758   if (!stars_enabled && (data & 0x01))
720   if (!state->m_stars_enabled && (data & 0x01))
759721   {
760722      /* on the rising edge of this, the CLR on the shift registers is released */
761723      /* this resets the "origin" of this frame to 0 minus the number of clocks */
762724      /* we have counted so far */
763      star_rng_origin = STAR_RNG_PERIOD - (space->machine().primary_screen->vpos() * 512 + space->machine().primary_screen->hpos());
764      star_rng_origin_frame = space->machine().primary_screen->frame_number();
725      state->m_star_rng_origin = STAR_RNG_PERIOD - (space->machine().primary_screen->vpos() * 512 + space->machine().primary_screen->hpos());
726      state->m_star_rng_origin_frame = space->machine().primary_screen->frame_number();
765727   }
766   stars_enabled = data & 0x01;
728   state->m_stars_enabled = data & 0x01;
767729}
768730
769731
770732WRITE8_HANDLER( scramble_background_enable_w )
771733{
772   if ((background_enable ^ data) & 0x01)
734   galaxian_state *state = space->machine().driver_data<galaxian_state>();
735   if ((state->m_background_enable ^ data) & 0x01)
773736      space->machine().primary_screen->update_now();
774737
775   background_enable = data & 0x01;
738   state->m_background_enable = data & 0x01;
776739}
777740
778741
779742WRITE8_HANDLER( scramble_background_red_w )
780743{
781   if ((background_red ^ data) & 0x01)
744   galaxian_state *state = space->machine().driver_data<galaxian_state>();
745   if ((state->m_background_red ^ data) & 0x01)
782746      space->machine().primary_screen->update_now();
783747
784   background_red = data & 0x01;
748   state->m_background_red = data & 0x01;
785749}
786750
787751
788752WRITE8_HANDLER( scramble_background_green_w )
789753{
790   if ((background_green ^ data) & 0x01)
754   galaxian_state *state = space->machine().driver_data<galaxian_state>();
755   if ((state->m_background_green ^ data) & 0x01)
791756      space->machine().primary_screen->update_now();
792757
793   background_green = data & 0x01;
758   state->m_background_green = data & 0x01;
794759}
795760
796761
797762WRITE8_HANDLER( scramble_background_blue_w )
798763{
799   if ((background_blue ^ data) & 0x01)
764   galaxian_state *state = space->machine().driver_data<galaxian_state>();
765   if ((state->m_background_blue ^ data) & 0x01)
800766      space->machine().primary_screen->update_now();
801767
802   background_blue = data & 0x01;
768   state->m_background_blue = data & 0x01;
803769}
804770
805771
r11160r11161
812778
813779WRITE8_HANDLER( galaxian_gfxbank_w )
814780{
815   if (gfxbank[offset] != data)
781   galaxian_state *state = space->machine().driver_data<galaxian_state>();
782   if (state->m_gfxbank[offset] != data)
816783   {
817784      space->machine().primary_screen->update_now();
818      gfxbank[offset] = data;
819      tilemap_mark_all_tiles_dirty(bg_tilemap);
785      state->m_gfxbank[offset] = data;
786      tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
820787   }
821788}
822789
r11160r11161
830797
831798static void stars_init(running_machine &machine)
832799{
800   galaxian_state *state = machine.driver_data<galaxian_state>();
833801   UINT32 shiftreg;
834802   int i;
835803
836804   /* reset the blink and enabled states */
837   stars_enabled = FALSE;
838   stars_blink_state = 0;
805   state->m_stars_enabled = FALSE;
806   state->m_stars_blink_state = 0;
839807
840808   /* precalculate the RNG */
841   stars = auto_alloc_array(machine, UINT8, STAR_RNG_PERIOD);
809   state->m_stars = auto_alloc_array(machine, UINT8, STAR_RNG_PERIOD);
842810   shiftreg = 0;
843811   for (i = 0; i < STAR_RNG_PERIOD; i++)
844812   {
r11160r11161
849817      int color = (~shiftreg & 0x1f8) >> 3;
850818
851819      /* store the color value in the low 6 bits and the enable in the upper bit */
852      stars[i] = color | (enabled << 7);
820      state->m_stars[i] = color | (enabled << 7);
853821
854822      /* the LFSR is fed based on the XOR of bit 12 and the inverse of bit 0 */
855823      shiftreg = (shiftreg >> 1) | ((((shiftreg >> 12) ^ ~shiftreg) & 1) << 16);
r11160r11161
866834
867835static void stars_update_origin(running_machine &machine)
868836{
837   galaxian_state *state = machine.driver_data<galaxian_state>();
869838   int curframe = machine.primary_screen->frame_number();
870839
871840   /* only update on a different frame */
872   if (curframe != star_rng_origin_frame)
841   if (curframe != state->m_star_rng_origin_frame)
873842   {
874843      /* The RNG period is 2^17-1; each frame, the shift register is clocked */
875844      /* 512*256 = 2^17 times. This means that we clock one extra time each */
r11160r11161
877846      /* at 6B which delay the count so that we count 512*256-2 = 2^17-2 times. */
878847      /* In this case, we only one time less than the period each frame. Both */
879848      /* of these off-by-one countings produce the horizontal star scrolling. */
880      int per_frame_delta = flipscreen_x ? 1 : -1;
881      int total_delta = per_frame_delta * (curframe - star_rng_origin_frame);
849      int per_frame_delta = state->m_flipscreen_x ? 1 : -1;
850      int total_delta = per_frame_delta * (curframe - state->m_star_rng_origin_frame);
882851
883852      /* we can't just use % here because mod of a negative number is undefined */
884853      while (total_delta < 0)
885854         total_delta += STAR_RNG_PERIOD;
886855
887856      /* now that everything is positive, do the mod */
888      star_rng_origin = (star_rng_origin + total_delta) % STAR_RNG_PERIOD;
889      star_rng_origin_frame = curframe;
857      state->m_star_rng_origin = (state->m_star_rng_origin + total_delta) % STAR_RNG_PERIOD;
858      state->m_star_rng_origin_frame = curframe;
890859   }
891860}
892861
r11160r11161
900869
901870TIMER_DEVICE_CALLBACK( galaxian_stars_blink_timer )
902871{
903   stars_blink_state++;
872   galaxian_state *state = timer.machine().driver_data<galaxian_state>();
873   state->m_stars_blink_state++;
904874}
905875
906876
r11160r11161
911881 *
912882 *************************************/
913883
914static void stars_draw_row(bitmap_t *bitmap, int maxx, int y, UINT32 star_offs, UINT8 starmask)
884static void stars_draw_row(galaxian_state *state, bitmap_t *bitmap, int maxx, int y, UINT32 star_offs, UINT8 starmask)
915885{
916886   int x;
917887
r11160r11161
943913        */
944914
945915      /* first RNG clock: one pixel */
946      star = stars[star_offs++];
916      star = state->m_stars[star_offs++];
947917      if (star_offs >= STAR_RNG_PERIOD)
948918         star_offs = 0;
949919      if (enable_star && (star & 0x80) != 0 && (star & starmask) != 0)
950         *BITMAP_ADDR32(bitmap, y, GALAXIAN_XSCALE*x + 0) = star_color[star & 0x3f];
920         *BITMAP_ADDR32(bitmap, y, GALAXIAN_XSCALE*x + 0) = state->m_star_color[star & 0x3f];
951921
952922      /* second RNG clock: two pixels */
953      star = stars[star_offs++];
923      star = state->m_stars[star_offs++];
954924      if (star_offs >= STAR_RNG_PERIOD)
955925         star_offs = 0;
956926      if (enable_star && (star & 0x80) != 0 && (star & starmask) != 0)
957927      {
958         *BITMAP_ADDR32(bitmap, y, GALAXIAN_XSCALE*x + 1) = star_color[star & 0x3f];
959         *BITMAP_ADDR32(bitmap, y, GALAXIAN_XSCALE*x + 2) = star_color[star & 0x3f];
928         *BITMAP_ADDR32(bitmap, y, GALAXIAN_XSCALE*x + 1) = state->m_star_color[star & 0x3f];
929         *BITMAP_ADDR32(bitmap, y, GALAXIAN_XSCALE*x + 2) = state->m_star_color[star & 0x3f];
960930      }
961931   }
962932}
r11160r11161
971941
972942void galaxian_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
973943{
944   galaxian_state *state = machine.driver_data<galaxian_state>();
974945   /* erase the background to black first */
975946   bitmap_fill(bitmap, cliprect, RGB_BLACK);
976947
r11160r11161
978949   stars_update_origin(machine);
979950
980951   /* render stars if enabled */
981   if (stars_enabled)
952   if (state->m_stars_enabled)
982953   {
983954      int y;
984955
985956      /* iterate over scanlines */
986957      for (y = cliprect->min_y; y <= cliprect->max_y; y++)
987958      {
988         UINT32 star_offs = star_rng_origin + y * 512;
989         stars_draw_row(bitmap, 256, y, star_offs, 0xff);
959         UINT32 star_offs = state->m_star_rng_origin + y * 512;
960         stars_draw_row(state, bitmap, 256, y, star_offs, 0xff);
990961      }
991962   }
992963}
r11160r11161
994965
995966static void background_draw_colorsplit(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, rgb_t color, int split, int split_flipped)
996967{
968   galaxian_state *state = machine.driver_data<galaxian_state>();
997969   /* horizontal bgcolor split */
998   if (flipscreen_x)
970   if (state->m_flipscreen_x)
999971   {
1000972      rectangle draw = *cliprect;
1001973      draw.max_x = MIN(draw.max_x, split_flipped * GALAXIAN_XSCALE - 1);
r11160r11161
1024996
1025997static void scramble_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int maxx)
1026998{
999   galaxian_state *state = machine.driver_data<galaxian_state>();
10271000   /* update the star origin to the current frame */
10281001   stars_update_origin(machine);
10291002
10301003   /* render stars if enabled */
1031   if (stars_enabled)
1004   if (state->m_stars_enabled)
10321005   {
1033      int blink_state = stars_blink_state & 3;
1006      int blink_state = state->m_stars_blink_state & 3;
10341007      int y;
10351008
10361009      /* iterate over scanlines */
r11160r11161
10411014         {
10421015            /* blink states 0 and 1 suppress stars when certain bits of the color == 0 */
10431016            static const UINT8 colormask_table[4] = { 0x20, 0x08, 0xff, 0xff };
1044            stars_draw_row(bitmap, maxx, y, y * 512, colormask_table[blink_state]);
1017            stars_draw_row(state, bitmap, maxx, y, y * 512, colormask_table[blink_state]);
10451018         }
10461019      }
10471020   }
r11160r11161
10501023
10511024void scramble_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
10521025{
1026   galaxian_state *state = machine.driver_data<galaxian_state>();
10531027   /* blue background - 390 ohm resistor */
1054   bitmap_fill(bitmap, cliprect, background_enable ? MAKE_RGB(0,0,0x56) : RGB_BLACK);
1028   bitmap_fill(bitmap, cliprect, state->m_background_enable ? MAKE_RGB(0,0,0x56) : RGB_BLACK);
10551029
10561030   scramble_draw_stars(machine, bitmap, cliprect, 256);
10571031}
r11160r11161
10591033
10601034void anteater_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
10611035{
1036   galaxian_state *state = machine.driver_data<galaxian_state>();
10621037   /* blue background, horizontal split as seen on flyer and real cabinet */
1063   background_draw_colorsplit(machine, bitmap, cliprect, background_enable ? MAKE_RGB(0,0,0x56) : RGB_BLACK, 56, 256-56);
1038   background_draw_colorsplit(machine, bitmap, cliprect, state->m_background_enable ? MAKE_RGB(0,0,0x56) : RGB_BLACK, 56, 256-56);
10641039
10651040   scramble_draw_stars(machine, bitmap, cliprect, 256);
10661041}
r11160r11161
10681043
10691044void jumpbug_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
10701045{
1046   galaxian_state *state = machine.driver_data<galaxian_state>();
10711047   /* blue background - 390 ohm resistor */
1072   bitmap_fill(bitmap, cliprect, background_enable ? MAKE_RGB(0,0,0x56) : RGB_BLACK);
1048   bitmap_fill(bitmap, cliprect, state->m_background_enable ? MAKE_RGB(0,0,0x56) : RGB_BLACK);
10731049
10741050   /* render stars same as scramble but nothing in the status area */
10751051   scramble_draw_stars(machine, bitmap, cliprect, 240);
r11160r11161
10781054
10791055void turtles_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
10801056{
1057   galaxian_state *state = machine.driver_data<galaxian_state>();
10811058   /*
10821059        The background color generator is connected this way:
10831060
r11160r11161
10851062            GREEN - 470 ohm resistor
10861063            BLUE  - 390 ohm resistor
10871064    */
1088   bitmap_fill(bitmap, cliprect, MAKE_RGB(background_red * 0x55, background_green * 0x47, background_blue * 0x55));
1065   bitmap_fill(bitmap, cliprect, MAKE_RGB(state->m_background_red * 0x55, state->m_background_green * 0x47, state->m_background_blue * 0x55));
10891066}
10901067
10911068
r11160r11161
11001077#ifdef UNUSED_FUNCTION
11011078static int flip_and_clip(rectangle *draw, int xstart, int xend, const rectangle *cliprect)
11021079{
1080   galaxian_state *state = machine.driver_data<galaxian_state>();
11031081   *draw = *cliprect;
1104   if (!flipscreen_x)
1082   if (!state->m_flipscreen_x)
11051083   {
11061084      draw->min_x = xstart * GALAXIAN_XSCALE;
11071085      draw->max_x = xend * GALAXIAN_XSCALE + (GALAXIAN_XSCALE - 1);
r11160r11161
11171095
11181096void amidar_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
11191097{
1098   galaxian_state *state = machine.driver_data<galaxian_state>();
11201099   const UINT8 *prom = machine.region("user1")->base();
11211100   rectangle draw;
11221101   int x;
r11160r11161
11381117                    GREEN - 560 ohm resistor
11391118                    BLUE  - 470 ohm resistor
11401119            */
1141         UINT8 red = ((~prom[x] & 0x02) && background_red) ? 0x7c : 0x00;
1142         UINT8 green = ((~prom[x] & 0x02) && background_green) ? 0x3c : 0x00;
1143         UINT8 blue = ((~prom[x] & 0x01) && background_blue) ? 0x47 : 0x00;
1120         UINT8 red = ((~prom[x] & 0x02) && state->m_background_red) ? 0x7c : 0x00;
1121         UINT8 green = ((~prom[x] & 0x02) && state->m_background_green) ? 0x3c : 0x00;
1122         UINT8 blue = ((~prom[x] & 0x01) && state->m_background_blue) ? 0x47 : 0x00;
11441123         bitmap_fill(bitmap, &draw, MAKE_RGB(red, green, blue));
11451124      }
11461125}
r11160r11161
11761155
11771156void galaxian_draw_bullet(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y)
11781157{
1158   galaxian_state *state = machine.driver_data<galaxian_state>();
11791159   /*
11801160        Both "shells" and "missiles" begin displaying when the horizontal counter
11811161        reaches $FC, and they stop displaying when it reaches $00, resulting in
r11160r11161
11831163        white; the final entry is called a "missile" and renders as yellow.
11841164    */
11851165   x -= 4;
1186   galaxian_draw_pixel(bitmap, cliprect, y, x++, bullet_color[offs]);
1187   galaxian_draw_pixel(bitmap, cliprect, y, x++, bullet_color[offs]);
1188   galaxian_draw_pixel(bitmap, cliprect, y, x++, bullet_color[offs]);
1189   galaxian_draw_pixel(bitmap, cliprect, y, x++, bullet_color[offs]);
1166   galaxian_draw_pixel(bitmap, cliprect, y, x++, state->m_bullet_color[offs]);
1167   galaxian_draw_pixel(bitmap, cliprect, y, x++, state->m_bullet_color[offs]);
1168   galaxian_draw_pixel(bitmap, cliprect, y, x++, state->m_bullet_color[offs]);
1169   galaxian_draw_pixel(bitmap, cliprect, y, x++, state->m_bullet_color[offs]);
11901170}
11911171
11921172
r11160r11161
12331213
12341214void theend_draw_bullet(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y)
12351215{
1216   galaxian_state *state = machine.driver_data<galaxian_state>();
12361217   /* Same as galaxian except blue/green are swapped */
12371218   x -= 4;
1238   galaxian_draw_pixel(bitmap, cliprect, y, x++, MAKE_RGB(RGB_RED(bullet_color[offs]), RGB_BLUE(bullet_color[offs]), RGB_GREEN(bullet_color[offs])));
1239   galaxian_draw_pixel(bitmap, cliprect, y, x++, MAKE_RGB(RGB_RED(bullet_color[offs]), RGB_BLUE(bullet_color[offs]), RGB_GREEN(bullet_color[offs])));
1240   galaxian_draw_pixel(bitmap, cliprect, y, x++, MAKE_RGB(RGB_RED(bullet_color[offs]), RGB_BLUE(bullet_color[offs]), RGB_GREEN(bullet_color[offs])));
1241   galaxian_draw_pixel(bitmap, cliprect, y, x++, MAKE_RGB(RGB_RED(bullet_color[offs]), RGB_BLUE(bullet_color[offs]), RGB_GREEN(bullet_color[offs])));
1219   galaxian_draw_pixel(bitmap, cliprect, y, x++, MAKE_RGB(RGB_RED(state->m_bullet_color[offs]), RGB_BLUE(state->m_bullet_color[offs]), RGB_GREEN(state->m_bullet_color[offs])));
1220   galaxian_draw_pixel(bitmap, cliprect, y, x++, MAKE_RGB(RGB_RED(state->m_bullet_color[offs]), RGB_BLUE(state->m_bullet_color[offs]), RGB_GREEN(state->m_bullet_color[offs])));
1221   galaxian_draw_pixel(bitmap, cliprect, y, x++, MAKE_RGB(RGB_RED(state->m_bullet_color[offs]), RGB_BLUE(state->m_bullet_color[offs]), RGB_GREEN(state->m_bullet_color[offs])));
1222   galaxian_draw_pixel(bitmap, cliprect, y, x++, MAKE_RGB(RGB_RED(state->m_bullet_color[offs]), RGB_BLUE(state->m_bullet_color[offs]), RGB_GREEN(state->m_bullet_color[offs])));
12421223}
12431224
12441225
r11160r11161
12501231 *************************************/
12511232
12521233/*** generic ***/
1253void upper_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
1234void upper_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
12541235{
12551236   /* tiles are in the upper half of a larger ROM */
12561237   *code += 0x100;
12571238}
12581239
1259void upper_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
1240void upper_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
12601241{
12611242   /* sprites are in the upper half of a larger ROM */
12621243   *code += 0x40;
r11160r11161
12641245
12651246
12661247/*** Frogger ***/
1267void frogger_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
1248void frogger_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
12681249{
12691250   *color = ((*color >> 1) & 0x03) | ((*color << 2) & 0x04);
12701251}
12711252
1272void frogger_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
1253void frogger_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
12731254{
12741255   *color = ((*color >> 1) & 0x03) | ((*color << 2) & 0x04);
12751256}
12761257
12771258
12781259/*** Ghostmuncher Galaxian ***/
1279void gmgalax_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
1260void gmgalax_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
12801261{
1281   *code |= gfxbank[0] << 9;
1282//  *color |= gfxbank[0] << 3;
1262   galaxian_state *state = machine.driver_data<galaxian_state>();
1263   *code |= state->m_gfxbank[0] << 9;
1264//  *color |= state->m_gfxbank[0] << 3;
12831265}
12841266
1285void gmgalax_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
1267void gmgalax_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
12861268{
1287   *code |= (gfxbank[0] << 7) | 0x40;
1288   *color |= gfxbank[0] << 3;
1269   galaxian_state *state = machine.driver_data<galaxian_state>();
1270   *code |= (state->m_gfxbank[0] << 7) | 0x40;
1271   *color |= state->m_gfxbank[0] << 3;
12891272}
12901273
12911274
12921275/*** Pisces ***/
1293void pisces_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
1276void pisces_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
12941277{
1295   *code |= gfxbank[0] << 8;
1278   galaxian_state *state = machine.driver_data<galaxian_state>();
1279   *code |= state->m_gfxbank[0] << 8;
12961280}
12971281
1298void pisces_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
1282void pisces_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
12991283{
1300   *code |= gfxbank[0] << 6;
1284   galaxian_state *state = machine.driver_data<galaxian_state>();
1285   *code |= state->m_gfxbank[0] << 6;
13011286}
13021287
13031288
13041289/*** Batman Part 2 ***/
1305void batman2_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
1290void batman2_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
13061291{
1292   galaxian_state *state = machine.driver_data<galaxian_state>();
13071293   if (*code & 0x80)
1308      *code |= gfxbank[0] << 8;
1294      *code |= state->m_gfxbank[0] << 8;
13091295}
13101296
13111297
13121298/*** Moon Cresta ***/
1313void mooncrst_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
1299void mooncrst_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
13141300{
1315   if (gfxbank[2] && (*code & 0xc0) == 0x80)
1316      *code = (*code & 0x3f) | (gfxbank[0] << 6) | (gfxbank[1] << 7) | 0x0100;
1301   galaxian_state *state = machine.driver_data<galaxian_state>();
1302   if (state->m_gfxbank[2] && (*code & 0xc0) == 0x80)
1303      *code = (*code & 0x3f) | (state->m_gfxbank[0] << 6) | (state->m_gfxbank[1] << 7) | 0x0100;
13171304}
13181305
1319void mooncrst_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
1306void mooncrst_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
13201307{
1321   if (gfxbank[2] && (*code & 0x30) == 0x20)
1322      *code = (*code & 0x0f) | (gfxbank[0] << 4) | (gfxbank[1] << 5) | 0x40;
1308   galaxian_state *state = machine.driver_data<galaxian_state>();
1309   if (state->m_gfxbank[2] && (*code & 0x30) == 0x20)
1310      *code = (*code & 0x0f) | (state->m_gfxbank[0] << 4) | (state->m_gfxbank[1] << 5) | 0x40;
13231311}
13241312
13251313
13261314/*** Moon Quasar ***/
1327void moonqsr_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
1315void moonqsr_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
13281316{
13291317   *code |= (attrib & 0x20) << 3;
13301318}
13311319
1332void moonqsr_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
1320void moonqsr_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
13331321{
13341322   *code |= (base[2] & 0x20) << 1;
13351323}
13361324
13371325
13381326/*** Moon Shuttle ***/
1339void mshuttle_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
1327void mshuttle_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
13401328{
13411329   *code |= (attrib & 0x30) << 4;
13421330}
13431331
1344void mshuttle_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
1332void mshuttle_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
13451333{
13461334   *code |= (base[2] & 0x30) << 2;
13471335}
13481336
13491337
13501338/*** Calipso ***/
1351void calipso_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
1339void calipso_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
13521340{
13531341   /* same as the others, but no sprite flipping, but instead the bits are used
13541342       as extra sprite code bits, giving 256 sprite images */
r11160r11161
13601348
13611349
13621350/*** Jumpbug ***/
1363void jumpbug_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
1351void jumpbug_extend_tile_info(running_machine &machine, UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
13641352{
1365   if ((*code & 0xc0) == 0x80 && (gfxbank[2] & 0x01))
1366      *code += 128 + (( gfxbank[0] & 0x01) << 6) +
1367                  (( gfxbank[1] & 0x01) << 7) +
1368                  ((~gfxbank[4] & 0x01) << 8);
1353   galaxian_state *state = machine.driver_data<galaxian_state>();
1354   if ((*code & 0xc0) == 0x80 && (state->m_gfxbank[2] & 0x01))
1355      *code += 128 + (( state->m_gfxbank[0] & 0x01) << 6) +
1356                  (( state->m_gfxbank[1] & 0x01) << 7) +
1357                  ((~state->m_gfxbank[4] & 0x01) << 8);
13691358}
13701359
1371void jumpbug_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
1360void jumpbug_extend_sprite_info(running_machine &machine, const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
13721361{
1373   if ((*code & 0x30) == 0x20 && (gfxbank[2] & 0x01) != 0)
1362   galaxian_state *state = machine.driver_data<galaxian_state>();
1363   if ((*code & 0x30) == 0x20 && (state->m_gfxbank[2] & 0x01) != 0)
13741364   {
1375      *code += 32 + (( gfxbank[0] & 0x01) << 4) +
1376                 (( gfxbank[1] & 0x01) << 5) +
1377                 ((~gfxbank[4] & 0x01) << 6);
1365      *code += 32 + (( state->m_gfxbank[0] & 0x01) << 4) +
1366                 (( state->m_gfxbank[1] & 0x01) << 5) +
1367                 ((~state->m_gfxbank[4] & 0x01) << 6);
13781368   }
13791369}
src/mame/video/arcadecl.c
r11160r11161
99
1010
1111#include "emu.h"
12#include "video/atarimo.h"
1213#include "includes/arcadecl.h"
1314
1415
src/mame/video/decospr.c
r11160r11161
395395
396396         x = spriteram[offs+1];
397397
398         if (!((y&0x2000) && (machine.primary_screen->frame_number() & 1)));
398         if (!((y&0x2000) && (machine.primary_screen->frame_number() & 1)))
399399         {
400400            if (!m_sprite_bitmap)
401401               colour = (spriteram[offs+2] >>0) & 0x1f;
src/mame/video/lordgun.c
r11160r11161
6161***************************************************************************/
6262
6363
64static TILE_GET_INFO( get_tile_info_0 )
64INLINE void get_tile_info(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, int _N_)
6565{
6666   lordgun_state *state = machine.driver_data<lordgun_state>();
67   UINT16 attr = state->m_vram_0[ tile_index * 2 + 0 ];
68   UINT16 code = state->m_vram_0[ tile_index * 2 + 1 ];
67   UINT16 attr = state->m_vram[_N_][tile_index * 2 + 0 ];
68   UINT16 code = state->m_vram[_N_][ tile_index * 2 + 1 ];
6969   UINT16 pri  = (attr & 0x0e00) >> 9;
70   SET_TILE_INFO( 0, code, ((attr & 0x0030) >> 4)+0x500/0x40+pri*0x800/0x40, TILE_FLIPXY(attr >> 14));
70   SET_TILE_INFO( _N_, code, ((attr & 0x0030) >> 4) + 0x10 + 0x4 * ((_N_ + 1) & 3) + pri*0x800/0x40, TILE_FLIPXY(attr >> 14));
7171}
7272
73static TILE_GET_INFO( get_tile_info_1 )
74{
75   lordgun_state *state = machine.driver_data<lordgun_state>();
76   UINT16 attr = state->m_vram_1[ tile_index * 2 + 0 ];
77   UINT16 code = state->m_vram_1[ tile_index * 2 + 1 ];
78   UINT16 pri  = (attr & 0x0e00) >> 9;
79   SET_TILE_INFO( 1, code, ((attr & 0x0070) >> 4)+0x600/0x40+pri*0x800/0x40, TILE_FLIPXY(attr >> 14));
80}
73static TILE_GET_INFO( get_tile_info_0 ) { get_tile_info(machine, tileinfo, tile_index, 0); }
74static TILE_GET_INFO( get_tile_info_1 ) { get_tile_info(machine, tileinfo, tile_index, 1); }
75static TILE_GET_INFO( get_tile_info_2 ) { get_tile_info(machine, tileinfo, tile_index, 2); }
76static TILE_GET_INFO( get_tile_info_3 ) { get_tile_info(machine, tileinfo, tile_index, 3); }
8177
82static TILE_GET_INFO( get_tile_info_2 )
78INLINE void lordgun_vram_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int _N_)
8379{
84   lordgun_state *state = machine.driver_data<lordgun_state>();
85   UINT16 attr = state->m_vram_2[ tile_index * 2 + 0 ];
86   UINT16 code = state->m_vram_2[ tile_index * 2 + 1 ];
87   UINT16 pri  = (attr & 0x0e00) >> 9;
88   SET_TILE_INFO( 2, code, ((attr & 0x0030) >> 4)+0x700/0x40+pri*0x800/0x40, TILE_FLIPXY(attr >> 14));
89}
90
91static TILE_GET_INFO( get_tile_info_3 )
92{
93   lordgun_state *state = machine.driver_data<lordgun_state>();
94   UINT16 attr = state->m_vram_3[ tile_index * 2 + 0 ];
95   UINT16 code = state->m_vram_3[ tile_index * 2 + 1 ];
96   UINT16 pri  = (attr & 0x0e00) >> 9;
97   SET_TILE_INFO( 3, code, ((attr & 0x00f0) >> 4)+0x400/0x40+pri*0x800/0x40, TILE_FLIPXY(attr >> 14));
98}
99
100WRITE16_HANDLER( lordgun_vram_0_w )
101{
10280   lordgun_state *state = space->machine().driver_data<lordgun_state>();
103   COMBINE_DATA(&state->m_vram_0[offset]);
104   tilemap_mark_tile_dirty(state->m_tilemap_0, offset/2);
81   COMBINE_DATA(&state->m_vram[_N_][offset]);
82   tilemap_mark_tile_dirty(state->m_tilemap[_N_], offset/2);
10583}
10684
107WRITE16_HANDLER( lordgun_vram_1_w )
108{
109   lordgun_state *state = space->machine().driver_data<lordgun_state>();
110   COMBINE_DATA(&state->m_vram_1[offset]);
111   tilemap_mark_tile_dirty(state->m_tilemap_1, offset/2);
112}
85WRITE16_HANDLER( lordgun_vram_0_w ) { lordgun_vram_w(space, offset, data, mem_mask, 0); }
86WRITE16_HANDLER( lordgun_vram_1_w ) { lordgun_vram_w(space, offset, data, mem_mask, 1); }
87WRITE16_HANDLER( lordgun_vram_2_w ) { lordgun_vram_w(space, offset, data, mem_mask, 2); }
88WRITE16_HANDLER( lordgun_vram_3_w ) { lordgun_vram_w(space, offset, data, mem_mask, 3); }
11389
114WRITE16_HANDLER( lordgun_vram_2_w )
115{
116   lordgun_state *state = space->machine().driver_data<lordgun_state>();
117   COMBINE_DATA(&state->m_vram_2[offset]);
118   tilemap_mark_tile_dirty(state->m_tilemap_2, offset/2);
119}
120
121WRITE16_HANDLER( lordgun_vram_3_w )
122{
123   lordgun_state *state = space->machine().driver_data<lordgun_state>();
124   COMBINE_DATA(&state->m_vram_3[offset]);
125   tilemap_mark_tile_dirty(state->m_tilemap_3, offset/2);
126}
127
12890/***************************************************************************
12991
13092    Video Init
r11160r11161
140102   int h = machine.primary_screen->height();
141103
142104   // 0x800 x 200
143   state->m_tilemap_0 = tilemap_create(   machine, get_tile_info_0, tilemap_scan_rows,
105   state->m_tilemap[0] = tilemap_create(   machine, get_tile_info_0, tilemap_scan_rows,
144106                         8,8, 0x100, 0x40 );
145107
146108   // 0x800 x 200
147   state->m_tilemap_1 = tilemap_create(   machine, get_tile_info_1, tilemap_scan_rows,
109   state->m_tilemap[1] = tilemap_create(   machine, get_tile_info_1, tilemap_scan_rows,
148110                         16,16, 0x80,0x20 );
149111
150112   // 0x800 x 200
151   state->m_tilemap_2 = tilemap_create(   machine, get_tile_info_2, tilemap_scan_rows,
113   state->m_tilemap[2] = tilemap_create(   machine, get_tile_info_2, tilemap_scan_rows,
152114                         32,32, 0x40,0x10 );
153115
154116   // 0x200 x 100
155   state->m_tilemap_3 = tilemap_create(   machine, get_tile_info_3, tilemap_scan_rows,
117   state->m_tilemap[3] = tilemap_create(   machine, get_tile_info_3, tilemap_scan_rows,
156118                         8,8, 0x40,0x20 );
157119
158   tilemap_set_scroll_rows(state->m_tilemap_0,1);
159   tilemap_set_scroll_cols(state->m_tilemap_0,1);
160   tilemap_set_transparent_pen(state->m_tilemap_0,0x3f);
120   tilemap_set_scroll_rows(state->m_tilemap[0],1);
121   tilemap_set_scroll_cols(state->m_tilemap[0],1);
122   tilemap_set_transparent_pen(state->m_tilemap[0],0x3f);
161123
162124   // Has line scroll
163   tilemap_set_scroll_rows(state->m_tilemap_1,0x200);
164   tilemap_set_scroll_cols(state->m_tilemap_1,1);
165   tilemap_set_transparent_pen(state->m_tilemap_1,0x3f);
125   tilemap_set_scroll_rows(state->m_tilemap[1],0x200);
126   tilemap_set_scroll_cols(state->m_tilemap[1],1);
127   tilemap_set_transparent_pen(state->m_tilemap[1],0x3f);
166128
167   tilemap_set_scroll_rows(state->m_tilemap_2,1);
168   tilemap_set_scroll_cols(state->m_tilemap_2,1);
169   tilemap_set_transparent_pen(state->m_tilemap_2,0x3f);
129   tilemap_set_scroll_rows(state->m_tilemap[2],1);
130   tilemap_set_scroll_cols(state->m_tilemap[2],1);
131   tilemap_set_transparent_pen(state->m_tilemap[2],0x3f);
170132
171   tilemap_set_scroll_rows(state->m_tilemap_3,1);
172   tilemap_set_scroll_cols(state->m_tilemap_3,1);
173   tilemap_set_transparent_pen(state->m_tilemap_3,0x3f);
133   tilemap_set_scroll_rows(state->m_tilemap[3],1);
134   tilemap_set_scroll_cols(state->m_tilemap[3],1);
135   tilemap_set_transparent_pen(state->m_tilemap[3],0x3f);
174136
175   // Buffer state->m_bitmaps for 4 tilemaps (0-3) + sprites (4)
137   // Buffer bitmaps for 4 tilemaps (0-3) + sprites (4)
176138   for (i = 0; i < 5; i++)
177139      state->m_bitmaps[i] = auto_bitmap_alloc(machine, w, h, BITMAP_FORMAT_INDEXED16);
178140}
r11160r11161
392354
393355   int x, y;
394356
395   tilemap_set_scrollx( state->m_tilemap_0, 0, *state->m_scroll_x_0 );
396   tilemap_set_scrolly( state->m_tilemap_0, 0, *state->m_scroll_y_0 );
357   tilemap_set_scrollx( state->m_tilemap[0], 0, *state->m_scroll_x[0] );
358   tilemap_set_scrolly( state->m_tilemap[0], 0, *state->m_scroll_y[0] );
397359
398360   for (y = 0; y < 0x200; y++)
399      tilemap_set_scrollx( state->m_tilemap_1, y, (*state->m_scroll_x_1) + state->m_scrollram[y * 4/2 + 2/2]);
400   tilemap_set_scrolly( state->m_tilemap_1, 0, *state->m_scroll_y_1 );
361      tilemap_set_scrollx( state->m_tilemap[1], y, (*state->m_scroll_x[1]) + state->m_scrollram[y * 4/2 + 2/2]);
362   tilemap_set_scrolly( state->m_tilemap[1], 0, *state->m_scroll_y[1] );
401363
402   tilemap_set_scrollx( state->m_tilemap_2, 0, *state->m_scroll_x_2 );
403   tilemap_set_scrolly( state->m_tilemap_2, 0, *state->m_scroll_y_2 );
364   tilemap_set_scrollx( state->m_tilemap[2], 0, *state->m_scroll_x[2] );
365   tilemap_set_scrolly( state->m_tilemap[2], 0, *state->m_scroll_y[2] );
404366
405   tilemap_set_scrollx( state->m_tilemap_3, 0, *state->m_scroll_x_3 );
406   tilemap_set_scrolly( state->m_tilemap_3, 0, *state->m_scroll_y_3 );
367   tilemap_set_scrollx( state->m_tilemap[3], 0, *state->m_scroll_x[3] );
368   tilemap_set_scrolly( state->m_tilemap[3], 0, *state->m_scroll_y[3] );
407369
408370   // Rendering:
409371
r11160r11161
416378   for (l = 0; l < 5; l++)
417379      bitmap_fill(state->m_bitmaps[l], cliprect, trans_pen);
418380
419   if (layers_ctrl & 1)   tilemap_draw(state->m_bitmaps[0], cliprect, state->m_tilemap_0, 0, 0);
420   if (layers_ctrl & 2)   tilemap_draw(state->m_bitmaps[1], cliprect, state->m_tilemap_1, 0, 0);
421   if (layers_ctrl & 4)   tilemap_draw(state->m_bitmaps[2], cliprect, state->m_tilemap_2, 0, 0);
422   if (layers_ctrl & 8)   tilemap_draw(state->m_bitmaps[3], cliprect, state->m_tilemap_3, 0, 0);
381   if (layers_ctrl & 1)   tilemap_draw(state->m_bitmaps[0], cliprect, state->m_tilemap[0], 0, 0);
382   if (layers_ctrl & 2)   tilemap_draw(state->m_bitmaps[1], cliprect, state->m_tilemap[1], 0, 0);
383   if (layers_ctrl & 4)   tilemap_draw(state->m_bitmaps[2], cliprect, state->m_tilemap[2], 0, 0);
384   if (layers_ctrl & 8)   tilemap_draw(state->m_bitmaps[3], cliprect, state->m_tilemap[3], 0, 0);
423385   if (layers_ctrl & 16)   draw_sprites(screen->machine(), state->m_bitmaps[4], cliprect);
424386
425387   // copy to screen bitmap
src/mame/video/namcos21.c
r11160r11161
1313
1414#define FRAMEBUFFER_SIZE_IN_BYTES (sizeof(UINT16)*NAMCOS21_POLY_FRAME_WIDTH*NAMCOS21_POLY_FRAME_HEIGHT)
1515
16/* work (hidden) framebuffer */
17static UINT16 *mpPolyFrameBufferPens;
18static UINT16 *mpPolyFrameBufferZ;
19
20/* visible framebuffer */
21static UINT16 *mpPolyFrameBufferPens2;
22static UINT16 *mpPolyFrameBufferZ2;
23
24static UINT16 winrun_color;
25static UINT16 winrun_gpu_register[0x10/2];
26
2716READ16_HANDLER(winrun_gpu_color_r)
2817{
29   return winrun_color;
18   namcos21_state *state = space->machine().driver_data<namcos21_state>();
19   return state->m_winrun_color;
3020}
3121
3222WRITE16_HANDLER(winrun_gpu_color_w)
3323{
34   COMBINE_DATA( &winrun_color );
24   namcos21_state *state = space->machine().driver_data<namcos21_state>();
25   COMBINE_DATA( &state->m_winrun_color );
3526}
3627
3728READ16_HANDLER(winrun_gpu_register_r)
3829{
39   return winrun_gpu_register[offset];
30   namcos21_state *state = space->machine().driver_data<namcos21_state>();
31   return state->m_winrun_gpu_register[offset];
4032}
4133
4234WRITE16_HANDLER(winrun_gpu_register_w)
4335{
44   COMBINE_DATA( &winrun_gpu_register[offset] );
36   namcos21_state *state = space->machine().driver_data<namcos21_state>();
37   COMBINE_DATA( &state->m_winrun_gpu_register[offset] );
4538}
4639
4740WRITE16_HANDLER( winrun_gpu_videoram_w)
r11160r11161
7063static void
7164AllocatePolyFrameBuffer( running_machine &machine )
7265{
73   mpPolyFrameBufferZ     = auto_alloc_array(machine, UINT16, FRAMEBUFFER_SIZE_IN_BYTES/2 );
74   mpPolyFrameBufferPens  = auto_alloc_array(machine, UINT16, FRAMEBUFFER_SIZE_IN_BYTES/2 );
66   namcos21_state *state = machine.driver_data<namcos21_state>();
67   state->m_mpPolyFrameBufferZ     = auto_alloc_array(machine, UINT16, FRAMEBUFFER_SIZE_IN_BYTES/2 );
68   state->m_mpPolyFrameBufferPens  = auto_alloc_array(machine, UINT16, FRAMEBUFFER_SIZE_IN_BYTES/2 );
7569
76   mpPolyFrameBufferZ2    = auto_alloc_array(machine, UINT16, FRAMEBUFFER_SIZE_IN_BYTES/2 );
77   mpPolyFrameBufferPens2 = auto_alloc_array(machine, UINT16, FRAMEBUFFER_SIZE_IN_BYTES/2 );
70   state->m_mpPolyFrameBufferZ2    = auto_alloc_array(machine, UINT16, FRAMEBUFFER_SIZE_IN_BYTES/2 );
71   state->m_mpPolyFrameBufferPens2 = auto_alloc_array(machine, UINT16, FRAMEBUFFER_SIZE_IN_BYTES/2 );
7872
79   namcos21_ClearPolyFrameBuffer();
80   namcos21_ClearPolyFrameBuffer();
73   namcos21_ClearPolyFrameBuffer(machine);
74   namcos21_ClearPolyFrameBuffer(machine);
8175} /* AllocatePolyFrameBuffer */
8276
8377void
84namcos21_ClearPolyFrameBuffer( void )
78namcos21_ClearPolyFrameBuffer( running_machine &machine )
8579{
80   namcos21_state *state = machine.driver_data<namcos21_state>();
8681   int i;
8782   UINT16 *temp2;
8883
8984   /* swap work and visible framebuffers */
90   temp2 = mpPolyFrameBufferZ;
91   mpPolyFrameBufferZ = mpPolyFrameBufferZ2;
92   mpPolyFrameBufferZ2 = temp2;
85   temp2 = state->m_mpPolyFrameBufferZ;
86   state->m_mpPolyFrameBufferZ = state->m_mpPolyFrameBufferZ2;
87   state->m_mpPolyFrameBufferZ2 = temp2;
9388
94   temp2 = mpPolyFrameBufferPens;
95   mpPolyFrameBufferPens = mpPolyFrameBufferPens2;
96   mpPolyFrameBufferPens2 = temp2;
89   temp2 = state->m_mpPolyFrameBufferPens;
90   state->m_mpPolyFrameBufferPens = state->m_mpPolyFrameBufferPens2;
91   state->m_mpPolyFrameBufferPens2 = temp2;
9792
9893   /* wipe work zbuffer */
9994   for( i=0; i<NAMCOS21_POLY_FRAME_WIDTH*NAMCOS21_POLY_FRAME_HEIGHT; i++ )
10095   {
101      mpPolyFrameBufferZ[i] = 0x7fff;
96      state->m_mpPolyFrameBufferZ[i] = 0x7fff;
10297   }
10398} /* namcos21_ClearPolyFrameBuffer */
10499
105100static void
106CopyVisiblePolyFrameBuffer( bitmap_t *bitmap, const rectangle *clip, int zlo, int zhi )
107{ /* blit the visible framebuffer */
101CopyVisiblePolyFrameBuffer( running_machine &machine, bitmap_t *bitmap, const rectangle *clip, int zlo, int zhi )
102{
103   namcos21_state *state = machine.driver_data<namcos21_state>(); /* blit the visible framebuffer */
108104   int sy;
109105   for( sy=clip->min_y; sy<=clip->max_y; sy++ )
110106   {
111107      UINT16 *dest = BITMAP_ADDR16(bitmap, sy, 0);
112      const UINT16 *pPen = mpPolyFrameBufferPens2+NAMCOS21_POLY_FRAME_WIDTH*sy;
113      const UINT16 *pZ = mpPolyFrameBufferZ2+NAMCOS21_POLY_FRAME_WIDTH*sy;
108      const UINT16 *pPen = state->m_mpPolyFrameBufferPens2+NAMCOS21_POLY_FRAME_WIDTH*sy;
109      const UINT16 *pZ = state->m_mpPolyFrameBufferZ2+NAMCOS21_POLY_FRAME_WIDTH*sy;
114110      int sx;
115111      for( sx=clip->min_x; sx<=clip->max_x; sx++ )
116112      {
r11160r11161
191187      namco_obj_draw(screen->machine(), bitmap, cliprect, 14 );   //driver's eyes
192188   }
193189
194   CopyVisiblePolyFrameBuffer( bitmap, cliprect,0x7fc0,0x7ffe );
190   CopyVisiblePolyFrameBuffer( screen->machine(), bitmap, cliprect, 0x7fc0, 0x7ffe );
195191
196192   if( namcos2_gametype != NAMCOS21_WINRUN91 )
197193   { /* draw low priority 2d sprites */
r11160r11161
199195      namco_obj_draw(screen->machine(), bitmap, cliprect, 1 );
200196   }
201197
202   CopyVisiblePolyFrameBuffer( bitmap, cliprect,0,0x7fbf );
198   CopyVisiblePolyFrameBuffer( screen->machine(), bitmap, cliprect, 0, 0x7fbf );
203199
204200
205201   if( namcos2_gametype != NAMCOS21_WINRUN91 )
r11160r11161
212208   }
213209   else
214210   { /* winrun bitmap layer */
215      int yscroll = -cliprect->min_y+(INT16)winrun_gpu_register[0x2/2];
216      int base = 0x1000+0x100*(winrun_color&0xf);
211      int yscroll = -cliprect->min_y+(INT16)state->m_winrun_gpu_register[0x2/2];
212      int base = 0x1000+0x100*(state->m_winrun_color&0xf);
217213      int sx,sy;
218214      for( sy=cliprect->min_y; sy<=cliprect->max_y; sy++ )
219215      {
r11160r11161
259255#define SWAP(T,A,B) { const T *temp = A; A = B; B = temp; }
260256
261257static void
262renderscanline_flat( const edge *e1, const edge *e2, int sy, unsigned color, int depthcueenable )
258renderscanline_flat( namcos21_state *state, const edge *e1, const edge *e2, int sy, unsigned color, int depthcueenable )
263259{
264260   if( e1->x > e2->x )
265261   {
r11160r11161
267263   }
268264
269265   {
270      UINT16 *pDest = mpPolyFrameBufferPens + sy*NAMCOS21_POLY_FRAME_WIDTH;
271      UINT16 *pZBuf = mpPolyFrameBufferZ    + sy*NAMCOS21_POLY_FRAME_WIDTH;
266      UINT16 *pDest = state->m_mpPolyFrameBufferPens + sy*NAMCOS21_POLY_FRAME_WIDTH;
267      UINT16 *pZBuf = state->m_mpPolyFrameBufferZ    + sy*NAMCOS21_POLY_FRAME_WIDTH;
272268      int x0 = (int)e1->x;
273269      int x1 = (int)e2->x;
274270      int w = x1-x0;
r11160r11161
324320
325321static void
326322rendertri(
323      namcos21_state *state,
327324      const vertex *v0,
328325      const vertex *v1,
329326      const vertex *v2,
r11160r11161
395392
396393         for( y=ystart; y<yend; y++ )
397394         {
398            renderscanline_flat( &e1, &e2, y, color, depthcueenable );
395            renderscanline_flat( state, &e1, &e2, y, color, depthcueenable );
399396
400397            e2.x += dx2dy;
401398            e2.z += dz2dy;
r11160r11161
429426         }
430427         for( y=ystart; y<yend; y++ )
431428         {
432            renderscanline_flat( &e1, &e2, y, color, depthcueenable );
429            renderscanline_flat( state, &e1, &e2, y, color, depthcueenable );
433430
434431            e2.x += dx2dy;
435432            e2.z += dz2dy;
r11160r11161
442439} /* rendertri */
443440
444441void
445namcos21_DrawQuad( int sx[4], int sy[4], int zcode[4], int color )
442namcos21_DrawQuad( running_machine &machine, int sx[4], int sy[4], int zcode[4], int color )
446443{
444   namcos21_state *state = machine.driver_data<namcos21_state>();
447445   vertex a,b,c,d;
448446   int depthcueenable = 1;
449447   /*
r11160r11161
496494   d.y = sy[3];
497495   d.z = zcode[3];
498496
499   rendertri( &a, &b, &c, color, depthcueenable );
500   rendertri( &c, &d, &a, color, depthcueenable );
497   rendertri( state, &a, &b, &c, color, depthcueenable );
498   rendertri( state, &c, &d, &a, color, depthcueenable );
501499} /* namcos21_DrawQuad */
src/mame/video/skullxbo.c
r11160r11161
55****************************************************************************/
66
77#include "emu.h"
8#include "video/atarimo.h"
89#include "includes/skullxbo.h"
910
1011
src/mame/video/namcos22.c
r11160r11161
4141// uncomment this line to render everything as quads
4242//#define RENDER_AS_QUADS
4343
44static int mbSuperSystem22; /* used to conditionally support Super System22-specific features */
45static int mbSpotlightEnable;
46static UINT16 *namcos22_czram[4];
4744
48static poly_manager *poly;
4945
5046static UINT8
5147nthbyte( const UINT32 *pSource, int offs )
r11160r11161
8480} mixer;
8581
8682static void
87UpdateVideoMixer( void )
83UpdateVideoMixer( running_machine &machine )
8884{
89   poly_wait(poly, "UpdateVideoMixer");
85   namcos22_state *state = machine.driver_data<namcos22_state>();
86   poly_wait(state->m_poly, "UpdateVideoMixer");
9087   memset( &mixer, 0, sizeof(mixer) );
91   if( mbSuperSystem22 )
88   if( state->m_mbSuperSystem22 )
9289   {
9390/*
9491           0 1 2 3  4 5 6 7  8 9 a b  c d e f 10       14       18       1c
r11160r11161
989500824000: ffffff00 00000000 1800187f 00800000 0080007f 0f000000 0000037f 00010007 // trans poly(2)
999600824000: ffffff00 00000000 1800187f 00000000 0000007f 0f800000 0000037f 00010007 // trans text
10097*/
101      mixer.rFogColor         = nthbyte( namcos22_gamma, 0x05 );
102      mixer.gFogColor         = nthbyte( namcos22_gamma, 0x06 );
103      mixer.bFogColor         = nthbyte( namcos22_gamma, 0x07 );
104      mixer.rBackColor        = nthbyte( namcos22_gamma, 0x08 );
105      mixer.gBackColor        = nthbyte( namcos22_gamma, 0x09 );
106      mixer.bBackColor        = nthbyte( namcos22_gamma, 0x0a );
107      mixer.spot_translucency = nthbyte( namcos22_gamma, 0x0d );
108      mixer.poly_translucency = nthbyte( namcos22_gamma, 0x11 );
109      mixer.text_translucency = nthbyte( namcos22_gamma, 0x15 );
110      mixer.rFadeColor        = nthbyte( namcos22_gamma, 0x16 );
111      mixer.gFadeColor        = nthbyte( namcos22_gamma, 0x17 );
112      mixer.bFadeColor        = nthbyte( namcos22_gamma, 0x18 );
113      mixer.fadeFactor        = nthbyte( namcos22_gamma, 0x19 );
114      mixer.target            = nthbyte( namcos22_gamma, 0x1a );
115      mixer.palBase           = nthbyte( namcos22_gamma, 0x1b );
98      mixer.rFogColor         = nthbyte( state->m_gamma, 0x05 );
99      mixer.gFogColor         = nthbyte( state->m_gamma, 0x06 );
100      mixer.bFogColor         = nthbyte( state->m_gamma, 0x07 );
101      mixer.rBackColor        = nthbyte( state->m_gamma, 0x08 );
102      mixer.gBackColor        = nthbyte( state->m_gamma, 0x09 );
103      mixer.bBackColor        = nthbyte( state->m_gamma, 0x0a );
104      mixer.spot_translucency = nthbyte( state->m_gamma, 0x0d );
105      mixer.poly_translucency = nthbyte( state->m_gamma, 0x11 );
106      mixer.text_translucency = nthbyte( state->m_gamma, 0x15 );
107      mixer.rFadeColor        = nthbyte( state->m_gamma, 0x16 );
108      mixer.gFadeColor        = nthbyte( state->m_gamma, 0x17 );
109      mixer.bFadeColor        = nthbyte( state->m_gamma, 0x18 );
110      mixer.fadeFactor        = nthbyte( state->m_gamma, 0x19 );
111      mixer.target            = nthbyte( state->m_gamma, 0x1a );
112      mixer.palBase           = nthbyte( state->m_gamma, 0x1b );
116113   }
117114   else
118115   {
r11160r11161
12612390020200: ff100000 00000000 00000000 00000000
127124*/
128125      mixer.palBase     = 0x7f;
129      mixer.target      = 0x7;//nthbyte( namcos22_gamma, 0x0002 )*256 + nthbyte( namcos22_gamma, 0x0003 );
130      mixer.rFadeColor  = nthbyte( namcos22_gamma, 0x0011 )*256 + nthbyte( namcos22_gamma, 0x0012 );
131      mixer.gFadeColor  = nthbyte( namcos22_gamma, 0x0013 )*256 + nthbyte( namcos22_gamma, 0x0014 );
132      mixer.bFadeColor  = nthbyte( namcos22_gamma, 0x0015 )*256 + nthbyte( namcos22_gamma, 0x0016 );
126      mixer.target      = 0x7;//nthbyte( state->m_gamma, 0x0002 )*256 + nthbyte( state->m_gamma, 0x0003 );
127      mixer.rFadeColor  = nthbyte( state->m_gamma, 0x0011 )*256 + nthbyte( state->m_gamma, 0x0012 );
128      mixer.gFadeColor  = nthbyte( state->m_gamma, 0x0013 )*256 + nthbyte( state->m_gamma, 0x0014 );
129      mixer.bFadeColor  = nthbyte( state->m_gamma, 0x0015 )*256 + nthbyte( state->m_gamma, 0x0016 );
133130
134131      mixer.fadeFactor  = 0x100 - mixer.rFadeColor; // hack
135132      mixer.rFadeColor  = 0;
136133      mixer.gFadeColor  = 0;
137134      mixer.bFadeColor  = 0;
138135
139      mixer.rFogColor   = nthbyte( namcos22_gamma, 0x0100 );
140      mixer.rFogColor2  = nthbyte( namcos22_gamma, 0x0101 );
141      mixer.gFogColor   = nthbyte( namcos22_gamma, 0x0180 );
142      mixer.gFogColor2  = nthbyte( namcos22_gamma, 0x0181 );
143      mixer.bFogColor   = nthbyte( namcos22_gamma, 0x0200 );
144      mixer.bFogColor2  = nthbyte( namcos22_gamma, 0x0201 );
136      mixer.rFogColor   = nthbyte( state->m_gamma, 0x0100 );
137      mixer.rFogColor2  = nthbyte( state->m_gamma, 0x0101 );
138      mixer.gFogColor   = nthbyte( state->m_gamma, 0x0180 );
139      mixer.gFogColor2  = nthbyte( state->m_gamma, 0x0181 );
140      mixer.bFogColor   = nthbyte( state->m_gamma, 0x0200 );
141      mixer.bFogColor2  = nthbyte( state->m_gamma, 0x0201 );
145142
146143/*  +0x0002.w   Fader Enable(?) (0: disabled)
147144 *  +0x0011.w   Display Fader (R) (0x0100 = 1.0)
r11160r11161
160157INLINE UINT8
161158Clamp256( int v )
162159{
163   if( v<0 )
164   {
165      v = 0;
166   }
167   else if( v>255 )
168   {
169      v = 255;
170   }
171   return v;
160   if( v<0 )
161   {
162      v = 0;
163   }
164   else if( v>255 )
165   {
166      v = 255;
167   }
168   return v;
172169} /* Clamp256 */
173170
174171#ifdef MAME_DEBUG
r11160r11161
177174
178175static struct
179176{
180   int cx,cy;
181   rectangle scissor;
177   int cx,cy;
178   rectangle scissor;
182179} mClip;
183180
184181static void
185182poly3d_Clip( float vx, float vy, float vw, float vh )
186183{
187   int cx = 320+vx;
188   int cy = 240+vy;
189   mClip.cx = cx;
190   mClip.cy = cy;
191   mClip.scissor.min_x = cx + vw;
192   mClip.scissor.min_y = cy + vh;
193   mClip.scissor.max_x = cx - vw;
194   mClip.scissor.max_y = cy - vh;
195   if( mClip.scissor.min_x<0 )   mClip.scissor.min_x = 0;
196   if( mClip.scissor.min_y<0 )   mClip.scissor.min_y = 0;
197   if( mClip.scissor.max_x>639 ) mClip.scissor.max_x = 639;
198   if( mClip.scissor.max_y>479 ) mClip.scissor.max_y = 479;
184   int cx = 320+vx;
185   int cy = 240+vy;
186   mClip.cx = cx;
187   mClip.cy = cy;
188   mClip.scissor.min_x = cx + vw;
189   mClip.scissor.min_y = cy + vh;
190   mClip.scissor.max_x = cx - vw;
191   mClip.scissor.max_y = cy - vh;
192   if( mClip.scissor.min_x<0 )   mClip.scissor.min_x = 0;
193   if( mClip.scissor.min_y<0 )   mClip.scissor.min_y = 0;
194   if( mClip.scissor.max_x>639 ) mClip.scissor.max_x = 639;
195   if( mClip.scissor.max_y>479 ) mClip.scissor.max_y = 479;
199196}
200197
201198static void
202199poly3d_NoClip( void )
203200{
204   mClip.cx = 640/2;
205   mClip.cy = 480/2;
206   mClip.scissor.min_x = 0;
207   mClip.scissor.max_x = 639;
208   mClip.scissor.min_y = 0;
209   mClip.scissor.max_x = 479;
201   mClip.cx = 640/2;
202   mClip.cy = 480/2;
203   mClip.scissor.min_x = 0;
204   mClip.scissor.max_x = 639;
205   mClip.scissor.min_y = 0;
206   mClip.scissor.max_x = 479;
210207}
211208
212209typedef struct
213210{
214   float x,y,z;
215   int u,v; /* 0..0xfff */
216   int bri; /* 0..0xff */
211   float x,y,z;
212   int u,v; /* 0..0xfff */
213   int bri; /* 0..0xff */
217214} Poly3dVertex;
218215
219216#define MIN_Z (10.0f)
r11160r11161
232229
233230#define SWAP(A,B) { const void *temp = A; A = B; B = temp; }
234231
235static UINT16 *mpTextureTileMap16;
236static UINT8 *mpTextureTileMapAttr;
237static UINT8 *mpTextureTileData;
238static UINT8 mXYAttrToPixel[16][16][16];
239232
240INLINE unsigned texel( unsigned x, unsigned y )
233INLINE unsigned texel( namcos22_state *state, unsigned x, unsigned y )
241234{
242235   unsigned offs = ((y&0xfff0)<<4)|((x&0xff0)>>4);
243   unsigned tile = mpTextureTileMap16[offs];
244   return mpTextureTileData[(tile<<8)|mXYAttrToPixel[mpTextureTileMapAttr[offs]][x&0xf][y&0xf]];
236   unsigned tile = state->m_mpTextureTileMap16[offs];
237   return state->m_mpTextureTileData[(tile<<8)|state->m_mXYAttrToPixel[state->m_mpTextureTileMapAttr[offs]][x&0xf][y&0xf]];
245238} /* texel */
246239
247240
r11160r11161
249242typedef struct _poly_extra_data poly_extra_data;
250243struct _poly_extra_data
251244{
245   running_machine *machine;
252246   rgbint fogColor;
253247   rgbint fadeColor;
254248   const pen_t *pens;
r11160r11161
278272   float di = extent->param[3].dpdx;
279273   bitmap_t *bitmap = (bitmap_t *)dest;
280274   const poly_extra_data *extra = (const poly_extra_data *)extradata;
275   namcos22_state *state = extra->machine->driver_data<namcos22_state>();
281276   int bn = extra->bn * 0x1000;
282277   const pen_t *pens = extra->pens;
283278   int fogFactor = 0xff - extra->fogFactor;
r11160r11161
324319      for( x=extent->startx; x<extent->stopx; x++ )
325320      {
326321         float ooz = 1.0f / z;
327         int pen = texel((int)(u * ooz),bn+(int)(v*ooz));
322         int pen = texel(state, (int)(u * ooz),bn+(int)(v*ooz));
328323         int shade = i*ooz;
329324         rgbint rgb;
330325
r11160r11161
359354         if( pCharPri[x]==0 )
360355         {
361356            float ooz = 1.0f / z;
362            int pen = texel((int)(u * ooz),bn+(int)(v*ooz));
357            int pen = texel(state, (int)(u * ooz),bn+(int)(v*ooz));
363358            int shade = i*ooz;
364359            rgbint rgb;
365360
r11160r11161
385380
386381static void poly3d_DrawQuad(running_machine &machine, bitmap_t *bitmap, int textureBank, int color, Poly3dVertex pv[4], UINT16 flags, int direct, int cmode )
387382{
383   namcos22_state *state = machine.driver_data<namcos22_state>();
388384   poly_extra_data *extra;
389385   poly_vertex v[4], clipv[6];
390386   int clipverts;
r11160r11161
434430      }
435431   }
436432
437   extra = (poly_extra_data *)poly_get_extra_data(poly);
433   extra = (poly_extra_data *)poly_get_extra_data(state->m_poly);
438434
435   extra->machine = &machine;
439436   extra->pens = &machine.pens[(color&0x7f)<<8];
440437   extra->priority_bitmap = machine.priority_bitmap;
441438   extra->bn = textureBank;
r11160r11161
450447      rgb_comp_to_rgbint(&extra->fadeColor, mixer.rFadeColor, mixer.gFadeColor, mixer.bFadeColor);
451448   }
452449
453   if( mbSuperSystem22 )
450   if( state->m_mbSuperSystem22 )
454451   {
455452      if( !(color&0x80) )
456453      {
457454         int cz = flags>>8;
458455         static const int cztype_remap[4] = { 3,1,2,0 };
459456         int cztype = flags&3;
460         if( nthword(namcos22_czattr,4)&(0x4000>>(cztype*4)) )
457         if( nthword(state->m_czattr,4)&(0x4000>>(cztype*4)) )
461458         {
462            int fogDelta = (INT16)nthword(namcos22_czattr, cztype);
463            int fogDensity = fogDelta + namcos22_czram[cztype_remap[cztype]][cz];
464            //          if( fogDelta == 0x8000 ) fogDelta = -0x7fff;
459            int fogDelta = (INT16)nthword(state->m_czattr, cztype);
460            int fogDensity = fogDelta + state->m_czram[cztype_remap[cztype]][cz];
461            //if( fogDelta == 0x8000 ) fogDelta = -0x7fff;
465462            //cz = Clamp256(cz+fogDelta);
466463            if( fogDensity<0x0000 )
467464            {
r11160r11161
478475   }
479476
480477#ifdef RENDER_AS_QUADS
481   poly_render_quad_fan(poly, bitmap, &mClip.scissor, renderscanline_uvi_full, 4, clipverts, clipv);
478   poly_render_quad_fan(state->m_poly, bitmap, &mClip.scissor, renderscanline_uvi_full, 4, clipverts, clipv);
482479#else
483   poly_render_triangle_fan(poly, bitmap, &mClip.scissor, renderscanline_uvi_full, 4, clipverts, clipv);
480   poly_render_triangle_fan(state->m_poly, bitmap, &mClip.scissor, renderscanline_uvi_full, 4, clipverts, clipv);
484481#endif
485482}
486483
r11160r11161
490487   int y_index = extent->param[1].start * 65536.0f;
491488   int dx = extent->param[0].dpdx * 65536.0f;
492489   const poly_extra_data *extra = (const poly_extra_data *)extradata;
490   namcos22_state *state = extra->machine->driver_data<namcos22_state>();
493491   bitmap_t *destmap = (bitmap_t *)destbase;
494492   const pen_t *pal = extra->pens;
495493   int prioverchar = extra->prioverchar;
r11160r11161
504502   INT16 fogDelta = 0;
505503   int fadeEnable = (mixer.target&2) && mixer.fadeFactor;
506504
507   if( mbSuperSystem22 )
505   if( state->m_mbSuperSystem22 )
508506   {
509      fogDelta = nthword(namcos22_czattr, 0 );
510      bFogEnable = nthword(namcos22_czattr,4)&0x4000; /* ? */
507      fogDelta = nthword(state->m_czattr, 0 );
508      bFogEnable = nthword(state->m_czattr,4)&0x4000; /* ? */
511509   }
512510   else
513511   {
r11160r11161
528526            if( bFogEnable && z!=0xffff )
529527            {
530528               int zc = Clamp256(fogDelta + z);
531               UINT16 fogDensity = namcos22_czram[3][zc];
529               UINT16 fogDensity = state->m_czram[3][zc];
532530               if( fogDensity>0 )
533531               {
534532                  int fogDensity2 = 0x2000 - fogDensity;
r11160r11161
561559   UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
562560   int scalex, int scaley, int z, int prioverchar, int alpha )
563561{
562   namcos22_state *state = gfx->machine().driver_data<namcos22_state>();
564563   int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
565564   int sprite_screen_width = (scalex*gfx->width+0x8000)>>16;
566565   if (sprite_screen_width && sprite_screen_height && gfx)
r11160r11161
591590      vert[3].p[0] = flipx ? fwidth : 0;
592591      vert[3].p[1] = flipy ? 0 : fheight;
593592
594      extra = (poly_extra_data *)poly_get_extra_data(poly);
593      extra = (poly_extra_data *)poly_get_extra_data(state->m_poly);
594      extra->machine = &gfx->machine();
595595      extra->z = z;
596596      extra->alpha = alpha;
597597      extra->prioverchar = prioverchar;
r11160r11161
600600      extra->priority_bitmap = gfx->machine().priority_bitmap;
601601      extra->source = gfx_element_get_data(gfx, code % gfx->total_elements);
602602#ifdef RENDER_AS_QUADS
603      poly_render_quad_fan(poly, dest_bmp, clip, renderscanline_sprite, 2, 4, &vert[0]);
603      poly_render_quad_fan(state->m_poly, dest_bmp, clip, renderscanline_sprite, 2, 4, &vert[0]);
604604#else
605      poly_render_triangle_fan(poly, dest_bmp, clip, renderscanline_sprite, 2, 4, &vert[0]);
605      poly_render_triangle_fan(state->m_poly, dest_bmp, clip, renderscanline_sprite, 2, 4, &vert[0]);
606606#endif
607607   }
608608} /* mydrawgfxzoom */
r11160r11161
610610static void
611611ApplyGamma( running_machine &machine, bitmap_t *bitmap )
612612{
613   namcos22_state *state = machine.driver_data<namcos22_state>();
613614   int x,y;
614   if( mbSuperSystem22 )
615   if( state->m_mbSuperSystem22 )
615616   { /* super system 22 */
616617#define XORPAT NATIVE_ENDIAN_VALUE_LE_BE(3,0)
617      const UINT8 *rlut = (const UINT8 *)&namcos22_gamma[0x100/4];
618      const UINT8 *glut = (const UINT8 *)&namcos22_gamma[0x200/4];
619      const UINT8 *blut = (const UINT8 *)&namcos22_gamma[0x300/4];
618      const UINT8 *rlut = (const UINT8 *)&state->m_gamma[0x100/4];
619      const UINT8 *glut = (const UINT8 *)&state->m_gamma[0x200/4];
620      const UINT8 *blut = (const UINT8 *)&state->m_gamma[0x300/4];
620621      for( y=0; y<bitmap->height; y++ )
621622      {
622623         UINT32 *dest = BITMAP_ADDR32(bitmap, y, 0);
r11160r11161
653654static void
654655poly3d_Draw3dSprite( bitmap_t *bitmap, const gfx_element *gfx, int tileNumber, int color, int sx, int sy, int width, int height, int translucency, int zc, UINT32 pri )
655656{
656   int flipx = 0;
657   int flipy = 0;
658   rectangle clip;
659   clip.min_x = 0;
660   clip.min_y = 0;
661   clip.max_x = 640-1;
662   clip.max_y = 480-1;
663   mydrawgfxzoom(
664      bitmap,
665      &clip,
666      gfx,
667      tileNumber,
668      color,
669      flipx, flipy,
670      sx, sy,
671      (width<<16)/32,
672      (height<<16)/32,
673      zc, pri, 0xff - translucency );
657   int flipx = 0;
658   int flipy = 0;
659   rectangle clip;
660   clip.min_x = 0;
661   clip.min_y = 0;
662   clip.max_x = 640-1;
663   clip.max_y = 480-1;
664   mydrawgfxzoom(
665      bitmap,
666      &clip,
667      gfx,
668      tileNumber,
669      color,
670      flipx, flipy,
671      sx, sy,
672      (width<<16)/32,
673      (height<<16)/32,
674      zc, pri, 0xff - translucency );
674675}
675676
676677#define DSP_FIXED_TO_FLOAT( X ) (((INT16)(X))/(float)0x7fff)
r11160r11161
679680#define NUM_CG_CHARS ((CGRAM_SIZE*8)/(64*16)) /* 0x3c0 */
680681
681682/* 16 bit access to DSP RAM */
682static UINT16 namcos22_dspram_bank;
683static UINT16 mUpperWordLatch;
684683
685static int mbDSPisActive;
686684
687685/* modal rendering properties */
688static INT32 mAbsolutePriority;
689static INT32 mObjectShiftValue22;
690686
691static UINT16 mPrimitiveID; /* 3d primitive to render */
692687
693static float mViewMatrix[4][4];
694688
695689static void
696690matrix3d_Multiply( float A[4][4], float B[4][4] )
r11160r11161
750744   *nz = m[0][2]*x + m[1][2]*y + m[2][2]*z;
751745}
752746
753#define MAX_LIT_SURFACES 32
754static UINT8 mLitSurfaceInfo[MAX_LIT_SURFACES];
755static INT32 mSurfaceNormalFormat;
756747
757static unsigned mLitSurfaceCount;
758static unsigned mLitSurfaceIndex;
759748
760static int mPtRomSize;
761static const UINT8 *mpPolyH;
762static const UINT8 *mpPolyM;
763static const UINT8 *mpPolyL;
764
765749static struct
766750{
767751   float zoom, vx, vy, vw, vh;
r11160r11161
772756
773757typedef enum
774758{
775   eSCENENODE_NONLEAF,
776   eSCENENODE_QUAD3D,
777   eSCENENODE_SPRITE
759   eSCENENODE_NONLEAF,
760   eSCENENODE_QUAD3D,
761   eSCENENODE_SPRITE
778762} SceneNodeType;
779763
780764#define RADIX_BITS 4
r11160r11161
783767
784768struct SceneNode
785769{
786   SceneNodeType type;
787   struct SceneNode *nextInBucket;
788   union
789   {
790      struct
791      {
792         struct SceneNode *next[RADIX_BUCKETS];
793      } nonleaf;
770   SceneNodeType type;
771   struct SceneNode *nextInBucket;
772   union
773   {
774      struct
775      {
776         struct SceneNode *next[RADIX_BUCKETS];
777      } nonleaf;
794778
795      struct
796      {
797         float vx,vy,vw,vh;
798         int textureBank;
799         int color;
800         int cmode;
801         int flags;
802         int direct;
803         Poly3dVertex v[4];
804      } quad3d;
779      struct
780      {
781         float vx,vy,vw,vh;
782         int textureBank;
783         int color;
784         int cmode;
785         int flags;
786         int direct;
787         Poly3dVertex v[4];
788      } quad3d;
805789
806      struct
807      {
808         int tile, color, pri;
809         int flipx, flipy;
790      struct
791      {
792         int tile, color, pri;
793         int flipx, flipy;
810794         int linkType;
811         int numcols, numrows;
812         int xpos, ypos;
813         int sizex, sizey;
814         int translucency;
815         int cz;
816      } sprite;
817   } data;
795         int numcols, numrows;
796         int xpos, ypos;
797         int sizex, sizey;
798         int translucency;
799         int cz;
800      } sprite;
801   } data;
818802};
819803static struct SceneNode mSceneRoot;
820804static struct SceneNode *mpFreeSceneNode;
r11160r11161
822806static void
823807FreeSceneNode( struct SceneNode *node )
824808{
825   node->nextInBucket = mpFreeSceneNode;
826   mpFreeSceneNode = node;
809   node->nextInBucket = mpFreeSceneNode;
810   mpFreeSceneNode = node;
827811} /* FreeSceneNode */
828812
829813static struct SceneNode *
830814MallocSceneNode( running_machine &machine )
831815{
832   struct SceneNode *node = mpFreeSceneNode;
833   if( node )
834   { /* use free pool */
835      mpFreeSceneNode = node->nextInBucket;
836   }
837   else
838   {
839     node = auto_alloc(machine, struct SceneNode);
840   }
841   memset( node, 0, sizeof(*node) );
842   return node;
816   struct SceneNode *node = mpFreeSceneNode;
817   if( node )
818   { /* use free pool */
819      mpFreeSceneNode = node->nextInBucket;
820   }
821   else
822   {
823      node = auto_alloc(machine, struct SceneNode);
824   }
825   memset( node, 0, sizeof(*node) );
826   return node;
843827} /* MallocSceneNode */
844828
845829static struct SceneNode *
846830NewSceneNode( running_machine &machine, UINT32 zsortvalue24, SceneNodeType type )
847831{
848   struct SceneNode *node = &mSceneRoot;
849   int i;
850   for( i=0; i<24; i+=RADIX_BITS )
851   {
852      int hash = (zsortvalue24>>20)&RADIX_MASK;
853      struct SceneNode *next = node->data.nonleaf.next[hash];
854      if( !next )
855      { /* lazily allocate tree node for this radix */
856         next = MallocSceneNode(machine);
857         next->type = eSCENENODE_NONLEAF;
858         node->data.nonleaf.next[hash] = next;
859      }
860      node = next;
861      zsortvalue24 <<= RADIX_BITS;
862   }
832   struct SceneNode *node = &mSceneRoot;
833   int i;
834   for( i=0; i<24; i+=RADIX_BITS )
835   {
836      int hash = (zsortvalue24>>20)&RADIX_MASK;
837      struct SceneNode *next = node->data.nonleaf.next[hash];
838      if( !next )
839      { /* lazily allocate tree node for this radix */
840         next = MallocSceneNode(machine);
841         next->type = eSCENENODE_NONLEAF;
842         node->data.nonleaf.next[hash] = next;
843      }
844      node = next;
845      zsortvalue24 <<= RADIX_BITS;
846   }
863847
864   if( node->type == eSCENENODE_NONLEAF )
865   { /* first leaf allocation on this branch */
866      node->type = type;
867      return node;
868   }
869   else
870   {
871      struct SceneNode *leaf = MallocSceneNode(machine);
872      leaf->type = type;
848   if( node->type == eSCENENODE_NONLEAF )
849   { /* first leaf allocation on this branch */
850      node->type = type;
851      return node;
852   }
853   else
854   {
855      struct SceneNode *leaf = MallocSceneNode(machine);
856      leaf->type = type;
873857#if 0
874      leaf->nextInBucket = node->nextInBucket;
875      node->nextInBucket = leaf;
858      leaf->nextInBucket = node->nextInBucket;
859      node->nextInBucket = leaf;
876860#else
877861      /* stable insertion sort */
878862      leaf->nextInBucket = NULL;
r11160r11161
882866      }
883867      node->nextInBucket = leaf;
884868#endif
885      return leaf;
886   }
869      return leaf;
870   }
887871} /* NewSceneNode */
888872
889873
890874static void RenderSprite(running_machine &machine, bitmap_t *bitmap, struct SceneNode *node )
891875{
892876   namcos22_state *state = machine.driver_data<namcos22_state>();
893   int tile = node->data.sprite.tile;
894   int col,row;
877   int tile = node->data.sprite.tile;
878   int col,row;
895879   int i = 0;
896   for( row=0; row<node->data.sprite.numrows; row++ )
897   {
898      for( col=0; col<node->data.sprite.numcols; col++ )
880   for( row=0; row<node->data.sprite.numrows; row++ )
899881   {
900         int code = tile;
901         if( node->data.sprite.linkType == 0xff )
902         {
903            code += i;
904         }
905         else
906         {
907            code += nthword( &state->m_spriteram[0x800/4], i+node->data.sprite.linkType*4 );
908         }
909         poly3d_Draw3dSprite(
910               bitmap,
911               machine.gfx[GFX_SPRITE],
912               code,
913               node->data.sprite.color,
914               node->data.sprite.xpos+col*node->data.sprite.sizex,
915               node->data.sprite.ypos+row*node->data.sprite.sizey,
916               node->data.sprite.sizex,
917               node->data.sprite.sizey,
918               node->data.sprite.translucency,
919               node->data.sprite.cz,
920               node->data.sprite.pri );
921       i++;
922      } /* next col */
923   } /* next row */
882      for( col=0; col<node->data.sprite.numcols; col++ )
883      {
884         int code = tile;
885         if( node->data.sprite.linkType == 0xff )
886         {
887            code += i;
888         }
889         else
890         {
891            code += nthword( &state->m_spriteram[0x800/4], i+node->data.sprite.linkType*4 );
892         }
893         poly3d_Draw3dSprite(
894               bitmap,
895               machine.gfx[GFX_SPRITE],
896               code,
897               node->data.sprite.color,
898               node->data.sprite.xpos+col*node->data.sprite.sizex,
899               node->data.sprite.ypos+row*node->data.sprite.sizey,
900               node->data.sprite.sizex,
901               node->data.sprite.sizey,
902               node->data.sprite.translucency,
903               node->data.sprite.cz,
904               node->data.sprite.pri );
905      i++;
906      } /* next col */
907   } /* next row */
924908} /* RenderSprite */
925909
926910static void RenderSceneHelper(running_machine &machine, bitmap_t *bitmap, struct SceneNode *node )
927911{
928   if( node )
929   {
930      if( node->type == eSCENENODE_NONLEAF )
931      {
932         int i;
933         for( i=RADIX_BUCKETS-1; i>=0; i-- )
934         {
935            RenderSceneHelper(machine, bitmap, node->data.nonleaf.next[i] );
936         }
937         FreeSceneNode( node );
938      }
939      else
940      {
941         while( node )
942         {
943            struct SceneNode *next = node->nextInBucket;
912   if( node )
913   {
914      if( node->type == eSCENENODE_NONLEAF )
915      {
916         int i;
917         for( i=RADIX_BUCKETS-1; i>=0; i-- )
918         {
919            RenderSceneHelper(machine, bitmap, node->data.nonleaf.next[i] );
920         }
921         FreeSceneNode( node );
922      }
923      else
924      {
925         while( node )
926         {
927            struct SceneNode *next = node->nextInBucket;
944928
945            switch( node->type )
946            {
947            case eSCENENODE_QUAD3D:
948               poly3d_Clip(
949                  node->data.quad3d.vx,
950                  node->data.quad3d.vy,
951                  node->data.quad3d.vw,
952                  node->data.quad3d.vh );
953               poly3d_DrawQuad(machine,
954                  bitmap,
955                  node->data.quad3d.textureBank,
956                  node->data.quad3d.color,
957                  node->data.quad3d.v,
958                  node->data.quad3d.flags,
959                  node->data.quad3d.direct,
960                  node->data.quad3d.cmode );
961               break;
929            switch( node->type )
930            {
931            case eSCENENODE_QUAD3D:
932               poly3d_Clip(
933                  node->data.quad3d.vx,
934                  node->data.quad3d.vy,
935                  node->data.quad3d.vw,
936                  node->data.quad3d.vh );
937               poly3d_DrawQuad(machine,
938                  bitmap,
939                  node->data.quad3d.textureBank,
940                  node->data.quad3d.color,
941                  node->data.quad3d.v,
942                  node->data.quad3d.flags,
943                  node->data.quad3d.direct,
944                  node->data.quad3d.cmode );
945               break;
962946
963            case eSCENENODE_SPRITE:
964               poly3d_NoClip();
965               RenderSprite(machine, bitmap,node );
966               break;
947            case eSCENENODE_SPRITE:
948               poly3d_NoClip();
949               RenderSprite(machine, bitmap,node );
950               break;
967951
968            default:
969               fatalerror("invalid node->type");
970               break;
971            }
972            FreeSceneNode( node );
973            node = next;
974         }
975      }
976   }
952            default:
953               fatalerror("invalid node->type");
954               break;
955            }
956            FreeSceneNode( node );
957            node = next;
958         }
959      }
960   }
977961} /* RenderSceneHelper */
978962
979963static void RenderScene(running_machine &machine, bitmap_t *bitmap )
980964{
981   struct SceneNode *node = &mSceneRoot;
982   int i;
983   for( i=RADIX_BUCKETS-1; i>=0; i-- )
984   {
985      RenderSceneHelper(machine, bitmap, node->data.nonleaf.next[i] );
986      node->data.nonleaf.next[i] = NULL;
987   }
988   poly3d_NoClip();
989   poly_wait(poly, "DrawPolygons");
965   namcos22_state *state = machine.driver_data<namcos22_state>();
966   struct SceneNode *node = &mSceneRoot;
967   int i;
968   for( i=RADIX_BUCKETS-1; i>=0; i-- )
969   {
970      RenderSceneHelper(machine, bitmap, node->data.nonleaf.next[i] );
971      node->data.nonleaf.next[i] = NULL;
972   }
973   poly3d_NoClip();
974   poly_wait(state->m_poly, "DrawPolygons");
990975} /* RenderScene */
991976
992977static float
993978DspFloatToNativeFloat( UINT32 iVal )
994979{
995   INT16 mantissa = (INT16)iVal;
996   float result = mantissa;//?((float)mantissa):((float)0x10000);
980   INT16 mantissa = (INT16)iVal;
981   float result = mantissa;//?((float)mantissa):((float)0x10000);
997982   int exponent = (iVal>>16)&0xff;
998983   while( exponent<0x2e )
999984   {
r11160r11161
1004989} /* DspFloatToNativeFloat */
1005990
1006991static INT32
1007GetPolyData( INT32 addr )
992GetPolyData( namcos22_state *state, INT32 addr )
1008993{
1009994   INT32 result;
1010   if( addr<0 || addr>=mPtRomSize )
995   if( addr<0 || addr>=state->m_mPtRomSize )
1011996   {
1012997      return -1; /* HACK */
1013998   }
1014   result = (mpPolyH[addr]<<16)|(mpPolyM[addr]<<8)|mpPolyL[addr];
999   result = (state->m_mpPolyH[addr]<<16)|(state->m_mpPolyM[addr]<<8)|state->m_mpPolyL[addr];
10151000   if( result&0x00800000 )
10161001   {
10171002      result |= 0xff000000; /* sign extend */
r11160r11161
10201005} /* GetPolyData */
10211006
10221007UINT32
1023namcos22_point_rom_r( offs_t offs )
1008namcos22_point_rom_r( running_machine &machine, offs_t offs )
10241009{
1025   return GetPolyData(offs);
1010   namcos22_state *state = machine.driver_data<namcos22_state>();
1011   return GetPolyData(state, offs);
10261012}
10271013
1028UINT32 *namcos22_cgram;
1029UINT32 *namcos22_textram;
1030UINT32 *namcos22_polygonram;
1031UINT32 *namcos22_gamma;
1032UINT32 *namcos22_vics_data;
1033UINT32 *namcos22_vics_control;
10341014
10351015/*
10361016                         0    2    4    6    8    a    b
r11160r11161
10471027         //00810000:  ff80 ff80 ff80 ff80 0000 0000 0000 0000 // hs entry
10481028         //00810000:  ff01 ff01 0000 0000 0000 0000 00e4 0000 // alpine racer
10491029*/
1050UINT32 *namcos22_czattr;
10511030
1052UINT32 *namcos22_tilemapattr;
10531031
1054static UINT8 *dirtypal;
10551032
10561033READ32_HANDLER( namcos22_czram_r )
10571034{
1058   int bank = nthword(namcos22_czattr,0xa/2);
1059   const UINT16 *czram = namcos22_czram[bank&3];
1060   return (czram[offset*2]<<16)|czram[offset*2+1];
1035   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1036   int bank = nthword(state->m_czattr,0xa/2);
1037   const UINT16 *czram = state->m_czram[bank&3];
1038   return (czram[offset*2]<<16)|czram[offset*2+1];
10611039}
10621040
10631041WRITE32_HANDLER( namcos22_czram_w )
10641042{
1065   int bank = nthword(namcos22_czattr,0xa/2);
1066   UINT16 *czram = namcos22_czram[bank&3];
1067   UINT32 dat = (czram[offset*2]<<16)|czram[offset*2+1];
1068   COMBINE_DATA( &dat );
1069   czram[offset*2] = dat>>16;
1070   czram[offset*2+1] = dat&0xffff;
1043   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1044   int bank = nthword(state->m_czattr,0xa/2);
1045   UINT16 *czram = state->m_czram[bank&3];
1046   UINT32 dat = (czram[offset*2]<<16)|czram[offset*2+1];
1047   COMBINE_DATA( &dat );
1048   czram[offset*2] = dat>>16;
1049   czram[offset*2+1] = dat&0xffff;
10711050}
10721051
10731052static void
1074InitXYAttrToPixel( void )
1053InitXYAttrToPixel( namcos22_state *state )
10751054{
10761055   unsigned attr,x,y,ix,iy,temp;
10771056   for( attr=0; attr<16; attr++ )
r11160r11161
10841063            if( attr&4 ) ix = 15-ix;
10851064            if( attr&2 ) iy = 15-iy;
10861065            if( attr&8 ){ temp = ix; ix = iy; iy = temp; }
1087            mXYAttrToPixel[attr][x][y] = (iy<<4)|ix;
1066            state->m_mXYAttrToPixel[attr][x][y] = (iy<<4)|ix;
10881067         }
10891068      }
10901069   }
10911070} /* InitXYAttrToPixel */
10921071
10931072static void
1094PatchTexture( void )
1073PatchTexture( namcos22_state *state )
10951074{
10961075   int i;
1097   switch( namcos22_gametype )
1076   switch( state->m_gametype )
10981077   {
10991078      case NAMCOS22_RIDGE_RACER:
11001079      case NAMCOS22_RIDGE_RACER2:
r11160r11161
11021081      case NAMCOS22_CYBER_COMMANDO:
11031082         for( i=0; i<0x100000; i++ )
11041083         {
1105            int tile = mpTextureTileMap16[i];
1106            int attr = mpTextureTileMapAttr[i];
1084            int tile = state->m_mpTextureTileMap16[i];
1085            int attr = state->m_mpTextureTileMapAttr[i];
11071086            if( (attr&0x1)==0 )
11081087            {
11091088               tile = (tile&0x3fff)|0x8000;
1110               mpTextureTileMap16[i] = tile;
1089               state->m_mpTextureTileMap16[i] = tile;
11111090            }
11121091         }
11131092         break;
r11160r11161
11201099void
11211100namcos22_draw_direct_poly( running_machine &machine, const UINT16 *pSource )
11221101{
1102   namcos22_state *state = machine.driver_data<namcos22_state>();
11231103   /**
11241104    * word#0:
11251105    *    x--------------- end-of-display-list marker
r11160r11161
11311111    * word#2:
11321112    *    xxxxxxxx-------- PAL (high bit is fog enable)
11331113    *    --------xxxx---- CMODE (color mode for texture unpack)
1134    *    ------------xxxx BN (texture bank)
1114    *    ------------xxxx BN (texture bank)
11351115    *
11361116    * word#3:
11371117    *    xxxxxxxx-------- ZC
r11160r11161
11391119    *
11401120    * for each vertex:
11411121    *    xxxx xxxx // u,v
1142    *
1122    *
11431123    *    xxxx xxxx // sx,sy
1144    *
1124    *
11451125    *    xx-- ---- // BRI
1146     *    --xx xxxx // zpos
1147     */
1126    *    --xx xxxx // zpos
1127    */
11481128   INT32 zsortvalue24 = ((pSource[1]&0xfff)<<12)|(pSource[0]&0xfff);
11491129   struct SceneNode *node = NewSceneNode(machine, zsortvalue24,eSCENENODE_QUAD3D);
11501130   int i;
r11160r11161
11591139
11601140      p->u = pSource[0];
11611141      p->v = pSource[1];
1162      if( mbSuperSystem22 )
1142      if( state->m_mbSuperSystem22 )
11631143      {
11641144         p->u >>= 4;
11651145         p->v >>= 4;
r11160r11161
11781158               zf /= 2.0;
11791159               exponent++;
11801160            }
1181            if( mbSuperSystem22 )
1161            if( state->m_mbSuperSystem22 )
11821162               p->z = zf;
11831163            else
11841164               p->z = 1.0f/zf;
r11160r11161
12111191static void
12121192Prepare3dTexture( running_machine &machine, void *pTilemapROM, void *pTextureROM )
12131193{
1214    int i;
1215    assert( pTilemapROM && pTextureROM );
1216    { /* following setup is Namco System 22 specific */
1217         const UINT8 *pPackedTileAttr = 0x200000 + (UINT8 *)pTilemapROM;
1218         UINT8 *pUnpackedTileAttr = auto_alloc_array(machine, UINT8, 0x080000*2);
1219       {
1220          InitXYAttrToPixel();
1221         mpTextureTileMapAttr = pUnpackedTileAttr;
1222         for( i=0; i<0x80000; i++ )
1223         {
1224            *pUnpackedTileAttr++ = (*pPackedTileAttr)>>4;
1225            *pUnpackedTileAttr++ = (*pPackedTileAttr)&0xf;
1226            pPackedTileAttr++;
1227      }
1228      mpTextureTileMap16 = (UINT16 *)pTilemapROM;
1229         mpTextureTileData = (UINT8 *)pTextureROM;
1230      PatchTexture();
1231      }
1232   }
1194   namcos22_state *state = machine.driver_data<namcos22_state>();
1195   int i;
1196   assert( pTilemapROM && pTextureROM );
1197   { /* following setup is Namco System 22 specific */
1198      const UINT8 *pPackedTileAttr = 0x200000 + (UINT8 *)pTilemapROM;
1199      UINT8 *pUnpackedTileAttr = auto_alloc_array(machine, UINT8, 0x080000*2);
1200      {
1201         InitXYAttrToPixel(state);
1202         state->m_mpTextureTileMapAttr = pUnpackedTileAttr;
1203         for( i=0; i<0x80000; i++ )
1204         {
1205            *pUnpackedTileAttr++ = (*pPackedTileAttr)>>4;
1206            *pUnpackedTileAttr++ = (*pPackedTileAttr)&0xf;
1207            pPackedTileAttr++;
1208         }
1209         state->m_mpTextureTileMap16 = (UINT16 *)pTilemapROM;
1210         state->m_mpTextureTileData = (UINT8 *)pTextureROM;
1211         PatchTexture(state);
1212      }
1213   }
12331214} /* Prepare3dTexture */
12341215
12351216static void
r11160r11161
13081289         {
13091290            struct SceneNode *node = NewSceneNode(machine, zcoord,eSCENENODE_SPRITE);
13101291
1311//              printf("[%02d]: tile %x pri %x color %x flipX %d flipY %d cols %d rows %d link %d X %d Y %d sX %d sY %d trans %d cz %d\n",
1312//                  i, tile, cz&0x80, color&0x7f, flipx, flipy, numcols, numrows, linkType, xpos, ypos, sizex, sizey, translucency, cz);
1292            //printf("[%02d]: tile %x pri %x color %x flipX %d flipY %d cols %d rows %d link %d X %d Y %d sX %d sY %d trans %d cz %d\n",
1293            //i, tile, cz&0x80, color&0x7f, flipx, flipy, numcols, numrows, linkType, xpos, ypos, sizex, sizey, translucency, cz);
13131294
13141295            if (color == 0) color = 0x67;   // extreme hack for Tokyo Wars
13151296
13161297            node->data.sprite.tile = tile;
13171298            node->data.sprite.pri = cz&0x80;
1318            //              node->data.sprite.pri = (color&0x80);
1299            //node->data.sprite.pri = (color&0x80);
13191300            node->data.sprite.color = color&0x7f;
13201301            node->data.sprite.flipx = flipx;
13211302            node->data.sprite.flipy = flipy;
r11160r11161
14291410      deltay = 43;
14301411   }
14311412
1432   if( enable==6 /*&& namcos22_gametype!=NAMCOS22_AIR_COMBAT22*/ )
1413   if( enable==6 /*&& state->m_gametype!=NAMCOS22_AIR_COMBAT22*/ )
14331414   {
14341415      DrawSpritesHelper( machine, bitmap, cliprect, pSource, pPal, num_sprites, deltax, deltay );
14351416   }
r11160r11161
14491430    0x940060..0x94007c      set#2
14501431    */
14511432
1452   num_sprites = (namcos22_vics_control[0x40/4]&0xffff)/0x10;
1433   num_sprites = (state->m_vics_control[0x40/4]&0xffff)/0x10;
14531434   if( num_sprites>=1 )
14541435   {
1455      pSource = &namcos22_vics_data[(namcos22_vics_control[0x48/4]&0xffff)/4];
1456      pPal    = &namcos22_vics_data[(namcos22_vics_control[0x58/4]&0xffff)/4];
1436      pSource = &state->m_vics_data[(state->m_vics_control[0x48/4]&0xffff)/4];
1437      pPal    = &state->m_vics_data[(state->m_vics_control[0x58/4]&0xffff)/4];
14571438      DrawSpritesHelper( machine, bitmap, cliprect, pSource, pPal, num_sprites, deltax, deltay );
14581439   }
14591440
1460   num_sprites = (namcos22_vics_control[0x60/4]&0xffff)/0x10;
1441   num_sprites = (state->m_vics_control[0x60/4]&0xffff)/0x10;
14611442   if( num_sprites>=1 )
14621443   {
1463      pSource = &namcos22_vics_data[(namcos22_vics_control[0x68/4]&0xffff)/4];
1464      pPal    = &namcos22_vics_data[(namcos22_vics_control[0x78/4]&0xffff)/4];
1444      pSource = &state->m_vics_data[(state->m_vics_control[0x68/4]&0xffff)/4];
1445      pPal    = &state->m_vics_data[(state->m_vics_control[0x78/4]&0xffff)/4];
14651446      DrawSpritesHelper( machine, bitmap, cliprect, pSource, pPal, num_sprites, deltax, deltay );
14661447   }
14671448} /* DrawSprites */
14681449
14691450static void UpdatePaletteS(running_machine &machine) /* for Super System22 - apply gamma correction and preliminary fader support */
14701451{
1452   namcos22_state *state = machine.driver_data<namcos22_state>();
14711453   int i;
14721454   for( i=0; i<NAMCOS22_PALETTE_SIZE/4; i++ )
14731455   {
1474      if( dirtypal[i] )
1456      if( state->m_dirtypal[i] )
14751457      {
14761458         int j;
14771459         for( j=0; j<4; j++ )
r11160r11161
14821464            int b = nthbyte(machine.generic.paletteram.u32,which+0x10000);
14831465            palette_set_color( machine,which,MAKE_RGB(r,g,b) );
14841466         }
1485         dirtypal[i] = 0;
1467         state->m_dirtypal[i] = 0;
14861468      }
14871469   }
14881470} /* UpdatePaletteS */
14891471
14901472static void UpdatePalette(running_machine &machine) /* for System22 - ignore gamma/fader effects for now */
14911473{
1474   namcos22_state *state = machine.driver_data<namcos22_state>();
14921475   int i,j;
14931476   for( i=0; i<NAMCOS22_PALETTE_SIZE/4; i++ )
14941477   {
1495      if( dirtypal[i] )
1478      if( state->m_dirtypal[i] )
14961479      {
14971480         for( j=0; j<4; j++ )
14981481         {
r11160r11161
15021485            int b = nthbyte(machine.generic.paletteram.u32,which+0x10000);
15031486            palette_set_color( machine,which,MAKE_RGB(r,g,b) );
15041487         }
1505         dirtypal[i] = 0;
1488         state->m_dirtypal[i] = 0;
15061489      }
15071490   }
15081491} /* UpdatePalette */
15091492
1510static tilemap_t *bgtilemap;
15111493
15121494static TILE_GET_INFO( TextTilemapGetInfo )
15131495{
1514   UINT16 data = nthword( namcos22_textram,tile_index );
1515   /**
1516     * x---.----.----.---- blend
1496   namcos22_state *state = machine.driver_data<namcos22_state>();
1497   UINT16 data = nthword( state->m_textram,tile_index );
1498   /**
1499    * x---.----.----.---- blend
15171500    * xxxx.----.----.---- palette select
15181501    * ----.xx--.----.---- flip
15191502    * ----.--xx.xxxx.xxxx code
r11160r11161
15271510
15281511READ32_HANDLER( namcos22_textram_r )
15291512{
1530   return namcos22_textram[offset];
1513   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1514   return state->m_textram[offset];
15311515}
15321516
15331517WRITE32_HANDLER( namcos22_textram_w )
15341518{
1535   COMBINE_DATA( &namcos22_textram[offset] );
1536   tilemap_mark_tile_dirty( bgtilemap, offset*2 );
1537   tilemap_mark_tile_dirty( bgtilemap, offset*2+1 );
1519   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1520   COMBINE_DATA( &state->m_textram[offset] );
1521   tilemap_mark_tile_dirty( state->m_bgtilemap, offset*2 );
1522   tilemap_mark_tile_dirty( state->m_bgtilemap, offset*2+1 );
15381523}
15391524
15401525static void
1541DrawTranslucentCharacters( bitmap_t *bitmap, const rectangle *cliprect )
1526DrawTranslucentCharacters( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
15421527{
1528   namcos22_state *state = machine.driver_data<namcos22_state>();
15431529   UINT8 alpha = 0xff-mixer.text_translucency; /* ? */
1544   tilemap_draw( bitmap, cliprect, bgtilemap, TILEMAP_DRAW_ALPHA(alpha)|1, 0 );
1530   tilemap_draw( bitmap, cliprect, state->m_bgtilemap, TILEMAP_DRAW_ALPHA(alpha)|1, 0 );
15451531}
15461532
15471533static void DrawCharacterLayer(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
15481534{
1549   INT32 dx = namcos22_tilemapattr[0]>>16;
1550   INT32 dy = namcos22_tilemapattr[0]&0xffff;
1551   /**
1552    * namcos22_tilemapattr[0x4/4] == 0x006e0000
1553    * namcos22_tilemapattr[0x8/4] == 0x01ff0000
1554    * namcos22_tilemapattr[0xe/4] == ?
1535   namcos22_state *state = machine.driver_data<namcos22_state>();
1536   INT32 dx = state->m_tilemapattr[0]>>16;
1537   INT32 dy = state->m_tilemapattr[0]&0xffff;
1538   /**
1539    * state->m_tilemapattr[0x4/4] == 0x006e0000
1540    * state->m_tilemapattr[0x8/4] == 0x01ff0000
1541    * state->m_tilemapattr[0xe/4] == ?
15551542    */
15561543   bitmap_fill(machine.priority_bitmap,cliprect,0);
1557   tilemap_set_scrollx( bgtilemap,0, (dx-0x35c)&0x3ff );
1558   tilemap_set_scrolly( bgtilemap,0, dy&0x3ff );
1559   tilemap_set_palette_offset( bgtilemap, mixer.palBase*256 );
1560   tilemap_draw( bitmap, cliprect, bgtilemap, 0/*flags*/, 0x1/*priority*/ ); /* opaque */
1544   tilemap_set_scrollx( state->m_bgtilemap,0, (dx-0x35c)&0x3ff );
1545   tilemap_set_scrolly( state->m_bgtilemap,0, dy&0x3ff );
1546   tilemap_set_palette_offset( state->m_bgtilemap, mixer.palBase*256 );
1547   tilemap_draw( bitmap, cliprect, state->m_bgtilemap, 0/*flags*/, 0x1/*priority*/ ); /* opaque */
15611548} /* DrawCharacterLayer */
15621549
15631550/*********************************************************************************************/
r11160r11161
15651552static int
15661553Cap( int val, int minval, int maxval )
15671554{
1568   if( val<minval )
1569   {
1570      val = minval;
1571   }
1572   else if( val>maxval )
1573   {
1574      val = maxval;
1575   }
1576   return val;
1555   if( val<minval )
1556   {
1557      val = minval;
1558   }
1559   else if( val>maxval )
1560   {
1561      val = maxval;
1562   }
1563   return val;
15771564}
15781565
15791566#define LSB21 (0x1fffff)
r11160r11161
15821569static INT32
15831570Signed18( UINT32 value )
15841571{
1585   INT32 offset = value&LSB18;
1586   if( offset&0x20000 )
1587   { /* sign extend */
1572   INT32 offset = value&LSB18;
1573   if( offset&0x20000 )
1574   { /* sign extend */
15881575      offset |= ~LSB18;
1589   }
1590   return offset;
1576   }
1577   return offset;
15911578}
15921579
15931580/**
r11160r11161
16311618      int flags,
16321619      int packetFormat )
16331620{
1634   int absolutePriority = mAbsolutePriority;
1621   namcos22_state *state = machine.driver_data<namcos22_state>();
1622   int absolutePriority = state->m_mAbsolutePriority;
16351623   UINT32 zsortvalue24;
16361624   float zmin = 0.0f;
16371625   float zmax = 0.0f;
r11160r11161
16421630   for( i=0; i<4; i++ )
16431631   {
16441632      Poly3dVertex *pVerTex = &v[i];
1645      pVerTex->x = GetPolyData(  8+i*3+addr );
1646      pVerTex->y = GetPolyData(  9+i*3+addr );
1647      pVerTex->z = GetPolyData( 10+i*3+addr );
1633      pVerTex->x = GetPolyData( state, 8+i*3+addr );
1634      pVerTex->y = GetPolyData( state, 9+i*3+addr );
1635      pVerTex->z = GetPolyData( state, 10+i*3+addr );
16481636      TransformPoint( &pVerTex->x, &pVerTex->y, &pVerTex->z, m );
16491637   } /* for( i=0; i<4; i++ ) */
16501638
r11160r11161
16681656      Poly3dVertex *pVerTex = &v[i];
16691657      int bri;
16701658
1671      pVerTex->u = GetPolyData(  0+i*2+addr );
1672      pVerTex->v = GetPolyData(  1+i*2+addr );
1659      pVerTex->u = GetPolyData( state, 0+i*2+addr );
1660      pVerTex->v = GetPolyData( state, 1+i*2+addr );
16731661
16741662      if( i==0 || pVerTex->z > zmax ) zmax = pVerTex->z;
16751663      if( i==0 || pVerTex->z < zmin ) zmin = pVerTex->z;
16761664
1677      if( mLitSurfaceCount )
1665      if( state->m_mLitSurfaceCount )
16781666      {
1679         bri = mLitSurfaceInfo[mLitSurfaceIndex%mLitSurfaceCount];
1680         if( mSurfaceNormalFormat == 0x6666 )
1667         bri = state->m_mLitSurfaceInfo[state->m_mLitSurfaceIndex%state->m_mLitSurfaceCount];
1668         if( state->m_mSurfaceNormalFormat == 0x6666 )
16811669         {
16821670            if( i==3 )
1683               mLitSurfaceIndex++;
1671               state->m_mLitSurfaceIndex++;
16841672         }
1685         else if( mSurfaceNormalFormat == 0x4000 )
1686            mLitSurfaceIndex++;
1673         else if( state->m_mSurfaceNormalFormat == 0x4000 )
1674            state->m_mLitSurfaceIndex++;
16871675         else
1688            logerror( "unknown normal format: 0x%x\n", mSurfaceNormalFormat );
1676            logerror( "unknown normal format: 0x%x\n", state->m_mSurfaceNormalFormat );
16891677      } /* pLitSurfaceInfo */
16901678      else if( packetFormat & 0x40 )
1691         bri = (GetPolyData(i+addr)>>16)&0xff;
1679         bri = (GetPolyData(state, i+addr)>>16)&0xff;
16921680      else
16931681         bri = 0x40;
16941682      pVerTex->bri = bri;
r11160r11161
17261714      absolutePriority += (polygonShiftValue22&0x1c0000)>>18;
17271715   }
17281716
1729   if( mObjectShiftValue22 & 0x200000 )
1730      zsortvalue24 = mObjectShiftValue22 & LSB21;
1717   if( state->m_mObjectShiftValue22 & 0x200000 )
1718      zsortvalue24 = state->m_mObjectShiftValue22 & LSB21;
17311719   else
17321720   {
1733      zsortvalue24 += Signed18( mObjectShiftValue22 );
1734      absolutePriority += (mObjectShiftValue22&0x1c0000)>>18;
1721      zsortvalue24 += Signed18( state->m_mObjectShiftValue22 );
1722      absolutePriority += (state->m_mObjectShiftValue22&0x1c0000)>>18;
17351723   }
17361724
17371725   absolutePriority &= 7;
r11160r11161
17691757} /* BlitQuadHelper */
17701758
17711759static void
1772RegisterNormals( INT32 addr, float m[4][4] )
1760RegisterNormals( namcos22_state *state, INT32 addr, float m[4][4] )
17731761{
17741762   int i;
17751763   for( i=0; i<4; i++ )
17761764   {
1777      float nx = DSP_FIXED_TO_FLOAT(GetPolyData(addr+i*3+0));
1778      float ny = DSP_FIXED_TO_FLOAT(GetPolyData(addr+i*3+1));
1779      float nz = DSP_FIXED_TO_FLOAT(GetPolyData(addr+i*3+2));
1765      float nx = DSP_FIXED_TO_FLOAT(GetPolyData(state, addr+i*3+0));
1766      float ny = DSP_FIXED_TO_FLOAT(GetPolyData(state, addr+i*3+1));
1767      float nz = DSP_FIXED_TO_FLOAT(GetPolyData(state, addr+i*3+2));
17801768      float dotproduct;
17811769
17821770      /* transform normal vector */
r11160r11161
17841772      dotproduct = nx*mCamera.lx + ny*mCamera.ly + nz*mCamera.lz;
17851773      if( dotproduct<0.0f )
17861774         dotproduct = 0.0f;
1787      mLitSurfaceInfo[mLitSurfaceCount++] = mCamera.ambient + mCamera.power*dotproduct;
1775      state->m_mLitSurfaceInfo[state->m_mLitSurfaceCount++] = mCamera.ambient + mCamera.power*dotproduct;
17881776   }
17891777} /* RegisterNormals */
17901778
17911779static void
17921780BlitQuads( running_machine &machine, bitmap_t *bitmap, INT32 addr, float m[4][4], INT32 base )
17931781{
1782   namcos22_state *state = machine.driver_data<namcos22_state>();
17941783   int numAdditionalNormals = 0;
1795   int chunkLength = GetPolyData(addr++);
1784   int chunkLength = GetPolyData(state, addr++);
17961785   int finish = addr + chunkLength;
17971786
17981787   if( chunkLength>0x100 )
r11160r11161
18001789
18011790   while( addr<finish )
18021791   {
1803      int packetLength = GetPolyData( addr++ );
1804      int packetFormat = GetPolyData( addr+0 );
1792      int packetLength = GetPolyData( state, addr++ );
1793      int packetFormat = GetPolyData( state, addr+0 );
18051794      int flags, color, bias;
18061795
18071796      /**
r11160r11161
18401829                * word 1: flags
18411830                * word 2: color
18421831                */
1843            flags = GetPolyData(addr+1);
1844            color = GetPolyData(addr+2);
1832            flags = GetPolyData(state, addr+1);
1833            color = GetPolyData(state, addr+2);
18451834            bias = 0;
18461835            BlitQuadHelper( machine,bitmap,color,addr+3,m,bias,flags,packetFormat );
18471836            break;
r11160r11161
18531842                * word 2: color
18541843                * word 3: depth bias
18551844                */
1856            flags = GetPolyData(addr+1);
1857            color = GetPolyData(addr+2);
1858            bias  = GetPolyData(addr+3);
1845            flags = GetPolyData(state, addr+1);
1846            color = GetPolyData(state, addr+2);
1847            bias  = GetPolyData(state, addr+3);
18591848            BlitQuadHelper( machine,bitmap,color,addr+4,m,bias,flags,packetFormat );
18601849            break;
18611850
r11160r11161
18681857                000000  000000  007fff // normal vector
18691858                000000  000000  007fff // normal vector
18701859                */
1871            numAdditionalNormals = GetPolyData(addr+2);
1872            mSurfaceNormalFormat = GetPolyData(addr+3);
1873            mLitSurfaceCount = 0;
1874            mLitSurfaceIndex = 0;
1875            RegisterNormals( addr+4, m );
1860            numAdditionalNormals = GetPolyData(state, addr+2);
1861            state->m_mSurfaceNormalFormat = GetPolyData(state, addr+3);
1862            state->m_mLitSurfaceCount = 0;
1863            state->m_mLitSurfaceIndex = 0;
1864            RegisterNormals( state, addr+4, m );
18761865            break;
18771866
18781867         case 0x0d: /* additional normals */
r11160r11161
18831872                ff8354 ffe401 000790
18841873                ff84f7 ffdd04 0004c2
18851874                */
1886            RegisterNormals( addr+1, m );
1875            RegisterNormals( state, addr+1, m );
18871876            break;
18881877
18891878         default:
r11160r11161
18961885static void
18971886BlitPolyObject( running_machine &machine, bitmap_t *bitmap, int code, float M[4][4] )
18981887{
1899   unsigned addr1 = GetPolyData(code);
1900   mLitSurfaceCount = 0;
1901   mLitSurfaceIndex = 0;
1888   namcos22_state *state = machine.driver_data<namcos22_state>();
1889   unsigned addr1 = GetPolyData(state, code);
1890   state->m_mLitSurfaceCount = 0;
1891   state->m_mLitSurfaceIndex = 0;
19021892   for(;;)
19031893   {
1904      INT32 addr2 = GetPolyData(addr1++);
1894      INT32 addr2 = GetPolyData(state, addr1++);
19051895      if( addr2<0 )
19061896         break;
19071897      BlitQuads( machine, bitmap, addr2, M, code );
r11160r11161
19121902
19131903READ32_HANDLER( namcos22_dspram_r )
19141904{
1915   return namcos22_polygonram[offset];
1905   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1906   return state->m_polygonram[offset];
19161907}
19171908
19181909WRITE32_HANDLER( namcos22_dspram_w )
19191910{
1920   COMBINE_DATA( &namcos22_polygonram[offset] );
1911   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1912   COMBINE_DATA( &state->m_polygonram[offset] );
19211913}
19221914
19231915/*******************************************************************************/
r11160r11161
19621954 * >=0x45: draw primitive
19631955 */
19641956static void
1965HandleBB0003( const INT32 *pSource )
1957HandleBB0003( namcos22_state *state, const INT32 *pSource )
19661958{
19671959   /*
19681960        bb0003 or 3b0003
r11160r11161
19891981   mCamera.ly       = DSP_FIXED_TO_FLOAT(pSource[0x3]);
19901982   mCamera.lz       = DSP_FIXED_TO_FLOAT(pSource[0x4]);
19911983
1992   mAbsolutePriority = pSource[0x3]>>16;
1993   mCamera.vx      = (INT16)(pSource[5]>>16);
1994   mCamera.vy      = (INT16)pSource[5];
1995   mCamera.zoom    = DspFloatToNativeFloat(pSource[6]);
1996   mCamera.vw      = DspFloatToNativeFloat(pSource[7])*mCamera.zoom;
1997   mCamera.vh      = DspFloatToNativeFloat(pSource[9])*mCamera.zoom;
1984   state->m_mAbsolutePriority = pSource[0x3]>>16;
1985   mCamera.vx      = (INT16)(pSource[5]>>16);
1986   mCamera.vy      = (INT16)pSource[5];
1987   mCamera.zoom    = DspFloatToNativeFloat(pSource[6]);
1988   mCamera.vw      = DspFloatToNativeFloat(pSource[7])*mCamera.zoom;
1989   mCamera.vh      = DspFloatToNativeFloat(pSource[9])*mCamera.zoom;
19981990
1999   mViewMatrix[0][0] = DSP_FIXED_TO_FLOAT(pSource[0x0c]);
2000   mViewMatrix[1][0] = DSP_FIXED_TO_FLOAT(pSource[0x0d]);
2001   mViewMatrix[2][0] = DSP_FIXED_TO_FLOAT(pSource[0x0e]);
1991   state->m_mViewMatrix[0][0] = DSP_FIXED_TO_FLOAT(pSource[0x0c]);
1992   state->m_mViewMatrix[1][0] = DSP_FIXED_TO_FLOAT(pSource[0x0d]);
1993   state->m_mViewMatrix[2][0] = DSP_FIXED_TO_FLOAT(pSource[0x0e]);
20021994
2003   mViewMatrix[0][1] = DSP_FIXED_TO_FLOAT(pSource[0x0f]);
2004   mViewMatrix[1][1] = DSP_FIXED_TO_FLOAT(pSource[0x10]);
2005   mViewMatrix[2][1] = DSP_FIXED_TO_FLOAT(pSource[0x11]);
1995   state->m_mViewMatrix[0][1] = DSP_FIXED_TO_FLOAT(pSource[0x0f]);
1996   state->m_mViewMatrix[1][1] = DSP_FIXED_TO_FLOAT(pSource[0x10]);
1997   state->m_mViewMatrix[2][1] = DSP_FIXED_TO_FLOAT(pSource[0x11]);
20061998
2007   mViewMatrix[0][2] = DSP_FIXED_TO_FLOAT(pSource[0x12]);
2008   mViewMatrix[1][2] = DSP_FIXED_TO_FLOAT(pSource[0x13]);
2009   mViewMatrix[2][2] = DSP_FIXED_TO_FLOAT(pSource[0x14]);
1999   state->m_mViewMatrix[0][2] = DSP_FIXED_TO_FLOAT(pSource[0x12]);
2000   state->m_mViewMatrix[1][2] = DSP_FIXED_TO_FLOAT(pSource[0x13]);
2001   state->m_mViewMatrix[2][2] = DSP_FIXED_TO_FLOAT(pSource[0x14]);
20102002
2011   TransformNormal( &mCamera.lx, &mCamera.ly, &mCamera.lz, mViewMatrix );
2003   TransformNormal( &mCamera.lx, &mCamera.ly, &mCamera.lz, state->m_mViewMatrix );
20122004} /* HandleBB0003 */
20132005
20142006static void
20152007Handle200002( running_machine &machine, bitmap_t *bitmap, const INT32 *pSource )
20162008{
2017   if( mPrimitiveID>=0x45 )
2009   namcos22_state *state = machine.driver_data<namcos22_state>();
2010   if( state->m_mPrimitiveID>=0x45 )
20182011   {
20192012      float m[4][4]; /* row major */
20202013
r11160r11161
20362029      m[3][1] = pSource[0xb]; /* ypos */
20372030      m[3][2] = pSource[0xc]; /* zpos */
20382031
2039      matrix3d_Multiply( m, mViewMatrix );
2040      BlitPolyObject( machine, bitmap, mPrimitiveID, m );
2032      matrix3d_Multiply( m, state->m_mViewMatrix );
2033      BlitPolyObject( machine, bitmap, state->m_mPrimitiveID, m );
20412034   }
2042   else if( mPrimitiveID !=0 && mPrimitiveID !=2 )
2043   {
2044      logerror( "Handle200002:unk code=0x%x\n", mPrimitiveID );
2045   }
2035   else if( state->m_mPrimitiveID !=0 && state->m_mPrimitiveID !=2 )
2036   {
2037      logerror( "Handle200002:unk code=0x%x\n", state->m_mPrimitiveID );
2038   }
20462039} /* Handle200002 */
20472040
20482041static void
2049Handle300000( const INT32 *pSource )
2050{ /* set view transform */
2051   mViewMatrix[0][0] = DSP_FIXED_TO_FLOAT(pSource[1]);
2052   mViewMatrix[1][0] = DSP_FIXED_TO_FLOAT(pSource[2]);
2053   mViewMatrix[2][0] = DSP_FIXED_TO_FLOAT(pSource[3]);
2042Handle300000( namcos22_state *state, const INT32 *pSource )
2043{
2044   state->m_mViewMatrix[0][0] = DSP_FIXED_TO_FLOAT(pSource[1]);
2045   state->m_mViewMatrix[1][0] = DSP_FIXED_TO_FLOAT(pSource[2]);
2046   state->m_mViewMatrix[2][0] = DSP_FIXED_TO_FLOAT(pSource[3]);
20542047
2055   mViewMatrix[0][1] = DSP_FIXED_TO_FLOAT(pSource[4]);
2056   mViewMatrix[1][1] = DSP_FIXED_TO_FLOAT(pSource[5]);
2057   mViewMatrix[2][1] = DSP_FIXED_TO_FLOAT(pSource[6]);
2048   state->m_mViewMatrix[0][1] = DSP_FIXED_TO_FLOAT(pSource[4]);
2049   state->m_mViewMatrix[1][1] = DSP_FIXED_TO_FLOAT(pSource[5]);
2050   state->m_mViewMatrix[2][1] = DSP_FIXED_TO_FLOAT(pSource[6]);
20582051
2059   mViewMatrix[0][2] = DSP_FIXED_TO_FLOAT(pSource[7]);
2060   mViewMatrix[1][2] = DSP_FIXED_TO_FLOAT(pSource[8]);
2061   mViewMatrix[2][2] = DSP_FIXED_TO_FLOAT(pSource[9]);
2052   state->m_mViewMatrix[0][2] = DSP_FIXED_TO_FLOAT(pSource[7]);
2053   state->m_mViewMatrix[1][2] = DSP_FIXED_TO_FLOAT(pSource[8]);
2054   state->m_mViewMatrix[2][2] = DSP_FIXED_TO_FLOAT(pSource[9]);
20622055} /* Handle300000 */
20632056
20642057static void
2065Handle233002( const INT32 *pSource )
2066{ /* set modal rendering options */
2058Handle233002( namcos22_state *state, const INT32 *pSource )
2059{
20672060   /*
20682061    00233002
20692062       00000000 // zc adjust?
r11160r11161
20742067       00000000 00000000 00007fff
20752068       00000000 00000000 00000000
20762069   */
2077   mObjectShiftValue22 = pSource[2];
2070   state->m_mObjectShiftValue22 = pSource[2];
20782071} /* Handle233002 */
20792072
20802073static void
20812074SimulateSlaveDSP( running_machine &machine, bitmap_t *bitmap )
20822075{
2083   const INT32 *pSource = 0x300 + (INT32 *)namcos22_polygonram;
2076   namcos22_state *state = machine.driver_data<namcos22_state>();
2077   const INT32 *pSource = 0x300 + (INT32 *)state->m_polygonram;
20842078   INT16 len;
20852079
2086   matrix3d_Identity( mViewMatrix );
2080   matrix3d_Identity( state->m_mViewMatrix );
20872081
2088   if( mbSuperSystem22 )
2082   if( state->m_mbSuperSystem22 )
20892083   {
20902084      pSource += 4; /* FFFE 0400 */
20912085   }
r11160r11161
20972091   for(;;)
20982092   {
20992093      INT16 marker, next;
2100      mPrimitiveID = *pSource++;
2094      state->m_mPrimitiveID = *pSource++;
21012095      len  = (INT16)*pSource++;
21022096
21032097      switch( len )
21042098      {
21052099      case 0x15:
2106         HandleBB0003( pSource ); /* define viewport */
2100         HandleBB0003( state, pSource ); /* define viewport */
21072101         break;
21082102
21092103      case 0x10:
2110         Handle233002( pSource ); /* set modal rendering options */
2104         Handle233002( state, pSource ); /* set modal rendering options */
21112105         break;
21122106
21132107      case 0x0a:
2114         Handle300000( pSource ); /* modify view transform */
2108         Handle300000( state, pSource ); /* modify view transform */
21152109         break;
21162110
21172111      case 0x0d:
r11160r11161
21192113         break;
21202114
21212115      default:
2122         logerror( "unk 3d data(%d) addr=0x%x!", len, (int)(pSource-(INT32*)namcos22_polygonram) );
2123         {
2124            int i;
2125            for( i=0; i<len; i++ )
2126            {
2127               logerror( " %06x", pSource[i]&0xffffff );
2128            }
2129            logerror( "\n" );
2130         }
2116         logerror( "unk 3d data(%d) addr=0x%x!", len, (int)(pSource-(INT32*)state->m_polygonram) );
2117         {
2118            int i;
2119            for( i=0; i<len; i++ )
2120            {
2121               logerror( " %06x", pSource[i]&0xffffff );
2122            }
2123            logerror( "\n" );
2124         }
21312125         return;
21322126      }
21332127
r11160r11161
21352129      pSource += len;
21362130      marker = (INT16)*pSource++; /* always 0xffff */
21372131      next   = (INT16)*pSource++; /* link to next command */
2138      if( (next&0x7fff) != (pSource - (INT32 *)namcos22_polygonram) )
2132      if( (next&0x7fff) != (pSource - (INT32 *)state->m_polygonram) )
21392133      { /* end of list */
21402134         break;
21412135      }
r11160r11161
21452139static void
21462140DrawPolygons( running_machine &machine, bitmap_t *bitmap )
21472141{
2148   if( mbDSPisActive )
2142   namcos22_state *state = machine.driver_data<namcos22_state>();
2143   if( state->m_mbDSPisActive )
21492144   {
21502145      SimulateSlaveDSP( machine, bitmap );
2151      poly_wait(poly, "DrawPolygons");
2146      poly_wait(state->m_poly, "DrawPolygons");
21522147   }
21532148} /* DrawPolygons */
21542149
21552150void
2156namcos22_enable_slave_simulation( void )
2151namcos22_enable_slave_simulation( running_machine &machine )
21572152{
2158   mbDSPisActive = 1;
2153   namcos22_state *state = machine.driver_data<namcos22_state>();
2154   state->m_mbDSPisActive = 1;
21592155}
21602156
21612157/*********************************************************************************************/
21622158
21632159READ32_HANDLER( namcos22_cgram_r )
21642160{
2165   return namcos22_cgram[offset];
2161   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2162   return state->m_cgram[offset];
21662163}
21672164
21682165WRITE32_HANDLER( namcos22_cgram_w )
21692166{
2170   COMBINE_DATA( &namcos22_cgram[offset] );
2167   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2168   COMBINE_DATA( &state->m_cgram[offset] );
21712169   gfx_element_mark_dirty(space->machine().gfx[GFX_CHAR],offset/32);
21722170}
21732171
21742172READ32_HANDLER( namcos22_gamma_r )
21752173{
2176   return namcos22_gamma[offset];
2174   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2175   return state->m_gamma[offset];
21772176}
21782177
21792178WRITE32_HANDLER( namcos22_gamma_w )
21802179{
2181   COMBINE_DATA( &namcos22_gamma[offset] );
2180   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2181   COMBINE_DATA( &state->m_gamma[offset] );
21822182}
21832183
21842184READ32_HANDLER( namcos22_paletteram_r )
r11160r11161
21882188
21892189WRITE32_HANDLER( namcos22_paletteram_w )
21902190{
2191   namcos22_state *state = space->machine().driver_data<namcos22_state>();
21912192   COMBINE_DATA( &space->machine().generic.paletteram.u32[offset] );
2192   dirtypal[offset&(0x7fff/4)] = 1;
2193   state->m_dirtypal[offset&(0x7fff/4)] = 1;
21932194}
21942195
21952196static void namcos22_reset(running_machine &machine)
r11160r11161
22002201
22012202static void namcos22_exit(running_machine &machine)
22022203{
2203   poly_free(poly);
2204   namcos22_state *state = machine.driver_data<namcos22_state>();
2205   poly_free(state->m_poly);
22042206}
22052207
22062208static VIDEO_START( common )
22072209{
2210   namcos22_state *state = machine.driver_data<namcos22_state>();
22082211   int code;
22092212
2210   bgtilemap = tilemap_create( machine, TextTilemapGetInfo,tilemap_scan_rows,16,16,64,64 );
2211      tilemap_set_transparent_pen( bgtilemap, 0xf );
2213   state->m_bgtilemap = tilemap_create( machine, TextTilemapGetInfo,tilemap_scan_rows,16,16,64,64 );
2214      tilemap_set_transparent_pen( state->m_bgtilemap, 0xf );
22122215
2213   mbDSPisActive = 0;
2214   memset( namcos22_polygonram, 0xcc, 0x20000 );
2216   state->m_mbDSPisActive = 0;
2217   memset( state->m_polygonram, 0xcc, 0x20000 );
22152218
22162219   for (code = 0; code < machine.gfx[GFX_TEXTURE_TILE]->total_elements; code++)
22172220      gfx_element_decode(machine.gfx[GFX_TEXTURE_TILE], code);
22182221   Prepare3dTexture(machine, machine.region("textilemap")->base(), machine.gfx[GFX_TEXTURE_TILE]->gfxdata );
2219   dirtypal = auto_alloc_array(machine, UINT8, NAMCOS22_PALETTE_SIZE/4);
2220   mPtRomSize = machine.region("pointrom")->bytes()/3;
2221   mpPolyL = machine.region("pointrom")->base();
2222   mpPolyM = mpPolyL + mPtRomSize;
2223   mpPolyH = mpPolyM + mPtRomSize;
2222   state->m_dirtypal = auto_alloc_array(machine, UINT8, NAMCOS22_PALETTE_SIZE/4);
2223   state->m_mPtRomSize = machine.region("pointrom")->bytes()/3;
2224   state->m_mpPolyL = machine.region("pointrom")->base();
2225   state->m_mpPolyM = state->m_mpPolyL + state->m_mPtRomSize;
2226   state->m_mpPolyH = state->m_mpPolyM + state->m_mPtRomSize;
22242227
22252228#ifdef RENDER_AS_QUADS
2226   poly = poly_alloc(machine, 4000, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS);
2229   state->m_poly = poly_alloc(machine, 4000, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS);
22272230#else
2228   poly = poly_alloc(machine, 4000, sizeof(poly_extra_data), 0);
2231   state->m_poly = poly_alloc(machine, 4000, sizeof(poly_extra_data), 0);
22292232#endif
22302233   machine.add_notifier(MACHINE_NOTIFY_RESET, namcos22_reset);
22312234   machine.add_notifier(MACHINE_NOTIFY_EXIT, namcos22_exit);
22322235
2233   gfx_element_set_source(machine.gfx[GFX_CHAR], (UINT8 *)namcos22_cgram);
2236   gfx_element_set_source(machine.gfx[GFX_CHAR], (UINT8 *)state->m_cgram);
22342237}
22352238
22362239VIDEO_START( namcos22 )
22372240{
2238   mbSuperSystem22 = 0;
2239   VIDEO_START_CALL(common);
2241   namcos22_state *state = machine.driver_data<namcos22_state>();
2242   state->m_mbSuperSystem22 = 0;
2243   VIDEO_START_CALL(common);
22402244}
22412245
22422246VIDEO_START( namcos22s )
22432247{
2244   mbSuperSystem22 = 1;
2245   namcos22_czram[0] = auto_alloc_array(machine, UINT16, 0x200/2 );
2246   namcos22_czram[1] = auto_alloc_array(machine, UINT16, 0x200/2 );
2247   namcos22_czram[2] = auto_alloc_array(machine, UINT16, 0x200/2 );
2248   namcos22_czram[3] = auto_alloc_array(machine, UINT16, 0x200/2 );
2248   namcos22_state *state = machine.driver_data<namcos22_state>();
2249   state->m_mbSuperSystem22 = 1;
2250   state->m_czram[0] = auto_alloc_array(machine, UINT16, 0x200/2 );
2251   state->m_czram[1] = auto_alloc_array(machine, UINT16, 0x200/2 );
2252   state->m_czram[2] = auto_alloc_array(machine, UINT16, 0x200/2 );
2253   state->m_czram[3] = auto_alloc_array(machine, UINT16, 0x200/2 );
22492254
2250   memset(namcos22_czram[0], 0, 0x200);
2251   memset(namcos22_czram[1], 0, 0x200);
2252   memset(namcos22_czram[2], 0, 0x200);
2253   memset(namcos22_czram[3], 0, 0x200);
2255   memset(state->m_czram[0], 0, 0x200);
2256   memset(state->m_czram[1], 0, 0x200);
2257   memset(state->m_czram[2], 0, 0x200);
2258   memset(state->m_czram[3], 0, 0x200);
22542259
2255   VIDEO_START_CALL(common);
2260   VIDEO_START_CALL(common);
22562261}
22572262
22582263SCREEN_UPDATE( namcos22s )
22592264{
22602265   UINT32 bgColor;
2261   UpdateVideoMixer();
2266   UpdateVideoMixer(screen->machine());
22622267   bgColor = (mixer.rBackColor<<16)|(mixer.gBackColor<<8)|mixer.bBackColor;
22632268   bitmap_fill( bitmap, cliprect , bgColor);
22642269   UpdatePaletteS(screen->machine());
r11160r11161
22662271   DrawPolygons( screen->machine(), bitmap );
22672272   DrawSprites( screen->machine(), bitmap, cliprect );
22682273   RenderScene(screen->machine(), bitmap );
2269   DrawTranslucentCharacters( bitmap, cliprect );
2274   DrawTranslucentCharacters( screen->machine(), bitmap, cliprect );
22702275   ApplyGamma( screen->machine(), bitmap );
22712276
22722277#ifdef MAME_DEBUG
2273   if( input_code_pressed(screen->machine(), KEYCODE_D) )
2274   {
2275      FILE *f = fopen( "dump.txt", "wb" );
2276      if( f )
2277      {
2278         address_space *space = screen->machine().device("maincpu")->memory().space(AS_PROGRAM);
2278   if( input_code_pressed(screen->machine(), KEYCODE_D) )
2279   {
2280      namcos22_state *state = screen->machine().driver_data<namcos22_state>();
2281      FILE *f = fopen( "dump.txt", "wb" );
2282      if( f )
2283      {
2284         address_space *space = screen->machine().device("maincpu")->memory().space(AS_PROGRAM);
22792285
2280         {
2281            int i,bank;
2282            for( bank=0; bank<4; bank++ )
2283            {
2284               fprintf( f, "czram[%d] =", bank );
2285               for( i=0; i<256; i++ )
2286               {
2287                  fprintf( f, " %04x", namcos22_czram[bank][i] );
2288               }
2289               fprintf( f, "\n" );
2290            }
2291         }
2286         {
2287            int i,bank;
2288            for( bank=0; bank<4; bank++ )
2289            {
2290               fprintf( f, "czram[%d] =", bank );
2291               for( i=0; i<256; i++ )
2292               {
2293                  fprintf( f, " %04x", state->m_czram[bank][i] );
2294               }
2295               fprintf( f, "\n" );
2296            }
2297         }
22922298
2293         Dump(space, f,0x810000, 0x81000f, "cz attr" );
2294         Dump(space, f,0x820000, 0x8202ff, "unk_ac" );
2295         Dump(space, f,0x824000, 0x8243ff, "gamma");
2296         Dump(space, f,0x828000, 0x83ffff, "palette" );
2297         Dump(space, f,0x8a0000, 0x8a000f, "tilemap_attr");
2298         Dump(space, f,0x880000, 0x89ffff, "cgram/textram");
2299         Dump(space, f,0x900000, 0x90ffff, "vics_data");
2300         Dump(space, f,0x940000, 0x94007f, "vics_control");
2301         Dump(space, f,0x980000, 0x9affff, "sprite374" );
2302         Dump(space, f,0xc00000, 0xc1ffff, "polygonram");
2303         fclose( f );
2304      }
2305      while( input_code_pressed(screen->machine(), KEYCODE_D) ){}
2306   }
2299         Dump(space, f,0x810000, 0x81000f, "cz attr" );
2300         Dump(space, f,0x820000, 0x8202ff, "unk_ac" );
2301         Dump(space, f,0x824000, 0x8243ff, "gamma");
2302         Dump(space, f,0x828000, 0x83ffff, "palette" );
2303         Dump(space, f,0x8a0000, 0x8a000f, "tilemap_attr");
2304         Dump(space, f,0x880000, 0x89ffff, "cgram/textram");
2305         Dump(space, f,0x900000, 0x90ffff, "vics_data");
2306         Dump(space, f,0x940000, 0x94007f, "vics_control");
2307         Dump(space, f,0x980000, 0x9affff, "sprite374" );
2308         Dump(space, f,0xc00000, 0xc1ffff, "polygonram");
2309         fclose( f );
2310      }
2311      while( input_code_pressed(screen->machine(), KEYCODE_D) ){}
2312   }
23072313#endif
23082314   return 0;
23092315}
23102316
23112317SCREEN_UPDATE( namcos22 )
23122318{
2313   UpdateVideoMixer();
2319   UpdateVideoMixer(screen->machine());
23142320   bitmap_fill( bitmap, cliprect , get_black_pen(screen->machine()));
23152321   UpdatePalette(screen->machine());
23162322   DrawCharacterLayer(screen->machine(), bitmap, cliprect );
23172323   DrawPolygons( screen->machine(), bitmap );
23182324   RenderScene(screen->machine(), bitmap);
2319   DrawTranslucentCharacters( bitmap, cliprect );
2325   DrawTranslucentCharacters( screen->machine(), bitmap, cliprect );
23202326   ApplyGamma( screen->machine(), bitmap );
23212327
23222328#ifdef MAME_DEBUG
2323   if( input_code_pressed(screen->machine(), KEYCODE_D) )
2324   {
2325      FILE *f = fopen( "dump.txt", "wb" );
2326      if( f )
2327      {
2328         address_space *space = screen->machine().device("maincpu")->memory().space(AS_PROGRAM);
2329   if( input_code_pressed(screen->machine(), KEYCODE_D) )
2330   {
2331      FILE *f = fopen( "dump.txt", "wb" );
2332      if( f )
2333      {
2334         address_space *space = screen->machine().device("maincpu")->memory().space(AS_PROGRAM);
23292335
2330//         Dump(space, f,0x90000000, 0x90000003, "led?" );
2331//         Dump(space, f,0x90010000, 0x90017fff, "cz_ram");
2332//         Dump(space, f,0x900a0000, 0x900a000f, "tilemap_attr");
2333         Dump(space, f,0x90020000, 0x90027fff, "gamma");
2334//         Dump(space, f,0x70000000, 0x7001ffff, "polygonram");
2335         fclose( f );
2336      }
2337      while( input_code_pressed(screen->machine(), KEYCODE_D) ){}
2338   }
2336         //Dump(space, f,0x90000000, 0x90000003, "led?" );
2337         //Dump(space, f,0x90010000, 0x90017fff, "cz_ram");
2338         //Dump(space, f,0x900a0000, 0x900a000f, "tilemap_attr");
2339         Dump(space, f,0x90020000, 0x90027fff, "gamma");
2340         //Dump(space, f,0x70000000, 0x7001ffff, "polygonram");
2341         fclose( f );
2342      }
2343      while( input_code_pressed(screen->machine(), KEYCODE_D) ){}
2344   }
23392345#endif
23402346   return 0;
23412347}
23422348
23432349WRITE16_HANDLER( namcos22_dspram16_bank_w )
23442350{
2345   COMBINE_DATA( &namcos22_dspram_bank );
2351   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2352   COMBINE_DATA( &state->m_dspram_bank );
23462353}
23472354
23482355READ16_HANDLER( namcos22_dspram16_r )
23492356{
2350   UINT32 value = namcos22_polygonram[offset];
2351   switch( namcos22_dspram_bank )
2357   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2358   UINT32 value = state->m_polygonram[offset];
2359   switch( state->m_dspram_bank )
23522360   {
23532361   case 0:
23542362      value &= 0xffff;
r11160r11161
23592367      break;
23602368
23612369   case 2:
2362      mUpperWordLatch = value>>16;
2370      state->m_mUpperWordLatch = value>>16;
23632371      value &= 0xffff;
23642372      break;
23652373
r11160r11161
23712379
23722380WRITE16_HANDLER( namcos22_dspram16_w )
23732381{
2374   UINT32 value = namcos22_polygonram[offset];
2382   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2383   UINT32 value = state->m_polygonram[offset];
23752384   UINT16 lo = value&0xffff;
23762385   UINT16 hi = value>>16;
2377   switch( namcos22_dspram_bank )
2386   switch( state->m_dspram_bank )
23782387   {
23792388   case 0:
23802389      COMBINE_DATA( &lo );
r11160r11161
23862395
23872396   case 2:
23882397      COMBINE_DATA( &lo );
2389      hi = mUpperWordLatch;
2398      hi = state->m_mUpperWordLatch;
23902399      break;
23912400
23922401   default:
23932402      break;
23942403   }
2395   namcos22_polygonram[offset] = (hi<<16)|lo;
2404   state->m_polygonram[offset] = (hi<<16)|lo;
23962405} /* namcos22_dspram16_w */
23972406
23982407#ifdef MAME_DEBUG
23992408static void
24002409Dump( address_space *space, FILE *f, unsigned addr1, unsigned addr2, const char *name )
24012410{
2402   unsigned addr;
2403   fprintf( f, "%s:\n", name );
2404   for( addr=addr1; addr<=addr2; addr+=16 )
2405   {
2406      UINT8 data[16];
2407      int bHasNonZero = 0;
2408      int i;
2409      for( i=0; i<16; i++ )
2410      {
2411         data[i] = space->read_byte(addr+i );
2412         if( data[i] )
2413         {
2414            bHasNonZero = 1;
2415         }
2416      }
2417      if( bHasNonZero )
2418      {
2419         fprintf( f,"%08x:", addr );
2420         for( i=0; i<16; i++ )
2421         {
2422            if( (i&0x03)==0 )
2423            {
2424               fprintf( f, " " );
2425            }
2426            fprintf( f, "%02x", data[i] );
2427         }
2428         fprintf( f, "\n" );
2429      }
2430   }
2431   fprintf( f, "\n" );
2411   unsigned addr;
2412   fprintf( f, "%s:\n", name );
2413   for( addr=addr1; addr<=addr2; addr+=16 )
2414   {
2415      UINT8 data[16];
2416      int bHasNonZero = 0;
2417      int i;
2418      for( i=0; i<16; i++ )
2419      {
2420         data[i] = space->read_byte(addr+i );
2421         if( data[i] )
2422         {
2423            bHasNonZero = 1;
2424         }
2425      }
2426      if( bHasNonZero )
2427      {
2428         fprintf( f,"%08x:", addr );
2429         for( i=0; i<16; i++ )
2430         {
2431            if( (i&0x03)==0 )
2432            {
2433               fprintf( f, " " );
2434            }
2435            fprintf( f, "%02x", data[i] );
2436         }
2437         fprintf( f, "\n" );
2438      }
2439   }
2440   fprintf( f, "\n" );
24322441}
24332442#endif
24342443
r11160r11161
24672476 */
24682477WRITE32_HANDLER(namcos22_port800000_w)
24692478{
2470   /* 00000011011111110000100011111111001001111110111110110001 */
2471   UINT16 word = data>>16;
2472   logerror( "%x: C304/C399: 0x%04x\n", cpu_get_previouspc(&space->device()), word );
2473   if( word == 0x4038 )
2474   {
2475      mbSpotlightEnable = 1;
2476   }
2477   else
2478   {
2479      mbSpotlightEnable = 0;
2480   }
2479   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2480   /* 00000011011111110000100011111111001001111110111110110001 */
2481   UINT16 word = data>>16;
2482   logerror( "%x: C304/C399: 0x%04x\n", cpu_get_previouspc(&space->device()), word );
2483   if( word == 0x4038 )
2484   {
2485      state->m_mbSpotlightEnable = 1;
2486   }
2487   else
2488   {
2489      state->m_mbSpotlightEnable = 0;
2490   }
24812491} /* namcos22_port800000_w */
src/mame/video/xybots.c
r11160r11161
66
77#include "emu.h"
88#include "machine/atarigen.h"
9#include "video/atarimo.h"
910#include "includes/xybots.h"
1011
1112
src/mame/video/galaxold.c
r11160r11161
77#include "emu.h"
88#include "includes/galaxold.h"
99
10static const rectangle _spritevisiblearea =
10static const rectangle spritevisiblearea =
1111{
1212   2*8+1, 32*8-1,
1313   2*8,   30*8-1
1414};
15static const rectangle _spritevisibleareaflipx =
15static const rectangle spritevisibleareaflipx =
1616{
1717   0*8, 30*8-2,
1818   2*8, 30*8-1
1919};
2020
21static const rectangle* spritevisiblearea;
22static const rectangle* spritevisibleareaflipx;
2321
24
2522#define STARS_COLOR_BASE      (machine.region("proms")->bytes())
2623#define BULLETS_COLOR_BASE      (STARS_COLOR_BASE + 64)
2724#define BACKGROUND_COLOR_BASE   (BULLETS_COLOR_BASE + 2)
2825
2926
30UINT8 *galaxold_videoram;
31UINT8 *galaxold_spriteram;
32UINT8 *galaxold_spriteram2;
33UINT8 *galaxold_attributesram;
34UINT8 *galaxold_bulletsram;
35UINT8 *rockclim_videoram;
36size_t galaxold_spriteram_size;
37size_t galaxold_spriteram2_size;
38size_t galaxold_bulletsram_size;
39
40
4127static TILE_GET_INFO( get_tile_info );
4228static TILE_GET_INFO( rockclim_get_tile_info );
43static tilemap_t *bg_tilemap;
44static tilemap_t *rockclim_tilemap;
45static int mooncrst_gfxextend;
46static int spriteram2_present;
47static UINT8 gfxbank[5];
48static UINT8 flipscreen_x;
49static UINT8 flipscreen_y;
50static UINT8 color_mask;
51static tilemap_t *dambustr_tilemap2;
52static UINT8 *dambustr_videoram2;
53static void (*modify_charcode)(running_machine &machine, UINT16 *code,UINT8 x);      /* function to call to do character banking */
54static void mooncrst_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x);
55static void   pisces_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x);
56static void mimonkey_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x);
57static void  mariner_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x);
58static void dambustr_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x);
29static void mooncrst_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x);
30static void   pisces_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x);
31static void mimonkey_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x);
32static void  mariner_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x);
33static void dambustr_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x);
5934
60static void (*modify_spritecode)(UINT8 *spriteram,int*,int*,int*,int);   /* function to call to do sprite banking */
61static void mshuttle_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs);
62static void mimonkey_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs);
63static void  batman2_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs);
64static void dkongjrm_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs);
65static void   ad2083_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs);
66static void dambustr_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs);
35static void mshuttle_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs);
36static void mimonkey_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs);
37static void  batman2_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs);
38static void dkongjrm_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs);
39static void   ad2083_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs);
40static void dambustr_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs);
6741
68static void (*modify_color)(UINT8 *color);   /* function to call to do modify how the color codes map to the PROM */
6942static void drivfrcg_modify_color(UINT8 *color);
7043
71static void (*modify_ypos)(UINT8*);   /* function to call to do modify how vertical positioning bits are connected */
72
7344static TIMER_CALLBACK( stars_blink_callback );
7445static TIMER_CALLBACK( stars_scroll_callback );
7546
76static void (*tilemap_set_scroll)( tilemap_t *, int col, int value );
77
78/* star circuit */
79#define STAR_COUNT  252
80struct star
81{
82   int x,y,color;
83};
84static struct star stars[STAR_COUNT];
85static int stars_colors_start;
86       UINT8 galaxold_stars_on;
87static INT32 stars_scrollpos;
88static UINT8 stars_blink_state;
89static emu_timer *stars_blink_timer;
90static emu_timer *stars_scroll_timer;
91static UINT8 timer_adjusted;
9247       void galaxold_init_stars(running_machine &machine, int colors_offset);
93static void (*draw_stars)(running_machine &machine, bitmap_t *, const rectangle *);      /* function to call to draw the star layer */
9448static void     noop_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
9549       void galaxold_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
9650static void scrambold_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
9751static void   rescue_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
9852static void  mariner_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
99static void start_stars_blink_timer(double ra, double rb, double c);
53static void start_stars_blink_timer(running_machine &machine, double ra, double rb, double c);
10054static void start_stars_scroll_timer(running_machine &machine);
10155
10256/* bullets circuit */
103static UINT8 darkplnt_bullet_color;
104static void (*draw_bullets)(running_machine &,bitmap_t *,const rectangle *,int,int,int);   /* function to call to draw a bullet */
10557static void galaxold_draw_bullets(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y);
10658static void scrambold_draw_bullets(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y);
10759static void darkplnt_draw_bullets(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y);
10860static void dambustr_draw_bullets(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y);
10961
11062/* background circuit */
111static UINT8 background_enable;
112static UINT8 background_red, background_green, background_blue;
113static void (*draw_background)(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);   /* function to call to draw the background */
11463static void galaxold_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
11564static void scrambold_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
11665static void  ad2083_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
r11160r11161
12069static void   rescue_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
12170static void dambustr_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect);
12271
123static UINT16 rockclim_v;
124static UINT16 rockclim_h;
125static int dambustr_bg_split_line;
126static int dambustr_bg_color_1;
127static int dambustr_bg_color_2;
128static int dambustr_bg_priority;
129static int dambustr_char_bank;
130static bitmap_t *dambustr_tmpbitmap;
13172
13273
13374
r11160r11161
496437
497438static void state_save_register(running_machine &machine)
498439{
499   state_save_register_global_array(machine, gfxbank);
500   state_save_register_global(machine, flipscreen_x);
501   state_save_register_global(machine, flipscreen_y);
440   galaxold_state *state = machine.driver_data<galaxold_state>();
441   state_save_register_global_array(machine, state->m_gfxbank);
442   state_save_register_global(machine, state->m_flipscreen_x);
443   state_save_register_global(machine, state->m_flipscreen_y);
502444
503   state_save_register_global(machine, galaxold_stars_on);
504   state_save_register_global(machine, stars_scrollpos);
505   state_save_register_global(machine, stars_blink_state);
445   state_save_register_global(machine, state->m_stars_on);
446   state_save_register_global(machine, state->m_stars_scrollpos);
447   state_save_register_global(machine, state->m_stars_blink_state);
506448
507   state_save_register_global(machine, darkplnt_bullet_color);
449   state_save_register_global(machine, state->m_darkplnt_bullet_color);
508450
509   state_save_register_global(machine, background_enable);
510   state_save_register_global(machine, background_red);
511   state_save_register_global(machine, background_green);
512   state_save_register_global(machine, background_blue);
451   state_save_register_global(machine, state->m_background_enable);
452   state_save_register_global(machine, state->m_background_red);
453   state_save_register_global(machine, state->m_background_green);
454   state_save_register_global(machine, state->m_background_blue);
513455}
514456
515static void video_start_common(running_machine &machine, tilemap_mapper_func get_memory_offset)
457static void video_start_common(running_machine &machine)
516458{
517   bg_tilemap = tilemap_create(machine, get_tile_info,get_memory_offset,8,8,32,32);
459   galaxold_state *state = machine.driver_data<galaxold_state>();
460   state->m_modify_charcode = 0;
461   state->m_modify_spritecode = 0;
462   state->m_modify_color = 0;
463   state->m_modify_ypos = 0;
518464
519   tilemap_set_transparent_pen(bg_tilemap,0);
465   state->m_mooncrst_gfxextend = 0;
520466
467   state->m_draw_bullets = 0;
521468
522   modify_charcode = 0;
523   modify_spritecode = 0;
524   modify_color = 0;
525   modify_ypos = 0;
469   state->m_draw_background = galaxold_draw_background;
470   state->m_background_enable = 0;
471   state->m_background_blue = 0;
472   state->m_background_red = 0;
473   state->m_background_green = 0;
526474
527   mooncrst_gfxextend = 0;
475   state->m_draw_stars = noop_draw_stars;
528476
529   draw_bullets = 0;
477   state->m_flipscreen_x = 0;
478   state->m_flipscreen_y = 0;
530479
531   draw_background = galaxold_draw_background;
532   background_enable = 0;
533   background_blue = 0;
534   background_red = 0;
535   background_green = 0;
480   state->m_spriteram2_present = 0;
536481
537   draw_stars = noop_draw_stars;
538
539   flipscreen_x = 0;
540   flipscreen_y = 0;
541
542   spriteram2_present = 0;
543
544   spritevisiblearea      = &_spritevisiblearea;
545   spritevisibleareaflipx = &_spritevisibleareaflipx;
546
547   color_mask = (machine.gfx[0]->color_granularity == 4) ? 7 : 3;
548
549482   state_save_register(machine);
550483}
551484
552485VIDEO_START( galaxold_plain )
553486{
554   video_start_common(machine,tilemap_scan_rows);
487   galaxold_state *state = machine.driver_data<galaxold_state>();
488   video_start_common(machine);
489   state->m_bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
490   tilemap_set_transparent_pen(state->m_bg_tilemap,0);
555491
556   tilemap_set_scroll_cols(bg_tilemap, 32);
557   tilemap_set_scroll = tilemap_set_scrolly;
492   tilemap_set_scroll_cols(state->m_bg_tilemap, 32);
493   state->m_tilemap_set_scroll = tilemap_set_scrolly;
494
495   state->m_color_mask = (machine.gfx[0]->color_granularity == 4) ? 7 : 3;
558496}
559497
560498VIDEO_START( galaxold )
561499{
500   galaxold_state *state = machine.driver_data<galaxold_state>();
562501   VIDEO_START_CALL(galaxold_plain);
563502
564   draw_stars = galaxold_draw_stars;
503   state->m_draw_stars = galaxold_draw_stars;
565504
566   draw_bullets = galaxold_draw_bullets;
505   state->m_draw_bullets = galaxold_draw_bullets;
567506}
568507
569508VIDEO_START( scrambold )
570509{
510   galaxold_state *state = machine.driver_data<galaxold_state>();
571511   VIDEO_START_CALL(galaxold_plain);
572512
573513   /* FIXME: This most probably needs to be adjusted
574514     * again when RAW video params are added to scramble
575515     */
576   tilemap_set_scrolldx(bg_tilemap, 0, 0);
516   tilemap_set_scrolldx(state->m_bg_tilemap, 0, 0);
577517
578   draw_stars = scrambold_draw_stars;
518   state->m_draw_stars = scrambold_draw_stars;
579519
580   draw_bullets = scrambold_draw_bullets;
520   state->m_draw_bullets = scrambold_draw_bullets;
581521
582   draw_background = scrambold_draw_background;
522   state->m_draw_background = scrambold_draw_background;
583523}
584524
585525VIDEO_START( darkplnt )
586526{
527   galaxold_state *state = machine.driver_data<galaxold_state>();
587528   VIDEO_START_CALL(galaxold_plain);
588529
589   tilemap_set_scrolldx(bg_tilemap, 0, 0);
590   draw_bullets = darkplnt_draw_bullets;
530   tilemap_set_scrolldx(state->m_bg_tilemap, 0, 0);
531   state->m_draw_bullets = darkplnt_draw_bullets;
591532}
592533
593534VIDEO_START( rescue )
594535{
536   galaxold_state *state = machine.driver_data<galaxold_state>();
595537   VIDEO_START_CALL(scrambold);
596538
597   draw_stars = rescue_draw_stars;
539   state->m_draw_stars = rescue_draw_stars;
598540
599   draw_background = rescue_draw_background;
541   state->m_draw_background = rescue_draw_background;
600542}
601543
602544VIDEO_START( minefld )
603545{
546   galaxold_state *state = machine.driver_data<galaxold_state>();
604547   VIDEO_START_CALL(scrambold);
605548
606   draw_stars = rescue_draw_stars;
549   state->m_draw_stars = rescue_draw_stars;
607550
608   draw_background = minefld_draw_background;
551   state->m_draw_background = minefld_draw_background;
609552}
610553
611554VIDEO_START( stratgyx )
612555{
556   galaxold_state *state = machine.driver_data<galaxold_state>();
613557   VIDEO_START_CALL(galaxold_plain);
614558
615   draw_background = stratgyx_draw_background;
559   state->m_draw_background = stratgyx_draw_background;
616560}
617561
618562VIDEO_START( ckongs )
619563{
564   galaxold_state *state = machine.driver_data<galaxold_state>();
620565   VIDEO_START_CALL(scrambold);
621566
622   modify_spritecode = mshuttle_modify_spritecode;
567   state->m_modify_spritecode = mshuttle_modify_spritecode;
623568}
624569
625570VIDEO_START( mariner )
626571{
572   galaxold_state *state = machine.driver_data<galaxold_state>();
627573   VIDEO_START_CALL(galaxold_plain);
628574
629   draw_stars = mariner_draw_stars;
575   state->m_draw_stars = mariner_draw_stars;
630576
631   draw_bullets = scrambold_draw_bullets;
577   state->m_draw_bullets = scrambold_draw_bullets;
632578
633   draw_background = mariner_draw_background;
579   state->m_draw_background = mariner_draw_background;
634580
635   modify_charcode = mariner_modify_charcode;
581   state->m_modify_charcode = mariner_modify_charcode;
636582}
637583
638584VIDEO_START( mimonkey )
639585{
586   galaxold_state *state = machine.driver_data<galaxold_state>();
640587   VIDEO_START_CALL(scrambold);
641588
642   modify_charcode   = mimonkey_modify_charcode;
643   modify_spritecode = mimonkey_modify_spritecode;
589   state->m_modify_charcode   = mimonkey_modify_charcode;
590   state->m_modify_spritecode = mimonkey_modify_spritecode;
644591}
645592
646593VIDEO_START( dkongjrm )
647594{
595   galaxold_state *state = machine.driver_data<galaxold_state>();
648596   VIDEO_START_CALL(galaxold_plain);
649597
650   modify_charcode   = pisces_modify_charcode;
651   modify_spritecode = dkongjrm_modify_spritecode;
598   state->m_modify_charcode   = pisces_modify_charcode;
599   state->m_modify_spritecode = dkongjrm_modify_spritecode;
652600
653   spriteram2_present= 1;
601   state->m_spriteram2_present= 1;
654602}
655603
656VIDEO_START( newsin7 )
657{
658   VIDEO_START_CALL(scrambold);
659
660   spritevisiblearea      = &_spritevisibleareaflipx;
661   spritevisibleareaflipx = &_spritevisiblearea;
662}
663
664604VIDEO_START( scorpion )
665605{
606   galaxold_state *state = machine.driver_data<galaxold_state>();
666607   VIDEO_START_CALL(scrambold);
667608
668   modify_spritecode = batman2_modify_spritecode;
609   state->m_modify_spritecode = batman2_modify_spritecode;
669610}
670611
671static void pisces_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs)
612static void pisces_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs)
672613{
673   *code |= (gfxbank[0] << 6);
614   galaxold_state *state = machine.driver_data<galaxold_state>();
615   *code |= (state->m_gfxbank[0] << 6);
674616}
675617
676618VIDEO_START( pisces )
677619{
620   galaxold_state *state = machine.driver_data<galaxold_state>();
678621   VIDEO_START_CALL(galaxold);
679622
680   modify_charcode   = pisces_modify_charcode;
681   modify_spritecode = pisces_modify_spritecode;
623   state->m_modify_charcode   = pisces_modify_charcode;
624   state->m_modify_spritecode = pisces_modify_spritecode;
682625}
683626
684627#ifdef UNUSED_FUNCTION
r11160r11161
699642
700643VIDEO_START( theend )
701644{
645   galaxold_state *state = machine.driver_data<galaxold_state>();
702646   VIDEO_START_CALL(galaxold);
703647
704   draw_bullets = theend_draw_bullets;
648   state->m_draw_bullets = theend_draw_bullets;
705649}
706650#endif
707651
708static void mooncrst_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs)
652static void mooncrst_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs)
709653{
710   if (gfxbank[2] && ((*code & 0x30) == 0x20))
654   galaxold_state *state = machine.driver_data<galaxold_state>();
655   if (state->m_gfxbank[2] && ((*code & 0x30) == 0x20))
711656   {
712      *code = (*code & 0x0f) | (gfxbank[0] << 4) | (gfxbank[1] << 5) | 0x40;
657      *code = (*code & 0x0f) | (state->m_gfxbank[0] << 4) | (state->m_gfxbank[1] << 5) | 0x40;
713658   }
714659}
715660
716661VIDEO_START( mooncrst )
717662{
663   galaxold_state *state = machine.driver_data<galaxold_state>();
718664   VIDEO_START_CALL(galaxold);
719665
720   modify_charcode   = mooncrst_modify_charcode;
721   modify_spritecode = mooncrst_modify_spritecode;
666   state->m_modify_charcode   = mooncrst_modify_charcode;
667   state->m_modify_spritecode = mooncrst_modify_spritecode;
722668}
723669
724static void batman2_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x)
670static void batman2_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x)
725671{
672   galaxold_state *state = machine.driver_data<galaxold_state>();
726673   if (*code & 0x80)
727674   {
728      *code |= (gfxbank[0] << 8);
675      *code |= (state->m_gfxbank[0] << 8);
729676   }
730677}
731678
732679VIDEO_START( batman2 )
733680{
681   galaxold_state *state = machine.driver_data<galaxold_state>();
734682   VIDEO_START_CALL(galaxold);
735683
736   modify_charcode   = batman2_modify_charcode;
737   modify_spritecode = batman2_modify_spritecode;
738
684   state->m_modify_charcode   = batman2_modify_charcode;
685   state->m_modify_spritecode = batman2_modify_spritecode;
739686}
740687
741688
742689
743690static void rockclim_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
744691{
745   tilemap_draw(bitmap,cliprect,rockclim_tilemap, 0,0);
692   galaxold_state *state = machine.driver_data<galaxold_state>();
693   tilemap_draw(bitmap,cliprect,state->m_rockclim_tilemap, 0,0);
746694}
747695
748static void rockclim_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs)
696static void rockclim_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs)
749697{
750   if (gfxbank[2])   *code|=0x40;
698   galaxold_state *state = machine.driver_data<galaxold_state>();
699   if (state->m_gfxbank[2])   *code|=0x40;
751700}
752701
753702VIDEO_START( rockclim )
754703{
704   galaxold_state *state = machine.driver_data<galaxold_state>();
755705   VIDEO_START_CALL(galaxold);
756   rockclim_tilemap = tilemap_create(machine, rockclim_get_tile_info,tilemap_scan_rows,8,8,64,32);
757   draw_background = rockclim_draw_background;
758   modify_charcode = mooncrst_modify_charcode;
759   modify_spritecode = rockclim_modify_spritecode;
760   rockclim_v = rockclim_h = 0;
761   state_save_register_global(machine, rockclim_v);
762   state_save_register_global(machine, rockclim_h);
706   state->m_rockclim_tilemap = tilemap_create(machine, rockclim_get_tile_info,tilemap_scan_rows,8,8,64,32);
707
708   state->m_draw_background = rockclim_draw_background;
709   state->m_modify_charcode = mooncrst_modify_charcode;
710   state->m_modify_spritecode = rockclim_modify_spritecode;
711
712   state->m_rockclim_v = state->m_rockclim_h = 0;
713   state_save_register_global(machine, state->m_rockclim_v);
714   state_save_register_global(machine, state->m_rockclim_h);
763715}
764716
765717static TILE_GET_INFO( drivfrcg_get_tile_info )
766718{
767   int code = galaxold_videoram[tile_index];
719   galaxold_state *state = machine.driver_data<galaxold_state>();
720   int code = state->m_videoram[tile_index];
768721   UINT8 x = tile_index & 0x1f;
769   UINT8 color = galaxold_attributesram[(x << 1) | 1] & 7;
770   UINT8 bank = galaxold_attributesram[(x << 1) | 1] & 0x30;
722   UINT8 color = state->m_attributesram[(x << 1) | 1] & 7;
723   UINT8 bank = state->m_attributesram[(x << 1) | 1] & 0x30;
771724
772725   code |= (bank << 4);
773   color |= ((galaxold_attributesram[(x << 1) | 1] & 0x40) >> 3);
726   color |= ((state->m_attributesram[(x << 1) | 1] & 0x40) >> 3);
774727
775728   SET_TILE_INFO(0, code, color, 0);
776729}
777730
778731VIDEO_START( drivfrcg )
779732{
780   bg_tilemap = tilemap_create(machine, drivfrcg_get_tile_info,tilemap_scan_rows,8,8,32,32);
733   galaxold_state *state = machine.driver_data<galaxold_state>();
734   video_start_common(machine);
735   state->m_bg_tilemap = tilemap_create(machine, drivfrcg_get_tile_info,tilemap_scan_rows,8,8,32,32);
781736
782   tilemap_set_transparent_pen(bg_tilemap,0);
783   tilemap_set_scroll_cols(bg_tilemap, 32);
784   tilemap_set_scroll = tilemap_set_scrolly;
737   tilemap_set_transparent_pen(state->m_bg_tilemap,0);
738   tilemap_set_scroll_cols(state->m_bg_tilemap, 32);
739   state->m_tilemap_set_scroll = tilemap_set_scrolly;
785740
786   modify_charcode = 0;
787   modify_spritecode = mshuttle_modify_spritecode;
788   modify_color = drivfrcg_modify_color;
789   modify_ypos = 0;
741   state->m_modify_spritecode = mshuttle_modify_spritecode;
742   state->m_modify_color = drivfrcg_modify_color;
790743
791   mooncrst_gfxextend = 0;
792
793   draw_bullets = 0;
794
795   draw_background = galaxold_draw_background;
796   background_enable = 0;
797   background_blue = 0;
798   background_red = 0;
799   background_green = 0;
800
801   draw_stars = noop_draw_stars;
802
803   flipscreen_x = 0;
804   flipscreen_y = 0;
805
806   spriteram2_present = 0;
807
808   spritevisiblearea      = &_spritevisiblearea;
809   spritevisibleareaflipx = &_spritevisibleareaflipx;
810
811   color_mask = 0xff;
812
813   state_save_register(machine);
744   state->m_color_mask = 0xff;
814745}
815746
816747VIDEO_START( ad2083 )
817748{
818   bg_tilemap = tilemap_create(machine, drivfrcg_get_tile_info,tilemap_scan_rows,8,8,32,32);
749   galaxold_state *state = machine.driver_data<galaxold_state>();
750   video_start_common(machine);
751   state->m_bg_tilemap = tilemap_create(machine, drivfrcg_get_tile_info,tilemap_scan_rows,8,8,32,32);
819752
820   tilemap_set_transparent_pen(bg_tilemap,0);
821   tilemap_set_scroll_cols(bg_tilemap, 32);
822   tilemap_set_scroll = tilemap_set_scrolly;
753   tilemap_set_transparent_pen(state->m_bg_tilemap,0);
754   tilemap_set_scroll_cols(state->m_bg_tilemap, 32);
755   state->m_tilemap_set_scroll = tilemap_set_scrolly;
823756
824   modify_charcode = 0;
825   modify_spritecode = ad2083_modify_spritecode;
826   modify_color = 0;
827   modify_ypos = 0;
757   state->m_modify_spritecode = ad2083_modify_spritecode;
828758
829   mooncrst_gfxextend = 0;
759   state->m_draw_bullets = scrambold_draw_bullets;
830760
831   draw_bullets = scrambold_draw_bullets;
761   state->m_draw_background = ad2083_draw_background;
832762
833   draw_background = ad2083_draw_background;
834   background_enable = 0;
835   background_blue = 0;
836   background_red = 0;
837   background_green = 0;
838
839   draw_stars = noop_draw_stars;
840
841   flipscreen_x = 0;
842   flipscreen_y = 0;
843
844   spriteram2_present = 0;
845
846   spritevisiblearea      = &_spritevisiblearea;
847   spritevisibleareaflipx = &_spritevisibleareaflipx;
848
849   color_mask = 7;
850
851   state_save_register(machine);
763   state->m_color_mask = 7;
852764}
853765
854UINT8 *racknrol_tiles_bank;
855766
856767WRITE8_HANDLER( racknrol_tiles_bank_w )
857768{
858   racknrol_tiles_bank[offset] = data;
859   tilemap_mark_all_tiles_dirty(bg_tilemap);
769   galaxold_state *state = space->machine().driver_data<galaxold_state>();
770   state->m_racknrol_tiles_bank[offset] = data;
771   tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
860772}
861773
862774static TILE_GET_INFO( racknrol_get_tile_info )
863775{
864   int code = galaxold_videoram[tile_index];
776   galaxold_state *state = machine.driver_data<galaxold_state>();
777   int code = state->m_videoram[tile_index];
865778   UINT8 x = tile_index & 0x1f;
866   UINT8 color = galaxold_attributesram[(x << 1) | 1] & 7;
867   UINT8 bank = racknrol_tiles_bank[x] & 7;
779   UINT8 color = state->m_attributesram[(x << 1) | 1] & 7;
780   UINT8 bank = state->m_racknrol_tiles_bank[x] & 7;
868781
869782   code |= (bank << 8);
870783
r11160r11161
873786
874787VIDEO_START( racknrol )
875788{
876   bg_tilemap = tilemap_create(machine, racknrol_get_tile_info,tilemap_scan_rows,8,8,32,32);
789   galaxold_state *state = machine.driver_data<galaxold_state>();
790   video_start_common(machine);
791   state->m_bg_tilemap = tilemap_create(machine, racknrol_get_tile_info,tilemap_scan_rows,8,8,32,32);
877792
878   tilemap_set_transparent_pen(bg_tilemap,0);
879   tilemap_set_scroll_cols(bg_tilemap, 32);
880   tilemap_set_scroll = tilemap_set_scrolly;
793   tilemap_set_transparent_pen(state->m_bg_tilemap,0);
794   tilemap_set_scroll_cols(state->m_bg_tilemap, 32);
795   state->m_tilemap_set_scroll = tilemap_set_scrolly;
881796
882   modify_charcode = 0;
883   modify_spritecode = 0;
884   modify_color = 0;
885   modify_ypos = 0;
886
887   mooncrst_gfxextend = 0;
888
889   draw_bullets = 0;
890
891   draw_background = galaxold_draw_background;
892   background_enable = 0;
893   background_blue = 0;
894   background_red = 0;
895   background_green = 0;
896
897   draw_stars = noop_draw_stars;
898
899   flipscreen_x = 0;
900   flipscreen_y = 0;
901
902   spriteram2_present = 0;
903
904   spritevisiblearea      = &_spritevisiblearea;
905   spritevisibleareaflipx = &_spritevisibleareaflipx;
906
907   color_mask = 0xff;
908
909   state_save_register(machine);
797   state->m_color_mask = 0xff;
910798}
911799
912800VIDEO_START( bongo )
913801{
802   galaxold_state *state = machine.driver_data<galaxold_state>();
914803   VIDEO_START_CALL(galaxold_plain);
915804
916   modify_spritecode = batman2_modify_spritecode;
805   state->m_modify_spritecode = batman2_modify_spritecode;
917806}
918807
919808static TILE_GET_INFO( dambustr_get_tile_info2 )
920809{
810   galaxold_state *state = machine.driver_data<galaxold_state>();
921811   UINT8 x = tile_index & 0x1f;
922812
923   UINT16 code = dambustr_videoram2[tile_index];
924   UINT8 color = galaxold_attributesram[(x << 1) | 1] & color_mask;
813   UINT16 code = state->m_dambustr_videoram2[tile_index];
814   UINT8 color = state->m_attributesram[(x << 1) | 1] & state->m_color_mask;
925815
926   if (modify_charcode)
816   if (state->m_modify_charcode)
927817   {
928      modify_charcode(machine, &code, x);
818      (*state->m_modify_charcode)(machine, &code, x);
929819   }
930820
931   if (modify_color)
821   if (state->m_modify_color)
932822   {
933      modify_color(&color);
823      (*state->m_modify_color)(&color);
934824   }
935825
936826   SET_TILE_INFO(0, code, color, 0);
r11160r11161
938828
939829VIDEO_START( dambustr )
940830{
831   galaxold_state *state = machine.driver_data<galaxold_state>();
941832   VIDEO_START_CALL(galaxold);
942833
943   dambustr_bg_split_line = 0;
944   dambustr_bg_color_1 = 0;
945   dambustr_bg_color_2 = 0;
946   dambustr_bg_priority = 0;
947   dambustr_char_bank = 0;
834   state->m_dambustr_bg_split_line = 0;
835   state->m_dambustr_bg_color_1 = 0;
836   state->m_dambustr_bg_color_2 = 0;
837   state->m_dambustr_bg_priority = 0;
838   state->m_dambustr_char_bank = 0;
948839
949   draw_background = dambustr_draw_background;
840   state->m_draw_background = dambustr_draw_background;
950841
951   modify_charcode   = dambustr_modify_charcode;
952   modify_spritecode = dambustr_modify_spritecode;
842   state->m_modify_charcode   = dambustr_modify_charcode;
843   state->m_modify_spritecode = dambustr_modify_spritecode;
953844
954   draw_bullets = dambustr_draw_bullets;
845   state->m_draw_bullets = dambustr_draw_bullets;
955846
956847   /* allocate the temporary bitmap for the background priority */
957   dambustr_tmpbitmap = machine.primary_screen->alloc_compatible_bitmap();
848   state->m_dambustr_tmpbitmap = machine.primary_screen->alloc_compatible_bitmap();
958849
959850   /* make a copy of the tilemap to emulate background priority */
960   dambustr_videoram2 = auto_alloc_array(machine, UINT8, 0x0400);
961   dambustr_tilemap2 = tilemap_create(machine, dambustr_get_tile_info2,tilemap_scan_rows,8,8,32,32);
851   state->m_dambustr_videoram2 = auto_alloc_array(machine, UINT8, 0x0400);
852   state->m_dambustr_tilemap2 = tilemap_create(machine, dambustr_get_tile_info2,tilemap_scan_rows,8,8,32,32);
962853
963   tilemap_set_transparent_pen(dambustr_tilemap2,0);
854   tilemap_set_transparent_pen(state->m_dambustr_tilemap2,0);
964855}
965856
966857
967858WRITE8_HANDLER( galaxold_videoram_w )
968859{
969   galaxold_videoram[offset] = data;
970   tilemap_mark_tile_dirty(bg_tilemap, offset);
860   galaxold_state *state = space->machine().driver_data<galaxold_state>();
861   state->m_videoram[offset] = data;
862   tilemap_mark_tile_dirty(state->m_bg_tilemap, offset);
971863}
972864
973865READ8_HANDLER( galaxold_videoram_r )
974866{
975   return galaxold_videoram[offset];
867   galaxold_state *state = space->machine().driver_data<galaxold_state>();
868   return state->m_videoram[offset];
976869}
977870
978871
979872WRITE8_HANDLER( galaxold_attributesram_w )
980873{
981   if (galaxold_attributesram[offset] != data)
874   galaxold_state *state = space->machine().driver_data<galaxold_state>();
875   if (state->m_attributesram[offset] != data)
982876   {
983877      if (offset & 0x01)
984878      {
r11160r11161
986880         int i;
987881
988882         for (i = offset >> 1; i < 0x0400; i += 32)
989            tilemap_mark_tile_dirty(bg_tilemap, i);
883            tilemap_mark_tile_dirty(state->m_bg_tilemap, i);
990884      }
991885      else
992886      {
993         if (modify_ypos)
887         if (state->m_modify_ypos)
994888         {
995            modify_ypos(&data);
889            (*state->m_modify_ypos)(&data);
996890         }
997891
998         tilemap_set_scroll(bg_tilemap, offset >> 1, data);
892         (*state->m_tilemap_set_scroll)(state->m_bg_tilemap, offset >> 1, data);
999893      }
1000894
1001      galaxold_attributesram[offset] = data;
895      state->m_attributesram[offset] = data;
1002896   }
1003897}
1004898
1005899
1006900WRITE8_HANDLER( galaxold_flip_screen_x_w )
1007901{
1008   if (flipscreen_x != (data & 0x01))
902   galaxold_state *state = space->machine().driver_data<galaxold_state>();
903   if (state->m_flipscreen_x != (data & 0x01))
1009904   {
1010      flipscreen_x = data & 0x01;
905      state->m_flipscreen_x = data & 0x01;
1011906
1012      tilemap_set_flip(bg_tilemap, (flipscreen_x ? TILEMAP_FLIPX : 0) | (flipscreen_y ? TILEMAP_FLIPY : 0));
907      tilemap_set_flip(state->m_bg_tilemap, (state->m_flipscreen_x ? TILEMAP_FLIPX : 0) | (state->m_flipscreen_y ? TILEMAP_FLIPY : 0));
1013908   }
1014909}
1015910
1016911WRITE8_HANDLER( galaxold_flip_screen_y_w )
1017912{
1018   if (flipscreen_y != (data & 0x01))
913   galaxold_state *state = space->machine().driver_data<galaxold_state>();
914   if (state->m_flipscreen_y != (data & 0x01))
1019915   {
1020      flipscreen_y = data & 0x01;
916      state->m_flipscreen_y = data & 0x01;
1021917
1022      tilemap_set_flip(bg_tilemap, (flipscreen_x ? TILEMAP_FLIPX : 0) | (flipscreen_y ? TILEMAP_FLIPY : 0));
918      tilemap_set_flip(state->m_bg_tilemap, (state->m_flipscreen_x ? TILEMAP_FLIPX : 0) | (state->m_flipscreen_y ? TILEMAP_FLIPY : 0));
1023919   }
1024920}
1025921
r11160r11161
1046942
1047943WRITE8_HANDLER( scrambold_background_enable_w )
1048944{
1049   background_enable = data & 0x01;
945   galaxold_state *state = space->machine().driver_data<galaxold_state>();
946   state->m_background_enable = data & 0x01;
1050947}
1051948
1052949WRITE8_HANDLER( scrambold_background_red_w )
1053950{
1054   background_red = data & 0x01;
951   galaxold_state *state = space->machine().driver_data<galaxold_state>();
952   state->m_background_red = data & 0x01;
1055953}
1056954
1057955WRITE8_HANDLER( scrambold_background_green_w )
1058956{
1059   background_green = data & 0x01;
957   galaxold_state *state = space->machine().driver_data<galaxold_state>();
958   state->m_background_green = data & 0x01;
1060959}
1061960
1062961WRITE8_HANDLER( scrambold_background_blue_w )
1063962{
1064   background_blue = data & 0x01;
963   galaxold_state *state = space->machine().driver_data<galaxold_state>();
964   state->m_background_blue = data & 0x01;
1065965}
1066966
1067967
1068968WRITE8_HANDLER( galaxold_stars_enable_w )
1069969{
1070   galaxold_stars_on = data & 0x01;
970   galaxold_state *state = space->machine().driver_data<galaxold_state>();
971   state->m_stars_on = data & 0x01;
1071972
1072   if (!galaxold_stars_on)
973   if (!state->m_stars_on)
1073974   {
1074      stars_scrollpos = 0;
975      state->m_stars_scrollpos = 0;
1075976   }
1076977}
1077978
1078979
1079980WRITE8_HANDLER( darkplnt_bullet_color_w )
1080981{
1081   darkplnt_bullet_color = data & 0x01;
982   galaxold_state *state = space->machine().driver_data<galaxold_state>();
983   state->m_darkplnt_bullet_color = data & 0x01;
1082984}
1083985
1084986
1085987
1086988WRITE8_HANDLER( galaxold_gfxbank_w )
1087989{
1088   if (gfxbank[offset] != data)
990   galaxold_state *state = space->machine().driver_data<galaxold_state>();
991   if (state->m_gfxbank[offset] != data)
1089992   {
1090      gfxbank[offset] = data;
993      state->m_gfxbank[offset] = data;
1091994
1092      tilemap_mark_all_tiles_dirty(bg_tilemap);
995      tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
1093996   }
1094997}
1095998
1096999WRITE8_HANDLER( rockclim_videoram_w )
10971000{
1098   rockclim_videoram[offset] = data;
1099   tilemap_mark_tile_dirty(rockclim_tilemap, offset);
1001   galaxold_state *state = space->machine().driver_data<galaxold_state>();
1002   state->m_rockclim_videoram[offset] = data;
1003   tilemap_mark_tile_dirty(state->m_rockclim_tilemap, offset);
11001004}
11011005
11021006WRITE8_HANDLER( rockclim_scroll_w )
11031007{
1008   galaxold_state *state = space->machine().driver_data<galaxold_state>();
11041009   switch(offset&3)
11051010   {
1106      case 0: rockclim_h=(rockclim_h&0xff00)|data;tilemap_set_scrollx(rockclim_tilemap , 0, rockclim_h );break;
1107      case 1:   rockclim_h=(rockclim_h&0xff)|(data<<8);tilemap_set_scrollx(rockclim_tilemap , 0, rockclim_h );break;
1108      case 2:   rockclim_v=(rockclim_v&0xff00)|data;tilemap_set_scrolly(rockclim_tilemap , 0, rockclim_v );break;
1109      case 3:   rockclim_v=(rockclim_v&0xff)|(data<<8);tilemap_set_scrolly(rockclim_tilemap , 0, rockclim_v );break;
1011      case 0: state->m_rockclim_h=(state->m_rockclim_h&0xff00)|data;tilemap_set_scrollx(state->m_rockclim_tilemap , 0, state->m_rockclim_h );break;
1012      case 1:   state->m_rockclim_h=(state->m_rockclim_h&0xff)|(data<<8);tilemap_set_scrollx(state->m_rockclim_tilemap , 0, state->m_rockclim_h );break;
1013      case 2:   state->m_rockclim_v=(state->m_rockclim_v&0xff00)|data;tilemap_set_scrolly(state->m_rockclim_tilemap , 0, state->m_rockclim_v );break;
1014      case 3:   state->m_rockclim_v=(state->m_rockclim_v&0xff)|(data<<8);tilemap_set_scrolly(state->m_rockclim_tilemap , 0, state->m_rockclim_v );break;
11101015   }
11111016
11121017}
r11160r11161
11141019
11151020READ8_HANDLER( rockclim_videoram_r )
11161021{
1117   return rockclim_videoram[offset];
1022   galaxold_state *state = space->machine().driver_data<galaxold_state>();
1023   return state->m_rockclim_videoram[offset];
11181024}
11191025
11201026
11211027WRITE8_HANDLER( dambustr_bg_split_line_w )
11221028{
1123   dambustr_bg_split_line = data;
1029   galaxold_state *state = space->machine().driver_data<galaxold_state>();
1030   state->m_dambustr_bg_split_line = data;
11241031}
11251032
11261033
11271034WRITE8_HANDLER( dambustr_bg_color_w )
11281035{
1129   dambustr_bg_color_1 = (BIT(data,2)<<2) | (BIT(data,1)<<1) | BIT(data,0);
1130   dambustr_bg_color_2 = (BIT(data,6)<<2) | (BIT(data,5)<<1) | BIT(data,4);
1131   dambustr_bg_priority = BIT(data,3);
1132   dambustr_char_bank = BIT(data,7);
1133   tilemap_mark_all_tiles_dirty(bg_tilemap);
1036   galaxold_state *state = space->machine().driver_data<galaxold_state>();
1037   state->m_dambustr_bg_color_1 = (BIT(data,2)<<2) | (BIT(data,1)<<1) | BIT(data,0);
1038   state->m_dambustr_bg_color_2 = (BIT(data,6)<<2) | (BIT(data,5)<<1) | BIT(data,4);
1039   state->m_dambustr_bg_priority = BIT(data,3);
1040   state->m_dambustr_char_bank = BIT(data,7);
1041   tilemap_mark_all_tiles_dirty(state->m_bg_tilemap);
11341042}
11351043
11361044
11371045
11381046/* character banking functions */
11391047
1140static void mooncrst_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x)
1048static void mooncrst_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x)
11411049{
1142   if (gfxbank[2] && ((*code & 0xc0) == 0x80))
1050   galaxold_state *state = machine.driver_data<galaxold_state>();
1051   if (state->m_gfxbank[2] && ((*code & 0xc0) == 0x80))
11431052   {
1144      *code = (*code & 0x3f) | (gfxbank[0] << 6) | (gfxbank[1] << 7) | 0x0100;
1053      *code = (*code & 0x3f) | (state->m_gfxbank[0] << 6) | (state->m_gfxbank[1] << 7) | 0x0100;
11451054   }
11461055}
11471056
1148static void pisces_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x)
1057static void pisces_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x)
11491058{
1150   *code |= (gfxbank[0] << 8);
1059   galaxold_state *state = machine.driver_data<galaxold_state>();
1060   *code |= (state->m_gfxbank[0] << 8);
11511061}
11521062
1153static void mimonkey_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x)
1063static void mimonkey_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x)
11541064{
1155   *code |= (gfxbank[0] << 8) | (gfxbank[2] << 9);
1065   galaxold_state *state = machine.driver_data<galaxold_state>();
1066   *code |= (state->m_gfxbank[0] << 8) | (state->m_gfxbank[2] << 9);
11561067}
11571068
1158static void mariner_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x)
1069static void mariner_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x)
11591070{
11601071   UINT8 *prom;
11611072
r11160r11161
11671078   *code |= ((prom[x] & 0x01) << 8);
11681079}
11691080
1170static void dambustr_modify_charcode(running_machine &machine, UINT16 *code,UINT8 x)
1081static void dambustr_modify_charcode(running_machine &machine, UINT16 *code, UINT8 x)
11711082{
1172   if (dambustr_char_bank == 0) {   // text mode
1083   galaxold_state *state = machine.driver_data<galaxold_state>();
1084   if (state->m_dambustr_char_bank == 0) {   // text mode
11731085      *code |= 0x0300;
11741086   }
11751087   else {            // graphics mode
r11160r11161
11841096
11851097/* sprite banking functions */
11861098
1187static void mshuttle_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs)
1099static void mshuttle_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs)
11881100{
11891101   *code |= ((spriteram[offs + 2] & 0x30) << 2);
11901102}
11911103
11921104
1193static void mimonkey_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs)
1105static void mimonkey_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs)
11941106{
1195   *code |= (gfxbank[0] << 6) | (gfxbank[2] << 7);
1107   galaxold_state *state = machine.driver_data<galaxold_state>();
1108   *code |= (state->m_gfxbank[0] << 6) | (state->m_gfxbank[2] << 7);
11961109}
11971110
1198static void batman2_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs)
1111static void batman2_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs)
11991112{
12001113   /* only the upper 64 sprites are used */
12011114   *code |= 0x40;
12021115}
12031116
1204static void dkongjrm_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs)
1117static void dkongjrm_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs)
12051118{
12061119   /* No x flip */
12071120   *code = (spriteram[offs + 1] & 0x7f) | 0x80;
12081121   *flipx = 0;
12091122}
12101123
1211static void ad2083_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs)
1124static void ad2083_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs)
12121125{
12131126   /* No x flip */
12141127   *code = (spriteram[offs + 1] & 0x7f) | ((spriteram[offs + 2] & 0x30) << 2);
12151128   *flipx = 0;
12161129}
12171130
1218static void dambustr_modify_spritecode(UINT8 *spriteram,int *code,int *flipx,int *flipy,int offs)
1131static void dambustr_modify_spritecode(running_machine &machine, UINT8 *spriteram, int *code, int *flipx, int *flipy, int offs)
12191132{
12201133   *code += 0x40;
12211134}
r11160r11161
12571170
12581171static void scrambold_draw_bullets(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y)
12591172{
1260   if (flipscreen_x)  x++;
1173   galaxold_state *state = machine.driver_data<galaxold_state>();
1174   if (state->m_flipscreen_x)  x++;
12611175
12621176   x = x - 6;
12631177
r11160r11161
12681182
12691183static void darkplnt_draw_bullets(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y)
12701184{
1271   if (flipscreen_x)  x++;
1185   galaxold_state *state = machine.driver_data<galaxold_state>();
1186   if (state->m_flipscreen_x)  x++;
12721187
12731188   x = x - 6;
12741189
12751190   if ((x >= cliprect->min_x) && (x <= cliprect->max_x) && (y >= cliprect->min_y) && (y <= cliprect->max_y))
1276      *BITMAP_ADDR16(bitmap, y, x) = 32 + darkplnt_bullet_color;
1191      *BITMAP_ADDR16(bitmap, y, x) = 32 + state->m_darkplnt_bullet_color;
12771192}
12781193
12791194static void dambustr_draw_bullets(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int x, int y)
r11160r11161
13141229
13151230static void scrambold_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
13161231{
1317   if (background_enable)
1232   galaxold_state *state = machine.driver_data<galaxold_state>();
1233   if (state->m_background_enable)
13181234      bitmap_fill(bitmap,cliprect,BACKGROUND_COLOR_BASE);
13191235   else
13201236      bitmap_fill(bitmap,cliprect,0);
r11160r11161
13221238
13231239static void ad2083_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
13241240{
1325   int color = (background_blue << 2) | (background_green << 1) | background_red;
1241   galaxold_state *state = machine.driver_data<galaxold_state>();
1242   int color = (state->m_background_blue << 2) | (state->m_background_green << 1) | state->m_background_red;
13261243
13271244   bitmap_fill(bitmap,cliprect,BACKGROUND_COLOR_BASE + color);
13281245}
13291246
13301247static void stratgyx_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
13311248{
1249   galaxold_state *state = machine.driver_data<galaxold_state>();
13321250   UINT8 x;
13331251   UINT8 *prom;
13341252   int base = BACKGROUND_COLOR_BASE;
r11160r11161
13501268
13511269      color = 0;
13521270
1353      if ((~prom[x] & 0x02) && background_red)   color |= 0x01;
1354      if ((~prom[x] & 0x02) && background_green) color |= 0x02;
1355      if ((~prom[x] & 0x01) && background_blue)  color |= 0x04;
1271      if ((~prom[x] & 0x02) && state->m_background_red)   color |= 0x01;
1272      if ((~prom[x] & 0x02) && state->m_background_green) color |= 0x02;
1273      if ((~prom[x] & 0x01) && state->m_background_blue)  color |= 0x04;
13561274
1357      if (flipscreen_x)
1275      if (state->m_flipscreen_x)
13581276         sx = 8 * (31 - x);
13591277      else
13601278         sx = 8 * x;
r11160r11161
13651283
13661284static void minefld_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
13671285{
1368   if (background_enable)
1286   galaxold_state *state = machine.driver_data<galaxold_state>();
1287   if (state->m_background_enable)
13691288   {
13701289      int base = BACKGROUND_COLOR_BASE;
13711290      int x;
r11160r11161
13851304
13861305static void rescue_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
13871306{
1388   if (background_enable)
1307   galaxold_state *state = machine.driver_data<galaxold_state>();
1308   if (state->m_background_enable)
13891309   {
13901310      int base = BACKGROUND_COLOR_BASE;
13911311      int x;
r11160r11161
14041324
14051325static void mariner_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
14061326{
1327   galaxold_state *state = machine.driver_data<galaxold_state>();
14071328   int base = BACKGROUND_COLOR_BASE;
14081329   UINT8 x;
14091330   UINT8 *prom;
r11160r11161
14151336
14161337   prom = machine.region("user1")->base();
14171338
1418   if (flipscreen_x)
1339   if (state->m_flipscreen_x)
14191340   {
14201341      for (x = 0; x < 32; x++)
14211342      {
r11160r11161
14471368
14481369static void dambustr_draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
14491370{
1371   galaxold_state *state = machine.driver_data<galaxold_state>();
14501372   int base = BACKGROUND_COLOR_BASE;
1451   int col1 = base + dambustr_bg_color_1;
1452   int col2 = base + dambustr_bg_color_2;
1373   int col1 = base + state->m_dambustr_bg_color_1;
1374   int col2 = base + state->m_dambustr_bg_color_2;
14531375
14541376   if (flip_screen_x_get(machine))
14551377   {
1456      plot_box(bitmap,   0, 0, 256-dambustr_bg_split_line, 256, col2);
1457      plot_box(bitmap, 256-dambustr_bg_split_line, 0, dambustr_bg_split_line, 256, col1);
1378      plot_box(bitmap,   0, 0, 256-state->m_dambustr_bg_split_line, 256, col2);
1379      plot_box(bitmap, 256-state->m_dambustr_bg_split_line, 0, state->m_dambustr_bg_split_line, 256, col1);
14581380   }
14591381   else
14601382   {
1461      plot_box(bitmap,   0, 0, 256-dambustr_bg_split_line, 256, col1);
1462      plot_box(bitmap, 256-dambustr_bg_split_line, 0, dambustr_bg_split_line, 256, col2);
1383      plot_box(bitmap,   0, 0, 256-state->m_dambustr_bg_split_line, 256, col1);
1384      plot_box(bitmap, 256-state->m_dambustr_bg_split_line, 0, state->m_dambustr_bg_split_line, 256, col2);
14631385   }
14641386
14651387}
14661388
14671389static void dambustr_draw_upper_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
14681390{
1469   static rectangle clip = { 0, 0, 0, 0 };
1391   galaxold_state *state = machine.driver_data<galaxold_state>();
1392   rectangle clip;
14701393
14711394   if (flip_screen_x_get(machine))
14721395   {
1473      clip.min_x = 254 - dambustr_bg_split_line;
1474      clip.max_x = dambustr_bg_split_line;
1396      clip.min_x = 254 - state->m_dambustr_bg_split_line;
1397      clip.max_x = state->m_dambustr_bg_split_line;
14751398      clip.min_y = 0;
14761399      clip.max_y = 255;
1477      copybitmap(bitmap, dambustr_tmpbitmap, 0, 0, 0, 0, &clip);
1400      copybitmap(bitmap, state->m_dambustr_tmpbitmap, 0, 0, 0, 0, &clip);
14781401   }
14791402   else
14801403   {
14811404      clip.min_x = 0;
1482      clip.max_x = 254 - dambustr_bg_split_line;
1405      clip.max_x = 254 - state->m_dambustr_bg_split_line;
14831406      clip.min_y = 0;
14841407      clip.max_y = 255;
1485      copybitmap(bitmap, dambustr_tmpbitmap, 0, 0, 0, 0, &clip);
1408      copybitmap(bitmap, state->m_dambustr_tmpbitmap, 0, 0, 0, 0, &clip);
14861409   }
14871410}
14881411
r11160r11161
14921415
14931416void galaxold_init_stars(running_machine &machine, int colors_offset)
14941417{
1418   galaxold_state *state = machine.driver_data<galaxold_state>();
1419   struct star *stars = state->m_stars;
14951420   int i;
14961421   int total_stars;
14971422   UINT32 generator;
14981423   int x,y;
14991424
15001425
1501   galaxold_stars_on = 0;
1502   stars_blink_state = 0;
1503   stars_blink_timer = machine.scheduler().timer_alloc(FUNC(stars_blink_callback));
1504   stars_scroll_timer = machine.scheduler().timer_alloc(FUNC(stars_scroll_callback));
1505   timer_adjusted = 0;
1506   stars_colors_start = colors_offset;
1426   state->m_stars_on = 0;
1427   state->m_stars_blink_state = 0;
1428   state->m_stars_blink_timer = machine.scheduler().timer_alloc(FUNC(stars_blink_callback));
1429   state->m_stars_scroll_timer = machine.scheduler().timer_alloc(FUNC(stars_scroll_callback));
1430   state->m_timer_adjusted = 0;
1431   state->m_stars_colors_start = colors_offset;
15071432
15081433   for (i = 0;i < 64;i++)
15091434   {
r11160r11161
15611486   }
15621487}
15631488
1564static void plot_star(bitmap_t *bitmap, int x, int y, int color, const rectangle *cliprect)
1489static void plot_star(galaxold_state *state, bitmap_t *bitmap, int x, int y, int color, const rectangle *cliprect)
15651490{
1566   if (flipscreen_x)
1491   if (state->m_flipscreen_x)
15671492      x = 255 - x;
15681493
1569   if (flipscreen_y)
1494   if (state->m_flipscreen_y)
15701495      y = 255 - y;
15711496
15721497   if ((x >= cliprect->min_x) && (x <= cliprect->max_x) && (y >= cliprect->min_y) && (y <= cliprect->max_y))
1573      *BITMAP_ADDR16(bitmap, y, x) = stars_colors_start + color;
1498      *BITMAP_ADDR16(bitmap, y, x) = state->m_stars_colors_start + color;
15741499}
15751500
15761501static void noop_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
r11160r11161
15791504
15801505void galaxold_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
15811506{
1507   galaxold_state *state = machine.driver_data<galaxold_state>();
1508   struct star *stars = state->m_stars;
15821509   int offs;
15831510
15841511
1585   if (!timer_adjusted)
1512   if (!state->m_timer_adjusted)
15861513   {
15871514      start_stars_scroll_timer(machine);
1588      timer_adjusted = 1;
1515      state->m_timer_adjusted = 1;
15891516   }
15901517
15911518
r11160r11161
15941521      int x,y;
15951522
15961523
1597      x = ((stars[offs].x +   stars_scrollpos) & 0x01ff) >> 1;
1598      y = ( stars[offs].y + ((stars_scrollpos + stars[offs].x) >> 9)) & 0xff;
1524      x = ((stars[offs].x +   state->m_stars_scrollpos) & 0x01ff) >> 1;
1525      y = ( stars[offs].y + ((state->m_stars_scrollpos + stars[offs].x) >> 9)) & 0xff;
15991526
16001527      if ((y & 0x01) ^ ((x >> 3) & 0x01))
16011528      {
1602         plot_star(bitmap, x, y, stars[offs].color, cliprect);
1529         plot_star(state, bitmap, x, y, stars[offs].color, cliprect);
16031530      }
16041531   }
16051532}
16061533
16071534static void scrambold_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
16081535{
1536   galaxold_state *state = machine.driver_data<galaxold_state>();
1537   struct star *stars = state->m_stars;
16091538   int offs;
16101539
16111540
1612   if (!timer_adjusted)
1541   if (!state->m_timer_adjusted)
16131542   {
1614      start_stars_blink_timer(100000, 10000, 0.00001);
1615      timer_adjusted = 1;
1543      start_stars_blink_timer(machine, 100000, 10000, 0.00001);
1544      state->m_timer_adjusted = 1;
16161545   }
16171546
16181547
r11160r11161
16271556      if ((y & 0x01) ^ ((x >> 3) & 0x01))
16281557      {
16291558         /* determine when to skip plotting */
1630         switch (stars_blink_state & 0x03)
1559         switch (state->m_stars_blink_state & 0x03)
16311560         {
16321561         case 0:
16331562            if (!(stars[offs].color & 0x01))  continue;
r11160r11161
16431572            break;
16441573         }
16451574
1646         plot_star(bitmap, x, y, stars[offs].color, cliprect);
1575         plot_star(state, bitmap, x, y, stars[offs].color, cliprect);
16471576      }
16481577   }
16491578}
16501579
16511580static void rescue_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
16521581{
1582   galaxold_state *state = machine.driver_data<galaxold_state>();
1583   struct star *stars = state->m_stars;
16531584   int offs;
16541585
16551586
16561587   /* same as Scramble, but only top (left) half of screen */
16571588
1658   if (!timer_adjusted)
1589   if (!state->m_timer_adjusted)
16591590   {
1660      start_stars_blink_timer(100000, 10000, 0.00001);
1661      timer_adjusted = 1;
1591      start_stars_blink_timer(machine, 100000, 10000, 0.00001);
1592      state->m_timer_adjusted = 1;
16621593   }
16631594
16641595
r11160r11161
16731604      if ((x < 128) && ((y & 0x01) ^ ((x >> 3) & 0x01)))
16741605      {
16751606         /* determine when to skip plotting */
1676         switch (stars_blink_state & 0x03)
1607         switch (state->m_stars_blink_state & 0x03)
16771608         {
16781609         case 0:
16791610            if (!(stars[offs].color & 0x01))  continue;
r11160r11161
16891620            break;
16901621         }
16911622
1692         plot_star(bitmap, x, y, stars[offs].color, cliprect);
1623         plot_star(state, bitmap, x, y, stars[offs].color, cliprect);
16931624      }
16941625   }
16951626}
16961627
16971628static void mariner_draw_stars(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
16981629{
1630   galaxold_state *state = machine.driver_data<galaxold_state>();
1631   struct star *stars = state->m_stars;
16991632   int offs;
17001633   UINT8 *prom;
17011634
17021635
1703   if (!timer_adjusted)
1636   if (!state->m_timer_adjusted)
17041637   {
17051638      start_stars_scroll_timer(machine);
1706      timer_adjusted = 1;
1639      state->m_timer_adjusted = 1;
17071640   }
17081641
17091642
r11160r11161
17161649      int x,y;
17171650
17181651
1719      x = ((stars[offs].x +   -stars_scrollpos) & 0x01ff) >> 1;
1720      y = ( stars[offs].y + ((-stars_scrollpos + stars[offs].x) >> 9)) & 0xff;
1652      x = ((stars[offs].x +   -state->m_stars_scrollpos) & 0x01ff) >> 1;
1653      y = ( stars[offs].y + ((-state->m_stars_scrollpos + stars[offs].x) >> 9)) & 0xff;
17211654
17221655      if ((y & 0x01) ^ ((x >> 3) & 0x01))
17231656      {
17241657         if (prom[(x/8 + 1) & 0x1f] & 0x04)
17251658         {
1726            plot_star(bitmap, x, y, stars[offs].color, cliprect);
1659            plot_star(state, bitmap, x, y, stars[offs].color, cliprect);
17271660         }
17281661      }
17291662   }
r11160r11161
17311664
17321665static TIMER_CALLBACK( stars_blink_callback )
17331666{
1734   stars_blink_state++;
1667   galaxold_state *state = machine.driver_data<galaxold_state>();
1668   state->m_stars_blink_state++;
17351669}
17361670
1737static void start_stars_blink_timer(double ra, double rb, double c)
1671static void start_stars_blink_timer(running_machine &machine, double ra, double rb, double c)
17381672{
1673   galaxold_state *state = machine.driver_data<galaxold_state>();
17391674   /* calculate the period using the formula given in the 555 datasheet */
17401675
17411676   int period_in_ms = 693 * (ra + 2.0 * rb) * c;
17421677
1743   stars_blink_timer->adjust(attotime::from_msec(period_in_ms), 0, attotime::from_msec(period_in_ms));
1678   state->m_stars_blink_timer->adjust(attotime::from_msec(period_in_ms), 0, attotime::from_msec(period_in_ms));
17441679}
17451680
17461681
17471682static TIMER_CALLBACK( stars_scroll_callback )
17481683{
1749   if (galaxold_stars_on)
1684   galaxold_state *state = machine.driver_data<galaxold_state>();
1685   if (state->m_stars_on)
17501686   {
1751      stars_scrollpos++;
1687      state->m_stars_scrollpos++;
17521688   }
17531689}
17541690
17551691static void start_stars_scroll_timer(running_machine &machine)
17561692{
1757   stars_scroll_timer->adjust(machine.primary_screen->frame_period(), 0, machine.primary_screen->frame_period());
1693   galaxold_state *state = machine.driver_data<galaxold_state>();
1694   state->m_stars_scroll_timer->adjust(machine.primary_screen->frame_period(), 0, machine.primary_screen->frame_period());
17581695}
17591696
17601697
17611698
17621699static TILE_GET_INFO( get_tile_info )
17631700{
1701   galaxold_state *state = machine.driver_data<galaxold_state>();
17641702   UINT8 x = tile_index & 0x1f;
17651703
1766   UINT16 code = galaxold_videoram[tile_index];
1767   UINT8 color = galaxold_attributesram[(x << 1) | 1] & color_mask;
1704   UINT16 code = state->m_videoram[tile_index];
1705   UINT8 color = state->m_attributesram[(x << 1) | 1] & state->m_color_mask;
17681706
1769   if (modify_charcode)
1707   if (state->m_modify_charcode)
17701708   {
1771      modify_charcode(machine, &code, x);
1709      (*state->m_modify_charcode)(machine, &code, x);
17721710   }
17731711
1774   if (modify_color)
1712   if (state->m_modify_color)
17751713   {
1776      modify_color(&color);
1714      (*state->m_modify_color)(&color);
17771715   }
17781716
17791717   SET_TILE_INFO(0, code, color, 0);
r11160r11161
17811719
17821720static TILE_GET_INFO( rockclim_get_tile_info )
17831721{
1784   UINT16 code = rockclim_videoram[tile_index];
1722   galaxold_state *state = machine.driver_data<galaxold_state>();
1723   UINT16 code = state->m_rockclim_videoram[tile_index];
17851724   SET_TILE_INFO(2, code, 0, 0);
17861725}
17871726
17881727static void draw_bullets_common(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
17891728{
1729   galaxold_state *state = machine.driver_data<galaxold_state>();
17901730   int offs;
17911731
17921732
1793   for (offs = 0;offs < galaxold_bulletsram_size;offs += 4)
1733   for (offs = 0;offs < state->m_bulletsram_size;offs += 4)
17941734   {
17951735      UINT8 sx,sy;
17961736
1797      sy = 255 - galaxold_bulletsram[offs + 1];
1798      sx = 255 - galaxold_bulletsram[offs + 3];
1737      sy = 255 - state->m_bulletsram[offs + 1];
1738      sx = 255 - state->m_bulletsram[offs + 3];
17991739
1800      if (flipscreen_y)  sy = 255 - sy;
1740      if (state->m_flipscreen_y)  sy = 255 - sy;
18011741
1802      draw_bullets(machine, bitmap, cliprect, offs, sx, sy);
1742      (*state->m_draw_bullets)(machine, bitmap, cliprect, offs, sx, sy);
18031743   }
18041744}
18051745
18061746
18071747static void draw_sprites(running_machine &machine, bitmap_t *bitmap, UINT8 *spriteram, size_t spriteram_size)
18081748{
1749   galaxold_state *state = machine.driver_data<galaxold_state>();
18091750   int offs;
18101751
18111752
r11160r11161
18201761      flipx = spriteram[offs + 1] & 0x40;
18211762      flipy = spriteram[offs + 1] & 0x80;
18221763      code = spriteram[offs + 1] & 0x3f;
1823      color = spriteram[offs + 2] & color_mask;
1764      color = spriteram[offs + 2] & state->m_color_mask;
18241765
1825      if (modify_spritecode)
1766      if (state->m_modify_spritecode)
18261767      {
1827         modify_spritecode(spriteram, &code, &flipx, &flipy, offs);
1768         (*state->m_modify_spritecode)(machine, spriteram, &code, &flipx, &flipy, offs);
18281769      }
18291770
1830      if (modify_color)
1771      if (state->m_modify_color)
18311772      {
1832         modify_color(&color);
1773         (*state->m_modify_color)(&color);
18331774      }
18341775
1835      if (modify_ypos)
1776      if (state->m_modify_ypos)
18361777      {
1837         modify_ypos(&sy);
1778         (*state->m_modify_ypos)(&sy);
18381779      }
18391780
1840      if (flipscreen_x)
1781      if (state->m_flipscreen_x)
18411782      {
18421783         sx = 240 - sx;
18431784         flipx = !flipx;
18441785      }
18451786
1846      if (flipscreen_y)
1787      if (state->m_flipscreen_y)
18471788      {
18481789         flipy = !flipy;
18491790      }
r11160r11161
18611802      if (offs < 3*4)  sy++;
18621803
18631804
1864      drawgfx_transpen(bitmap,flipscreen_x ? spritevisibleareaflipx : spritevisiblearea,machine.gfx[1],
1805      drawgfx_transpen(bitmap, state->m_flipscreen_x ? &spritevisibleareaflipx : &spritevisiblearea, machine.gfx[1],
18651806            code,color,
18661807            flipx,flipy,
18671808            sx,sy,0);
r11160r11161
18711812
18721813SCREEN_UPDATE( galaxold )
18731814{
1874   draw_background(screen->machine(), bitmap, cliprect);
1815   galaxold_state *state = screen->machine().driver_data<galaxold_state>();
18751816
1817   (*state->m_draw_background)(screen->machine(), bitmap, cliprect);
18761818
1877   if (galaxold_stars_on)
1819   if (state->m_stars_on)
18781820   {
1879      draw_stars(screen->machine(), bitmap, cliprect);
1821      (*state->m_draw_stars)(screen->machine(), bitmap, cliprect);
18801822   }
18811823
18821824
1883   tilemap_draw(bitmap, 0, bg_tilemap, 0, 0);
1825   tilemap_draw(bitmap, 0, state->m_bg_tilemap, 0, 0);
18841826
1885
1886   if (draw_bullets)
1827   if (state->m_draw_bullets)
18871828   {
18881829      draw_bullets_common(screen->machine(), bitmap, cliprect);
18891830   }
18901831
18911832
1892   draw_sprites(screen->machine(), bitmap, galaxold_spriteram, galaxold_spriteram_size);
1833   draw_sprites(screen->machine(), bitmap, state->m_spriteram, state->m_spriteram_size);
18931834
1894   if (spriteram2_present)
1835   if (state->m_spriteram2_present)
18951836   {
1896      draw_sprites(screen->machine(), bitmap, galaxold_spriteram2, galaxold_spriteram2_size);
1837      draw_sprites(screen->machine(), bitmap, state->m_spriteram2, state->m_spriteram2_size);
18971838   }
18981839   return 0;
18991840}
r11160r11161
19011842
19021843SCREEN_UPDATE( dambustr )
19031844{
1845   galaxold_state *state = screen->machine().driver_data<galaxold_state>();
19041846   int i, j;
19051847   UINT8 color;
19061848
1907   draw_background(screen->machine(), bitmap, cliprect);
1849   (*state->m_draw_background)(screen->machine(), bitmap, cliprect);
19081850
1909   if (galaxold_stars_on)
1851   if (state->m_stars_on)
19101852   {
1911      draw_stars(screen->machine(), bitmap, cliprect);
1853      (*state->m_draw_stars)(screen->machine(), bitmap, cliprect);
19121854   }
19131855
19141856   /* save the background for drawing it again later, if background has priority over characters */
1915   copybitmap(dambustr_tmpbitmap, bitmap, 0, 0, 0, 0, NULL);
1857   copybitmap(state->m_dambustr_tmpbitmap, bitmap, 0, 0, 0, 0, NULL);
19161858
1917   tilemap_draw(bitmap, 0, bg_tilemap, 0, 0);
1859   tilemap_draw(bitmap, 0, state->m_bg_tilemap, 0, 0);
19181860
1919   if (draw_bullets)
1861   if (state->m_draw_bullets)
19201862   {
19211863      draw_bullets_common(screen->machine(), bitmap, cliprect);
19221864   }
19231865
1924   draw_sprites(screen->machine(), bitmap, galaxold_spriteram, galaxold_spriteram_size);
1866   draw_sprites(screen->machine(), bitmap, state->m_spriteram, state->m_spriteram_size);
19251867
1926   if (dambustr_bg_priority)
1868   if (state->m_dambustr_bg_priority)
19271869   {
19281870      /* draw the upper part of the background, as it has priority */
19291871      dambustr_draw_upper_background(screen->machine(), bitmap, cliprect);
19301872
19311873      /* only rows with color code > 3 are stronger than the background */
1932      memset(dambustr_videoram2, 0x20, 0x0400);
1874      memset(state->m_dambustr_videoram2, 0x20, 0x0400);
19331875      for (i=0; i<32; i++) {
1934         color = galaxold_attributesram[(i << 1) | 1] & color_mask;
1876         color = state->m_attributesram[(i << 1) | 1] & state->m_color_mask;
19351877         if (color > 3) {
19361878            for (j=0; j<32; j++)
1937               dambustr_videoram2[32*j+i] = galaxold_videoram[32*j+i];
1879               state->m_dambustr_videoram2[32*j+i] = state->m_videoram[32*j+i];
19381880         };
19391881      };
1940      tilemap_mark_all_tiles_dirty(dambustr_tilemap2);
1941      tilemap_draw(bitmap, 0, dambustr_tilemap2, 0, 0);
1882      tilemap_mark_all_tiles_dirty(state->m_dambustr_tilemap2);
1883      tilemap_draw(bitmap, 0, state->m_dambustr_tilemap2, 0, 0);
19421884   };
19431885
19441886   return 0;
src/mame/video/atarisy1.c
r11160r11161
55****************************************************************************/
66
77#include "emu.h"
8#include "video/atarimo.h"
89#include "includes/atarisy1.h"
910
1011
r11160r11161
348349WRITE16_HANDLER( atarisy1_spriteram_w )
349350{
350351   int active_bank = atarimo_get_bank(0);
351   int oldword = atarimo_0_spriteram[offset];
352   int oldword = atarimo_0_spriteram_r(space, offset, mem_mask);
352353   int newword = oldword;
353354   COMBINE_DATA(&newword);
354355
r11160r11161
356357   if (oldword != newword && (offset >> 8) == active_bank)
357358   {
358359      /* if modifying a timer, beware */
359      if (((offset & 0xc0) == 0x00 && atarimo_0_spriteram[offset | 0x40] == 0xffff) ||
360      if (((offset & 0xc0) == 0x00 && atarimo_0_spriteram_r(space, offset | 0x40, mem_mask) == 0xffff) ||
360361          ((offset & 0xc0) == 0x40 && (newword == 0xffff || oldword == 0xffff)))
361362      {
362363         /* if the timer is in the active bank, update the display list */
r11160r11161
434435static void update_timers(running_machine &machine, int scanline)
435436{
436437   atarisy1_state *state = machine.driver_data<atarisy1_state>();
437   UINT16 *base = &atarimo_0_spriteram[atarimo_get_bank(0) * 64 * 4];
438   address_space *space = NULL;
439   UINT16 mem_mask = 0xffff;
440   int offset = atarimo_get_bank(0) * 64 * 4;
438441   int link = 0, best = scanline, found = 0;
439442   UINT8 spritevisit[64];
440443
r11160r11161
445448   while (!spritevisit[link])
446449   {
447450      /* timers are indicated by 0xffff in entry 2 */
448      if (base[link + 0x40] == 0xffff)
451      if (atarimo_0_spriteram_r(space, offset + link + 0x40, mem_mask) == 0xffff)
449452      {
450         int data = base[link];
453         int data = atarimo_0_spriteram_r(space, offset + link, mem_mask);
451454         int vsize = (data & 15) + 1;
452455         int ypos = (256 - (data >> 5) - vsize * 8 - 1) & 0x1ff;
453456
r11160r11161
469472
470473      /* link to the next */
471474      spritevisit[link] = 1;
472      link = base[link + 0xc0] & 0x3f;
475      link = atarimo_0_spriteram_r(space, offset + link + 0xc0, mem_mask) & 0x3f;
473476   }
474477
475478   /* if nothing was found, use scanline -1 */
src/mame/video/atarig42.c
r11160r11161
215215            if (mo[x])
216216            {
217217               int pfpri = pri[x];
218               int mopri = mo[x] >> ATARIMO_PRIORITY_SHIFT;
218               int mopri = mo[x] >> ATARIRLE_PRIORITY_SHIFT;
219219               if (mopri >= pfpri)
220220                  pf[x] = mo[x] & ATARIRLE_DATA_MASK;
221221            }
src/mame/video/vindictr.c
r11160r11161
55****************************************************************************/
66
77#include "emu.h"
8#include "video/atarimo.h"
89#include "includes/vindictr.h"
910
1011
src/mame/video/atarisy2.c
r11160r11161
55****************************************************************************/
66
77#include "emu.h"
8#include "video/atarimo.h"
89#include "includes/slapstic.h"
910#include "includes/atarisy2.h"
1011
r11160r11161
9697
9798   /* initialize banked memory */
9899   state->m_alpha = &state->m_vram[0x0000];
99   atarimo_0_spriteram = &state->m_vram[0x0c00];
100100   state->m_playfield = &state->m_vram[0x2000];
101101
102102   /* initialize the playfield */
r11160r11161
264264READ16_HANDLER( atarisy2_videoram_r )
265265{
266266   atarisy2_state *state = space->machine().driver_data<atarisy2_state>();
267   return state->m_vram[offset | state->m_videobank];
267   int offs = offset | state->m_videobank;
268   if (offs >= 0xc00 && offs < 0x1000)
269   {
270      return atarimo_0_spriteram_r(space, offs - 0x0c00, mem_mask);
271   }
272
273   return state->m_vram[offs];
268274}
269275
270276
src/mame/video/batman.c
r11160r11161
55****************************************************************************/
66
77#include "emu.h"
8#include "video/atarimo.h"
89#include "includes/batman.h"
910
1011
src/mame/video/astrocde.c
r11160r11161
2626
2727/*************************************
2828 *
29 *  Global variables
30 *
31 *************************************/
32
33/* video configuration */
34UINT8 astrocade_video_config;
35UINT8 astrocade_sparkle[4];
36
37/* palette/sparkle/star */
38static UINT8 *sparklestar;
39
40/* Astrocade interrupts */
41static UINT8 interrupt_enable;
42static UINT8 interrupt_vector;
43static UINT8 interrupt_scanline;
44static UINT8 vertical_feedback;
45static UINT8 horizontal_feedback;
46
47/* Astrocade video parameters */
48static emu_timer *scanline_timer;
49static UINT8 colors[8];
50static UINT8 colorsplit;
51static UINT8 bgdata;
52static UINT8 vblank;
53static UINT8 video_mode;
54
55/* Astrocade function generator */
56static UINT8 funcgen_expand_color[2];
57static UINT8 funcgen_control;
58static UINT8 funcgen_expand_count;
59static UINT8 funcgen_rotate_count;
60static UINT8 funcgen_rotate_data[4];
61static UINT8 funcgen_shift_prev_data;
62static UINT8 funcgen_intercept;
63
64/* pattern board registers */
65static UINT16 pattern_source;
66static UINT8 pattern_mode;
67static UINT16 pattern_dest;
68static UINT8 pattern_skip;
69static UINT8 pattern_width;
70static UINT8 pattern_height;
71
72/* 16-color board registers and video RAM */
73static UINT16 *profpac_videoram;
74static UINT16 profpac_palette[16];
75static UINT8 profpac_colormap[4];
76static UINT8 profpac_intercept;
77static UINT8 profpac_vispage;
78static UINT8 profpac_readpage;
79static UINT8 profpac_readshift;
80static UINT8 profpac_writepage;
81static UINT8 profpac_writemode;
82static UINT16 profpac_writemask;
83static UINT8 profpac_vw;
84
85
86
87/*************************************
88 *
8929 *  Function prototypes
9030 *
9131 *************************************/
r11160r11161
221161
222162VIDEO_START( astrocde )
223163{
164   astrocde_state *state = machine.driver_data<astrocde_state>();
224165   /* allocate a per-scanline timer */
225   scanline_timer = machine.scheduler().timer_alloc(FUNC(scanline_callback));
226   scanline_timer->adjust(machine.primary_screen->time_until_pos(1), 1);
166   state->m_scanline_timer = machine.scheduler().timer_alloc(FUNC(scanline_callback));
167   state->m_scanline_timer->adjust(machine.primary_screen->time_until_pos(1), 1);
227168
228169   /* register for save states */
229170   init_savestate(machine);
230171
231172   /* initialize the sparkle and stars */
232   if (astrocade_video_config & AC_STARS)
173   if (state->m_video_config & AC_STARS)
233174      init_sparklestar(machine);
234175}
235176
236177
237178VIDEO_START( profpac )
238179{
180   astrocde_state *state = machine.driver_data<astrocde_state>();
239181   /* allocate a per-scanline timer */
240   scanline_timer = machine.scheduler().timer_alloc(FUNC(scanline_callback));
241   scanline_timer->adjust(machine.primary_screen->time_until_pos(1), 1);
182   state->m_scanline_timer = machine.scheduler().timer_alloc(FUNC(scanline_callback));
183   state->m_scanline_timer->adjust(machine.primary_screen->time_until_pos(1), 1);
242184
243185   /* allocate videoram */
244   profpac_videoram = auto_alloc_array(machine, UINT16, 0x4000 * 4);
186   state->m_profpac_videoram = auto_alloc_array(machine, UINT16, 0x4000 * 4);
245187
246188   /* register for save states */
247189   init_savestate(machine);
248190
249191   /* register our specific save state data */
250   state_save_register_global_pointer(machine, profpac_videoram, 0x4000 * 4);
251   state_save_register_global_array(machine, profpac_palette);
252   state_save_register_global_array(machine, profpac_colormap);
253   state_save_register_global(machine, profpac_intercept);
254   state_save_register_global(machine, profpac_vispage);
255   state_save_register_global(machine, profpac_readpage);
256   state_save_register_global(machine, profpac_readshift);
257   state_save_register_global(machine, profpac_writepage);
258   state_save_register_global(machine, profpac_writemode);
259   state_save_register_global(machine, profpac_writemask);
260   state_save_register_global(machine, profpac_vw);
192   state_save_register_global_pointer(machine, state->m_profpac_videoram, 0x4000 * 4);
193   state_save_register_global_array(machine, state->m_profpac_palette);
194   state_save_register_global_array(machine, state->m_profpac_colormap);
195   state_save_register_global(machine, state->m_profpac_intercept);
196   state_save_register_global(machine, state->m_profpac_vispage);
197   state_save_register_global(machine, state->m_profpac_readpage);
198   state_save_register_global(machine, state->m_profpac_readshift);
199   state_save_register_global(machine, state->m_profpac_writepage);
200   state_save_register_global(machine, state->m_profpac_writemode);
201   state_save_register_global(machine, state->m_profpac_writemask);
202   state_save_register_global(machine, state->m_profpac_vw);
261203}
262204
263205
264206static void init_savestate(running_machine &machine)
265207{
266   state_save_register_global_array(machine, astrocade_sparkle);
208   astrocde_state *state = machine.driver_data<astrocde_state>();
209   state_save_register_global_array(machine, state->m_sparkle);
267210
268   state_save_register_global(machine, interrupt_enable);
269   state_save_register_global(machine, interrupt_vector);
270   state_save_register_global(machine, interrupt_scanline);
271   state_save_register_global(machine, vertical_feedback);
272   state_save_register_global(machine, horizontal_feedback);
211   state_save_register_global(machine, state->m_interrupt_enabl);
212   state_save_register_global(machine, state->m_interrupt_vector);
213   state_save_register_global(machine, state->m_interrupt_scanline);
214   state_save_register_global(machine, state->m_vertical_feedback);
215   state_save_register_global(machine, state->m_horizontal_feedback);
273216
274   state_save_register_global_array(machine, colors);
275   state_save_register_global(machine, colorsplit);
276   state_save_register_global(machine, bgdata);
277   state_save_register_global(machine, vblank);
278   state_save_register_global(machine, video_mode);
217   state_save_register_global_array(machine, state->m_colors);
218   state_save_register_global(machine, state->m_colorsplit);
219   state_save_register_global(machine, state->m_bgdata);
220   state_save_register_global(machine, state->m_vblank);
221   state_save_register_global(machine, state->m_video_mode);
279222
280   state_save_register_global_array(machine, funcgen_expand_color);
281   state_save_register_global(machine, funcgen_control);
282   state_save_register_global(machine, funcgen_expand_count);
283   state_save_register_global(machine, funcgen_rotate_count);
284   state_save_register_global_array(machine, funcgen_rotate_data);
285   state_save_register_global(machine, funcgen_shift_prev_data);
286   state_save_register_global(machine, funcgen_intercept);
223   state_save_register_global_array(machine, state->m_funcgen_expand_color);
224   state_save_register_global(machine, state->m_funcgen_control);
225   state_save_register_global(machine, state->m_funcgen_expand_count);
226   state_save_register_global(machine, state->m_funcgen_rotate_count);
227   state_save_register_global_array(machine, state->m_funcgen_rotate_data);
228   state_save_register_global(machine, state->m_funcgen_shift_prev_data);
229   state_save_register_global(machine, state->m_funcgen_intercept);
287230
288   state_save_register_global(machine, pattern_source);
289   state_save_register_global(machine, pattern_mode);
290   state_save_register_global(machine, pattern_dest);
291   state_save_register_global(machine, pattern_skip);
292   state_save_register_global(machine, pattern_width);
293   state_save_register_global(machine, pattern_height);
231   state_save_register_global(machine, state->m_pattern_source);
232   state_save_register_global(machine, state->m_pattern_mode);
233   state_save_register_global(machine, state->m_pattern_dest);
234   state_save_register_global(machine, state->m_pattern_skip);
235   state_save_register_global(machine, state->m_pattern_width);
236   state_save_register_global(machine, state->m_pattern_height);
294237}
295238
296239
r11160r11161
306249   astrocde_state *state = screen->machine().driver_data<astrocde_state>();
307250   UINT8 *videoram = state->m_videoram;
308251   UINT32 sparklebase = 0;
309   const int colormask = (astrocade_video_config & AC_MONITOR_BW) ? 0 : 0x1f0;
310   int xystep = 2 - video_mode;
252   const int colormask = (state->m_video_config & AC_MONITOR_BW) ? 0 : 0x1f0;
253   int xystep = 2 - state->m_video_mode;
311254   int y;
312255
313256   /* compute the starting point of sparkle for the current frame */
314257   int width = screen->width();
315258   int height = screen->height();
316259
317   if (astrocade_video_config & AC_STARS)
260   if (state->m_video_config & AC_STARS)
318261      sparklebase = (screen->frame_number() * (UINT64)(width * height)) % RNG_PERIOD;
319262
320263   /* iterate over scanlines */
r11160r11161
327270      int x;
328271
329272      /* compute the star and sparkle offset at the start of this line */
330      if (astrocade_video_config & AC_STARS)
273      if (state->m_video_config & AC_STARS)
331274      {
332275         staroffs = ((effy < 0) ? (effy + 262) : effy) * width;
333276         sparkleoffs = sparklebase + y * width;
r11160r11161
339282      for (x = 0; x < 456/4; x += xystep)
340283      {
341284         int effx = x - HORZ_OFFSET/4;
342         const UINT8 *colorbase = &colors[(effx < colorsplit) ? 4 : 0];
285         const UINT8 *colorbase = &state->m_colors[(effx < state->m_colorsplit) ? 4 : 0];
343286         UINT8 data;
344287         int xx;
345288
346289         /* select either video data or background data */
347         data = (effx >= 0 && effx < 80 && effy >= 0 && effy < vblank) ? videoram[offset++] : bgdata;
290         data = (effx >= 0 && effx < 80 && effy >= 0 && effy < state->m_vblank) ? videoram[offset++] : state->m_bgdata;
348291
349292         /* iterate over the 4 pixels */
350293         for (xx = 0; xx < 4; xx++)
r11160r11161
355298            rgb_t color;
356299
357300            /* handle stars/sparkle */
358            if (astrocade_video_config & AC_STARS)
301            if (state->m_video_config & AC_STARS)
359302            {
360303               /* if sparkle is enabled for this pixel index and either it is non-zero or a star */
361304               /* then adjust the intensity */
362               if (astrocade_sparkle[pixdata] == 0)
305               if (state->m_sparkle[pixdata] == 0)
363306               {
364                  if (pixdata != 0 || (sparklestar[staroffs] & 0x10))
365                     luma = sparklestar[sparkleoffs] & 0x0f;
307                  if (pixdata != 0 || (state->m_sparklestar[staroffs] & 0x10))
308                     luma = state->m_sparklestar[sparkleoffs] & 0x0f;
366309                  else if (pixdata == 0)
367310                     colordata = luma = 0;
368311               }
r11160r11161
389332
390333SCREEN_UPDATE( profpac )
391334{
335   astrocde_state *state = screen->machine().driver_data<astrocde_state>();
392336   int y;
393337
394338   /* iterate over scanlines */
r11160r11161
396340   {
397341      int effy = mame_vpos_to_astrocade_vpos(y);
398342      UINT16 *dest = BITMAP_ADDR16(bitmap, y, 0);
399      UINT16 offset = profpac_vispage * 0x4000 + effy * 80;
343      UINT16 offset = state->m_profpac_vispage * 0x4000 + effy * 80;
400344      int x;
401345
402346      /* star with black */
r11160r11161
407351         int effx = x - HORZ_OFFSET/4;
408352
409353         /* select either video data or background data */
410         UINT16 data = (effx >= 0 && effx < 80 && effy >= 0 && effy < vblank) ? profpac_videoram[offset++] : 0;
354         UINT16 data = (effx >= 0 && effx < 80 && effy >= 0 && effy < state->m_vblank) ? state->m_profpac_videoram[offset++] : 0;
411355
412356         /* iterate over the 4 pixels */
413         *dest++ = profpac_palette[(data >> 12) & 0x0f];
414         *dest++ = profpac_palette[(data >> 8) & 0x0f];
415         *dest++ = profpac_palette[(data >> 4) & 0x0f];
416         *dest++ = profpac_palette[(data >> 0) & 0x0f];
357         *dest++ = state->m_profpac_palette[(data >> 12) & 0x0f];
358         *dest++ = state->m_profpac_palette[(data >> 8) & 0x0f];
359         *dest++ = state->m_profpac_palette[(data >> 4) & 0x0f];
360         *dest++ = state->m_profpac_palette[(data >> 0) & 0x0f];
417361      }
418362   }
419363
r11160r11161
436380
437381static void astrocade_trigger_lightpen(running_machine &machine, UINT8 vfeedback, UINT8 hfeedback)
438382{
383   astrocde_state *state = machine.driver_data<astrocde_state>();
439384   /* both bits 1 and 4 enable lightpen interrupts; bit 4 enables them even in horizontal */
440385   /* blanking regions; we treat them both the same here */
441   if ((interrupt_enable & 0x12) != 0)
386   if ((state->m_interrupt_enabl & 0x12) != 0)
442387   {
443388      /* bit 0 controls the interrupt mode: mode 0 means assert until acknowledged */
444      if ((interrupt_enable & 0x01) == 0)
389      if ((state->m_interrupt_enabl & 0x01) == 0)
445390      {
446         cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, interrupt_vector & 0xf0);
391         cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, state->m_interrupt_vector & 0xf0);
447392         machine.scheduler().timer_set(machine.primary_screen->time_until_pos(vfeedback), FUNC(interrupt_off));
448393      }
449394
450395      /* mode 1 means assert for 1 instruction */
451396      else
452397      {
453         cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, interrupt_vector & 0xf0);
398         cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, state->m_interrupt_vector & 0xf0);
454399         machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(1), FUNC(interrupt_off));
455400      }
456401
457402      /* latch the feedback registers */
458      vertical_feedback = vfeedback;
459      horizontal_feedback = hfeedback;
403      state->m_vertical_feedback = vfeedback;
404      state->m_horizontal_feedback = hfeedback;
460405   }
461406}
462407
r11160r11161
470415
471416static TIMER_CALLBACK( scanline_callback )
472417{
418   astrocde_state *state = machine.driver_data<astrocde_state>();
473419   int scanline = param;
474420   int astrocade_scanline = mame_vpos_to_astrocade_vpos(scanline);
475421
r11160r11161
478424      machine.primary_screen->update_partial(scanline - 1);
479425
480426   /* generate a scanline interrupt if it's time */
481   if (astrocade_scanline == interrupt_scanline && (interrupt_enable & 0x08) != 0)
427   if (astrocade_scanline == state->m_interrupt_scanline && (state->m_interrupt_enabl & 0x08) != 0)
482428   {
483429      /* bit 2 controls the interrupt mode: mode 0 means assert until acknowledged */
484      if ((interrupt_enable & 0x04) == 0)
430      if ((state->m_interrupt_enabl & 0x04) == 0)
485431      {
486         cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, interrupt_vector);
432         cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, state->m_interrupt_vector);
487433         machine.scheduler().timer_set(machine.primary_screen->time_until_vblank_end(), FUNC(interrupt_off));
488434      }
489435
490436      /* mode 1 means assert for 1 instruction */
491437      else
492438      {
493         cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, interrupt_vector);
439         cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, state->m_interrupt_vector);
494440         machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(1), FUNC(interrupt_off));
495441      }
496442   }
497443
498444   /* on some games, the horizontal drive line is conected to the lightpen interrupt */
499   else if (astrocade_video_config & AC_LIGHTPEN_INTS)
445   else if (state->m_video_config & AC_LIGHTPEN_INTS)
500446      astrocade_trigger_lightpen(machine, astrocade_scanline, 8);
501447
502448   /* advance to the next scanline */
503449   scanline++;
504450   if (scanline >= machine.primary_screen->height())
505451      scanline = 0;
506   scanline_timer->adjust(machine.primary_screen->time_until_pos(scanline), scanline);
452   state->m_scanline_timer->adjust(machine.primary_screen->time_until_pos(scanline), scanline);
507453}
508454
509455
r11160r11161
516462
517463READ8_HANDLER( astrocade_data_chip_register_r )
518464{
465   astrocde_state *state = space->machine().driver_data<astrocde_state>();
519466   UINT8 result = 0xff;
520467
521468   /* these are the core registers */
522469   switch (offset & 0xff)
523470   {
524471      case 0x08:   /* intercept feedback */
525         result = funcgen_intercept;
526         funcgen_intercept = 0;
472         result = state->m_funcgen_intercept;
473         state->m_funcgen_intercept = 0;
527474         break;
528475
529476      case 0x0e:   /* vertical feedback (from lightpen interrupt) */
530         result = vertical_feedback;
477         result = state->m_vertical_feedback;
531478         break;
532479
533480      case 0x0f:   /* horizontal feedback (from lightpen interrupt) */
534         result = horizontal_feedback;
481         result = state->m_horizontal_feedback;
535482         break;
536483
537484      case 0x10:   /* player 1 handle */
r11160r11161
589536
590537WRITE8_HANDLER( astrocade_data_chip_register_w )
591538{
539   astrocde_state *state = space->machine().driver_data<astrocde_state>();
592540   /* these are the core registers */
593541   switch (offset & 0xff)
594542   {
r11160r11161
600548      case 0x05:
601549      case 0x06:
602550      case 0x07:
603         colors[offset & 7] = data;
551         state->m_colors[offset & 7] = data;
604552         break;
605553
606554      case 0x08:   /* mode register */
607         video_mode = data & 1;
555         state->m_video_mode = data & 1;
608556         break;
609557
610558      case 0x09:   /* color split pixel */
611         colorsplit = 2 * (data & 0x3f);
612         bgdata = ((data & 0xc0) >> 6) * 0x55;
559         state->m_colorsplit = 2 * (data & 0x3f);
560         state->m_bgdata = ((data & 0xc0) >> 6) * 0x55;
613561         break;
614562
615563      case 0x0a:   /* vertical blank register */
616         vblank = data;
564         state->m_vblank = data;
617565         break;
618566
619567      case 0x0b:   /* color block transfer */
620         colors[(offset >> 8) & 7] = data;
568         state->m_colors[(offset >> 8) & 7] = data;
621569         break;
622570
623571      case 0x0c:   /* function generator */
624         funcgen_control = data;
625         funcgen_expand_count = 0;      /* reset flip-flop for expand mode on write to this register */
626         funcgen_rotate_count = 0;      /* reset counter for rotate mode on write to this register */
627         funcgen_shift_prev_data = 0;   /* reset shift buffer on write to this register */
572         state->m_funcgen_control = data;
573         state->m_funcgen_expand_count = 0;      /* reset flip-flop for expand mode on write to this register */
574         state->m_funcgen_rotate_count = 0;      /* reset counter for rotate mode on write to this register */
575         state->m_funcgen_shift_prev_data = 0;   /* reset shift buffer on write to this register */
628576         break;
629577
630578      case 0x0d:   /* interrupt feedback */
631         interrupt_vector = data;
579         state->m_interrupt_vector = data;
632580         break;
633581
634582      case 0x0e:   /* interrupt enable and mode */
635         interrupt_enable = data;
583         state->m_interrupt_enabl = data;
636584         break;
637585
638586      case 0x0f:   /* interrupt line */
639         interrupt_scanline = data;
587         state->m_interrupt_scanline = data;
640588         break;
641589
642590      case 0x10:   /* master oscillator register */
r11160r11161
648596      case 0x16:   /* tone A volume and tone B volume register */
649597      case 0x17:   /* noise volume register */
650598      case 0x18:   /* sound block transfer */
651         if (astrocade_video_config & AC_SOUND_PRESENT)
599         if (state->m_video_config & AC_SOUND_PRESENT)
652600            astrocade_sound_w(space->machine().device("astrocade1"), offset, data);
653601         break;
654602
655603      case 0x19:   /* expand register */
656         funcgen_expand_color[0] = data & 0x03;
657         funcgen_expand_color[1] = (data >> 2) & 0x03;
604         state->m_funcgen_expand_color[0] = data & 0x03;
605         state->m_funcgen_expand_color[1] = (data >> 2) & 0x03;
658606         break;
659607   }
660608}
r11160r11161
669617
670618WRITE8_HANDLER( astrocade_funcgen_w )
671619{
620   astrocde_state *state = space->machine().driver_data<astrocde_state>();
672621   UINT8 prev_data;
673622
674623   /* control register:
r11160r11161
682631    */
683632
684633   /* expansion */
685   if (funcgen_control & 0x08)
634   if (state->m_funcgen_control & 0x08)
686635   {
687      funcgen_expand_count ^= 1;
688      data >>= 4 * funcgen_expand_count;
689      data =   (funcgen_expand_color[(data >> 3) & 1] << 6) |
690            (funcgen_expand_color[(data >> 2) & 1] << 4) |
691            (funcgen_expand_color[(data >> 1) & 1] << 2) |
692            (funcgen_expand_color[(data >> 0) & 1] << 0);
636      state->m_funcgen_expand_count ^= 1;
637      data >>= 4 * state->m_funcgen_expand_count;
638      data =   (state->m_funcgen_expand_color[(data >> 3) & 1] << 6) |
639            (state->m_funcgen_expand_color[(data >> 2) & 1] << 4) |
640            (state->m_funcgen_expand_color[(data >> 1) & 1] << 2) |
641            (state->m_funcgen_expand_color[(data >> 0) & 1] << 0);
693642   }
694   prev_data = funcgen_shift_prev_data;
695   funcgen_shift_prev_data = data;
643   prev_data = state->m_funcgen_shift_prev_data;
644   state->m_funcgen_shift_prev_data = data;
696645
697646   /* rotate or shift */
698   if (funcgen_control & 0x04)
647   if (state->m_funcgen_control & 0x04)
699648   {
700649      /* rotate */
701650
702651      /* first 4 writes accumulate data for the rotate */
703      if ((funcgen_rotate_count & 4) == 0)
652      if ((state->m_funcgen_rotate_count & 4) == 0)
704653      {
705         funcgen_rotate_data[funcgen_rotate_count++ & 3] = data;
654         state->m_funcgen_rotate_data[state->m_funcgen_rotate_count++ & 3] = data;
706655         return;
707656      }
708657
709658      /* second 4 writes actually write it */
710659      else
711660      {
712         UINT8 shift = 2 * (~funcgen_rotate_count++ & 3);
713         data =   (((funcgen_rotate_data[3] >> shift) & 3) << 6) |
714               (((funcgen_rotate_data[2] >> shift) & 3) << 4) |
715               (((funcgen_rotate_data[1] >> shift) & 3) << 2) |
716               (((funcgen_rotate_data[0] >> shift) & 3) << 0);
661         UINT8 shift = 2 * (~state->m_funcgen_rotate_count++ & 3);
662         data =   (((state->m_funcgen_rotate_data[3] >> shift) & 3) << 6) |
663               (((state->m_funcgen_rotate_data[2] >> shift) & 3) << 4) |
664               (((state->m_funcgen_rotate_data[1] >> shift) & 3) << 2) |
665               (((state->m_funcgen_rotate_data[0] >> shift) & 3) << 0);
717666      }
718667   }
719668   else
720669   {
721670      /* shift */
722      UINT8 shift = 2 * (funcgen_control & 0x03);
671      UINT8 shift = 2 * (state->m_funcgen_control & 0x03);
723672      data = (data >> shift) | (prev_data << (8 - shift));
724673   }
725674
726675   /* flopping */
727   if (funcgen_control & 0x40)
676   if (state->m_funcgen_control & 0x40)
728677      data = (data >> 6) | ((data >> 2) & 0x0c) | ((data << 2) & 0x30) | (data << 6);
729678
730679   /* OR/XOR */
731   if (funcgen_control & 0x30)
680   if (state->m_funcgen_control & 0x30)
732681   {
733682      UINT8 olddata = space->read_byte(0x4000 + offset);
734683
735684      /* compute any intercepts */
736      funcgen_intercept &= 0x0f;
685      state->m_funcgen_intercept &= 0x0f;
737686      if ((olddata & 0xc0) && (data & 0xc0))
738         funcgen_intercept |= 0x11;
687         state->m_funcgen_intercept |= 0x11;
739688      if ((olddata & 0x30) && (data & 0x30))
740         funcgen_intercept |= 0x22;
689         state->m_funcgen_intercept |= 0x22;
741690      if ((olddata & 0x0c) && (data & 0x0c))
742         funcgen_intercept |= 0x44;
691         state->m_funcgen_intercept |= 0x44;
743692      if ((olddata & 0x03) && (data & 0x03))
744         funcgen_intercept |= 0x88;
693         state->m_funcgen_intercept |= 0x88;
745694
746695      /* apply the operation */
747      if (funcgen_control & 0x10)
696      if (state->m_funcgen_control & 0x10)
748697         data |= olddata;
749      else if (funcgen_control & 0x20)
698      else if (state->m_funcgen_control & 0x20)
750699         data ^= olddata;
751700   }
752701
r11160r11161
762711 *
763712 *************************************/
764713
765INLINE void increment_source(UINT8 curwidth, UINT8 *u13ff)
714INLINE void increment_source(astrocde_state *state, UINT8 curwidth, UINT8 *u13ff)
766715{
767716   /* if the flip-flop at U13 is high and mode.d2 is 1 we can increment */
768717   /* however, if mode.d3 is set and we're on the last byte of a row, the increment is suppressed */
769   if (*u13ff && (pattern_mode & 0x04) != 0 && (curwidth != 0 || (pattern_mode & 0x08) == 0))
770      pattern_source++;
718   if (*u13ff && (state->m_pattern_mode & 0x04) != 0 && (curwidth != 0 || (state->m_pattern_mode & 0x08) == 0))
719      state->m_pattern_source++;
771720
772721   /* if mode.d1 is 1, toggle the flip-flop; otherwise leave it preset */
773   if ((pattern_mode & 0x02) != 0)
722   if ((state->m_pattern_mode & 0x02) != 0)
774723      *u13ff ^= 1;
775724}
776725
777726
778INLINE void increment_dest(UINT8 curwidth)
727INLINE void increment_dest(astrocde_state *state, UINT8 curwidth)
779728{
780729   /* increment is suppressed for the last byte in a row */
781730   if (curwidth != 0)
782731   {
783732      /* if mode.d5 is 1, we increment */
784      if ((pattern_mode & 0x20) != 0)
785         pattern_dest++;
733      if ((state->m_pattern_mode & 0x20) != 0)
734         state->m_pattern_dest++;
786735
787736      /* otherwise, we decrement */
788737      else
789         pattern_dest--;
738         state->m_pattern_dest--;
790739   }
791740}
792741
793742
794743static void execute_blit(address_space *space)
795744{
745   astrocde_state *state = space->machine().driver_data<astrocde_state>();
796746   /*
797        pattern_source = counter set U7/U16/U25/U34
798        pattern_dest = counter set U9/U18/U30/U39
799        pattern_mode = latch U21
800        pattern_skip = latch set U30/U39
801        pattern_width = latch set U32/U41
802        pattern_height = counter set U31/U40
747        state->m_pattern_source = counter set U7/U16/U25/U34
748        state->m_pattern_dest = counter set U9/U18/U30/U39
749        state->m_pattern_mode = latch U21
750        state->m_pattern_skip = latch set U30/U39
751        state->m_pattern_width = latch set U32/U41
752        state->m_pattern_height = counter set U31/U40
803753
804        pattern_mode bits:
754        state->m_pattern_mode bits:
805755            d0 = direction (0 = read from src, write to dest, 1 = read from dest, write to src)
806756            d1 = expand (0 = increment src each pixel, 1 = increment src every other pixel)
807757            d2 = constant (0 = never increment src, 1 = normal src increment)
r11160r11161
815765   int cycles = 0;
816766
817767/*  logerror("Blit: src=%04X mode=%02X dest=%04X skip=%02X width=%02X height=%02X\n",
818            pattern_source, pattern_mode, pattern_dest, pattern_skip, pattern_width, pattern_height);*/
768            state->m_pattern_source, state->m_pattern_mode, state->m_pattern_dest, state->m_pattern_skip, state->m_pattern_width, state->m_pattern_height);*/
819769
820770   /* flip-flop at U13 is cleared at the beginning */
821771   u13ff = 0;
822772
823773   /* it is also forced preset if mode.d1 == 0 */
824   if ((pattern_mode & 0x02) == 0)
774   if ((state->m_pattern_mode & 0x02) == 0)
825775      u13ff = 1;
826776
827777   /* loop over height */
r11160r11161
830780      UINT16 carry;
831781
832782      /* loop over width */
833      curwidth = pattern_width;
783      curwidth = state->m_pattern_width;
834784      do
835785      {
836786         UINT16 busaddr;
r11160r11161
839789         /* ----- read phase ----- */
840790
841791         /* address is selected between source/dest based on mode.d0 */
842         busaddr = ((pattern_mode & 0x01) == 0) ? pattern_source : pattern_dest;
792         busaddr = ((state->m_pattern_mode & 0x01) == 0) ? state->m_pattern_source : state->m_pattern_dest;
843793
844794         /* if mode.d3 is set, then the last byte fetched per row is forced to 0 */
845         if (curwidth == 0 && (pattern_mode & 0x08) != 0)
795         if (curwidth == 0 && (state->m_pattern_mode & 0x08) != 0)
846796            busdata = 0;
847797         else
848798            busdata = space->read_byte(busaddr);
849799
850800         /* increment the appropriate address */
851         if ((pattern_mode & 0x01) == 0)
852            increment_source(curwidth, &u13ff);
801         if ((state->m_pattern_mode & 0x01) == 0)
802            increment_source(state, curwidth, &u13ff);
853803         else
854            increment_dest(curwidth);
804            increment_dest(state, curwidth);
855805
856806         /* ----- write phase ----- */
857807
858808         /* address is selected between source/dest based on mode.d0 */
859         busaddr = ((pattern_mode & 0x01) != 0) ? pattern_source : pattern_dest;
809         busaddr = ((state->m_pattern_mode & 0x01) != 0) ? state->m_pattern_source : state->m_pattern_dest;
860810         space->write_byte(busaddr, busdata);
861811
862812         /* increment the appropriate address */
863         if ((pattern_mode & 0x01) == 0)
864            increment_dest(curwidth);
813         if ((state->m_pattern_mode & 0x01) == 0)
814            increment_dest(state, curwidth);
865815         else
866            increment_source(curwidth, &u13ff);
816            increment_source(state, curwidth, &u13ff);
867817
868818         /* count 4 cycles (two read, two write) */
869819         cycles += 4;
r11160r11161
871821      } while (curwidth-- != 0);
872822
873823      /* at the end of each row, the skip value is added to the dest value */
874      carry = ((pattern_dest & 0xff) + pattern_skip) & 0x100;
875      pattern_dest = (pattern_dest & 0xff00) | ((pattern_dest + pattern_skip) & 0xff);
824      carry = ((state->m_pattern_dest & 0xff) + state->m_pattern_skip) & 0x100;
825      state->m_pattern_dest = (state->m_pattern_dest & 0xff00) | ((state->m_pattern_dest + state->m_pattern_skip) & 0xff);
876826
877827      /* carry behavior into the top byte is controlled by mode.d4 */
878      if ((pattern_mode & 0x10) == 0)
879         pattern_dest += carry;
828      if ((state->m_pattern_mode & 0x10) == 0)
829         state->m_pattern_dest += carry;
880830      else
881         pattern_dest -= carry ^ 0x100;
831         state->m_pattern_dest -= carry ^ 0x100;
882832
883   } while (pattern_height-- != 0);
833   } while (state->m_pattern_height-- != 0);
884834
885835   /* count cycles we ran the bus */
886836   device_adjust_icount(&space->device(), -cycles);
r11160r11161
889839
890840WRITE8_HANDLER( astrocade_pattern_board_w )
891841{
842   astrocde_state *state = space->machine().driver_data<astrocde_state>();
892843   switch (offset)
893844   {
894845      case 0:      /* source offset low 8 bits */
895         pattern_source = (pattern_source & 0xff00) | (data << 0);
846         state->m_pattern_source = (state->m_pattern_source & 0xff00) | (data << 0);
896847         break;
897848
898849      case 1:      /* source offset upper 8 bits */
899         pattern_source = (pattern_source & 0x00ff) | (data << 8);
850         state->m_pattern_source = (state->m_pattern_source & 0x00ff) | (data << 8);
900851         break;
901852
902853      case 2:      /* mode control; also clears low byte of dest */
903         pattern_mode = data & 0x3f;
904         pattern_dest &= 0xff00;
854         state->m_pattern_mode = data & 0x3f;
855         state->m_pattern_dest &= 0xff00;
905856         break;
906857
907858      case 3:      /* skip value */
908         pattern_skip = data;
859         state->m_pattern_skip = data;
909860         break;
910861
911862      case 4:      /* dest offset upper 8 bits; also adds skip to low 8 bits */
912         pattern_dest = ((pattern_dest + pattern_skip) & 0xff) | (data << 8);
863         state->m_pattern_dest = ((state->m_pattern_dest + state->m_pattern_skip) & 0xff) | (data << 8);
913864         break;
914865
915866      case 5:      /* width of blit */
916         pattern_width = data;
867         state->m_pattern_width = data;
917868         break;
918869
919870      case 6:      /* height of blit and initiator */
920         pattern_height = data;
871         state->m_pattern_height = data;
921872         execute_blit(space->device().memory().space(AS_PROGRAM));
922873         break;
923874   }
r11160r11161
962913
963914static void init_sparklestar(running_machine &machine)
964915{
916   astrocde_state *state = machine.driver_data<astrocde_state>();
965917   UINT32 shiftreg;
966918   int i;
967919
968920   /* reset global sparkle state */
969   astrocade_sparkle[0] = astrocade_sparkle[1] = astrocade_sparkle[2] = astrocade_sparkle[3] = 0;
921   state->m_sparkle[0] = state->m_sparkle[1] = state->m_sparkle[2] = state->m_sparkle[3] = 0;
970922
971923   /* allocate memory for the sparkle/star array */
972   sparklestar = auto_alloc_array(machine, UINT8, RNG_PERIOD);
924   state->m_sparklestar = auto_alloc_array(machine, UINT8, RNG_PERIOD);
973925
974926   /* generate the data for the sparkle/star array */
975927   for (shiftreg = i = 0; i < RNG_PERIOD; i++)
r11160r11161
982934
983935      /* extract the sparkle/star intensity here */
984936      /* this is controlled by the shift register at U17/U19/U18 */
985      sparklestar[i] = (((shiftreg >> 4) & 1) << 3) |
937      state->m_sparklestar[i] = (((shiftreg >> 4) & 1) << 3) |
986938                   (((shiftreg >> 12) & 1) << 2) |
987939                   (((shiftreg >> 16) & 1) << 1) |
988940                   (((shiftreg >> 8) & 1) << 0);
r11160r11161
990942      /* determine the star enable here */
991943      /* this is controlled by the shift register at U17/U12/U11 */
992944      if ((shiftreg & 0xff) == 0xfe)
993         sparklestar[i] |= 0x10;
945         state->m_sparklestar[i] |= 0x10;
994946   }
995947}
996948
r11160r11161
1004956
1005957WRITE8_HANDLER( profpac_page_select_w )
1006958{
1007   profpac_readpage = data & 3;
1008   profpac_writepage = (data >> 2) & 3;
1009   profpac_vispage = (data >> 4) & 3;
959   astrocde_state *state = space->machine().driver_data<astrocde_state>();
960   state->m_profpac_readpage = data & 3;
961   state->m_profpac_writepage = (data >> 2) & 3;
962   state->m_profpac_vispage = (data >> 4) & 3;
1010963}
1011964
1012965
1013966READ8_HANDLER( profpac_intercept_r )
1014967{
1015   return profpac_intercept;
968   astrocde_state *state = space->machine().driver_data<astrocde_state>();
969   return state->m_profpac_intercept;
1016970}
1017971
1018972
1019973WRITE8_HANDLER( profpac_screenram_ctrl_w )
1020974{
975   astrocde_state *state = space->machine().driver_data<astrocde_state>();
1021976   switch (offset)
1022977   {
1023978      case 0:      /* port 0xC0 - red component */
1024         profpac_palette[data >> 4] = (profpac_palette[data >> 4] & ~0xf00) | ((data & 0x0f) << 8);
979         state->m_profpac_palette[data >> 4] = (state->m_profpac_palette[data >> 4] & ~0xf00) | ((data & 0x0f) << 8);
1025980         break;
1026981
1027982      case 1:      /* port 0xC1 - green component */
1028         profpac_palette[data >> 4] = (profpac_palette[data >> 4] & ~0x0f0) | ((data & 0x0f) << 4);
983         state->m_profpac_palette[data >> 4] = (state->m_profpac_palette[data >> 4] & ~0x0f0) | ((data & 0x0f) << 4);
1029984         break;
1030985
1031986      case 2:      /* port 0xC2 - blue component */
1032         profpac_palette[data >> 4] = (profpac_palette[data >> 4] & ~0x00f) | ((data & 0x0f) << 0);
987         state->m_profpac_palette[data >> 4] = (state->m_profpac_palette[data >> 4] & ~0x00f) | ((data & 0x0f) << 0);
1033988         break;
1034989
1035990      case 3:      /* port 0xC3 - set 2bpp to 4bpp mapping and clear intercepts */
1036         profpac_colormap[(data >> 4) & 3] = data & 0x0f;
1037         profpac_intercept = 0x00;
991         state->m_profpac_colormap[(data >> 4) & 3] = data & 0x0f;
992         state->m_profpac_intercept = 0x00;
1038993         break;
1039994
1040995      case 4:      /* port 0xC4 - which half to read on a memory access */
1041         profpac_vw = data & 0x0f;   /* refresh write enable lines TBD */
1042         profpac_readshift = 2 * ((data >> 4) & 1);
996         state->m_profpac_vw = data & 0x0f;   /* refresh write enable lines TBD */
997         state->m_profpac_readshift = 2 * ((data >> 4) & 1);
1043998         break;
1044999
10451000      case 5:      /* port 0xC5 - write enable and write mode */
1046         profpac_writemask = ((data & 0x0f) << 12) | ((data & 0x0f) << 8) | ((data & 0x0f) << 4) | ((data & 0x0f) << 0);
1047         profpac_writemode = (data >> 4) & 0x03;
1001         state->m_profpac_writemask = ((data & 0x0f) << 12) | ((data & 0x0f) << 8) | ((data & 0x0f) << 4) | ((data & 0x0f) << 0);
1002         state->m_profpac_writemode = (data >> 4) & 0x03;
10481003         break;
10491004   }
10501005}
r11160r11161
10591014
10601015READ8_HANDLER( profpac_videoram_r )
10611016{
1062   UINT16 temp = profpac_videoram[profpac_readpage * 0x4000 + offset] >> profpac_readshift;
1017   astrocde_state *state = space->machine().driver_data<astrocde_state>();
1018   UINT16 temp = state->m_profpac_videoram[state->m_profpac_readpage * 0x4000 + offset] >> state->m_profpac_readshift;
10631019   return ((temp >> 6) & 0xc0) | ((temp >> 4) & 0x30) | ((temp >> 2) & 0x0c) | ((temp >> 0) & 0x03);
10641020}
10651021
r11160r11161
10671023/* All this information comes from decoding the PLA at U39 on the screen ram board */
10681024WRITE8_HANDLER( profpac_videoram_w )
10691025{
1070   UINT16 oldbits = profpac_videoram[profpac_writepage * 0x4000 + offset];
1026   astrocde_state *state = space->machine().driver_data<astrocde_state>();
1027   UINT16 oldbits = state->m_profpac_videoram[state->m_profpac_writepage * 0x4000 + offset];
10711028   UINT16 newbits, result = 0;
10721029
10731030   /* apply the 2->4 bit expansion first */
1074   newbits = (profpac_colormap[(data >> 6) & 3] << 12) |
1075           (profpac_colormap[(data >> 4) & 3] << 8) |
1076           (profpac_colormap[(data >> 2) & 3] << 4) |
1077           (profpac_colormap[(data >> 0) & 3] << 0);
1031   newbits = (state->m_profpac_colormap[(data >> 6) & 3] << 12) |
1032           (state->m_profpac_colormap[(data >> 4) & 3] << 8) |
1033           (state->m_profpac_colormap[(data >> 2) & 3] << 4) |
1034           (state->m_profpac_colormap[(data >> 0) & 3] << 0);
10781035
10791036   /* there are 4 write modes: overwrite, xor, overlay, or underlay */
1080   switch (profpac_writemode)
1037   switch (state->m_profpac_writemode)
10811038   {
10821039      case 0:      /* normal write */
10831040         result = newbits;
r11160r11161
11031060   }
11041061
11051062   /* apply the write mask and store */
1106   result = (result & profpac_writemask) | (oldbits & ~profpac_writemask);
1107   profpac_videoram[profpac_writepage * 0x4000 + offset] = result;
1063   result = (result & state->m_profpac_writemask) | (oldbits & ~state->m_profpac_writemask);
1064   state->m_profpac_videoram[state->m_profpac_writepage * 0x4000 + offset] = result;
11081065
11091066   /* Intercept (collision) stuff */
11101067
r11160r11161
11171074       ((oldbits & 0x00f0) == 0x0030 && (newbits & 0x00c0) == 0x0040) ||
11181075       ((oldbits & 0x000f) == 0x0002 && (newbits & 0x0008) == 0x0008) ||
11191076       ((oldbits & 0x000f) == 0x0003 && (newbits & 0x000c) == 0x0004))
1120       profpac_intercept |= 0x01;
1077       state->m_profpac_intercept |= 0x01;
11211078
11221079   if (((newbits & 0xf000) != 0x0000 && (oldbits & 0xc000) == 0x4000) ||
11231080       ((newbits & 0x0f00) != 0x0000 && (oldbits & 0x0c00) == 0x0400) ||
11241081       ((newbits & 0x00f0) != 0x0000 && (oldbits & 0x00c0) == 0x0040) ||
11251082       ((newbits & 0x000f) != 0x0000 && (oldbits & 0x000c) == 0x0004))
1126       profpac_intercept |= 0x02;
1083       state->m_profpac_intercept |= 0x02;
11271084
11281085   if (((newbits & 0xf000) != 0x0000 && (oldbits & 0x8000) == 0x8000) ||
11291086       ((newbits & 0x0f00) != 0x0000 && (oldbits & 0x0800) == 0x0800) ||
11301087       ((newbits & 0x00f0) != 0x0000 && (oldbits & 0x0080) == 0x0080) ||
11311088       ((newbits & 0x000f) != 0x0000 && (oldbits & 0x0008) == 0x0008))
1132       profpac_intercept |= 0x04;
1089       state->m_profpac_intercept |= 0x04;
11331090}
src/mame/video/blstroid.c
r11160r11161
66
77#include "emu.h"
88#include "machine/atarigen.h"
9#include "video/atarimo.h"
910#include "includes/blstroid.h"
1011
1112
src/mame/video/toobin.c
r11160r11161
66
77#include "emu.h"
88#include "machine/atarigen.h"
9#include "video/atarimo.h"
910#include "includes/toobin.h"
1011
1112
r11160r11161
207208
208209WRITE16_HANDLER( toobin_slip_w )
209210{
210   int oldslip = atarimo_0_slipram[offset];
211   int oldslip = atarimo_0_slipram_r(space, offset, mem_mask);
211212   int newslip = oldslip;
212213   COMBINE_DATA(&newslip);
213214
src/mame/video/funworld.c
r11160r11161
88
99  Games running on this hardware:
1010
11  * Jolly Card (austrian),                            TAB Austria,        1985.
11  * Jolly Card (Austrian),                            TAB Austria,        1985.
1212  * Jolly Card (3x3 deal),                            TAB Austria,        1985.
1313  * Jolly Card Professional 2.0 (MZS Tech),           MZS Tech,           1993.
1414  * Jolly Card Professional 2.0 (Spale Soft),         Spale Soft,         2000.
1515  * Jolly Card (Evona Electronic),                    Evona Electronic    1998.
16  * Jolly Card (croatian, set 1),                     TAB Austria,        1985.
17  * Jolly Card (croatian, set 2),                     Soft Design,        1993.
18  * Jolly Card (italian, blue TAB board, encrypted),  bootleg,            199?.
19  * Jolly Card (italian, encrypted bootleg),          bootleg,            1990.
16  * Jolly Card (Croatian, set 1),                     TAB Austria,        1985.
17  * Jolly Card (Croatian, set 2),                     Soft Design,        1993.
18  * Jolly Card (Italian, blue TAB board, encrypted),  bootleg,            199?.
19  * Jolly Card (Italian, encrypted bootleg),          bootleg,            1990.
2020  * Super Joly 2000 - 3x,                             M.P.                1985.
21  * Jolly Card (austrian, Funworld, bootleg),         Inter Games,        1986.
22  * Big Deal (hungarian, set 1),                      Funworld,           1986.
23  * Big Deal (hungarian, set 2),                      Funworld,           1986.
24  * Jolly Card (austrian, Funworld),                  Funworld,           1986.
25  * Cuore 1 (italian),                                C.M.C.,             1996.
26  * Elephant Family (italian, new),                   C.M.C.,             1997.
27  * Elephant Family (italian, old),                   C.M.C.,             1996.
28  * Pool 10 (italian, set 1),                         C.M.C.,             1996.
29  * Pool 10 (italian, set 2),                         C.M.C.,             1996.
30  * Pool 10 (italian, set 3),                         C.M.C.,             1996.
31  * Pool 10 (italian, set 4),                         C.M.C.,             1997.
32  * Tortuga Family (italian),                         C.M.C.,             1997.
33  * Pot Game (italian),                               C.M.C.,             1996.
34  * Bottle 10 (italian, set 1),                       C.M.C.,             1996.
35  * Bottle 10 (italian, set 2),                       C.M.C.,             1996.
36  * Royal Card (austrian, set 1),                     TAB Austria,        1991.
37  * Royal Card (austrian, set 2),                     TAB Austria,        1991.
38  * Royal Card (austrian/polish, set 3),              TAB Austria,        1991.
39  * Royal Card (austrian, set 4),                     TAB Austria,        1991.
40  * Royal Card (austrian, set 5),                     TAB Austria,        1991.
41  * Royal Card (austrian, set 6),                     TAB Austria,        1991.
21  * Jolly Card (Austrian, Funworld, bootleg),         Inter Games,        1986.
22  * Big Deal (Hungarian, set 1),                      Funworld,           1986.
23  * Big Deal (Hungarian, set 2),                      Funworld,           1986.
24  * Jolly Card (Austrian, Funworld),                  Funworld,           1986.
25  * Cuore 1 (Italian),                                C.M.C.,             1996.
26  * Elephant Family (Italian, new),                   C.M.C.,             1997.
27  * Elephant Family (Italian, old),                   C.M.C.,             1996.
28  * Pool 10 (Italian, set 1),                         C.M.C.,             1996.
29  * Pool 10 (Italian, set 2),                         C.M.C.,             1996.
30  * Pool 10 (Italian, set 3),                         C.M.C.,             1996.
31  * Pool 10 (Italian, set 4),                         C.M.C.,             1997.
32  * Tortuga Family (Italian),                         C.M.C.,             1997.
33  * Pot Game (Italian),                               C.M.C.,             1996.
34  * Bottle 10 (Italian, set 1),                       C.M.C.,             1996.
35  * Bottle 10 (Italian, set 2),                       C.M.C.,             1996.
36  * Royal Card (Austrian, set 1),                     TAB Austria,        1991.
37  * Royal Card (Austrian, set 2),                     TAB Austria,        1991.
38  * Royal Card (Austrian/Polish, set 3),              TAB Austria,        1991.
39  * Royal Card (Austrian, set 4),                     TAB Austria,        1991.
40  * Royal Card (Austrian, set 5),                     TAB Austria,        1991.
41  * Royal Card (Austrian, set 6),                     TAB Austria,        1991.
4242  * Royal Card (TAB original),                        TAB Austria,        1991.
43  * Royal Card (slovak, encrypted),                   Evona Electronic,   1991.
43  * Royal Card (Slovak, encrypted),                   Evona Electronic,   1991.
4444  * Royal Card Professional 2.0,                      Digital Dreams,     1993.
4545  * Lucky Lady (3x3 deal),                            TAB Austria,        1991.
4646  * Lucky Lady (4x1 aces),                            TAB Austria,        1991.
47  * Magic Card II (bulgarian),                        Impera,             1996.
48  * Magic Card II (green TAB or Impera board),        Impera,             1996.
49  * Magic Card II (blue TAB board, encrypted),        Impera,             1996.
50  * Royal Vegas Joker Card (slow deal),               Funworld,           1993.
51  * Royal Vegas Joker Card (fast deal),               Soft Design,        1993.
52  * Royal Vegas Joker Card (fast deal, english gfx),  Soft Design,        1993.
53  * Royal Vegas Joker Card (fast deal, Mile),         Mile,               1993.
47  * Magic Card II (Bulgarian),                        Impera,             1996.
48  * Magic Card II (Green TAB or Impera board),        Impera,             1996.
49  * Magic Card II (Blue TAB board, encrypted),        Impera,             1996.
50  * Royal Vegas Joker Card (Slow deal),               Funworld,           1993.
51  * Royal Vegas Joker Card (Fast deal),               Soft Design,        1993.
52  * Royal Vegas Joker Card (Fast deal, english gfx),  Soft Design,        1993.
53  * Royal Vegas Joker Card (Fast deal, Mile),         Mile,               1993.
5454  * Jolly Joker (98bet, set 1).                       Impera,             198?.
5555  * Jolly Joker (98bet, set 2).                       Impera,             198?.
5656  * Jolly Joker (40bet, croatian hack),               Impera,             198?.
5757  * Multi Win (Ver.0167, encrypted),                  Funworld,           1992.
5858  * Joker Card (Ver.A267BC, encrypted),               Vesely Svet,        1993.
59  * Mongolfier New (italian),                         bootleg,            199?.
60  * Soccer New (italian),                             bootleg,            199?.
61  * Saloon (french, encrypted),                       unknown,            199?.
62  * Fun World Quiz (austrian),                        Funworld,           198?.
59  * Mongolfier New (Italian),                         bootleg,            199?.
60  * Soccer New (Italian),                             bootleg,            199?.
61  * Saloon (French, encrypted),                       unknown,            199?.
62  * Fun World Quiz (Austrian),                        Funworld,           198?.
63  * Witch Royal (Export version 2.1),                 Video Klein,        199?.
6364
64
6565***********************************************************************************
6666
6767  TAB/Impera/FunWorld color system circuitry
src/mame/video/cyberbal.c
r11160r11161
66
77#include "emu.h"
88#include "machine/atarigen.h"
9#include "video/atarimo.h"
910#include "includes/cyberbal.h"
1011
1112
r11160r11161
143144   };
144145   cyberbal_state *state = machine.driver_data<cyberbal_state>();
145146
146   /* set the slip variables */
147   atarimo_0_slipram = &state->m_current_slip[0];
148   atarimo_1_slipram = &state->m_current_slip[1];
149
150147   /* initialize the playfield */
151148   state->m_playfield_tilemap = tilemap_create(machine, get_playfield_tile_info, tilemap_scan_rows,  16,8, 64,64);
152149
153150   /* initialize the motion objects */
154151   atarimo_init(machine, 0, &mo0desc);
152   atarimo_set_slipram(0, &state->m_current_slip[0]);
155153
156154   /* initialize the alphanumerics */
157155   state->m_alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows,  16,8, 64,32);
r11160r11161
166164
167165      /* initialize the motion objects */
168166      atarimo_init(machine, 1, &mo1desc);
167      atarimo_set_slipram(1, &state->m_current_slip[1]);
169168
170169      /* initialize the alphanumerics */
171170      state->m_alpha2_tilemap = tilemap_create(machine, get_alpha2_tile_info, tilemap_scan_rows,  16,8, 64,32);
src/mame/video/badlands.c
r11160r11161
55***************************************************************************/
66
77#include "emu.h"
8#include "video/atarimo.h"
89#include "includes/badlands.h"
910
1011
src/mame/video/psikyosh.c
r11160r11161
7171//#define DEBUG_KEYS
7272//#define DEBUG_MESSAGE
7373
74static UINT8 alphatable[256];   // this might be moved to psikyosh_state, if we ever add a machine parameter to drawgfxm.h macros
7574
76
7775/*-------------------------------------------------
7876    palette.h like macros
7977-------------------------------------------------*/
r11160r11161
201199      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
202200      int fixedalpha)
203201{
202   psikyosh_state *state = gfx->machine().driver_data<psikyosh_state>();
203   UINT8 *alphatable = state->m_alphatable;
204204   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
205205   const pen_t *paldata;
206206
r11160r11161
246246      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
247247      int fixedalpha)
248248{
249   psikyosh_state *state = gfx->machine().driver_data<psikyosh_state>();
250   UINT8 *alphatable = state->m_alphatable;
249251   bitmap_t *priority = NULL;   /* dummy, no priority in this case */
250252
251253   const pen_t *paldata;
r11160r11161
535537      int alpha, int zoomx, int zoomy, int wide, int high, UINT32 z)
536538{
537539   psikyosh_state *state = machine.driver_data<psikyosh_state>();
540   UINT8 *alphatable = state->m_alphatable;
538541   rectangle myclip; /* Clip to screen boundaries */
539542   int code_offset = 0;
540543   int xtile, ytile, xpixel, ypixel;
r11160r11161
12541257VIDEO_START( psikyosh )
12551258{
12561259   psikyosh_state *state = machine.driver_data<psikyosh_state>();
1260   UINT8 *alphatable = state->m_alphatable;
12571261   int width = machine.primary_screen->width();
12581262   int height = machine.primary_screen->height();
12591263
src/mame/video/offtwall.c
r11160r11161
55****************************************************************************/
66
77#include "emu.h"
8#include "video/atarimo.h"
89#include "includes/offtwall.h"
910
1011
src/mame/video/klax.c
r11160r11161
55****************************************************************************/
66
77#include "emu.h"
8#include "video/atarimo.h"
89#include "includes/klax.h"
910
1011
src/mame/video/thunderj.c
r11160r11161
66
77#include "emu.h"
88#include "machine/atarigen.h"
9#include "video/atarimo.h"
910#include "includes/thunderj.h"
1011
1112
src/mame/video/fuukifg2.c
r11160r11161
4444
4545***************************************************************************/
4646
47#define LAYER( _N_ ) \
48\
49static TILE_GET_INFO( get_tile_info_##_N_ ) \
50{ \
51   fuuki16_state *state = machine.driver_data<fuuki16_state>(); \
52   UINT16 code = state->m_vram_##_N_[2 * tile_index + 0]; \
53   UINT16 attr = state->m_vram_##_N_[2 * tile_index + 1]; \
54   SET_TILE_INFO(1 + _N_, code, attr & 0x3f, TILE_FLIPYX((attr >> 6) & 3)); \
55} \
56\
57WRITE16_HANDLER( fuuki16_vram_##_N_##_w ) \
58{ \
59   fuuki16_state *state = space->machine().driver_data<fuuki16_state>(); \
60   COMBINE_DATA(&state->m_vram_##_N_[offset]); \
61   tilemap_mark_tile_dirty(state->m_tilemap_##_N_, offset / 2); \
47INLINE void get_tile_info(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, int _N_)
48{
49   fuuki16_state *state = machine.driver_data<fuuki16_state>();
50   UINT16 code = state->m_vram[_N_][2 * tile_index + 0];
51   UINT16 attr = state->m_vram[_N_][2 * tile_index + 1];
52   SET_TILE_INFO(1 + _N_, code, attr & 0x3f, TILE_FLIPYX((attr >> 6) & 3));
6253}
6354
64LAYER( 0 )
65LAYER( 1 )
66LAYER( 2 )
67LAYER( 3 )
55static TILE_GET_INFO( get_tile_info_0 ) { get_tile_info(machine, tileinfo, tile_index, 0); }
56static TILE_GET_INFO( get_tile_info_1 ) { get_tile_info(machine, tileinfo, tile_index, 1); }
57static TILE_GET_INFO( get_tile_info_2 ) { get_tile_info(machine, tileinfo, tile_index, 2); }
58static TILE_GET_INFO( get_tile_info_3 ) { get_tile_info(machine, tileinfo, tile_index, 3); }
6859
60INLINE void fuuki16_vram_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int _N_)
61{
62   fuuki16_state *state = space->machine().driver_data<fuuki16_state>();
63   COMBINE_DATA(&state->m_vram[_N_][offset]);
64   tilemap_mark_tile_dirty(state->m_tilemap[_N_], offset / 2);
65}
6966
67WRITE16_HANDLER( fuuki16_vram_0_w ) { fuuki16_vram_w(space, offset, data, mem_mask, 0); }
68WRITE16_HANDLER( fuuki16_vram_1_w ) { fuuki16_vram_w(space, offset, data, mem_mask, 1); }
69WRITE16_HANDLER( fuuki16_vram_2_w ) { fuuki16_vram_w(space, offset, data, mem_mask, 2); }
70WRITE16_HANDLER( fuuki16_vram_3_w ) { fuuki16_vram_w(space, offset, data, mem_mask, 3); }
71
72
7073/***************************************************************************
7174
7275
r11160r11161
9194VIDEO_START( fuuki16 )
9295{
9396   fuuki16_state *state = machine.driver_data<fuuki16_state>();
94   state->m_tilemap_0 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 64, 32);
95   state->m_tilemap_1 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 64, 32);
96   state->m_tilemap_2 = tilemap_create(machine, get_tile_info_2, tilemap_scan_rows, 8, 8, 64, 32);
97   state->m_tilemap_3 = tilemap_create(machine, get_tile_info_3, tilemap_scan_rows, 8, 8, 64, 32);
97   state->m_tilemap[0] = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 64, 32);
98   state->m_tilemap[1] = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 64, 32);
99   state->m_tilemap[2] = tilemap_create(machine, get_tile_info_2, tilemap_scan_rows, 8, 8, 64, 32);
100   state->m_tilemap[3] = tilemap_create(machine, get_tile_info_3, tilemap_scan_rows, 8, 8, 64, 32);
98101
99   tilemap_set_transparent_pen(state->m_tilemap_0, 0x0f);   // 4 bits
100   tilemap_set_transparent_pen(state->m_tilemap_1, 0xff);   // 8 bits
101   tilemap_set_transparent_pen(state->m_tilemap_2, 0x0f);   // 4 bits
102   tilemap_set_transparent_pen(state->m_tilemap_3, 0x0f);   // 4 bits
102   tilemap_set_transparent_pen(state->m_tilemap[0], 0x0f);   // 4 bits
103   tilemap_set_transparent_pen(state->m_tilemap[1], 0xff);   // 8 bits
104   tilemap_set_transparent_pen(state->m_tilemap[2], 0x0f);   // 4 bits
105   tilemap_set_transparent_pen(state->m_tilemap[3], 0x0f);   // 4 bits
103106
104107   machine.gfx[2]->color_granularity = 16; /* 256 colour tiles with palette selectable on 16 colour boundaries */
105108}
r11160r11161
269272
270273   switch( i )
271274   {
272      case 2:   if (buffer)   tilemap_draw(bitmap, cliprect, state->m_tilemap_3, flag, pri);
273            else      tilemap_draw(bitmap, cliprect, state->m_tilemap_2, flag, pri);
275      case 2:   if (buffer)   tilemap_draw(bitmap, cliprect, state->m_tilemap[3], flag, pri);
276            else      tilemap_draw(bitmap, cliprect, state->m_tilemap[2], flag, pri);
274277            return;
275      case 1:   tilemap_draw(bitmap, cliprect, state->m_tilemap_1, flag, pri);
278      case 1:   tilemap_draw(bitmap, cliprect, state->m_tilemap[0], flag, pri);
276279            return;
277      case 0:   tilemap_draw(bitmap, cliprect, state->m_tilemap_0, flag, pri);
280      case 0:   tilemap_draw(bitmap, cliprect, state->m_tilemap[0], flag, pri);
278281            return;
279282   }
280283}
r11160r11161
318321   layer2_scrolly = state->m_vregs[0x8 / 2];
319322   layer2_scrollx = state->m_vregs[0xa / 2];
320323
321   tilemap_set_scrollx(state->m_tilemap_0, 0, layer0_scrollx);
322   tilemap_set_scrolly(state->m_tilemap_0, 0, layer0_scrolly);
323   tilemap_set_scrollx(state->m_tilemap_1, 0, layer1_scrollx);
324   tilemap_set_scrolly(state->m_tilemap_1, 0, layer1_scrolly);
324   tilemap_set_scrollx(state->m_tilemap[0], 0, layer0_scrollx);
325   tilemap_set_scrolly(state->m_tilemap[0], 0, layer0_scrolly);
326   tilemap_set_scrollx(state->m_tilemap[1], 0, layer1_scrollx);
327   tilemap_set_scrolly(state->m_tilemap[1], 0, layer1_scrolly);
325328
326   tilemap_set_scrollx(state->m_tilemap_2, 0, layer2_scrollx + 0x10);
327   tilemap_set_scrolly(state->m_tilemap_2, 0, layer2_scrolly /*+ 0x02*/);
328   tilemap_set_scrollx(state->m_tilemap_3, 0, layer2_scrollx + 0x10);
329   tilemap_set_scrolly(state->m_tilemap_3, 0, layer2_scrolly /*+ 0x02*/);
329   tilemap_set_scrollx(state->m_tilemap[2], 0, layer2_scrollx + 0x10);
330   tilemap_set_scrolly(state->m_tilemap[2], 0, layer2_scrolly /*+ 0x02*/);
331   tilemap_set_scrollx(state->m_tilemap[3], 0, layer2_scrollx + 0x10);
332   tilemap_set_scrolly(state->m_tilemap[3], 0, layer2_scrolly /*+ 0x02*/);
330333
331334   /* The backmost tilemap decides the background color(s) but sprites can
332335       go below the opaque pixels of that tilemap. We thus need to mark the
src/mame/video/relief.c
r11160r11161
66
77#include "emu.h"
88#include "machine/atarigen.h"
9#include "video/atarimo.h"
910#include "includes/relief.h"
1011
1112
src/mame/video/taito_f3.c
r11160r11161
257257   { PBOBBLE4,  0,     1 },
258258   { POPNPOP,   1,     1 },
259259   { LANDMAKR,  1,     1 },
260   { TMDRILL,   1,     0 },
260261   {0}
261262};
262263
r11160r11161
270271   int pri;
271272};
272273
273static void get_sprite_info(running_machine &machine, const UINT32 *spriteram32_ptr);
274static void get_sprite_info(running_machine &machine, const UINT16 *spriteram16_ptr);
274275
275276struct f3_playfield_line_inf
276277{
r11160r11161
328329static void print_debug_info(running_machine &machine, bitmap_t *bitmap)
329330{
330331   taito_f3_state *state = machine.driver_data<taito_f3_state>();
331   UINT32 *f3_line_ram = state->m_f3_line_ram;
332   UINT16 *f3_line_ram = state->m_f3_line_ram;
332333   int l[16];
333334   char buf[64*16];
334335   char *bufptr = buf;
335336
336   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->m_f3_control_0[0]>>22,(state->m_f3_control_0[0]&0xffff)>>6,state->m_f3_control_0[1]>>22,(state->m_f3_control_0[1]&0xffff)>>6);
337   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->m_f3_control_0[2]>>23,(state->m_f3_control_0[2]&0xffff)>>7,state->m_f3_control_0[3]>>23,(state->m_f3_control_0[3]&0xffff)>>7);
338   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->m_f3_control_1[0]>>16,state->m_f3_control_1[0]&0xffff,state->m_f3_control_1[1]>>16,state->m_f3_control_1[1]&0xffff);
339   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->m_f3_control_1[2]>>16,state->m_f3_control_1[2]&0xffff,state->m_f3_control_1[3]>>16,state->m_f3_control_1[3]&0xffff);
337   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->m_f3_control_0[0]>>6,state->m_f3_control_0[1]>>6,state->m_f3_control_0[2]>>6,state->m_f3_control_0[3]>>6);
338   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->m_f3_control_0[4]>>7,state->m_f3_control_0[5]>>7,state->m_f3_control_0[6]>>7,state->m_f3_control_0[7]>>7);
339   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->m_f3_control_1[0],state->m_f3_control_1[1],state->m_f3_control_1[2],state->m_f3_control_1[3]);
340   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->m_f3_control_1[4],state->m_f3_control_1[5],state->m_f3_control_1[6],state->m_f3_control_1[7]);
340341
341   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",state->m_spriteram32_buffered[0]>>16,state->m_spriteram32_buffered[0]&0xffff,state->m_spriteram32_buffered[1]>>16,state->m_spriteram32_buffered[1]&0xffff,state->m_spriteram32_buffered[2]>>16,state->m_spriteram32_buffered[2]&0xffff,state->m_spriteram32_buffered[3]>>16,state->m_spriteram32_buffered[3]&0xffff);
342   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",state->m_spriteram32_buffered[4]>>16,state->m_spriteram32_buffered[4]&0xffff,state->m_spriteram32_buffered[5]>>16,state->m_spriteram32_buffered[5]&0xffff,state->m_spriteram32_buffered[6]>>16,state->m_spriteram32_buffered[6]&0xffff,state->m_spriteram32_buffered[7]>>16,state->m_spriteram32_buffered[7]&0xffff);
343   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",state->m_spriteram32_buffered[8]>>16,state->m_spriteram32_buffered[8]&0xffff,state->m_spriteram32_buffered[9]>>16,state->m_spriteram32_buffered[9]&0xffff,state->m_spriteram32_buffered[10]>>16,state->m_spriteram32_buffered[10]&0xffff,state->m_spriteram32_buffered[11]>>16,state->m_spriteram32_buffered[11]&0xffff);
342   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",state->m_spriteram16_buffered[0],state->m_spriteram16_buffered[1],state->m_spriteram16_buffered[2],state->m_spriteram16_buffered[3],state->m_spriteram16_buffered[4],state->m_spriteram16_buffered[5],state->m_spriteram16_buffered[6],state->m_spriteram16_buffered[7]);
343   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",state->m_spriteram16_buffered[8],state->m_spriteram16_buffered[9],state->m_spriteram16_buffered[10],state->m_spriteram16_buffered[11],state->m_spriteram16_buffered[12],state->m_spriteram16_buffered[13],state->m_spriteram16_buffered[14],state->m_spriteram16_buffered[15]);
344   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",state->m_spriteram16_buffered[16],state->m_spriteram16_buffered[17],state->m_spriteram16_buffered[18],state->m_spriteram16_buffered[19],state->m_spriteram16_buffered[20],state->m_spriteram16_buffered[21],state->m_spriteram16_buffered[22],state->m_spriteram16_buffered[23]);
344345
345   l[0]=f3_line_ram[0x0040]&0xffff;
346   l[1]=f3_line_ram[0x00c0]&0xffff;
347   l[2]=f3_line_ram[0x0140]&0xffff;
348   l[3]=f3_line_ram[0x01c0]&0xffff;
346   l[0]=f3_line_ram[0x0040*2]&0xffff;
347   l[1]=f3_line_ram[0x00c0*2]&0xffff;
348   l[2]=f3_line_ram[0x0140*2]&0xffff;
349   l[3]=f3_line_ram[0x01c0*2]&0xffff;
349350   bufptr += sprintf(bufptr,"Ctr1: %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]);
350351
351   l[0]=f3_line_ram[0x0240]&0xffff;
352   l[1]=f3_line_ram[0x02c0]&0xffff;
353   l[2]=f3_line_ram[0x0340]&0xffff;
354   l[3]=f3_line_ram[0x03c0]&0xffff;
352   l[0]=f3_line_ram[0x0240*2]&0xffff;
353   l[1]=f3_line_ram[0x02c0*2]&0xffff;
354   l[2]=f3_line_ram[0x0340*2]&0xffff;
355   l[3]=f3_line_ram[0x03c0*2]&0xffff;
355356   bufptr += sprintf(bufptr,"Ctr2: %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]);
356357
357   l[0]=f3_line_ram[0x2c60]&0xffff;
358   l[1]=f3_line_ram[0x2ce0]&0xffff;
359   l[2]=f3_line_ram[0x2d60]&0xffff;
360   l[3]=f3_line_ram[0x2de0]&0xffff;
358   l[0]=f3_line_ram[0x2c60*2]&0xffff;
359   l[1]=f3_line_ram[0x2ce0*2]&0xffff;
360   l[2]=f3_line_ram[0x2d60*2]&0xffff;
361   l[3]=f3_line_ram[0x2de0*2]&0xffff;
361362   bufptr += sprintf(bufptr,"Pri : %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]);
362363
363   l[0]=f3_line_ram[0x2060]&0xffff;
364   l[1]=f3_line_ram[0x20e0]&0xffff;
365   l[2]=f3_line_ram[0x2160]&0xffff;
366   l[3]=f3_line_ram[0x21e0]&0xffff;
364   l[0]=f3_line_ram[0x2060*2]&0xffff;
365   l[1]=f3_line_ram[0x20e0*2]&0xffff;
366   l[2]=f3_line_ram[0x2160*2]&0xffff;
367   l[3]=f3_line_ram[0x21e0*2]&0xffff;
367368   bufptr += sprintf(bufptr,"Zoom: %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]);
368369
369   l[0]=f3_line_ram[0x2860]&0xffff;
370   l[1]=f3_line_ram[0x28e0]&0xffff;
371   l[2]=f3_line_ram[0x2960]&0xffff;
372   l[3]=f3_line_ram[0x29e0]&0xffff;
370   l[0]=f3_line_ram[0x2860*2]&0xffff;
371   l[1]=f3_line_ram[0x28e0*2]&0xffff;
372   l[2]=f3_line_ram[0x2960*2]&0xffff;
373   l[3]=f3_line_ram[0x29e0*2]&0xffff;
373374   bufptr += sprintf(bufptr,"Line: %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]);
374375
375   l[0]=f3_line_ram[0x1c60]&0xffff;
376   l[1]=f3_line_ram[0x1ce0]&0xffff;
377   l[2]=f3_line_ram[0x1d60]&0xffff;
378   l[3]=f3_line_ram[0x1de0]&0xffff;
376   l[0]=f3_line_ram[0x1c60*2]&0xffff;
377   l[1]=f3_line_ram[0x1ce0*2]&0xffff;
378   l[2]=f3_line_ram[0x1d60*2]&0xffff;
379   l[3]=f3_line_ram[0x1de0*2]&0xffff;
379380   bufptr += sprintf(bufptr,"Sprt: %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]);
380381
381   l[0]=f3_line_ram[0x1860]&0xffff;
382   l[1]=f3_line_ram[0x18e0]&0xffff;
383   l[2]=f3_line_ram[0x1960]&0xffff;
384   l[3]=f3_line_ram[0x19e0]&0xffff;
382   l[0]=f3_line_ram[0x1860*2]&0xffff;
383   l[1]=f3_line_ram[0x18e0*2]&0xffff;
384   l[2]=f3_line_ram[0x1960*2]&0xffff;
385   l[3]=f3_line_ram[0x19e0*2]&0xffff;
385386   bufptr += sprintf(bufptr,"Pivt: %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]);
386387
387   l[0]=f3_line_ram[0x1060]&0xffff;
388   l[1]=f3_line_ram[0x10e0]&0xffff;
389   l[2]=f3_line_ram[0x1160]&0xffff;
390   l[3]=f3_line_ram[0x11e0]&0xffff;
388   l[0]=f3_line_ram[0x1060*2]&0xffff;
389   l[1]=f3_line_ram[0x10e0*2]&0xffff;
390   l[2]=f3_line_ram[0x1160*2]&0xffff;
391   l[3]=f3_line_ram[0x11e0*2]&0xffff;
391392   bufptr += sprintf(bufptr,"Colm: %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]);
392393
393   l[0]=f3_line_ram[0x1460]&0xffff;
394   l[1]=f3_line_ram[0x14e0]&0xffff;
395   l[2]=f3_line_ram[0x1560]&0xffff;
396   l[3]=f3_line_ram[0x15e0]&0xffff;
394   l[0]=f3_line_ram[0x1460*2]&0xffff;
395   l[1]=f3_line_ram[0x14e0*2]&0xffff;
396   l[2]=f3_line_ram[0x1560*2]&0xffff;
397   l[3]=f3_line_ram[0x15e0*2]&0xffff;
397398   bufptr += sprintf(bufptr,"5000: %04x %04x %04x %04x\n",l[0],l[1],l[2],l[3]);
398399
399400   ui_draw_text(&machine.render().ui_container(), buf, 60, 40);
r11160r11161
401402
402403/******************************************************************************/
403404
404INLINE void get_tile_info(running_machine &machine, tile_data *tileinfo, int tile_index, UINT32 *gfx_base)
405INLINE void get_tile_info(running_machine &machine, tile_data *tileinfo, int tile_index, UINT16 *gfx_base)
405406{
406   UINT32 tile=gfx_base[tile_index];
407   UINT32 tile=(gfx_base[tile_index*2+0]<<16)|(gfx_base[tile_index*2+1]&0xffff);
407408   UINT8 abtype=(tile>>(16+9)) & 1;
408409   // tiles can be configured to use 4, 5, or 6 bpp data.
409410   // if tiles use more than 4bpp, the bottom bits of the color code must be masked out.
r11160r11161
443444   get_tile_info(machine,tileinfo,tile_index,state->m_f3_pf_data_4);
444445}
445446
447static TILE_GET_INFO( get_tile_info5 )
448{
449   taito_f3_state *state = machine.driver_data<taito_f3_state>();
450   get_tile_info(machine,tileinfo,tile_index,state->m_f3_pf_data_5);
451}
452
453static TILE_GET_INFO( get_tile_info6 )
454{
455   taito_f3_state *state = machine.driver_data<taito_f3_state>();
456   get_tile_info(machine,tileinfo,tile_index,state->m_f3_pf_data_6);
457}
458
459static TILE_GET_INFO( get_tile_info7 )
460{
461   taito_f3_state *state = machine.driver_data<taito_f3_state>();
462   get_tile_info(machine,tileinfo,tile_index,state->m_f3_pf_data_7);
463}
464
465static TILE_GET_INFO( get_tile_info8 )
466{
467   taito_f3_state *state = machine.driver_data<taito_f3_state>();
468   get_tile_info(machine,tileinfo,tile_index,state->m_f3_pf_data_8);
469}
470
471
446472static TILE_GET_INFO( get_tile_info_vram )
447473{
448474   taito_f3_state *state = machine.driver_data<taito_f3_state>();
449   UINT32 *videoram = state->m_videoram;
450475   int vram_tile;
451476   int flags=0;
452477
453   if (tile_index&1)
454      vram_tile = (videoram[tile_index>>1]&0xffff);
455   else
456      vram_tile = (videoram[tile_index>>1]>>16);
478   vram_tile = (state->m_videoram[tile_index]&0xffff);
457479
458480   if (vram_tile&0x0100) flags|=TILE_FLIPX;
459481   if (vram_tile&0x8000) flags|=TILE_FLIPY;
r11160r11161
468490static TILE_GET_INFO( get_tile_info_pixel )
469491{
470492   taito_f3_state *state = machine.driver_data<taito_f3_state>();
471   UINT32 *videoram = state->m_videoram;
472493   int vram_tile,col_off;
473494   int flags=0;
474   int y_offs=(state->m_f3_control_1[2]&0x1ff);
495   int y_offs=(state->m_f3_control_1[5]&0x1ff);
475496   if (state->m_flipscreen) y_offs+=0x100;
476497
477498   /* Colour is shared with VRAM layer */
r11160r11161
480501   else
481502      col_off=((tile_index%32)*0x40)+((tile_index&0xfe0)>>5);
482503
483   if (col_off&1)
484      vram_tile = (videoram[col_off>>1]&0xffff);
485   else
486      vram_tile = (videoram[col_off>>1]>>16);
504   vram_tile = (state->m_videoram[col_off]&0xffff);
487505
488506   if (vram_tile&0x0100) flags|=TILE_FLIPX;
489507   if (vram_tile&0x8000) flags|=TILE_FLIPY;
r11160r11161
504522   {
505523      if (machine.video().skip_this_frame() == 0)
506524      {
507         get_sprite_info(machine, state->m_spriteram32_buffered);
525         get_sprite_info(machine, state->m_spriteram16_buffered);
508526      }
509      memcpy(state->m_spriteram32_buffered,state->m_spriteram,state->m_spriteram_size);
527      memcpy(state->m_spriteram16_buffered,state->m_spriteram,0x10000);
510528   }
511529   else if (state->m_sprite_lag==1)
512530   {
r11160r11161
543561   state->m_tr_3b = 1;
544562
545563   state->m_spritelist=0;
546   state->m_spriteram32_buffered=0;
564   state->m_spriteram16_buffered=0;
547565   state->m_pf_line_inf=0;
548566   state->m_pri_alp_bitmap=0;
549567   state->m_tile_opaque_sp=0;
r11160r11161
559577
560578   state->m_f3_game_config=pCFG;
561579
580   state->m_f3_vram =      auto_alloc_array(machine, UINT16, 0x2000/2);
581   state->m_f3_pf_data =   auto_alloc_array(machine, UINT16, 0xc000/2);
582   state->m_videoram =     auto_alloc_array(machine, UINT16, 0x2000/2);
583   state->m_f3_line_ram =  auto_alloc_array(machine, UINT16, 0x10000/2);
584   state->m_f3_pivot_ram = auto_alloc_array(machine, UINT16, 0x10000/2);
585   state->m_spriteram =    auto_alloc_array(machine, UINT16, 0x10000/2);
586
562587   if (state->m_f3_game_config->extend) {
563588      state->m_pf1_tilemap = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,64,32);
564589      state->m_pf2_tilemap = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,16,16,64,32);
565590      state->m_pf3_tilemap = tilemap_create(machine, get_tile_info3,tilemap_scan_rows,16,16,64,32);
566591      state->m_pf4_tilemap = tilemap_create(machine, get_tile_info4,tilemap_scan_rows,16,16,64,32);
567592
568      state->m_f3_pf_data_1=state->m_f3_pf_data+0x0000;
569      state->m_f3_pf_data_2=state->m_f3_pf_data+0x0800;
570      state->m_f3_pf_data_3=state->m_f3_pf_data+0x1000;
571      state->m_f3_pf_data_4=state->m_f3_pf_data+0x1800;
593      state->m_f3_pf_data_1=state->m_f3_pf_data+(0x0000/2);
594      state->m_f3_pf_data_2=state->m_f3_pf_data+(0x2000/2);
595      state->m_f3_pf_data_3=state->m_f3_pf_data+(0x4000/2);
596      state->m_f3_pf_data_4=state->m_f3_pf_data+(0x6000/2);
572597
573598      state->m_width_mask=0x3ff;
574      state->m_twidth_mask=0x3f;
575      state->m_twidth_mask_bit=6;
599      state->m_twidth_mask=0x7f;
600      state->m_twidth_mask_bit=7;
576601
602      tilemap_set_transparent_pen(state->m_pf1_tilemap,0);
603      tilemap_set_transparent_pen(state->m_pf2_tilemap,0);
604      tilemap_set_transparent_pen(state->m_pf3_tilemap,0);
605      tilemap_set_transparent_pen(state->m_pf4_tilemap,0);
606
607
577608   } else {
578609      state->m_pf1_tilemap = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,32,32);
579610      state->m_pf2_tilemap = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,16,16,32,32);
580611      state->m_pf3_tilemap = tilemap_create(machine, get_tile_info3,tilemap_scan_rows,16,16,32,32);
581612      state->m_pf4_tilemap = tilemap_create(machine, get_tile_info4,tilemap_scan_rows,16,16,32,32);
613      state->m_pf5_tilemap = tilemap_create(machine, get_tile_info5,tilemap_scan_rows,16,16,32,32);
614      state->m_pf6_tilemap = tilemap_create(machine, get_tile_info6,tilemap_scan_rows,16,16,32,32);
615      state->m_pf7_tilemap = tilemap_create(machine, get_tile_info7,tilemap_scan_rows,16,16,32,32);
616      state->m_pf8_tilemap = tilemap_create(machine, get_tile_info8,tilemap_scan_rows,16,16,32,32);
582617
583      state->m_f3_pf_data_1=state->m_f3_pf_data+0x0000;
584      state->m_f3_pf_data_2=state->m_f3_pf_data+0x0400;
585      state->m_f3_pf_data_3=state->m_f3_pf_data+0x0800;
586      state->m_f3_pf_data_4=state->m_f3_pf_data+0x0c00;
618      state->m_f3_pf_data_1=state->m_f3_pf_data+(0x0000/2);
619      state->m_f3_pf_data_2=state->m_f3_pf_data+(0x1000/2);
620      state->m_f3_pf_data_3=state->m_f3_pf_data+(0x2000/2);
621      state->m_f3_pf_data_4=state->m_f3_pf_data+(0x3000/2);
622      state->m_f3_pf_data_5=state->m_f3_pf_data+(0x4000/2);
623      state->m_f3_pf_data_6=state->m_f3_pf_data+(0x5000/2);
624      state->m_f3_pf_data_7=state->m_f3_pf_data+(0x6000/2);
625      state->m_f3_pf_data_8=state->m_f3_pf_data+(0x7000/2);
587626
588627      state->m_width_mask=0x1ff;
589      state->m_twidth_mask=0x1f;
590      state->m_twidth_mask_bit=5;
628      state->m_twidth_mask=0x3f;
629      state->m_twidth_mask_bit=6;
630
631      tilemap_set_transparent_pen(state->m_pf1_tilemap,0);
632      tilemap_set_transparent_pen(state->m_pf2_tilemap,0);
633      tilemap_set_transparent_pen(state->m_pf3_tilemap,0);
634      tilemap_set_transparent_pen(state->m_pf4_tilemap,0);   
635      tilemap_set_transparent_pen(state->m_pf5_tilemap,0);
636      tilemap_set_transparent_pen(state->m_pf6_tilemap,0);
637      tilemap_set_transparent_pen(state->m_pf7_tilemap,0);
638      tilemap_set_transparent_pen(state->m_pf8_tilemap,0);
591639   }
592640
593   state->m_spriteram32_buffered = auto_alloc_array(machine, UINT32, 0x10000/4);
641   state->m_spriteram16_buffered = auto_alloc_array(machine, UINT16, 0x10000/2);
594642   state->m_spritelist = auto_alloc_array(machine, struct tempsprite, 0x400);
595643   state->m_sprite_end = state->m_spritelist;
596644   state->m_vram_layer = tilemap_create(machine, get_tile_info_vram,tilemap_scan_rows,8,8,64,64);
r11160r11161
601649   height = machine.primary_screen->height();
602650   state->m_pri_alp_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8 );
603651   state->m_tile_opaque_sp = auto_alloc_array(machine, UINT8, machine.gfx[2]->total_elements);
604   for (i=0; i<4; i++)
652   for (i=0; i<8; i++)
605653      state->m_tile_opaque_pf[i] = auto_alloc_array(machine, UINT8, machine.gfx[1]->total_elements);
606654
607   tilemap_set_transparent_pen(state->m_pf1_tilemap,0);
608   tilemap_set_transparent_pen(state->m_pf2_tilemap,0);
609   tilemap_set_transparent_pen(state->m_pf3_tilemap,0);
610   tilemap_set_transparent_pen(state->m_pf4_tilemap,0);
655
611656   tilemap_set_transparent_pen(state->m_vram_layer,0);
612657   tilemap_set_transparent_pen(state->m_pixel_layer,0);
613658
r11160r11161
617662   machine.gfx[2]->color_granularity=16;
618663
619664   state->m_flipscreen = 0;
620   memset(state->m_spriteram32_buffered,0,state->m_spriteram_size);
621   memset(state->m_spriteram,0,state->m_spriteram_size);
665   memset(state->m_spriteram16_buffered,0,0x10000);
666   memset(state->m_spriteram,0,0x10000);
622667
623668   state_save_register_global_array(machine, state->m_f3_control_0);
624669   state_save_register_global_array(machine, state->m_f3_control_1);
r11160r11161
690735
691736/******************************************************************************/
692737
693WRITE32_HANDLER( f3_pf_data_w )
738READ16_HANDLER( f3_pf_data_r )
694739{
695740   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
741   return state->m_f3_pf_data[offset];
742}
743
744WRITE16_HANDLER( f3_pf_data_w )
745{
746   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
696747   COMBINE_DATA(&state->m_f3_pf_data[offset]);
697748
698749   if (state->m_f3_game_config->extend) {
699      if (offset<0x800) tilemap_mark_tile_dirty(state->m_pf1_tilemap,offset-0x0000);
700      else if (offset<0x1000) tilemap_mark_tile_dirty(state->m_pf2_tilemap,offset-0x0800);
701      else if (offset<0x1800) tilemap_mark_tile_dirty(state->m_pf3_tilemap,offset-0x1000);
702      else if (offset<0x2000) tilemap_mark_tile_dirty(state->m_pf4_tilemap,offset-0x1800);
750      if       (offset<0x1000) tilemap_mark_tile_dirty(state->m_pf1_tilemap,(offset & 0xfff) >> 1);
751      else if (offset<0x2000) tilemap_mark_tile_dirty(state->m_pf2_tilemap,(offset & 0xfff) >> 1);
752      else if (offset<0x3000) tilemap_mark_tile_dirty(state->m_pf3_tilemap,(offset & 0xfff) >> 1);
753      else if (offset<0x4000) tilemap_mark_tile_dirty(state->m_pf4_tilemap,(offset & 0xfff) >> 1);
703754   } else {
704      if (offset<0x400) tilemap_mark_tile_dirty(state->m_pf1_tilemap,offset-0x0000);
705      else if (offset<0x800) tilemap_mark_tile_dirty(state->m_pf2_tilemap,offset-0x0400);
706      else if (offset<0xc00) tilemap_mark_tile_dirty(state->m_pf3_tilemap,offset-0x0800);
707      else if (offset<0x1000) tilemap_mark_tile_dirty(state->m_pf4_tilemap,offset-0xc00);
755      if       (offset<0x0800) tilemap_mark_tile_dirty(state->m_pf1_tilemap,(offset & 0x7ff) >> 1);
756      else if (offset<0x1000) tilemap_mark_tile_dirty(state->m_pf2_tilemap,(offset & 0x7ff) >> 1);
757      else if (offset<0x1800) tilemap_mark_tile_dirty(state->m_pf3_tilemap,(offset & 0x7ff) >> 1);
758      else if (offset<0x2000) tilemap_mark_tile_dirty(state->m_pf4_tilemap,(offset & 0x7ff) >> 1);
759      else if (offset<0x2800) tilemap_mark_tile_dirty(state->m_pf5_tilemap,(offset & 0x7ff) >> 1);
760      else if (offset<0x3000) tilemap_mark_tile_dirty(state->m_pf6_tilemap,(offset & 0x7ff) >> 1);
761      else if (offset<0x3800) tilemap_mark_tile_dirty(state->m_pf7_tilemap,(offset & 0x7ff) >> 1);
762      else if (offset<0x4000) tilemap_mark_tile_dirty(state->m_pf8_tilemap,(offset & 0x7ff) >> 1);
708763   }
709764}
710765
711WRITE32_HANDLER( f3_control_0_w )
766WRITE16_HANDLER( f3_control_0_w )
712767{
713768   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
714769   COMBINE_DATA(&state->m_f3_control_0[offset]);
715770}
716771
717WRITE32_HANDLER( f3_control_1_w )
772WRITE16_HANDLER( f3_control_1_w )
718773{
719774   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
720775   COMBINE_DATA(&state->m_f3_control_1[offset]);
721776}
722777
723WRITE32_HANDLER( f3_videoram_w )
778READ16_HANDLER( f3_spriteram_r )
724779{
725780   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
726   UINT32 *videoram = state->m_videoram;
781   return state->m_spriteram[offset];
782}
783
784WRITE16_HANDLER( f3_spriteram_w )
785{
786   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
787   COMBINE_DATA(&state->m_spriteram[offset]);
788}
789
790READ16_HANDLER( f3_videoram_r )
791{
792   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
793   return state->m_videoram[offset];
794}
795
796WRITE16_HANDLER( f3_videoram_w )
797{
798   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
727799   int tile,col_off;
728   COMBINE_DATA(&videoram[offset]);
800   COMBINE_DATA(&state->m_videoram[offset]);
729801
730   tilemap_mark_tile_dirty(state->m_vram_layer,offset<<1);
731   tilemap_mark_tile_dirty(state->m_vram_layer,(offset<<1)+1);
802   tilemap_mark_tile_dirty(state->m_vram_layer,offset);
803   //tilemap_mark_tile_dirty(state->m_vram_layer,offset+1);
732804
733   if (offset>0x3ff) offset-=0x400;
805   if (offset>0x7ff) offset-=0x800;
734806
735   tile=offset<<1;
807   tile=offset;
736808   col_off=((tile&0x3f)*32)+((tile&0xfc0)>>6);
737809
738810   tilemap_mark_tile_dirty(state->m_pixel_layer,col_off);
739   tilemap_mark_tile_dirty(state->m_pixel_layer,col_off+32);
811   //tilemap_mark_tile_dirty(state->m_pixel_layer,col_off+32);
740812}
741813
742WRITE32_HANDLER( f3_vram_w )
814
815READ16_HANDLER( f3_vram_r )
743816{
744817   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
818
819   return state->m_f3_vram[offset];
820}
821
822WRITE16_HANDLER( f3_vram_w )
823{
824   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
745825   COMBINE_DATA(&state->m_f3_vram[offset]);
746   gfx_element_mark_dirty(space->machine().gfx[0], offset/8);
826   gfx_element_mark_dirty(space->machine().gfx[0], offset/16);
747827}
748828
749WRITE32_HANDLER( f3_pivot_w )
829READ16_HANDLER( f3_pivot_r )
750830{
751831   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
832   return state->m_f3_pivot_ram[offset];
833}
834
835WRITE16_HANDLER( f3_pivot_w )
836{
837   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
752838   COMBINE_DATA(&state->m_f3_pivot_ram[offset]);
753   gfx_element_mark_dirty(space->machine().gfx[3], offset/8);
839   gfx_element_mark_dirty(space->machine().gfx[3], offset/16);
754840}
755841
756WRITE32_HANDLER( f3_lineram_w )
842READ16_HANDLER( f3_lineram_r )
757843{
758844   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
845   return state->m_f3_line_ram[offset];
846}
847
848WRITE16_HANDLER( f3_lineram_w )
849{
850   taito_f3_state *state = space->machine().driver_data<taito_f3_state>();
759851   /* DariusGX has an interesting bug at the start of Round D - the clearing of lineram
760852    (0xa000->0x0xa7ff) overflows into priority RAM (0xb000) and creates garbage priority
761853    values.  I'm not sure what the real machine would do with these values, and this
r11160r11161
765857   if (state->m_f3_game==DARIUSG) {
766858      if (state->m_f3_skip_this_frame)
767859         return;
768      if (offset==0xb000/4 && data==0x003f0000) {
860      if (offset==0xb000/2 && data==0x003f) {
769861         state->m_f3_skip_this_frame=1;
770862         return;
771863      }
r11160r11161
14761568                        struct f3_playfield_line_inf *line_t,
14771569                        int line,
14781570                        UINT32 x_index_fx,UINT32 y_index,
1479                        UINT32 *f3_pf_data_n)
1571                        UINT16 *f3_pf_data_n)
14801572{
14811573   taito_f3_state *state = machine.driver_data<taito_f3_state>();
1482   UINT32 *pf_base;
1574   UINT16 *pf_base;
14831575   int i,trans_all,tile_index,tile_num;
14841576   int alpha_type,alpha_mode;
14851577   int opaque_all;
r11160r11161
15071599   alpha_type=0;
15081600   for(i=0;i<tile_num;i++)
15091601   {
1510      UINT32 tile=pf_base[(tile_index)&state->m_twidth_mask];
1602      UINT32 tile=(pf_base[(tile_index*2+0)&state->m_twidth_mask]<<16)|(pf_base[(tile_index*2+1)&state->m_twidth_mask]);
15111603      UINT8  extra_planes = (tile>>(16+10)) & 3;
15121604      if(tile&0xffff)
15131605      {
r11160r11161
16921784   while(y!=y_end)
16931785   {
16941786      /* The zoom, column and row values can latch according to control ram */
1695      if (y&1)
16961787      {
1697         if (state->m_f3_line_ram[0x080+(y>>1)]&1)
1698            clip0_low=(state->m_f3_line_ram[clip_base_low/4]>> 0)&0xffff;
1699         if (state->m_f3_line_ram[0x000+(y>>1)]&4)
1700            clip0_high=(state->m_f3_line_ram[clip_base_high/4]>> 0)&0xffff;
1701         if (state->m_f3_line_ram[0x080+(y>>1)]&2)
1702            clip1_low=(state->m_f3_line_ram[(clip_base_low+0x200)/4]>> 0)&0xffff;
1788         if (state->m_f3_line_ram[0x100+(y)]&1)
1789            clip0_low=(state->m_f3_line_ram[clip_base_low/2]>> 0)&0xffff;
1790         if (state->m_f3_line_ram[0x000+(y)]&4)
1791            clip0_high=(state->m_f3_line_ram[clip_base_high/2]>> 0)&0xffff;
1792         if (state->m_f3_line_ram[0x100+(y)]&2)
1793            clip1_low=(state->m_f3_line_ram[(clip_base_low+0x200)/2]>> 0)&0xffff;
17031794
1704         if (state->m_f3_line_ram[(0x0600/4)+(y>>1)]&0x8)
1705            spri=state->m_f3_line_ram[spri_base/4]&0xffff;
1706         if (state->m_f3_line_ram[(0x0600/4)+(y>>1)]&0x4)
1707            sprite_clip=state->m_f3_line_ram[(spri_base-0x200)/4]&0xffff;
1708         if (state->m_f3_line_ram[(0x0400/4)+(y>>1)]&0x1)
1709            sprite_alpha=state->m_f3_line_ram[(spri_base-0x1600)/4]&0xffff;
1710         if (state->m_f3_line_ram[(0x0400/4)+(y>>1)]&0x2)
1711            alpha_level=state->m_f3_line_ram[(spri_base-0x1400)/4]&0xffff;
1795         if (state->m_f3_line_ram[(0x0600/2)+(y)]&0x8)
1796            spri=state->m_f3_line_ram[spri_base/2]&0xffff;
1797         if (state->m_f3_line_ram[(0x0600/2)+(y)]&0x4)
1798            sprite_clip=state->m_f3_line_ram[(spri_base-0x200)/2]&0xffff;
1799         if (state->m_f3_line_ram[(0x0400/2)+(y)]&0x1)
1800            sprite_alpha=state->m_f3_line_ram[(spri_base-0x1600)/2]&0xffff;
1801         if (state->m_f3_line_ram[(0x0400/2)+(y)]&0x2)
1802            alpha_level=state->m_f3_line_ram[(spri_base-0x1400)/2]&0xffff;
17121803      }
1713      else
1714      {
1715         if (state->m_f3_line_ram[0x080+(y>>1)]&0x10000)
1716            clip0_low=(state->m_f3_line_ram[clip_base_low/4]>>16)&0xffff;
1717         if (state->m_f3_line_ram[0x000+(y>>1)]&0x40000)
1718            clip0_high=(state->m_f3_line_ram[clip_base_high/4]>>16)&0xffff;
1719         if (state->m_f3_line_ram[0x080+(y>>1)]&0x20000)
1720            clip1_low=(state->m_f3_line_ram[(clip_base_low+0x200)/4]>>16)&0xffff;
17211804
1722         if (state->m_f3_line_ram[(0x0600/4)+(y>>1)]&0x80000)
1723            spri=state->m_f3_line_ram[spri_base/4]>>16;
1724         if (state->m_f3_line_ram[(0x0600/4)+(y>>1)]&0x40000)
1725            sprite_clip=state->m_f3_line_ram[(spri_base-0x200)/4]>>16;
1726         if (state->m_f3_line_ram[(0x0400/4)+(y>>1)]&0x10000)
1727            sprite_alpha=state->m_f3_line_ram[(spri_base-0x1600)/4]>>16;
1728         if (state->m_f3_line_ram[(0x0400/4)+(y>>1)]&0x20000)
1729            alpha_level=state->m_f3_line_ram[(spri_base-0x1400)/4]>>16;
1730      }
17311805
17321806      line_t->alpha_level[y]=alpha_level;
17331807      line_t->spri[y]=spri;
r11160r11161
17681842}
17691843
17701844/* sx and sy are 16.16 fixed point numbers */
1771static void get_line_ram_info(running_machine &machine, tilemap_t *tmap, int sx, int sy, int pos, UINT32 *f3_pf_data_n)
1845static void get_line_ram_info(running_machine &machine, tilemap_t *tmap, int sx, int sy, int pos, UINT16 *f3_pf_data_n)
17721846{
17731847   taito_f3_state *state = machine.driver_data<taito_f3_state>();
17741848   struct f3_playfield_line_inf *line_t=&state->m_pf_line_inf[pos];
r11160r11161
17821856   int colscroll=0,x_offset=0,line_zoom=0;
17831857   UINT32 _y_zoom[256];
17841858   UINT16 pri=0;
1785   int bit_select0=0x10000<<pos;
1786   int bit_select1=1<<pos;
1859   int bit_select=1<<pos;
17871860
17881861   int _colscroll[256];
17891862   UINT32 _x_offset[256];
r11160r11161
18201893   }
18211894
18221895   y=y_start;
1896
18231897   while(y!=y_end)
18241898   {
18251899      /* The zoom, column and row values can latch according to control ram */
1826      if (y&1)
18271900      {
1828         if (state->m_f3_line_ram[0x300+(y>>1)]&bit_select1)
1829            x_offset=(state->m_f3_line_ram[line_base/4]&0xffff)<<10;
1830         if (state->m_f3_line_ram[0x380+(y>>1)]&bit_select1)
1831            pri=state->m_f3_line_ram[pri_base/4]&0xffff;
1901         if (state->m_f3_line_ram[0x600+(y)]&bit_select)
1902            x_offset=(state->m_f3_line_ram[line_base/2]&0xffff)<<10;
1903         if (state->m_f3_line_ram[0x700+(y)]&bit_select)
1904            pri=state->m_f3_line_ram[pri_base/2]&0xffff;
18321905
18331906         // Zoom for playfields 1 & 3 is interleaved, as is the latch select
18341907         switch (pos)
18351908         {
18361909         case 0:
1837            if (state->m_f3_line_ram[0x200+(y>>1)]&bit_select1)
1838               line_zoom=state->m_f3_line_ram[(zoom_base+0x000)/4]&0xffff;
1910            if (state->m_f3_line_ram[0x400+(y)]&bit_select)
1911               line_zoom=state->m_f3_line_ram[(zoom_base+0x000)/2]&0xffff;
18391912            break;
18401913         case 1:
1841            if (state->m_f3_line_ram[0x200+(y>>1)]&0x2)
1842               line_zoom=((state->m_f3_line_ram[(zoom_base+0x200)/4]&0xffff)&0xff00) | (line_zoom&0x00ff);
1843            if (state->m_f3_line_ram[0x200+(y>>1)]&0x8)
1844               line_zoom=((state->m_f3_line_ram[(zoom_base+0x600)/4]&0xffff)&0x00ff) | (line_zoom&0xff00);
1914            if (state->m_f3_line_ram[0x400+(y)]&0x2)
1915               line_zoom=((state->m_f3_line_ram[(zoom_base+0x200)/2]&0xffff)&0xff00) | (line_zoom&0x00ff);
1916            if (state->m_f3_line_ram[0x400+(y)]&0x8)
1917               line_zoom=((state->m_f3_line_ram[(zoom_base+0x600)/2]&0xffff)&0x00ff) | (line_zoom&0xff00);
18451918            break;
18461919         case 2:
1847            if (state->m_f3_line_ram[0x200+(y>>1)]&bit_select1)
1848               line_zoom=state->m_f3_line_ram[(zoom_base+0x400)/4]&0xffff;
1920            if (state->m_f3_line_ram[0x400+(y)]&bit_select)
1921               line_zoom=state->m_f3_line_ram[(zoom_base+0x400)/2]&0xffff;
18491922            break;
18501923         case 3:
1851            if (state->m_f3_line_ram[0x200+(y>>1)]&0x8)
1852               line_zoom=((state->m_f3_line_ram[(zoom_base+0x600)/4]&0xffff)&0xff00) | (line_zoom&0x00ff);
1853            if (state->m_f3_line_ram[0x200+(y>>1)]&0x2)
1854               line_zoom=((state->m_f3_line_ram[(zoom_base+0x200)/4]&0xffff)&0x00ff) | (line_zoom&0xff00);
1924            if (state->m_f3_line_ram[0x400+(y)]&0x8)
1925               line_zoom=((state->m_f3_line_ram[(zoom_base+0x600)/2]&0xffff)&0xff00) | (line_zoom&0x00ff);
1926            if (state->m_f3_line_ram[0x400+(y)]&0x2)
1927               line_zoom=((state->m_f3_line_ram[(zoom_base+0x200)/2]&0xffff)&0x00ff) | (line_zoom&0xff00);
18551928            break;
18561929         default:
18571930            break;
18581931         }
18591932
18601933         // Column scroll only affects playfields 2 & 3
1861         if (pos>=2 && state->m_f3_line_ram[0x000+(y>>1)]&bit_select1)
1862            colscroll=(state->m_f3_line_ram[col_base/4]>> 0)&0x3ff;
1934         if (pos>=2 && state->m_f3_line_ram[0x000+(y)]&bit_select)
1935            colscroll=(state->m_f3_line_ram[col_base/2]>> 0)&0x3ff;
18631936      }
1864      else
1865      {
1866         if (state->m_f3_line_ram[0x300+(y>>1)]&bit_select0)
1867            x_offset=(state->m_f3_line_ram[line_base/4]&0xffff0000)>>6;
18681937
1869         if (state->m_f3_line_ram[0x380+(y>>1)]&bit_select0)
1870            pri=(state->m_f3_line_ram[pri_base/4]>>16)&0xffff;
1871
1872         // Zoom for playfields 1 & 3 is interleaved, as is the latch select
1873         switch (pos)
1874         {
1875         case 0:
1876            if (state->m_f3_line_ram[0x200+(y>>1)]&bit_select0)
1877               line_zoom=state->m_f3_line_ram[(zoom_base+0x000)/4]>>16;
1878            break;
1879         case 1:
1880            if (state->m_f3_line_ram[0x200+(y>>1)]&0x20000)
1881               line_zoom=((state->m_f3_line_ram[(zoom_base+0x200)/4]>>16)&0xff00) | (line_zoom&0x00ff);
1882            if (state->m_f3_line_ram[0x200+(y>>1)]&0x80000)
1883               line_zoom=((state->m_f3_line_ram[(zoom_base+0x600)/4]>>16)&0x00ff) | (line_zoom&0xff00);
1884            break;
1885         case 2:
1886            if (state->m_f3_line_ram[0x200+(y>>1)]&bit_select0)
1887               line_zoom=state->m_f3_line_ram[(zoom_base+0x400)/4]>>16;
1888            break;
1889         case 3:
1890            if (state->m_f3_line_ram[0x200+(y>>1)]&0x80000)
1891               line_zoom=((state->m_f3_line_ram[(zoom_base+0x600)/4]>>16)&0xff00) | (line_zoom&0x00ff);
1892            if (state->m_f3_line_ram[0x200+(y>>1)]&0x20000)
1893               line_zoom=((state->m_f3_line_ram[(zoom_base+0x200)/4]>>16)&0x00ff) | (line_zoom&0xff00);
1894            break;
1895         default:
1896            break;
1897         }
1898
1899         // Column scroll only affects playfields 2 & 3
1900         if (pos>=2 && state->m_f3_line_ram[0x000+(y>>1)]&bit_select0)
1901            colscroll=(state->m_f3_line_ram[col_base/4]>>16)&0x3ff;
1902      }
1903
19041938      if (!pri || (!state->m_flipscreen && y<24) || (state->m_flipscreen && y>231) ||
19051939         (pri&0xc000)==0xc000 || !(pri&0x2000)/**/)
19061940         line_enable=0;
r11160r11161
19141948      _colscroll[y]=colscroll;
19151949      _x_offset[y]=(x_offset&0xffff0000) - (x_offset&0x0000ffff);
19161950      _y_zoom[y] = (line_zoom&0xff) << 9;
1917
1918      /* The football games use values in the range 0x200-0x3ff where the crowd should be drawn - !?
1919
1920            Until this is understood we disable those lines (which would usually wrap and show the grass
1921            area.
1922        */
1923      if (colscroll&0x200)
1924         pri|=0x0800;
1925
1951   
19261952      /* Evaluate clipping */
19271953      if (pri&0x0800)
19281954         line_enable=0;
r11160r11161
19491975      y +=y_inc;
19501976   }
19511977
1952   /* set pixmap pointer */
1953   srcbitmap = tilemap_get_pixmap(tmap);
1954   flagsbitmap = tilemap_get_flagsmap(tmap);
19551978
1979   tilemap_t* tm = tmap;
1980
19561981   y=y_start;
19571982   while(y!=y_end)
19581983   {
19591984      UINT32 x_index_fx;
19601985      UINT32 y_index;
19611986
1987      /* The football games use values in the range 0x200-0x3ff where the crowd should be drawn - !?
1988
1989         This appears to cause it to reference outside of the normal tilemap RAM area into the unused
1990         area on the 32x32 tilemap configuration.. but exactly how isn't understood
1991
1992            Until this is understood we're creating additional tilemaps for the otherwise unused area of
1993         RAM and forcing it to look up there.
1994
1995         the crowd area still seems to 'lag' behind the pitch area however.. but these are the values
1996         in ram??
1997        */
1998      int cs = _colscroll[y];
1999     
2000      if (cs&0x200)
2001      {
2002         if (state->m_pf5_tilemap && state->m_pf6_tilemap)
2003         {
2004            if (tmap == state->m_pf3_tilemap) tmap = state->m_pf5_tilemap; // pitch -> crowd
2005            if (tmap == state->m_pf4_tilemap) tmap = state->m_pf6_tilemap; // corruption on goals -> blank (hthero94)
2006         }
2007      }
2008      else
2009      {
2010         tmap = tm;
2011      }
2012
2013      /* set pixmap pointer */
2014      srcbitmap = tilemap_get_pixmap(tmap);
2015      flagsbitmap = tilemap_get_flagsmap(tmap);
2016
19622017      if(line_t->alpha_mode[y]!=0)
19632018      {
19642019         UINT16 *src_s;
r11160r11161
20042059
20052060   UINT16 pri=0;
20062061
2007   const int vram_width_mask=0x1ff;
2062   const int vram_width_mask=0x3ff;
20082063
20092064   if (state->m_flipscreen)
20102065   {
r11160r11161
20282083   while(y!=y_end)
20292084   {
20302085      /* The zoom, column and row values can latch according to control ram */
2031      if (y&1)
20322086      {
2033         if (state->m_f3_line_ram[(0x0600/4)+(y>>1)]&0x2)
2034            pri=(state->m_f3_line_ram[pri_base/4]&0xffff);
2087         if (state->m_f3_line_ram[(0x0600/2)+(y)]&0x2)
2088            pri=(state->m_f3_line_ram[pri_base/2]&0xffff);
20352089      }
2036      else
2037      {
2038         if (state->m_f3_line_ram[(0x0600/4)+(y>>1)]&0x20000)
2039            pri=(state->m_f3_line_ram[pri_base/4]&0xffff0000)>>16;
2040      }
20412090
2091
20422092      if (!pri || (!state->m_flipscreen && y<24) || (state->m_flipscreen && y>231) ||
20432093         (pri&0xc000)==0xc000 || !(pri&0x2000)/**/)
20442094         line_enable=0;
r11160r11161
25482598
25492599INLINE void f3_drawgfx(
25502600      bitmap_t *dest_bmp,const rectangle *clip,const gfx_element *gfx,
2551      UINT32 code,
2552      UINT32 color,
2601      int code,
2602      int color,
25532603      int flipx,int flipy,
25542604      int sx,int sy,
25552605      UINT8 pri_dst)
r11160r11161
27122762
27132763INLINE void f3_drawgfxzoom(
27142764      bitmap_t *dest_bmp,const rectangle *clip,const gfx_element *gfx,
2715      UINT32 code,
2716      UINT32 color,
2765      int code,
2766      int color,
27172767      int flipx,int flipy,
27182768      int sx,int sy,
27192769      int scalex, int scaley,
r11160r11161
28462896   /*zoom##p = p##_addition << 12;*/                     \
28472897}
28482898
2849static void get_sprite_info(running_machine &machine, const UINT32 *spriteram32_ptr)
2899static void get_sprite_info(running_machine &machine, const UINT16 *spriteram16_ptr)
28502900{
28512901   taito_f3_state *state = machine.driver_data<taito_f3_state>();
28522902   const rectangle &visarea = machine.primary_screen->visible_area();
r11160r11161
28722922   //old_x=0;
28732923   y=x=0;
28742924
2875   sprite_top=0x1000;
2876   for (offs = 0; offs < sprite_top && (total_sprites < 0x400); offs += 4)
2925   sprite_top=0x2000;
2926   for (offs = 0; offs < sprite_top && (total_sprites < 0x400); offs += 8)
28772927   {
28782928      const int current_offs=offs; /* Offs can change during loop, current_offs cannot */
28792929
28802930      /* Check if the sprite list jump command bit is set */
2881      if ((spriteram32_ptr[current_offs+3]>>16) & 0x8000) {
2882         UINT32 jump = (spriteram32_ptr[current_offs+3]>>16)&0x3ff;
2931      if ((spriteram16_ptr[current_offs+6+0]) & 0x8000) {
2932         UINT32 jump = (spriteram16_ptr[current_offs+6+0])&0x3ff;
28832933
2884         UINT32 new_offs=((offs&0x2000)|((jump<<4)/4));
2934         UINT32 new_offs=((offs&0x4000)|((jump<<4)/2));
28852935         if (new_offs==offs)
28862936            break;
2887         offs=new_offs - 4;
2937         offs=new_offs - 8;
28882938      }
28892939
28902940      /* Check if special command bit is set */
2891      if (spriteram32_ptr[current_offs+1] & 0x8000) {
2892         UINT32 cntrl=(spriteram32_ptr[current_offs+2])&0xffff;
2941      if (spriteram16_ptr[current_offs+2+1] & 0x8000) {
2942         UINT32 cntrl=(spriteram16_ptr[current_offs+4+1])&0xffff;
28932943         state->m_flipscreen=cntrl&0x2000;
28942944
28952945         /*  cntrl&0x1000 = disabled?  (From F2 driver, doesn't seem used anywhere)
r11160r11161
29022952
29032953         /* Sprite bank select */
29042954         if (cntrl&1) {
2905            offs=offs|0x2000;
2906            sprite_top=sprite_top|0x2000;
2955            offs=offs|0x4000;
2956            sprite_top=sprite_top|0x4000;
29072957         }
29082958      }
29092959
29102960      /* Set global sprite scroll */
2911      if (((spriteram32_ptr[current_offs+1]>>16) & 0xf000) == 0xa000) {
2912         global_x = (spriteram32_ptr[current_offs+1]>>16) & 0xfff;
2961      if (((spriteram16_ptr[current_offs+2+0]) & 0xf000) == 0xa000) {
2962         global_x = (spriteram16_ptr[current_offs+2+0]) & 0xfff;
29132963         if (global_x >= 0x800) global_x -= 0x1000;
2914         global_y = spriteram32_ptr[current_offs+1] & 0xfff;
2964         global_y = spriteram16_ptr[current_offs+2+1] & 0xfff;
29152965         if (global_y >= 0x800) global_y -= 0x1000;
29162966      }
29172967
29182968      /* And sub-global sprite scroll */
2919      if (((spriteram32_ptr[current_offs+1]>>16) & 0xf000) == 0x5000) {
2920         subglobal_x = (spriteram32_ptr[current_offs+1]>>16) & 0xfff;
2969      if (((spriteram16_ptr[current_offs+2+0]) & 0xf000) == 0x5000) {
2970         subglobal_x = (spriteram16_ptr[current_offs+2+0]) & 0xfff;
29212971         if (subglobal_x >= 0x800) subglobal_x -= 0x1000;
2922         subglobal_y = spriteram32_ptr[current_offs+1] & 0xfff;
2972         subglobal_y = spriteram16_ptr[current_offs+2+1] & 0xfff;
29232973         if (subglobal_y >= 0x800) subglobal_y -= 0x1000;
29242974      }
29252975
2926      if (((spriteram32_ptr[current_offs+1]>>16) & 0xf000) == 0xb000) {
2927         subglobal_x = (spriteram32_ptr[current_offs+1]>>16) & 0xfff;
2976      if (((spriteram16_ptr[current_offs+2+0]) & 0xf000) == 0xb000) {
2977         subglobal_x = (spriteram16_ptr[current_offs+2+0]) & 0xfff;
29282978         if (subglobal_x >= 0x800) subglobal_x -= 0x1000;
2929         subglobal_y = spriteram32_ptr[current_offs+1] & 0xfff;
2979         subglobal_y = spriteram16_ptr[current_offs+2+1] & 0xfff;
29302980         if (subglobal_y >= 0x800) subglobal_y -= 0x1000;
29312981         global_y=subglobal_y;
29322982         global_x=subglobal_x;
29332983      }
29342984
29352985      /* A real sprite to process! */
2936      sprite = (spriteram32_ptr[current_offs]>>16) | ((spriteram32_ptr[current_offs+2]&1)<<16);
2937      spritecont = spriteram32_ptr[current_offs+2]>>24;
2986      sprite = (spriteram16_ptr[current_offs+0+0]) | ((spriteram16_ptr[current_offs+4+1]&1)<<16);
2987      spritecont = spriteram16_ptr[current_offs+4+0]>>8;
29382988
29392989/* These games either don't set the XY control bits properly (68020 bug?), or
29402990    have some different mode from the others */
r11160r11161
29472997      if (multi) {
29482998         /* Bit 0x4 is 'use previous colour' for this block part */
29492999         if (spritecont&0x4) color=last_color;
2950         else color=(spriteram32_ptr[current_offs+2]>>16)&0xff;
3000         else color=(spriteram16_ptr[current_offs+4+0])&0xff;
29513001
29523002#ifdef DARIUSG_KLUDGE
29533003         if (state->m_f3_game==DARIUSG || state->m_f3_game==GEKIRIDO || state->m_f3_game==CLEOPATR || state->m_f3_game==RECALH) {
r11160r11161
29563006               if (spritecont & 0x4) {
29573007                  x = block_x;
29583008               } else {
2959                  this_x = spriteram32_ptr[current_offs+1]>>16;
3009                  this_x = spriteram16_ptr[current_offs+2+0];
29603010                  if (this_x&0x800) this_x= 0 - (0x800 - (this_x&0x7ff)); else this_x&=0x7ff;
29613011
2962                  if ((spriteram32_ptr[current_offs+1]>>16)&0x8000) {
3012                  if ((spriteram16_ptr[current_offs+2+0])&0x8000) {
29633013                     this_x+=0;
2964                  } else if ((spriteram32_ptr[current_offs+1]>>16)&0x4000) {
3014                  } else if ((spriteram16_ptr[current_offs+2+0])&0x4000) {
29653015                     /* Ignore subglobal (but apply global) */
29663016                     this_x+=global_x;
29673017                  } else { /* Apply both scroll offsets */
r11160r11161
29833033               if (spritecont & 0x4) {
29843034                  y = block_y;
29853035               } else {
2986                  this_y = spriteram32_ptr[current_offs+1]&0xffff;
3036                  this_y = spriteram16_ptr[current_offs+2+1]&0xffff;
29873037                  if (this_y&0x800) this_y= 0 - (0x800 - (this_y&0x7ff)); else this_y&=0x7ff;
29883038
2989                  if ((spriteram32_ptr[current_offs+1]>>16)&0x8000) {
3039                  if ((spriteram16_ptr[current_offs+2+0])&0x8000) {
29903040                     this_y+=0;
2991                  } else if ((spriteram32_ptr[current_offs+1]>>16)&0x4000) {
3041                  } else if ((spriteram16_ptr[current_offs+2+0])&0x4000) {
29923042                     /* Ignore subglobal (but apply global) */
29933043                     this_y+=global_y;
29943044                  } else { /* Apply both scroll offsets */
r11160r11161
30323082      }
30333083      /* Else this sprite is the possible start of a block */
30343084      else {
3035         color = (spriteram32_ptr[current_offs+2]>>16)&0xff;
3085         color = (spriteram16_ptr[current_offs+4+0])&0xff;
30363086         last_color=color;
30373087
30383088         /* Sprite positioning */
3039         this_y = spriteram32_ptr[current_offs+1]&0xffff;
3040         this_x = spriteram32_ptr[current_offs+1]>>16;
3089         this_y = spriteram16_ptr[current_offs+2+1]&0xffff;
3090         this_x = spriteram16_ptr[current_offs+2+0]&0xffff;
30413091         if (this_y&0x800) this_y= 0 - (0x800 - (this_y&0x7ff)); else this_y&=0x7ff;
30423092         if (this_x&0x800) this_x= 0 - (0x800 - (this_x&0x7ff)); else this_x&=0x7ff;
30433093
30443094         /* Ignore both scroll offsets for this block */
3045         if ((spriteram32_ptr[current_offs+1]>>16)&0x8000) {
3095         if ((spriteram16_ptr[current_offs+2+0])&0x8000) {
30463096            this_x+=0;
30473097            this_y+=0;
3048         } else if ((spriteram32_ptr[current_offs+1]>>16)&0x4000) {
3098         } else if ((spriteram16_ptr[current_offs+2+0])&0x4000) {
30493099            /* Ignore subglobal (but apply global) */
30503100            this_x+=global_x;
30513101            this_y+=global_y;
r11160r11161
30573107           block_y = y = this_y;
30583108            block_x = x = this_x;
30593109
3060         block_zoom_x=spriteram32_ptr[current_offs];
3110         block_zoom_x=spriteram16_ptr[current_offs+0+1];
30613111         block_zoom_y=(block_zoom_x>>8)&0xff;
30623112         block_zoom_x&=0xff;
30633113
r11160r11161
31653215   tilemap_set_flip_all(screen->machine(),state->m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
31663216
31673217   /* Setup scroll */
3168   sy_fix[0]=((state->m_f3_control_0[2]&0xffff0000)>> 7) + (1<<16);
3169   sy_fix[1]=((state->m_f3_control_0[2]&0x0000ffff)<< 9) + (1<<16);
3170   sy_fix[2]=((state->m_f3_control_0[3]&0xffff0000)>> 7) + (1<<16);
3171   sy_fix[3]=((state->m_f3_control_0[3]&0x0000ffff)<< 9) + (1<<16);
3172   sx_fix[0]=((state->m_f3_control_0[0]&0xffc00000)>> 6) - (6<<16);
3173   sx_fix[1]=((state->m_f3_control_0[0]&0x0000ffc0)<<10) - (10<<16);
3174   sx_fix[2]=((state->m_f3_control_0[1]&0xffc00000)>> 6) - (14<<16);
3175   sx_fix[3]=((state->m_f3_control_0[1]&0x0000ffc0)<<10) - (18<<16);
3176   sx_fix[4]=-(state->m_f3_control_1[2]>>16)+41;
3177   sy_fix[4]=-(state->m_f3_control_1[2]&0x1ff);
3218   sy_fix[0]=((state->m_f3_control_0[4]&0xffff)<< 9) + (1<<16);
3219   sy_fix[1]=((state->m_f3_control_0[5]&0xffff)<< 9) + (1<<16);
3220   sy_fix[2]=((state->m_f3_control_0[6]&0xffff)<< 9) + (1<<16);
3221   sy_fix[3]=((state->m_f3_control_0[7]&0xffff)<< 9) + (1<<16);
3222   sx_fix[0]=((state->m_f3_control_0[0]&0xffc0)<<10) - (6<<16);
3223   sx_fix[1]=((state->m_f3_control_0[1]&0xffc0)<<10) - (10<<16);
3224   sx_fix[2]=((state->m_f3_control_0[2]&0xffc0)<<10) - (14<<16);
3225   sx_fix[3]=((state->m_f3_control_0[3]&0xffc0)<<10) - (18<<16);
3226   sx_fix[4]=-(state->m_f3_control_1[4])+41;
3227   sy_fix[4]=-(state->m_f3_control_1[5]&0x1ff);
31783228
3179   sx_fix[0]-=((state->m_f3_control_0[0]&0x003f0000)>> 6)+0x0400-0x10000;
3180   sx_fix[1]-=((state->m_f3_control_0[0]&0x0000003f)<<10)+0x0400-0x10000;
3181   sx_fix[2]-=((state->m_f3_control_0[1]&0x003f0000)>> 6)+0x0400-0x10000;
3182   sx_fix[3]-=((state->m_f3_control_0[1]&0x0000003f)<<10)+0x0400-0x10000;
3229   sx_fix[0]-=((state->m_f3_control_0[0]&0x003f)<<10)+0x0400-0x10000;
3230   sx_fix[1]-=((state->m_f3_control_0[1]&0x003f)<<10)+0x0400-0x10000;
3231   sx_fix[2]-=((state->m_f3_control_0[2]&0x003f)<<10)+0x0400-0x10000;
3232   sx_fix[3]-=((state->m_f3_control_0[3]&0x003f)<<10)+0x0400-0x10000;
31833233
31843234   if (state->m_flipscreen)
31853235   {
src/mame/video/cave.c
r11160r11161
225225
226226***************************************************************************/
227227
228INLINE void get_tile_info( running_machine &machine, tile_data *tileinfo, int tile_index, int GFX, UINT16 *VRAM, int TDIM )
228INLINE void get_tile_info( running_machine &machine, tile_data *tileinfo, int tile_index, int GFX )
229229{
230   cave_state *state = machine.driver_data<cave_state>();
231   UINT16 *VRAM = state->m_vram[GFX];
232   int TDIM = state->m_tiledim[GFX];
230233   UINT32 code, color, pri, tile;
231234
232235   if (TDIM)
r11160r11161
263266   if (state->m_sailormn_tilebank != bank)
264267   {
265268      state->m_sailormn_tilebank = bank;
266      tilemap_mark_all_tiles_dirty(state->m_tilemap_2);
269      tilemap_mark_all_tiles_dirty(state->m_tilemap[2]);
267270   }
268271}
269272
r11160r11161
272275   cave_state *state = machine.driver_data<cave_state>();
273276   UINT32 code, color, pri;
274277
275   if (state->m_tiledim_2)
278   if (state->m_tiledim[2])
276279   {
277280      UINT32 tile;
278281      tile  = (tile_index % (512 / 8)) / 2 + ((tile_index / (512 / 8)) / 2) * (512 / 16);
279      code  = (state->m_vram_2[tile * 2 + 0x0000 / 2] << 16) + state->m_vram_2[tile * 2 + 0x0002 / 2];
282      code  = (state->m_vram[2][tile * 2 + 0x0000 / 2] << 16) + state->m_vram[2][tile * 2 + 0x0002 / 2];
280283
281284      color = (code & 0x3f000000) >> (32 - 8);
282285      pri   = (code & 0xc0000000) >> (32 - 2);
r11160r11161
287290   }
288291   else
289292   {
290      code  = (state->m_vram_2[tile_index * 2 + 0x4000 / 2] << 16) + state->m_vram_2[tile_index * 2 + 0x4002 / 2];
293      code  = (state->m_vram[2][tile_index * 2 + 0x4000 / 2] << 16) + state->m_vram[2][tile_index * 2 + 0x4002 / 2];
291294
292295      color = (code & 0x3f000000) >> (32 - 8);
293296      pri   = (code & 0xc0000000) >> (32 - 2);
r11160r11161
301304}
302305
303306
304INLINE void vram_w( UINT16 *VRAM, tilemap_t *TILEMAP, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask )
307INLINE void vram_w( address_space *space, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask, int GFX )
305308{
309   cave_state *state = space->machine().driver_data<cave_state>();
310   UINT16 *VRAM = state->m_vram[GFX];
311   tilemap_t *TILEMAP = state->m_tilemap[GFX];
312
306313   if ((VRAM[offset] & mem_mask) == (data & mem_mask))
307         return;
314      return;
308315
309316   COMBINE_DATA(&VRAM[offset]);
310317   offset /= 2;
r11160r11161
325332    and 408000-407fff both go to the 8x8 tilemap ram. Use this function
326333    in this cases. Note that the get_tile_info function looks in the
327334    4000-7fff range for tiles, so we have to write the data there. */
328INLINE void vram_8x8_w( UINT16 *VRAM, tilemap_t *TILEMAP, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask )
335INLINE void vram_8x8_w( address_space *space, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask, int GFX )
329336{
337   cave_state *state = space->machine().driver_data<cave_state>();
338   UINT16 *VRAM = state->m_vram[GFX];
339   tilemap_t *TILEMAP = state->m_tilemap[GFX];
340
330341   offset %= 0x4000 / 2;
331342   if ((VRAM[offset] & mem_mask) == (data & mem_mask))
332343      return;
r11160r11161
337348}
338349
339350
340static TILE_GET_INFO( get_tile_info_0 )   { cave_state *state = machine.driver_data<cave_state>(); get_tile_info(machine, tileinfo, tile_index, 0, state->m_vram_0, state->m_tiledim_0); }
341static TILE_GET_INFO( get_tile_info_1 )   { cave_state *state = machine.driver_data<cave_state>(); get_tile_info(machine, tileinfo, tile_index, 1, state->m_vram_1, state->m_tiledim_1); }
342static TILE_GET_INFO( get_tile_info_2 )   { cave_state *state = machine.driver_data<cave_state>(); get_tile_info(machine, tileinfo, tile_index, 2, state->m_vram_2, state->m_tiledim_2); }
343static TILE_GET_INFO( get_tile_info_3 )   { cave_state *state = machine.driver_data<cave_state>(); get_tile_info(machine, tileinfo, tile_index, 3, state->m_vram_3, state->m_tiledim_3); }
351static TILE_GET_INFO( get_tile_info_0 )   { get_tile_info(machine, tileinfo, tile_index, 0); }
352static TILE_GET_INFO( get_tile_info_1 )   { get_tile_info(machine, tileinfo, tile_index, 1); }
353static TILE_GET_INFO( get_tile_info_2 )   { get_tile_info(machine, tileinfo, tile_index, 2); }
354static TILE_GET_INFO( get_tile_info_3 )   { get_tile_info(machine, tileinfo, tile_index, 3); }
344355
345WRITE16_HANDLER( cave_vram_0_w )
346{
347   cave_state *state = space->machine().driver_data<cave_state>();
348   vram_w(state->m_vram_0, state->m_tilemap_0, offset, data, mem_mask);
349}
356WRITE16_HANDLER( cave_vram_0_w ) { vram_w(space, offset, data, mem_mask, 0); }
357WRITE16_HANDLER( cave_vram_1_w ) { vram_w(space, offset, data, mem_mask, 1); }
358WRITE16_HANDLER( cave_vram_2_w ) { vram_w(space, offset, data, mem_mask, 2); }
359WRITE16_HANDLER( cave_vram_3_w ) { vram_w(space, offset, data, mem_mask, 3); }
350360
351WRITE16_HANDLER( cave_vram_0_8x8_w )
352{
353   cave_state *state = space->machine().driver_data<cave_state>();
354   vram_8x8_w(state->m_vram_0, state->m_tilemap_0, offset, data, mem_mask);
355}
361WRITE16_HANDLER( cave_vram_0_8x8_w ) { vram_8x8_w(space, offset, data, mem_mask, 0); }
362WRITE16_HANDLER( cave_vram_1_8x8_w ) { vram_8x8_w(space, offset, data, mem_mask, 1); }
363WRITE16_HANDLER( cave_vram_2_8x8_w ) { vram_8x8_w(space, offset, data, mem_mask, 2); }
364WRITE16_HANDLER( cave_vram_3_8x8_w ) { vram_8x8_w(space, offset, data, mem_mask, 3); }
356365
357WRITE16_HANDLER( cave_vram_1_w )
358{
359   cave_state *state = space->machine().driver_data<cave_state>();
360   vram_w(state->m_vram_1, state->m_tilemap_1, offset, data, mem_mask);
361}
362366
363WRITE16_HANDLER( cave_vram_1_8x8_w )
364{
365   cave_state *state = space->machine().driver_data<cave_state>();
366   vram_8x8_w(state->m_vram_1, state->m_tilemap_1, offset, data, mem_mask);
367}
368
369WRITE16_HANDLER( cave_vram_2_w )
370{
371   cave_state *state = space->machine().driver_data<cave_state>();
372   vram_w(state->m_vram_2, state->m_tilemap_2, offset, data, mem_mask);
373}
374
375WRITE16_HANDLER( cave_vram_2_8x8_w )
376{
377   cave_state *state = space->machine().driver_data<cave_state>();
378   vram_8x8_w(state->m_vram_2, state->m_tilemap_2, offset, data, mem_mask);
379}
380
381WRITE16_HANDLER( cave_vram_3_w )
382{
383   cave_state *state = space->machine().driver_data<cave_state>();
384   vram_w(state->m_vram_3, state->m_tilemap_3, offset, data, mem_mask);
385}
386
387WRITE16_HANDLER( cave_vram_3_8x8_w )
388{
389   cave_state *state = space->machine().driver_data<cave_state>();
390   vram_8x8_w(state->m_vram_3, state->m_tilemap_3, offset, data, mem_mask);
391}
392
393
394367/***************************************************************************
395368
396369                            Video Init Routines
r11160r11161
406379
407380   assert(state->m_palette_map != NULL);
408381
409   state->m_tilemap_0 = 0;
410   state->m_tilemap_1 = 0;
411   state->m_tilemap_2 = 0;
412   state->m_tilemap_3 = 0;
382   state->m_tilemap[0] = 0;
383   state->m_tilemap[1] = 0;
384   state->m_tilemap[2] = 0;
385   state->m_tilemap[3] = 0;
413386
414   state->m_tiledim_0 = 0;
415   state->m_tiledim_1 = 0;
416   state->m_tiledim_2 = 0;
417   state->m_tiledim_3 = 0;
387   state->m_tiledim[0] = 0;
388   state->m_tiledim[1] = 0;
389   state->m_tiledim[2] = 0;
390   state->m_tiledim[3] = 0;
418391
419   state->m_old_tiledim_0 = 0;
420   state->m_old_tiledim_1 = 0;
421   state->m_old_tiledim_2 = 0;
422   state->m_old_tiledim_3 = 0;
392   state->m_old_tiledim[0] = 0;
393   state->m_old_tiledim[1] = 0;
394   state->m_old_tiledim[2] = 0;
395   state->m_old_tiledim[3] = 0;
423396
424397   assert((num >= 1) && (num <= 4));
425398
426399   switch (num)
427400   {
428401      case 4:
429         state->m_tilemap_3 = tilemap_create(machine, get_tile_info_3, tilemap_scan_rows, 8, 8, 512 / 8, 512 / 8);
430         tilemap_set_transparent_pen(state->m_tilemap_3, 0);
431         tilemap_set_scroll_rows(state->m_tilemap_3, 1);
432         tilemap_set_scroll_cols(state->m_tilemap_3, 1);
433         state->save_item(NAME(state->m_tiledim_3));
434         state->save_item(NAME(state->m_old_tiledim_3));
402         state->m_tilemap[3] = tilemap_create(machine, get_tile_info_3, tilemap_scan_rows, 8, 8, 512 / 8, 512 / 8);
403         tilemap_set_transparent_pen(state->m_tilemap[3], 0);
404         tilemap_set_scroll_rows(state->m_tilemap[3], 1);
405         tilemap_set_scroll_cols(state->m_tilemap[3], 1);
406         state->save_item(NAME(state->m_tiledim[3]));
407         state->save_item(NAME(state->m_old_tiledim[3]));
435408
436409      case 3:
437         state->m_tilemap_2 = tilemap_create(machine, get_tile_info_2, tilemap_scan_rows, 8, 8, 512 / 8, 512 / 8);
438         tilemap_set_transparent_pen(state->m_tilemap_2, 0);
439         tilemap_set_scroll_rows(state->m_tilemap_2, 1);
440         tilemap_set_scroll_cols(state->m_tilemap_2, 1);
441         state->save_item(NAME(state->m_tiledim_2));
442         state->save_item(NAME(state->m_old_tiledim_2));
410         state->m_tilemap[2] = tilemap_create(machine, get_tile_info_2, tilemap_scan_rows, 8, 8, 512 / 8, 512 / 8);
411         tilemap_set_transparent_pen(state->m_tilemap[2], 0);
412         tilemap_set_scroll_rows(state->m_tilemap[2], 1);
413         tilemap_set_scroll_cols(state->m_tilemap[2], 1);
414         state->save_item(NAME(state->m_tiledim[2]));
415         state->save_item(NAME(state->m_old_tiledim[2]));
443416
444417      case 2:
445         state->m_tilemap_1 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 8, 8, 512 / 8, 512 / 8);
446         tilemap_set_transparent_pen(state->m_tilemap_1, 0);
447         tilemap_set_scroll_rows(state->m_tilemap_1, 1);
448         tilemap_set_scroll_cols(state->m_tilemap_1, 1);
449         state->save_item(NAME(state->m_tiledim_1));
450         state->save_item(NAME(state->m_old_tiledim_1));
418         state->m_tilemap[1] = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 8, 8, 512 / 8, 512 / 8);
419         tilemap_set_transparent_pen(state->m_tilemap[1], 0);
420         tilemap_set_scroll_rows(state->m_tilemap[1], 1);
421         tilemap_set_scroll_cols(state->m_tilemap[1], 1);
422         state->save_item(NAME(state->m_tiledim[1]));
423         state->save_item(NAME(state->m_old_tiledim[1]));
451424
452425      case 1:
453         state->m_tilemap_0 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 8, 8, 512 / 8, 512 / 8);
454         tilemap_set_transparent_pen(state->m_tilemap_0, 0);
455         tilemap_set_scroll_rows(state->m_tilemap_0, 1);
456         tilemap_set_scroll_cols(state->m_tilemap_0, 1);
457         state->save_item(NAME(state->m_tiledim_0));
458         state->save_item(NAME(state->m_old_tiledim_0));
426         state->m_tilemap[0] = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 8, 8, 512 / 8, 512 / 8);
427         tilemap_set_transparent_pen(state->m_tilemap[0], 0);
428         tilemap_set_scroll_rows(state->m_tilemap[0], 1);
429         tilemap_set_scroll_cols(state->m_tilemap[0], 1);
430         state->save_item(NAME(state->m_tiledim[0]));
431         state->save_item(NAME(state->m_old_tiledim[0]));
459432
460433         break;
461434   }
r11160r11161
500473   cave_vh_start(machine, 2);
501474
502475   /* Layer 2 (8x8) needs to be handled differently */
503   state->m_tilemap_2 = tilemap_create(machine, sailormn_get_tile_info_2, tilemap_scan_rows, 8, 8, 512 / 8, 512 / 8 );
476   state->m_tilemap[2] = tilemap_create(machine, sailormn_get_tile_info_2, tilemap_scan_rows, 8, 8, 512 / 8, 512 / 8 );
504477
505   tilemap_set_transparent_pen(state->m_tilemap_2, 0);
506   tilemap_set_scroll_rows(state->m_tilemap_2, 1);
507   tilemap_set_scroll_cols(state->m_tilemap_2, 1);
478   tilemap_set_transparent_pen(state->m_tilemap[2], 0);
479   tilemap_set_scroll_rows(state->m_tilemap[2], 1);
480   tilemap_set_scroll_cols(state->m_tilemap[2], 1);
508481}
509482
510483/***************************************************************************
r11160r11161
14471420
14481421INLINE void cave_tilemap_draw(
14491422   running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect,
1450   tilemap_t *TILEMAP, UINT16 *VRAM, UINT16 *VCTRL,
1451   UINT32 flags, UINT32 priority, UINT32 priority2 )
1423   UINT32 flags, UINT32 priority, UINT32 priority2, int GFX )
14521424{
14531425   cave_state *state = machine.driver_data<cave_state>();
1426   tilemap_t *TILEMAP = state->m_tilemap[GFX];
1427   UINT16 *VRAM = state->m_vram[GFX];
1428   UINT16 *VCTRL = state->m_vctrl[GFX];
14541429   int sx, sy, flipx, flipy, offs_x, offs_y, offs_row;
14551430
14561431   /* Bail out if ... */
r11160r11161
14721447   /* An additional 8 pixel offset for layers with 8x8 tiles. Plus
14731448       Layer 0 is displaced by 1 pixel wrt Layer 1, so is Layer 2 wrt
14741449       Layer 1 */
1475   if      (TILEMAP == state->m_tilemap_0)   offs_x -= (state->m_tiledim_0 ? 1 : (1 + 8));
1476   else if   (TILEMAP == state->m_tilemap_1)   offs_x -= (state->m_tiledim_1 ? 2 : (2 + 8));
1477   else if   (TILEMAP == state->m_tilemap_2)   offs_x -= (state->m_tiledim_2 ? 3 : (3 + 8));
1478   else if   (TILEMAP == state->m_tilemap_3)   offs_x -= (state->m_tiledim_3 ? 4 : (4 + 8));
1450   if      (TILEMAP == state->m_tilemap[0])   offs_x -= (state->m_tiledim[0] ? 1 : (1 + 8));
1451   else if   (TILEMAP == state->m_tilemap[1])   offs_x -= (state->m_tiledim[1] ? 2 : (2 + 8));
1452   else if   (TILEMAP == state->m_tilemap[2])   offs_x -= (state->m_tiledim[2] ? 3 : (3 + 8));
1453   else if   (TILEMAP == state->m_tilemap[3])   offs_x -= (state->m_tiledim[3] ? 4 : (4 + 8));
14791454
14801455   sx = VCTRL[0] - state->m_videoregs[0] + (flipx ? (offs_x + 2) : -offs_x);
14811456   sy = VCTRL[1] - state->m_videoregs[1] + (flipy ? (offs_y + 2) : -offs_y);
r11160r11161
15651540   }
15661541}
15671542
1568static void cave_tilemap_0_draw( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
1569{
1570   cave_state *state = machine.driver_data<cave_state>();
1571   cave_tilemap_draw(machine, bitmap, cliprect, state->m_tilemap_0, state->m_vram_0, state->m_vctrl_0, flags, priority, priority2);
1572}
15731543
1574static void cave_tilemap_1_draw( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
1575{
1576   cave_state *state = machine.driver_data<cave_state>();
1577   cave_tilemap_draw(machine, bitmap, cliprect, state->m_tilemap_1, state->m_vram_1, state->m_vctrl_1, flags, priority, priority2);
1578}
1579
1580static void cave_tilemap_2_draw( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
1581{
1582   cave_state *state = machine.driver_data<cave_state>();
1583   cave_tilemap_draw(machine, bitmap, cliprect, state->m_tilemap_2, state->m_vram_2, state->m_vctrl_2, flags, priority, priority2);
1584}
1585
1586static void cave_tilemap_3_draw( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
1587{
1588   cave_state *state = machine.driver_data<cave_state>();
1589   cave_tilemap_draw(machine, bitmap, cliprect, state->m_tilemap_3, state->m_vram_3, state->m_vctrl_3, flags, priority, priority2);
1590}
1591
1592
15931544SCREEN_UPDATE( cave )
15941545{
15951546   cave_state *state = screen->machine().driver_data<cave_state>();
1596   int pri, pri2;
1547   int pri, pri2, GFX;
15971548   int layers_ctrl = -1;
15981549
15991550   set_pens(screen->machine());
r11160r11161
16021553   state->m_blit.line_offset = bitmap->rowpixels * bitmap->bpp / 8;
16031554
16041555   /* Choose the tilemap to display (8x8 tiles or 16x16 tiles) */
1605   if (state->m_tilemap_0)
1556   for (GFX = 0; GFX < 4; GFX++)
16061557   {
1607      state->m_tiledim_0 = state->m_vctrl_0[1] & 0x2000;
1608      if (state->m_tiledim_0 != state->m_old_tiledim_0)
1609         tilemap_mark_all_tiles_dirty(state->m_tilemap_0);
1610      state->m_old_tiledim_0 = state->m_tiledim_0;
1558      if (state->m_tilemap[GFX])
1559      {
1560         state->m_tiledim[GFX] = state->m_vctrl[0][1] & 0x2000;
1561         if (state->m_tiledim[GFX] != state->m_old_tiledim[GFX])
1562            tilemap_mark_all_tiles_dirty(state->m_tilemap[GFX]);
1563         state->m_old_tiledim[GFX] = state->m_tiledim[GFX];
1564      }
16111565   }
16121566
1613   if (state->m_tilemap_1)
1614   {
1615      state->m_tiledim_1 = state->m_vctrl_1[1] & 0x2000;
1616      if (state->m_tiledim_1 != state->m_old_tiledim_1)
1617         tilemap_mark_all_tiles_dirty(state->m_tilemap_1);
1618      state->m_old_tiledim_1 = state->m_tiledim_1;
1619   }
1620
1621   if (state->m_tilemap_2)
1622   {
1623      state->m_tiledim_2 = state->m_vctrl_2[1] & 0x2000;
1624      if (state->m_tiledim_2 != state->m_old_tiledim_2)
1625         tilemap_mark_all_tiles_dirty(state->m_tilemap_2);
1626      state->m_old_tiledim_2 = state->m_tiledim_2;
1627   }
1628
1629   if (state->m_tilemap_3)
1630   {
1631      state->m_tiledim_3 = state->m_vctrl_3[1] & 0x2000;
1632      if (state->m_tiledim_3 != state->m_old_tiledim_3)
1633         tilemap_mark_all_tiles_dirty(state->m_tilemap_3);
1634      state->m_old_tiledim_3 = state->m_tiledim_3;
1635   }
1636
1637
16381567#ifdef MAME_DEBUG
16391568{
16401569   if ( input_code_pressed(screen->machine(), KEYCODE_Z) || input_code_pressed(screen->machine(), KEYCODE_X) || input_code_pressed(screen->machine(), KEYCODE_C) ||
r11160r11161
16621591         state->m_videoregs[4], state->m_videoregs[5], state->m_videoregs[6], state->m_videoregs[7] );
16631592#endif
16641593      /* Show the scroll / flags registers of the selected layer */
1665      if ((state->m_tilemap_0) && (msk & 0x000f))   popmessage("x:%04X y:%04X f:%04X", state->m_vctrl_0[0],state->m_vctrl_0[1],state->m_vctrl_0[2]);
1666      if ((state->m_tilemap_1) && (msk & 0x00f0))   popmessage("x:%04X y:%04X f:%04X", state->m_vctrl_1[0],state->m_vctrl_1[1],state->m_vctrl_1[2]);
1667      if ((state->m_tilemap_2) && (msk & 0x0f00))   popmessage("x:%04X y:%04X f:%04X", state->m_vctrl_2[0],state->m_vctrl_2[1],state->m_vctrl_2[2]);
1668      if ((state->m_tilemap_3) && (msk & 0xf000))   popmessage("x:%04X y:%04X f:%04X", state->m_vctrl_3[0],state->m_vctrl_3[1],state->m_vctrl_3[2]);
1594      if ((state->m_tilemap[0]) && (msk & 0x000f))   popmessage("x:%04X y:%04X f:%04X", state->m_vctrl[0][0],state->m_vctrl[0][1],state->m_vctrl[0][2]);
1595      if ((state->m_tilemap[1]) && (msk & 0x00f0))   popmessage("x:%04X y:%04X f:%04X", state->m_vctrl[1][0],state->m_vctrl[1][1],state->m_vctrl[1][2]);
1596      if ((state->m_tilemap[2]) && (msk & 0x0f00))   popmessage("x:%04X y:%04X f:%04X", state->m_vctrl[2][0],state->m_vctrl[2][1],state->m_vctrl[2][2]);
1597      if ((state->m_tilemap[3]) && (msk & 0xf000))   popmessage("x:%04X y:%04X f:%04X", state->m_vctrl[3][0],state->m_vctrl[3][1],state->m_vctrl[3][2]);
16691598   }
16701599
16711600   /* Show the row / "column" scroll enable flags, when they change state */
16721601   state->m_rasflag = 0;
1673   if (state->m_tilemap_0)
1602   for (GFX = 0; GFX < 4; GFX++)
16741603   {
1675      state->m_rasflag |= (state->m_vctrl_0[0] & 0x4000) ? 0x0001 : 0;
1676      state->m_rasflag |= (state->m_vctrl_0[1] & 0x4000) ? 0x0002 : 0;
1604      if (state->m_tilemap[GFX])
1605      {
1606         state->m_rasflag |= (state->m_vctrl[GFX][0] & 0x4000) ? 0x0001 << (4*GFX) : 0;
1607         state->m_rasflag |= (state->m_vctrl[GFX][1] & 0x4000) ? 0x0002 << (4*GFX) : 0;
1608      }
16771609   }
1678   if (state->m_tilemap_1)
1679   {
1680      state->m_rasflag |= (state->m_vctrl_1[0] & 0x4000) ? 0x0010 : 0;
1681      state->m_rasflag |= (state->m_vctrl_1[1] & 0x4000) ? 0x0020 : 0;
1682   }
1683   if (state->m_tilemap_2)
1684   {
1685      state->m_rasflag |= (state->m_vctrl_2[0] & 0x4000) ? 0x0100 : 0;
1686      state->m_rasflag |= (state->m_vctrl_2[1] & 0x4000) ? 0x0200 : 0;
1687   }
1688   if (state->m_tilemap_3)
1689   {
1690      state->m_rasflag |= (state->m_vctrl_3[0] & 0x4000) ? 0x1000 : 0;
1691      state->m_rasflag |= (state->m_vctrl_3[1] & 0x4000) ? 0x2000 : 0;
1692   }
1610
16931611   if (state->m_rasflag != state->m_old_rasflag)
16941612   {
16951613      popmessage("Line Effect: 0:%c%c 1:%c%c 2:%c%c 3:%c%c",
r11160r11161
17201638    */
17211639   for (pri = 0; pri <= 3; pri++)   // tile / sprite priority
17221640   {
1723         if (layers_ctrl & (1 << (pri + 16)))   (*state->m_sprite_draw)(screen->machine(), pri);
1641      if (layers_ctrl & (1 << (pri + 16)))   (*state->m_sprite_draw)(screen->machine(), pri);
17241642
17251643      for (pri2 = 0; pri2 <= 3; pri2++)   // priority of the whole layer
17261644      {
1727         if (layers_ctrl & (1 << (pri +  0)))   cave_tilemap_0_draw(screen->machine(), bitmap, cliprect, pri, 0, pri2);
1728         if (layers_ctrl & (1 << (pri +  4)))   cave_tilemap_1_draw(screen->machine(), bitmap, cliprect, pri, 0, pri2);
1729         if (layers_ctrl & (1 << (pri +  8)))   cave_tilemap_2_draw(screen->machine(), bitmap, cliprect, pri, 0, pri2);
1730         if (layers_ctrl & (1 << (pri + 12)))   cave_tilemap_3_draw(screen->machine(), bitmap, cliprect, pri, 0, pri2);
1645         if (layers_ctrl & (1 << (pri +  0)))   cave_tilemap_draw(screen->machine(), bitmap, cliprect, pri, 0, pri2, 0);
1646         if (layers_ctrl & (1 << (pri +  4)))   cave_tilemap_draw(screen->machine(), bitmap, cliprect, pri, 0, pri2, 1);
1647         if (layers_ctrl & (1 << (pri +  8)))   cave_tilemap_draw(screen->machine(), bitmap, cliprect, pri, 0, pri2, 2);
1648         if (layers_ctrl & (1 << (pri + 12)))   cave_tilemap_draw(screen->machine(), bitmap, cliprect, pri, 0, pri2, 3);
17311649      }
17321650   }
17331651   return 0;
src/mame/video/fuukifg3.c
r11160r11161
4848
4949***************************************************************************/
5050
51#define LAYER_8BPP( _N_ ) \
52\
53static TILE_GET_INFO( get_tile_info_##_N_ ) \
54{ \
55   fuuki32_state *state = machine.driver_data<fuuki32_state>(); \
56   UINT16 code = (state->m_vram_##_N_[tile_index] & 0xffff0000) >> 16; \
57   UINT16 attr = (state->m_vram_##_N_[tile_index] & 0x0000ffff); \
58   SET_TILE_INFO(1 + _N_, code, (attr & 0x3f) >> 4, TILE_FLIPYX((attr >> 6) & 3)); \
59} \
60\
61WRITE32_HANDLER( fuuki32_vram_##_N_##_w ) \
62{ \
63   fuuki32_state *state = space->machine().driver_data<fuuki32_state>(); \
64   COMBINE_DATA(&state->m_vram_##_N_[offset]); \
65   tilemap_mark_tile_dirty(state->m_tilemap_##_N_,offset); \
51INLINE void get_tile_info8bpp(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, int _N_)
52{
53   fuuki32_state *state = machine.driver_data<fuuki32_state>();
54   UINT16 code = (state->m_vram[_N_][tile_index] & 0xffff0000) >> 16;
55   UINT16 attr = (state->m_vram[_N_][tile_index] & 0x0000ffff);
56   SET_TILE_INFO(1 + _N_, code, (attr & 0x3f) >> 4, TILE_FLIPYX((attr >> 6) & 3));
6657}
6758
68#define LAYER_4BPP( _N_ ) \
69\
70static TILE_GET_INFO( get_tile_info_##_N_ ) \
71{ \
72   fuuki32_state *state = machine.driver_data<fuuki32_state>(); \
73   UINT16 code = (state->m_vram_##_N_[tile_index] & 0xffff0000) >> 16; \
74   UINT16 attr = (state->m_vram_##_N_[tile_index] & 0x0000ffff); \
75   SET_TILE_INFO(1 + _N_, code, attr & 0x3f, TILE_FLIPYX((attr >> 6) & 3)); \
76} \
77\
78WRITE32_HANDLER( fuuki32_vram_##_N_##_w ) \
79{ \
80   fuuki32_state *state = space->machine().driver_data<fuuki32_state>(); \
81   COMBINE_DATA(&state->m_vram_##_N_[offset]); \
82   tilemap_mark_tile_dirty(state->m_tilemap_##_N_, offset); \
59static TILE_GET_INFO( get_tile_info_0 ) { get_tile_info8bpp(machine, tileinfo, tile_index, 0); }
60static TILE_GET_INFO( get_tile_info_1 ) { get_tile_info8bpp(machine, tileinfo, tile_index, 1); }
61
62INLINE void get_tile_info4bpp(running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, int _N_)
63{
64   fuuki32_state *state = machine.driver_data<fuuki32_state>();
65   UINT16 code = (state->m_vram[_N_][tile_index] & 0xffff0000) >> 16;
66   UINT16 attr = (state->m_vram[_N_][tile_index] & 0x0000ffff);
67   SET_TILE_INFO(1 + _N_, code, attr & 0x3f, TILE_FLIPYX((attr >> 6) & 3));
8368}
8469
70static TILE_GET_INFO( get_tile_info_2 ) { get_tile_info4bpp(machine, tileinfo, tile_index, 2); }
71static TILE_GET_INFO( get_tile_info_3 ) { get_tile_info4bpp(machine, tileinfo, tile_index, 3); }
8572
86LAYER_8BPP( 0 )
87LAYER_8BPP( 1 )
88LAYER_4BPP( 2 )
89LAYER_4BPP( 3 )
73INLINE void fuuki32_vram_w(address_space *space, offs_t offset, UINT32 data, UINT32 mem_mask, int _N_)
74{
75   fuuki32_state *state = space->machine().driver_data<fuuki32_state>();
76   COMBINE_DATA(&state->m_vram[_N_][offset]);
77   tilemap_mark_tile_dirty(state->m_tilemap[_N_],offset);
78}
9079
80WRITE32_HANDLER( fuuki32_vram_0_w ) { fuuki32_vram_w(space, offset, data, mem_mask, 0); }
81WRITE32_HANDLER( fuuki32_vram_1_w ) { fuuki32_vram_w(space, offset, data, mem_mask, 1); }
82WRITE32_HANDLER( fuuki32_vram_2_w ) { fuuki32_vram_w(space, offset, data, mem_mask, 2); }
83WRITE32_HANDLER( fuuki32_vram_3_w ) { fuuki32_vram_w(space, offset, data, mem_mask, 3); }
9184
85
9286/***************************************************************************
9387
9488
r11160r11161
106100   state->save_pointer(NAME(state->m_buf_spriteram), state->m_spriteram_size / 4);
107101   state->save_pointer(NAME(state->m_buf_spriteram2), state->m_spriteram_size / 4);
108102
109   state->m_tilemap_0 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 64, 32);
110   state->m_tilemap_1 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 64, 32);
111   state->m_tilemap_2 = tilemap_create(machine, get_tile_info_2, tilemap_scan_rows, 8, 8, 64, 32);
112   state->m_tilemap_3 = tilemap_create(machine, get_tile_info_3, tilemap_scan_rows, 8, 8, 64, 32);
103   state->m_tilemap[0] = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 64, 32);
104   state->m_tilemap[1] = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 64, 32);
105   state->m_tilemap[2] = tilemap_create(machine, get_tile_info_2, tilemap_scan_rows, 8, 8, 64, 32);
106   state->m_tilemap[3] = tilemap_create(machine, get_tile_info_3, tilemap_scan_rows, 8, 8, 64, 32);
113107
114   tilemap_set_transparent_pen(state->m_tilemap_0, 0xff);   // 8 bits
115   tilemap_set_transparent_pen(state->m_tilemap_1, 0xff);   // 8 bits
116   tilemap_set_transparent_pen(state->m_tilemap_2, 0x0f);   // 4 bits
117   tilemap_set_transparent_pen(state->m_tilemap_3, 0x0f);   // 4 bits
108   tilemap_set_transparent_pen(state->m_tilemap[0], 0xff);   // 8 bits
109   tilemap_set_transparent_pen(state->m_tilemap[1], 0xff);   // 8 bits
110   tilemap_set_transparent_pen(state->m_tilemap[2], 0x0f);   // 4 bits
111   tilemap_set_transparent_pen(state->m_tilemap[3], 0x0f);   // 4 bits
118112
119113   //machine.gfx[1]->color_granularity = 16; /* 256 colour tiles with palette selectable on 16 colour boundaries */
120114   //machine.gfx[2]->color_granularity = 16;
r11160r11161
302296
303297   switch( i )
304298   {
305      case 2:   if (buffer)   tilemap_draw(bitmap, cliprect, state->m_tilemap_3, flag, pri);
306            else      tilemap_draw(bitmap, cliprect, state->m_tilemap_2, flag, pri);
299      case 2:   if (buffer)   tilemap_draw(bitmap, cliprect, state->m_tilemap[3], flag, pri);
300            else      tilemap_draw(bitmap, cliprect, state->m_tilemap[2], flag, pri);
307301            return;
308      case 1:   tilemap_draw(bitmap, cliprect, state->m_tilemap_1, flag, pri);
302      case 1:   tilemap_draw(bitmap, cliprect, state->m_tilemap[1], flag, pri);
309303            return;
310      case 0:   tilemap_draw(bitmap, cliprect, state->m_tilemap_0, flag, pri);
304      case 0:   tilemap_draw(bitmap, cliprect, state->m_tilemap[0], flag, pri);
311305            return;
312306   }
313307}
r11160r11161
351345   layer2_scrolly = ((state->m_vregs[0x8 / 4] & 0xffff0000) >> 16);
352346   layer2_scrollx = ((state->m_vregs[0x8 / 4] & 0x0000ffff));
353347
354   tilemap_set_scrollx(state->m_tilemap_0, 0, layer0_scrollx);
355   tilemap_set_scrolly(state->m_tilemap_0, 0, layer0_scrolly);
356   tilemap_set_scrollx(state->m_tilemap_1, 0, layer1_scrollx);
357   tilemap_set_scrolly(state->m_tilemap_1, 0, layer1_scrolly);
348   tilemap_set_scrollx(state->m_tilemap[0], 0, layer0_scrollx);
349   tilemap_set_scrolly(state->m_tilemap[0], 0, layer0_scrolly);
350   tilemap_set_scrollx(state->m_tilemap[1], 0, layer1_scrollx);
351   tilemap_set_scrolly(state->m_tilemap[1], 0, layer1_scrolly);
358352
359   tilemap_set_scrollx(state->m_tilemap_2, 0, layer2_scrollx);
360   tilemap_set_scrolly(state->m_tilemap_2, 0, layer2_scrolly);
361   tilemap_set_scrollx(state->m_tilemap_3, 0, layer2_scrollx);
362   tilemap_set_scrolly(state->m_tilemap_3, 0, layer2_scrolly);
353   tilemap_set_scrollx(state->m_tilemap[2], 0, layer2_scrollx);
354   tilemap_set_scrolly(state->m_tilemap[2], 0, layer2_scrolly);
355   tilemap_set_scrollx(state->m_tilemap[3], 0, layer2_scrollx);
356   tilemap_set_scrolly(state->m_tilemap[3], 0, layer2_scrolly);
363357
364358   /* The bg colour is the last pen i.e. 0x1fff */
365359   bitmap_fill(bitmap, cliprect, (0x800 * 4) - 1);
src/mame/layout/majorpkr.lay
r0r11161
1<?xml version="1.0"?>
2<mamelayout version="2">
3   <element name="hold1" defstate="0">
4      <rect state="1">
5         <color red="1.0" green="0.0" blue="0.0" />
6      </rect>
7      <rect state="0">
8         <color red="0.15" green="0.0" blue="0.0" />
9      </rect>
10      <text string="HOLD 1">
11         <color red="0.0" green="0.0" blue="0.0" />
12         <bounds x="0" y="0.2" width="1" height="0.6" />
13      </text>
14   </element>
15
16   <element name="hold2" defstate="0">
17      <rect state="1">
18         <color red="1.0" green="0.0" blue="0.0" />
19      </rect>
20      <rect state="0">
21         <color red="0.15" green="0.0" blue="0.0" />
22      </rect>
23      <text string="HOLD 2">
24         <color red="0.0" green="0.0" blue="0.0" />
25         <bounds x="0" y="0.2" width="1" height="0.6" />
26      </text>
27   </element>
28
29   <element name="hold3" defstate="0">
30      <rect state="1">
31         <color red="1.0" green="0.0" blue="0.0" />
32      </rect>
33      <rect state="0">
34         <color red="0.15" green="0.0" blue="0.0" />
35      </rect>
36      <text string="HOLD 3">
37         <color red="0.0" green="0.0" blue="0.0" />
38         <bounds x="0" y="0.2" width="1" height="0.6" />
39      </text>
40   </element>
41
42   <element name="hold4" defstate="0">
43      <rect state="1">
44         <color red="1.0" green="0.0" blue="0.0" />
45      </rect>
46      <rect state="0">
47         <color red="0.15" green="0.0" blue="0.0" />
48      </rect>
49      <text string="HOLD 4">
50         <color red="0.0" green="0.0" blue="0.0" />
51         <bounds x="0" y="0.2" width="1" height="0.6" />
52      </text>
53   </element>
54
55   <element name="hold5" defstate="0">
56      <rect state="1">
57         <color red="1.0" green="0.0" blue="0.0" />
58      </rect>
59      <rect state="0">
60         <color red="0.15" green="0.0" blue="0.0" />
61      </rect>
62      <text string="HOLD 5">
63         <color red="0.0" green="0.0" blue="0.0" />
64         <bounds x="0" y="0.2" width="1" height="0.6" />
65      </text>
66   </element>
67
68   <element name="cancel" defstate="0">
69      <rect state="1">
70         <color red="0.25" green="0.25" blue="1.0" />
71      </rect>
72      <rect state="0">
73         <color red="0.075" green="0.075" blue="0.15" />
74      </rect>
75      <text string="CANCEL">
76         <color red="0.0" green="0.0" blue="0.0" />
77         <bounds x="0" y="0.2" width="1" height="0.6" />
78      </text>
79   </element>
80
81   <element name="dup" defstate="0">
82      <rect state="1">
83         <color red="1.0" green="1.0" blue="0.0" />
84      </rect>
85      <rect state="0">
86         <color red="0.1" green="0.1" blue="0.0" />
87      </rect>
88      <text string="D-UP">
89         <color red="0.0" green="0.0" blue="0.0" />
90         <bounds x="0" y="0.2" width="1" height="0.6" />
91      </text>
92   </element>
93
94   <element name="take" defstate="0">
95      <rect state="1">
96         <color red="1.0" green="1.0" blue="0.0" />
97      </rect>
98      <rect state="0">
99         <color red="0.1" green="0.1" blue="0.0" />
100      </rect>
101      <text string="TAKE">
102         <color red="0.0" green="0.0" blue="0.0" />
103         <bounds x="0" y="0.2" width="1" height="0.6" />
104      </text>
105   </element>
106
107   <element name="big" defstate="0">
108      <rect state="1">
109         <color red="1.0" green="1.0" blue="1.0" />
110      </rect>
111      <rect state="0">
112         <color red="0.1" green="0.1" blue="0.1" />
113      </rect>
114      <text string="BIG">
115         <color red="0.0" green="0.0" blue="0.0" />
116         <bounds x="0" y="0.2" width="1" height="0.6" />
117      </text>
118   </element>
119
120   <element name="small" defstate="0">
121      <rect state="1">
122         <color red="1.0" green="1.0" blue="1.0" />
123      </rect>
124      <rect state="0">
125         <color red="0.1" green="0.1" blue="0.1" />
126      </rect>
127      <text string="SMALL">
128         <color red="0.0" green="0.0" blue="0.0" />
129         <bounds x="0" y="0.2" width="1" height="0.6" />
130      </text>
131   </element>
132
133   <element name="deal" defstate="0">
134      <rect state="1">
135         <color red="0.5" green="1.0" blue="0.0" />
136      </rect>
137      <rect state="0">
138         <color red="0.05" green="0.1" blue="0.0" />
139      </rect>
140      <text string="DEAL">
141         <color red="0.0" green="0.0" blue="0.0" />
142         <bounds x="0" y="0.2" width="1" height="0.6" />
143      </text>
144   </element>
145
146   <element name="bet" defstate="0">
147      <rect state="1">
148         <color red="0.5" green="1.0" blue="0.0" />
149      </rect>
150      <rect state="0">
151         <color red="0.05" green="0.1" blue="0.0" />
152      </rect>
153      <text string="BET">
154         <color red="0.0" green="0.0" blue="0.0" />
155         <bounds x="0" y="0.2" width="1" height="0.6" />
156      </text>
157   </element>
158
159   <element name="fever" defstate="0">
160      <rect state="1">
161         <color red="1.0" green="1.0" blue="1.0" />
162      </rect>
163      <rect state="0">
164         <color red="0.1" green="0.1" blue="0.1" />
165      </rect>
166      <text string="-----">
167         <color red="0.0" green="0.0" blue="0.0" />
168         <bounds x="0" y="0.05" width="1" height="0.3" />
169      </text>
170      <text string="FEVER">
171         <color red="0.0" green="0.0" blue="0.0" />
172         <bounds x="0" y="0.35" width="1" height="0.3" />
173      </text>
174      <text string="-----">
175         <color red="0.0" green="0.0" blue="0.0" />
176         <bounds x="0" y="0.65" width="1" height="0.3" />
177      </text>
178   </element>
179
180   <view name="Button Lamps">
181      <screen index="0">
182         <bounds left="0" top="0" right="4" bottom="3" />
183      </screen>
184
185      <bezel name="lamp0" element="hold1">
186         <bounds x="0" y="3.02" width="0.50" height="0.24" />
187      </bezel>
188
189      <bezel name="lamp9" element="cancel">
190         <bounds x="0" y="3.28" width="0.50" height="0.24" />
191      </bezel>
192
193      <bezel name="lamp1" element="hold2">
194         <bounds x="0.60" y="3.02" width="0.50" height="0.24" />
195      </bezel>
196
197      <bezel name="lamp11" element="dup">
198         <bounds x="0.60" y="3.28" width="0.50" height="0.24" />
199      </bezel>
200
201      <bezel name="lamp2" element="hold3">
202         <bounds x="1.2" y="3.02" width="0.50" height="0.24" />
203      </bezel>
204
205      <bezel name="lamp10" element="take">
206         <bounds x="1.2" y="3.28" width="0.50" height="0.24" />
207      </bezel>
208
209      <bezel name="lamp3" element="hold4">
210         <bounds x="1.8" y="3.02" width="0.50" height="0.24" />
211      </bezel>
212
213      <bezel name="lamp5" element="big">
214         <bounds x="1.8" y="3.28" width="0.50" height="0.24" />
215      </bezel>
216
217      <bezel name="lamp4" element="hold5">
218         <bounds x="2.4" y="3.02" width="0.50" height="0.24" />
219      </bezel>
220
221      <bezel name="lamp6" element="small">
222         <bounds x="2.4" y="3.28" width="0.50" height="0.24" />
223      </bezel>
224
225      <bezel name="lamp12" element="fever">
226         <bounds x="3" y="3.02" width="0.40" height="0.50" />
227      </bezel>
228
229      <bezel name="lamp8" element="deal">
230         <bounds x="3.50" y="3.02" width="0.50" height="0.24" />
231      </bezel>
232
233      <bezel name="lamp7" element="bet">
234         <bounds x="3.50" y="3.28" width="0.50" height="0.24" />
235      </bezel>
236   </view>
237</mamelayout>
src/mame/layout/jollycrd.lay
r11160r11161
108108         <bounds left="0" top="0" right="4" bottom="3" />
109109      </screen>
110110      <bezel name="lamp0" element="hold1">
111         <bounds x="0" y="3.13" width="0.55" height="0.24" />
111         <bounds x="0.15" y="3.13" width="0.55" height="0.24" />
112112      </bezel>
113113      <bezel name="lamp1" element="hold2">
114         <bounds x="0.65" y="3.13" width="0.55" height="0.24" />
114         <bounds x="0.80" y="3.13" width="0.55" height="0.24" />
115115      </bezel>
116116      <bezel name="lamp2" element="hold3">
117         <bounds x="1.3" y="3.13" width="0.55" height="0.24" />
117         <bounds x="1.45" y="3.13" width="0.55" height="0.24" />
118118      </bezel>
119119      <bezel name="lamp3" element="hold4">
120         <bounds x="1.95" y="3.13" width="0.55" height="0.24" />
120         <bounds x="2.10" y="3.13" width="0.55" height="0.24" />
121121      </bezel>
122122      <bezel name="lamp4" element="hold5">
123         <bounds x="2.6" y="3.13" width="0.55" height="0.24" />
123         <bounds x="2.75" y="3.13" width="0.55" height="0.24" />
124124      </bezel>
125125      <bezel name="lamp5" element="cancel">
126126         <bounds x="3.45" y="3.02" width="0.55" height="0.24" />
src/mame/drivers/expro02.c
r11160r11161
151151#include "sound/okim6295.h"
152152
153153
154class expro02_state : public driver_device
154class expro02_state : public kaneko16_state
155155{
156156public:
157157   expro02_state(running_machine &machine, const driver_device_config_base &config)
158      : driver_device(machine, config) { }
158      : kaneko16_state(machine, config) { }
159159
160160   UINT16 m_vram_0_bank_num;
161161   UINT16 m_vram_1_bank_num;
r11160r11161
336336   {
337337      for(i = 0; i < 0x1000 / 2; i += 2)
338338      {
339         if(kaneko16_vram_0[i])
339         if(state->m_vram[0][i])
340340         {
341341            kaneko16_vram_0_w(space, i+1, data << 8, 0xFF00);
342342         }
r11160r11161
353353   {
354354      for(i = 0; i < 0x1000 / 2; i += 2)
355355      {
356         if(kaneko16_vram_1[i])
356         if(state->m_vram[1][i])
357357         {
358358            kaneko16_vram_1_w(space, i+1, data << 8, 0xFF00);
359359         }
r11160r11161
375375   AM_RANGE(0x400000, 0x400001) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
376376
377377
378   AM_RANGE(0x500000, 0x51ffff) AM_RAM AM_BASE(&galsnew_bg_pixram)
379   AM_RANGE(0x520000, 0x53ffff) AM_RAM AM_BASE(&galsnew_fg_pixram)
378   AM_RANGE(0x500000, 0x51ffff) AM_RAM AM_BASE_MEMBER(expro02_state, m_galsnew_bg_pixram)
379   AM_RANGE(0x520000, 0x53ffff) AM_RAM AM_BASE_MEMBER(expro02_state, m_galsnew_fg_pixram)
380380
381   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
382   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
383   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                           //
384   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                           //
381   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(expro02_state, m_vram[1])   // Layers 0
382   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(expro02_state, m_vram[0])   //
383   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE_MEMBER(expro02_state, m_vscroll[1])                           //
384   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE_MEMBER(expro02_state, m_vscroll[0])                           //
385385
386386   AM_RANGE(0x600000, 0x600fff) AM_RAM_WRITE(galsnew_paletteram_w) AM_BASE_GENERIC(paletteram) // palette?
387387
388   AM_RANGE(0x680000, 0x68001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs) // sprite regs? tileregs?
388   AM_RANGE(0x680000, 0x68001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(expro02_state, m_layers_0_regs) // sprite regs? tileregs?
389389
390390   AM_RANGE(0x700000, 0x700fff) AM_RAM AM_BASE_SIZE_MEMBER(expro02_state, m_spriteram, m_spriteram_size)    // sprites? 0x72f words tested
391391
392   AM_RANGE(0x780000, 0x78001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs) // sprite regs? tileregs?
392   AM_RANGE(0x780000, 0x78001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE_MEMBER(expro02_state, m_sprites_regs) // sprite regs? tileregs?
393393
394394   AM_RANGE(0x800000, 0x800001) AM_READ_PORT("DSW1")
395395   AM_RANGE(0x800002, 0x800003) AM_READ_PORT("DSW2")
r11160r11161
413413//  no CALC mcu
414414static ADDRESS_MAP_START( fantasia_map, AS_PROGRAM, 16 )
415415   AM_RANGE(0x000000, 0x4fffff) AM_ROM
416   AM_RANGE(0x500000, 0x51ffff) AM_RAM AM_BASE(&galsnew_bg_pixram)
417   AM_RANGE(0x520000, 0x53ffff) AM_RAM AM_BASE(&galsnew_fg_pixram)
418   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
419   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
420   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                           //
421   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                           //
416   AM_RANGE(0x500000, 0x51ffff) AM_RAM AM_BASE_MEMBER(expro02_state, m_galsnew_bg_pixram)
417   AM_RANGE(0x520000, 0x53ffff) AM_RAM AM_BASE_MEMBER(expro02_state, m_galsnew_fg_pixram)
418   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(expro02_state, m_vram[1])   // Layers 0
419   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(expro02_state, m_vram[0])   //
420   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE_MEMBER(expro02_state, m_vscroll[1])                           //
421   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE_MEMBER(expro02_state, m_vscroll[0])                           //
422422   AM_RANGE(0x600000, 0x600fff) AM_RAM_WRITE(galsnew_paletteram_w) AM_BASE_GENERIC(paletteram) // palette?
423   AM_RANGE(0x680000, 0x68001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs) // sprite regs? tileregs?
423   AM_RANGE(0x680000, 0x68001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(expro02_state, m_layers_0_regs) // sprite regs? tileregs?
424424   AM_RANGE(0x700000, 0x700fff) AM_RAM AM_BASE_SIZE_MEMBER(expro02_state, m_spriteram, m_spriteram_size)    // sprites? 0x72f words tested
425   AM_RANGE(0x780000, 0x78001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs) // sprite regs? tileregs?
425   AM_RANGE(0x780000, 0x78001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE_MEMBER(expro02_state, m_sprites_regs) // sprite regs? tileregs?
426426   AM_RANGE(0x800000, 0x800001) AM_READ_PORT("DSW1")
427427   AM_RANGE(0x800002, 0x800003) AM_READ_PORT("DSW2")
428428   AM_RANGE(0x800004, 0x800005) AM_READ_PORT("DSW3")
r11160r11161
449449
450450static MACHINE_RESET( galsnew )
451451{
452   kaneko16_sprite_type  = 0;
452   expro02_state *state = machine.driver_data<expro02_state>();
453   state->m_sprite_type  = 0;
453454
454   kaneko16_sprite_xoffs = 0;
455   kaneko16_sprite_yoffs = -1*0x40; // align testgrid with bitmap in service mode
455   state->m_sprite_xoffs = 0;
456   state->m_sprite_yoffs = -1*0x40; // align testgrid with bitmap in service mode
456457
457458   // priorities not verified
458   kaneko16_priority.sprite[0] = 8;   // above all
459   kaneko16_priority.sprite[1] = 8;   // above all
460   kaneko16_priority.sprite[2] = 8;   // above all
461   kaneko16_priority.sprite[3] = 8;   // above all
459   state->m_priority.sprite[0] = 8;   // above all
460   state->m_priority.sprite[1] = 8;   // above all
461   state->m_priority.sprite[2] = 8;   // above all
462   state->m_priority.sprite[3] = 8;   // above all
462463}
463464
464465/*************************************
src/mame/drivers/rampart.c
r11160r11161
2424
2525#include "emu.h"
2626#include "cpu/m68000/m68000.h"
27#include "includes/rampart.h"
2827#include "sound/okim6295.h"
2928#include "sound/2413intf.h"
29#include "video/atarimo.h"
30#include "includes/rampart.h"
3031
3132
3233#define MASTER_CLOCK      XTAL_14_31818MHz
r11160r11161
139140   AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE_MEMBER(rampart_state, m_bitmap)
140141   AM_RANGE(0x220000, 0x3bffff) AM_WRITENOP   /* the code blasts right through this when initializing */
141142   AM_RANGE(0x3c0000, 0x3c07ff) AM_MIRROR(0x019800) AM_RAM_WRITE(atarigen_expanded_666_paletteram_w) AM_BASE_GENERIC(paletteram)
142   AM_RANGE(0x3e0000, 0x3e07ff) AM_MIRROR(0x010000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
143   AM_RANGE(0x3e0000, 0x3e07ff) AM_MIRROR(0x010000) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
143144   AM_RANGE(0x3e0800, 0x3e3f3f) AM_MIRROR(0x010000) AM_RAM
144   AM_RANGE(0x3e3f40, 0x3e3f7f) AM_MIRROR(0x010000) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
145   AM_RANGE(0x3e3f40, 0x3e3f7f) AM_MIRROR(0x010000) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
145146   AM_RANGE(0x3e3f80, 0x3effff) AM_MIRROR(0x010000) AM_RAM
146147   AM_RANGE(0x460000, 0x460001) AM_MIRROR(0x019ffe) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0xff00)
147148   AM_RANGE(0x480000, 0x480003) AM_MIRROR(0x019ffc) AM_DEVWRITE8("ymsnd", ym2413_w, 0xff00)
src/mame/drivers/csplayh5.c
r11160r11161
767767   // 0x100000 - 0x3fffff empty sockets
768768
769769   DISK_REGION( "dvd" )
770   DISK_IMAGE( "bikiniko", 0, NO_DUMP )
770   DISK_IMAGE( "bikiniko", 0, SHA1(2189b676746dd848b9b5eb69f9663d6dccd63787) )
771771ROM_END
772772
773773
src/mame/drivers/hornet.c
r11160r11161
12721272   ROM_LOAD( "830a10.14p", 0x400000, 0x400000, CRC(8b8aaf7e) SHA1(49b694dc171c149056b87c15410a6bf37ff2987f) )
12731273
12741274   ROM_REGION(0x2000, "m48t58",0)
1275   ROM_LOAD( "m48t58y.35d", 0x000000, 0x002000, CRC(b077e262) SHA1(5cdcc1b742bf23562f4558216063fea903f045ab) )
1275   ROM_LOAD( "m48t58y.35d",   0x000000, 0x002000, CRC(b077e262) SHA1(5cdcc1b742bf23562f4558216063fea903f045ab) ) // this is set to the JXD, I don't think it's valid.
1276   ROM_LOAD( "m48t58y-70pc1", 0x000000, 0x002000, CRC(ee815325) SHA1(91b10802791b68a8360c0cd6c376c0c4bbbc6fa0) ) // so just load over it with the US one, we know works.
12761277ROM_END
12771278
1278ROM_START(sscopea)
1279ROM_START(sscopec)
12791280   ROM_REGION32_BE(0x400000, "user1", 0)   /* PowerPC program */
1280   ROM_LOAD16_WORD_SWAP("830b01.27p", 0x200000, 0x200000, CRC(3b6bb075) SHA1(babc134c3a20c7cdcaa735d5f1fd5cab38667a14) )
1281   ROM_LOAD16_WORD_SWAP("830c01.27p", 0x200000, 0x200000, CRC(87682449) SHA1(6ccaa5bac86e947e01a6aae568a75f002421fe5b) )
12811282   ROM_RELOAD(0x000000, 0x200000)
12821283
12831284   ROM_REGION32_BE(0x800000, "user2", ROMREGION_ERASE00)   /* Data roms */
r11160r11161
12991300
13001301ROM_START(sscopeb)
13011302   ROM_REGION32_BE(0x400000, "user1", 0)   /* PowerPC program */
1303   ROM_LOAD16_WORD_SWAP("830b01.27p", 0x200000, 0x200000, CRC(3b6bb075) SHA1(babc134c3a20c7cdcaa735d5f1fd5cab38667a14) )
1304   ROM_RELOAD(0x000000, 0x200000)
1305
1306   ROM_REGION32_BE(0x800000, "user2", ROMREGION_ERASE00)   /* Data roms */
1307
1308   ROM_REGION(0x80000, "audiocpu", 0)      /* 68K Program */
1309   ROM_LOAD16_WORD_SWAP("830a08.7s", 0x000000, 0x80000, CRC(2805ea1d) SHA1(2556a51ee98cb8f59bf081e916c69a24532196f1) )
1310
1311   ROM_REGION(0x1000000, "user5", 0)      /* CG Board texture roms */
1312   ROM_LOAD32_WORD( "830a14.u32", 0x000000, 0x400000, CRC(335793e1) SHA1(d582b53c3853abd59bc728f619a30c27cfc9497c) )
1313   ROM_LOAD32_WORD( "830a13.u24", 0x000002, 0x400000, CRC(d6e7877e) SHA1(b4d0e17ada7dd126ec564a20e7140775b4b3fdb7) )
1314
1315   ROM_REGION(0x1000000, "rfsnd", 0)      /* PCM sample roms */
1316   ROM_LOAD( "830a09.16p", 0x000000, 0x400000, CRC(e4b9f305) SHA1(ce2c6f63bdc9374dde48d8359102b57e48b4fdeb) )
1317   ROM_LOAD( "830a10.14p", 0x400000, 0x400000, CRC(8b8aaf7e) SHA1(49b694dc171c149056b87c15410a6bf37ff2987f) )
1318
1319   ROM_REGION(0x2000, "m48t58",0)
1320   ROM_LOAD( "m48t58y-70pc1", 0x000000, 0x002000, CRC(ee815325) SHA1(91b10802791b68a8360c0cd6c376c0c4bbbc6fa0) )
1321ROM_END
1322
1323ROM_START(sscopea)
1324   ROM_REGION32_BE(0x400000, "user1", 0)   /* PowerPC program */
13021325   ROM_LOAD16_WORD_SWAP("830a01.27p", 0x200000, 0x200000, CRC(39e353f1) SHA1(569b06969ae7a690f6d6e63cc3b5336061663a37) )
13031326   ROM_RELOAD(0x000000, 0x200000)
13041327
r11160r11161
14591482GAME(  1998, nbapbp,    0,        hornet,           hornet, hornet,        ROT0, "Konami", "NBA Play By Play", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
14601483GAMEL( 1998, terabrst,  0,        terabrst,         hornet, hornet_2board, ROT0, "Konami", "Teraburst (1998/07/17 ver UEL)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE, layout_dualhsxs )
14611484GAMEL( 1998, terabrsta, terabrst, terabrst,         hornet, hornet_2board, ROT0, "Konami", "Teraburst (1998/02/25 ver AAA)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1462GAMEL( 2000, sscope,    0,        hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver JZD)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1463GAMEL( 2000, sscopea,   sscope,   hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver UAB)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1464GAMEL( 2000, sscopeb,   sscope,   hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver UAA)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1485
1486// The region comes from the Timekeeper NVRAM, without a valid default all sets except 'xxD, Ver 1.33' will init their NVRAM to UAx versions, the xxD set seems to incorrectly init it to JXD, which isn't a valid
1487// version, and thus can't be booted.  If you copy the NVRAM from another already initialized set, it will boot as UAD.
1488// to get the actual game to boot you must calibrate the guns etc.
1489GAMEL( 2000, sscope,    0,        hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver xxD, Ver 1.33)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1490GAMEL( 2000, sscopec,   sscope,   hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver xxC, Ver 1.30)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1491GAMEL( 2000, sscopeb,   sscope,   hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver xxB, Ver 1.20)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1492GAMEL( 2000, sscopea,   sscope,   hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver xxA, Ver 1.00)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1493
14651494GAMEL( 2000, sscope2,   0,        hornet_2board_v2, sscope, hornet_2board, ROT0, "Konami", "Silent Scope 2", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
src/mame/drivers/mediagx.c
r11160r11161
10071007static IRQ_CALLBACK(irq_callback)
10081008{
10091009   mediagx_state *state = device->machine().driver_data<mediagx_state>();
1010   int r;
1011
1012   r = pic8259_acknowledge( state->m_pic8259_2);
1013   if (r==0)
1014   {
1015      r = pic8259_acknowledge( state->m_pic8259_1);
1016   }
1017   return r;
1010   return pic8259_acknowledge( state->m_pic8259_1);
10181011}
10191012
10201013static MACHINE_START(mediagx)
r11160r11161
10611054   cputag_set_input_line(device->machine(), "maincpu", 0, state ? HOLD_LINE : CLEAR_LINE);
10621055}
10631056
1057static READ8_DEVICE_HANDLER( get_slave_ack )
1058{
1059   mediagx_state *state = device->machine().driver_data<mediagx_state>();
1060   if (offset==2) { // IRQ = 2
1061      return pic8259_acknowledge(state->m_pic8259_2);
1062   }
1063   return 0x00;
1064}
1065
10641066static const struct pic8259_interface mediagx_pic8259_1_config =
10651067{
1066   DEVCB_LINE(mediagx_pic8259_1_set_int_line)
1068   DEVCB_LINE(mediagx_pic8259_1_set_int_line),
1069   DEVCB_LINE_VCC,
1070   DEVCB_HANDLER(get_slave_ack)
10671071};
10681072
10691073static const struct pic8259_interface mediagx_pic8259_2_config =
10701074{
1071   DEVCB_DEVICE_LINE("pic8259_master", pic8259_ir2_w)
1075   DEVCB_DEVICE_LINE("pic8259_master", pic8259_ir2_w),
1076   DEVCB_LINE_GND,
1077   DEVCB_NULL
10721078};
10731079
10741080
src/mame/drivers/galpani3.c
r11160r11161
6868#include "includes/kaneko16.h"
6969#include "video/sknsspr.h"
7070
71class galpani3_state : public driver_device
71class galpani3_state : public kaneko16_state
7272{
7373public:
7474   galpani3_state(running_machine &machine, const driver_device_config_base &config)
75      : driver_device(machine, config) { }
75      : kaneko16_state(machine, config) { }
7676
7777   UINT16* m_priority_buffer;
7878   UINT16* m_framebuffer1;
r11160r11161
531531   * com0=com1=0xFFFF -> command to execute
532532   * com2=com3=0xFFFF -> status reading only
533533*/
534#define GALPANI3_MCU_COM_W(_n_) \
535static WRITE16_HANDLER( galpani3_mcu_com##_n_##_w ) \
536{ \
537   galpani3_state *state = space->machine().driver_data<galpani3_state>(); \
538   COMBINE_DATA(&state->m_mcu_com[_n_]); \
539   if (state->m_mcu_com[0] != 0xFFFF)   return; \
540   if (state->m_mcu_com[1] != 0xFFFF)   return; \
541   if (state->m_mcu_com[2] != 0xFFFF)   return; \
542   if (state->m_mcu_com[3] != 0xFFFF)   return; \
543\
544   memset(state->m_mcu_com, 0, 4 * sizeof( UINT16 ) ); \
545   galpani3_mcu_run(space->machine()); \
534
535INLINE void galpani3_mcu_com_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
536{
537   galpani3_state *state = space->machine().driver_data<galpani3_state>();
538   COMBINE_DATA(&state->m_mcu_com[_n_]);
539   if (state->m_mcu_com[0] != 0xFFFF)   return;
540   if (state->m_mcu_com[1] != 0xFFFF)   return;
541   if (state->m_mcu_com[2] != 0xFFFF)   return;
542   if (state->m_mcu_com[3] != 0xFFFF)   return;
543
544   memset(state->m_mcu_com, 0, 4 * sizeof( UINT16 ) );
545   galpani3_mcu_run(space->machine());
546546}
547547
548GALPANI3_MCU_COM_W(0)
549GALPANI3_MCU_COM_W(1)
550GALPANI3_MCU_COM_W(2)
551GALPANI3_MCU_COM_W(3)
548static WRITE16_HANDLER( galpani3_mcu_com0_w ) { galpani3_mcu_com_w(space, offset, data, mem_mask, 0); }
549static WRITE16_HANDLER( galpani3_mcu_com1_w ) { galpani3_mcu_com_w(space, offset, data, mem_mask, 1); }
550static WRITE16_HANDLER( galpani3_mcu_com2_w ) { galpani3_mcu_com_w(space, offset, data, mem_mask, 2); }
551static WRITE16_HANDLER( galpani3_mcu_com3_w ) { galpani3_mcu_com_w(space, offset, data, mem_mask, 3); }
552552
553553static READ16_HANDLER( galpani3_mcu_status_r )
554554{
src/mame/drivers/zaxxon.c
r11160r11161
334334}
335335
336336
337static MACHINE_RESET( razmataz )
338{
339   /* the timer value is unknown, but this seems to work well */
340   sega_usb_reset(machine, 0x10);
341}
342337
343
344
345338/*************************************
346339 *
347340 *  Input handlers
r11160r11161
981974
982975static MACHINE_CONFIG_DERIVED( razmataz, root )
983976
984   MCFG_MACHINE_RESET(razmataz)
985
986977   /* video hardware */
987978   MCFG_VIDEO_START(razmataz)
988979   MCFG_SCREEN_MODIFY("screen")
r11160r11161
15081499static DRIVER_INIT( razmataz )
15091500{
15101501   zaxxon_state *state = machine.driver_data<zaxxon_state>();
1502   address_space *pgmspace = machine.device("maincpu")->memory().space(AS_PROGRAM);
1503   device_t *usbsnd = machine.device("usbsnd");
15111504
15121505   nprinces_decode(machine, "maincpu");
15131506
15141507   /* additional input ports are wired */
1515   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_port(0xc004, 0xc004, 0, 0x18f3, "SW04");
1516   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_port(0xc008, 0xc008, 0, 0x18f3, "SW08");
1517   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_port(0xc00c, 0xc00c, 0, 0x18f3, "SW0C");
1508   pgmspace->install_read_port(0xc004, 0xc004, 0, 0x18f3, "SW04");
1509   pgmspace->install_read_port(0xc008, 0xc008, 0, 0x18f3, "SW08");
1510   pgmspace->install_read_port(0xc00c, 0xc00c, 0, 0x18f3, "SW0C");
15181511
15191512   /* unknown behavior expected here */
1520   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0xc80a, 0xc80a, FUNC(razmataz_counter_r));
1513   pgmspace->install_legacy_read_handler(0xc80a, 0xc80a, FUNC(razmataz_counter_r));
15211514
15221515   /* connect the universal sound board */
1523   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xe03c, 0xe03c, 0, 0x1f00, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
1516   pgmspace->install_legacy_readwrite_handler(*usbsnd, 0xe03c, 0xe03c, 0, 0x1f00, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
15241517
15251518   /* additional state saving */
15261519   state->save_item(NAME(state->m_razmataz_dial_pos));
r11160r11161
15301523
15311524static DRIVER_INIT( ixion )
15321525{
1526   address_space *pgmspace = machine.device("maincpu")->memory().space(AS_PROGRAM);
1527   device_t *usbsnd = machine.device("usbsnd");
1528
15331529   szaxxon_decode(machine, "maincpu");
15341530
15351531   /* connect the universal sound board */
1536   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xe03c, 0xe03c, 0, 0x1f00, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
1532   pgmspace->install_legacy_readwrite_handler(*usbsnd, 0xe03c, 0xe03c, 0, 0x1f00, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
15371533}
15381534
15391535
src/mame/drivers/cesclass.c
r0r11161
1/*
2
3   CES Classic wall games
4
5*/
6
7#include "emu.h"
8#include "cpu/m68000/m68000.h"
9
10class cesclassic_state : public driver_device
11{
12public:
13   cesclassic_state(running_machine &machine, const driver_device_config_base &config)
14      : driver_device(machine, config) {}
15};
16
17static VIDEO_START( cesclassic )
18{
19}
20
21static SCREEN_UPDATE( cesclassic )
22{
23   return 0;
24}
25
26static READ16_HANDLER(cesclassic_60000_r)
27{
28   return 0x100 | 0x200;
29}
30
31static ADDRESS_MAP_START( cesclassic_map, AS_PROGRAM, 16 )
32   AM_RANGE(0x000000, 0x0fffff) AM_ROM
33   AM_RANGE(0x400000, 0x40ffff) AM_RAM
34   AM_RANGE(0x600000, 0x600001) AM_READ(cesclassic_60000_r)
35   AM_RANGE(0x640040, 0x640041) AM_WRITENOP
36   AM_RANGE(0x904000, 0x904001) AM_WRITENOP
37ADDRESS_MAP_END
38
39static INPUT_PORTS_START( cesclassic )
40INPUT_PORTS_END
41
42static MACHINE_CONFIG_START( cesclassic, cesclassic_state )
43
44   MCFG_CPU_ADD("maincpu", M68000, 24000000/2 )
45   MCFG_CPU_PROGRAM_MAP(cesclassic_map)
46
47   /* video hardware */
48   MCFG_SCREEN_ADD("screen", RASTER)
49   MCFG_SCREEN_REFRESH_RATE(60)
50   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
51   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
52   MCFG_SCREEN_SIZE(32*8, 32*8)
53   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
54   MCFG_SCREEN_UPDATE(cesclassic)
55
56   MCFG_PALETTE_LENGTH(16)
57
58   MCFG_VIDEO_START(cesclassic)
59MACHINE_CONFIG_END
60
61ROM_START(hrclass)
62   ROM_REGION( 0x100000, "maincpu", 0 )
63   ROM_LOAD16_BYTE("hrclassic-v121-u44.bin", 0x000000, 0x80000, CRC(cbbbbbdb) SHA1(d406a27a823f5e530a9cf7615c396fe52df1c387) )
64   ROM_LOAD16_BYTE("hrclassic-v121-u43.bin", 0x000001, 0x80000, CRC(f136aec3) SHA1(7823e81eb79c7575c1d6c2ae0848c2b9943ee6ef) )
65
66   ROM_REGION( 0x80000, "oki", 0 )
67   ROM_LOAD( "hrclassic-v100-u28.bin", 0x00000, 0x80000, CRC(45d15b3a) SHA1(a11ce27a77ea353034c5f498cb46ef5ed787b0f9) )
68ROM_END
69
70ROM_START(ccclass)
71   ROM_REGION( 0x100000, "maincpu", 0 )
72   ROM_LOAD16_BYTE("ccclassic-v110-u44.bin", 0x000000, 0x80000, CRC(63b63f3a) SHA1(d4b6f401815b05ac0c6c259bb066663d4c2ee132) )
73   ROM_LOAD16_BYTE("ccclassic-v110-u43.bin", 0x000001, 0x80000, CRC(c1b420df) SHA1(9f1f22e6b27abcede6880a1a8ad5399ce582dab1) )
74
75   ROM_REGION( 0x80000, "oki", 0 )
76   ROM_LOAD( "ccclassic-v100-u28.bin", 0x00000, 0x80000, CRC(94190a55) SHA1(fb219401431747fc3840da02c4e933d4c23049b7) )
77ROM_END
78
79ROM_START(tsclass)
80   ROM_REGION( 0x100000, "maincpu", 0 )   
81   ROM_LOAD("tsclassic-v100-u43u44.bin", 0x000000, 0x100000, CRC(a820ec9a) SHA1(84e38c7e54bb9e80142ed4e7763c9e36df560f42) )
82
83   ROM_REGION( 0x80000, "oki", 0 )
84   ROM_LOAD( "tsclassic-v100-u28.bin", 0x00000, 0x80000, CRC(5bf53ca3) SHA1(5767391175fa9488ba0fb17a16de6d5013712a01) )
85ROM_END
86
87GAME(1996, hrclass, 0, cesclassic, cesclassic, 0, ROT0, "Creative Electronics And Software", "Home Run Classic", GAME_NOT_WORKING | GAME_NO_SOUND )
88GAME(1996, ccclass, 0, cesclassic, cesclassic, 0, ROT0, "Creative Electronics And Software", "Country Club Classic", GAME_NOT_WORKING | GAME_NO_SOUND )
89GAME(1996, tsclass, 0, cesclassic, cesclassic, 0, ROT0, "Creative Electronics And Software", "Trap Shoot Classic", GAME_NOT_WORKING | GAME_NO_SOUND )
src/mame/drivers/kaneko16.c
r11160r11161
9393#include "sound/2151intf.h"
9494#include "sound/okim6295.h"
9595
96static UINT16* kaneko16_mainram;
9796
9897/***************************************************************************
9998
r11160r11161
105104
106105MACHINE_RESET( kaneko16 )
107106{
108   kaneko16_sprite_type  = 0;
107   kaneko16_state *state = machine.driver_data<kaneko16_state>();
108   state->m_sprite_type  = 0;
109109
110   kaneko16_sprite_xoffs = 0;
111   kaneko16_sprite_yoffs = 0;
110   state->m_sprite_xoffs = 0;
111   state->m_sprite_yoffs = 0;
112112
113   kaneko16_sprite_fliptype = 0;
113   state->m_sprite_fliptype = 0;
114114
115115/*
116116    Sx = Sprites with priority x, x = tiles with priority x,
r11160r11161
121121    0   1   2   S2  3
122122    0   1   2   3   S3
123123*/
124   kaneko16_priority.sprite[0] = 1;   // above tile[0],   below the others
125   kaneko16_priority.sprite[1] = 2;   // above tile[0-1], below the others
126   kaneko16_priority.sprite[2] = 3;   // above tile[0-2], below the others
127   kaneko16_priority.sprite[3] = 8;   // above all
124   state->m_priority.sprite[0] = 1;   // above tile[0],   below the others
125   state->m_priority.sprite[1] = 2;   // above tile[0-1], below the others
126   state->m_priority.sprite[2] = 3;   // above tile[0-2], below the others
127   state->m_priority.sprite[3] = 8;   // above all
128128}
129129
130130static MACHINE_RESET( berlwall )
131131{
132   kaneko16_state *state = machine.driver_data<kaneko16_state>();
132133   MACHINE_RESET_CALL(kaneko16);
133134
134   kaneko16_sprite_type = 2;   // like type 0, but using 16 instead of 8 bytes
135   state->m_sprite_type = 2;   // like type 0, but using 16 instead of 8 bytes
135136}
136137
137138static MACHINE_RESET( blazeon )
138139{
140   kaneko16_state *state = machine.driver_data<kaneko16_state>();
139141   MACHINE_RESET_CALL(kaneko16);
140142
141   kaneko16_sprite_xoffs = 0x10000 - 0x680;
142   kaneko16_sprite_yoffs = 0x000;
143   state->m_sprite_xoffs = 0x10000 - 0x680;
144   state->m_sprite_yoffs = 0x000;
143145
144146/*
145147    Sx = Sprites with priority x, x = tiles with priority x,
r11160r11161
150152    0   1   2   3   S2
151153    0   1   2   3   S3
152154*/
153   kaneko16_priority.sprite[0] = 1;   // above tile[0], below the others
154   kaneko16_priority.sprite[1] = 2;   // above tile[0-1], below the others
155   kaneko16_priority.sprite[2] = 8;   // above all
156   kaneko16_priority.sprite[3] = 8;   // ""
155   state->m_priority.sprite[0] = 1;   // above tile[0], below the others
156   state->m_priority.sprite[1] = 2;   // above tile[0-1], below the others
157   state->m_priority.sprite[2] = 8;   // above all
158   state->m_priority.sprite[3] = 8;   // ""
157159}
158160
159161static MACHINE_RESET( bloodwar )
160162{
161   kaneko16_priority.sprite[0] = 2;   // ever used ?
162   kaneko16_priority.sprite[1] = 3;   // character selection / vs. portraits
163   kaneko16_priority.sprite[2] = 5;   // winning portrait
164   kaneko16_priority.sprite[3] = 7;
163   kaneko16_state *state = machine.driver_data<kaneko16_state>();
164   state->m_priority.sprite[0] = 2;   // ever used ?
165   state->m_priority.sprite[1] = 3;   // character selection / vs. portraits
166   state->m_priority.sprite[2] = 5;   // winning portrait
167   state->m_priority.sprite[3] = 7;
165168
166   kaneko16_sprite_type = 1;
169   state->m_sprite_type = 1;
167170
168   kaneko16_priority.VIEW2_2_pri = 1;
171   state->m_priority.VIEW2_2_pri = 1;
169172
170   toybox_mcu_run = bloodwar_mcu_run;
171   toybox_mcu_init();
173   state->m_toybox_mcu_run = bloodwar_mcu_run;
174   toybox_mcu_init(machine);
172175}
173176
174177static MACHINE_RESET( bonkadv )
175178{
176   kaneko16_priority.sprite[0] = 2;   // ever used ?
177   kaneko16_priority.sprite[1] = 3;   // volcano lava on level 2
178   kaneko16_priority.sprite[2] = 5;   // in-game player
179   kaneko16_priority.sprite[3] = 7;   // demostration text
179   kaneko16_state *state = machine.driver_data<kaneko16_state>();
180   state->m_priority.sprite[0] = 2;   // ever used ?
181   state->m_priority.sprite[1] = 3;   // volcano lava on level 2
182   state->m_priority.sprite[2] = 5;   // in-game player
183   state->m_priority.sprite[3] = 7;   // demostration text
180184
181   kaneko16_sprite_type = 1;
185   state->m_sprite_type = 1;
182186
183   kaneko16_priority.VIEW2_2_pri = 1;
187   state->m_priority.VIEW2_2_pri = 1;
184188
185   toybox_mcu_run = bonkadv_mcu_run;
186   toybox_mcu_init();
189   state->m_toybox_mcu_run = bonkadv_mcu_run;
190   toybox_mcu_init(machine);
187191}
188192
189193static MACHINE_RESET( bakubrkr )
190194{
195   kaneko16_state *state = machine.driver_data<kaneko16_state>();
191196   MACHINE_RESET_CALL(kaneko16);
192197
193   kaneko16_priority.sprite[0] = 8;   // above all
194   kaneko16_priority.sprite[1] = 8;   // above all
195   kaneko16_priority.sprite[2] = 8;   // above all
196   kaneko16_priority.sprite[3] = 8;   // above all
198   state->m_priority.sprite[0] = 8;   // above all
199   state->m_priority.sprite[1] = 8;   // above all
200   state->m_priority.sprite[2] = 8;   // above all
201   state->m_priority.sprite[3] = 8;   // above all
197202
198   kaneko16_priority.VIEW2_2_pri = 1;
203   state->m_priority.VIEW2_2_pri = 1;
199204}
200205
201206static MACHINE_RESET( gtmr )
202207{
208   kaneko16_state *state = machine.driver_data<kaneko16_state>();
203209   MACHINE_RESET_CALL(kaneko16);
204210
205   kaneko16_sprite_type = 1;
211   state->m_sprite_type = 1;
206212
207   kaneko16_priority.VIEW2_2_pri = 1;
213   state->m_priority.VIEW2_2_pri = 1;
208214
209   toybox_mcu_run = gtmr_mcu_run;
210   toybox_mcu_init();
215   state->m_toybox_mcu_run = gtmr_mcu_run;
216   toybox_mcu_init(machine);
211217}
212218
213219static MACHINE_RESET( mgcrystl )
214220{
221   kaneko16_state *state = machine.driver_data<kaneko16_state>();
215222   MACHINE_RESET_CALL(kaneko16);
216223/*
217224    Sx = Sprites with priority x, x = tiles with priority x,
r11160r11161
229236    tiles of the 2nd VIEW2 chip always behind sprites?
230237
231238*/
232   kaneko16_priority.sprite[0] = 2;   // below all
233   kaneko16_priority.sprite[1] = 3;   // above tile[0], below the others
234   kaneko16_priority.sprite[2] = 5;   // above all
235   kaneko16_priority.sprite[3] = 7;   // ""
239   state->m_priority.sprite[0] = 2;   // below all
240   state->m_priority.sprite[1] = 3;   // above tile[0], below the others
241   state->m_priority.sprite[2] = 5;   // above all
242   state->m_priority.sprite[3] = 7;   // ""
236243
237   kaneko16_priority.VIEW2_2_pri = 0;
244   state->m_priority.VIEW2_2_pri = 0;
238245}
239246
240247
241248
242249static MACHINE_RESET( shogwarr )
243250{
251   kaneko16_state *state = machine.driver_data<kaneko16_state>();
244252   MACHINE_RESET_CALL(kaneko16);
245253
246   kaneko16_sprite_xoffs = 0xa00;
254   state->m_sprite_xoffs = 0xa00;
247255
248   kaneko16_sprite_yoffs = -0x40;
256   state->m_sprite_yoffs = -0x40;
249257
250   kaneko16_sprite_type = 0;
251   kaneko16_sprite_fliptype = 1;
258   state->m_sprite_type = 0;
259   state->m_sprite_fliptype = 1;
252260
253   kaneko16_priority.sprite[0] = 1;   // below all
254   kaneko16_priority.sprite[1] = 3;   // above tile[0], below the others
255   kaneko16_priority.sprite[2] = 5;   // above all
256   kaneko16_priority.sprite[3] = 7;   // ""
257   kaneko16_priority.VIEW2_2_pri = 0;
261   state->m_priority.sprite[0] = 1;   // below all
262   state->m_priority.sprite[1] = 3;   // above tile[0], below the others
263   state->m_priority.sprite[2] = 5;   // above all
264   state->m_priority.sprite[3] = 7;   // ""
265   state->m_priority.VIEW2_2_pri = 0;
258266
259   calc3_mcu_init();
267   calc3_mcu_init(machine);
260268}
261269
262270
r11160r11161
366374   AM_RANGE(0x30e000, 0x30ffff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)      // Sprites
367375   AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram)   // Palette
368376//  AM_RANGE(0x480000, 0x480001) AM_RAM     // ?
369   AM_RANGE(0x500000, 0x500001) AM_READWRITE(kaneko16_bg15_reg_r, kaneko16_bg15_reg_w) AM_BASE(&kaneko16_bg15_reg)   // High Color Background
370   AM_RANGE(0x580000, 0x580001) AM_READWRITE(kaneko16_bg15_select_r, kaneko16_bg15_select_w) AM_BASE(&kaneko16_bg15_select)
371   AM_RANGE(0x600000, 0x60003f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs)   // Sprites Regs
377   AM_RANGE(0x500000, 0x500001) AM_READWRITE(kaneko16_bg15_reg_r, kaneko16_bg15_reg_w) AM_BASE_MEMBER(kaneko16_state, m_bg15_reg)   // High Color Background
378   AM_RANGE(0x580000, 0x580001) AM_READWRITE(kaneko16_bg15_select_r, kaneko16_bg15_select_w) AM_BASE_MEMBER(kaneko16_state, m_bg15_select)
379   AM_RANGE(0x600000, 0x60003f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE_MEMBER(kaneko16_state, m_sprites_regs)   // Sprites Regs
372380   AM_RANGE(0x680000, 0x680001) AM_READ_PORT("P1")
373381   AM_RANGE(0x680002, 0x680003) AM_READ_PORT("P2")
374382   AM_RANGE(0x680004, 0x680005) AM_READ_PORT("SYSTEM")
r11160r11161
379387   AM_RANGE(0x800200, 0x80021f) AM_DEVREADWRITE("ay2", kaneko16_YM2149_r, kaneko16_YM2149_w)
380388   AM_RANGE(0x8003fe, 0x8003ff) AM_NOP // for OKI when accessed as .l
381389   AM_RANGE(0x800400, 0x800401) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
382   AM_RANGE(0xc00000, 0xc00fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers
383   AM_RANGE(0xc01000, 0xc01fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
384   AM_RANGE(0xc02000, 0xc02fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                           //
385   AM_RANGE(0xc03000, 0xc03fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                           //
386   AM_RANGE(0xd00000, 0xd0001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers Regs
390   AM_RANGE(0xc00000, 0xc00fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(kaneko16_state, m_vram[1])   // Layers
391   AM_RANGE(0xc01000, 0xc01fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(kaneko16_state, m_vram[0])   //
392   AM_RANGE(0xc02000, 0xc02fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[1])                           //
393   AM_RANGE(0xc03000, 0xc03fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[0])                           //
394   AM_RANGE(0xd00000, 0xd0001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_0_regs)   // Layers Regs
387395ADDRESS_MAP_END
388396
389397
r11160r11161
412420   AM_RANGE(0x40001e, 0x40001f) AM_DEVWRITE("oki", bakubrkr_oki_bank_sw)   // OKI bank Switch
413421   AM_RANGE(0x400200, 0x40021f) AM_DEVREADWRITE("ay2", kaneko16_YM2149_r,kaneko16_YM2149_w)         // Sound
414422   AM_RANGE(0x400400, 0x400401) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)   //
415   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
416   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
417   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                           //
418   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                           //
419   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE(&kaneko16_vram_3)   // Layers 1
420   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE(&kaneko16_vram_2)   //
421   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE(&kaneko16_vscroll_3)                           //
422   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE(&kaneko16_vscroll_2)                           //
423   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(kaneko16_state, m_vram[1])   // Layers 0
424   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(kaneko16_state, m_vram[0])   //
425   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[1])                           //
426   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[0])                           //
427   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE_MEMBER(kaneko16_state, m_vram[3])   // Layers 1
428   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE_MEMBER(kaneko16_state, m_vram[2])   //
429   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[3])                           //
430   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[2])                           //
423431   AM_RANGE(0x600000, 0x601fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)               // Sprites
424432   AM_RANGE(0x700000, 0x700fff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram)   // Palette
425   AM_RANGE(0x800000, 0x80001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
426   AM_RANGE(0x900000, 0x90001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs   )   // Sprites Regs
433   AM_RANGE(0x800000, 0x80001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_0_regs)   // Layers 0 Regs
434   AM_RANGE(0x900000, 0x90001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE_MEMBER(kaneko16_state, m_sprites_regs   )   // Sprites Regs
427435   AM_RANGE(0xa80000, 0xa80001) AM_READ(watchdog_reset16_r)   // Watchdog
428   AM_RANGE(0xb00000, 0xb0001f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE(&kaneko16_layers_1_regs)   // Layers 1 Regs
436   AM_RANGE(0xb00000, 0xb0001f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_1_regs)   // Layers 1 Regs
429437   AM_RANGE(0xd00000, 0xd00001) AM_WRITE(kaneko16_eeprom_w)   // EEPROM
430438   AM_RANGE(0xe00000, 0xe00001) AM_READ_PORT("P1")
431439   AM_RANGE(0xe00002, 0xe00003) AM_READ_PORT("P2")
r11160r11161
442450   AM_RANGE(0x000000, 0x07ffff) AM_ROM      // ROM
443451   AM_RANGE(0x300000, 0x30ffff) AM_RAM      // Work RAM
444452   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram)   // Palette
445   AM_RANGE(0x600000, 0x600fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
446   AM_RANGE(0x601000, 0x601fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
447   AM_RANGE(0x602000, 0x602fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                           //
448   AM_RANGE(0x603000, 0x603fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                           //
453   AM_RANGE(0x600000, 0x600fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(kaneko16_state, m_vram[1])   // Layers 0
454   AM_RANGE(0x601000, 0x601fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(kaneko16_state, m_vram[0])   //
455   AM_RANGE(0x602000, 0x602fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[1])                           //
456   AM_RANGE(0x603000, 0x603fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[0])                           //
449457   AM_RANGE(0x700000, 0x700fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)               // Sprites
450   AM_RANGE(0x800000, 0x80001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
451   AM_RANGE(0x900000, 0x90001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs)   // Sprites Regs #1
458   AM_RANGE(0x800000, 0x80001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_0_regs)   // Layers 0 Regs
459   AM_RANGE(0x900000, 0x90001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE_MEMBER(kaneko16_state, m_sprites_regs)   // Sprites Regs #1
452460   AM_RANGE(0x980000, 0x98001f) AM_RAM                                                            // Sprites Regs #2
453461   AM_RANGE(0xc00000, 0xc00001) AM_READ_PORT("DSW2_P1")
454462   AM_RANGE(0xc00002, 0xc00003) AM_READ_PORT("DSW1_P2")
r11160r11161
500508static ADDRESS_MAP_START( bloodwar, AS_PROGRAM, 16 )
501509   AM_RANGE(0x000000, 0x0fffff) AM_ROM      // ROM
502510   AM_RANGE(0x100000, 0x10ffff) AM_RAM      // Work RAM
503   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE(&kaneko16_mcu_ram)      // Shared With MCU
511   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_mcu_ram)      // Shared With MCU
504512   AM_RANGE(0x2a0000, 0x2a0001) AM_WRITE(toybox_mcu_com0_w)   // To MCU ?
505513   AM_RANGE(0x2b0000, 0x2b0001) AM_WRITE(toybox_mcu_com1_w)
506514   AM_RANGE(0x2c0000, 0x2c0001) AM_WRITE(toybox_mcu_com2_w)
507515   AM_RANGE(0x2d0000, 0x2d0001) AM_WRITE(toybox_mcu_com3_w)
508516   AM_RANGE(0x300000, 0x30ffff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram)   // Palette
509517   AM_RANGE(0x400000, 0x401fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)               // Sprites
510   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
511   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
512   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                           //
513   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                           //
514   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE(&kaneko16_vram_3)   // Layers 1
515   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE(&kaneko16_vram_2)   //
516   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE(&kaneko16_vscroll_3)                           //
517   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE(&kaneko16_vscroll_2)                           //
518   AM_RANGE(0x600000, 0x60001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
519   AM_RANGE(0x680000, 0x68001f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE(&kaneko16_layers_1_regs)   // Layers 1 Regs
520   AM_RANGE(0x700000, 0x70001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs)   // Sprites Regs
518   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(kaneko16_state, m_vram[1])   // Layers 0
519   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(kaneko16_state, m_vram[0])   //
520   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[1])                           //
521   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[0])                           //
522   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE_MEMBER(kaneko16_state, m_vram[3])   // Layers 1
523   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE_MEMBER(kaneko16_state, m_vram[2])   //
524   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[3])                           //
525   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[2])                           //
526   AM_RANGE(0x600000, 0x60001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_0_regs)   // Layers 0 Regs
527   AM_RANGE(0x680000, 0x68001f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_1_regs)   // Layers 1 Regs
528   AM_RANGE(0x700000, 0x70001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE_MEMBER(kaneko16_state, m_sprites_regs)   // Sprites Regs
521529   AM_RANGE(0x800000, 0x800001) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0x00ff)
522530   AM_RANGE(0x880000, 0x880001) AM_DEVREADWRITE8_MODERN("oki2", okim6295_device, read, write, 0x00ff)
523531   AM_RANGE(0x900000, 0x900039) AM_READWRITE(bloodwar_calc_r, bloodwar_calc_w)
r11160r11161
562570static ADDRESS_MAP_START( bonkadv, AS_PROGRAM, 16 )
563571   AM_RANGE(0x000000, 0x0fffff) AM_ROM      // ROM
564572   AM_RANGE(0x100000, 0x10ffff) AM_RAM      // Work RAM
565   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE(&kaneko16_mcu_ram)      // Shared With MCU
573   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_mcu_ram)      // Shared With MCU
566574   AM_RANGE(0x2a0000, 0x2a0001) AM_WRITE(toybox_mcu_com0_w)   // To MCU ?
567575   AM_RANGE(0x2b0000, 0x2b0001) AM_WRITE(toybox_mcu_com1_w)
568576   AM_RANGE(0x2c0000, 0x2c0001) AM_WRITE(toybox_mcu_com2_w)
569577   AM_RANGE(0x2d0000, 0x2d0001) AM_WRITE(toybox_mcu_com3_w)
570578   AM_RANGE(0x300000, 0x30ffff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram)   // Palette
571579   AM_RANGE(0x400000, 0x401fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)               // Sprites
572   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
573   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
574   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                           //
575   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                           //
576   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE(&kaneko16_vram_3)   // Layers 1
577   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE(&kaneko16_vram_2)   //
578   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE(&kaneko16_vscroll_3)                           //
579   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE(&kaneko16_vscroll_2)                           //
580   AM_RANGE(0x600000, 0x60001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
581   AM_RANGE(0x680000, 0x68001f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE(&kaneko16_layers_1_regs)   // Layers 1 Regs
582   AM_RANGE(0x700000, 0x70001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs)   // Sprites Regs
580   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(kaneko16_state, m_vram[1])   // Layers 0
581   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(kaneko16_state, m_vram[0])   //
582   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[1])                           //
583   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[0])                           //
584   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE_MEMBER(kaneko16_state, m_vram[3])   // Layers 1
585   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE_MEMBER(kaneko16_state, m_vram[2])   //
586   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[3])                           //
587   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[2])                           //
588   AM_RANGE(0x600000, 0x60001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_0_regs)   // Layers 0 Regs
589   AM_RANGE(0x680000, 0x68001f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_1_regs)   // Layers 1 Regs
590   AM_RANGE(0x700000, 0x70001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE_MEMBER(kaneko16_state, m_sprites_regs)   // Sprites Regs
583591   AM_RANGE(0x800000, 0x800001) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0x00ff)
584592   AM_RANGE(0x880000, 0x880001) AM_DEVREADWRITE8_MODERN("oki2", okim6295_device, read, write, 0x00ff)
585593   AM_RANGE(0x900000, 0x900015) AM_READWRITE(galpanib_calc_r,galpanib_calc_w)
r11160r11161
640648   AM_RANGE(0x0ffffe, 0x0fffff) AM_READ(gtmr_wheel_r)                                          // Wheel Value
641649
642650   AM_RANGE(0x100000, 0x10ffff) AM_RAM                                                      // Work RAM
643   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE(&kaneko16_mcu_ram)                                 // Shared With MCU
651   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_mcu_ram)                                 // Shared With MCU
644652
645653   AM_RANGE(0x2a0000, 0x2a0001) AM_WRITE(toybox_mcu_com0_w)                                    // To MCU ?
646654   AM_RANGE(0x2b0000, 0x2b0001) AM_WRITE(toybox_mcu_com1_w)
r11160r11161
651659   AM_RANGE(0x310000, 0x327fff) AM_RAM                                                      //
652660   AM_RANGE(0x400000, 0x401fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)                  // Sprites
653661
654   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)               // Layers 0
655   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)               //
656   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                              //
657   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                              //
662   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(kaneko16_state, m_vram[1])               // Layers 0
663   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(kaneko16_state, m_vram[0])               //
664   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[1])                              //
665   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[0])                              //
658666
659   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE(&kaneko16_vram_3)               // Layers 1
660   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE(&kaneko16_vram_2)               //
661   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE(&kaneko16_vscroll_3)                              //
662   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE(&kaneko16_vscroll_2)                              //
667   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE_MEMBER(kaneko16_state, m_vram[3])               // Layers 1
668   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE_MEMBER(kaneko16_state, m_vram[2])               //
669   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[3])                              //
670   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[2])                              //
663671
664   AM_RANGE(0x600000, 0x60000f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
665   AM_RANGE(0x680000, 0x68000f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE(&kaneko16_layers_1_regs)   // Layers 1 Regs
672   AM_RANGE(0x600000, 0x60000f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_0_regs)   // Layers 0 Regs
673   AM_RANGE(0x680000, 0x68000f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_1_regs)   // Layers 1 Regs
666674
667   AM_RANGE(0x700000, 0x70001f) AM_READWRITE(kaneko16_sprites_regs_r, kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs)   // Sprites Regs
675   AM_RANGE(0x700000, 0x70001f) AM_READWRITE(kaneko16_sprites_regs_r, kaneko16_sprites_regs_w) AM_BASE_MEMBER(kaneko16_state, m_sprites_regs)   // Sprites Regs
668676
669677   AM_RANGE(0x800000, 0x800001) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0x00ff)               // Samples
670678   AM_RANGE(0x880000, 0x880001) AM_DEVREADWRITE8_MODERN("oki2", okim6295_device, read, write, 0x00ff)
r11160r11161
716724   AM_RANGE(0x0ffffe, 0x0fffff) AM_READ(gtmr2_wheel_r)   // Wheel Value
717725
718726   AM_RANGE(0x100000, 0x10ffff) AM_RAM // Work RAM
719   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE(&kaneko16_mcu_ram) // Shared With MCU
727   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_mcu_ram) // Shared With MCU
720728
721729   AM_RANGE(0x2a0000, 0x2a0001) AM_WRITE(toybox_mcu_com0_w)   // To MCU ?
722730   AM_RANGE(0x2b0000, 0x2b0001) AM_WRITE(toybox_mcu_com1_w)
r11160r11161
727735   AM_RANGE(0x310000, 0x327fff) AM_RAM //
728736   AM_RANGE(0x400000, 0x401fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) // Sprites
729737
730   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
731   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
732   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)   //
733   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)   //
738   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(kaneko16_state, m_vram[1])   // Layers 0
739   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(kaneko16_state, m_vram[0])   //
740   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[1])   //
741   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[0])   //
734742
735   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE(&kaneko16_vram_3)   // Layers 1
736   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE(&kaneko16_vram_2)   //
737   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE(&kaneko16_vscroll_3)   //
738   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE(&kaneko16_vscroll_2)   //
739   AM_RANGE(0x600000, 0x60000f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
743   AM_RANGE(0x580000, 0x580fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE_MEMBER(kaneko16_state, m_vram[3])   // Layers 1
744   AM_RANGE(0x581000, 0x581fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE_MEMBER(kaneko16_state, m_vram[2])   //
745   AM_RANGE(0x582000, 0x582fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[3])   //
746   AM_RANGE(0x583000, 0x583fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[2])   //
747   AM_RANGE(0x600000, 0x60000f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_0_regs)   // Layers 0 Regs
740748
741   AM_RANGE(0x680000, 0x68000f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE(&kaneko16_layers_1_regs)   // Layers 1 Regs
742   AM_RANGE(0x700000, 0x70001f) AM_READWRITE(kaneko16_sprites_regs_r, kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs)   // Sprites Regs
749   AM_RANGE(0x680000, 0x68000f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_1_regs)   // Layers 1 Regs
750   AM_RANGE(0x700000, 0x70001f) AM_READWRITE(kaneko16_sprites_regs_r, kaneko16_sprites_regs_w) AM_BASE_MEMBER(kaneko16_state, m_sprites_regs)   // Sprites Regs
743751   AM_RANGE(0x800000, 0x800001) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0x00ff)   // Samples
744752   AM_RANGE(0x880000, 0x880001) AM_DEVREADWRITE8_MODERN("oki2", okim6295_device, read, write, 0x00ff)
745753
r11160r11161
771779   AM_RANGE(0x400200, 0x40021f) AM_DEVREADWRITE("ay2", kaneko16_YM2149_r, kaneko16_YM2149_w)
772780   AM_RANGE(0x400400, 0x400401) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
773781   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram)   // Palette
774   AM_RANGE(0x600000, 0x600fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
775   AM_RANGE(0x601000, 0x601fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
776   AM_RANGE(0x602000, 0x602fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                           //
777   AM_RANGE(0x603000, 0x603fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                           //
778   AM_RANGE(0x680000, 0x680fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE(&kaneko16_vram_3)   // Layers 1
779   AM_RANGE(0x681000, 0x681fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE(&kaneko16_vram_2)   //
780   AM_RANGE(0x682000, 0x682fff) AM_RAM AM_BASE(&kaneko16_vscroll_3)                           //
781   AM_RANGE(0x683000, 0x683fff) AM_RAM AM_BASE(&kaneko16_vscroll_2)                           //
782   AM_RANGE(0x600000, 0x600fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(kaneko16_state, m_vram[1])   // Layers 0
783   AM_RANGE(0x601000, 0x601fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(kaneko16_state, m_vram[0])   //
784   AM_RANGE(0x602000, 0x602fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[1])                           //
785   AM_RANGE(0x603000, 0x603fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[0])                           //
786   AM_RANGE(0x680000, 0x680fff) AM_RAM_WRITE(kaneko16_vram_3_w) AM_BASE_MEMBER(kaneko16_state, m_vram[3])   // Layers 1
787   AM_RANGE(0x681000, 0x681fff) AM_RAM_WRITE(kaneko16_vram_2_w) AM_BASE_MEMBER(kaneko16_state, m_vram[2])   //
788   AM_RANGE(0x682000, 0x682fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[3])                           //
789   AM_RANGE(0x683000, 0x683fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[2])                           //
782790   AM_RANGE(0x700000, 0x701fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)               // Sprites
783   AM_RANGE(0x800000, 0x80001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
784   AM_RANGE(0x900000, 0x90001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs)   // Sprites Regs
785   AM_RANGE(0xb00000, 0xb0001f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE(&kaneko16_layers_1_regs)   // Layers 1 Regs
791   AM_RANGE(0x800000, 0x80001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_0_regs)   // Layers 0 Regs
792   AM_RANGE(0x900000, 0x90001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE_MEMBER(kaneko16_state, m_sprites_regs)   // Sprites Regs
793   AM_RANGE(0xb00000, 0xb0001f) AM_RAM_WRITE(kaneko16_layers_1_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_1_regs)   // Layers 1 Regs
786794   AM_RANGE(0xa00000, 0xa00001) AM_READ(watchdog_reset16_r)   // Watchdog
787795   AM_RANGE(0xc00000, 0xc00001) AM_READ_PORT("DSW_P1")
788796   AM_RANGE(0xc00002, 0xc00003) AM_READ_PORT("P2")
r11160r11161
831839
832840static ADDRESS_MAP_START( shogwarr, AS_PROGRAM, 16 )
833841   AM_RANGE(0x000000, 0x03ffff) AM_ROM      // ROM
834   AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&kaneko16_mainram)      // Work RAM
835   AM_RANGE(0x200000, 0x20ffff) AM_RAM_WRITE(calc3_mcu_ram_w) AM_BASE(&kaneko16_mcu_ram)   // Shared With MCU
842   AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_mainram)      // Work RAM
843   AM_RANGE(0x200000, 0x20ffff) AM_RAM_WRITE(calc3_mcu_ram_w) AM_BASE_MEMBER(kaneko16_state, m_mcu_ram)   // Shared With MCU
836844   AM_RANGE(0x280000, 0x280001) AM_WRITE(calc3_mcu_com0_w)
837845   AM_RANGE(0x290000, 0x290001) AM_WRITE(calc3_mcu_com1_w)
838846   AM_RANGE(0x2b0000, 0x2b0001) AM_WRITE(calc3_mcu_com2_w)
r11160r11161
842850   AM_RANGE(0x400000, 0x400001) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0x00ff)   // Samples
843851   AM_RANGE(0x480000, 0x480001) AM_DEVREADWRITE8_MODERN("oki2", okim6295_device, read, write, 0x00ff)
844852   AM_RANGE(0x580000, 0x581fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)               // Sprites
845   AM_RANGE(0x600000, 0x600fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
846   AM_RANGE(0x601000, 0x601fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)
847   AM_RANGE(0x602000, 0x602fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)
848   AM_RANGE(0x603000, 0x603fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)
849   AM_RANGE(0x800000, 0x80000f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
850   AM_RANGE(0x900000, 0x90001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs)   // Sprites Regs
853   AM_RANGE(0x600000, 0x600fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(kaneko16_state, m_vram[1])   // Layers 0
854   AM_RANGE(0x601000, 0x601fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(kaneko16_state, m_vram[0])
855   AM_RANGE(0x602000, 0x602fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[1])
856   AM_RANGE(0x603000, 0x603fff) AM_RAM AM_BASE_MEMBER(kaneko16_state, m_vscroll[0])
857   AM_RANGE(0x800000, 0x80000f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(kaneko16_state, m_layers_0_regs)   // Layers 0 Regs
858   AM_RANGE(0x900000, 0x90001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE_MEMBER(kaneko16_state, m_sprites_regs)   // Sprites Regs
851859   AM_RANGE(0xa00000, 0xa0007f) AM_READWRITE(bloodwar_calc_r, bloodwar_calc_w)
852860   AM_RANGE(0xa80000, 0xa80001) AM_READWRITE(watchdog_reset16_r, watchdog_reset16_w)   // Watchdog
853861   AM_RANGE(0xb80000, 0xb80001) AM_READ_PORT("P1")
r11160r11161
17991807    6-7]    rte
18001808*/
18011809
1802static MACHINE_CONFIG_START( berlwall, driver_device )
1810static MACHINE_CONFIG_START( berlwall, kaneko16_state )
18031811
18041812   /* basic machine hardware */
18051813   MCFG_CPU_ADD("maincpu", M68000, 12000000)   /* MC68000P12 */
r11160r11161
18451853                            Bakuretsu Breaker
18461854***************************************************************************/
18471855
1848static MACHINE_CONFIG_START( bakubrkr, driver_device )
1856static MACHINE_CONFIG_START( bakubrkr, kaneko16_state )
18491857
18501858   /* basic machine hardware */
18511859   MCFG_CPU_ADD("maincpu", M68000, XTAL_12MHz) /* verified on pcb */
r11160r11161
19001908        6-7]    busy loop
19011909*/
19021910
1903static MACHINE_CONFIG_START( blazeon, driver_device )
1911static MACHINE_CONFIG_START( blazeon, kaneko16_state )
19041912
19051913   /* basic machine hardware */
19061914   MCFG_CPU_ADD("maincpu", M68000,12000000)   /* TMP68HC000-12 */
r11160r11161
19531961    VIDEO_UPDATE_AFTER_VBLANK fixes the mangled/wrong colored sprites
19541962*/
19551963
1956static MACHINE_CONFIG_START( gtmr, driver_device )
1964static MACHINE_CONFIG_START( gtmr, kaneko16_state )
19571965
19581966   /* basic machine hardware */
19591967   MCFG_CPU_ADD("gtmr", M68000, XTAL_16MHz)   /* verified on pcb */
r11160r11161
20412049                                Magical Crystal
20422050***************************************************************************/
20432051
2044static MACHINE_CONFIG_START( mgcrystl, driver_device )
2052static MACHINE_CONFIG_START( mgcrystl, kaneko16_state )
20452053
20462054   /* basic machine hardware */
20472055   MCFG_CPU_ADD("maincpu", M68000, XTAL_12MHz) /* verified on pcb */
r11160r11161
21032111#define SHOGWARR_INTERRUPTS_NUM   3
21042112static INTERRUPT_GEN( shogwarr_interrupt )
21052113{
2114   //kaneko16_state *state = device->machine().driver_data<kaneko16_state>();
21062115   switch ( cpu_getiloops(device) )
21072116   {
21082117      case 2:  device_set_input_line(device, 2, HOLD_LINE); break;
r11160r11161
21132122
21142123            calc3_mcu_run(device->machine());
21152124      break;
2116      /*case 0:
2117        {
2118            // hack, clear this ram address to get into test mode (interrupt would clear it)
2119            if (kaneko16_mainram[0x2dfe/2]==0xff00)
2120            {
2121                kaneko16_mainram[0x2dfe/2]=0x0000;
2122            }
2123
2124        }*/
2125#if 0
2126      case 0:
2127      {
2128         // hack, clear this ram address to get into test mode (interrupt would clear it)
2129         if (state->mainram[0x2dfe/2]==0xff00)
2130         {
2131            state->mainram[0x2dfe/2]=0x0000;
2132         }
2133           }
2134#endif
21252135   }
21262136}
21272137
r11160r11161
21592169   AM_RANGE(0x00000, 0x3ffff) AM_ROMBANK("bank11")
21602170ADDRESS_MAP_END
21612171
2162static MACHINE_CONFIG_START( shogwarr, driver_device )
2172static MACHINE_CONFIG_START( shogwarr, kaneko16_state )
21632173
21642174   /* basic machine hardware */
21652175   MCFG_CPU_ADD("maincpu", M68000, XTAL_12MHz)
r11160r11161
38433853
38443854static DRIVER_INIT( bloodwar )
38453855{
3846   machine.device<nvram_device>("nvram")->set_base(kaneko16_nvram_save, sizeof(kaneko16_nvram_save));
3856   kaneko16_state *state = machine.driver_data<kaneko16_state>();
3857   machine.device<nvram_device>("nvram")->set_base(state->m_nvram_save, sizeof(state->m_nvram_save));
38473858   DRIVER_INIT_CALL(samplebank);
38483859   DRIVER_INIT_CALL(decrypt_toybox_rom);
38493860}
38503861
38513862static DRIVER_INIT( gtmr2 )
38523863{
3853   machine.device<nvram_device>("nvram")->set_base(kaneko16_nvram_save, sizeof(kaneko16_nvram_save));
3864   kaneko16_state *state = machine.driver_data<kaneko16_state>();
3865   machine.device<nvram_device>("nvram")->set_base(state->m_nvram_save, sizeof(state->m_nvram_save));
38543866   DRIVER_INIT_CALL(samplebank);
38553867   DRIVER_INIT_CALL(decrypt_toybox_rom_alt);
38563868}
src/mame/drivers/gauntlet.c
r11160r11161
124124#include "sound/tms5220.h"
125125#include "sound/2151intf.h"
126126#include "sound/pokey.h"
127#include "video/atarimo.h"
127128#include "includes/gauntlet.h"
128129
129130
r11160r11161
325326
326327   /* VBUS */
327328   AM_RANGE(0x900000, 0x901fff) AM_MIRROR(0x2c8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(gauntlet_state, m_playfield)
328   AM_RANGE(0x902000, 0x903fff) AM_MIRROR(0x2c8000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
329   AM_RANGE(0x902000, 0x903fff) AM_MIRROR(0x2c8000) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
329330   AM_RANGE(0x904000, 0x904fff) AM_MIRROR(0x2c8000) AM_RAM
330331   AM_RANGE(0x905f6e, 0x905f6f) AM_MIRROR(0x2c8000) AM_RAM_WRITE(gauntlet_yscroll_w) AM_BASE_MEMBER(gauntlet_state, m_yscroll)
331332   AM_RANGE(0x905000, 0x905f7f) AM_MIRROR(0x2c8000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(gauntlet_state, m_alpha)
332   AM_RANGE(0x905f80, 0x905fff) AM_MIRROR(0x2c8000) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
333   AM_RANGE(0x905f80, 0x905fff) AM_MIRROR(0x2c8000) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
333334   AM_RANGE(0x910000, 0x9107ff) AM_MIRROR(0x2cf800) AM_RAM_WRITE(paletteram16_IIIIRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram)
334335   AM_RANGE(0x930000, 0x930001) AM_MIRROR(0x2cfffe) AM_WRITE(gauntlet_xscroll_w) AM_BASE_MEMBER(gauntlet_state, m_xscroll)
335336ADDRESS_MAP_END
src/mame/drivers/majorpkr.c
r0r11161
1/**********************************************************************************
2
3  Major Poker / Major Joker
4  1994 PAL System.
5
6  Driver by Roberto Fresca.
7
8
9  Special thanks to Tomasz Slanina & Rob Ragon for their invaluable help.
10
11***********************************************************************************
12
13  Hardware Notes:
14  --------------
15
16  1x Z80 @ 6 MHz. (main CPU)
17
18  1x M6295 @ 1.5 MHz. (4 channel mixing ADPCM voice synthesis). Pin7 high.
19
20  1x 6845 (CRT Controller) @ 750 kHz.
21        Hs 15625 Hz
22        Vs 52.786 Hz
23   
24  2x MB8464 (Video?)8kx8
25  1x MB8416 (NVRAM) 2Kx8
26  1x MB8464 (?) 8kx8
27
28  2x 27C040 (Roms P1 & P2) (GFX ROMs).
29  2x 27C010 (Roms 3 & 4) (GFX ROMs).
30  1x 27C020 (Rom 5) (sound)
31  1x 27C512 (Rom 6) (program)
32
33  1x Xtal @ 12 MHz.
34
35  4x 8 DIP switches banks.
36  2x switches (SW1, SW2).
37
38  1x 2x10-pin edge connector.
39  1x 2x22-pin edge connector.
40
41
42***********************************************************************************
43
44  PORTS:
45  ------
46
47  00  W ---> ROM bank.
48  01  W ---> RAM bank.
49  02  W ---> RAM bank.
50 
51  10 R  ---> Regular inputs (holds) multiplexed with credits out.
52  10  W ---> Writes a kind of watchdog (bit4) and mech counters pulses (bits 0-1-2-3).
53  11 R  ---> Read input port (remaining controls).
54  11  W ---> Writes mux selector.
55  12 R  ---> Read coin/credits port.
56  12  W ---> Video registers: Normal or Up Down screen (bit6 off/on). Also writes 0xFC & 0x11 at CRTC offsets 0x0C & 0x0D (0's if normal).
57  13 R  ---> Multiplexed port for DIP switches banks.
58  13  W ---> Lamps out (array a)
59  14 R  ---> Freeze. Switch in bit0 that pause the game when active. Just once active, the code loops till the bit resets.
60  14  W ---> Lamps out (array b).
61 
62  50 RW ---> OKI6295 (R/W)
63 
64  60  W ---> PSG SN76489/96 initialization routines. (Maybe a leftover for different hardware)
65             The offset is initialized with the following sequence: 0x9f, 0xbf, 0xdf, 0xff.
66
67
68  Pulses - Port 10h.
69  ------------------
70    - bits -
71    7654 3210
72    ---- ---x   Credits Out mech counter.
73    ---- --x-   Credits 3 mech counter.
74    ---- -x--   Credits 1 mech counter.
75    ---- x---   Credits 2 mech counter.
76    ---x ----   Watchdog? (constant writes). (*)
77    xxx- ----   Unknown.
78
79  (*) Tied to a ULN Opto Triac (pin3 solder side edge connector - Lock Out (100V))
80
81
82  Lamps - Array A - Port 13h.
83  ---------------------------
84    - bits -
85    7654 3210
86    ---- ---x   Hold 1 lamp.
87    ---- --x-   Hold 2 lamp.
88    ---- -x--   Hold 3 lamp.
89    ---- x---   Hold 4 lamp.
90    ---x ----   Hold 5 lamp.
91    --x- ----   Big lamp.
92    -x-- ----   Small lamp.
93    x--- ----   Unknown.
94
95
96  Lamps - Array B - Port 14h.
97  ---------------------------
98    - bits -
99    7654 3210
100    ---- ---x   Bet lamp.
101    ---- --x-   Draw lamp.
102    ---- -x--   Cancel lamp.
103    ---- x---   Take lamp.
104    ---x ----   Double-Up lamp.
105    --x- ----   Fever lamp.
106    xx-- ----   Unknown.
107
108***********************************************************************************
109
110  Instructions...
111  (translated from a Japanese flyer)
112
113  Bonus stage:
114  - 10 fever awarded by three of a kind of 1, 3, or 7.
115  - 15 fever awarded by four of a kind.
116
117  Slot stage:
118  - 10 bonus stage awarded by three consecutive 1, 3, or 7.
119  -  5 bonus stage awarded by four consecutive numbers other than 1, 3, or 7.
120
121  If bonus is awarded while you are in bonus stage, odds will be x4.
122  Bonus stage & slot stage: You can get triple & fourth fever points, and you
123  can challenge 3 or 4 times of double-up game by this point.
124
125  ....
126
127  Service Mode:
128 
129  F2 to enter the Book/Settings Mode.
130  HOLD1 to move UP.
131  HOLD2 to move DOWN.
132  HOLD3 to move LEFT.
133  HOLD4 to move RIGHT.
134  HOLD5 to move next screen / exit.
135
136  You can shortcut the DIP settings pressing "0" in Book Mode.
137  HOLD5 to exit.
138
139***********************************************************************************
140
141   Major Poker: Things that you should know!!! (from "engrish" manual)
142  -------------------------------------------------------------------
143
144  The game not stabilise until 10,000 games have been played. As a result, the
145  actual payout % may exceed the set payout % during this period. After the 10,000
146  games the machine will follow the set payout %.
147
148  Original game for your location.
149
150  Analyzer screen #1: Provides you with data regarding games played so far such as
151  numbers of games, number of fevers, etc...
152
153  Analyzer screen #2: Allows you to adjust various aspects of the game to suit your
154  location. For example you can increase the number of Fever (this does not affect
155  the payout %). Also you can make the dealing speed quicker or slower.
156
157  Even if you do not adjust the game it is ready to be played.
158
159
160  DIP Switches....
161
162  .-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----.
163  | DIP Switches #1               |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |
164  +-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----+
165  +-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----+
166  | OFF Fixed                     | OFF |                                         |
167  +-------------------------------+-----+-----+-----------------------------------+
168  | Screen Direction   Normal     |     | OFF |                                   |
169  |                    Up Down    |     | ON  |                                   |
170  +-------------------------------+-----+-----+-----+-----------------------------+
171  | Hopper             No         |           | OFF |                             |
172  |                    Yes        |           | ON  |                             |
173  +-------------------------------+-----------+-----+-----+-----------------------+
174  | Hopper SW Active   High       |                 | OFF |                       |
175  |                    Low        |                 | ON  |                       |
176  +-------------------------------+-----------------+-----+-----+-----------------+
177  | Coin Payout        Payout SW  |                       | OFF |                 |
178  |                    Automatic  |                       | ON  |                 |
179  +-------------------------------+-----------------------+-----+-----+-----------+
180  | Hold Cancel        No         |                             | OFF |           |
181  |                    Yes        |                             | ON  |           |
182  +-------------------------------+-----------------------------+-----+-----+-----+
183  | Auto Hold          No         |                                   | OFF |     |
184  |                    Yes        |                                   | ON  |     |
185  +-------------------------------+-----------------------------------+-----+-----+
186  | Fever Mode         Yes        |                                         | OFF |
187  |                    No         |                                         | ON  |
188  '-------------------------------+-----------------------------------------+-----'
189
190  .-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----.
191  | DIP Switches #2               |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |
192  +-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----+
193  +-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----+
194  | Payout %           95%        | OFF | OFF | OFF |                             |
195  |                    90%        | ON  | OFF | OFF |                             |
196  |                    85%        | OFF | ON  | OFF |                             |
197  |                    80%        | ON  | ON  | OFF |                             |
198  |                    75%        | OFF | OFF | ON  |                             |
199  |                    70%        | ON  | OFF | ON  |                             |
200  |                    65%        | OFF | ON  | ON  |                             |
201  |                    60%        | ON  | ON  | ON  |                             |
202  +-------------------------------+-----+-----+-----+-----+-----+-----------------+
203  | Min Bet size        1         |                 | OFF | OFF |                 |
204  | for Fever           3         |                 | ON  | OFF |                 |
205  |                     5         |                 | OFF | ON  |                 |
206  |                    10         |                 | ON  | ON  |                 |
207  +-------------------------------+-----------------+-----+-----+-----+-----+-----+
208  | Double-Up          Weak       |                             | OFF | OFF |     |
209  | Game Difficulty    ...        |                             | ON  | OFF |     |
210  |                    ...        |                             | OFF | ON  |     |
211  |                    Strong     |                             | ON  | ON  |     |
212  +-------------------------------+-----------------------------+-----+-----+-----+
213  | OFF Fixed                     |                                         | OFF |
214  '-------------------------------+-----------------------------------------+-----'
215
216  .-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----.
217  | DIP Switches #3               |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |
218  +-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----+
219  +-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----+
220  | Key In   1 Coin - 50 Credits  | OFF | OFF | OFF |                             |
221  |          1 Coin - 5 Credits   | ON  | OFF | OFF |                             |
222  |          1 Coin - 10 Credits  | OFF | ON  | OFF |                             |
223  |          1 Coin - 20 Credits  | ON  | ON  | OFF |                             |
224  |          1 Coin - 25 Credits  | OFF | OFF | ON  |                             |
225  |          1 Coin - 40 Credits  | ON  | OFF | ON  |                             |
226  |          1 Coin - 60 Credits  | OFF | ON  | ON  |                             |
227  |          1 Coin - 100 Credits | ON  | ON  | ON  |                             |
228  +-------------------------------+-----+-----+-----+-----+-----+-----+-----------+
229  | Coin-A   1 Coin - 5 Credits   |                 | OFF | OFF | OFF |           |
230  |          1 Coin - 1 Credit    |                 | ON  | OFF | OFF |           |
231  |          1 Coin - 2 Credits   |                 | OFF | ON  | OFF |           |
232  |          1 Coin - 10 Credits  |                 | ON  | ON  | OFF |           |
233  |          1 Coin - 20 Credits  |                 | OFF | OFF | ON  |           |
234  |          1 Coin - 25 Credits  |                 | ON  | OFF | ON  |           |
235  |          1 Coin - 40 Credits  |                 | OFF | ON  | ON  |           |
236  |          1 Coin - 50 Credits  |                 | ON  | ON  | ON  |           |
237  +-------------------------------+-----------------+-----+-----+-----+-----+-----+
238  | Credit Limit        5000      |                                   | OFF | OFF |
239  |                    10000      |                                   | ON  | OFF |
240  |                    20000      |                                   | OFF | ON  |
241  |                    30000      |                                   | ON  | ON  |
242  '-------------------------------+-----------------------------------+-----+-----'
243
244  .-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----.
245  | DIP Switches #4               |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |
246  +-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----+
247  +-------------------------------+-----+-----+-----+-----+-----+-----+-----+-----+
248  | Coin-B   1 Coin - 50 Credits  | OFF | OFF | OFF | OFF |                       |
249  |          1 Coin - 1 Credit    | ON  | OFF | OFF | OFF |                       |
250  |          1 Coin - 2 Credits   | OFF | ON  | OFF | OFF |                       |
251  |          1 Coin - 4 Credits   | ON  | ON  | OFF | OFF |                       |
252  |          1 Coin - 5 Credits   | OFF | OFF | ON  | OFF |                       |
253  |          1 Coin - 10 Credits  | ON  | OFF | ON  | OFF |                       |
254  |          1 Coin - 20 Credits  | OFF | ON  | ON  | OFF |                       |
255  |          1 Coin - 25 Credits  | ON  | ON  | ON  | OFF |                       |
256  |          1 Coin - 100 Credits | OFF | OFF | OFF | ON  |                       |
257  |          2 Coins - 1 Credit   | ON  | OFF | OFF | ON  |                       |
258  |          2 Coins - 5 Credits  | OFF | ON  | OFF | ON  |                       |
259  |          4 Coins - 1 Credit   | ON  | ON  | OFF | ON  |                       |
260  |          5 Coins - 1 Credit   | OFF | OFF | ON  | ON  |                       |
261  |          5 Coins - 2 Credits  | ON  | OFF | ON  | ON  |                       |
262  |          10 Coins - 1 Credit  | OFF | ON  | ON  | ON  |                       |
263  |          20 Coins - 1 Credit  | ON  | ON  | ON  | ON  |                       |
264  +-------------------------------+-----+-----+-----+-----+-----+-----+-----------+
265  | Max Bet            20         |                       | OFF | OFF |           |
266  |                    10         |                       | ON  | OFF |           |
267  |                    30         |                       | OFF | ON  |           |
268  |                    50         |                       | ON  | ON  |           |
269  +-------------------------------+-----------------------+-----+-----+-----+-----+
270  | Credit-In Limit    No Limit   |                                   | OFF | OFF |
271  |                    1000       |                                   | ON  | OFF |
272  |                    2000       |                                   | OFF | ON  |
273  |                    5000       |                                   | ON  | ON  |
274  '-------------------------------+-----------------------------------+-----+-----'
275
276
277***********************************************************************************
278
279  Power Supply edge connector Layout...
280 
281  .-----------------------+-+--+---------------------------.
282  |       Components side |L|PN| Solder side               |
283  +-----------------------+-+--+---------------------------+
284  |                   GND |A|01| GND                       |
285  |                   GND |B|02| GND                       |
286  |                   +5V |C|03| +5V                       |
287  |                   +5V |D|04| +5V                       |
288  |              Lamp BET |E|05| Lamp HOLD 1               |
289  |                  +12V |F|06| +12V                      |
290  |             Lamp DEAL |H|07| Lamp HOLD 2               |
291  |           Lamp CANCEL |J|08| Lamp HOLD 3               |
292  |       Lamp TAKE SCORE |K|09| Lamp HOLD 4               |
293  |        Lamp DOUBLE UP |L|10| Lamp HOLD 5               |
294  '-----------------------+-+--+---------------------------'
295 
296  Edge connector Layout...
297
298  .-----------------------+-+--+---------------------------.
299  |       Components side |L|PN| Solder side               |
300  +-----------------------+-+--+---------------------------+
301  |           Out Counter |A|01| AC 100V In                |
302  |        Key In Counter |B|02| AC Out to Hopper          |
303  |     Coin In Counter A |C|03| Lock Out (100V)           |
304  |             Sound GND |D|04| Sound Out                 |
305  |        HOLD 5 / SMALL |E|05| Payout                    |
306  |                Key In |F|06| HOLD 2                    |
307  |                HOLD 3 |H|07| Coin B In                 |
308  |                HOLD 4 |J|08| HOLD 1 / BIG              |
309  |                       |K|09| RED (TV)                  |
310  |                       |L|10| GREEN (TV)                |
311  |            TAKE SCORE |M|11| Sync (TV)                 |
312  |             DOUBLE UP |N|12| BLUE (TV)                 |
313  |             Coin A In |P|13| DEAL                      |
314  |                CANCEL |R|14| Analyzer (Books/Settings) |
315  |  * SW2 (Clear Meters) |S|15| BET                       |
316  |       Coin In Counter |T|16| Out of Fever Lamp         |
317  |                ** GND |U|17| GND **                    |
318  |                ** GND |V|18| GND **                    |
319  |                       |W|19| GND                       |
320  |                       |X|20|                           |
321  |     Hopper Limited SW |Y|21| Hopper Payout             |
322  |                       |Z|22|                           |
323  '-----------------------+-+--+---------------------------'
324
325  *   Soft SW2 Extension. Traced (undocumented).
326  **  Edge connector pins U, V, 17 and 18 (GND), are tied
327      to Power Supply edge connector pins A, B, 01 and 02.
328
329***********************************************************************************
330
331  Book / Settings Mode:
332  ---------------------
333
334  First Screen (Books & Meters):
335
336  5C     0         F5C     0
337  RF     0         FRF     0
338  SF     0         FSF     0
339  4C     0         F4C     0
340  FH     0         FFH     0
341  FL     0         FFL     0
342  ST     0         FST     0
343  3C     0         F3C     0
344  2P     0         F2P     0
345
346  MAIN GAMES               0
347  FEVER GAMES              0
348  FEVER OUT                0
349  S-FEVER GAMES            0
350  S-FEVER OUT              0
351  TOTAL BET                0
352  TOTAL SCORE              0
353  SCORE%BET                0%
354  W-UP IN                  0
355  W-UP OUT                 0
356  W-UP OUT%IN              0%
357  CREDIT IN                0
358  CREDIT OUT               0
359  CREDIT OUT%IN            0%
360  DOWN COUNT               0
361  TOTAL-CREDIT IN          0
362  TOTAL-CREDIT OUT         0
363  TOTAL-CREDIT IN/OUT      0
364
365  DATA RESET: In this first screen, press the SW2 to clear all data,
366  except for the Total Credits meters.
367
368
369  Second Screen (Settings):
370
371                  MIN                NTL                MAX
372  FEVER           --------------------*--------------------
373  5 CARD          --------------------*--------------------
374  ROYAL           --------------------*--------------------
375  STR-FLUSH       --------------------*--------------------
376  4 CARD          --------------------*--------------------
377  FULL HOUSE      --------------------*--------------------
378  FLUSH           --------------------*--------------------
379  STRAIGHT        --------------------*--------------------
380  3 CARD          --------------------*--------------------
381  2 PAIR          --------------------*--------------------
382  NORMAL JKR      --------------------*--------------------
383  FEVER JKR       --------------------*--------------------
384  DEAL SPEED      --------------------*--------------------
385                  difficult appear              easy appear
386
387  HOLD 1 (Up)
388  HOLD 2 (Down)
389  HOLD 3 (Left)
390  HOLD 4 (Right)
391  HOLD 5 (Next)
392
393
394  Third Screen (Settings):
395
396  Memory Switches...
397
398  DEALER                OFF  ON         <--- Girl Dealer.
399  FVR-ANIMATION         OFF  ON         <--- Fever Screen animation.
400  DUP-NUDE              OFF  ON         <--- Double-Up Nude.
401  SLOW-ACTION           OFF  ON         <--- Speed of Cards.
402  KEY-LOCK              OFF  ON         <--- Lock settings leaving only Books. Other revisions may have "JQKA-1PAIR" (Jacks or Better).
403  FVR-SLOT              OFF  ON         <--- Fever's number slot.
404  AMUSEMENT-MODE        OFF  ON         <--- Self explanatory....
405
406  1ST BET           1  5  10  20  30    <--- First Bet.
407  CNT BET           1  5  10  20  30    <--- Second Bet.
408
409  BACK-RGB R        0 1 2 3 4 5 6 7     <--- Background R component (0 = light, 7 = strong)
410  BACK-RGB G        0 1 2 3 4 5 6 7     <--- Background G component (0 = light, 7 = strong)
411  BACK-RGB B        0 1 2 3 4 5 6 7     <--- Background B component (0 = light, 7 = strong)
412
413  BACK-PATTERN      0 1 2 3 4 5 6       <--- Background Pattern (0 = None, 1-6 available when dealer is off)
414
415  HOLD 1 (Up)
416  HOLD 2 (Down)
417  HOLD 3 (Off)
418  HOLD 4 (On)
419  HOLD 5 (Exit)
420
421
422  Fourth Screen (DIP switches test):
423
424  DIP Switch test...
425
426  DIPSW-1    00000000    00000000
427  DIPSW-2    00000000    00000000
428  DIPSW-3    00000000    00000000
429  DIPSW-4    00000000    00000000
430
431  HOLD 5 (Exit)
432
433  Created of DIP Switch (Green)       <--- ?????
434  Test Mode of DIP Switch (White)     <--- Show on the fly each DIP switch state.
435
436***********************************************************************************
437
438  To Do:
439 
440  - Find the input that unlocks the "KEY-LOCK" mode in the settings.
441  - Proper flip mode.
442  - Resistors Network.
443
444**********************************************************************************/
445
446#define MASTER_CLOCK   XTAL_12MHz
447#define CPU_CLOCK      (MASTER_CLOCK / 2)   /* 6 MHz, measured */
448#define OKI_CLOCK      (MASTER_CLOCK / 8)   /* 1.5 MHz, measured */
449#define CRTC_CLOCK      (MASTER_CLOCK / 16)   /* 750 kHz, measured */
450
451#include "emu.h"
452#include "cpu/z80/z80.h"
453#include "video/mc6845.h"
454#include "sound/okim6295.h"
455#include "machine/nvram.h"
456#include "majorpkr.lh"
457
458
459class majorpkr_state : public driver_device
460{
461public:
462   majorpkr_state(running_machine &machine, const driver_device_config_base &config) : driver_device(machine, config), oki(*this, "oki") { }
463
464   int m_mux_data;
465   int   m_palette_bank;
466   int m_vram_bank;
467   int m_flip_state;
468   
469   tilemap_t    *m_bg_tilemap,   *m_fg_tilemap;
470
471   UINT8 *m_videoram;
472   
473   required_device<okim6295_device> oki;
474
475};
476
477
478/*************************
479*     Video Hardware     *
480*************************/
481
482static TILE_GET_INFO( bg_get_tile_info )
483{
484   majorpkr_state *state = machine.driver_data<majorpkr_state>();
485   
486   int code = state->m_videoram[0x800 + 2 * tile_index] + (state->m_videoram[0x800 + 2 * tile_index + 1] << 8);
487   
488   SET_TILE_INFO(
489         0,
490         (code & 0x1fff),
491         code >> 13,
492         0);
493}
494
495static TILE_GET_INFO( fg_get_tile_info )
496{
497   majorpkr_state *state = machine.driver_data<majorpkr_state>();
498
499   int code = state->m_videoram[2 * tile_index] + (state->m_videoram[2 * tile_index + 1] << 8);
500   
501   SET_TILE_INFO(
502         1,
503         (code & 0x07ff),
504         code >> 13,
505         (code & (1 << 12)) ? (TILE_FLIPX|TILE_FLIPY) : 0);
506}
507
508
509static VIDEO_START(majorpkr)
510{
511   majorpkr_state *state = machine.driver_data<majorpkr_state>();
512   
513   state->m_bg_tilemap = tilemap_create(machine, bg_get_tile_info, tilemap_scan_rows, 16, 8, 36, 28);
514   state->m_fg_tilemap = tilemap_create(machine, fg_get_tile_info, tilemap_scan_rows, 16, 8, 36, 28);
515   tilemap_set_transparent_pen(state->m_fg_tilemap, 0);
516   
517   state->machine().generic.paletteram.u8 = auto_alloc_array(machine, UINT8, 4 * 0x800);
518
519   state->m_videoram = auto_alloc_array(machine, UINT8, 4 * 0x800); /* 2 banks in use, but the game clears 4 after boot ... */
520}
521
522
523static SCREEN_UPDATE(majorpkr)
524{
525   majorpkr_state *state = screen->machine().driver_data<majorpkr_state>();
526   
527   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine()));
528
529   rectangle custom_clip;
530
531   /* The following custom_clip is to exclude the last char column (unused)
532       form the render. We need more proof about how the video is working.
533    */
534   custom_clip.min_x=cliprect->min_x;
535//   custom_clip.max_x=cliprect->max_x-16;
536   custom_clip.max_x=cliprect->max_x;
537   custom_clip.min_y=cliprect->min_y;
538   custom_clip.max_y=cliprect->max_y;
539
540   tilemap_draw(bitmap, &custom_clip, state->m_bg_tilemap, 0, 0);
541   tilemap_draw(bitmap, &custom_clip, state->m_fg_tilemap, 0, 0);
542
543   if (state->m_flip_state == 1)
544   {
545      tilemap_set_flip(state->m_bg_tilemap, TILEMAP_FLIPX | TILEMAP_FLIPY);
546      tilemap_set_flip(state->m_fg_tilemap, TILEMAP_FLIPX | TILEMAP_FLIPY);
547   }
548
549   return 0;
550}
551
552
553/******************************
554*         R/W Handlers        *
555******************************/
556
557static WRITE8_HANDLER(rom_bank_w)
558{
559   memory_set_bank(space->machine(), "rom_bank", data & 0x3);
560}
561
562
563static WRITE8_HANDLER(palette_bank_w)
564{
565   majorpkr_state *state = space->machine().driver_data<majorpkr_state>();
566   
567   state->m_palette_bank=data;
568}
569
570
571static READ8_HANDLER(paletteram_r)
572{
573   majorpkr_state *state = space->machine().driver_data<majorpkr_state>();
574   return state->machine().generic.paletteram.u8[state->m_palette_bank * 0x800 + offset];
575}
576
577static WRITE8_HANDLER(paletteram_w)
578{
579   majorpkr_state *state = space->machine().driver_data<majorpkr_state>();
580   state->machine().generic.paletteram.u8[state->m_palette_bank * 0x800 + offset] = data;
581
582   offset >>= 1;
583   int color = state->machine().generic.paletteram.u8[state->m_palette_bank * 0x800 + offset * 2] + state->machine().generic.paletteram.u8[state->m_palette_bank * 0x800 + offset * 2 + 1] * 256;
584   palette_set_color(space->machine(), offset + state->m_palette_bank * 256 * 4, MAKE_RGB(pal5bit(color >> 5), pal5bit(color >> 10), pal5bit(color)));
585}
586
587
588static WRITE8_HANDLER(vram_bank_w)
589{
590   majorpkr_state *state = space->machine().driver_data<majorpkr_state>();
591   state->m_vram_bank = data;
592}
593
594static READ8_HANDLER(vram_r)
595{
596   majorpkr_state *state = space->machine().driver_data<majorpkr_state>();
597   return state->m_videoram[state->m_vram_bank * 0x800 + offset];
598}
599
600static WRITE8_HANDLER(vram_w)
601{
602   majorpkr_state *state = space->machine().driver_data<majorpkr_state>();
603   state->m_videoram[state->m_vram_bank * 0x800 + offset] = data;
604
605   if (state->m_vram_bank == 0)
606   {
607      tilemap_mark_tile_dirty(state->m_fg_tilemap, offset >> 1);
608   }
609   else
610   {
611      if (state->m_vram_bank == 1)
612      {
613         tilemap_mark_tile_dirty(state->m_bg_tilemap, offset >> 1);
614      }
615      else
616      {
617         //logerror("accessing vram bank %d (offset = %x , data = %x )\n", state->m_vram_bank, offset,data);
618      }
619   }
620}
621
622static WRITE8_HANDLER(vidreg_w)
623{
624   majorpkr_state *state = space->machine().driver_data<majorpkr_state>();
625
626/*  If bit6 is active, the screen is drawn upside down.
627    (also 0xfc and 0x11 are written to the CRTC registers 0xc0 and 0xd0)
628   So, the CRTC display start address = 0xfc11
629*/   
630   if (data & 0x40)
631   {
632      /* upside down screen */
633      state->m_flip_state = 1;
634   }
635   
636/*  If bit6 is not active, the screen is drawn normally.
637    (also 0x00 is written to the CRTC registers 0xc0 and 0xd0)
638   So, the CRTC display start address = 0x0000
639*/   
640   else
641   {
642      /* normal screen */
643      state->m_flip_state = 0;
644   }
645}
646
647
648/***** Multiplexed Ports *****/
649
650static READ8_HANDLER( mux_port_r )
651{
652   majorpkr_state *state = space->machine().driver_data<majorpkr_state>();
653   
654   switch( (state->m_mux_data & 0xf0) )      /* 00-10-20-30-0F-1F-2F-3F */
655   {
656      case 0x00: return input_port_read(space->machine(), "DSW1");   /* confirmed */
657      case 0x10: return input_port_read(space->machine(), "DSW2");   /* confirmed */
658      case 0x20: return input_port_read(space->machine(), "DSW3");   /* confirmed */
659      case 0x30: return input_port_read(space->machine(), "DSW4");   /* confirmed */
660   }
661   
662   return 0xff;
663}
664
665static READ8_HANDLER( mux_port2_r )
666{
667   majorpkr_state *state = space->machine().driver_data<majorpkr_state>();
668   
669   if ((state->m_mux_data & 0x0f) == 4)
670   {
671      return input_port_read(space->machine(), "IN0-1");
672   }
673   else
674   {
675      return input_port_read(space->machine(), "IN0-0");
676   }
677}
678   
679static WRITE8_HANDLER( mux_sel_w )
680{
681   majorpkr_state *state = space->machine().driver_data<majorpkr_state>();
682
683   state->m_mux_data = data;   /* 00-10-20-30-0F-1F-2F-3F */
684}
685
686
687/*************************
688*    Lamps and Pulses    *
689*************************/
690
691static WRITE8_HANDLER( lamps_a_w )
692{
693/*  Lamps - Array A.
694
695    - bits -
696    7654 3210
697    ---- ---x   Hold 1 lamp.
698    ---- --x-   Hold 2 lamp.
699    ---- -x--   Hold 3 lamp.
700    ---- x---   Hold 4 lamp.
701    ---x ----   Hold 5 lamp.
702    --x- ----   Big lamp.
703    -x-- ----   Small lamp.
704    x--- ----   Unknown.
705*/
706   output_set_lamp_value(0, (data) & 1);      /* Lamp 0: Hold 1 */
707   output_set_lamp_value(1, (data >> 1) & 1);   /* Lamp 1: Hold 2 */
708   output_set_lamp_value(2, (data >> 2) & 1);   /* Lamp 2: Hold 3 */
709   output_set_lamp_value(3, (data >> 3) & 1);   /* Lamp 3: Hold 4 */
710   output_set_lamp_value(4, (data >> 4) & 1);   /* Lamp 4: Hold 5 */
711   output_set_lamp_value(5, (data >> 5) & 1);   /* Lamp 5: Big or Small (need identification) */
712   output_set_lamp_value(6, (data >> 6) & 1);   /* Lamp 6: Big or Small (need identification) */
713
714   if (data & 0x80)
715      logerror("Lamps A: Write to 13h: %02x\n", data);
716}
717
718static WRITE8_HANDLER( lamps_b_w )
719{
720/*  Lamps - Array B.
721
722    - bits -
723    7654 3210
724    ---- ---x   Bet lamp.
725    ---- --x-   Draw lamp.
726    ---- -x--   Cancel lamp.
727    ---- x---   Take lamp.
728    ---x ----   Double-Up lamp.
729    --x- ----   Fever lamp.
730    xx-- ----   Unknown.
731*/
732   output_set_lamp_value(7, (data) & 1);      /* Lamp 7: Bet */
733   output_set_lamp_value(8, (data >> 1) & 1);   /* Lamp 8: Draw */
734   output_set_lamp_value(9, (data >> 2) & 1);   /* Lamp 9: Cancel */
735   output_set_lamp_value(10, (data >> 3) & 1);   /* Lamp 10: Take */
736   output_set_lamp_value(11, (data >> 4) & 1);   /* Lamp 11: D-UP */
737   output_set_lamp_value(12, (data >> 5) & 1);   /* Lamp 12: Fever */
738   
739   if (data & 0xc0)
740      logerror("Lamps B: Write to 14h: %02x\n", data);
741}
742
743static WRITE8_HANDLER( pulses_w )
744{
745/*  Pulses...
746
747    - bits -
748    7654 3210
749    ---- ---x   Credits Out mech counter.
750    ---- --x-   Credits 3 mech counter.
751    ---- -x--   Credits 1 mech counter.
752    ---- x---   Credits 2 mech counter.
753    ---x ----   Watchdog? (constant writes).
754    xxx- ----   Unknown.
755*/
756   coin_counter_w(space->machine(), 3, data & 0x01);      /* Credits Out (all) */
757   coin_counter_w(space->machine(), 2, data & 0x02);      /* Credits 3 */
758   coin_counter_w(space->machine(), 0, data & 0x04);      /* Credits 1 */
759   coin_counter_w(space->machine(), 1, data & 0x08);      /* Credits 2 */
760
761   if (data & 0xe0)
762      logerror("Pulse: Write to 10h: %02x\n", data);
763}
764
765
766/*************************
767* Memory map information *
768*************************/
769
770static ADDRESS_MAP_START( map, AS_PROGRAM, 8 )
771   AM_RANGE(0x0000, 0xdfff) AM_ROM
772   AM_RANGE(0xe000, 0xe7ff) AM_ROM AM_ROMBANK("rom_bank")
773   AM_RANGE(0xe800, 0xefff) AM_RAM AM_SHARE("nvram")
774   AM_RANGE(0xf000, 0xf7ff) AM_READWRITE(paletteram_r, paletteram_w)   /* 4*4 palettes - 4 banks? */
775   AM_RANGE(0xf800, 0xffff) AM_READWRITE(vram_r, vram_w)            /* two tilemaps - 2 banks? */
776ADDRESS_MAP_END
777
778/*
779  00  W ---> ROM bank.
780  01  W ---> RAM bank.
781  02  W ---> RAM bank.
782 
783  10 R  ---> Regular inputs (holds) multiplexed with credits out.
784  10  W ---> Writes a kind of watchdog (bit4) and mech counters pulses (bits 0-1-2-3).
785  11 R  ---> Read input port (remaining controls).
786  11  W ---> Writes mux selector.
787  12 R  ---> Read coin/credits port.
788  12  W ---> Video registers: Normal or Up Down screen (bit6 off/on). Also writes 0xFC & 0x11 at CRTC offsets 0x0C & 0x0D (0's if normal).
789  13 R  ---> Multiplexed port for DIP switches banks.
790  13  W ---> Lamps out (array a)
791  14 R  ---> Freeze. Switch in bit0 that pause the game when active. Just once active, the code loops till the bit resets.
792  14  W ---> Lamps out (array b).
793 
794  50 RW ---> OKI6295 (RW)
795 
796  60  W ---> PSG SN76489/96 initialization routines.
797             (Maybe a leftover for different hardware).
798*/
799static ADDRESS_MAP_START( portmap, AS_IO, 8 )
800   ADDRESS_MAP_GLOBAL_MASK(0xff)
801   AM_RANGE(0x00, 0x00) AM_WRITE(rom_bank_w)
802   AM_RANGE(0x01, 0x01) AM_WRITE(palette_bank_w)
803   AM_RANGE(0x02, 0x02) AM_WRITE(vram_bank_w)
804   
805   AM_RANGE(0x10, 0x10) AM_READ(mux_port2_r)   /* muxed set of controls */
806   AM_RANGE(0x10, 0x10) AM_WRITE(pulses_w)      /* kind of watchdog on bit4... mech counters on bits 0-1-2-3 */
807   AM_RANGE(0x11, 0x11) AM_READ_PORT("IN1")
808   AM_RANGE(0x11, 0x11) AM_WRITE(mux_sel_w)   /* multiplexer selector */
809   AM_RANGE(0x12, 0x12) AM_READ_PORT("IN2")
810   AM_RANGE(0x12, 0x12) AM_WRITE(vidreg_w)      /* video registers: normal or up down screen */
811   AM_RANGE(0x13, 0x13) AM_READ(mux_port_r)   /* all 4 DIP switches banks multiplexed */
812   AM_RANGE(0x13, 0x13) AM_WRITE(lamps_a_w)   /* lamps a out */
813   AM_RANGE(0x14, 0x14) AM_READ_PORT("TEST")   /* "freeze" switch */
814   AM_RANGE(0x14, 0x14) AM_WRITE(lamps_b_w)   /* lamps b out */
815
816//   AM_RANGE(0x30, 0x30) AM_DEVWRITE("crtc", mc6845_address_w)
817//   AM_RANGE(0x31, 0x31) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
818
819   AM_RANGE(0x50, 0x50) AM_DEVREADWRITE_MODERN("oki", okim6295_device, read, write)
820   AM_RANGE(0x60, 0x60) AM_WRITENOP   /* leftover from a PSG SN76489/96? */
821ADDRESS_MAP_END
822
823
824/*************************
825*      Input ports       *
826*************************/
827
828static INPUT_PORTS_START( majorpkr )
829   PORT_START("IN0-0")
830   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_POKER_HOLD1 )
831   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_POKER_HOLD2 )   /* muxed with Key Out */
832   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_POKER_HOLD3 )
833   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_POKER_HOLD4 )
834   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_POKER_HOLD5 )
835   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_POKER_CANCEL )
836   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_GAMBLE_HIGH )  PORT_NAME("Big")
837   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_GAMBLE_LOW )   PORT_NAME("Small / DIP Test (In Book Mode)")
838
839   PORT_START("IN0-1")
840   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_GAMBLE_KEYOUT )   /* muxed with HOLD 2 */
841   PORT_BIT( 0xfd, IP_ACTIVE_HIGH, IPT_UNKNOWN )
842
843   PORT_START("IN1")
844   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_POKER_BET )
845   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_GAMBLE_DEAL )
846   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_GAMBLE_D_UP )
847   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_GAMBLE_TAKE )
848   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SERVICE )       PORT_NAME("Book/Settings Mode")
849   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_GAMBLE_PAYOUT )
850   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_OTHER )         PORT_CODE(KEYCODE_1_PAD)  PORT_NAME("UNK 1-PAD")
851   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_OTHER )         PORT_CODE(KEYCODE_2_PAD)  PORT_NAME("UNK 2-PAD")
852
853   PORT_START("IN2")
854   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
855   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 )
856   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_GAMBLE_KEYIN)
857   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SERVICE )       PORT_CODE(KEYCODE_0)      PORT_NAME("SW2 (Clear Short-Term Meters)")
858   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OTHER )         PORT_CODE(KEYCODE_4_PAD)  PORT_NAME("UNK 4-PAD")
859   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE )       PORT_CODE(KEYCODE_E)      PORT_NAME("Manual Payout")
860   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_OTHER )         PORT_CODE(KEYCODE_5_PAD)  PORT_NAME("UNK 5-PAD")
861   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_OTHER )         PORT_CODE(KEYCODE_6_PAD)  PORT_NAME("UNK 6-PAD")
862
863   PORT_START("DSW1")   /* multiplexed x4 & inverted */
864   PORT_DIPNAME( 0x01, 0x00, "OFF Fixed" )         PORT_DIPLOCATION("DSW1:1")
865   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
866   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
867   PORT_DIPNAME( 0x02, 0x00, "Screen Direction" )   PORT_DIPLOCATION("DSW1:2")   /* Activates bit6 at port 0x10 & change CRTC registers */
868   PORT_DIPSETTING(    0x00, DEF_STR( Normal ) )
869   PORT_DIPSETTING(    0x02, "Up Down" )
870   PORT_DIPNAME( 0x04, 0x00, "Payout" )         PORT_DIPLOCATION("DSW1:3")   /* Hopper: No / Yes (in the manual) */
871   PORT_DIPSETTING(    0x00, "Automatic" )
872   PORT_DIPSETTING(    0x04, "Manual" )
873   PORT_DIPNAME( 0x08, 0x00, "Hopper SW Active" )   PORT_DIPLOCATION("DSW1:4")
874   PORT_DIPSETTING(    0x00, DEF_STR( High ) )
875   PORT_DIPSETTING(    0x08, DEF_STR( Low ) )
876   PORT_DIPNAME( 0x10, 0x00, "Auto Max Bet" )      PORT_DIPLOCATION("DSW1:5")   /* Coin Payout: Payout SW / Automatic (in the manual) */
877   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
878   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
879   PORT_DIPNAME( 0x20, 0x20, "Hold Cancel" )      PORT_DIPLOCATION("DSW1:6")   /* Inverse from the manual */
880   PORT_DIPSETTING(    0x20, DEF_STR( No ) )
881   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
882   PORT_DIPNAME( 0x40, 0x40, "Auto Hold" )         PORT_DIPLOCATION("DSW1:7")
883   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
884   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
885   PORT_DIPNAME( 0x80, 0x00, "Fever Mode" )      PORT_DIPLOCATION("DSW1:8")
886   PORT_DIPSETTING(    0x80, DEF_STR( No ) )
887   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
888
889   PORT_START("DSW2")   /* multiplexed x4 & inverted */
890   PORT_DIPNAME( 0x07, 0x00, "Payout %" )               PORT_DIPLOCATION("DSW2:1,2,3")
891   PORT_DIPSETTING(    0x07, "60%" )
892   PORT_DIPSETTING(    0x06, "65%" )
893   PORT_DIPSETTING(    0x05, "70%" )
894   PORT_DIPSETTING(    0x04, "75%" )
895   PORT_DIPSETTING(    0x03, "80%" )
896   PORT_DIPSETTING(    0x02, "85%" )
897   PORT_DIPSETTING(    0x01, "90%" )
898   PORT_DIPSETTING(    0x00, "95%" )
899   PORT_DIPNAME( 0x18, 0x00, "Min Bet Size for Fever" )   PORT_DIPLOCATION("DSW2:4,5")
900   PORT_DIPSETTING(    0x00, "1" )
901   PORT_DIPSETTING(    0x08, "3" )
902   PORT_DIPSETTING(    0x10, "5" )
903   PORT_DIPSETTING(    0x18, "10" )
904   PORT_DIPNAME( 0x60, 0x00, "D-UP Game Difficulty" )      PORT_DIPLOCATION("DSW2:6,7")
905   PORT_DIPSETTING(    0x00, "0 (Weak)" )
906   PORT_DIPSETTING(    0x20, "1" )
907   PORT_DIPSETTING(    0x40, "2" )
908   PORT_DIPSETTING(    0x60, "3 (Strong)" )
909   PORT_DIPNAME( 0x80, 0x00, "OFF Fixed" )               PORT_DIPLOCATION("DSW2:8")
910   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
911   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
912
913   PORT_START("DSW3")   /* multiplexed x4 & inverted */
914   PORT_DIPNAME( 0x07, 0x00, "Key In" )            PORT_DIPLOCATION("DSW3:1,2,3")
915   PORT_DIPSETTING(    0x01, "5 Credits / Pulse" )
916   PORT_DIPSETTING(    0x02, "10 Credits / Pulse" )
917   PORT_DIPSETTING(    0x03, "20 Credits / Pulse" )
918   PORT_DIPSETTING(    0x04, "25 Credits / Pulse" )
919   PORT_DIPSETTING(    0x05, "40 Credits / Pulse" )
920   PORT_DIPSETTING(    0x00, "50 Credits / Pulse" )
921   PORT_DIPSETTING(    0x06, "60 Credits / Pulse" )
922   PORT_DIPSETTING(    0x07, "100 Credits / Pulse" )
923   PORT_DIPNAME( 0x38, 0x00, DEF_STR( Coin_A ) )      PORT_DIPLOCATION("DSW3:4,5,6")
924   PORT_DIPSETTING(    0x08, DEF_STR( 1C_1C ) )
925   PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
926   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )
927   PORT_DIPSETTING(    0x18, "1 Coin/10 Credits" )
928   PORT_DIPSETTING(    0x20, "1 Coin/20 Credits" )
929   PORT_DIPSETTING(    0x28, "1 Coin/25 Credits" )
930   PORT_DIPSETTING(    0x30, "1 Coin/40 Credits" )
931   PORT_DIPSETTING(    0x38, "1 Coin/50 Credits" )
932   PORT_DIPNAME( 0xc0, 0x00, "Credit Limit" )         PORT_DIPLOCATION("DSW3:7,8")
933   PORT_DIPSETTING(    0x00, "5000" )
934   PORT_DIPSETTING(    0x40, "10000" )
935   PORT_DIPSETTING(    0x80, "20000" )
936   PORT_DIPSETTING(    0xc0, "30000" )
937
938   PORT_START("DSW4")   /* multiplexed x4 & inverted */
939   PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Coin_B ) )      PORT_DIPLOCATION("DSW4:1,2,3,4")
940   PORT_DIPSETTING(    0x0f, "20 Coins/1 Credit" )
941   PORT_DIPSETTING(    0x0e, "10 Coins/1 Credit" )
942   PORT_DIPSETTING(    0x0c, DEF_STR( 5C_1C ) )
943   PORT_DIPSETTING(    0x0b, DEF_STR( 4C_1C ) )
944   PORT_DIPSETTING(    0x0d, "5 Coins/2 Credits" )
945   PORT_DIPSETTING(    0x09, DEF_STR( 2C_1C ) )
946   PORT_DIPSETTING(    0x01, DEF_STR( 1C_1C ) )
947   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
948   PORT_DIPSETTING(    0x0a, DEF_STR( 2C_5C ) )
949   PORT_DIPSETTING(    0x03, DEF_STR( 1C_4C ) )
950   PORT_DIPSETTING(    0x04, DEF_STR( 1C_5C ) )
951   PORT_DIPSETTING(    0x05, "1 Coin/10 Credits" )
952   PORT_DIPSETTING(    0x06, "1 Coin/20 Credits" )
953   PORT_DIPSETTING(    0x07, "1 Coin/25 Credits" )
954   PORT_DIPSETTING(    0x00, "1 Coin/50 Credits" )
955   PORT_DIPSETTING(    0x08, "1 Coin/100 Credits" )
956   PORT_DIPNAME( 0x30, 0x00, "Max Bet" )            PORT_DIPLOCATION("DSW4:5,6")
957   PORT_DIPSETTING(    0x10, "10" )
958   PORT_DIPSETTING(    0x00, "20" )
959   PORT_DIPSETTING(    0x20, "30" )
960   PORT_DIPSETTING(    0x30, "50" )
961   PORT_DIPNAME( 0xc0, 0x00, "Credit-In Limit" )      PORT_DIPLOCATION("DSW4:7,8")
962   PORT_DIPSETTING(    0x00, "No Limit" )
963   PORT_DIPSETTING(    0x40, "1000" )
964   PORT_DIPSETTING(    0x80, "2000" )
965   PORT_DIPSETTING(    0xc0, "5000" )
966
967   PORT_START("TEST")
968   PORT_DIPNAME( 0x01, 0x00, "Freeze" )      /* Freeze the execution */
969   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
970   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
971   PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNKNOWN )
972INPUT_PORTS_END
973
974
975/*************************
976*    Graphics Layouts    *
977*************************/
978
979static const gfx_layout tilelayout =
980{
981   16, 8,
982   RGN_FRAC(1,2),
983   8,
984   { 0, 1, 2, 3, 4, 5, 6, 7 },
985   {
986      0*8, 0*8+RGN_FRAC(1,2), 1*8, 1*8+RGN_FRAC(1,2), 2*8, 2*8+RGN_FRAC(1,2), 3*8, 3*8+RGN_FRAC(1,2),
987      4*8, 4*8+RGN_FRAC(1,2), 5*8, 5*8+RGN_FRAC(1,2), 6*8, 6*8+RGN_FRAC(1,2), 7*8, 7*8+RGN_FRAC(1,2)
988   },
989   { 0*8*8, 1*8*8, 2*8*8, 3*8*8, 4*8*8, 5*8*8, 6*8*8, 7*8*8 },
990   8*8*8
991};
992
993
994/******************************
995* Graphics Decode Information *
996******************************/
997
998static GFXDECODE_START( majorpkr )
999   GFXDECODE_ENTRY( "gfx1", 0, tilelayout, 8*256, 8 )
1000   GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 0, 8 )
1001GFXDECODE_END
1002
1003
1004/***********************
1005*    CRTC Interface    *
1006***********************/
1007
1008static const mc6845_interface mc6845_intf =
1009{
1010   "screen",      /* screen we are acting on */
1011   16,            /* number of pixels per video memory address */
1012   NULL,         /* before pixel update callback */
1013   NULL,         /* row update callback */
1014   NULL,         /* after pixel update callback */
1015   DEVCB_NULL,      /* callback for display state changes */
1016   DEVCB_NULL,      /* callback for cursor state changes */
1017   DEVCB_NULL,      /* HSYNC callback */
1018   DEVCB_NULL,      /* VSYNC callback */
1019   NULL         /* update address callback */
1020};
1021
1022
1023/*************************
1024*    Machine Drivers     *
1025*************************/
1026
1027static MACHINE_CONFIG_START( majorpkr, majorpkr_state )
1028   /* basic machine hardware */
1029   MCFG_CPU_ADD("maincpu", Z80, CPU_CLOCK)   /* 6 MHz */
1030   MCFG_CPU_PROGRAM_MAP(map)
1031   MCFG_CPU_IO_MAP(portmap)
1032   MCFG_CPU_VBLANK_INT("screen", irq0_line_hold)
1033
1034   MCFG_NVRAM_ADD_0FILL("nvram")
1035
1036   /* video hardware */
1037   MCFG_SCREEN_ADD("screen", RASTER)
1038   MCFG_SCREEN_REFRESH_RATE(52.786)
1039   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
1040   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1041   MCFG_SCREEN_SIZE((47+1)*16, (36+1)*8)            /* through CRTC registers: 768 x 296 */
1042//   MCFG_SCREEN_VISIBLE_AREA(0, (36*16)-1, 0, (28*8)-1)   /* through CRTC registers: 560(+16) x 224 */
1043   MCFG_SCREEN_VISIBLE_AREA(0, (35*16)-1, 0, (28*8)-1)
1044
1045   MCFG_GFXDECODE(majorpkr)
1046   MCFG_PALETTE_LENGTH(0x100 * 16)
1047
1048   MCFG_VIDEO_START(majorpkr)
1049   MCFG_SCREEN_UPDATE(majorpkr)
1050   
1051   MCFG_MC6845_ADD("crtc", MC6845, CRTC_CLOCK, mc6845_intf) /* verified */
1052
1053   /* sound hardware */
1054   MCFG_SPEAKER_STANDARD_MONO("mono")
1055   MCFG_OKIM6295_ADD("oki", OKI_CLOCK, OKIM6295_PIN7_HIGH)   /* clock frequency & pin 7 verified */
1056   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
1057MACHINE_CONFIG_END
1058
1059
1060/*************************
1061*        Rom Load        *
1062*************************/
1063
1064ROM_START( majorpkr )
1065   ROM_REGION( 0x20000, "maincpu", 0 )
1066   ROM_LOAD( "6_27c512_823b.bin", 0x00000, 0x0e000, CRC(a3d5475e) SHA1(cb41508b55da8b8c658a2f2ccc6ebda09db29040)  )
1067   ROM_CONTINUE(0x10000,0x2000)
1068   
1069   ROM_REGION( 0x100000, "gfx1", 0 )
1070   ROM_LOAD( "p1_27c040_7d3b.bin", 0x00000, 0x80000, CRC(67299eff) SHA1(34d3d8baf08dea495b699dd63272b445e2acb42d) )
1071   ROM_LOAD( "p2_27c040_6039.bin", 0x80000, 0x80000, CRC(2d68b177) SHA1(01c934e0383991f2208b915cc5015463a8b6a8fd) )
1072
1073   ROM_REGION( 0x40000, "gfx2", 0 )
1074   ROM_LOAD( "3_27c010_af18.bin", 0x00000, 0x20000, CRC(54452bb8) SHA1(9d13c17b85dd0185ba64fc6f90425e0c75363960) )
1075   ROM_LOAD( "4_27c010_92d6.bin", 0x20000, 0x20000, CRC(2e1e0972) SHA1(729dba2ef6ae8a7299c7ceb38835bebb0c42d28e) )
1076
1077   ROM_REGION( 0x40000, "oki", 0 )
1078   ROM_LOAD( "5_27c020_8630.bin", 0x00000, 0x40000, CRC(4843858e) SHA1(27629829cf7753d7801a6eb42bb77ca2a467bebd) )
1079ROM_END
1080
1081
1082/*************************
1083*      Driver Init       *
1084*************************/
1085
1086static DRIVER_INIT( majorpkr )
1087{
1088   UINT8 * ROM = (UINT8 *)machine.region("maincpu")->base();
1089   memory_configure_bank(machine, "rom_bank", 0, 4, &ROM[0x10000], 0x800);
1090}
1091
1092
1093/*************************
1094*      Game Drivers      *
1095*************************/
1096
1097/*     YEAR  NAME      PARENT  MACHINE   INPUT     INIT      ROT    COMPANY       FULLNAME             FLAGS  LAYOUT */
1098GAMEL( 1994, majorpkr, 0,      majorpkr, majorpkr, majorpkr, ROT0, "PAL System", "Major Poker (v2.0)", 0,     layout_majorpkr )
src/mame/drivers/4enraya.c
r11160r11161
22
33Driver by Tomasz Slanina  dox@space.pl
44
5TODO:
6- video and irq timings;
7- there's a waitstate penalty on the VRAM apparently?
8
59***************************************************************************
610
711RAM :
r11160r11161
5357#include "sound/ay8910.h"
5458#include "includes/4enraya.h"
5559
60#define MAIN_CLOCK XTAL_8MHz
61
5662static WRITE8_HANDLER( sound_data_w )
5763{
5864   _4enraya_state *state = space->machine().driver_data<_4enraya_state>();
r11160r11161
6975   state->m_last_snd_ctrl = data;
7076}
7177
78static READ8_HANDLER( fenraya_custom_map_r )
79{
80   UINT8 *prom = space->machine().region("pal_prom")->base();
81   UINT8 prom_routing = (prom[offset >> 12] & 0xf) ^ 0xf;
82   UINT8 res;
83
84   res = 0;
85
86   if(prom_routing & 1) //ROM5
87   {
88      UINT8 *rom = space->machine().region("maincpu")->base();
89      res |= rom[offset & 0x7fff];
90   }
91
92   if(prom_routing & 2) //ROM4
93   {
94      UINT8 *rom = space->machine().region("maincpu")->base();
95      res |= rom[(offset & 0x7fff) | 0x8000];
96   }
97
98   if(prom_routing & 4) //RAM
99   {
100      _4enraya_state *state = space->machine().driver_data<_4enraya_state>();
101      res |= state->m_workram[offset & 0xfff];
102   }
103
104   if(prom_routing & 8) //gfx control / RAM wait
105   {
106      _4enraya_state *state = space->machine().driver_data<_4enraya_state>();
107      res |= state->m_videoram[offset & 0xfff];
108   }
109
110   return res;
111}
112
113static WRITE8_HANDLER( fenraya_custom_map_w )
114{
115   UINT8 *prom = space->machine().region("pal_prom")->base();
116   UINT8 prom_routing = (prom[offset >> 12] & 0xf) ^ 0xf;
117
118   if(prom_routing & 1) //ROM5
119   {
120      // ...
121   }
122
123   if(prom_routing & 2) //ROM4
124   {
125      // ...
126   }
127
128   if(prom_routing & 4) //RAM
129   {
130      _4enraya_state *state = space->machine().driver_data<_4enraya_state>();
131      state->m_workram[offset & 0xfff] = data;
132   }
133
134   if(prom_routing & 8) //gfx control / RAM wait
135   {
136      fenraya_videoram_w(space,offset & 0xfff,data);
137   }
138}
139
72140static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8 )
141   AM_RANGE(0x0000, 0xffff) AM_READWRITE(fenraya_custom_map_r,fenraya_custom_map_w)
142   #if 0
73143   AM_RANGE(0x0000, 0xbfff) AM_ROM
74144   AM_RANGE(0xc000, 0xcfff) AM_RAM
75145   AM_RANGE(0xd000, 0xdfff) AM_WRITE(fenraya_videoram_w) AM_BASE_SIZE_MEMBER(_4enraya_state, m_videoram, m_videoram_size)
76146   AM_RANGE(0xe000, 0xefff) AM_WRITE(fenraya_videoram_w)
77147   AM_RANGE(0xf000, 0xffff) AM_NOP
148   #endif
78149ADDRESS_MAP_END
79150
80151static ADDRESS_MAP_START( main_portmap, AS_IO, 8 )
r11160r11161
135206
136207static const gfx_layout charlayout =
137208{
138   8,8,   /* 8*8 characters */
139   RGN_FRAC(1,3),   /* 1024 characters */
140   3,   /* 3 bits per pixel */
141   { RGN_FRAC(1,3), RGN_FRAC(2,3), RGN_FRAC(0,3) },   /* the bitplanes are separated */
209   8,8,
210   RGN_FRAC(1,3),
211   3,
212   { RGN_FRAC(1,3), RGN_FRAC(2,3), RGN_FRAC(0,3) },
142213   { 0, 1, 2, 3, 4, 5, 6, 7 },
143214   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
144   8*8   /* every char takes 8 consecutive bytes */
215   8*8
145216};
146217
147218static GFXDECODE_START( 4enraya )
r11160r11161
176247static MACHINE_CONFIG_START( 4enraya, _4enraya_state )
177248
178249   /* basic machine hardware */
179   MCFG_CPU_ADD("maincpu",Z80,8000000/2)
250   MCFG_CPU_ADD("maincpu",Z80,MAIN_CLOCK/2)
180251   MCFG_CPU_PROGRAM_MAP(main_map)
181252   MCFG_CPU_IO_MAP(main_portmap)
182253   MCFG_CPU_PERIODIC_INT(irq0_line_hold,4*60) // unknown timing
r11160r11161
202273
203274   /* sound hardware */
204275   MCFG_SPEAKER_STANDARD_MONO("mono")
205   MCFG_SOUND_ADD("aysnd", AY8910, 8000000/4) /* guess */
276   MCFG_SOUND_ADD("aysnd", AY8910, MAIN_CLOCK/4) /* guess */
206277   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
207278MACHINE_CONFIG_END
208279
r11160r11161
222293   ROM_LOAD( "2.bin",   0x2000, 0x2000, CRC(2b0a3793) SHA1(2c3d224251557824bb9641dc2f98a000ab72c4a2) )
223294   ROM_LOAD( "3.bin",   0x4000, 0x2000, CRC(f6940836) SHA1(afde21ffa0c141cf73243e50da62ecfd474aaac2) )
224295
225   ROM_REGION( 0x0020,  "proms", 0 )
226   ROM_LOAD( "1.bpr",   0x0000, 0x0020, CRC(dcbd2352) SHA1(ce72e84129ed1b455aaf648e1dfaa4333e7e7628) )   /* system control - not used */
296   ROM_REGION( 0x0020,  "pal_prom", 0 )
297   ROM_LOAD( "1.bpr",   0x0000, 0x0020, CRC(dcbd2352) SHA1(ce72e84129ed1b455aaf648e1dfaa4333e7e7628) )   /* system control: used for memory mapping */
227298ROM_END
228299
229300GAME( 1990, 4enraya,  0,   4enraya,  4enraya,  0, ROT0, "IDSA", "4 En Raya", GAME_SUPPORTS_SAVE )
src/mame/drivers/scramble.c
r11160r11161
3333#include "sound/flt_rc.h"
3434#include "machine/7474.h"
3535#include "machine/8255ppi.h"
36#include "includes/galaxold.h"
36#include "includes/scramble.h"
3737
3838
3939
4040static ADDRESS_MAP_START( scramble_map, AS_PROGRAM, 8 )
4141   AM_RANGE(0x0000, 0x3fff) AM_ROM
4242   AM_RANGE(0x4000, 0x47ff) AM_RAM
43   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
43   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
4444   AM_RANGE(0x4c00, 0x4fff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w)   /* mirror address */
45   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
46   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
47   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
45   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
46   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
47   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
4848   AM_RANGE(0x5080, 0x50ff) AM_RAM
4949   AM_RANGE(0x6801, 0x6801) AM_WRITE(galaxold_nmi_enable_w)
5050   AM_RANGE(0x6802, 0x6802) AM_WRITE(galaxold_coin_counter_w)
r11160r11161
6262static ADDRESS_MAP_START( turpins_map, AS_PROGRAM, 8 )
6363   AM_RANGE(0x0000, 0x5fff) AM_ROM
6464   AM_RANGE(0x8000, 0x87ff) AM_RAM
65   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
65   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
6666   AM_RANGE(0x9400, 0x97ff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w)
67   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
68   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
69   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
67   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
68   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
69   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
7070   AM_RANGE(0x9880, 0x98ff) AM_RAM
7171
7272   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
r11160r11161
9494   AM_RANGE(0x6000, 0x6bff) AM_RAM
9595   AM_RANGE(0x7000, 0x7003) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w)
9696   AM_RANGE(0x7800, 0x7803) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w)
97   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
98   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
99   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
100   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
97   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
98   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
99   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
100   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
101101   AM_RANGE(0x9880, 0x98ff) AM_RAM
102102   AM_RANGE(0xa801, 0xa801) AM_WRITE(galaxold_nmi_enable_w)
103103   AM_RANGE(0xa802, 0xa802) AM_WRITE(galaxold_coin_counter_w)
r11160r11161
121121static ADDRESS_MAP_START( mars_map, AS_PROGRAM, 8 )
122122   AM_RANGE(0x0000, 0x3fff) AM_ROM
123123   AM_RANGE(0x4000, 0x47ff) AM_RAM
124   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
124   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
125125   AM_RANGE(0x4c00, 0x4fff) AM_READ(galaxold_videoram_r)
126   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
127   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
128   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
126   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
127   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
128   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
129129   AM_RANGE(0x5080, 0x50ff) AM_RAM
130130   AM_RANGE(0x6800, 0x6800) AM_WRITE(galaxold_coin_counter_1_w)
131131   AM_RANGE(0x6801, 0x6801) AM_WRITE(galaxold_stars_enable_w)
r11160r11161
143143static ADDRESS_MAP_START( newsin7_map, AS_PROGRAM, 8 )
144144   AM_RANGE(0x0000, 0x3fff) AM_ROM
145145   AM_RANGE(0x4000, 0x47ff) AM_RAM
146   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
146   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
147147   AM_RANGE(0x4c00, 0x4fff) AM_READ(galaxold_videoram_r)
148   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
149   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
150   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
148   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
149   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
150   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
151151   AM_RANGE(0x5080, 0x50ff) AM_RAM
152152   AM_RANGE(0x6800, 0x6800) AM_WRITE(galaxold_coin_counter_1_w)
153153   AM_RANGE(0x6801, 0x6801) AM_WRITE(galaxold_stars_enable_w)
r11160r11161
165165static ADDRESS_MAP_START( mrkougar_map, AS_PROGRAM, 8 )
166166   AM_RANGE(0x0000, 0x3fff) AM_ROM
167167   AM_RANGE(0x4000, 0x47ff) AM_RAM
168   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
168   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
169169   AM_RANGE(0x4c00, 0x4fff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w)
170   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
171   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
172   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
170   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
171   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
172   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
173173   AM_RANGE(0x5080, 0x50ff) AM_RAM
174174   AM_RANGE(0x6800, 0x6800) AM_WRITE(galaxold_coin_counter_1_w)
175175   AM_RANGE(0x6801, 0x6801) AM_WRITE(galaxold_nmi_enable_w)
r11160r11161
185185static ADDRESS_MAP_START( hotshock_map, AS_PROGRAM, 8 )
186186   AM_RANGE(0x0000, 0x3fff) AM_ROM
187187   AM_RANGE(0x4000, 0x47ff) AM_RAM
188   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
188   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
189189   AM_RANGE(0x4c00, 0x4fff) AM_READ(galaxold_videoram_r)
190   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
191   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
192   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
190   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
191   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
192   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
193193   AM_RANGE(0x5080, 0x50ff) AM_RAM
194194   AM_RANGE(0x6000, 0x6000) AM_WRITE(galaxold_coin_counter_2_w)
195195   AM_RANGE(0x6002, 0x6002) AM_WRITE(galaxold_coin_counter_1_w)
r11160r11161
209209static ADDRESS_MAP_START( hunchbks_map, AS_PROGRAM, 8 )
210210   AM_RANGE(0x0000, 0x0fff) AM_ROM
211211   AM_RANGE(0x1210, 0x1213) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w)
212   AM_RANGE(0x1400, 0x143f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
213   AM_RANGE(0x1440, 0x145f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
214   AM_RANGE(0x1460, 0x147f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
212   AM_RANGE(0x1400, 0x143f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
213   AM_RANGE(0x1440, 0x145f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
214   AM_RANGE(0x1460, 0x147f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
215215   AM_RANGE(0x1480, 0x14ff) AM_RAM
216216   AM_RANGE(0x1500, 0x1503) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w)
217217   AM_RANGE(0x1606, 0x1606) AM_WRITE(galaxold_flip_screen_x_w)
218218   AM_RANGE(0x1607, 0x1607) AM_WRITE(galaxold_flip_screen_y_w)
219219   AM_RANGE(0x1680, 0x1680) AM_READ(watchdog_reset_r)
220220   AM_RANGE(0x1780, 0x1780) AM_READ(watchdog_reset_r)
221   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
221   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
222222   AM_RANGE(0x1c00, 0x1fff) AM_RAM
223223   AM_RANGE(0x2000, 0x2fff) AM_ROM
224224   AM_RANGE(0x3000, 0x3fff) AM_READWRITE(hunchbks_mirror_r, hunchbks_mirror_w)
r11160r11161
233233   AM_RANGE(0x0000, 0x3fff) AM_ROM
234234   AM_RANGE(0x4000, 0x43ff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w)   /* mirror address?, probably not */
235235   AM_RANGE(0x4400, 0x47ff) AM_RAM
236   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
237   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
238   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
239   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
236   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
237   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
238   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
239   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
240240   AM_RANGE(0x5080, 0x50ff) AM_RAM
241241   AM_RANGE(0x6801, 0x6801) AM_WRITE(galaxold_nmi_enable_w)
242242   AM_RANGE(0x6800, 0x6802) AM_WRITE(galaxold_gfxbank_w)
r11160r11161
252252static ADDRESS_MAP_START( ad2083_map, AS_PROGRAM, 8 )
253253   AM_RANGE(0x0000, 0x3fff) AM_ROM
254254   AM_RANGE(0x4000, 0x47ff) AM_RAM
255   AM_RANGE(0x4800, 0x4bff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w) AM_BASE(&galaxold_videoram)
256   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
257   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
258   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
255   AM_RANGE(0x4800, 0x4bff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
256   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
257   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
258   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
259259   AM_RANGE(0x6004, 0x6004) AM_WRITE(hotshock_flip_screen_w)
260260   AM_RANGE(0x6800, 0x6800) AM_WRITE(galaxold_coin_counter_2_w)
261261   AM_RANGE(0x6801, 0x6801) AM_WRITE(galaxold_nmi_enable_w)
r11160r11161
12061206GFXDECODE_END
12071207
12081208
1209static UINT8 *scramble_soundram;
12101209
12111210static READ8_HANDLER(scramble_soundram_r)
12121211{
1213   return scramble_soundram[offset & 0x03ff];
1212   scramble_state *state = space->machine().driver_data<scramble_state>();
1213   return state->m_soundram[offset & 0x03ff];
12141214}
12151215
12161216static WRITE8_HANDLER(scramble_soundram_w)
12171217{
1218   scramble_soundram[offset & 0x03ff] = data;
1218   scramble_state *state = space->machine().driver_data<scramble_state>();
1219   state->m_soundram[offset & 0x03ff] = data;
12191220}
12201221
12211222static ADDRESS_MAP_START( scramble_sound_map, AS_PROGRAM, 8 )
12221223   AM_RANGE(0x0000, 0x2fff) AM_ROM
12231224   AM_RANGE(0x8000, 0x8fff) AM_READWRITE(scramble_soundram_r, scramble_soundram_w)
1224   AM_RANGE(0x8000, 0x83ff) AM_WRITENOP AM_BASE(&scramble_soundram)  /* only here to initialize pointer */
1225   AM_RANGE(0x8000, 0x83ff) AM_WRITENOP AM_BASE_MEMBER(scramble_state, m_soundram)  /* only here to initialize pointer */
12251226   AM_RANGE(0x9000, 0x9fff) AM_WRITE(scramble_filter_w)
12261227ADDRESS_MAP_END
12271228
r11160r11161
12331234   AM_RANGE(0x80, 0x80) AM_DEVREADWRITE("8910.2", ay8910_r, ay8910_data_w)
12341235ADDRESS_MAP_END
12351236
1236static MACHINE_CONFIG_START( scramble, driver_device )
1237static MACHINE_CONFIG_START( scramble, scramble_state )
12371238
12381239   /* basic machine hardware */
12391240   MCFG_CPU_ADD("maincpu", Z80, 18432000/6)   /* 3.072 MHz */
r11160r11161
13131314   MCFG_GFXDECODE(newsin7)
13141315   MCFG_PALETTE_LENGTH(32+64+2+0)   /* 32 for characters, 64 for stars, 2 for bullets, 0/1 for background */
13151316   MCFG_PALETTE_INIT(galaxold)
1316   MCFG_VIDEO_START(newsin7)
1317   MCFG_VIDEO_START(scrambold)
13171318MACHINE_CONFIG_END
13181319
13191320static MACHINE_CONFIG_DERIVED( mrkougar, scramble )
r11160r11161
14631464   MCFG_VIDEO_START(scorpion)
14641465MACHINE_CONFIG_END
14651466
1466static MACHINE_CONFIG_START( ad2083, driver_device )
1467static MACHINE_CONFIG_START( ad2083, scramble_state )
14671468   /* basic machine hardware */
14681469   MCFG_CPU_ADD("maincpu", Z80, 18432000/6)   /* 3.072 MHz */
14691470   MCFG_CPU_PROGRAM_MAP(ad2083_map)
src/mame/drivers/namcos21.c
r11160r11161
303303
304304#define PTRAM_SIZE 0x20000
305305
306static UINT16 *winrun_dspbios;
307static UINT16 *winrun_dspcomram;
308#define WINRUN_MAX_POLY_PARAM (1+256*3)
309static UINT16 winrun_poly_buf[WINRUN_MAX_POLY_PARAM];
310static int winrun_poly_index;
311static UINT32 winrun_pointrom_addr;
312static UINT16 *winrun_polydata;
313static int winrun_dsp_alive;
314static UINT16 *winrun_gpucomram;
315static UINT16 winrun_dspcomram_control[8];
316static UINT16 namcos21_video_enable;
317
318static UINT8 *pointram;
319static int pointram_idx;
320
321static UINT16 *namcos21_dspram16;
322//UINT16 *namcos21_spritepos;
323
324/* private data */
325static UINT16 *mpDataROM;
326static UINT16 *mpSharedRAM1;
327static UINT8   *mpDualPortRAM;
328static UINT16 pointram_control;
329
330
331306#define ENABLE_LOGGING      0
332307
333308
334#define DSP_BUF_MAX (4096*12)
335struct dsp_state
336{
337   unsigned masterSourceAddr;
338   UINT16 slaveInputBuffer[DSP_BUF_MAX];
339   unsigned slaveBytesAvailable;
340   unsigned slaveBytesAdvertised;
341   unsigned slaveInputStart;
342   UINT16 slaveOutputBuffer[DSP_BUF_MAX];
343   unsigned slaveOutputSize;
344   UINT16 masterDirectDrawBuffer[256];
345   unsigned masterDirectDrawSize;
346   int masterFinished;
347   int slaveActive;
348};
349static dsp_state *mpDspState;
350
351309static INT32
352310ReadPointROMData( running_machine &machine, unsigned offset )
353311{
r11160r11161
358316
359317static READ16_HANDLER(namcos21_video_enable_r)
360318{
361   return namcos21_video_enable;
319   namcos21_state *state = space->machine().driver_data<namcos21_state>();
320   return state->m_video_enable;
362321}
363322
364323static WRITE16_HANDLER(namcos21_video_enable_w)
365324{
366   COMBINE_DATA( &namcos21_video_enable ); /* 0x40 = enable */
367   if( namcos21_video_enable!=0 && namcos21_video_enable!=0x40 )
325   namcos21_state *state = space->machine().driver_data<namcos21_state>();
326   COMBINE_DATA( &state->m_video_enable ); /* 0x40 = enable */
327   if( state->m_video_enable!=0 && state->m_video_enable!=0x40 )
368328   {
369      logerror( "unexpected namcos21_video_enable_w=0x%x\n", namcos21_video_enable );
329      logerror( "unexpected namcos21_video_enable_w=0x%x\n", state->m_video_enable );
370330   }
371331}
372332
r11160r11161
418378}
419379
420380static void
421TransmitWordToSlave( UINT16 data )
381TransmitWordToSlave( namcos21_state *state, UINT16 data )
422382{
423   unsigned offs = mpDspState->slaveInputStart+mpDspState->slaveBytesAvailable++;
424   mpDspState->slaveInputBuffer[offs%DSP_BUF_MAX] = data;
425   if (ENABLE_LOGGING) logerror( "+%04x(#%04x)\n", data, mpDspState->slaveBytesAvailable );
426   mpDspState->slaveActive = 1;
427   if( mpDspState->slaveBytesAvailable >= DSP_BUF_MAX )
383   unsigned offs = state->m_mpDspState->slaveInputStart+state->m_mpDspState->slaveBytesAvailable++;
384   state->m_mpDspState->slaveInputBuffer[offs%DSP_BUF_MAX] = data;
385   if (ENABLE_LOGGING) logerror( "+%04x(#%04x)\n", data, state->m_mpDspState->slaveBytesAvailable );
386   state->m_mpDspState->slaveActive = 1;
387   if( state->m_mpDspState->slaveBytesAvailable >= DSP_BUF_MAX )
428388   {
429389      logerror( "IDC overflow\n" );
430390      exit(1);
r11160r11161
434394static void
435395TransferDspData( running_machine &machine )
436396{
437   UINT16 addr = mpDspState->masterSourceAddr;
397   namcos21_state *state = machine.driver_data<namcos21_state>();
398   UINT16 addr = state->m_mpDspState->masterSourceAddr;
438399   int mode = addr&0x8000;
439400   addr&=0x7fff;
440401   if( addr )
r11160r11161
443404      {
444405         int i;
445406         UINT16 old = addr;
446         UINT16 code = namcos21_dspram16[addr++];
407         UINT16 code = state->m_dspram16[addr++];
447408         if( code == 0xffff )
448409         {
449410            if( mode )
450411            {
451               addr = namcos21_dspram16[addr];
452               mpDspState->masterSourceAddr = addr;
412               addr = state->m_dspram16[addr];
413               state->m_mpDspState->masterSourceAddr = addr;
453414               if (ENABLE_LOGGING) logerror( "LOOP:0x%04x\n", addr );
454415               addr&=0x7fff;
455416               if( old==addr )
r11160r11161
459420            }
460421            else
461422            {
462               mpDspState->masterSourceAddr = 0;
423               state->m_mpDspState->masterSourceAddr = 0;
463424               return;
464425            }
465426         }
466427         else if( mode==0 )
467428         { /* direct data transfer */
468429            if (ENABLE_LOGGING) logerror( "DATA TFR(0x%x)\n", code );
469            TransmitWordToSlave( code );
430            TransmitWordToSlave( state, code );
470431            for( i=0; i<code; i++ )
471432            {
472               UINT16 data = namcos21_dspram16[addr++];
473               TransmitWordToSlave( data );
433               UINT16 data = state->m_dspram16[addr++];
434               TransmitWordToSlave( state, data );
474435            }
475436         }
476437         else if( code==0x18 || code==0x1a )
477438         {
478439            if (ENABLE_LOGGING) logerror( "HEADER TFR(0x%x)\n", code );
479            TransmitWordToSlave( code+1 );
440            TransmitWordToSlave( state, code+1 );
480441            for( i=0; i<code; i++ )
481442            {
482               UINT16 data = namcos21_dspram16[addr++];
483               TransmitWordToSlave( data );
443               UINT16 data = state->m_dspram16[addr++];
444               TransmitWordToSlave( state, data );
484445            }
485446         }
486447         else
r11160r11161
488449            INT32 masterAddr = ReadPointROMData(machine, code);
489450            if (ENABLE_LOGGING) logerror( "OBJ TFR(0x%x)\n", code );
490451            {
491               UINT16 len = namcos21_dspram16[addr++];
452               UINT16 len = state->m_dspram16[addr++];
492453               for(;;)
493454               {
494455                  int subAddr = ReadPointROMData(machine, masterAddr++);
r11160r11161
501462                     int primWords = (UINT16)ReadPointROMData(machine, subAddr++);
502463                     if( primWords>2 )
503464                     {
504                        TransmitWordToSlave( 0 ); /* pad1 */
505                        TransmitWordToSlave( len+1 );
465                        TransmitWordToSlave( state, 0 ); /* pad1 */
466                        TransmitWordToSlave( state, len+1 );
506467                        for( i=0; i<len; i++ )
507468                        { /* transform */
508                           TransmitWordToSlave( namcos21_dspram16[addr+i] );
469                           TransmitWordToSlave( state, state->m_dspram16[addr+i] );
509470                        }
510                        TransmitWordToSlave( 0 ); /* pad2 */
511                        TransmitWordToSlave( primWords+1 );
471                        TransmitWordToSlave( state, 0 ); /* pad2 */
472                        TransmitWordToSlave( state, primWords+1 );
512473                        for( i=0; i<primWords; i++ )
513474                        {
514                           TransmitWordToSlave( (UINT16)ReadPointROMData(machine, subAddr+i) );
475                           TransmitWordToSlave( state, (UINT16)ReadPointROMData(machine, subAddr+i) );
515476                        }
516477                     }
517478                     else
r11160r11161
527488   }
528489} /* TransferDspData */
529490
530static int mbNeedsKickstart;
531491
532static UINT16 *master_dsp_code;
533492
534493void
535494namcos21_kickstart( running_machine &machine, int internal )
536495{
496   namcos21_state *state = machine.driver_data<namcos21_state>();
537497   /* patch dsp watchdog */
538498   switch( namcos2_gametype )
539499   {
540500   case NAMCOS21_AIRCOMBAT:
541      master_dsp_code[0x008e] = 0x808f;
501      state->m_master_dsp_code[0x008e] = 0x808f;
542502      break;
543503   case NAMCOS21_SOLVALOU:
544      master_dsp_code[0x008b] = 0x808c;
504      state->m_master_dsp_code[0x008b] = 0x808c;
545505      break;
546506   default:
547507      break;
548508   }
549509   if( internal )
550510   {
551      if( mbNeedsKickstart==0 ) return;
552      mbNeedsKickstart--;
553      if( mbNeedsKickstart ) return;
511      if( state->m_mbNeedsKickstart==0 ) return;
512      state->m_mbNeedsKickstart--;
513      if( state->m_mbNeedsKickstart ) return;
554514   }
555515
556   namcos21_ClearPolyFrameBuffer();
557   mpDspState->masterSourceAddr = 0;
558   mpDspState->slaveOutputSize = 0;
559   mpDspState->masterFinished = 0;
560   mpDspState->slaveActive = 0;
516   namcos21_ClearPolyFrameBuffer(machine);
517   state->m_mpDspState->masterSourceAddr = 0;
518   state->m_mpDspState->slaveOutputSize = 0;
519   state->m_mpDspState->masterFinished = 0;
520   state->m_mpDspState->slaveActive = 0;
561521   cputag_set_input_line(machine, "dspmaster", 0, HOLD_LINE);
562522   cputag_set_input_line(machine, "dspslave", INPUT_LINE_RESET, PULSE_LINE);
563523}
r11160r11161
565525static UINT16
566526ReadWordFromSlaveInput( address_space *space )
567527{
528   namcos21_state *state = space->machine().driver_data<namcos21_state>();
568529   UINT16 data = 0;
569   if( mpDspState->slaveBytesAvailable>0 )
530   if( state->m_mpDspState->slaveBytesAvailable>0 )
570531   {
571      data = mpDspState->slaveInputBuffer[mpDspState->slaveInputStart++];
572      mpDspState->slaveInputStart %= DSP_BUF_MAX;
573      mpDspState->slaveBytesAvailable--;
574      if( mpDspState->slaveBytesAdvertised>0 )
532      data = state->m_mpDspState->slaveInputBuffer[state->m_mpDspState->slaveInputStart++];
533      state->m_mpDspState->slaveInputStart %= DSP_BUF_MAX;
534      state->m_mpDspState->slaveBytesAvailable--;
535      if( state->m_mpDspState->slaveBytesAdvertised>0 )
575536      {
576         mpDspState->slaveBytesAdvertised--;
537         state->m_mpDspState->slaveBytesAdvertised--;
577538      }
578      if (ENABLE_LOGGING) logerror( "%s:-%04x(0x%04x)\n", space->machine().describe_context(), data, mpDspState->slaveBytesAvailable );
539      if (ENABLE_LOGGING) logerror( "%s:-%04x(0x%04x)\n", space->machine().describe_context(), data, state->m_mpDspState->slaveBytesAvailable );
579540   }
580541   return data;
581542} /* ReadWordFromSlaveInput */
r11160r11161
583544static size_t
584545GetInputBytesAdvertisedForSlave( running_machine &machine )
585546{
586   if( mpDspState->slaveBytesAdvertised < mpDspState->slaveBytesAvailable )
547   namcos21_state *state = machine.driver_data<namcos21_state>();
548   if( state->m_mpDspState->slaveBytesAdvertised < state->m_mpDspState->slaveBytesAvailable )
587549   {
588      mpDspState->slaveBytesAdvertised++;
550      state->m_mpDspState->slaveBytesAdvertised++;
589551   }
590   else if( mpDspState->slaveActive && mpDspState->masterFinished && mpDspState->masterSourceAddr )
552   else if( state->m_mpDspState->slaveActive && state->m_mpDspState->masterFinished && state->m_mpDspState->masterSourceAddr )
591553   {
592554      namcos21_kickstart(machine, 0);
593555   }
594   return mpDspState->slaveBytesAdvertised;
556   return state->m_mpDspState->slaveBytesAdvertised;
595557} /* GetInputBytesAdvertisedForSlave */
596558
597559static READ16_HANDLER( dspram16_r )
598560{
599   return namcos21_dspram16[offset];
561   namcos21_state *state = space->machine().driver_data<namcos21_state>();
562   return state->m_dspram16[offset];
600563} /* dspram16_r */
601564
602565static WRITE16_HANDLER( dspram16_w )
603566{
604   COMBINE_DATA( &namcos21_dspram16[offset] );
567   namcos21_state *state = space->machine().driver_data<namcos21_state>();
568   COMBINE_DATA( &state->m_dspram16[offset] );
605569
606570   if( namcos2_gametype != NAMCOS21_WINRUN91 )
607571   {
608      if( mpDspState->masterSourceAddr &&
609         offset == 1+(mpDspState->masterSourceAddr&0x7fff) )
572      if( state->m_mpDspState->masterSourceAddr &&
573         offset == 1+(state->m_mpDspState->masterSourceAddr&0x7fff) )
610574      {
611575         if (ENABLE_LOGGING) logerror( "IDC-CONTINUE\n" );
612576         TransferDspData(space->machine());
r11160r11161
625589static int
626590InitDSP( running_machine &machine )
627591{
592   namcos21_state *state = machine.driver_data<namcos21_state>();
628593   UINT16 *pMem = (UINT16 *)machine.region("dspmaster")->base();
629594   /**
630595     * DSP BIOS tests "CPU ID" on startup
r11160r11161
634599   pMem[0x8000] = 0xFF80;
635600   pMem[0x8001] = 0x0000;
636601
637   mpDspState = auto_alloc_clear(machine, dsp_state);
602   state->m_mpDspState = auto_alloc_clear(machine, dsp_state);
638603
639604   return 0;
640605}
641606
642607/***********************************************************/
643608
644static UINT32 pointrom_idx;
645609
646static UINT8 mPointRomMSB;
647static int mbPointRomDataAvailable;
648610
649611static READ16_HANDLER( dsp_port0_r )
650612{
651   INT32 data = ReadPointROMData(space->machine(), pointrom_idx++);
652   mPointRomMSB = (UINT8)(data>>16);
653   mbPointRomDataAvailable = 1;
613   namcos21_state *state = space->machine().driver_data<namcos21_state>();
614   INT32 data = ReadPointROMData(space->machine(), state->m_pointrom_idx++);
615   state->m_mPointRomMSB = (UINT8)(data>>16);
616   state->m_mbPointRomDataAvailable = 1;
654617   return (UINT16)data;
655618} /* dsp_port0_r */
656619
r11160r11161
661624
662625static READ16_HANDLER( dsp_port1_r )
663626{
664   if( mbPointRomDataAvailable )
627   namcos21_state *state = space->machine().driver_data<namcos21_state>();
628   if( state->m_mbPointRomDataAvailable )
665629   {
666      mbPointRomDataAvailable = 0;
667      return mPointRomMSB;
630      state->m_mbPointRomDataAvailable = 0;
631      return state->m_mPointRomMSB;
668632   }
669633   return 0x8000; /* IDC ack? */
670634} /* dsp_port1_r */
r11160r11161
681645
682646static WRITE16_HANDLER( dsp_port2_w )
683647{
648   namcos21_state *state = space->machine().driver_data<namcos21_state>();
684649   if (ENABLE_LOGGING) logerror( "IDC ADDR INIT(0x%04x)\n", data );
685   mpDspState->masterSourceAddr = data;
650   state->m_mpDspState->masterSourceAddr = data;
686651   TransferDspData(space->machine());
687652} /* dsp_port2_w */
688653
r11160r11161
692657} /* dsp_port3_idc_rcv_enable_r */
693658
694659static WRITE16_HANDLER( dsp_port3_w )
695{ /* same address space as pointram? */
696   pointrom_idx<<=16;
697   pointrom_idx|=data;
660{
661   namcos21_state *state = space->machine().driver_data<namcos21_state>(); /* same address space as state->m_pointram? */
662   state->m_pointrom_idx<<=16;
663   state->m_pointrom_idx|=data;
698664} /* dsp_port3_w */
699665
700666static WRITE16_HANDLER( dsp_port4_w )
r11160r11161
706672   return 1;
707673} /* dsp_port8_r */
708674
709static int namcos21_irq_enable;
710675
711676static WRITE16_HANDLER( dsp_port8_w )
712{ /* IRQ-enable? */
677{
678   namcos21_state *state = space->machine().driver_data<namcos21_state>(); /* IRQ-enable? */
713679   if (ENABLE_LOGGING) logerror( "port8_w(%d)\n", data );
714680   if( data )
715681   {
716      mpDspState->masterFinished = 1;
682      state->m_mpDspState->masterFinished = 1;
717683   }
718   namcos21_irq_enable = data;
684   state->m_irq_enable = data;
719685} /* dsp_port8_w */
720686
721687static READ16_HANDLER( dsp_port9_r )
r11160r11161
744710} /* dsp_portb_r */
745711
746712static WRITE16_HANDLER(dsp_portb_w)
747{ /* render-device trigger */
713{
714   namcos21_state *state = space->machine().driver_data<namcos21_state>(); /* render-device trigger */
748715   if( data==0 )
749716   { /* only 0->1 transition triggers */
750717      return;
751718   }
752   if( mpDspState->masterDirectDrawSize == 13 )
719   if( state->m_mpDspState->masterDirectDrawSize == 13 )
753720   {
754721      int i;
755722      int sx[4], sy[4], zcode[4];
756      int color  = mpDspState->masterDirectDrawBuffer[0];
723      int color  = state->m_mpDspState->masterDirectDrawBuffer[0];
757724      for( i=0; i<4; i++ )
758725      {
759         sx[i] = NAMCOS21_POLY_FRAME_WIDTH/2 + (INT16)mpDspState->masterDirectDrawBuffer[i*3+1];
760         sy[i] = NAMCOS21_POLY_FRAME_HEIGHT/2 + (INT16)mpDspState->masterDirectDrawBuffer[i*3+2];
761         zcode[i] = mpDspState->masterDirectDrawBuffer[i*3+3];
726         sx[i] = NAMCOS21_POLY_FRAME_WIDTH/2 + (INT16)state->m_mpDspState->masterDirectDrawBuffer[i*3+1];
727         sy[i] = NAMCOS21_POLY_FRAME_HEIGHT/2 + (INT16)state->m_mpDspState->masterDirectDrawBuffer[i*3+2];
728         zcode[i] = state->m_mpDspState->masterDirectDrawBuffer[i*3+3];
762729      }
763730      if( color&0x8000 )
764731      {
765         namcos21_DrawQuad( sx, sy, zcode, color );
732         namcos21_DrawQuad( space->machine(), sx, sy, zcode, color );
766733      }
767734      else
768735      {
769736         logerror( "indirection used w/ direct draw?\n" );
770737      }
771738   }
772   else if( mpDspState->masterDirectDrawSize )
739   else if( state->m_mpDspState->masterDirectDrawSize )
773740   {
774      logerror( "unexpected masterDirectDrawSize=%d!\n",mpDspState->masterDirectDrawSize );
741      logerror( "unexpected masterDirectDrawSize=%d!\n",state->m_mpDspState->masterDirectDrawSize );
775742   }
776   mpDspState->masterDirectDrawSize = 0;
743   state->m_mpDspState->masterDirectDrawSize = 0;
777744} /* dsp_portb_w */
778745
779746static WRITE16_HANDLER(dsp_portc_w)
780{ /* enqueue data for direct-drawn poly */
781   if( mpDspState->masterDirectDrawSize < DSP_BUF_MAX )
747{
748   namcos21_state *state = space->machine().driver_data<namcos21_state>(); /* enqueue data for direct-drawn poly */
749   if( state->m_mpDspState->masterDirectDrawSize < DSP_BUF_MAX )
782750   {
783      mpDspState->masterDirectDrawBuffer[mpDspState->masterDirectDrawSize++] = data;
751      state->m_mpDspState->masterDirectDrawBuffer[state->m_mpDspState->masterDirectDrawSize++] = data;
784752   }
785753   else
786754   {
r11160r11161
800768
801769static ADDRESS_MAP_START( master_dsp_program, AS_PROGRAM, 16 )
802770   AM_RANGE(0x0000, 0x0fff) AM_ROM /* BIOS */
803   AM_RANGE(0x8000, 0xbfff) AM_RAM AM_BASE(&master_dsp_code)
771   AM_RANGE(0x8000, 0xbfff) AM_RAM AM_BASE_MEMBER(namcos21_state, m_master_dsp_code)
804772ADDRESS_MAP_END
805773
806774static ADDRESS_MAP_START( master_dsp_data, AS_DATA, 16 )
r11160r11161
828796/************************************************************************************/
829797
830798static void
831RenderSlaveOutput( UINT16 data )
799RenderSlaveOutput( running_machine &machine, UINT16 data )
832800{
833   if( mpDspState->slaveOutputSize >= 4096 )
801   namcos21_state *state = machine.driver_data<namcos21_state>();
802   if( state->m_mpDspState->slaveOutputSize >= 4096 )
834803   {
835      logerror( "FATAL ERROR: SLAVE OVERFLOW (0x%x)\n",mpDspState->slaveOutputBuffer[0]  );
804      logerror( "FATAL ERROR: SLAVE OVERFLOW (0x%x)\n",state->m_mpDspState->slaveOutputBuffer[0]  );
836805      exit(1);
837806      return;
838807   }
839808
840809   /* append word to slave output buffer */
841   mpDspState->slaveOutputBuffer[mpDspState->slaveOutputSize++] = data;
810   state->m_mpDspState->slaveOutputBuffer[state->m_mpDspState->slaveOutputSize++] = data;
842811
843812   {
844      UINT16 *pSource = mpDspState->slaveOutputBuffer;
813      UINT16 *pSource = state->m_mpDspState->slaveOutputBuffer;
845814      UINT16 count = *pSource++;
846      if( count && mpDspState->slaveOutputSize > count )
815      if( count && state->m_mpDspState->slaveOutputSize > count )
847816      {
848817         UINT16 color = *pSource++;
849818         int sx[4], sy[4],zcode[4];
r11160r11161
857826               sy[j] = NAMCOS21_POLY_FRAME_HEIGHT/2 + (INT16)pSource[3*j+1];
858827               zcode[j] = pSource[3*j+2];
859828            }
860            namcos21_DrawQuad( sx, sy, zcode, color&0x7fff );
829            namcos21_DrawQuad( machine, sx, sy, zcode, color&0x7fff );
861830         }
862831         else
863832         {
864833            int quad_idx = color*6;
865834            for(;;)
866835            {
867               UINT8 code = pointram[quad_idx++];
868               color = pointram[quad_idx++]|(code<<8);
836               UINT8 code = state->m_pointram[quad_idx++];
837               color = state->m_pointram[quad_idx++]|(code<<8);
869838               for( j=0; j<4; j++ )
870839               {
871                  UINT8 vi = pointram[quad_idx++];
840                  UINT8 vi = state->m_pointram[quad_idx++];
872841                  sx[j] = NAMCOS21_POLY_FRAME_WIDTH/2  + (INT16)pSource[vi*3+0];
873842                  sy[j] = NAMCOS21_POLY_FRAME_HEIGHT/2 + (INT16)pSource[vi*3+1];
874843                  zcode[j] = pSource[vi*3+2];
875844               }
876               namcos21_DrawQuad( sx, sy, zcode, color&0x7fff );
845               namcos21_DrawQuad( machine, sx, sy, zcode, color&0x7fff );
877846               if( code&0x80 )
878847               { /* end-of-quadlist marker */
879848                  break;
880849               }
881850            }
882851         }
883         mpDspState->slaveOutputSize = 0;
852         state->m_mpDspState->slaveOutputSize = 0;
884853      }
885854      else if( count==0 )
886855      {
r11160r11161
897866
898867static WRITE16_HANDLER(slave_port0_w)
899868{
900   RenderSlaveOutput( data );
869   RenderSlaveOutput( space->machine(), data );
901870}
902871
903872static READ16_HANDLER(slave_port2_r)
r11160r11161
967936 */
968937static WRITE16_HANDLER( pointram_control_w )
969938{
970//  UINT16 prev = pointram_control;
971   COMBINE_DATA( &pointram_control );
939   namcos21_state *state = space->machine().driver_data<namcos21_state>();
940//  UINT16 prev = state->m_pointram_control;
941   COMBINE_DATA( &state->m_pointram_control );
972942
973   /* pointram_control&0x20 : bank for depthcue data */
974/*
975    logerror( "dsp_control_w:'%s':%x[%x]:=%04x ",
976            space->device().tag,
977            cpu_get_pc(&space->device()),
978            offset,
979            pointram_control );
943   /* state->m_pointram_control&0x20 : bank for depthcue data */
944#if 0
945   logerror( "dsp_control_w:'%s':%x[%x]:=%04x ",
946      space->cpu->tag,
947      cpu_get_pc(space->cpu),
948      offset,
949      state->m_pointram_control );
980950
981    UINT16 delta = (prev^pointram_control)&pointram_control;
982    if( delta&0x10 )
983    {
984        logerror( " [reset]" );
985    }
986    if( delta&2 )
987    {
988        logerror( " send(A)%x", pointram_control&1 );
989    }
990    if( delta&4 )
991    {
992        logerror( " send(B)%x", pointram_control&1 );
993    }
994    if( delta&8 )
995    {
996        logerror( " send(C)%x", pointram_control&1 );
997    }
998    logerror( "\n" );
999*/
1000   pointram_idx = 0; /* HACK */
951   UINT16 delta = (prev^state->m_pointram_control)&state->m_pointram_control;
952   if( delta&0x10 )
953   {
954      logerror( " [reset]" );
955   }
956   if( delta&2 )
957   {
958      logerror( " send(A)%x", state->m_pointram_control&1 );
959   }
960   if( delta&4 )
961   {
962      logerror( " send(B)%x", state->m_pointram_control&1 );
963   }
964   if( delta&8 )
965   {
966      logerror( " send(C)%x", state->m_pointram_control&1 );
967   }
968   logerror( "\n" );
969#endif
970   state->m_pointram_idx = 0; /* HACK */
1001971} /* pointram_control_w */
1002972
1003973static READ16_HANDLER( pointram_data_r )
1004974{
1005   return pointram[pointram_idx];
975   namcos21_state *state = space->machine().driver_data<namcos21_state>();
976   return state->m_pointram[state->m_pointram_idx];
1006977} /* pointram_data_r */
1007978
1008979static WRITE16_HANDLER( pointram_data_w )
1009980{
981   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1010982   if( ACCESSING_BITS_0_7 )
1011983   {
1012//      if( (pointram_idx%6)==0 ) logerror("\n" );
984//      if( (state->m_pointram_idx%6)==0 ) logerror("\n" );
1013985//      logerror( " %02x", data );
1014      pointram[pointram_idx++] = data;
1015      pointram_idx &= (PTRAM_SIZE-1);
986      state->m_pointram[state->m_pointram_idx++] = data;
987      state->m_pointram_idx &= (PTRAM_SIZE-1);
1016988   }
1017989} /* pointram_data_w */
1018990
1019static UINT8 namcos21_depthcue[2][0x400]; /* 0x800 nybbles */
1020991
1021992static READ16_HANDLER( namcos21_depthcue_r )
1022993{
1023   int bank = (pointram_control&0x20)?1:0;
1024   return namcos21_depthcue[bank][offset];
994   namcos21_state *state = space->machine().driver_data<namcos21_state>();
995   int bank = (state->m_pointram_control&0x20)?1:0;
996   return state->m_depthcue[bank][offset];
1025997}
1026998static WRITE16_HANDLER( namcos21_depthcue_w )
1027999{
1000   namcos21_state *state = space->machine().driver_data<namcos21_state>();
10281001   if( ACCESSING_BITS_0_7 )
10291002   {
1030      int bank = (pointram_control&0x20)?1:0;
1031      namcos21_depthcue[bank][offset] = data;
1003      int bank = (state->m_pointram_control&0x20)?1:0;
1004      state->m_depthcue[bank][offset] = data;
10321005//      if( (offset&0xf)==0 ) logerror( "\n depthcue: " );
10331006//      logerror( " %02x", data );
10341007   }
r11160r11161
10381011
10391012static READ16_HANDLER( namcos2_68k_dualportram_word_r )
10401013{
1041   return mpDualPortRAM[offset];
1014   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1015   return state->m_mpDualPortRAM[offset];
10421016}
10431017
10441018static WRITE16_HANDLER( namcos2_68k_dualportram_word_w )
10451019{
1020   namcos21_state *state = space->machine().driver_data<namcos21_state>();
10461021   if( ACCESSING_BITS_0_7 )
10471022   {
1048      mpDualPortRAM[offset] = data&0xff;
1023      state->m_mpDualPortRAM[offset] = data&0xff;
10491024   }
10501025}
10511026
10521027static READ8_HANDLER( namcos2_dualportram_byte_r )
10531028{
1054   return mpDualPortRAM[offset];
1029   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1030   return state->m_mpDualPortRAM[offset];
10551031}
10561032
10571033static WRITE8_HANDLER( namcos2_dualportram_byte_w )
10581034{
1059   mpDualPortRAM[offset] = data;
1035   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1036   state->m_mpDualPortRAM[offset] = data;
10601037}
10611038
10621039/* shared RAM memory handlers */
10631040
10641041static READ16_HANDLER( shareram1_r )
10651042{
1066   return mpSharedRAM1[offset];
1043   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1044   return state->m_mpSharedRAM1[offset];
10671045}
10681046
10691047static WRITE16_HANDLER( shareram1_w )
10701048{
1071   COMBINE_DATA( &mpSharedRAM1[offset] );
1049   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1050   COMBINE_DATA( &state->m_mpSharedRAM1[offset] );
10721051}
10731052
10741053/* some games have read-only areas where more ROMs are mapped */
10751054
10761055static READ16_HANDLER( datarom_r )
10771056{
1078   return mpDataROM[offset];
1057   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1058   return state->m_mpDataROM[offset];
10791059}
10801060
10811061static READ16_HANDLER( data2_r )
10821062{
1083   return mpDataROM[0x100000/2+offset];
1063   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1064   return state->m_mpDataROM[0x100000/2+offset];
10841065}
10851066
10861067/* palette memory handlers */
r11160r11161
11081089/*************************************************************/
11091090
11101091#define NAMCO21_68K_COMMON \
1111   AM_RANGE(0x200000, 0x20ffff) AM_READWRITE(dspram16_r,dspram16_w) AM_BASE(&namcos21_dspram16) \
1092   AM_RANGE(0x200000, 0x20ffff) AM_READWRITE(dspram16_r,dspram16_w) AM_BASE_MEMBER(namcos21_state, m_dspram16) \
11121093   AM_RANGE(0x280000, 0x280001) AM_WRITENOP /* written once on startup */ \
11131094   AM_RANGE(0x400000, 0x400001) AM_WRITE(pointram_control_w) \
11141095   AM_RANGE(0x440000, 0x440001) AM_READWRITE(pointram_data_r,pointram_data_w) \
r11160r11161
11191100   AM_RANGE(0x740000, 0x75ffff) AM_READWRITE(paletteram16_r,paletteram16_w) AM_BASE_GENERIC(paletteram) \
11201101   AM_RANGE(0x760000, 0x760001) AM_READWRITE(namcos21_video_enable_r,namcos21_video_enable_w) \
11211102   AM_RANGE(0x800000, 0x8fffff) AM_READ(datarom_r) \
1122   AM_RANGE(0x900000, 0x90ffff) AM_READWRITE(shareram1_r,shareram1_w) AM_BASE(&mpSharedRAM1) \
1103   AM_RANGE(0x900000, 0x90ffff) AM_READWRITE(shareram1_r,shareram1_w) AM_BASE_MEMBER(namcos21_state, m_mpSharedRAM1) \
11231104   AM_RANGE(0xa00000, 0xa00fff) AM_READWRITE(namcos2_68k_dualportram_word_r,namcos2_68k_dualportram_word_w) \
11241105   AM_RANGE(0xb00000, 0xb03fff) AM_READWRITE(NAMCO_C139_SCI_buffer_r,NAMCO_C139_SCI_buffer_w) \
11251106   AM_RANGE(0xb80000, 0xb8000f) AM_READWRITE(NAMCO_C139_SCI_register_r,NAMCO_C139_SCI_register_w) \
r11160r11161
11471128 *************************************************************/
11481129static READ16_HANDLER( winrun_dspcomram_r )
11491130{
1150   int bank = 1-(winrun_dspcomram_control[0x4/2]&1);
1151   UINT16 *mem = &winrun_dspcomram[0x1000*bank];
1131   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1132   int bank = 1-(state->m_winrun_dspcomram_control[0x4/2]&1);
1133   UINT16 *mem = &state->m_winrun_dspcomram[0x1000*bank];
11521134   return mem[offset];
11531135}
11541136static WRITE16_HANDLER( winrun_dspcomram_w )
11551137{
1156   int bank = 1-(winrun_dspcomram_control[0x4/2]&1);
1157   UINT16 *mem = &winrun_dspcomram[0x1000*bank];
1138   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1139   int bank = 1-(state->m_winrun_dspcomram_control[0x4/2]&1);
1140   UINT16 *mem = &state->m_winrun_dspcomram[0x1000*bank];
11581141   COMBINE_DATA( &mem[offset] );
11591142}
11601143
r11160r11161
11841167} /* winrun_cuskey_w */
11851168
11861169static void
1187winrun_flushpoly( void )
1170winrun_flushpoly( running_machine &machine )
11881171{
1189   if( winrun_poly_index>0 )
1172   namcos21_state *state = machine.driver_data<namcos21_state>();
1173   if( state->m_winrun_poly_index>0 )
11901174   {
1191      const UINT16 *pSource = winrun_poly_buf;
1175      const UINT16 *pSource = state->m_winrun_poly_buf;
11921176      UINT16 color;
11931177      int sx[4], sy[4], zcode[4];
11941178      int j;
r11160r11161
12011185            sy[j] = NAMCOS21_POLY_FRAME_HEIGHT/2 + (INT16)*pSource++;
12021186            zcode[j] = *pSource++;
12031187         }
1204         namcos21_DrawQuad( sx, sy, zcode, color&0x7fff );
1188         namcos21_DrawQuad( machine, sx, sy, zcode, color&0x7fff );
12051189      }
12061190      else
12071191      {
12081192         int quad_idx = color*6;
12091193         for(;;)
12101194         {
1211            UINT8 code = pointram[quad_idx++];
1212            color = pointram[quad_idx++];
1195            UINT8 code = state->m_pointram[quad_idx++];
1196            color = state->m_pointram[quad_idx++];
12131197            for( j=0; j<4; j++ )
12141198            {
1215               UINT8 vi = pointram[quad_idx++];
1199               UINT8 vi = state->m_pointram[quad_idx++];
12161200               sx[j] = NAMCOS21_POLY_FRAME_WIDTH/2  + (INT16)pSource[vi*3+0];
12171201               sy[j] = NAMCOS21_POLY_FRAME_HEIGHT/2 + (INT16)pSource[vi*3+1];
12181202               zcode[j] = pSource[vi*3+2];
12191203            }
1220            namcos21_DrawQuad( sx, sy, zcode, color&0x7fff );
1204            namcos21_DrawQuad( machine, sx, sy, zcode, color&0x7fff );
12211205            if( code&0x80 )
12221206            { /* end-of-quadlist marker */
12231207               break;
12241208            }
12251209         }
12261210      }
1227      winrun_poly_index = 0;
1211      state->m_winrun_poly_index = 0;
12281212   }
12291213} /* winrun_flushpoly */
12301214
12311215static READ16_HANDLER( winrun_poly_reset_r )
12321216{
1233   winrun_flushpoly();
1217   winrun_flushpoly(space->machine());
12341218   return 0;
12351219}
12361220
12371221static WRITE16_HANDLER( winrun_dsp_render_w )
12381222{
1239   if( winrun_poly_index<WINRUN_MAX_POLY_PARAM )
1223   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1224   if( state->m_winrun_poly_index<WINRUN_MAX_POLY_PARAM )
12401225   {
1241      winrun_poly_buf[winrun_poly_index++] = data;
1226      state->m_winrun_poly_buf[state->m_winrun_poly_index++] = data;
12421227   }
12431228   else
12441229   {
r11160r11161
12481233
12491234static WRITE16_HANDLER( winrun_dsp_pointrom_addr_w )
12501235{
1236   namcos21_state *state = space->machine().driver_data<namcos21_state>();
12511237   if( offset==0 )
12521238   { /* port 8 */
1253      winrun_pointrom_addr = data;
1239      state->m_winrun_pointrom_addr = data;
12541240   }
12551241   else
12561242   { /* port 9 */
1257      winrun_pointrom_addr |= (data<<16);
1243      state->m_winrun_pointrom_addr |= (data<<16);
12581244   }
12591245}
12601246
12611247static READ16_HANDLER( winrun_dsp_pointrom_data_r )
12621248{
1249   namcos21_state *state = space->machine().driver_data<namcos21_state>();
12631250   UINT16 *ptrom = (UINT16 *)space->machine().region("user2")->base();
1264   return ptrom[winrun_pointrom_addr++];
1251   return ptrom[state->m_winrun_pointrom_addr++];
12651252} /* winrun_dsp_pointrom_data_r */
12661253
12671254static WRITE16_HANDLER( winrun_dsp_complete_w )
12681255{
12691256   if( data )
12701257   {
1271      winrun_flushpoly();
1258      winrun_flushpoly(space->machine());
12721259      cputag_set_input_line(space->machine(), "dsp", INPUT_LINE_RESET, PULSE_LINE);
1273      namcos21_ClearPolyFrameBuffer();
1260      namcos21_ClearPolyFrameBuffer(space->machine());
12741261   }
12751262}
12761263
12771264static READ16_HANDLER( winrun_table_r )
12781265{
1279   return winrun_polydata[offset];
1266   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1267   return state->m_winrun_polydata[offset];
12801268}
12811269
12821270static ADDRESS_MAP_START( winrun_dsp_program, AS_PROGRAM, 16 )
r11160r11161
13081296
13091297static READ16_HANDLER( winrun_gpucomram_r )
13101298{
1311   return winrun_gpucomram[offset];
1299   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1300   return state->m_winrun_gpucomram[offset];
13121301}
13131302static WRITE16_HANDLER( winrun_gpucomram_w )
13141303{
1315   COMBINE_DATA( &winrun_gpucomram[offset] );
1304   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1305   COMBINE_DATA( &state->m_winrun_gpucomram[offset] );
13161306}
13171307
13181308static WRITE16_HANDLER( winrun_dspbios_w )
13191309{
1320   COMBINE_DATA( &winrun_dspbios[offset] );
1310   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1311   COMBINE_DATA( &state->m_winrun_dspbios[offset] );
13211312   if( offset==0xfff )
13221313   {
13231314      UINT16 *mem = (UINT16 *)space->machine().region("dsp")->base();
1324      memcpy( mem, winrun_dspbios, 0x2000 );
1325      winrun_dsp_alive = 1;
1315      memcpy( mem, state->m_winrun_dspbios, 0x2000 );
1316      state->m_winrun_dsp_alive = 1;
13261317   }
13271318} /* winrun_dspbios_w */
13281319
r11160r11161
13331324
13341325static READ16_HANDLER( winrun_68k_dspcomram_r )
13351326{
1336   int bank = winrun_dspcomram_control[0x4/2]&1;
1337   UINT16 *mem = &winrun_dspcomram[0x1000*bank];
1327   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1328   int bank = state->m_winrun_dspcomram_control[0x4/2]&1;
1329   UINT16 *mem = &state->m_winrun_dspcomram[0x1000*bank];
13381330   return mem[offset];
13391331}
13401332
13411333static WRITE16_HANDLER( winrun_68k_dspcomram_w )
13421334{
1343   int bank = winrun_dspcomram_control[0x4/2]&1;
1344   UINT16 *mem = &winrun_dspcomram[0x1000*bank];
1335   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1336   int bank = state->m_winrun_dspcomram_control[0x4/2]&1;
1337   UINT16 *mem = &state->m_winrun_dspcomram[0x1000*bank];
13451338   COMBINE_DATA( &mem[offset] );
13461339}
13471340
13481341static READ16_HANDLER( winrun_dspcomram_control_r )
13491342{
1350   return winrun_dspcomram_control[offset];
1343   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1344   return state->m_winrun_dspcomram_control[offset];
13511345}
13521346
13531347static WRITE16_HANDLER( winrun_dspcomram_control_w )
13541348{
1355   COMBINE_DATA( &winrun_dspcomram_control[offset] );
1349   namcos21_state *state = space->machine().driver_data<namcos21_state>();
1350   COMBINE_DATA( &state->m_winrun_dspcomram_control[offset] );
13561351}
13571352
13581353static ADDRESS_MAP_START( am_master_winrun, AS_PROGRAM, 16 )
r11160r11161
13601355   AM_RANGE(0x100000, 0x10ffff) AM_RAM /* work RAM */
13611356   AM_RANGE(0x180000, 0x183fff) AM_READWRITE(NAMCOS2_68K_eeprom_R,NAMCOS2_68K_eeprom_W)// AM_BASE(&namcos2_eeprom) AM_SIZE(&namcos2_eeprom_size)
13621357   AM_RANGE(0x1c0000, 0x1fffff) AM_READWRITE(namcos2_68k_master_C148_r,namcos2_68k_master_C148_w)
1363   AM_RANGE(0x250000, 0x25ffff) AM_RAM AM_BASE( &winrun_polydata )
1358   AM_RANGE(0x250000, 0x25ffff) AM_RAM AM_BASE_MEMBER(namcos21_state, m_winrun_polydata )
13641359   AM_RANGE(0x260000, 0x26ffff) AM_RAM /* unused? */
1365   AM_RANGE(0x280000, 0x281fff) AM_WRITE(winrun_dspbios_w) AM_BASE(&winrun_dspbios)
1360   AM_RANGE(0x280000, 0x281fff) AM_WRITE(winrun_dspbios_w) AM_BASE_MEMBER(namcos21_state, m_winrun_dspbios)
13661361   AM_RANGE(0x380000, 0x38000f) AM_READWRITE(winrun_dspcomram_control_r,winrun_dspcomram_control_w)
13671362   AM_RANGE(0x3c0000, 0x3c1fff) AM_READWRITE(winrun_68k_dspcomram_r,winrun_68k_dspcomram_w)
13681363   AM_RANGE(0x400000, 0x400001) AM_WRITE(pointram_control_w)
13691364   AM_RANGE(0x440000, 0x440001) AM_READWRITE(pointram_data_r,pointram_data_w)
13701365   AM_RANGE(0x600000, 0x60ffff) AM_READWRITE(winrun_gpucomram_r,winrun_gpucomram_w)
13711366   AM_RANGE(0x800000, 0x87ffff) AM_READ(datarom_r)
1372   AM_RANGE(0x900000, 0x90ffff) AM_READWRITE(shareram1_r,shareram1_w) AM_BASE(&mpSharedRAM1)
1367   AM_RANGE(0x900000, 0x90ffff) AM_READWRITE(shareram1_r,shareram1_w) AM_BASE_MEMBER(namcos21_state, m_mpSharedRAM1)
13731368   AM_RANGE(0xa00000, 0xa00fff) AM_READWRITE(namcos2_68k_dualportram_word_r,namcos2_68k_dualportram_word_w)
13741369   AM_RANGE(0xb00000, 0xb03fff) AM_READWRITE(NAMCO_C139_SCI_buffer_r,NAMCO_C139_SCI_buffer_w)
13751370   AM_RANGE(0xb80000, 0xb8000f) AM_READWRITE(NAMCO_C139_SCI_register_r,NAMCO_C139_SCI_register_w)
r11160r11161
13921387   AM_RANGE(0x100000, 0x100001) AM_READWRITE(winrun_gpu_color_r,winrun_gpu_color_w) /* ? */
13931388   AM_RANGE(0x180000, 0x19ffff) AM_RAM /* work RAM */
13941389   AM_RANGE(0x1c0000, 0x1fffff) AM_READWRITE(namcos2_68k_gpu_C148_r,namcos2_68k_gpu_C148_w)
1395   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE( &winrun_gpucomram )
1390   AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE_MEMBER(namcos21_state, m_winrun_gpucomram )
13961391   AM_RANGE(0x400000, 0x41ffff) AM_READWRITE(paletteram16_r,paletteram16_w) AM_BASE_GENERIC( paletteram )
13971392   AM_RANGE(0x600000, 0x6fffff) AM_READ(gpu_data_r)
13981393   AM_RANGE(0xc00000, 0xcfffff) AM_READWRITE(winrun_gpu_videoram_r,winrun_gpu_videoram_w)
r11160r11161
14101405   AM_RANGE(0x3000, 0x3003) AM_WRITENOP /* ? */
14111406   AM_RANGE(0x4000, 0x4001) AM_DEVREADWRITE("ymsnd", ym2151_r,ym2151_w)
14121407   AM_RANGE(0x5000, 0x6fff) AM_DEVREADWRITE("c140", c140_r,c140_w)
1413   AM_RANGE(0x7000, 0x77ff) AM_READWRITE(namcos2_dualportram_byte_r,namcos2_dualportram_byte_w) AM_BASE(&mpDualPortRAM)
1408   AM_RANGE(0x7000, 0x77ff) AM_READWRITE(namcos2_dualportram_byte_r,namcos2_dualportram_byte_w) AM_BASE_MEMBER(namcos21_state, m_mpDualPortRAM)
14141409   AM_RANGE(0x7800, 0x7fff) AM_READWRITE(namcos2_dualportram_byte_r,namcos2_dualportram_byte_w) /* mirror */
14151410   AM_RANGE(0x8000, 0x9fff) AM_RAM
14161411   AM_RANGE(0xa000, 0xbfff) AM_WRITENOP /* amplifier enable on 1st write */
r11160r11161
14411436   AM_RANGE(0x3001, 0x3001) AM_READ_PORT("DIAL1")
14421437   AM_RANGE(0x3002, 0x3002) AM_READ_PORT("DIAL2")
14431438   AM_RANGE(0x3003, 0x3003) AM_READ_PORT("DIAL3")
1444   AM_RANGE(0x5000, 0x57ff) AM_READWRITE(namcos2_dualportram_byte_r,namcos2_dualportram_byte_w) AM_BASE(&mpDualPortRAM)
1439   AM_RANGE(0x5000, 0x57ff) AM_READWRITE(namcos2_dualportram_byte_r,namcos2_dualportram_byte_w) AM_BASE_MEMBER(namcos21_state, m_mpDualPortRAM)
14451440   AM_RANGE(0x6000, 0x6fff) AM_READNOP            /* watchdog */
14461441   AM_RANGE(0x8000, 0xffff) AM_ROM
14471442ADDRESS_MAP_END
r11160r11161
14581453   AM_RANGE(0x740000, 0x75ffff) AM_READWRITE(paletteram16_r,paletteram16_w) AM_BASE_GENERIC(paletteram) \
14591454   AM_RANGE(0x760000, 0x760001) AM_READWRITE(namcos21_video_enable_r,namcos21_video_enable_w) \
14601455   AM_RANGE(0x800000, 0x8fffff) AM_READ(datarom_r) \
1461   AM_RANGE(0x900000, 0x90ffff) AM_READWRITE(shareram1_r,shareram1_w) AM_BASE(&mpSharedRAM1) \
1456   AM_RANGE(0x900000, 0x90ffff) AM_READWRITE(shareram1_r,shareram1_w) AM_BASE_MEMBER(namcos21_state, m_mpSharedRAM1) \
14621457   AM_RANGE(0xa00000, 0xa00fff) AM_READWRITE(namcos2_68k_dualportram_word_r,namcos2_68k_dualportram_word_w) \
14631458   AM_RANGE(0xb00000, 0xb03fff) AM_READWRITE(NAMCO_C139_SCI_buffer_r,NAMCO_C139_SCI_buffer_w) \
14641459   AM_RANGE(0xb80000, 0xb8000f) AM_READWRITE(NAMCO_C139_SCI_register_r,NAMCO_C139_SCI_register_w) \
r11160r11161
14691464   AM_RANGE(0x100000, 0x10ffff) AM_RAM /* private work RAM */
14701465   AM_RANGE(0x180000, 0x183fff) AM_READWRITE(NAMCOS2_68K_eeprom_R,NAMCOS2_68K_eeprom_W)// AM_BASE(&namcos2_eeprom) AM_SIZE(&namcos2_eeprom_size)
14711466   AM_RANGE(0x1c0000, 0x1fffff) AM_READWRITE(namcos2_68k_master_C148_r,namcos2_68k_master_C148_w)
1472   AM_RANGE(0x250000, 0x25ffff) AM_RAM AM_BASE( &winrun_polydata )
1473   AM_RANGE(0x280000, 0x281fff) AM_WRITE(winrun_dspbios_w) AM_BASE(&winrun_dspbios)
1467   AM_RANGE(0x250000, 0x25ffff) AM_RAM AM_BASE_MEMBER(namcos21_state, m_winrun_polydata )
1468   AM_RANGE(0x280000, 0x281fff) AM_WRITE(winrun_dspbios_w) AM_BASE_MEMBER(namcos21_state, m_winrun_dspbios)
14741469   AM_RANGE(0x380000, 0x38000f) AM_READWRITE(winrun_dspcomram_control_r,winrun_dspcomram_control_w)
14751470   AM_RANGE(0x3c0000, 0x3c1fff) AM_READWRITE(winrun_68k_dspcomram_r,winrun_68k_dspcomram_w)
14761471   AM_RANGE(0x400000, 0x400001) AM_WRITE(pointram_control_w)
r11160r11161
17691764   ROM_LOAD("ac1-voi2.12d",0x100000,0x80000,CRC(1fcb51ba) SHA1(80fc815e5fad76d20c3795ab1d89b57d9abc3efd) )
17701765   ROM_LOAD("ac1-voi3.12e",0x180000,0x80000,CRC(cd202e06) SHA1(72a18f5ba402caefef14b8d1304f337eaaa3eb1d) )
17711766
1772//  ROM_REGION( 0x0600, "plds", 0 )
1773//  ROM_LOAD( "gal16v8a-3pdsp5.17d", 0x0000, 0x0117, CRC(799c1f26) SHA1(d28ed1b9fa78180c5a0b01a7198a2870137c7349) )
1774//  ROM_LOAD( "plhs18p8-3pobj3.17n", 0x0200, 0x0149, CRC(9625f469) SHA1(29158a3d37485fb0714d0a60bcd07abd26a3f56e) )
1775//  ROM_LOAD( "plhs18p8-3pobj4.17n", 0x0400, 0x0149, CRC(1b7c90c1) SHA1(ae65aab7a191cdf1af488e144af22b9d8669c903) )
1767   ROM_REGION( 0x0600, "plds", 0 )
1768   ROM_LOAD( "gal16v8a-3pdsp5.17d", 0x0000, 0x0117, CRC(799c1f26) SHA1(d28ed1b9fa78180c5a0b01a7198a2870137c7349) )
1769   ROM_LOAD( "plhs18p8-3pobj3.17n", 0x0200, 0x0149, CRC(9625f469) SHA1(29158a3d37485fb0714d0a60bcd07abd26a3f56e) )
1770   ROM_LOAD( "plhs18p8-3pobj4.17n", 0x0400, 0x0149, CRC(1b7c90c1) SHA1(ae65aab7a191cdf1af488e144af22b9d8669c903) )
17761771ROM_END
17771772
17781773ROM_START( aircombj )
r11160r11161
22032198
22042199static void namcos21_init( running_machine &machine, int game_type )
22052200{
2201   namcos21_state *state = machine.driver_data<namcos21_state>();
22062202   namcos2_gametype = game_type;
2207   pointram = auto_alloc_array(machine, UINT8, PTRAM_SIZE);
2208   mpDataROM = (UINT16 *)machine.region( "user1" )->base();
2203   state->m_pointram = auto_alloc_array(machine, UINT8, PTRAM_SIZE);
2204   state->m_mpDataROM = (UINT16 *)machine.region( "user1" )->base();
22092205   InitDSP(machine);
2210   mbNeedsKickstart = 20;
2206   state->m_mbNeedsKickstart = 20;
22112207   if( game_type==NAMCOS21_CYBERSLED )
22122208   {
2213      mbNeedsKickstart = 200;
2209      state->m_mbNeedsKickstart = 200;
22142210   }
22152211} /* namcos21_init */
22162212
22172213static DRIVER_INIT( winrun )
22182214{
2215   namcos21_state *state = machine.driver_data<namcos21_state>();
22192216   UINT16 *pMem = (UINT16 *)machine.region("dsp")->base();
22202217   int pc = 0;
22212218   pMem[pc++] = 0xff80; /* b */
22222219   pMem[pc++] = 0;
22232220
2224   winrun_dspcomram = auto_alloc_array(machine, UINT16, 0x1000*2);
2221   state->m_winrun_dspcomram = auto_alloc_array(machine, UINT16, 0x1000*2);
22252222
22262223   namcos2_gametype = NAMCOS21_WINRUN91;
2227   mpDataROM = (UINT16 *)machine.region( "user1" )->base();
2228   pointram = auto_alloc_array(machine, UINT8, PTRAM_SIZE);
2229   pointram_idx = 0;
2230   mbNeedsKickstart = 0;
2224   state->m_mpDataROM = (UINT16 *)machine.region( "user1" )->base();
2225   state->m_pointram = auto_alloc_array(machine, UINT8, PTRAM_SIZE);
2226   state->m_pointram_idx = 0;
2227   state->m_mbNeedsKickstart = 0;
22312228}
22322229
22332230static DRIVER_INIT( aircombt )
r11160r11161
22592256
22602257static DRIVER_INIT( driveyes )
22612258{
2259   namcos21_state *state = machine.driver_data<namcos21_state>();
22622260   UINT16 *pMem = (UINT16 *)machine.region("dsp")->base();
22632261   int pc = 0;
22642262   pMem[pc++] = 0xff80; /* b */
22652263   pMem[pc++] = 0;
2266   winrun_dspcomram = auto_alloc_array(machine, UINT16, 0x1000*2);
2264   state->m_winrun_dspcomram = auto_alloc_array(machine, UINT16, 0x1000*2);
22672265   namcos2_gametype = NAMCOS21_DRIVERS_EYES;
2268   mpDataROM = (UINT16 *)machine.region( "user1" )->base();
2269   pointram = auto_alloc_array(machine, UINT8, PTRAM_SIZE);
2270   pointram_idx = 0;
2271   mbNeedsKickstart = 0;
2266   state->m_mpDataROM = (UINT16 *)machine.region( "user1" )->base();
2267   state->m_pointram = auto_alloc_array(machine, UINT8, PTRAM_SIZE);
2268   state->m_pointram_idx = 0;
2269   state->m_mbNeedsKickstart = 0;
22722270}
22732271
22742272/*************************************************************/
src/mame/drivers/kinst.c
r11160r11161
335335      case 2:      /* $90 -- sound return */
336336         result = input_port_read(space->machine(), portnames[offset]);
337337         result &= ~0x0002;
338         if (dcs_control_r() & 0x800)
338         if (dcs_control_r(space->machine()) & 0x800)
339339            result |= 0x0002;
340340         break;
341341
r11160r11161
376376         break;
377377
378378      case 1:      /* $88 - sound reset */
379         dcs_reset_w(~data & 0x01);
379         dcs_reset_w(space->machine(), ~data & 0x01);
380380         break;
381381
382382      case 2:      /* $90 - sound control */
383383         if (!(olddata & 0x02) && (state->m_control[offset] & 0x02))
384            dcs_data_w(state->m_control[3]);
384            dcs_data_w(space->machine(), state->m_control[3]);
385385         break;
386386
387387      case 3:      /* $98 - sound data */
src/mame/drivers/pcxt.c
r11160r11161
683683   cputag_set_input_line(device->machine(), "maincpu", 0, state ? HOLD_LINE : CLEAR_LINE);
684684}
685685
686static READ8_DEVICE_HANDLER( get_slave_ack )
687{
688   pcxt_state *state = device->machine().driver_data<pcxt_state>();
689   if (offset==2) { // IRQ = 2
690      return pic8259_acknowledge(state->m_pic8259_2);
691   }
692   return 0x00;
693}
694
686695static const struct pic8259_interface pic8259_1_config =
687696{
688   DEVCB_LINE(pic8259_1_set_int_line)
697   DEVCB_LINE(pic8259_1_set_int_line),
698   DEVCB_LINE_VCC,
699   DEVCB_HANDLER(get_slave_ack)
689700};
690701
691702static const struct pic8259_interface pic8259_2_config =
692703{
693   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w)
704   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w),
705   DEVCB_LINE_GND,
706   DEVCB_NULL
694707};
695708
696709static IRQ_CALLBACK(irq_callback)
697710{
698711   pcxt_state *state = device->machine().driver_data<pcxt_state>();
699   int r = 0;
700   r = pic8259_acknowledge(state->m_pic8259_2);
701   if (r==0)
702   {
703      r = pic8259_acknowledge(state->m_pic8259_1);
704   }
705   return r;
712   return pic8259_acknowledge(state->m_pic8259_1);
706713}
707714
708715static ADDRESS_MAP_START( filetto_map, AS_PROGRAM, 8 )
src/mame/drivers/xybots.c
r11160r11161
2121#include "cpu/m68000/m68000.h"
2222#include "machine/atarigen.h"
2323#include "audio/atarijsa.h"
24#include "video/atarimo.h"
2425#include "includes/xybots.h"
2526
2627
r11160r11161
8990   AM_RANGE(0x010000, 0x03ffff) AM_MIRROR(0x7c0000) AM_ROM
9091   AM_RANGE(0xff8000, 0xff8fff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(xybots_state, m_alpha)
9192   AM_RANGE(0xff9000, 0xffadff) AM_MIRROR(0x7f8000) AM_RAM
92   AM_RANGE(0xffae00, 0xffafff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
93   AM_RANGE(0xffae00, 0xffafff) AM_MIRROR(0x7f8000) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
9394   AM_RANGE(0xffb000, 0xffbfff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(xybots_state, m_playfield)
9495   AM_RANGE(0xffc000, 0xffc7ff) AM_MIRROR(0x7f8800) AM_RAM_WRITE(paletteram16_IIIIRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram)
9596   AM_RANGE(0xffd000, 0xffdfff) AM_MIRROR(0x7f8000) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_SHARE("eeprom")
src/mame/drivers/metro.c
r11160r11161
11171117
11181118#define KARATOUR_OFFS( _x_ ) ((_x_) & (0x3f)) + (((_x_) & ~(0x3f)) * (0x100 / 0x40))
11191119
1120#define KARATOUR_VRAM( _n_ ) \
1121static READ16_HANDLER( karatour_vram_##_n_##_r ) \
1122{ \
1123   metro_state *state = space->machine().driver_data<metro_state>(); \
1124   return state->m_vram_##_n_[KARATOUR_OFFS(offset)]; \
1125} \
1126static WRITE16_HANDLER( karatour_vram_##_n_##_w ) \
1127{ \
1128   metro_vram_##_n_##_w(space, KARATOUR_OFFS(offset), data, mem_mask); \
1129}
1120static READ16_HANDLER( karatour_vram_0_r ) { return space->machine().driver_data<metro_state>()->m_vram_0[KARATOUR_OFFS(offset)]; }
1121static READ16_HANDLER( karatour_vram_1_r ) { return space->machine().driver_data<metro_state>()->m_vram_1[KARATOUR_OFFS(offset)]; }
1122static READ16_HANDLER( karatour_vram_2_r ) { return space->machine().driver_data<metro_state>()->m_vram_2[KARATOUR_OFFS(offset)]; }
11301123
1131KARATOUR_VRAM( 0 )
1132KARATOUR_VRAM( 1 )
1133KARATOUR_VRAM( 2 )
1124static WRITE16_HANDLER( karatour_vram_0_w ) { metro_vram_0_w(space, KARATOUR_OFFS(offset), data, mem_mask); }
1125static WRITE16_HANDLER( karatour_vram_1_w ) { metro_vram_1_w(space, KARATOUR_OFFS(offset), data, mem_mask); }
1126static WRITE16_HANDLER( karatour_vram_2_w ) { metro_vram_2_w(space, KARATOUR_OFFS(offset), data, mem_mask); }
11341127
11351128static ADDRESS_MAP_START( karatour_map, AS_PROGRAM, 16 )
11361129   AM_RANGE(0x000000, 0x07ffff) AM_ROM                                 // ROM
r11160r11161
42664259static MACHINE_CONFIG_START( pururun, metro_state )
42674260
42684261   /* basic machine hardware */
4269   MCFG_CPU_ADD("maincpu", M68000, 12000000)
4262   MCFG_CPU_ADD("maincpu", M68000, XTAL_24MHz/2)      /* Not confirmed */
42704263   MCFG_CPU_PROGRAM_MAP(pururun_map)
4271   //MCFG_CPU_VBLANK_INT_HACK(msgogo_interrupt,262)    /* fixes the title screen scroll in GunMaster, but makes the game painfully slow */
4272   MCFG_CPU_VBLANK_INT_HACK(metro_interrupt,10)    /* ? */
4264   //MCFG_CPU_VBLANK_INT_HACK(msgogo_interrupt,262)    /* fixes the title screen scroll in GunMaster, but makes the game painfully slow */
4265   MCFG_CPU_VBLANK_INT_HACK(metro_interrupt,10)      /* ? */
42734266
4274   MCFG_CPU_ADD("audiocpu", UPD7810, 12000000)
4267   MCFG_CPU_ADD("audiocpu", UPD7810, XTAL_24MHz/2)      /* Not confiremd */
42754268   MCFG_CPU_CONFIG(metro_cpu_config)
42764269   MCFG_CPU_PROGRAM_MAP(metro_sound_map)
42774270   MCFG_CPU_IO_MAP(daitorid_sound_io_map)
r11160r11161
42964289   /* sound hardware */
42974290   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
42984291
4299   MCFG_SOUND_ADD("ymsnd", YM2151, 4000000)
4292   MCFG_SOUND_ADD("ymsnd", YM2151, XTAL_3_579545MHz)   /* Confirmed match to reference video */
43004293   MCFG_SOUND_CONFIG(ym2151_config)
43014294   MCFG_SOUND_ROUTE(0, "lspeaker", 0.80)
43024295   MCFG_SOUND_ROUTE(1, "rspeaker", 0.80)
43034296
4304   MCFG_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified
4297   MCFG_OKIM6295_ADD("oki", XTAL_3_579545MHz/3, OKIM6295_PIN7_HIGH)// was /128.. so pin 7 not verified - not confirmed
43054298   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40)
43064299   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
43074300MACHINE_CONFIG_END
src/mame/drivers/namcos23.c
r11160r11161
989989#define S23_HSYNC   (16666150)
990990#define S23_MODECLOCK   (130205)
991991
992static tilemap_t *bgtilemap;
993static UINT32 *namcos23_textram, *namcos23_shared_ram, *gmen_sh2_shared;
994static UINT32 *namcos23_charram;
995static UINT8 namcos23_jvssense;
996static INT32 has_jvsio;
992enum { MODEL, FLUSH };
997993
998static bool ctl_vbl_active;
999static UINT8 ctl_led;
1000static UINT16 ctl_inp_buffer[2];
994struct namcos23_render_entry {
995   int type;
1001996
1002static UINT16 c417_ram[0x10000], c417_adr = 0;
1003static UINT32 c417_pointrom_adr = 0;
997   union {
998      struct {
999         UINT16 model;
1000         INT16 m[9];
1001         INT32 v[3];
1002         float scaling;
1003      } model;
1004   };
1005};
10041006
1005static UINT16 c412_sdram_a[0x100000]; // Framebuffers, probably
1006static UINT16 c412_sdram_b[0x100000];
1007static UINT16 c412_sram[0x20000];     // Ram-based tiles for rendering
1008static UINT16 c412_pczram[0x200];     // Ram-based tilemap for rendering, or something else
1009static UINT32 c412_adr = 0;
1007struct namcos23_render_data {
1008   running_machine *machine;
1009   const pen_t *pens;
1010   UINT32 (*texture_lookup)(running_machine &machine, const pen_t *pens, float x, float y);
1011};
10101012
1011static UINT16 c421_dram_a[0x40000];
1012static UINT16 c421_dram_b[0x40000];
1013static UINT16 c421_sram[0x8000];
1014static UINT32 c421_adr = 0;
1013struct namcos23_poly_entry {
1014   namcos23_render_data rd;
1015   float zkey;
1016   int front;
1017   int vertex_count;
1018   poly_vertex pv[16];
1019};
10151020
1016static INT16 s23_c422_regs[0x10];
1017static int s23_subcpu_running;
1021enum { RENDER_MAX_ENTRIES = 1000, POLY_MAX_ENTRIES = 10000 };
10181022
1019static emu_timer *c361_timer;
10201023
1021static UINT32 p3d_address, p3d_size;
1024typedef struct
1025{
1026   UINT16 ram[0x10000];
1027   UINT16 adr;
1028   UINT32 pointrom_adr;
1029} c417_t;
10221030
1023static const UINT32 *ptrom;
1024static const UINT16 *tmlrom;
1025static const UINT8  *tmhrom, *texrom;
1026static UINT32 tileid_mask, tile_mask, ptrom_limit;
1031typedef struct
1032{
1033   UINT16 sdram_a[0x100000]; // Framebuffers, probably
1034   UINT16 sdram_b[0x100000];
1035   UINT16 sram[0x20000];     // Ram-based tiles for rendering
1036   UINT16 pczram[0x200];     // Ram-based tilemap for rendering, or something else
1037   UINT32 adr;
1038} c412_t;
10271039
1040typedef struct
1041{
1042   UINT16 dram_a[0x40000];
1043   UINT16 dram_b[0x40000];
1044   UINT16 sram[0x8000];
1045   UINT32 adr;
1046} c421_t;
1047
1048typedef struct
1049{
1050   INT16 regs[0x10];
1051} c422_t;
1052
1053typedef struct
1054{
1055   emu_timer *timer;
1056   int scanline;
1057} c361_t;
1058
1059typedef struct
1060{
1061   poly_manager *polymgr;
1062   int cur;
1063   int poly_count;
1064   int count[2];
1065   namcos23_render_entry entries[2][RENDER_MAX_ENTRIES];
1066   namcos23_poly_entry polys[POLY_MAX_ENTRIES];
1067   namcos23_poly_entry *poly_order[POLY_MAX_ENTRIES];
1068} render_t;
1069
1070class namcos23_state : public driver_device
1071{
1072public:
1073   namcos23_state(running_machine &machine, const driver_device_config_base &config)
1074      : driver_device(machine, config) { }
1075
1076   c361_t m_c361;
1077   c417_t m_c417;
1078   c412_t m_c412;
1079   c421_t m_c421;
1080   c422_t m_c422;
1081   render_t m_render;
1082
1083   tilemap_t *m_bgtilemap;
1084   UINT32 *m_textram;
1085   UINT32 *m_shared_ram;
1086   UINT32 *m_gmen_sh2_shared;
1087   UINT32 *m_charram;
1088   UINT8 m_jvssense;
1089   INT32 m_has_jvsio;
1090   bool m_ctl_vbl_active;
1091   UINT8 m_ctl_led;
1092   UINT16 m_ctl_inp_buffer[2];
1093   int m_s23_subcpu_running;
1094   UINT32 m_p3d_address;
1095   UINT32 m_p3d_size;
1096   const UINT32 *m_ptrom;
1097   const UINT16 *m_tmlrom;
1098   const UINT8 *m_tmhrom;
1099   const UINT8 *m_texrom;
1100   UINT32 m_tileid_mask;
1101   UINT32 m_tile_mask;
1102   UINT32 m_ptrom_limit;
1103
10281104// It may only be 128
10291105// At 0x1e bytes per slot, rounded up to 0x20, that's 0x1000 to 0x2000 bytes.
10301106// That fits pretty much anywhere, including inside a IC
r11160r11161
10331109// Matrices are stored in signed 2.14 fixed point
10341110// Vectors are stored in signed 10.14 fixed point
10351111
1036static INT16 matrices[256][9];
1037static INT32 vectors[256][3];
1038static INT32 light_vector[3];
1039static UINT16 scaling;
1112   INT16 m_matrices[256][9];
1113   INT32 m_vectors[256][3];
1114   INT32 m_light_vector[3];
1115   UINT16 m_scaling;
1116   INT32 m_spv[3];
1117   INT16 m_spm[3];
10401118
1119   int m_s23_porta;
1120   int m_s23_rtcstate;
1121   int m_s23_lastpB;
1122   int m_s23_setstate;
1123   int m_s23_setnum;
1124   int m_s23_settings[8];
1125   UINT8 m_maintoio[128];
1126   UINT8 m_mi_rd;
1127   UINT8 m_mi_wr;
1128   UINT8 m_iotomain[128];
1129   UINT8 m_im_rd;
1130   UINT8 m_im_wr;
1131   UINT8 m_s23_tssio_port_4;
1132};
10411133
1134
1135
10421136static UINT16 nthword( const UINT32 *pSource, int offs )
10431137{
10441138   pSource += offs/2;
r11160r11161
10471141
10481142static TILE_GET_INFO( TextTilemapGetInfo )
10491143{
1050   UINT16 data = nthword( namcos23_textram,tile_index );
1144   namcos23_state *state = machine.driver_data<namcos23_state>();
1145   UINT16 data = nthword( state->m_textram,tile_index );
10511146  /**
10521147    * x---.----.----.---- blend
10531148    * xxxx.----.----.---- palette select
r11160r11161
10591154
10601155static WRITE32_HANDLER( namcos23_textram_w )
10611156{
1062   COMBINE_DATA( &namcos23_textram[offset] );
1063   tilemap_mark_tile_dirty(bgtilemap, offset*2);
1064   tilemap_mark_tile_dirty(bgtilemap, (offset*2)+1);
1157   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1158   COMBINE_DATA( &state->m_textram[offset] );
1159   tilemap_mark_tile_dirty(state->m_bgtilemap, offset*2);
1160   tilemap_mark_tile_dirty(state->m_bgtilemap, (offset*2)+1);
10651161}
10661162
10671163static WRITE32_HANDLER( s23_txtchar_w )
10681164{
1069   COMBINE_DATA(&namcos23_charram[offset]);
1165   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1166   COMBINE_DATA(&state->m_charram[offset]);
10701167   gfx_element_mark_dirty(space->machine().gfx[0], offset/32);
10711168}
10721169
r11160r11161
11011198
11021199static READ16_HANDLER(s23_c417_r)
11031200{
1201   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1202   c417_t &c417 = state->m_c417;
1203
11041204   switch(offset) {
11051205      /* According to timecrs2c, +0 is the status word with bits being:
11061206           15: test mode flag (huh?)
r11160r11161
11171217           0:  xcpreq
11181218         */
11191219   case 0: return 0x8e | (space->machine().primary_screen->vblank() ? 0x0000 : 0x8000);
1120   case 1: return c417_adr;
1220   case 1: return c417.adr;
11211221   case 4:
1122      //      logerror("c417_r %04x = %04x (%08x, %08x)\n", c417_adr, c417_ram[c417_adr], cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
1123      return c417_ram[c417_adr];
1222      //      logerror("c417_r %04x = %04x (%08x, %08x)\n", c417.adr, c417.ram[c417.adr], cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
1223      return c417.ram[c417.adr];
11241224   case 5:
1125      if(c417_pointrom_adr >= ptrom_limit)
1225      if(c417.pointrom_adr >= state->m_ptrom_limit)
11261226         return 0xffff;
1127      return ptrom[c417_pointrom_adr] >> 16;
1227      return state->m_ptrom[c417.pointrom_adr] >> 16;
11281228   case 6:
1129      if(c417_pointrom_adr >= ptrom_limit)
1229      if(c417.pointrom_adr >= state->m_ptrom_limit)
11301230         return 0xffff;
1131      return ptrom[c417_pointrom_adr];
1231      return state->m_ptrom[c417.pointrom_adr];
11321232
11331233   }
11341234
r11160r11161
11381238
11391239static WRITE16_HANDLER(s23_c417_w)
11401240{
1141    switch(offset) {
1142    case 0:
1241   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1242   c417_t &c417 = state->m_c417;
1243
1244   switch(offset) {
1245   case 0:
11431246      logerror("p3d PIO %04x\n", data);
11441247      break;
1145    case 1:
1146        COMBINE_DATA(&c417_adr);
1147        break;
1248   case 1:
1249      COMBINE_DATA(&c417.adr);
1250      break;
11481251   case 2:
1149      c417_pointrom_adr = (c417_pointrom_adr << 16) | data;
1252      c417.pointrom_adr = (c417.pointrom_adr << 16) | data;
11501253      break;
11511254   case 3:
1152      c417_pointrom_adr = 0;
1255      c417.pointrom_adr = 0;
11531256      break;
1154    case 4:
1155      //        logerror("c417_w %04x = %04x (%08x, %08x)\n", c417_adr, data, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
1156        COMBINE_DATA(c417_ram + c417_adr);
1157        break;
1158    case 7:
1159       logerror("c417_w: ack IRQ 2 (%x)\n", data);
1160       cputag_set_input_line(space->machine(), "maincpu", MIPS3_IRQ2, CLEAR_LINE);
1161       break;
1162    default:
1163        logerror("c417_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
1164        break;
1165    }
1257   case 4:
1258      //        logerror("c417_w %04x = %04x (%08x, %08x)\n", c417.adr, data, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
1259      COMBINE_DATA(c417.ram + c417.adr);
1260      break;
1261   case 7:
1262      logerror("c417_w: ack IRQ 2 (%x)\n", data);
1263      cputag_set_input_line(space->machine(), "maincpu", MIPS3_IRQ2, CLEAR_LINE);
1264      break;
1265   default:
1266      logerror("c417_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
1267      break;
1268   }
11661269}
11671270
11681271static READ16_HANDLER(s23_c412_ram_r)
11691272{
1273   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1274   c412_t &c412 = state->m_c412;
1275
11701276   //  logerror("c412_ram_r %06x (%08x, %08x)\n", offset, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
11711277   if(offset < 0x100000)
1172      return c412_sdram_a[offset & 0xfffff];
1278      return c412.sdram_a[offset & 0xfffff];
11731279   else if(offset < 0x200000)
1174      return c412_sdram_b[offset & 0xfffff];
1280      return c412.sdram_b[offset & 0xfffff];
11751281   else if(offset < 0x220000)
1176      return c412_sram   [offset & 0x1ffff];
1282      return c412.sram   [offset & 0x1ffff];
11771283   else if(offset < 0x220200)
1178      return c412_pczram [offset & 0x001ff];
1284      return c412.pczram [offset & 0x001ff];
11791285
11801286   return 0xffff;
11811287}
11821288
11831289static WRITE16_HANDLER(s23_c412_ram_w)
11841290{
1291   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1292   c412_t &c412 = state->m_c412;
1293
11851294   //  logerror("c412_ram_w %06x = %04x (%08x, %08x)\n", offset, data, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
11861295   if(offset < 0x100000)
1187      COMBINE_DATA(c412_sdram_a + (offset & 0xfffff));
1296      COMBINE_DATA(c412.sdram_a + (offset & 0xfffff));
11881297   else if(offset < 0x200000)
1189      COMBINE_DATA(c412_sdram_b + (offset & 0xfffff));
1298      COMBINE_DATA(c412.sdram_b + (offset & 0xfffff));
11901299   else if(offset < 0x220000)
1191      COMBINE_DATA(c412_sram    + (offset & 0x1ffff));
1300      COMBINE_DATA(c412.sram    + (offset & 0x1ffff));
11921301   else if(offset < 0x220200)
1193      COMBINE_DATA(c412_pczram  + (offset & 0x001ff));
1302      COMBINE_DATA(c412.pczram  + (offset & 0x001ff));
11941303}
11951304
11961305static READ16_HANDLER(s23_c412_r)
11971306{
1307   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1308   c412_t &c412 = state->m_c412;
1309
11981310   switch(offset) {
11991311   case 3:
12001312      // 0001 = busy, 0002 = game uploads things
12011313      return 0x0002;
1202   case 8: return c412_adr;
1203   case 9: return c412_adr >> 16;
1204   case 10: return s23_c412_ram_r(space, c412_adr, mem_mask);
1314   case 8: return c412.adr;
1315   case 9: return c412.adr >> 16;
1316   case 10: return s23_c412_ram_r(space, c412.adr, mem_mask);
12051317   }
12061318
12071319   logerror("c412_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
r11160r11161
12101322
12111323static WRITE16_HANDLER(s23_c412_w)
12121324{
1213    switch(offset) {
1214   case 8: c412_adr = (data & mem_mask) | (c412_adr & (0xffffffff ^ mem_mask)); break;
1215   case 9: c412_adr = ((data & mem_mask) << 16) | (c412_adr & (0xffffffff ^ (mem_mask << 16))); break;
1216   case 10: s23_c412_ram_w(space, c412_adr, data, mem_mask); c412_adr += 2; break;
1217    default:
1218        logerror("c412_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
1219        break;
1220    }
1325   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1326   c412_t &c412 = state->m_c412;
1327
1328   switch(offset) {
1329   case 8: c412.adr = (data & mem_mask) | (c412.adr & (0xffffffff ^ mem_mask)); break;
1330   case 9: c412.adr = ((data & mem_mask) << 16) | (c412.adr & (0xffffffff ^ (mem_mask << 16))); break;
1331   case 10: s23_c412_ram_w(space, c412.adr, data, mem_mask); c412.adr += 2; break;
1332   default:
1333      logerror("c412_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
1334      break;
1335   }
12211336}
12221337
12231338static READ16_HANDLER(s23_c421_ram_r)
12241339{
1340   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1341   c421_t &c421 = state->m_c421;
1342
12251343   //  logerror("c421_ram_r %06x (%08x, %08x)\n", offset, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
12261344   if(offset < 0x40000)
1227      return c421_dram_a[offset & 0x3ffff];
1345      return c421.dram_a[offset & 0x3ffff];
12281346   else if(offset < 0x80000)
1229      return c421_dram_b[offset & 0x3ffff];
1347      return c421.dram_b[offset & 0x3ffff];
12301348   else if(offset < 0x88000)
1231      return c421_sram  [offset & 0x07fff];
1349      return c421.sram  [offset & 0x07fff];
12321350
12331351   return 0xffff;
12341352}
12351353
12361354static WRITE16_HANDLER(s23_c421_ram_w)
12371355{
1356   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1357   c421_t &c421 = state->m_c421;
1358
12381359   //  logerror("c421_ram_w %06x = %04x (%08x, %08x)\n", offset, data, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
12391360   if(offset < 0x40000)
1240      COMBINE_DATA(c421_dram_a + (offset & 0x3ffff));
1361      COMBINE_DATA(c421.dram_a + (offset & 0x3ffff));
12411362   else if(offset < 0x80000)
1242      COMBINE_DATA(c421_dram_b + (offset & 0x3ffff));
1363      COMBINE_DATA(c421.dram_b + (offset & 0x3ffff));
12431364   else if(offset < 0x88000)
1244      COMBINE_DATA(c421_sram   + (offset & 0x07fff));
1365      COMBINE_DATA(c421.sram   + (offset & 0x07fff));
12451366}
12461367
12471368static READ16_HANDLER(s23_c421_r)
12481369{
1370   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1371   c421_t &c421 = state->m_c421;
1372
12491373   switch(offset) {
1250   case 0: return s23_c421_ram_r(space, c421_adr & 0xfffff, mem_mask);
1251   case 2: return c421_adr >> 16;
1252   case 3: return c421_adr;
1374   case 0: return s23_c421_ram_r(space, c421.adr & 0xfffff, mem_mask);
1375   case 2: return c421.adr >> 16;
1376   case 3: return c421.adr;
12531377   }
12541378
12551379   logerror("c421_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
r11160r11161
12581382
12591383static WRITE16_HANDLER(s23_c421_w)
12601384{
1261    switch(offset) {
1262   case 0: s23_c421_ram_w(space, c421_adr & 0xfffff, data, mem_mask); c421_adr += 2; break;
1263   case 2: c421_adr = ((data & mem_mask) << 16) | (c421_adr & (0xffffffff ^ (mem_mask << 16))); break;
1264   case 3: c421_adr = (data & mem_mask) | (c421_adr & (0xffffffff ^ mem_mask)); break;
1265    default:
1266        logerror("c421_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
1267        break;
1268    }
1385   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1386   c421_t &c421 = state->m_c421;
1387
1388   switch(offset) {
1389   case 0: s23_c421_ram_w(space, c421.adr & 0xfffff, data, mem_mask); c421.adr += 2; break;
1390   case 2: c421.adr = ((data & mem_mask) << 16) | (c421.adr & (0xffffffff ^ (mem_mask << 16))); break;
1391   case 3: c421.adr = (data & mem_mask) | (c421.adr & (0xffffffff ^ mem_mask)); break;
1392   default:
1393      logerror("c421_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
1394      break;
1395   }
12691396}
12701397
12711398static WRITE16_HANDLER(s23_ctl_w)
12721399{
1400   namcos23_state *state = space->machine().driver_data<namcos23_state>();
12731401   switch(offset) {
12741402   case 0: {
1275      if(ctl_led != (data & 0xff)) {
1276         ctl_led = data;
1403      if(state->m_ctl_led != (data & 0xff)) {
1404         state->m_ctl_led = data;
12771405/*          logerror("LEDS %c%c%c%c%c%c%c%c\n",
1278                     ctl_led & 0x80 ? '.' : '#',
1279                     ctl_led & 0x40 ? '.' : '#',
1280                     ctl_led & 0x20 ? '.' : '#',
1281                     ctl_led & 0x10 ? '.' : '#',
1282                     ctl_led & 0x08 ? '.' : '#',
1283                     ctl_led & 0x04 ? '.' : '#',
1284                     ctl_led & 0x02 ? '.' : '#',
1285                     ctl_led & 0x01 ? '.' : '#');*/
1406                     state->m_ctl_led & 0x80 ? '.' : '#',
1407                     state->m_ctl_led & 0x40 ? '.' : '#',
1408                     state->m_ctl_led & 0x20 ? '.' : '#',
1409                     state->m_ctl_led & 0x10 ? '.' : '#',
1410                     state->m_ctl_led & 0x08 ? '.' : '#',
1411                     state->m_ctl_led & 0x04 ? '.' : '#',
1412                     state->m_ctl_led & 0x02 ? '.' : '#',
1413                     state->m_ctl_led & 0x01 ? '.' : '#');*/
12861414      }
12871415      break;
12881416   }
12891417
12901418   case 2: case 3:
12911419      // These may be coming from another CPU, in particular the I/O one
1292      ctl_inp_buffer[offset-2] = input_port_read(space->machine(), offset == 2 ? "P1" : "P2");
1420      state->m_ctl_inp_buffer[offset-2] = input_port_read(space->machine(), offset == 2 ? "P1" : "P2");
12931421      break;
12941422   case 5:
1295      if(ctl_vbl_active) {
1296         ctl_vbl_active = false;
1423      if(state->m_ctl_vbl_active) {
1424         state->m_ctl_vbl_active = false;
12971425         device_set_input_line(&space->device(), MIPS3_IRQ0, CLEAR_LINE);
12981426      }
12991427      break;
r11160r11161
13101438
13111439static READ16_HANDLER(s23_ctl_r)
13121440{
1441   namcos23_state *state = space->machine().driver_data<namcos23_state>();
13131442   switch(offset) {
13141443      // 0100 set freezes gorgon (polygon fifo flag)
13151444   case 1: return 0x0000 | input_port_read(space->machine(), "DSW");
13161445   case 2: case 3: {
1317      UINT16 res = ctl_inp_buffer[offset-2] & 0x800 ? 0xffff : 0x0000;
1318      ctl_inp_buffer[offset-2] = (ctl_inp_buffer[offset-2] << 1) | 1;
1446      UINT16 res = state->m_ctl_inp_buffer[offset-2] & 0x800 ? 0xffff : 0x0000;
1447      state->m_ctl_inp_buffer[offset-2] = (state->m_ctl_inp_buffer[offset-2] << 1) | 1;
13191448      return res;
13201449   }
13211450   }
r11160r11161
13241453}
13251454
13261455// raster timer.  TC2 indicates it's probably one-shot since it resets it each VBL...
1327static int c361_scanline;
13281456static TIMER_CALLBACK( c361_timer_cb )
13291457{
1330   if (c361_scanline != 511)
1458   namcos23_state *state = machine.driver_data<namcos23_state>();
1459   c361_t &c361 = state->m_c361;
1460
1461   if (c361.scanline != 511)
13311462   {
13321463      cputag_set_input_line(machine, "maincpu", MIPS3_IRQ1, ASSERT_LINE);
1333      c361_timer->adjust(attotime::never);
1464      c361.timer->adjust(attotime::never);
13341465   }
13351466}
13361467
13371468static WRITE16_HANDLER(s23_c361_w)
13381469{
1470   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1471   c361_t &c361 = state->m_c361;
1472
13391473   switch(offset) {
13401474   case 0:
1341      tilemap_set_scrollx(bgtilemap, 0, data&0xfff);
1475      tilemap_set_scrollx(state->m_bgtilemap, 0, data&0xfff);
13421476      break;
13431477
13441478   case 1:
1345      tilemap_set_scrolly(bgtilemap, 0, data&0xfff);
1479      tilemap_set_scrolly(state->m_bgtilemap, 0, data&0xfff);
13461480      break;
13471481
13481482   case 4:   // interrupt control
1349      c361_scanline = data;
1483      c361.scanline = data;
13501484      if (data == 0x1ff)
13511485      {
13521486         cputag_set_input_line(space->machine(), "maincpu", MIPS3_IRQ1, CLEAR_LINE);
1353         c361_timer->adjust(attotime::never);
1487         c361.timer->adjust(attotime::never);
13541488      }
13551489      else
13561490      {
1357         c361_timer->adjust(space->machine().primary_screen->time_until_pos(c361_scanline));
1491         c361.timer->adjust(space->machine().primary_screen->time_until_pos(c361.scanline));
13581492      }
13591493      break;
13601494
r11160r11161
13751509
13761510static READ16_HANDLER(s23_c422_r)
13771511{
1378   return s23_c422_regs[offset];;
1512   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1513   c422_t &c422 = state->m_c422;
1514   return c422.regs[offset];
13791515}
13801516
13811517static WRITE16_HANDLER(s23_c422_w)
13821518{
1519   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1520   c422_t &c422 = state->m_c422;
13831521   switch (offset)
13841522   {
13851523      case 1:
r11160r11161
14011539
14021540   }
14031541
1404   COMBINE_DATA(&s23_c422_regs[offset]);
1542   COMBINE_DATA(&c422.regs[offset]);
14051543}
14061544
14071545// as with System 22, we need to halt the MCU while checking shared RAM
14081546static WRITE32_HANDLER( s23_mcuen_w )
14091547{
1548   namcos23_state *state = space->machine().driver_data<namcos23_state>();
14101549   logerror("mcuen_w: mask %08x, data %08x\n", mem_mask, data);
14111550   if (mem_mask == 0x0000ffff)
14121551   {
r11160r11161
14151554         logerror("S23: booting H8/3002\n");
14161555
14171556         // Panic Park: writing 1 when it's already running means reboot?
1418         if (s23_subcpu_running)
1557         if (state->m_s23_subcpu_running)
14191558         {
14201559            cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_RESET, ASSERT_LINE);
14211560         }
14221561
14231562         cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_RESET, CLEAR_LINE);
1424         s23_subcpu_running = 1;
1563         state->m_s23_subcpu_running = 1;
14251564      }
14261565      else
14271566      {
14281567         logerror("S23: stopping H8/3002\n");
14291568         cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_RESET, ASSERT_LINE);
1430         s23_subcpu_running = 0;
1569         state->m_s23_subcpu_running = 0;
14311570      }
14321571   }
14331572}
r11160r11161
14401579
14411580static READ32_HANDLER( gorgon_sharedram_r )
14421581{
1443   return namcos23_shared_ram[offset];
1582   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1583   return state->m_shared_ram[offset];
14441584}
14451585
14461586static WRITE32_HANDLER( gorgon_sharedram_w )
14471587{
1448   COMBINE_DATA(&namcos23_shared_ram[offset]);
1588   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1589   COMBINE_DATA(&state->m_shared_ram[offset]);
14491590
14501591   // hack for final furlong
14511592   if ((offset == 0x6000/4) && (data == 0) && (mem_mask == 0xff000000))
r11160r11161
14641605
14651606// 3D hardware, to throw at least in part in video/namcos23.c
14661607
1467enum { MODEL, FLUSH };
1468
1469struct namcos23_render_entry {
1470   int type;
1471
1472   union {
1473      struct {
1474         UINT16 model;
1475         INT16 m[9];
1476         INT32 v[3];
1477         float scaling;
1478      } model;
1479   };
1480};
1481
1482struct namcos23_render_data {
1483   const pen_t *pens;
1484   UINT32 (*texture_lookup)(const pen_t *pens, float x, float y);
1485};
1486
1487struct namcos23_poly_entry {
1488   namcos23_render_data rd;
1489   float zkey;
1490   int front;
1491   int vertex_count;
1492   poly_vertex pv[16];
1493};
1494
1495enum { RENDER_MAX_ENTRIES = 1000, POLY_MAX_ENTRIES = 10000 };
1496static namcos23_render_entry render_entries[2][RENDER_MAX_ENTRIES];
1497static namcos23_poly_entry render_polys[POLY_MAX_ENTRIES];
1498static int render_poly_order[POLY_MAX_ENTRIES];
1499static int render_count[2], render_cur, render_poly_count;
1500static poly_manager *polymgr;
1501
15021608INLINE INT32 u32_to_s24(UINT32 v)
15031609{
15041610   return v & 0x800000 ? v | 0xff000000 : v & 0xffffff;
r11160r11161
15191625   return UINT8(l);
15201626}
15211627
1522static UINT32 texture_lookup_nocache_point(const pen_t *pens, float x, float y)
1628static UINT32 texture_lookup_nocache_point(running_machine &machine, const pen_t *pens, float x, float y)
15231629{
1630   namcos23_state *state = machine.driver_data<namcos23_state>();
15241631   UINT32 xx = UINT32(x);
15251632   UINT32 yy = UINT32(y);
1526   UINT32 tileid = ((xx >> 4) & 0xff) | ((yy << 4) & tileid_mask);
1527   UINT8 attr = tmhrom[tileid >> 1];
1633   UINT32 tileid = ((xx >> 4) & 0xff) | ((yy << 4) & state->m_tileid_mask);
1634   UINT8 attr = state->m_tmhrom[tileid >> 1];
15281635   if(tileid & 1)
15291636      attr &= 15;
15301637   else
15311638      attr >>= 4;
1532   UINT32 tile = (tmlrom[tileid] | (attr << 16)) & tile_mask;
1639   UINT32 tile = (state->m_tmlrom[tileid] | (attr << 16)) & state->m_tile_mask;
15331640
15341641   // Probably swapx/swapy to add on bits 2-3 of attr
15351642   // Bits used by motoxgo at least
1536   UINT8 color = texrom[(tile << 8) | ((yy << 4) & 0xf0) | (xx & 0x0f)];
1643   UINT8 color = state->m_texrom[(tile << 8) | ((yy << 4) & 0xf0) | (xx & 0x0f)];
15371644   return pens[color];
15381645}
15391646
r11160r11161
15541661
15551662   for(int x = extent->startx; x < extent->stopx; x++) {
15561663      float z = w ? 1/w : 0;
1557      UINT32 pcol = rd->texture_lookup(rd->pens, u*z, v*z);
1664      UINT32 pcol = rd->texture_lookup(*rd->machine, rd->pens, u*z, v*z);
15581665      float ll = l*z;
15591666      *img = (light(pcol >> 16, ll) << 16) | (light(pcol >> 8, ll) << 8) | light(pcol, ll);
15601667
r11160r11161
15661673   }
15671674}
15681675
1569static INT32 *p3d_getv(UINT16 id)
1676static INT32 *p3d_getv(namcos23_state *state, UINT16 id)
15701677{
1571   static INT32 sp[3];
15721678   if(id == 0x8000)
1573      return light_vector;
1679      return state->m_light_vector;
15741680   if(id >= 0x100) {
1575      memset(sp, 0, sizeof(sp));
1576      return sp;
1681      memset(state->m_spv, 0, sizeof(state->m_spv));
1682      return state->m_spv;
15771683   }
1578   return vectors[id];
1684   return state->m_vectors[id];
15791685}
15801686
1581static INT16 *p3d_getm(UINT16 id)
1687static INT16 *p3d_getm(namcos23_state *state, UINT16 id)
15821688{
1583   static INT16 sp[3];
15841689   if(id >= 0x100) {
1585      memset(sp, 0, sizeof(sp));
1586      return sp;
1690      memset(state->m_spm, 0, sizeof(state->m_spm));
1691      return state->m_spm;
15871692   }
1588   return matrices[id];
1693   return state->m_matrices[id];
15891694}
15901695
1591static void p3d_matrix_set(const UINT16 *p, int size)
1696static void p3d_matrix_set(namcos23_state *state, const UINT16 *p, int size)
15921697{
15931698   if(size != 10) {
15941699      logerror("WARNING: p3d_matrix_set with size %d\n", size);
15951700      return;
15961701   }
1597   INT16 *t = p3d_getm(*p++);
1702   INT16 *t = p3d_getm(state, *p++);
15981703   for(int i=0; i<9; i++)
15991704      t[i] = *p++;
16001705}
16011706
1602static void p3d_vector_set(const UINT16 *p, int size)
1707static void p3d_vector_set(namcos23_state *state, const UINT16 *p, int size)
16031708{
16041709   if(size != 7) {
16051710      logerror("WARNING: p3d_vector_set with size %d\n", size);
16061711      return;
16071712   }
1608   INT32 *t = p3d_getv(*p++);
1713   INT32 *t = p3d_getv(state, *p++);
16091714   for(int i=0; i<3; i++) {
16101715      t[i] = u32_to_s24((p[0] << 16) | p[1]);
16111716      p += 2;
16121717   }
16131718}
16141719
1615static void p3d_scaling_set(const UINT16 *p, int size)
1720static void p3d_scaling_set(namcos23_state *state, const UINT16 *p, int size)
16161721{
16171722   if(size != 1) {
16181723      logerror("WARNING: p3d_scaling_set with size %d\n", size);
16191724      return;
16201725   }
1621   scaling = *p;
1726   state->m_scaling = *p;
16221727}
16231728
1624static void p3d_vector_matrix_mul(const UINT16 *p, int size)
1729static void p3d_vector_matrix_mul(namcos23_state *state, const UINT16 *p, int size)
16251730{
16261731   if(size != 4) {
16271732      logerror("WARNING: p3d_vector_matrix_mul with size %d\n", size);
r11160r11161
16301735   if(p[2] != 0xffff)
16311736      logerror("WARNING: p3d_vector_matrix_mul with +2=%04x\n", p[2]);
16321737
1633   INT32 *t       = p3d_getv(p[0]);
1634   const INT16 *m = p3d_getm(p[1]);
1635   const INT32 *v = p3d_getv(p[3]);
1738   INT32 *t       = p3d_getv(state, p[0]);
1739   const INT16 *m = p3d_getm(state, p[1]);
1740   const INT32 *v = p3d_getv(state, p[3]);
16361741
16371742   t[0] = INT32((m[0]*INT64(v[0]) + m[3]*INT64(v[1]) + m[6]*INT64(v[2])) >> 14);
16381743   t[1] = INT32((m[1]*INT64(v[0]) + m[4]*INT64(v[1]) + m[7]*INT64(v[2])) >> 14);
16391744   t[2] = INT32((m[2]*INT64(v[0]) + m[5]*INT64(v[1]) + m[8]*INT64(v[2])) >> 14);
16401745}
16411746
1642static void p3d_matrix_vector_mul(const UINT16 *p, int size)
1747static void p3d_matrix_vector_mul(namcos23_state *state, const UINT16 *p, int size)
16431748{
16441749   if(size != 4) {
16451750      logerror("WARNING: p3d_matrix_vector_mul with size %d\n", size);
r11160r11161
16481753   if(p[2] != 0xffff)
16491754      logerror("WARNING: p3d_matrix_vector_mul with +2=%04x\n", p[2]);
16501755
1651   INT32 *t       = p3d_getv(p[0]);
1652   const INT16 *m = p3d_getm(p[1]);
1653   const INT32 *v = p3d_getv(p[3]);
1756   INT32 *t       = p3d_getv(state, p[0]);
1757   const INT16 *m = p3d_getm(state, p[1]);
1758   const INT32 *v = p3d_getv(state, p[3]);
16541759
16551760   t[0] = INT32((m[0]*INT64(v[0]) + m[1]*INT64(v[1]) + m[2]*INT64(v[2])) >> 14);
16561761   t[1] = INT32((m[3]*INT64(v[0]) + m[4]*INT64(v[1]) + m[7]*INT64(v[2])) >> 14);
r11160r11161
16581763}
16591764
16601765
1661static void p3d_matrix_matrix_mul(const UINT16 *p, int size)
1766static void p3d_matrix_matrix_mul(namcos23_state *state, const UINT16 *p, int size)
16621767{
16631768   if(size != 4) {
16641769      logerror("WARNING: p3d_matrix_matrix_mul with size %d\n", size);
r11160r11161
16671772   if(p[2] != 0xffff)
16681773      logerror("WARNING: p3d_matrix_matrix_mul with +2=%04x\n", p[2]);
16691774
1670   INT16 *t        = p3d_getm(p[0]);
1671   const INT16 *m1 = p3d_getm(p[1]);
1672   const INT16 *m2 = p3d_getm(p[3]);
1775   INT16 *t        = p3d_getm(state, p[0]);
1776   const INT16 *m1 = p3d_getm(state, p[1]);
1777   const INT16 *m2 = p3d_getm(state, p[3]);
16731778
16741779   t[0] = INT16((m1[0]*m2[0] + m1[1]*m2[3] + m1[2]*m2[6]) >> 14);
16751780   t[1] = INT16((m1[0]*m2[1] + m1[1]*m2[4] + m1[2]*m2[7]) >> 14);
r11160r11161
16821787   t[8] = INT16((m1[6]*m2[2] + m1[7]*m2[5] + m1[8]*m2[8]) >> 14);
16831788}
16841789
1685static void p3d_render(const UINT16 *p, int size, bool use_scaling)
1790static void p3d_render(namcos23_state *state, const UINT16 *p, int size, bool use_scaling)
16861791{
1792   render_t &render = state->m_render;
1793
16871794   if(size != 3) {
16881795      logerror("WARNING: p3d_render with size %d\n", size);
16891796      return;
r11160r11161
16951802   if(p[0] == 0xd96)
16961803      return;
16971804
1698   if(render_count[render_cur] >= RENDER_MAX_ENTRIES) {
1805   if(render.count[render.cur] >= RENDER_MAX_ENTRIES) {
16991806      logerror("WARNING: render buffer full\n");
17001807      return;
17011808   }
17021809
17031810   // Vector and matrix may be inverted
1704   const INT16 *m = p3d_getm(p[1]);
1705   const INT32 *v = p3d_getv(p[2]);
1811   const INT16 *m = p3d_getm(state, p[1]);
1812   const INT32 *v = p3d_getv(state, p[2]);
17061813
1707   namcos23_render_entry *re = render_entries[render_cur] + render_count[render_cur];
1814   namcos23_render_entry *re = render.entries[render.cur] + render.count[render.cur];
17081815   re->type = MODEL;
17091816   re->model.model = p[0];
1710   re->model.scaling = use_scaling ? scaling / 16384.0 : 1.0;
1817   re->model.scaling = use_scaling ? state->m_scaling / 16384.0 : 1.0;
17111818   memcpy(re->model.m, m, sizeof(re->model.m));
17121819   memcpy(re->model.v, v, sizeof(re->model.v));
17131820   if(0)
r11160r11161
17181825            re->model.m[6]/16384.0, re->model.m[7]/16384.0, re->model.m[8]/16384.0,
17191826            re->model.v[0]/16384.0, re->model.v[1]/16384.0, re->model.v[2]/16384.0);
17201827
1721   render_count[render_cur]++;
1828   render.count[render.cur]++;
17221829}
17231830
17241831
1725static void p3d_flush(const UINT16 *p, int size)
1832static void p3d_flush(namcos23_state *state, const UINT16 *p, int size)
17261833{
1834   render_t &render = state->m_render;
1835
17271836   if(size != 0) {
17281837      logerror("WARNING: p3d_flush with size %d\n", size);
17291838      return;
17301839   }
17311840
1732   namcos23_render_entry *re = render_entries[render_cur] + render_count[render_cur];
1841   namcos23_render_entry *re = render.entries[render.cur] + render.count[render.cur];
17331842   re->type = FLUSH;
1734   render_count[render_cur]++;
1843   render.count[render.cur]++;
17351844}
17361845
17371846static void p3d_dma(address_space *space, UINT32 adr, UINT32 size)
17381847{
1848   namcos23_state *state = space->machine().driver_data<namcos23_state>();
1849   UINT16 buffer[256];
17391850   adr &= 0x1fffffff;
1740   UINT16 buffer[256];
17411851   int pos = 0;
17421852   while(pos < size) {
17431853      UINT16 h = space->read_word(adr+pos);
r11160r11161
17651875      }
17661876
17671877      switch(h1) {
1768      case 0x0040: p3d_matrix_set(buffer, psize); break;
1769      case 0x0050: p3d_vector_set(buffer, psize); break;
1770      case 0x0000: p3d_matrix_matrix_mul(buffer, psize); break;
1771      case 0x0810: p3d_matrix_vector_mul(buffer, psize); break;
1772      case 0x1010: p3d_vector_matrix_mul(buffer, psize); break;
1773      case 0x4400: p3d_scaling_set(buffer, psize); break;
1774      case 0x8000: p3d_render(buffer, psize, false); break;
1775      case 0x8080: p3d_render(buffer, psize, true); break;
1776      case 0xc000: p3d_flush(buffer, psize); break;
1878      case 0x0040: p3d_matrix_set(state, buffer, psize); break;
1879      case 0x0050: p3d_vector_set(state, buffer, psize); break;
1880      case 0x0000: p3d_matrix_matrix_mul(state, buffer, psize); break;
1881      case 0x0810: p3d_matrix_vector_mul(state, buffer, psize); break;
1882      case 0x1010: p3d_vector_matrix_mul(state, buffer, psize); break;
1883      case 0x4400: p3d_scaling_set(state, buffer, psize); break;
1884      case 0x8000: p3d_render(state, buffer, psize, false); break;
1885      case 0x8080: p3d_render(state, buffer, psize, true); break;
1886      case 0xc000: p3d_flush(state, buffer, psize); break;
17771887      default: {
17781888         if(0) {
17791889            logerror("p3d - [%04x] %04x", h1, h);
r11160r11161
17991909
18001910static WRITE32_HANDLER( p3d_w)
18011911{
1912   namcos23_state *state = space->machine().driver_data<namcos23_state>();
18021913   switch(offset) {
1803   case 0x7: COMBINE_DATA(&p3d_address); return;
1804   case 0x8: COMBINE_DATA(&p3d_size); return;
1914   case 0x7: COMBINE_DATA(&state->m_p3d_address); return;
1915   case 0x8: COMBINE_DATA(&state->m_p3d_size); return;
18051916   case 0x9:
18061917      if(data & 1)
1807         p3d_dma(space, p3d_address, p3d_size);
1918         p3d_dma(space, state->m_p3d_address, state->m_p3d_size);
18081919      return;
18091920   case 0x17:
18101921      cputag_set_input_line(space->machine(), "maincpu", MIPS3_IRQ1, CLEAR_LINE);
1811      c361_timer->adjust(attotime::never);
1922      state->m_c361.timer->adjust(attotime::never);
18121923      return;
18131924   }
18141925   logerror("p3d_w %02x, %08x @ %08x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(&space->device()), (unsigned int)cpu_get_reg(&space->device(), MIPS3_R31));
r11160r11161
18431954
18441955static void render_one_model(running_machine &machine, const namcos23_render_entry *re)
18451956{
1846   UINT32 adr = ptrom[re->model.model];
1847   if(adr >= ptrom_limit) {
1957   namcos23_state *state = machine.driver_data<namcos23_state>();
1958   render_t &render = state->m_render;
1959   UINT32 adr = state->m_ptrom[re->model.model];
1960   if(adr >= state->m_ptrom_limit) {
18481961      logerror("WARNING: model %04x base address %08x out-of-bounds - pointram?\n", re->model.model, adr);
18491962      return;
18501963   }
18511964
1852   while(adr < ptrom_limit) {
1965   while(adr < state->m_ptrom_limit) {
18531966      poly_vertex pv[15];
18541967
1855      UINT32 type = ptrom[adr++];
1856      UINT32 h    = ptrom[adr++];
1968      UINT32 type = state->m_ptrom[adr++];
1969      UINT32 h    = state->m_ptrom[adr++];
18571970
18581971
18591972      float tbase = (type >> 24) << 12;
r11160r11161
18721985         extptr = adr;
18731986         adr += ne;
18741987      } else
1875         light = ptrom[adr++];
1988         light = state->m_ptrom[adr++];
18761989
18771990      float minz = FLT_MAX;
18781991      float maxz = FLT_MIN;
18791992
18801993      for(int i=0; i<ne; i++) {
1881         UINT32 v1 = ptrom[adr++];
1882         UINT32 v2 = ptrom[adr++];
1883         UINT32 v3 = ptrom[adr++];
1994         UINT32 v1 = state->m_ptrom[adr++];
1995         UINT32 v2 = state->m_ptrom[adr++];
1996         UINT32 v3 = state->m_ptrom[adr++];
18841997
18851998         render_apply_transform(u32_to_s24(v1), u32_to_s24(v2), u32_to_s24(v3), re, pv[i]);
18861999         pv[i].p[1] = (((v1 >> 20) & 0xf00) | ((v2 >> 24 & 0xff))) + 0.5;
r11160r11161
18992012            pv[i].p[3] = 1.0;
19002013            break;
19012014         case 3: {
1902            UINT32 norm = ptrom[extptr++];
2015            UINT32 norm = state->m_ptrom[extptr++];
19032016            INT32 nx = u32_to_s10(norm >> 20);
19042017            INT32 ny = u32_to_s10(norm >> 10);
19052018            INT32 nz = u32_to_s10(norm);
19062019            INT32 nrx, nry, nrz;
19072020            render_apply_matrot(nx, ny, nz, re, nrx, nry, nrz);
19082021
1909            float lsi = float(nrx*light_vector[0] + nry*light_vector[1] + nrz*light_vector[2])/4194304.0;
2022            float lsi = float(nrx*state->m_light_vector[0] + nry*state->m_light_vector[1] + nrz*state->m_light_vector[2])/4194304.0;
19102023            if(lsi < 0)
19112024               lsi = 0;
19122025
r11160r11161
19172030         }
19182031      }
19192032
1920      namcos23_poly_entry *p = render_polys + render_poly_count;
2033      namcos23_poly_entry *p = render.polys + render.poly_count;
19212034
19222035      p->vertex_count = poly_zclip_if_less(ne, pv, p->pv, 4, 0.001f);
19232036
r11160r11161
19312044         }
19322045         p->zkey = 0.5*(minz+maxz);
19332046         p->front = !(h & 0x00000001);
2047         p->rd.machine = &machine;
19342048         p->rd.texture_lookup = texture_lookup_nocache_point;
19352049         p->rd.pens = machine.pens + (color << 8);
1936         render_poly_count++;
2050         render.poly_count++;
19372051      }
19382052
19392053      if(type & 0x000010000)
r11160r11161
19432057
19442058static int render_poly_compare(const void *i1, const void *i2)
19452059{
1946   const namcos23_poly_entry *p1 = render_polys + *(const int *)i1;
1947   const namcos23_poly_entry *p2 = render_polys + *(const int *)i2;
2060   const namcos23_poly_entry *p1 = *(const namcos23_poly_entry **)i1;
2061   const namcos23_poly_entry *p2 = *(const namcos23_poly_entry **)i2;
19482062
19492063   if(p1->front != p2->front)
19502064      return p1->front ? 1 : -1;
r11160r11161
19542068
19552069static void render_flush(running_machine &machine, bitmap_t *bitmap)
19562070{
1957   if(!render_poly_count)
2071   namcos23_state *state = machine.driver_data<namcos23_state>();
2072   render_t &render = state->m_render;
2073
2074   if(!render.poly_count)
19582075      return;
19592076
1960   for(int i=0; i<render_poly_count; i++)
1961      render_poly_order[i] = i;
2077   for(int i=0; i<render.poly_count; i++)
2078      render.poly_order[i] = &render.polys[i];
19622079
1963   qsort(render_poly_order, render_poly_count, sizeof(int), render_poly_compare);
2080   qsort(render.poly_order, render.poly_count, sizeof(namcos23_poly_entry *), render_poly_compare);
19642081
19652082   const static rectangle scissor = { 0, 639, 0, 479 };
19662083
1967   for(int i=0; i<render_poly_count; i++) {
1968      const namcos23_poly_entry *p = render_polys + render_poly_order[i];
1969      namcos23_render_data *rd = (namcos23_render_data *)poly_get_extra_data(polymgr);
2084   for(int i=0; i<render.poly_count; i++) {
2085      const namcos23_poly_entry *p = render.poly_order[i];
2086      namcos23_render_data *rd = (namcos23_render_data *)poly_get_extra_data(render.polymgr);
19702087      *rd = p->rd;
1971      poly_render_triangle_fan(polymgr, bitmap, &scissor, render_scanline, 4, p->vertex_count, p->pv);
2088      poly_render_triangle_fan(render.polymgr, bitmap, &scissor, render_scanline, 4, p->vertex_count, p->pv);
19722089   }
1973   render_poly_count = 0;
2090   render.poly_count = 0;
19742091}
19752092
19762093static void render_run(running_machine &machine, bitmap_t *bitmap)
19772094{
1978   render_poly_count = 0;
1979   const namcos23_render_entry *re = render_entries[!render_cur];
1980   for(int i=0; i<render_count[!render_cur]; i++) {
2095   namcos23_state *state = machine.driver_data<namcos23_state>();
2096   render_t &render = state->m_render;
2097   const namcos23_render_entry *re = render.entries[!render.cur];
2098
2099   render.poly_count = 0;
2100   for(int i=0; i<render.count[!render.cur]; i++) {
19812101      switch(re->type) {
19822102      case MODEL:
19832103         render_one_model(machine, re);
r11160r11161
19902110   }
19912111   render_flush(machine, bitmap);
19922112
1993   poly_wait(polymgr, "render_run");
2113   poly_wait(render.polymgr, "render_run");
19942114}
19952115
19962116
19972117static VIDEO_START( ss23 )
19982118{
1999   gfx_element_set_source(machine.gfx[0], (UINT8 *)namcos23_charram);
2000   bgtilemap = tilemap_create(machine, TextTilemapGetInfo, tilemap_scan_rows, 16, 16, 64, 64);
2001   tilemap_set_transparent_pen(bgtilemap, 0xf);
2119   namcos23_state *state = machine.driver_data<namcos23_state>();
2120   gfx_element_set_source(machine.gfx[0], (UINT8 *)state->m_charram);
2121   state->m_bgtilemap = tilemap_create(machine, TextTilemapGetInfo, tilemap_scan_rows, 16, 16, 64, 64);
2122   tilemap_set_transparent_pen(state->m_bgtilemap, 0xf);
20022123
20032124   // Gorgon's tilemap offset is 0, S23/SS23's is 860
20042125   if ((!strcmp(machine.system().name, "rapidrvr")) ||
20052126       (!strcmp(machine.system().name, "rapidrvr2")) ||
20062127       (!strcmp(machine.system().name, "finlflng")))
20072128   {
2008      tilemap_set_scrolldx(bgtilemap, 0, 0);
2129      tilemap_set_scrolldx(state->m_bgtilemap, 0, 0);
20092130   }
20102131   else
20112132   {
2012      tilemap_set_scrolldx(bgtilemap, 860, 860);
2133      tilemap_set_scrolldx(state->m_bgtilemap, 860, 860);
20132134   }
2014   polymgr = poly_alloc(machine, 10000, sizeof(namcos23_render_data), POLYFLAG_NO_WORK_QUEUE);
2135   state->m_render.polymgr = poly_alloc(machine, 10000, sizeof(namcos23_render_data), POLYFLAG_NO_WORK_QUEUE);
20152136}
20162137
20172138static SCREEN_UPDATE( ss23 )
20182139{
2140   namcos23_state *state = screen->machine().driver_data<namcos23_state>();
20192141   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine()));
20202142
20212143   render_run( screen->machine(), bitmap );
r11160r11161
20232145   gfx_element *gfx = screen->machine().gfx[0];
20242146   memset(gfx->dirty, 1, gfx->total_elements);
20252147
2026   tilemap_draw( bitmap, cliprect, bgtilemap, 0/*flags*/, 0/*priority*/ ); /* opaque */
2148   tilemap_draw( bitmap, cliprect, state->m_bgtilemap, 0/*flags*/, 0/*priority*/ ); /* opaque */
20272149   return 0;
20282150}
20292151
20302152static INTERRUPT_GEN(s23_interrupt)
20312153{
2032   if(!ctl_vbl_active) {
2033      ctl_vbl_active = true;
2154   namcos23_state *state = device->machine().driver_data<namcos23_state>();
2155   render_t &render = state->m_render;
2156
2157   if(!state->m_ctl_vbl_active) {
2158      state->m_ctl_vbl_active = true;
20342159      device_set_input_line(device, MIPS3_IRQ0, ASSERT_LINE);
20352160   }
20362161
2037   render_cur = !render_cur;
2038   render_count[render_cur] = 0;
2162   render.cur = !render.cur;
2163   render.count[render.cur] = 0;
20392164}
20402165
20412166static MACHINE_START( s23 )
20422167{
2043   c361_timer = machine.scheduler().timer_alloc(FUNC(c361_timer_cb));
2044   c361_timer->adjust(attotime::never);
2168   namcos23_state *state = machine.driver_data<namcos23_state>();
2169   c361_t &c361 = state->m_c361;
2170   c361.timer = machine.scheduler().timer_alloc(FUNC(c361_timer_cb));
2171   c361.timer->adjust(attotime::never);
20452172}
20462173
20472174static ADDRESS_MAP_START( gorgon_map, AS_PROGRAM, 32 )
r11160r11161
20492176   AM_RANGE(0x00000000, 0x003fffff) AM_RAM
20502177   AM_RANGE(0x01000000, 0x010000ff) AM_READWRITE( p3d_r, p3d_w )
20512178   AM_RANGE(0x02000000, 0x0200000f) AM_READWRITE16( s23_c417_r, s23_c417_w, 0xffffffff )
2052   AM_RANGE(0x04400000, 0x0440ffff) AM_READWRITE( gorgon_sharedram_r, gorgon_sharedram_w ) AM_BASE(&namcos23_shared_ram)
2179   AM_RANGE(0x04400000, 0x0440ffff) AM_READWRITE( gorgon_sharedram_r, gorgon_sharedram_w ) AM_BASE_MEMBER(namcos23_state, m_shared_ram)
20532180
20542181   AM_RANGE(0x04c3ff08, 0x04c3ff0b) AM_WRITE( s23_mcuen_w )
20552182   AM_RANGE(0x04c3ff0c, 0x04c3ff0f) AM_RAM
r11160r11161
20582185
20592186   AM_RANGE(0x06108000, 0x061087ff) AM_RAM      // GAMMA (C404-3S)
20602187   AM_RANGE(0x06110000, 0x0613ffff) AM_RAM_WRITE( namcos23_paletteram_w ) AM_BASE_GENERIC(paletteram)
2061   AM_RANGE(0x06400000, 0x06403fff) AM_RAM_WRITE( s23_txtchar_w ) AM_BASE(&namcos23_charram)   // text layer characters
2188   AM_RANGE(0x06400000, 0x06403fff) AM_RAM_WRITE( s23_txtchar_w ) AM_BASE_MEMBER(namcos23_state, m_charram)   // text layer characters
20622189   AM_RANGE(0x06404000, 0x0641dfff) AM_RAM
2063   AM_RANGE(0x0641e000, 0x0641ffff) AM_RAM_WRITE( namcos23_textram_w ) AM_BASE(&namcos23_textram)
2190   AM_RANGE(0x0641e000, 0x0641ffff) AM_RAM_WRITE( namcos23_textram_w ) AM_BASE_MEMBER(namcos23_state, m_textram)
20642191
20652192   AM_RANGE(0x08000000, 0x087fffff) AM_ROM AM_REGION("data", 0)   // data ROMs
20662193
r11160r11161
20802207   AM_RANGE(0x00000000, 0x00ffffff) AM_RAM
20812208   AM_RANGE(0x01000000, 0x010000ff) AM_READWRITE( p3d_r, p3d_w )
20822209   AM_RANGE(0x02000000, 0x0200000f) AM_READWRITE16( s23_c417_r, s23_c417_w, 0xffffffff )
2083   AM_RANGE(0x04400000, 0x0440ffff) AM_RAM AM_BASE(&namcos23_shared_ram)
2210   AM_RANGE(0x04400000, 0x0440ffff) AM_RAM AM_BASE_MEMBER(namcos23_state, m_shared_ram)
20842211   AM_RANGE(0x04c3ff08, 0x04c3ff0b) AM_WRITE( s23_mcuen_w )
20852212   AM_RANGE(0x04c3ff0c, 0x04c3ff0f) AM_RAM
20862213   AM_RANGE(0x06000000, 0x0600ffff) AM_RAM AM_SHARE("nvram") // Backup
20872214   AM_RANGE(0x06200000, 0x06203fff) AM_RAM                             // C422
20882215   AM_RANGE(0x06400000, 0x0640000f) AM_READWRITE16( s23_c422_r, s23_c422_w, 0xffffffff ) // C422 registers
2089   AM_RANGE(0x06800000, 0x06807fff) AM_RAM_WRITE( s23_txtchar_w ) AM_BASE(&namcos23_charram) // text layer characters (shown as CGRAM in POST)
2216   AM_RANGE(0x06800000, 0x06807fff) AM_RAM_WRITE( s23_txtchar_w ) AM_BASE_MEMBER(namcos23_state, m_charram) // text layer characters (shown as CGRAM in POST)
20902217   AM_RANGE(0x06804000, 0x0681dfff) AM_RAM
2091   AM_RANGE(0x0681e000, 0x0681ffff) AM_RAM_WRITE( namcos23_textram_w ) AM_BASE(&namcos23_textram)
2218   AM_RANGE(0x0681e000, 0x0681ffff) AM_RAM_WRITE( namcos23_textram_w ) AM_BASE_MEMBER(namcos23_state, m_textram)
20922219   AM_RANGE(0x06820000, 0x0682000f) AM_READWRITE16( s23_c361_r, s23_c361_w, 0xffffffff ) // C361
20932220   AM_RANGE(0x06a08000, 0x06a087ff) AM_RAM // Blending control & GAMMA (C404)
20942221   AM_RANGE(0x06a10000, 0x06a3ffff) AM_RAM_WRITE( namcos23_paletteram_w ) AM_BASE_GENERIC(paletteram)
r11160r11161
21112238
21122239static READ32_HANDLER( sh2_shared_r )
21132240{
2114   return gmen_sh2_shared[offset];
2241   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2242   return state->m_gmen_sh2_shared[offset];
21152243}
21162244
21172245static WRITE32_HANDLER( sh2_shared_w )
21182246{
2119   COMBINE_DATA(&gmen_sh2_shared[offset]);
2247   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2248   COMBINE_DATA(&state->m_gmen_sh2_shared[offset]);
21202249}
21212250
21222251static ADDRESS_MAP_START( gmen_mips_map, AS_PROGRAM, 32 )
r11160r11161
21272256
21282257
21292258static ADDRESS_MAP_START( gmen_sh2_map, AS_PROGRAM, 32 )
2130   AM_RANGE( 0x00000000, 0x00007fff ) AM_RAM AM_BASE(&gmen_sh2_shared)
2259   AM_RANGE( 0x00000000, 0x00007fff ) AM_RAM AM_BASE_MEMBER(namcos23_state, m_gmen_sh2_shared)
21312260   AM_RANGE( 0x04000000, 0x043fffff ) AM_RAM   // SH-2 main work RAM
21322261ADDRESS_MAP_END
21332262
r11160r11161
21392268
21402269static WRITE16_HANDLER( sharedram_sub_w )
21412270{
2142   UINT16 *shared16 = (UINT16 *)namcos23_shared_ram;
2271   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2272   UINT16 *shared16 = (UINT16 *)state->m_shared_ram;
21432273
21442274   // fake that an I/O board is connected for games w/o a dump or that aren't properly communicating with it yet
2145   if (!has_jvsio)
2275   if (!state->m_has_jvsio)
21462276   {
21472277      if ((offset == 0x4052/2) && (data == 0x78))
21482278      {
r11160r11161
21552285
21562286static READ16_HANDLER( sharedram_sub_r )
21572287{
2158   UINT16 *shared16 = (UINT16 *)namcos23_shared_ram;
2288   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2289   UINT16 *shared16 = (UINT16 *)state->m_shared_ram;
21592290
21602291   return shared16[BYTE_XOR_BE(offset)];
21612292}
r11160r11161
21922323// in System 12, bit 0 of H8/3002 port A is connected to it's chip enable
21932324// the actual I/O takes place through the H8/3002's serial port B.
21942325
2195static int s23_porta = 0, s23_rtcstate = 0;
21962326
21972327static READ8_HANDLER( s23_mcu_pa_r )
21982328{
2199   return s23_porta;
2329   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2330   return state->m_s23_porta;
22002331}
22012332
22022333static WRITE8_HANDLER( s23_mcu_pa_w )
22032334{
2335   namcos23_state *state = space->machine().driver_data<namcos23_state>();
22042336   // bit 0 = chip enable for the RTC
22052337   // reset the state on the rising edge of the bit
2206   if ((!(s23_porta & 1)) && (data & 1))
2338   if ((!(state->m_s23_porta & 1)) && (data & 1))
22072339   {
2208      s23_rtcstate = 0;
2340      state->m_s23_rtcstate = 0;
22092341   }
22102342
2211   s23_porta = data;
2343   state->m_s23_porta = data;
22122344}
22132345
22142346INLINE UINT8 make_bcd(UINT8 data)
r11160r11161
22182350
22192351static READ8_HANDLER( s23_mcu_rtc_r )
22202352{
2353   namcos23_state *state = space->machine().driver_data<namcos23_state>();
22212354   UINT8 ret = 0;
22222355   system_time systime;
22232356   static const int weekday[7] = { 7, 1, 2, 3, 4, 5, 6 };
22242357
22252358   space->machine().current_datetime(systime);
22262359
2227   switch (s23_rtcstate)
2360   switch (state->m_s23_rtcstate)
22282361   {
22292362      case 0:
22302363         ret = make_bcd(systime.local_time.second);   // seconds (BCD, 0-59) in bits 0-6, bit 7 = battery low
r11160r11161
22522385         break;
22532386   }
22542387
2255   s23_rtcstate++;
2388   state->m_s23_rtcstate++;
22562389
22572390   return ret;
22582391}
22592392
2260static int s23_lastpB, s23_setstate, s23_setnum, s23_settings[8];
22612393
22622394static READ8_HANDLER( s23_mcu_portB_r )
22632395{
2264   s23_lastpB ^= 0x80;
2265   return s23_lastpB;
2396   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2397   state->m_s23_lastpB ^= 0x80;
2398   return state->m_s23_lastpB;
22662399}
22672400
22682401static WRITE8_HANDLER( s23_mcu_portB_w )
22692402{
2403   namcos23_state *state = space->machine().driver_data<namcos23_state>();
22702404   // bit 7 = chip enable for the video settings controller
22712405   if (data & 0x80)
22722406   {
2273      s23_setstate = 0;
2407      state->m_s23_setstate = 0;
22742408   }
22752409
2276   s23_lastpB = data;
2410   state->m_s23_lastpB = data;
22772411}
22782412
22792413static WRITE8_HANDLER( s23_mcu_settings_w )
22802414{
2281   if (s23_setstate)
2415   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2416   if (state->m_s23_setstate)
22822417   {
22832418      // data
2284      s23_settings[s23_setnum] = data;
2419      state->m_s23_settings[state->m_s23_setnum] = data;
22852420
2286      if (s23_setnum == 7)
2421      if (state->m_s23_setnum == 7)
22872422      {
22882423         logerror("S23 video settings: Contrast: %02x  R: %02x  G: %02x  B: %02x\n",
2289            BITSWAP8(s23_settings[0], 0, 1, 2, 3, 4, 5, 6, 7),
2290            BITSWAP8(s23_settings[1], 0, 1, 2, 3, 4, 5, 6, 7),
2291            BITSWAP8(s23_settings[2], 0, 1, 2, 3, 4, 5, 6, 7),
2292            BITSWAP8(s23_settings[3], 0, 1, 2, 3, 4, 5, 6, 7));
2424            BITSWAP8(state->m_s23_settings[0], 0, 1, 2, 3, 4, 5, 6, 7),
2425            BITSWAP8(state->m_s23_settings[1], 0, 1, 2, 3, 4, 5, 6, 7),
2426            BITSWAP8(state->m_s23_settings[2], 0, 1, 2, 3, 4, 5, 6, 7),
2427            BITSWAP8(state->m_s23_settings[3], 0, 1, 2, 3, 4, 5, 6, 7));
22932428      }
22942429   }
22952430   else
22962431   {   // setting number
2297      s23_setnum = (data >> 4)-1;
2432      state->m_s23_setnum = (data >> 4)-1;
22982433   }
22992434
2300   s23_setstate ^= 1;
2435   state->m_s23_setstate ^= 1;
23012436}
23022437
2303static UINT8 maintoio[128], mi_rd, mi_wr;
2304static UINT8 iotomain[128], im_rd, im_wr;
23052438
23062439static READ8_HANDLER( s23_mcu_iob_r )
23072440{
2308   UINT8 ret = iotomain[im_rd];
2441   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2442   UINT8 ret = state->m_iotomain[state->m_im_rd];
23092443
2310   im_rd++;
2311   im_rd &= 0x7f;
2444   state->m_im_rd++;
2445   state->m_im_rd &= 0x7f;
23122446
2313   if (im_rd == im_wr)
2447   if (state->m_im_rd == state->m_im_wr)
23142448   {
23152449      cputag_set_input_line(space->machine(), "audiocpu", H8_SCI_0_RX, CLEAR_LINE);
23162450   }
r11160r11161
23252459
23262460static WRITE8_HANDLER( s23_mcu_iob_w )
23272461{
2328   maintoio[mi_wr++] = data;
2329   mi_wr &= 0x7f;
2462   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2463   state->m_maintoio[state->m_mi_wr++] = data;
2464   state->m_mi_wr &= 0x7f;
23302465
23312466   cputag_set_input_line(space->machine(), "ioboard", H8_SCI_0_RX, ASSERT_LINE);
23322467}
r11160r11161
25032638
25042639static READ8_HANDLER(s23_mcu_p6_r)
25052640{
2641   namcos23_state *state = space->machine().driver_data<namcos23_state>();
25062642   // bit 1 = JVS cable present sense (1 = I/O board plugged in)
2507      return (namcos23_jvssense << 1) | 0xfd;
2643      return (state->m_jvssense << 1) | 0xfd;
25082644}
25092645
25102646static WRITE8_HANDLER(s23_mcu_p6_w)
r11160r11161
25442680
25452681static READ8_HANDLER( s23_iob_mcu_r )
25462682{
2547   UINT8 ret = maintoio[mi_rd];
2683   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2684   UINT8 ret = state->m_maintoio[state->m_mi_rd];
25482685
2549   mi_rd++;
2550   mi_rd &= 0x7f;
2686   state->m_mi_rd++;
2687   state->m_mi_rd &= 0x7f;
25512688
2552   if (mi_rd == mi_wr)
2689   if (state->m_mi_rd == state->m_mi_wr)
25532690   {
25542691      cputag_set_input_line(space->machine(), "ioboard", H8_SCI_0_RX, CLEAR_LINE);
25552692   }
r11160r11161
25592696
25602697static WRITE8_HANDLER( s23_iob_mcu_w )
25612698{
2562   iotomain[im_wr++] = data;
2563   im_wr &= 0x7f;
2699   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2700   state->m_iotomain[state->m_im_wr++] = data;
2701   state->m_im_wr &= 0x7f;
25642702
25652703   cputag_set_input_line(space->machine(), "audiocpu", H8_SCI_0_RX, ASSERT_LINE);
25662704}
25672705
2568static UINT8 s23_tssio_port_4 = 0;
25692706
25702707static READ8_HANDLER( s23_iob_p4_r )
25712708{
2572   return s23_tssio_port_4;
2709   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2710   return state->m_s23_tssio_port_4;
25732711}
25742712
25752713static WRITE8_HANDLER( s23_iob_p4_w )
25762714{
2577   s23_tssio_port_4 = data;
2715   namcos23_state *state = space->machine().driver_data<namcos23_state>();
2716   state->m_s23_tssio_port_4 = data;
25782717
2579   namcos23_jvssense = (data & 0x04) ? 0 : 1;
2718   state->m_jvssense = (data & 0x04) ? 0 : 1;
25802719}
25812720
25822721static READ8_HANDLER(iob_r)
r11160r11161
26272766
26282767static DRIVER_INIT(ss23)
26292768{
2630   ptrom  = (const UINT32 *)machine.region("pointrom")->base();
2631   tmlrom = (const UINT16 *)machine.region("textilemapl")->base();
2632   tmhrom = machine.region("textilemaph")->base();
2633   texrom = machine.region("textile")->base();
2769   namcos23_state *state = machine.driver_data<namcos23_state>();
2770   render_t &render = state->m_render;
2771   state->m_ptrom  = (const UINT32 *)machine.region("pointrom")->base();
2772   state->m_tmlrom = (const UINT16 *)machine.region("textilemapl")->base();
2773   state->m_tmhrom = machine.region("textilemaph")->base();
2774   state->m_texrom = machine.region("textile")->base();
26342775
2635   tileid_mask = (machine.region("textilemapl")->bytes()/2 - 1) & ~0xff; // Used for y masking
2636   tile_mask = machine.region("textile")->bytes()/256 - 1;
2637   ptrom_limit = machine.region("pointrom")->bytes()/4;
2776   state->m_tileid_mask = (machine.region("textilemapl")->bytes()/2 - 1) & ~0xff; // Used for y masking
2777   state->m_tile_mask = machine.region("textile")->bytes()/256 - 1;
2778   state->m_ptrom_limit = machine.region("pointrom")->bytes()/4;
26382779
2639   mi_rd = mi_wr = im_rd = im_wr = 0;
2640   namcos23_jvssense = 1;
2641   ctl_vbl_active = false;
2642   s23_lastpB = 0x50;
2643   s23_setstate = 0;
2644   s23_setnum = 0;
2645   memset(s23_settings, 0, sizeof(s23_settings));
2646   s23_tssio_port_4 = 0;
2647   s23_porta = 0, s23_rtcstate = 0;
2648   s23_subcpu_running = 1;
2649   render_count[0] = render_count[1] = 0;
2650   render_cur = 0;
2780   state->m_mi_rd = state->m_mi_wr = state->m_im_rd = state->m_im_wr = 0;
2781   state->m_jvssense = 1;
2782   state->m_ctl_vbl_active = false;
2783   state->m_s23_lastpB = 0x50;
2784   state->m_s23_setstate = 0;
2785   state->m_s23_setnum = 0;
2786   memset(state->m_s23_settings, 0, sizeof(state->m_s23_settings));
2787   state->m_s23_tssio_port_4 = 0;
2788   state->m_s23_porta = 0, state->m_s23_rtcstate = 0;
2789   state->m_s23_subcpu_running = 1;
2790   render.count[0] = render.count[1] = 0;
2791   render.cur = 0;
26512792
26522793   if ((!strcmp(machine.system().name, "motoxgo")) ||
26532794       (!strcmp(machine.system().name, "panicprk")) ||
r11160r11161
26652806       (!strcmp(machine.system().name, "timecrs2b")) ||
26662807       (!strcmp(machine.system().name, "timecrs2")))
26672808   {
2668      has_jvsio = 1;
2809      state->m_has_jvsio = 1;
26692810   }
26702811   else
26712812   {
2672      has_jvsio = 0;
2813      state->m_has_jvsio = 0;
26732814   }
26742815}
26752816
r11160r11161
26972838   8192            /* data cache size - VERIFIED */
26982839};
26992840
2700static MACHINE_CONFIG_START( gorgon, driver_device )
2841static MACHINE_CONFIG_START( gorgon, namcos23_state )
27012842
27022843   /* basic machine hardware */
27032844   MCFG_CPU_ADD("maincpu", R4650BE, S23_BUSCLOCK*4)
r11160r11161
27442885   MCFG_SOUND_ROUTE(3, "lspeaker", 1.00)
27452886MACHINE_CONFIG_END
27462887
2747static MACHINE_CONFIG_START( s23, driver_device )
2888static MACHINE_CONFIG_START( s23, namcos23_state )
27482889   /* basic machine hardware */
27492890   MCFG_CPU_ADD("maincpu", R4650BE, S23_BUSCLOCK*4)
27502891   MCFG_CPU_CONFIG(r4650_config)
r11160r11161
27902931   MCFG_SOUND_ROUTE(3, "lspeaker", 1.00)
27912932MACHINE_CONFIG_END
27922933
2793static MACHINE_CONFIG_START( ss23, driver_device )
2934static MACHINE_CONFIG_START( ss23, namcos23_state )
27942935   /* basic machine hardware */
27952936   MCFG_CPU_ADD("maincpu", R4650BE, S23_BUSCLOCK*5)
27962937   MCFG_CPU_CONFIG(r4650_config)
src/mame/drivers/galdrvr.c
r11160r11161
15371537   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL
15381538   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_COCKTAIL
15391539   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
1540    PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) // turning both of these on boots with 9 credits?
1541    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1542    PORT_DIPSETTING(    0x40, DEF_STR( On ) )
1543    PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
1544    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1545    PORT_DIPSETTING(    0x80, DEF_STR( On ) )
1540   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) // turning both of these on boots with 9 credits?
1541   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1542   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
1543   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
1544   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1545   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
15461546
15471547   PORT_START("IN2")
1548    PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
1549    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1550    PORT_DIPSETTING(    0x01, DEF_STR( On ) )
1551    PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
1552    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1553    PORT_DIPSETTING(    0x02, DEF_STR( On ) )
1554    PORT_DIPNAME( 0x04, 0x00, DEF_STR( Flip_Screen ) )
1555    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1556    PORT_DIPSETTING(    0x04, DEF_STR( On ) )
1548   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
1549   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1550   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
1551   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
1552   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1553   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
1554   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Flip_Screen ) )
1555   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1556   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
15571557   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Cabinet ) )
15581558   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
15591559   PORT_DIPSETTING(    0x08, DEF_STR( Cocktail ) )
1560    PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
1561    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1562    PORT_DIPSETTING(    0x10, DEF_STR( On ) )
1563    PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
1564    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1565    PORT_DIPSETTING(    0x20, DEF_STR( On ) )
1566    PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
1567    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1568    PORT_DIPSETTING(    0x40, DEF_STR( On ) )
1569    PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
1570    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1571    PORT_DIPSETTING(    0x80, DEF_STR( On ) )
1560   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
1561   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1562   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
1563   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
1564   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1565   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
1566   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
1567   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1568   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
1569   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
1570   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1571   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
15721572INPUT_PORTS_END
15731573
15741574/*************************************
r11160r11161
21692169   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
21702170   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
21712171   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_8WAY
2172    PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2173    PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2174    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2172   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2173   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2174   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
21752175   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON2 )
21762176   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
21772177
r11160r11161
21792179   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("Start 1 / P1 Button 1")      /* also P1 Button 1 */
21802180   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("Start 2 / P1 Button 2")      /* also P1 Button 2 */
21812181   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
2182    PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
2183    PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2184    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2185    PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2186    PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2187    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2188    PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2189    PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2190    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2191    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
2192    PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2193    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2194    PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2195    PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2196    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2182   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
2183   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2184   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2185   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2186   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2187   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2188   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2189   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2190   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2191   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
2192   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2193   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2194   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2195   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2196   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
21972197
21982198
21992199   PORT_START("IN2")      /* 0xb001 */
r11160r11161
22032203   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
22042204   PORT_DIPSETTING(    0x03, DEF_STR( 1C_3C ) )
22052205   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
2206    PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
2207    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2208    PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
2209    PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2210    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2211    PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2212    PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2213    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2214    PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2215    PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2216    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2217    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
2218    PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2219    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2220    PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2221    PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2222    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2206   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
2207   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2208   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
2209   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2210   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2211   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2212   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2213   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2214   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2215   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2216   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2217   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
2218   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2219   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2220   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2221   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2222   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
22232223
22242224   PORT_START("IN3")      /* 0xb002 */
2225    PORT_DIPNAME( 0x01, 0x01, "0xb002" )
2226    PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
2227    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2228    PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
2229    PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2230    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2231    PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
2232    PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
2233    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2234    PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
2235    PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2236    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2237    PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2238    PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2239    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2240    PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2241    PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2242    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2243    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
2244    PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2245    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2246    PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2247    PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2248    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2225   PORT_DIPNAME( 0x01, 0x01, "0xb002" )
2226   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
2227   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2228   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
2229   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2230   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2231   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
2232   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
2233   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2234   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
2235   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2236   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2237   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2238   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2239   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2240   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2241   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2242   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2243   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
2244   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2245   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2246   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2247   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2248   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
22492249INPUT_PORTS_END
22502250
22512251
r11160r11161
23542354
23552355static CUSTOM_INPUT( moonwar_dial_r )
23562356{
2357   galaxian_state *state = field->port->machine().driver_data<galaxian_state>();
23572358   static const char *const dialname[2] = { "P1_DIAL", "P2_DIAL" };
2358   int p = (~moonwar_port_select >> 4) & 1;
2359   int p = (~state->m_moonwar_port_select >> 4) & 1;
23592360
23602361   // see http://www.cityofberwyn.com/schematics/stern/MoonWar_opto.tiff for schematic
23612362   // I.e. a 74ls161 counts from 0 to 15 which is the absolute number of bars passed on the quadrature
23622363
2363   static int counter_74ls161[2] = {0, 0};
2364   static int direction[2] = {0, 0};
23652364   signed char dialread = input_port_read(field->port->machine(), dialname[p]);
23662365
23672366   UINT8 ret;
23682367
2369   if (dialread < 0) direction[p] = 0x00;
2370   else if (dialread > 0) direction[p] = 0x10;
2368   if (dialread < 0) state->m_direction[p] = 0x00;
2369   else if (dialread > 0) state->m_direction[p] = 0x10;
23712370
2372   counter_74ls161[p] += abs(dialread);
2373   counter_74ls161[p] &= 0xf;
2371   state->m_counter_74ls161[p] += abs(dialread);
2372   state->m_counter_74ls161[p] &= 0xf;
23742373
2375   ret = counter_74ls161[p] | direction[p];
2376   //fprintf(stderr, "dialread1: %02x, counter_74ls161: %02x, spinner ret is %02x\n", dialread, counter_74ls161[p], ret);
2374   ret = state->m_counter_74ls161[p] | state->m_direction[p];
2375   //fprintf(stderr, "dialread1: %02x, counter_74ls161: %02x, spinner ret is %02x\n", dialread, state->m_counter_74ls161[p], ret);
23772376
23782377   return ret;
23792378}
src/mame/drivers/alien.c
r0r11161
1/**********************************************************************************
2
3   Alien: The Arcade Medal Edition (c) 2005 Capcom
4
5   skeleton driver
6
7   - sh-4 clocked with 200MHz
8   - 2 x Panasonic MN677511DE chips (MPEG2 decoders)
9   - Altera ACEX 1K PLD
10   - M48T35Y timekeeper device
11   - CF interface
12
13***********************************************************************************/
14
15#include "emu.h"
16#include "cpu/sh4/sh4.h"
17
18#define MASTER_CLOCK   XTAL_200MHz
19
20class alien_state : public driver_device
21{
22public:
23   alien_state(running_machine &machine, const driver_device_config_base &config)
24      : driver_device(machine, config) { }
25
26};
27
28static VIDEO_START( alien )
29{
30
31}
32
33static SCREEN_UPDATE( alien )
34{
35
36   return 0;
37}
38
39static READ64_HANDLER( test_r )
40{
41   return space->machine().rand();
42}
43
44static ADDRESS_MAP_START( alien_map, AS_PROGRAM, 64 )
45   AM_RANGE(0x00000000, 0x0003ffff) AM_ROM
46   AM_RANGE(0x08000000, 0x08000007) AM_READ(test_r) //hangs if zero
47   AM_RANGE(0x0cfe0000, 0x0cffffff) AM_RAM
48   AM_RANGE(0x10000000, 0x13ffffff) AM_RAM
49   AM_RANGE(0x18000000, 0x1800000f) AM_READ(test_r) AM_WRITENOP
50ADDRESS_MAP_END
51
52
53
54
55static INPUT_PORTS_START( alien )
56
57INPUT_PORTS_END
58
59static MACHINE_RESET( alien )
60{
61   //cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, ASSERT_LINE);
62}
63
64static MACHINE_CONFIG_START( alien, alien_state )
65   /* basic machine hardware */
66   MCFG_CPU_ADD("maincpu", SH4, MASTER_CLOCK)   /* 200MHz */
67   MCFG_CPU_PROGRAM_MAP(alien_map)
68
69   /* video hardware */
70
71   MCFG_SCREEN_ADD("screen", RASTER)
72   MCFG_SCREEN_REFRESH_RATE(60)
73   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
74   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
75   MCFG_SCREEN_SIZE((32)*8, (32)*8)
76   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1)
77
78   MCFG_MACHINE_RESET(alien)
79
80   MCFG_VIDEO_START(alien)
81   MCFG_SCREEN_UPDATE(alien)
82
83   MCFG_PALETTE_LENGTH(0x1000)
84
85   /* sound hardware */
86   MCFG_SPEAKER_STANDARD_MONO("mono")
87
88MACHINE_CONFIG_END
89
90
91/*************************
92*        Rom Load        *
93*************************/
94
95ROM_START( alien )
96   ROM_REGION( 0x800000, "maincpu", 0 ) // BIOS code
97   ROM_LOAD32_WORD( "aln_s04.4.ic30", 0x000000, 0x400000, CRC(11777d3f) SHA1(8cc9fcae7911e6be273b4532d89b44a309687ead) )
98    ROM_LOAD32_WORD( "aln_s05.5.ic33", 0x000002, 0x400000, CRC(71d2f22c) SHA1(16b25aa34f8b0d988565e7ab7cecc4df62ee8cf3) )
99
100   ROM_REGION( 0x800100, "unk", 0 ) //flash firmware?
101   ROM_LOAD( "s29jl064hxxtfi00.u35", 0x000000, 0x800100, CRC(01890c61) SHA1(4fad321f42eab835351c6d5f73539bdbed80affe) )
102
103   ROM_REGION( 0x8000, "nvram", ROMREGION_ERASEFF) //timekeeper device
104   ROM_LOAD( "m48t35y.3.ic26", 0x000000, 0x007ff8, CRC(060b0a75) SHA1(7ddf380ee0e7b54533ef7e248405bfce1c5dbb4b) )
105
106   DISK_REGION( "card" ) //compact flash
107   DISK_IMAGE( "alien", 0, NO_DUMP)
108ROM_END
109
110
111GAME( 2005, alien,  0,      alien, alien, 0, ROT0, "Capcom", "Alien: The Arcade Medal Edition", GAME_NO_SOUND | GAME_NOT_WORKING )
src/mame/drivers/vigilant.c
r11160r11161
7272
7373static ADDRESS_MAP_START( vigilant_io_map, AS_IO, 8 )
7474   ADDRESS_MAP_GLOBAL_MASK(0xff)
75   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0") AM_WRITE(m72_sound_command_byte_w)   /* SD */
75   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0") AM_DEVWRITE("m72", m72_sound_command_byte_w)   /* SD */
7676   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1") AM_WRITE(vigilant_out2_w)         /* OUT2 */
7777   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2")
7878   AM_RANGE(0x03, 0x03) AM_READ_PORT("DSW1")
r11160r11161
9898   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN0")
9999   AM_RANGE(0x03, 0x03) AM_READ_PORT("IN1")
100100   AM_RANGE(0x04, 0x04) AM_READ_PORT("IN2") AM_WRITE(vigilant_bank_select_w)
101   AM_RANGE(0x06, 0x06) AM_WRITE(m72_sound_command_byte_w)
101   AM_RANGE(0x06, 0x06) AM_DEVWRITE("m72", m72_sound_command_byte_w)
102102//  AM_RANGE(0x07, 0x07) AM_WRITENOP /* ?? */
103103ADDRESS_MAP_END
104104
r11160r11161
110110static ADDRESS_MAP_START( sound_io_map, AS_IO, 8 )
111111   ADDRESS_MAP_GLOBAL_MASK(0xff)
112112   AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
113   AM_RANGE(0x80, 0x81) AM_READWRITE(soundlatch_r, vigilant_sample_addr_w)   /* STL / STH */
114   AM_RANGE(0x82, 0x82) AM_DEVWRITE("dac", m72_sample_w)         /* COUNT UP */
115   AM_RANGE(0x83, 0x83) AM_WRITE(m72_sound_irq_ack_w)   /* IRQ clear */
116   AM_RANGE(0x84, 0x84) AM_READ(m72_sample_r)   /* S ROM C */
113   AM_RANGE(0x80, 0x81) AM_READ(soundlatch_r) AM_DEVWRITE("m72", vigilant_sample_addr_w)   /* STL / STH */
114   AM_RANGE(0x82, 0x82) AM_DEVWRITE("m72", m72_sample_w)         /* COUNT UP */
115   AM_RANGE(0x83, 0x83) AM_DEVWRITE("m72", m72_sound_irq_ack_w)   /* IRQ clear */
116   AM_RANGE(0x84, 0x84) AM_DEVREAD("m72", m72_sample_r)   /* S ROM C */
117117ADDRESS_MAP_END
118118
119119static ADDRESS_MAP_START( buccanrs_sound_io_map, AS_IO, 8 )
r11160r11161
121121   AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("ym1", ym2203_r, ym2203_w)
122122   AM_RANGE(0x02, 0x03) AM_DEVREADWRITE("ym2", ym2203_r, ym2203_w)
123123   AM_RANGE(0x80, 0x80) AM_READ(soundlatch_r)            /* SDRE */
124   AM_RANGE(0x80, 0x81) AM_WRITE(vigilant_sample_addr_w)   /* STL / STH */
125   AM_RANGE(0x82, 0x82) AM_DEVWRITE("dac", m72_sample_w)            /* COUNT UP */
126   AM_RANGE(0x83, 0x83) AM_WRITE(m72_sound_irq_ack_w)      /* IRQ clear */
127   AM_RANGE(0x84, 0x84) AM_READ(m72_sample_r)            /* S ROM C */
124   AM_RANGE(0x80, 0x81) AM_DEVWRITE("m72", vigilant_sample_addr_w)   /* STL / STH */
125   AM_RANGE(0x82, 0x82) AM_DEVWRITE("m72", m72_sample_w)            /* COUNT UP */
126   AM_RANGE(0x83, 0x83) AM_DEVWRITE("m72", m72_sound_irq_ack_w)      /* IRQ clear */
127   AM_RANGE(0x84, 0x84) AM_DEVREAD("m72", m72_sample_r)            /* S ROM C */
128128ADDRESS_MAP_END
129129
130130
r11160r11161
526526   MCFG_CPU_IO_MAP(sound_io_map)
527527   MCFG_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1 */
528528                        /* IRQs are generated by main Z80 and YM2151 */
529   MCFG_SOUND_START(m72)
530   MCFG_SOUND_RESET(m72)
531
532529   /* video hardware */
533530   MCFG_SCREEN_ADD("screen", RASTER)
534531   MCFG_SCREEN_REFRESH_RATE(55)
r11160r11161
547544   /* sound hardware */
548545   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
549546
547   MCFG_SOUND_ADD("m72", M72, 0)
548
550549   MCFG_SOUND_ADD("ymsnd", YM2151, 3579645)
551550   MCFG_SOUND_CONFIG(ym2151_config)
552551   MCFG_SOUND_ROUTE(0, "lspeaker", 0.55)
r11160r11161
570569   MCFG_CPU_IO_MAP(buccanrs_sound_io_map)
571570   MCFG_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1 */
572571                        /* IRQs are generated by main Z80 and YM2151 */
573   MCFG_SOUND_START(m72)
574   MCFG_SOUND_RESET(m72)
575
576572   /* video hardware */
577573   MCFG_SCREEN_ADD("screen", RASTER)
578574   MCFG_SCREEN_REFRESH_RATE(55)
r11160r11161
591587   /* sound hardware */
592588   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
593589
590   MCFG_SOUND_ADD("m72", M72, 0)
591
594592   MCFG_SOUND_ADD("ym1", YM2203, 18432000/6)
595593   MCFG_SOUND_CONFIG(ym2203_config)
596594   MCFG_SOUND_ROUTE(0, "lspeaker",  0.35)
r11160r11161
630628   MCFG_CPU_IO_MAP(sound_io_map)
631629   MCFG_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1 */
632630                        /* IRQs are generated by main Z80 and YM2151 */
633   MCFG_SOUND_START(m72)
634   MCFG_SOUND_RESET(m72)
635
636631   /* video hardware */
637632   MCFG_SCREEN_ADD("screen", RASTER)
638633   MCFG_SCREEN_REFRESH_RATE(55)
r11160r11161
651646   /* sound hardware */
652647   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
653648
649   MCFG_SOUND_ADD("m72", M72, 0)
650
654651   MCFG_SOUND_ADD("ymsnd", YM2151, 3579645)
655652   MCFG_SOUND_CONFIG(ym2151_config)
656653   MCFG_SOUND_ROUTE(0, "lspeaker", 0.55)
src/mame/drivers/subsino2.c
r11160r11161
1414Year  Game            CPU         Sound            Custom                            Other
1515-------------------------------------------------------------------------------------------------------------
16161996  Magic Train     HD647180*   U6295            SS9601, SS9602                    HM86171 RAMDAC, Battery
171996  Water-Nymph     HD647180*   U6295            SS9601, SS9602                    HM86171 RAMDAC, Battery
17181998  Express Card    AM188-EM    M6295            SS9601, SS9802, SS9803            HM86171 RAMDAC, Battery
18191998  Ying Hua Lian   AM188-EM    M6295 + YM3812?  SS9601, SS9602                    HM86171 RAMDAC, Battery
19201999  Bishou Jan      H8/3044     SS9904?          SS9601, SS9802, SS9803            HM86171 RAMDAC, Battery
r11160r11161
4041#include "sound/3812intf.h"
4142#include "sound/okim6295.h"
4243#include "machine/nvram.h"
44#include "machine/subsino.h"
4345#include "machine/ticket.h"
4446
4547
r11160r11161
312314
313315More registers, at boot (never changed AFAICT):
314316
315mtrain      saklove     xtrain,      expcard
316                        xplan
317mtrain,     saklove     xtrain,      expcard
318wtrnymph                xplan
317319
318320                         C0 = 0A     C0 = 0A
319321                         E0 = 18     E0 = 18
r11160r11161
3283309107 = 00   207 = 00    207 = 00    207 = 00
3293319108 = 33   208 = 33    208 = 33    208 = 33
3303329109 = 16   209 = 0E    209 = 0E    209 = 0E
331910A = F6   20A = FD    20A = FD    20A = FD
333910A = F6   20A = FD    20A = FD    20A = FD    *F5 in wtrnymph
332334910B = 22   20B = 22    20B = 22    20B = 22
333335910C = FE   20C = FE    20C = FE    20C = FE
334336910D = FB   20D = FB    20D = FB    20D = FB
r11160r11161
19992001   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SPECIAL       )                              // serial in?
20002002INPUT_PORTS_END
20012003
2004/***************************************************************************
2005                               Water-Nymph
2006***************************************************************************/
20022007
2008static INPUT_PORTS_START( wtrnymph )
2009   PORT_START("DSW1")
2010   PORT_DIPNAME( 0x07, 0x00, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW1:1,2,3")
2011   PORT_DIPSETTING(    0x01, DEF_STR( 1C_1C ) )
2012   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
2013   PORT_DIPSETTING(    0x03, DEF_STR( 1C_5C ) )
2014   PORT_DIPSETTING(    0x00, "1 Coin / 10 Credits" )
2015   PORT_DIPSETTING(    0x04, "1 Coin / 20 Credits" )
2016   PORT_DIPSETTING(    0x05, "1 Coin / 25 Credits" )
2017   PORT_DIPSETTING(    0x06, "1 Coin / 50 Credits" )
2018   PORT_DIPSETTING(    0x07, "1 Coin / 100 Credits" )
2019   PORT_DIPNAME( 0x38, 0x00, "Key Coinage" )         PORT_DIPLOCATION("SW1:4,5,6")
2020   PORT_DIPSETTING(    0x08, "1 Key / 1 Credits" )
2021   PORT_DIPSETTING(    0x10, "1 Key / 2 Credits" )
2022   PORT_DIPSETTING(    0x18, "1 Key / 5 Credits" )
2023   PORT_DIPSETTING(    0x00, "1 Key / 10 Credits" )
2024   PORT_DIPSETTING(    0x20, "1 Key / 20 Credits" )
2025   PORT_DIPSETTING(    0x28, "1 Key / 25 Credits" )
2026   PORT_DIPSETTING(    0x30, "1 Key / 50 Credits" )
2027   PORT_DIPSETTING(    0x38, "1 Key / 100 Credits" )
2028   PORT_DIPNAME( 0x40, 0x40, "Pay Out" )            PORT_DIPLOCATION("SW1:7")
2029   PORT_DIPSETTING(    0x40, "Coin" )
2030   PORT_DIPSETTING(    0x00, "Key" )
2031   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:8")
2032   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2033   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2034
2035   PORT_START("DSW2")
2036   PORT_DIPNAME( 0x03, 0x00, "Minimum Bet" )         PORT_DIPLOCATION("SW2:1,2")
2037   PORT_DIPSETTING(    0x01, "1" )
2038   PORT_DIPSETTING(    0x00, "8" )
2039   PORT_DIPSETTING(    0x02, "16" )
2040   PORT_DIPSETTING(    0x03, "20" )
2041   PORT_DIPNAME( 0x0c, 0x0c, "Max Bet" )            PORT_DIPLOCATION("SW2:3,4")
2042   PORT_DIPSETTING(    0x08, "10" )
2043   PORT_DIPSETTING(    0x04, "20" )
2044   PORT_DIPSETTING(    0x00, "40" )
2045   PORT_DIPSETTING(    0x0c, "60" )
2046   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("SW2:5")
2047   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
2048   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
2049   PORT_DIPNAME( 0x60, 0x60, "Game Limit" )         PORT_DIPLOCATION("SW2:6,7")
2050   PORT_DIPSETTING(    0x20, "10k" )
2051   PORT_DIPSETTING(    0x00, "20k" )
2052   PORT_DIPSETTING(    0x40, "30k" )
2053   PORT_DIPSETTING(    0x60, "40k" )
2054   PORT_DIPNAME( 0x80, 0x80, "Double Up" )            PORT_DIPLOCATION("SW2:8")
2055   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
2056   PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
2057
2058   PORT_START("DSW3")
2059   PORT_DIPNAME( 0x07, 0x07, "Win Rate" )      PORT_DIPLOCATION("SW3:1,2,3")
2060   PORT_DIPSETTING(    0x07, "55%" )
2061   PORT_DIPSETTING(    0x06, "60%" )
2062   PORT_DIPSETTING(    0x05, "65%" )
2063   PORT_DIPSETTING(    0x04, "70%" )
2064   PORT_DIPSETTING(    0x03, "75%" )
2065   PORT_DIPSETTING(    0x00, "80%" )
2066   PORT_DIPSETTING(    0x02, "85%" )
2067   PORT_DIPSETTING(    0x01, "90%" )
2068   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW3:4")
2069   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2070   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2071   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW3:5")
2072   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2073   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2074   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW3:6")
2075   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2076   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2077   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW3:7")
2078   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2079   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2080   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW3:8")
2081   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2082   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2083
2084   PORT_START("DSW4")
2085   PORT_DIPNAME( 0x07, 0x07, "Double-Up Rate" )      PORT_DIPLOCATION("SW4:1,2,3")
2086   PORT_DIPSETTING(    0x00, "82%" )
2087   PORT_DIPSETTING(    0x01, "84%" )
2088   PORT_DIPSETTING(    0x02, "88%" )
2089   PORT_DIPSETTING(    0x03, "90%" )
2090   PORT_DIPSETTING(    0x04, "92%" )
2091   PORT_DIPSETTING(    0x05, "94%" )
2092   PORT_DIPSETTING(    0x06, "96%" )
2093   PORT_DIPSETTING(    0x07, "98%" )
2094   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW4:4")
2095   PORT_DIPSETTING(    0x00, "5k" )
2096   PORT_DIPSETTING(    0x08, "10k" )
2097   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW4:6")
2098   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2099   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2100   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW4:6")
2101   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2102   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2103   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW4:7")
2104   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2105   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2106   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW4:8")
2107   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2108   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2109
2110   PORT_START("IN A")
2111   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN    )
2112   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN    )
2113   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN    )
2114   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START      )   PORT_CODE(KEYCODE_N)   PORT_NAME("Start All")
2115   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_GAMBLE_BET )   PORT_NAME("Bet / Stop All")
2116   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER      ) PORT_CODE(KEYCODE_Z)   PORT_NAME("Info / Double?")   // down
2117   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN    )
2118   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN    )
2119
2120   PORT_START("IN B")
2121   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_KEYIN  ) PORT_IMPULSE(5)         // key in
2122   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1         )                     // coin in
2123   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN       )
2124   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN       )
2125   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_GAMBLE_BOOK   )   // stats
2126   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE       )   // service mode
2127   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT )   // payout (hopper error)
2128   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_GAMBLE_KEYOUT )   // key out
2129
2130   PORT_START("IN C")
2131   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SLOT_STOP3 )   PORT_NAME("Stop 3 / Right")
2132   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN    )
2133   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN    )
2134   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SLOT_STOP2 )   PORT_NAME("Stop 2 / Left / Play Gambling 1")      // C \__ play gambling game
2135   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER      )   PORT_NAME("Play Gambling 2") PORT_CODE(KEYCODE_D)   // D /
2136   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN    )
2137   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SLOT_STOP1 )   PORT_NAME("Stop 1 / Take / Rotate")
2138   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER      ) PORT_NAME("Play Tetris")     PORT_CODE(KEYCODE_T)   // T |__ play Tetris game
2139
2140   PORT_START("IN D")   // not shown in test mode
2141   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN  )
2142   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN  )
2143   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN  )
2144   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN  )
2145   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER    ) PORT_NAME("Reset") PORT_CODE(KEYCODE_F1)
2146   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN  )
2147   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN  )
2148   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SPECIAL  )   // serial in?
2149INPUT_PORTS_END
2150
2151
20032152/***************************************************************************
20042153                                Machine Drivers
20052154***************************************************************************/
r11160r11161
23482497   ROM_REGION( 0x80000, "oki", 0 )
23492498   ROM_LOAD( "rom_5.u27", 0x00000, 0x40000, CRC(51cae476) SHA1(d1da4e5c3d53d18d8b69dfb57796d0ae311d99bf) )
23502499   ROM_RELOAD(            0x40000, 0x40000 )
2500
2501    ROM_REGION( 0x117, "plds", 0 )
2502    ROM_LOAD( "gal16v8d.u6",  0x000, 0x117, NO_DUMP )
2503    ROM_LOAD( "gal16v8d.u18", 0x000, 0x117, NO_DUMP )
2504    ROM_LOAD( "gal16v8d.u19", 0x000, 0x117, NO_DUMP )
2505    ROM_LOAD( "gal16v8d.u26", 0x000, 0x117, NO_DUMP )
2506    ROM_LOAD( "gal16v8d.u31", 0x000, 0x117, NO_DUMP )
23512507ROM_END
23522508
23532509/***************************************************************************
23542510
2355  Decryption of mtrain (lifted from subsino.c)
2511  Decryption of mtrain (same as crsbingo)
23562512
23572513  Notes:
23582514
r11160r11161
23672523
23682524***************************************************************************/
23692525
2370static void crsbingo_bitswaps(UINT8* decrypt, int i)
2371{
2372   if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
2373   if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
2374   if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],3,2,5,0,7,6,1,4);
2375   if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,0,3,6,1,4);
2376   if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,0,3,2,1,4);
2377   if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,4,3,6,5,0);
2378   if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
2379   if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,0,7,6,5,4);
2380}
2381
2382static const unsigned char crsbingo_xors[8] = { 0xbb, 0xcc, 0xcc, 0xdd, 0xaa, 0x11, 0x44, 0xee };
2383
2384static void subsino_decrypt(running_machine& machine, void (*bitswaps)(UINT8* decrypt, int i), const UINT8* xors, int size)
2385{
2386   int i;
2387   UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000);
2388   UINT8* region = machine.region("maincpu")->base();
2389
2390   for (i=0;i<0x10000;i++)
2391   {
2392      if (i<size)
2393      {
2394         decrypt[i] = region[i]^xors[i&7];
2395         bitswaps(decrypt, i);
2396      }
2397      else
2398      {
2399         decrypt[i] = region[i];
2400      }
2401   }
2402//  dump_decrypted(machine, decrypt);
2403   memcpy(region, decrypt, 0x10000);
2404}
2405
24062526DRIVER_INIT( mtrain )
24072527{
24082528   subsino_decrypt(machine, crsbingo_bitswaps, crsbingo_xors, 0x8000);
r11160r11161
25882708   rom[0xe190f-0xc0000] = 0xeb;
25892709}
25902710
2591GAME( 1996, mtrain,  0, mtrain,  mtrain,  mtrain,  ROT0, "Subsino",        "Magic Train (Ver. 1.31)",               0 )
2592GAME( 1998, expcard, 0, expcard, expcard, expcard, ROT0, "American Alpha", "Express Card / Top Card (Ver. 1.5)",    0 )
2593GAME( 1998, saklove, 0, saklove, saklove, saklove, ROT0, "Subsino",        "Ying Hua Lian 2.0 (China, Ver. 1.02)",  0 )
2594GAME( 1999, xtrain,  0, xtrain,  xtrain,  xtrain,  ROT0, "Subsino",        "X-Train (Ver. 1.3)",                    0 )
2595GAME( 1999, bishjan, 0, bishjan, bishjan, bishjan, ROT0, "Subsino",        "Bishou Jan (Japan, Ver. 2.03)",         GAME_NO_SOUND )
2596GAME( 2006, xplan,   0, xplan,   xplan,   xplan,   ROT0, "Subsino",        "X-Plan (Ver. 1.01)",                    0 )
2711/***************************************************************************
2712
2713Water-Nymph (Ver. 1.4)
2714(c) 1996 Subsino
2715
2716Same PCB as Magic Train
2717
2718***************************************************************************/
2719
2720ROM_START( wtrnymph )
2721   ROM_REGION( 0x10000, "maincpu", 0 )
2722   // code starts at 0x8100!
2723   ROM_LOAD( "ocean-n tetris_1 v1.4.u17", 0x0000, 0x8100, CRC(c7499123) SHA1(39a9ea6d927ee839cfb127747e5e3df3535af098) )
2724   ROM_CONTINUE(                          0x0000, 0x7f00 )
2725   ROM_RELOAD(                            0xa000, 0x6000 )
2726
2727   ROM_REGION( 0x100000, "tilemap", 0 )
2728   ROM_LOAD32_BYTE( "ocean-n tetris_2 v1.21.u2", 0x00000, 0x40000, CRC(813aac90) SHA1(4555adf8dc363359b10f1d5cfae2dcebed411679) )
2729   ROM_LOAD32_BYTE( "ocean-n tetris_3 v1.21.u3", 0x00001, 0x40000, CRC(83c39379) SHA1(e7f9315d19370c18b664b759e433052a88f8c146) )
2730   ROM_LOAD32_BYTE( "ocean-n tetris_4 v1.21.u4", 0x00002, 0x40000, CRC(6fc64b42) SHA1(80110d7dae28cca5e39c8a7c2ceebf589116ae23) )
2731   ROM_LOAD32_BYTE( "ocean-n tetris_5 v1.21.u5", 0x00003, 0x40000, CRC(8c7515ee) SHA1(a67b21c1e8ca8a098fe558c73561bca13962893e) )
2732
2733   ROM_REGION( 0x80000, "oki", 0 )
2734   ROM_LOAD( "ocean-n tetris_6 v1.21.u27", 0x00000, 0x40000, CRC(1c8a886d) SHA1(faa983801b368a6d04ef80e359c6fb67b240c60d) )
2735   ROM_RELOAD(                             0x40000, 0x40000 )
2736
2737    ROM_REGION( 0x117, "plds", 0 )
2738    ROM_LOAD( "gal16v8d.u6",  0x000, 0x117, NO_DUMP )
2739    ROM_LOAD( "gal16v8d.u18", 0x000, 0x117, NO_DUMP )
2740    ROM_LOAD( "gal16v8d.u19", 0x000, 0x117, NO_DUMP )
2741    ROM_LOAD( "gal16v8d.u26", 0x000, 0x117, NO_DUMP )
2742    ROM_LOAD( "gal16v8d.u31", 0x000, 0x117, NO_DUMP )
2743ROM_END
2744
2745DRIVER_INIT( wtrnymph )
2746{
2747   subsino_decrypt(machine, victor5_bitswaps, victor5_xors, 0x8000);
2748
2749   // patch serial protection test (it always enters test mode on boot otherwise)
2750   UINT8 *rom = machine.region("maincpu")->base();
2751   rom[0x0d79] = 0x18;
2752   rom[0xc1cf] = 0x18;
2753   rom[0xc2a9] = 0x18;
2754   rom[0xc2d7] = 0x18;
2755}
2756
2757GAME( 1996, mtrain,   0,        mtrain,   mtrain,   mtrain,   ROT0, "Subsino",        "Magic Train (Ver. 1.31)",              0 )
2758GAME( 1996, wtrnymph, 0,        mtrain,   wtrnymph, wtrnymph, ROT0, "Subsino",        "Water-Nymph (Ver. 1.4)",               0 )
2759GAME( 1998, expcard,  0,        expcard,  expcard,  expcard,  ROT0, "American Alpha", "Express Card / Top Card (Ver. 1.5)",   0 )
2760GAME( 1998, saklove,  0,        saklove,  saklove,  saklove,  ROT0, "Subsino",        "Ying Hua Lian 2.0 (China, Ver. 1.02)", 0 )
2761GAME( 1999, xtrain,   0,        xtrain,   xtrain,   xtrain,   ROT0, "Subsino",        "X-Train (Ver. 1.3)",                   0 )
2762GAME( 1999, bishjan,  0,        bishjan,  bishjan,  bishjan,  ROT0, "Subsino",        "Bishou Jan (Japan, Ver. 2.03)",        GAME_NO_SOUND )
2763GAME( 2006, xplan,    0,        xplan,    xplan,    xplan,    ROT0, "Subsino",        "X-Plan (Ver. 1.01)",                   0 )
src/mame/drivers/exidy440.c
r11160r11161
345345
346346static READ8_HANDLER( sound_command_ack_r )
347347{
348   exidy440_state *state = space->machine().driver_data<exidy440_state>();
348349   /* sound command acknowledgements come on bit 3 here */
349   return exidy440_sound_command_ack() ? 0xf7 : 0xff;
350   return exidy440_sound_command_ack(state->m_custom) ? 0xf7 : 0xff;
350351}
351352
352353
r11160r11161
359360
360361static TIMER_CALLBACK( delayed_sound_command_w )
361362{
362   exidy440_sound_command(machine, param);
363   exidy440_state *state = machine.driver_data<exidy440_state>();
364   exidy440_sound_command(state->m_custom, param);
363365}
364366
365367
r11160r11161
447449
448450static MACHINE_START( exidy440 )
449451{
452   exidy440_state *state = machine.driver_data<exidy440_state>();
450453   /* the EEROM lives in the uppermost 8k of the top bank */
451454   UINT8 *rom = machine.region("maincpu")->base();
455
456   state->m_custom = machine.device("custom");
452457   machine.device<nvram_device>("nvram")->set_base(&rom[0x10000 + 15 * 0x4000 + 0x2000], 0x2000);
453458}
454459
src/mame/drivers/dambustr.c
r11160r11161
5454#include "machine/7474.h"
5555
5656
57class dambustr_state : public driver_device
57class dambustr_state : public galaxold_state
5858{
5959public:
6060   dambustr_state(running_machine &machine, const driver_device_config_base &config)
61      : driver_device(machine, config) { }
61      : galaxold_state(machine, config) { }
6262
6363   int m_noise_data;
6464};
r11160r11161
8484
8585   AM_RANGE(0xc000, 0xc7ff) AM_RAM
8686
87   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
87   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
8888   AM_RANGE(0xd400, 0xd7ff) AM_READ(galaxold_videoram_r)
89   AM_RANGE(0xd800, 0xd83f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
90   AM_RANGE(0xd840, 0xd85f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
91   AM_RANGE(0xd860, 0xd87f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
89   AM_RANGE(0xd800, 0xd83f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
90   AM_RANGE(0xd840, 0xd85f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
91   AM_RANGE(0xd860, 0xd87f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
9292
9393   AM_RANGE(0xd880, 0xd8ff) AM_RAM
9494
src/mame/drivers/m72.c
r11160r11161
106106static MACHINE_START( m72 )
107107{
108108   m72_state *state = machine.driver_data<m72_state>();
109   state->m_audio = machine.device("m72");
109110   state->m_scanline_timer = machine.scheduler().timer_alloc(FUNC(m72_scanline_interrupt));
110111
111112   state->save_item(NAME(state->m_mcu_sample_addr));
r11160r11161
453454
454455static INTERRUPT_GEN(fake_nmi)
455456{
456   address_space *space = device->memory().space(AS_PROGRAM);
457   int sample = m72_sample_r(space,0);
457   m72_state *state = device->machine().driver_data<m72_state>();
458   int sample = m72_sample_r(state->m_audio,0);
458459   if (sample)
459      m72_sample_w(device->machine().device("dac"),0,sample);
460      m72_sample_w(state->m_audio,0,sample);
460461}
461462
462463
463464static WRITE16_HANDLER( bchopper_sample_trigger_w )
464465{
466   m72_state *state = space->machine().driver_data<m72_state>();
465467   static const int a[6] = { 0x0000, 0x0010, 0x2510, 0x6510, 0x8510, 0x9310 };
466   if (ACCESSING_BITS_0_7 && (data & 0xff) < 6) m72_set_sample_start(a[data & 0xff]);
468   if (ACCESSING_BITS_0_7 && (data & 0xff) < 6) m72_set_sample_start(state->m_audio, a[data & 0xff]);
467469}
468470
469471static WRITE16_HANDLER( nspirit_sample_trigger_w )
470472{
473   m72_state *state = space->machine().driver_data<m72_state>();
471474   static const int a[9] = { 0x0000, 0x0020, 0x2020, 0, 0x5720, 0, 0x7b60, 0x9b60, 0xc360 };
472   if (ACCESSING_BITS_0_7 && (data & 0xff) < 9) m72_set_sample_start(a[data & 0xff]);
475   if (ACCESSING_BITS_0_7 && (data & 0xff) < 9) m72_set_sample_start(state->m_audio, a[data & 0xff]);
473476}
474477
475478static WRITE16_HANDLER( imgfight_sample_trigger_w )
476479{
480   m72_state *state = space->machine().driver_data<m72_state>();
477481   static const int a[7] = { 0x0000, 0x0020, 0x44e0, 0x98a0, 0xc820, 0xf7a0, 0x108c0 };
478   if (ACCESSING_BITS_0_7 && (data & 0xff) < 7) m72_set_sample_start(a[data & 0xff]);
482   if (ACCESSING_BITS_0_7 && (data & 0xff) < 7) m72_set_sample_start(state->m_audio, a[data & 0xff]);
479483}
480484
481485static WRITE16_HANDLER( loht_sample_trigger_w )
482486{
487   m72_state *state = space->machine().driver_data<m72_state>();
483488   static const int a[7] = { 0x0000, 0x0020, 0, 0x2c40, 0x4320, 0x7120, 0xb200 };
484   if (ACCESSING_BITS_0_7 && (data & 0xff) < 7) m72_set_sample_start(a[data & 0xff]);
489   if (ACCESSING_BITS_0_7 && (data & 0xff) < 7) m72_set_sample_start(state->m_audio, a[data & 0xff]);
485490}
486491
487492static WRITE16_HANDLER( xmultiplm72_sample_trigger_w )
488493{
494   m72_state *state = space->machine().driver_data<m72_state>();
489495   static const int a[3] = { 0x0000, 0x0020, 0x1a40 };
490   if (ACCESSING_BITS_0_7 && (data & 0xff) < 3) m72_set_sample_start(a[data & 0xff]);
496   if (ACCESSING_BITS_0_7 && (data & 0xff) < 3) m72_set_sample_start(state->m_audio, a[data & 0xff]);
491497}
492498
493499static WRITE16_HANDLER( dbreedm72_sample_trigger_w )
494500{
501   m72_state *state = space->machine().driver_data<m72_state>();
495502   static const int a[9] = { 0x00000, 0x00020, 0x02c40, 0x08160, 0x0c8c0, 0x0ffe0, 0x13000, 0x15820, 0x15f40 };
496   if (ACCESSING_BITS_0_7 && (data & 0xff) < 9) m72_set_sample_start(a[data & 0xff]);
503   if (ACCESSING_BITS_0_7 && (data & 0xff) < 9) m72_set_sample_start(state->m_audio, a[data & 0xff]);
497504}
498505
499506static WRITE16_HANDLER( airduel_sample_trigger_w )
500507{
508   m72_state *state = space->machine().driver_data<m72_state>();
501509   static const int a[16] = {
502510      0x00000, 0x00020, 0x03ec0, 0x05640, 0x06dc0, 0x083a0, 0x0c000, 0x0eb60,
503511      0x112e0, 0x13dc0, 0x16520, 0x16d60, 0x18ae0, 0x1a5a0, 0x1bf00, 0x1c340 };
504   if (ACCESSING_BITS_0_7 && (data & 0xff) < 16) m72_set_sample_start(a[data & 0xff]);
512   if (ACCESSING_BITS_0_7 && (data & 0xff) < 16) m72_set_sample_start(state->m_audio, a[data & 0xff]);
505513}
506514
507515static WRITE16_HANDLER( dkgenm72_sample_trigger_w )
508516{
517   m72_state *state = space->machine().driver_data<m72_state>();
509518   static const int a[28] = {
510519      0x00000, 0x00020, 0x01800, 0x02da0, 0x03be0, 0x05ae0, 0x06100, 0x06de0,
511520      0x07260, 0x07a60, 0x08720, 0x0a5c0, 0x0c3c0, 0x0c7a0, 0x0e140, 0x0fb00,
512521      0x10fa0, 0x10fc0, 0x10fe0, 0x11f40, 0x12b20, 0x130a0, 0x13c60, 0x14740,
513522      0x153c0, 0x197e0, 0x1af40, 0x1c080 };
514523
515   if (ACCESSING_BITS_0_7 && (data & 0xff) < 28) m72_set_sample_start(a[data & 0xff]);
524   if (ACCESSING_BITS_0_7 && (data & 0xff) < 28) m72_set_sample_start(state->m_audio, a[data & 0xff]);
516525}
517526
518527static WRITE16_HANDLER( gallop_sample_trigger_w )
519528{
529   m72_state *state = space->machine().driver_data<m72_state>();
520530   static const int a[31] = {
521531      0x00000, 0x00020, 0x00040, 0x01360, 0x02580, 0x04f20, 0x06240, 0x076e0,
522532      0x08660, 0x092a0, 0x09ba0, 0x0a560, 0x0cee0, 0x0de20, 0x0e620, 0x0f1c0,
523533      0x10200, 0x10220, 0x10240, 0x11380, 0x12760, 0x12780, 0x127a0, 0x13c40,
524534      0x140a0, 0x16760, 0x17e40, 0x18ee0, 0x19f60, 0x1bbc0, 0x1cee0 };
525535
526   if (ACCESSING_BITS_0_7 && (data & 0xff) < 31) m72_set_sample_start(a[data & 0xff]);
536   if (ACCESSING_BITS_0_7 && (data & 0xff) < 31) m72_set_sample_start(state->m_audio, a[data & 0xff]);
527537}
528538
529539
r11160r11161
9981008   AM_RANGE(0x00, 0x01) AM_READ_PORT("IN0")
9991009   AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
10001010   AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
1001   AM_RANGE(0x00, 0x01) AM_WRITE(m72_sound_command_w)
1011   AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_sound_command_w)
10021012   AM_RANGE(0x02, 0x03) AM_WRITE(m72_port02_w)   /* coin counters, reset sound cpu, other stuff? */
10031013   AM_RANGE(0x04, 0x05) AM_WRITE(m72_dmaon_w)
10041014   AM_RANGE(0x06, 0x07) AM_WRITE(m72_irq_line_w)
r11160r11161
10141024   AM_RANGE(0x00, 0x01) AM_READ_PORT("IN0")
10151025   AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
10161026   AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
1017   AM_RANGE(0x00, 0x01) AM_WRITE(m72_sound_command_w)
1027   AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_sound_command_w)
10181028   AM_RANGE(0x02, 0x03) AM_WRITE(rtype2_port02_w)
10191029   AM_RANGE(0x40, 0x43) AM_WRITENOP /* Interrupt controller, only written to at bootup */
10201030   AM_RANGE(0x80, 0x81) AM_WRITE(m72_scrolly1_w)
r11160r11161
10271037   AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
10281038   AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
10291039   AM_RANGE(0x08, 0x0f) AM_READ(poundfor_trackball_r)
1030   AM_RANGE(0x00, 0x01) AM_WRITE(m72_sound_command_w)
1040   AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_sound_command_w)
10311041   AM_RANGE(0x02, 0x03) AM_WRITE(rtype2_port02_w)
10321042   AM_RANGE(0x40, 0x43) AM_WRITENOP /* Interrupt controller, only written to at bootup */
10331043   AM_RANGE(0x80, 0x81) AM_WRITE(m72_scrolly1_w)
r11160r11161
10401050   AM_RANGE(0x00, 0x01) AM_READ_PORT("IN0")
10411051   AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
10421052   AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
1043   AM_RANGE(0x00, 0x01) AM_WRITE(m72_sound_command_w)
1053   AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_sound_command_w)
10441054   AM_RANGE(0x02, 0x03) AM_WRITE(rtype2_port02_w)
10451055   AM_RANGE(0x40, 0x43) AM_WRITENOP /* Interrupt controller, only written to at bootup */
10461056   AM_RANGE(0x80, 0x81) AM_WRITE(m72_scrolly1_w)
r11160r11161
10541064   AM_RANGE(0x00, 0x01) AM_READ_PORT("IN0")
10551065   AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
10561066   AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
1057   AM_RANGE(0x00, 0x01) AM_WRITE(m72_sound_command_w)
1067   AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_sound_command_w)
10581068   AM_RANGE(0x02, 0x03) AM_WRITE(rtype2_port02_w)   /* coin counters, reset sound cpu, other stuff? */
10591069   AM_RANGE(0x04, 0x05) AM_WRITE(m72_dmaon_w)
10601070   AM_RANGE(0x06, 0x07) AM_WRITE(m72_irq_line_w)
r11160r11161
10691079   AM_RANGE(0x00, 0x01) AM_READ_PORT("IN0")
10701080   AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
10711081   AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
1072   AM_RANGE(0x00, 0x01) AM_WRITE(m72_sound_command_w)
1082   AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_sound_command_w)
10731083   AM_RANGE(0x02, 0x03) AM_WRITE(rtype2_port02_w)
10741084   AM_RANGE(0x80, 0x81) AM_WRITE(m72_scrolly1_w)
10751085   AM_RANGE(0x82, 0x83) AM_WRITE(m72_scrollx1_w)
r11160r11161
10921102   ADDRESS_MAP_GLOBAL_MASK(0xff)
10931103   AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
10941104   AM_RANGE(0x02, 0x02) AM_READ(soundlatch_r)
1095   AM_RANGE(0x06, 0x06) AM_WRITE(m72_sound_irq_ack_w)
1096   AM_RANGE(0x84, 0x84) AM_READ(m72_sample_r)
1105   AM_RANGE(0x06, 0x06) AM_DEVWRITE("m72", m72_sound_irq_ack_w)
1106   AM_RANGE(0x84, 0x84) AM_DEVREAD("m72", m72_sample_r)
10971107ADDRESS_MAP_END
10981108
10991109static ADDRESS_MAP_START( sound_portmap, AS_IO, 8 )
11001110   ADDRESS_MAP_GLOBAL_MASK(0xff)
11011111   AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
11021112   AM_RANGE(0x02, 0x02) AM_READ(soundlatch_r)
1103   AM_RANGE(0x06, 0x06) AM_WRITE(m72_sound_irq_ack_w)
1104   AM_RANGE(0x82, 0x82) AM_DEVWRITE("dac", m72_sample_w)
1105   AM_RANGE(0x84, 0x84) AM_READ(m72_sample_r)
1113   AM_RANGE(0x06, 0x06) AM_DEVWRITE("m72", m72_sound_irq_ack_w)
1114   AM_RANGE(0x82, 0x82) AM_DEVWRITE("m72", m72_sample_w)
1115   AM_RANGE(0x84, 0x84) AM_DEVREAD("m72", m72_sample_r)
11061116ADDRESS_MAP_END
11071117
11081118static ADDRESS_MAP_START( rtype2_sound_portmap, AS_IO, 8 )
11091119   ADDRESS_MAP_GLOBAL_MASK(0xff)
11101120   AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
11111121   AM_RANGE(0x80, 0x80) AM_READ(soundlatch_r)
1112   AM_RANGE(0x80, 0x81) AM_WRITE(rtype2_sample_addr_w)
1113   AM_RANGE(0x82, 0x82) AM_DEVWRITE("dac", m72_sample_w)
1114   AM_RANGE(0x83, 0x83) AM_WRITE(m72_sound_irq_ack_w)
1115   AM_RANGE(0x84, 0x84) AM_READ(m72_sample_r)
1122   AM_RANGE(0x80, 0x81) AM_DEVWRITE("m72", rtype2_sample_addr_w)
1123   AM_RANGE(0x82, 0x82) AM_DEVWRITE("m72", m72_sample_w)
1124   AM_RANGE(0x83, 0x83) AM_DEVWRITE("m72", m72_sound_irq_ack_w)
1125   AM_RANGE(0x84, 0x84) AM_DEVREAD("m72", m72_sample_r)
11161126//  AM_RANGE(0x87, 0x87) AM_WRITENOP    /* ??? */
11171127ADDRESS_MAP_END
11181128
11191129static ADDRESS_MAP_START( poundfor_sound_portmap, AS_IO, 8 )
11201130   ADDRESS_MAP_GLOBAL_MASK(0xff)
1121   AM_RANGE(0x10, 0x13) AM_WRITE(poundfor_sample_addr_w)
1131   AM_RANGE(0x10, 0x13) AM_DEVWRITE("m72", poundfor_sample_addr_w)
11221132   AM_RANGE(0x40, 0x41) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
11231133   AM_RANGE(0x42, 0x42) AM_READ(soundlatch_r)
1124   AM_RANGE(0x42, 0x42) AM_WRITE(m72_sound_irq_ack_w)
1134   AM_RANGE(0x42, 0x42) AM_DEVWRITE("m72", m72_sound_irq_ack_w)
11251135ADDRESS_MAP_END
11261136
11271137static ADDRESS_MAP_START( mcu_io_map, AS_IO, 8 )
r11160r11161
18591869   MCFG_MACHINE_START(m72)
18601870   MCFG_MACHINE_RESET(m72)
18611871
1862   MCFG_SOUND_START(m72)
1863   MCFG_SOUND_RESET(m72)
1864
18651872   /* video hardware */
18661873   MCFG_GFXDECODE(m72)
18671874   MCFG_PALETTE_LENGTH(512)
r11160r11161
18761883   /* sound hardware */
18771884   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
18781885
1886   MCFG_SOUND_ADD("m72", M72, 0);
1887
18791888   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
18801889   MCFG_SOUND_CONFIG(ym2151_config)
18811890   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
19161925   MCFG_MACHINE_START(m72)
19171926   MCFG_MACHINE_RESET(m72)
19181927
1919   MCFG_SOUND_START(m72)
1920   MCFG_SOUND_RESET(m72)
1921
19221928   /* video hardware */
19231929   MCFG_GFXDECODE(m72)
19241930   MCFG_PALETTE_LENGTH(512)
r11160r11161
19331939   /* sound hardware */
19341940   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
19351941
1942   MCFG_SOUND_ADD("m72", M72, 0);
1943
19361944   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
19371945   MCFG_SOUND_CONFIG(ym2151_config)
19381946   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
19551963   MCFG_MACHINE_START(m72)
19561964   MCFG_MACHINE_RESET(xmultipl)
19571965
1958   MCFG_SOUND_START(m72)
1959   MCFG_SOUND_RESET(m72)
1960
19611966   /* video hardware */
19621967   MCFG_GFXDECODE(m72)
19631968   MCFG_PALETTE_LENGTH(512)
r11160r11161
19721977   /* sound hardware */
19731978   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
19741979
1980   MCFG_SOUND_ADD("m72", M72, 0);
1981
19751982   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
19761983   MCFG_SOUND_CONFIG(ym2151_config)
19771984   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
19982005   MCFG_MACHINE_START(m72)
19992006   MCFG_MACHINE_RESET(xmultipl)
20002007
2001   MCFG_SOUND_START(m72)
2002   MCFG_SOUND_RESET(m72)
2003
20042008   /* video hardware */
20052009   MCFG_GFXDECODE(m72)
20062010   MCFG_PALETTE_LENGTH(512)
r11160r11161
20152019   /* sound hardware */
20162020   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
20172021
2022   MCFG_SOUND_ADD("m72", M72, 0);
2023
20182024   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
20192025   MCFG_SOUND_CONFIG(ym2151_config)
20202026   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
20412047   MCFG_MACHINE_START(m72)
20422048   MCFG_MACHINE_RESET(xmultipl)
20432049
2044   MCFG_SOUND_START(m72)
2045   MCFG_SOUND_RESET(m72)
2046
20472050   /* video hardware */
20482051   MCFG_GFXDECODE(rtype2)
20492052   MCFG_PALETTE_LENGTH(512)
r11160r11161
20582061   /* sound hardware */
20592062   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
20602063
2064   MCFG_SOUND_ADD("m72", M72, 0);
2065
20612066   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
20622067   MCFG_SOUND_CONFIG(ym2151_config)
20632068   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
20842089   MCFG_MACHINE_START(m72)
20852090   MCFG_MACHINE_RESET(xmultipl)
20862091
2087   MCFG_SOUND_START(m72)
2088   MCFG_SOUND_RESET(m72)
2089
20902092   /* video hardware */
20912093   MCFG_GFXDECODE(m72)
20922094   MCFG_PALETTE_LENGTH(512)
r11160r11161
21012103   /* sound hardware */
21022104   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
21032105
2106   MCFG_SOUND_ADD("m72", M72, 0);
2107
21042108   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
21052109   MCFG_SOUND_CONFIG(ym2151_config)
21062110   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
21272131   MCFG_MACHINE_START(m72)
21282132   MCFG_MACHINE_RESET(m72)
21292133
2130   MCFG_SOUND_START(m72)
2131   MCFG_SOUND_RESET(m72)
2132
21332134   /* video hardware */
21342135   MCFG_GFXDECODE(rtype2)
21352136   MCFG_PALETTE_LENGTH(512)
r11160r11161
21442145   /* sound hardware */
21452146   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
21462147
2148   MCFG_SOUND_ADD("m72", M72, 0);
2149
21472150   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
21482151   MCFG_SOUND_CONFIG(ym2151_config)
21492152   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
21702173   MCFG_MACHINE_START(m72)
21712174   MCFG_MACHINE_RESET(m72)
21722175
2173   MCFG_SOUND_START(m72)
2174   MCFG_SOUND_RESET(m72)
2175
21762176   /* video hardware */
21772177   MCFG_GFXDECODE(majtitle)
21782178   MCFG_PALETTE_LENGTH(512)
r11160r11161
21872187   /* sound hardware */
21882188   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
21892189
2190   MCFG_SOUND_ADD("m72", M72, 0);
2191
21902192   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
21912193   MCFG_SOUND_CONFIG(ym2151_config)
21922194   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
22132215   MCFG_MACHINE_START(m72)
22142216   MCFG_MACHINE_RESET(xmultipl)
22152217
2216   MCFG_SOUND_START(m72)
2217   MCFG_SOUND_RESET(m72)
2218
22192218   /* video hardware */
22202219   MCFG_GFXDECODE(rtype2)
22212220   MCFG_PALETTE_LENGTH(512)
r11160r11161
22302229   /* sound hardware */
22312230   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
22322231
2232   MCFG_SOUND_ADD("m72", M72, 0);
2233
22332234   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
22342235   MCFG_SOUND_CONFIG(ym2151_config)
22352236   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
22562257   MCFG_MACHINE_START(m72)
22572258   MCFG_MACHINE_RESET(xmultipl)
22582259
2259   MCFG_SOUND_START(m72)
2260   MCFG_SOUND_RESET(m72)
2261
22622260   /* video hardware */
22632261   MCFG_GFXDECODE(rtype2)
22642262   MCFG_PALETTE_LENGTH(512)
r11160r11161
22732271   /* sound hardware */
22742272   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
22752273
2274   MCFG_SOUND_ADD("m72", M72, 0);
2275
22762276   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
22772277   MCFG_SOUND_CONFIG(ym2151_config)
22782278   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
22992299   MCFG_MACHINE_START(m72)
23002300   MCFG_MACHINE_RESET(xmultipl)
23012301
2302   MCFG_SOUND_START(m72)
2303   MCFG_SOUND_RESET(m72)
2304
23052302   /* video hardware */
23062303   MCFG_GFXDECODE(m72)
23072304   MCFG_PALETTE_LENGTH(512)
r11160r11161
23162313   /* sound hardware */
23172314   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
23182315
2316   MCFG_SOUND_ADD("m72", M72, 0);
2317
23192318   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
23202319   MCFG_SOUND_CONFIG(ym2151_config)
23212320   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
23422341   MCFG_MACHINE_START(m72)
23432342   MCFG_MACHINE_RESET(m72)
23442343
2345   MCFG_SOUND_START(m72)
2346   MCFG_SOUND_RESET(m72)
2347
23482344   /* video hardware */
23492345   MCFG_GFXDECODE(rtype2)
23502346   MCFG_PALETTE_LENGTH(512)
r11160r11161
23592355   /* sound hardware */
23602356   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
23612357
2358   MCFG_SOUND_ADD("m72", M72, 0);
2359
23622360   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
23632361   MCFG_SOUND_CONFIG(ym2151_config)
23642362   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
r11160r11161
23852383   MCFG_MACHINE_START(kengo)
23862384   MCFG_MACHINE_RESET(kengo)
23872385
2388   MCFG_SOUND_START(m72)
2389   MCFG_SOUND_RESET(m72)
2390
23912386   /* video hardware */
23922387   MCFG_GFXDECODE(rtype2)
23932388   MCFG_PALETTE_LENGTH(512)
r11160r11161
24022397   /* sound hardware */
24032398   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
24042399
2400   MCFG_SOUND_ADD("m72", M72, 0);
2401
24052402   MCFG_SOUND_ADD("ymsnd", YM2151, SOUND_CLOCK)
24062403   MCFG_SOUND_CONFIG(ym2151_config)
24072404   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
src/mame/drivers/toobin.c
r11160r11161
2121#include "cpu/m68000/m68000.h"
2222#include "machine/atarigen.h"
2323#include "audio/atarijsa.h"
24#include "video/atarimo.h"
2425#include "includes/toobin.h"
2526
2627#define MASTER_CLOCK      XTAL_32MHz
r11160r11161
111112   AM_RANGE(0x000000, 0x07ffff) AM_ROM
112113   AM_RANGE(0xc00000, 0xc07fff) AM_RAM_WRITE(atarigen_playfield_large_w) AM_BASE_MEMBER(toobin_state, m_playfield)
113114   AM_RANGE(0xc08000, 0xc097ff) AM_MIRROR(0x046000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(toobin_state, m_alpha)
114   AM_RANGE(0xc09800, 0xc09fff) AM_MIRROR(0x046000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
115   AM_RANGE(0xc09800, 0xc09fff) AM_MIRROR(0x046000) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
115116   AM_RANGE(0xc10000, 0xc107ff) AM_MIRROR(0x047800) AM_RAM_WRITE(toobin_paletteram_w) AM_BASE_GENERIC(paletteram)
116117   AM_RANGE(0xff6000, 0xff6001) AM_READNOP      /* who knows? read at controls time */
117118   AM_RANGE(0xff8000, 0xff8001) AM_MIRROR(0x4500fe) AM_WRITE(watchdog_reset16_w)
118119   AM_RANGE(0xff8100, 0xff8101) AM_MIRROR(0x4500fe) AM_WRITE(atarigen_sound_w)
119120   AM_RANGE(0xff8300, 0xff8301) AM_MIRROR(0x45003e) AM_WRITE(toobin_intensity_w)
120121   AM_RANGE(0xff8340, 0xff8341) AM_MIRROR(0x45003e) AM_WRITE(interrupt_scan_w) AM_BASE_MEMBER(toobin_state, m_interrupt_scan)
121   AM_RANGE(0xff8380, 0xff8381) AM_MIRROR(0x45003e) AM_WRITE(toobin_slip_w) AM_BASE(&atarimo_0_slipram)
122   AM_RANGE(0xff8380, 0xff8381) AM_MIRROR(0x45003e) AM_READWRITE(atarimo_0_slipram_r, toobin_slip_w)
122123   AM_RANGE(0xff83c0, 0xff83c1) AM_MIRROR(0x45003e) AM_WRITE(atarigen_scanline_int_ack_w)
123124   AM_RANGE(0xff8400, 0xff8401) AM_MIRROR(0x4500fe) AM_WRITE(atarigen_sound_reset_w)
124125   AM_RANGE(0xff8500, 0xff8501) AM_MIRROR(0x4500fe) AM_WRITE(atarigen_eeprom_enable_w)
src/mame/drivers/m90.c
r11160r11161
109109ADDRESS_MAP_END
110110
111111static ADDRESS_MAP_START( m90_main_cpu_io_map, AS_IO, 16 )
112   AM_RANGE(0x00, 0x01) AM_WRITE(m72_sound_command_w)
112   AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_sound_command_w)
113113   AM_RANGE(0x00, 0x01) AM_READ_PORT("P1_P2")
114114   AM_RANGE(0x02, 0x03) AM_WRITE(m90_coincounter_w)
115115   AM_RANGE(0x02, 0x03) AM_READ_PORT("SYSTEM")
r11160r11161
120120ADDRESS_MAP_END
121121
122122static ADDRESS_MAP_START( dynablsb_cpu_io_map, AS_IO, 16 )
123   AM_RANGE(0x00, 0x01) AM_WRITE(m72_sound_command_w)
123   AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_sound_command_w)
124124   AM_RANGE(0x00, 0x01) AM_READ_PORT("P1_P2")
125125   AM_RANGE(0x02, 0x03) AM_WRITE(m90_coincounter_w)
126126   AM_RANGE(0x02, 0x03) AM_READ_PORT("SYSTEM")
r11160r11161
142142   ADDRESS_MAP_GLOBAL_MASK(0xff)
143143   AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
144144   AM_RANGE(0x80, 0x80) AM_READ(soundlatch_r)
145   AM_RANGE(0x80, 0x81) AM_WRITE(rtype2_sample_addr_w)
146   AM_RANGE(0x82, 0x82) AM_DEVWRITE("dac", m72_sample_w)
147   AM_RANGE(0x83, 0x83) AM_WRITE(m72_sound_irq_ack_w)
148   AM_RANGE(0x84, 0x84) AM_READ(m72_sample_r)
145   AM_RANGE(0x80, 0x81) AM_DEVWRITE("m72", rtype2_sample_addr_w)
146   AM_RANGE(0x82, 0x82) AM_DEVWRITE("m72", m72_sample_w)
147   AM_RANGE(0x83, 0x83) AM_DEVWRITE("m72", m72_sound_irq_ack_w)
148   AM_RANGE(0x84, 0x84) AM_DEVREAD("m72", m72_sample_r)
149149ADDRESS_MAP_END
150150
151151static ADDRESS_MAP_START( bbmanw_sound_io_map, AS_IO, 8 )
152152   ADDRESS_MAP_GLOBAL_MASK(0xff)
153153   AM_RANGE(0x40, 0x41) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
154   AM_RANGE(0x42, 0x42) AM_READWRITE(soundlatch_r, m72_sound_irq_ack_w)
154   AM_RANGE(0x42, 0x42) AM_READ(soundlatch_r) AM_DEVWRITE("m72", m72_sound_irq_ack_w)
155155//  AM_RANGE(0x40, 0x41) AM_WRITE(rtype2_sample_addr_w)
156//  AM_RANGE(0x41, 0x41) AM_READ(m72_sample_r)
157//  AM_RANGE(0x42, 0x42) AM_DEVWRITE("dac", m72_sample_w)
156//  AM_RANGE(0x41, 0x41) AM_DEVREAD("m72", m72_sample_r)
157//  AM_RANGE(0x42, 0x42) AM_DEVWRITE("m72", m72_sample_w)
158158ADDRESS_MAP_END
159159
160160/*****************************************************************************/
r11160r11161
709709   MCFG_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1? (Vigilante) */
710710                        /* IRQs are generated by main Z80 and YM2151 */
711711
712   MCFG_SOUND_START(m72)
713   MCFG_SOUND_RESET(m72)
714
715712   /* video hardware */
716713   MCFG_SCREEN_ADD("screen", RASTER)
717714   MCFG_SCREEN_REFRESH_RATE(60)
r11160r11161
729726   /* sound hardware */
730727   MCFG_SPEAKER_STANDARD_MONO("mono")
731728
729   MCFG_SOUND_ADD("m72", M72, 0)
730
732731   MCFG_SOUND_ADD("ymsnd", YM2151, XTAL_3_579545MHz) /* verified on pcb */
733732   MCFG_SOUND_CONFIG(ym2151_config)
734733   MCFG_SOUND_ROUTE(0, "mono", 0.15)
src/mame/drivers/cyberbal.c
r11160r11161
2626#include "sound/dac.h"
2727#include "rendlay.h"
2828#include "audio/atarijsa.h"
29#include "video/atarimo.h"
2930#include "includes/cyberbal.h"
3031
3132
r11160r11161
162163   AM_RANGE(0xfec000, 0xfecfff) AM_RAM_WRITE(cyberbal_paletteram_0_w) AM_SHARE("share2") AM_BASE_MEMBER(cyberbal_state, m_paletteram_0)
163164   AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(atarigen_playfield2_w)   AM_SHARE("share3") AM_BASE_MEMBER(cyberbal_state, m_playfield2)
164165   AM_RANGE(0xff2000, 0xff2fff) AM_RAM_WRITE(atarigen_alpha2_w)       AM_SHARE("share4") AM_BASE_MEMBER(cyberbal_state, m_alpha2)
165   AM_RANGE(0xff3000, 0xff37ff) AM_RAM_WRITE(atarimo_1_spriteram_w)   AM_SHARE("share5") AM_BASE(&atarimo_1_spriteram)
166   AM_RANGE(0xff3000, 0xff37ff) AM_READWRITE(atarimo_1_spriteram_r, atarimo_1_spriteram_w)
166167   AM_RANGE(0xff3800, 0xff3fff) AM_RAM                                           AM_SHARE("share6")
167168   AM_RANGE(0xff4000, 0xff5fff) AM_RAM_WRITE(atarigen_playfield_w)    AM_SHARE("share7") AM_BASE_MEMBER(cyberbal_state, m_playfield)
168169   AM_RANGE(0xff6000, 0xff6fff) AM_RAM_WRITE(atarigen_alpha_w)        AM_SHARE("share8") AM_BASE_MEMBER(cyberbal_state, m_alpha)
169   AM_RANGE(0xff7000, 0xff77ff) AM_RAM_WRITE(atarimo_0_spriteram_w)   AM_SHARE("share9") AM_BASE(&atarimo_0_spriteram)
170   AM_RANGE(0xff7000, 0xff77ff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
170171   AM_RANGE(0xff7800, 0xff9fff) AM_RAM                                           AM_SHARE("share10")
171172   AM_RANGE(0xffa000, 0xffbfff) AM_READONLY AM_WRITENOP               AM_SHARE("share11")
172173   AM_RANGE(0xffc000, 0xffffff) AM_RAM                                           AM_SHARE("share12")
r11160r11161
189190   AM_RANGE(0xfec000, 0xfecfff) AM_RAM_WRITE(cyberbal_paletteram_0_w) AM_SHARE("share2")
190191   AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(atarigen_playfield2_w)   AM_SHARE("share3")
191192   AM_RANGE(0xff2000, 0xff2fff) AM_RAM_WRITE(atarigen_alpha2_w)       AM_SHARE("share4")
192   AM_RANGE(0xff3000, 0xff37ff) AM_RAM_WRITE(atarimo_1_spriteram_w)   AM_SHARE("share5")
193   AM_RANGE(0xff3000, 0xff37ff) AM_READWRITE(atarimo_1_spriteram_r, atarimo_1_spriteram_w)
193194   AM_RANGE(0xff3800, 0xff3fff) AM_RAM                                           AM_SHARE("share6")
194195   AM_RANGE(0xff4000, 0xff5fff) AM_RAM_WRITE(atarigen_playfield_w)    AM_SHARE("share7")
195196   AM_RANGE(0xff6000, 0xff6fff) AM_RAM_WRITE(atarigen_alpha_w)        AM_SHARE("share8")
196   AM_RANGE(0xff7000, 0xff77ff) AM_RAM_WRITE(atarimo_0_spriteram_w)   AM_SHARE("share9")
197   AM_RANGE(0xff7000, 0xff77ff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
197198   AM_RANGE(0xff7800, 0xff9fff) AM_RAM                                           AM_SHARE("share10")
198199   AM_RANGE(0xffa000, 0xffbfff) AM_RAM                                           AM_SHARE("share11")
199200   AM_RANGE(0xffc000, 0xffffff) AM_READONLY AM_WRITENOP               AM_SHARE("share12")
r11160r11161
263264   AM_RANGE(0xfe0000, 0xfe0003) AM_READ(sound_state_r)
264265   AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(cyberbal_state, m_playfield)
265266   AM_RANGE(0xff2000, 0xff2fff) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(cyberbal_state, m_alpha)
266   AM_RANGE(0xff3000, 0xff37ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
267   AM_RANGE(0xff3000, 0xff37ff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
267268   AM_RANGE(0xff3800, 0xffffff) AM_RAM
268269ADDRESS_MAP_END
269270
src/mame/drivers/badlands.c
r11160r11161
165165#include "cpu/z80/z80.h"
166166#include "cpu/m68000/m68000.h"
167167#include "cpu/m6502/m6502.h"
168#include "sound/2151intf.h"
169#include "video/atarimo.h"
168170#include "includes/badlands.h"
169#include "sound/2151intf.h"
170171
171172
172173
r11160r11161
398399   AM_RANGE(0xfee000, 0xfeffff) AM_WRITE(atarigen_eeprom_enable_w)
399400   AM_RANGE(0xffc000, 0xffc3ff) AM_RAM_WRITE(atarigen_expanded_666_paletteram_w) AM_BASE_GENERIC(paletteram)
400401   AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(badlands_state, m_playfield)
401   AM_RANGE(0xfff000, 0xfff1ff) AM_RAM_WRITE(atarimo_0_spriteram_expanded_w) AM_BASE(&atarimo_0_spriteram)
402   AM_RANGE(0xfff000, 0xfff1ff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_expanded_w)
402403   AM_RANGE(0xfff200, 0xffffff) AM_RAM
403404ADDRESS_MAP_END
404405
r11160r11161
660661   AM_RANGE(0xfee000, 0xfeffff) AM_WRITE(atarigen_eeprom_enable_w)
661662   AM_RANGE(0xffc000, 0xffc3ff) AM_RAM_WRITE(atarigen_expanded_666_paletteram_w) AM_BASE_GENERIC(paletteram)
662663   AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(badlands_state, m_playfield)
663   AM_RANGE(0xfff000, 0xfff1ff) AM_RAM_WRITE(atarimo_0_spriteram_expanded_w) AM_BASE(&atarimo_0_spriteram)
664   AM_RANGE(0xfff000, 0xfff1ff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_expanded_w)
664665   AM_RANGE(0xfff200, 0xffffff) AM_RAM
665666ADDRESS_MAP_END
666667
src/mame/drivers/offtwall.c
r11160r11161
2020#include "emu.h"
2121#include "cpu/m68000/m68000.h"
2222#include "audio/atarijsa.h"
23#include "video/atarimo.h"
2324#include "includes/offtwall.h"
2425
2526
r11160r11161
295296   AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(offtwall_atarivc_r, offtwall_atarivc_w) AM_BASE_MEMBER(offtwall_state, m_atarivc_data)
296297   AM_RANGE(0x3f4000, 0x3f5eff) AM_RAM_WRITE(atarigen_playfield_latched_msb_w) AM_BASE_MEMBER(offtwall_state, m_playfield)
297298   AM_RANGE(0x3f5f00, 0x3f5f7f) AM_RAM AM_BASE_MEMBER(offtwall_state, m_atarivc_eof_data)
298   AM_RANGE(0x3f5f80, 0x3f5fff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
299   AM_RANGE(0x3f5f80, 0x3f5fff) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
299300   AM_RANGE(0x3f6000, 0x3f7fff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(offtwall_state, m_playfield_upper)
300301   AM_RANGE(0x3f8000, 0x3fcfff) AM_RAM
301   AM_RANGE(0x3fd000, 0x3fd7ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
302   AM_RANGE(0x3fd000, 0x3fd7ff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
302303   AM_RANGE(0x3fd800, 0x3fffff) AM_RAM
303304ADDRESS_MAP_END
304305
src/mame/drivers/fuukifg2.c
r11160r11161
7979static ADDRESS_MAP_START( fuuki16_map, AS_PROGRAM, 16 )
8080   AM_RANGE(0x000000, 0x0fffff) AM_ROM                                                      // ROM
8181   AM_RANGE(0x400000, 0x40ffff) AM_RAM                                                      // RAM
82   AM_RANGE(0x500000, 0x501fff) AM_RAM_WRITE(fuuki16_vram_0_w) AM_BASE_MEMBER(fuuki16_state, m_vram_0)               // Layers
83   AM_RANGE(0x502000, 0x503fff) AM_RAM_WRITE(fuuki16_vram_1_w) AM_BASE_MEMBER(fuuki16_state, m_vram_1)               //
84   AM_RANGE(0x504000, 0x505fff) AM_RAM_WRITE(fuuki16_vram_2_w) AM_BASE_MEMBER(fuuki16_state, m_vram_2)               //
85   AM_RANGE(0x506000, 0x507fff) AM_RAM_WRITE(fuuki16_vram_3_w) AM_BASE_MEMBER(fuuki16_state, m_vram_3)               //
82   AM_RANGE(0x500000, 0x501fff) AM_RAM_WRITE(fuuki16_vram_0_w) AM_BASE_MEMBER(fuuki16_state, m_vram[0])               // Layers
83   AM_RANGE(0x502000, 0x503fff) AM_RAM_WRITE(fuuki16_vram_1_w) AM_BASE_MEMBER(fuuki16_state, m_vram[1])               //
84   AM_RANGE(0x504000, 0x505fff) AM_RAM_WRITE(fuuki16_vram_2_w) AM_BASE_MEMBER(fuuki16_state, m_vram[2])               //
85   AM_RANGE(0x506000, 0x507fff) AM_RAM_WRITE(fuuki16_vram_3_w) AM_BASE_MEMBER(fuuki16_state, m_vram[3])               //
8686   AM_RANGE(0x600000, 0x601fff) AM_MIRROR(0x008000) AM_RAM AM_BASE_SIZE_MEMBER(fuuki16_state, m_spriteram, m_spriteram_size)   // Sprites, mirrored?
8787   AM_RANGE(0x700000, 0x703fff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)   // Palette
8888   AM_RANGE(0x800000, 0x800001) AM_READ_PORT("SYSTEM")
src/mame/drivers/photoply.c
r11160r11161
247247   cputag_set_input_line(device->machine(), "maincpu", 0, state ? HOLD_LINE : CLEAR_LINE);
248248}
249249
250static READ8_DEVICE_HANDLER( get_slave_ack )
251{
252   photoply_state *state = device->machine().driver_data<photoply_state>();
253   if (offset==2) { // IRQ = 2
254      return pic8259_acknowledge(state->m_pic8259_2);
255   }
256   return 0x00;
257}
258
250259static const struct pic8259_interface pic8259_1_config =
251260{
252   DEVCB_LINE(pic8259_1_set_int_line)
261   DEVCB_LINE(pic8259_1_set_int_line),
262   DEVCB_LINE_VCC,
263   DEVCB_HANDLER(get_slave_ack)
253264};
254265
255266static const struct pic8259_interface pic8259_2_config =
256267{
257   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w)
268   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w),
269   DEVCB_LINE_GND,
270   DEVCB_NULL
258271};
259272
260273static IRQ_CALLBACK(irq_callback)
261274{
262275   photoply_state *state = device->machine().driver_data<photoply_state>();
263   int r = 0;
264   r = pic8259_acknowledge(state->m_pic8259_2);
265   if (r==0)
266   {
267      r = pic8259_acknowledge(state->m_pic8259_1);
268   }
269   return r;
276   return pic8259_acknowledge(state->m_pic8259_1);
270277}
271278
272279static WRITE_LINE_DEVICE_HANDLER( at_pit8254_out0_changed )
src/mame/drivers/eprom.c
r11160r11161
2626#include "emu.h"
2727#include "cpu/m68000/m68000.h"
2828#include "audio/atarijsa.h"
29#include "video/atarimo.h"
2930#include "includes/eprom.h"
3031
3132
r11160r11161
176177   AM_RANGE(0x360030, 0x360031) AM_WRITE(atarigen_sound_w)
177178   AM_RANGE(0x3e0000, 0x3e0fff) AM_RAM AM_BASE_GENERIC(paletteram)
178179   AM_RANGE(0x3f0000, 0x3f1fff) AM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(eprom_state, m_playfield)
179   AM_RANGE(0x3f2000, 0x3f3fff) AM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
180   AM_RANGE(0x3f2000, 0x3f3fff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
180181   AM_RANGE(0x3f4000, 0x3f4f7f) AM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(eprom_state, m_alpha)
181   AM_RANGE(0x3f4f80, 0x3f4fff) AM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
182   AM_RANGE(0x3f4f80, 0x3f4fff) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
182183   AM_RANGE(0x3f8000, 0x3f9fff) AM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(eprom_state, m_playfield_upper)
183184   AM_RANGE(0x3f0000, 0x3f9fff) AM_RAM
184185ADDRESS_MAP_END
r11160r11161
202203   AM_RANGE(0x3e0000, 0x3e0fff) AM_RAM AM_BASE_GENERIC(paletteram)
203204   AM_RANGE(0xff0000, 0xff1fff) AM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(eprom_state, m_playfield_upper)
204205   AM_RANGE(0xff8000, 0xff9fff) AM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(eprom_state, m_playfield)
205   AM_RANGE(0xffa000, 0xffbfff) AM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
206   AM_RANGE(0xffa000, 0xffbfff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
206207   AM_RANGE(0xffc000, 0xffcf7f) AM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(eprom_state, m_alpha)
207   AM_RANGE(0xffcf80, 0xffcfff) AM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
208   AM_RANGE(0xffcf80, 0xffcfff) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
208209   AM_RANGE(0xff0000, 0xff1fff) AM_RAM
209210   AM_RANGE(0xff8000, 0xffffff) AM_RAM
210211ADDRESS_MAP_END
src/mame/drivers/famibox.c
r0r11161
1/***************************************************************************
2
3  famibox.c
4  Preliminary driver file to handle emulation of the
5  Nintendo FamicomBox
6
7In 1986, Nintendo Co., Ltd. began distrubuting the FamicomBox (SSS-CDS) which
8allowed gamers to test out and play up to 15 different Famicom games which
9could be installed in the unit itself.  Like it's sequel, the Super Famicom Box,
10it was found in hotels often set up to accept 100 yen coins giving you an
11adjusted amount of gametime (10 or 20 minutes - DIP selectable).  Sharp also
12produced a version of the FamicomBox called FamicomStation which was more
13of a consumer (non-coin accept) unit.  Besides that, the equipment and
14capabilities between the two are thought to be virtually idential - save the
15case style and cartridge/case color:  (FamicomBox = Black, FamicomStation = Gray).
16
17
18
19Specific Hardware information
20-----------------------------
21The unit had 3 controllers - 2 standard NES controllers and a NES Zapper light
22gun.  The cartridges are shaped and appear to be idential to NES 72-pin
23cartridges.  Unfortunately, it was made to play only the games specifically
24released for it.  Why?
25
26- The FamicomBox will not run mmc3 games and many other advanced mappers
27- There a special lockout chip, but the lockout chip connects to different pins on
28  a FamicomBox cartridge’s connector than a regular cart
29- The lockout chips in the system and the games have to “talk” before the system will
30  load any games into its menu.
31
32Here’s a list of some of the games known to have come with the FamicomBox:
331943; Baseball; Bomber Man; Devil World; Donkey Kong; Donkey Kong Jr.; Duck Hunt;
34Excite Bike; F1 Race; Fighting Golf; Golf; Gradius; Hogan’s Alley; Ice Climbers;
35Ice Hockey; Knight Rider; Makaimura: Ghosts ‘n Goblins; McKids; Mah-Jong; Mario Bros.;
36Mike Tyson’s Punch-Out!!; Ninja Ryukenden; Operation Wolf (?); Punch-Out!!; Rock Man;
37Rygar; Senjou no Ookami; Soccer League Winner’s Cup; Super Chinese 2; Super Mario Bros;
38Tag Team Pro Wrestling; Takahashi Meijin no Boukenjima; Tennis; Twin Bee;
39Volleyball; Wild Gunman; Wrecking Crew.
40
41Here’s a list of some of the games known to have come with the FamicomStation:
421943; Baseball; Donkey Kong; Duck Hunt; F1 Race; Golf; Kame no Ongaeshi:
43Urashima Densetsu; Mah-Jong; Mario Bros.; Night Raider; Senjou no Ookami;
44Soccer League Winner’s Cup; Super Chinese 2; Super Mario Bros; Tag Team Pro Wrestling;
45Takahashi Meijin no Boukenjima; Tennis; Wild Gunman; Wrecking Crew.
46
47***************************************************************************/
48
49#include "emu.h"
50#include "video/ppu2c0x.h"
51#include "cpu/m6502/m6502.h"
52#include "imagedev/cartslot.h"
53#include "sound/nes_apu.h"
54
55class famibox_state : public driver_device
56{
57public:
58   famibox_state(running_machine &machine, const driver_device_config_base &config)
59      : driver_device(machine, config) { }
60};
61
62
63static ADDRESS_MAP_START( famibox_map, AS_PROGRAM, 8 )
64   AM_RANGE(0x0000, 0x1fff) AM_RAM
65   AM_RANGE(0x2000, 0x3fff) AM_ROM
66   AM_RANGE(0x4000, 0x4fff) AM_RAM
67   AM_RANGE(0x5000, 0x5fff) AM_RAM
68   AM_RANGE(0x6000, 0x7fff) AM_RAM
69   AM_RANGE(0x8000, 0xffff) AM_ROM
70ADDRESS_MAP_END
71
72
73static INPUT_PORTS_START( famibox )
74INPUT_PORTS_END
75
76static MACHINE_RESET( famibox )
77{
78}
79
80//static DRIVER_INIT( famibox )
81//{
82//}
83
84static MACHINE_CONFIG_START( famibox, famibox_state )
85   /* basic machine hardware */
86   MCFG_CPU_ADD("maincpu", N2A03, N2A03_DEFAULTCLOCK)
87   MCFG_CPU_PROGRAM_MAP(famibox_map)
88
89   MCFG_MACHINE_RESET( famibox )
90   MCFG_PALETTE_LENGTH(4*16*8)
91   MCFG_SCREEN_ADD("screen", RASTER)
92   MCFG_SCREEN_REFRESH_RATE(60)
93   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
94   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
95   MCFG_SCREEN_SIZE(32*8, 262)
96   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 30*8-1)
97MACHINE_CONFIG_END
98
99
100/*-------------------------------------------------------------------
101/ FamicomBox
102/-------------------------------------------------------------------*/
103ROM_START(famibox)
104   ROM_REGION(0x10000, "maincpu", 0)
105   ROM_LOAD("sss_menu.prg", 0x8000, 0x8000, CRC(da1eb8d2) SHA1(943e3b0edfbf9bd3ee87dc5f298621b9ddc98db8))
106   ROM_LOAD("sss_menu.chr", 0x2000, 0x2000, CRC(a43d4435) SHA1(ee56b4d2110aff394bf2c8cd3414ca175ace01bd))
107ROM_END
108
109GAME( 1986,  famibox,      0,  famibox,  famibox,  0, ROT0, "Nintendo", "FamicomBox", GAME_NOT_WORKING | GAME_NO_SOUND)
110
src/mame/drivers/quakeat.c
r11160r11161
117117   cputag_set_input_line(device->machine(), "maincpu", 0, state ? HOLD_LINE : CLEAR_LINE);
118118}
119119
120static READ8_DEVICE_HANDLER( get_slave_ack )
121{
122   quakeat_state *state = device->machine().driver_data<quakeat_state>();
123   if (offset==2) { // IRQ = 2
124      return pic8259_acknowledge(state->m_pic8259_2);
125   }
126   return 0x00;
127}
128
120129static const struct pic8259_interface quakeat_pic8259_1_config =
121130{
122   DEVCB_LINE(quakeat_pic8259_1_set_int_line)
131   DEVCB_LINE(quakeat_pic8259_1_set_int_line),
132   DEVCB_LINE_VCC,
133   DEVCB_HANDLER(get_slave_ack)
123134};
124135
125136static const struct pic8259_interface quakeat_pic8259_2_config =
126137{
127   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w)
138   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w),
139   DEVCB_LINE_GND,
140   DEVCB_NULL
128141};
129142
130143/*************************************************************/
r11160r11161
137150static IRQ_CALLBACK(irq_callback)
138151{
139152   quakeat_state *state = device->machine().driver_data<quakeat_state>();
140   int r = 0;
141   r = pic8259_acknowledge( state->m_pic8259_2);
142   if (r==0)
143   {
144      r = pic8259_acknowledge( state->m_pic8259_1);
145   }
146   return r;
153   return pic8259_acknowledge( state->m_pic8259_1);
147154}
148155
149156static MACHINE_START(quakeat)
src/mame/drivers/midyunit.c
r11160r11161
152152
153153static CUSTOM_INPUT( narc_talkback_strobe_r )
154154{
155   return (williams_narc_talkback_r() >> 8) & 1;
155   return (williams_narc_talkback_r(field->port->machine()) >> 8) & 1;
156156}
157157
158158
159159static CUSTOM_INPUT( narc_talkback_data_r )
160160{
161   return williams_narc_talkback_r() & 0xff;
161   return williams_narc_talkback_r(field->port->machine()) & 0xff;
162162}
163163
164164
165165static CUSTOM_INPUT( adpcm_irq_state_r )
166166{
167   return williams_adpcm_sound_irq_r() & 1;
167   return williams_adpcm_sound_irq_r(field->port->machine()) & 1;
168168}
169169
170170
src/mame/drivers/galpani2.c
r11160r11161
7272
7373static MACHINE_RESET( galpani2 )
7474{
75   galpani2_state *state = machine.driver_data<galpani2_state>();
7576   MACHINE_RESET_CALL(kaneko16);
7677
77   kaneko16_sprite_type = 1;
78   state->m_sprite_type = 1;
7879
79   kaneko16_sprite_xoffs = 0x10000 - 0x16c0 + 0xc00;
80   kaneko16_sprite_yoffs = 0x000;
80   state->m_sprite_xoffs = 0x10000 - 0x16c0 + 0xc00;
81   state->m_sprite_yoffs = 0x000;
8182   machine.scheduler().boost_interleave(attotime::zero, attotime::from_usec(50)); //initial mcu xchk
8283}
8384
r11160r11161
295296   AM_RANGE(0x110000, 0x11000f) AM_RAM                                    // ? corrupted? stack dumper on POST failure, pc+sr on gp2se
296297   AM_RANGE(0x300000, 0x301fff) AM_RAM                                    // ?
297298   AM_RANGE(0x302000, 0x303fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)   // Sprites
298   AM_RANGE(0x304000, 0x30401f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs   )   // Sprites Regs
299   AM_RANGE(0x304000, 0x30401f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE_MEMBER(galpani2_state, m_sprites_regs)   // Sprites Regs
299300   AM_RANGE(0x308000, 0x308001) AM_WRITENOP                              // ? 0 at startup
300301   AM_RANGE(0x30c000, 0x30c001) AM_WRITENOP                              // ? hblank effect ?
301   AM_RANGE(0x310000, 0x3101ff) AM_RAM_WRITE(galpani2_palette_0_w) AM_BASE_MEMBER(galpani2_state, m_palette_0)   // ?
302   AM_RANGE(0x310000, 0x3101ff) AM_RAM_WRITE(galpani2_palette_0_w) AM_BASE_MEMBER(galpani2_state, m_palette[0])   // ?
302303   AM_RANGE(0x314000, 0x314001) AM_WRITENOP                              // ? flip backgrounds ?
303304   AM_RANGE(0x318000, 0x318001) AM_DEVREADWRITE("eeprom", galpani2_eeprom_r, galpani2_eeprom_w)   // EEPROM
304305   AM_RANGE(0x380000, 0x387fff) AM_RAM                                    // Palette?
305306   AM_RANGE(0x388000, 0x38ffff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram   )   // Palette
306307   AM_RANGE(0x390000, 0x3901ff) AM_WRITENOP                              // ? at startup of service mode
307308
308   AM_RANGE(0x400000, 0x43ffff) AM_RAM_WRITE(galpani2_bg8_0_w) AM_BASE_MEMBER(galpani2_state, m_bg8_0)   // Background 0
309   AM_RANGE(0x440000, 0x440001) AM_RAM AM_BASE_MEMBER(galpani2_state, m_bg8_0_scrollx)         // Background 0 Scroll X
310   AM_RANGE(0x480000, 0x480001) AM_RAM AM_BASE_MEMBER(galpani2_state, m_bg8_0_scrolly)         // Background 0 Scroll Y
309   AM_RANGE(0x400000, 0x43ffff) AM_RAM_WRITE(galpani2_bg8_0_w) AM_BASE_MEMBER(galpani2_state, m_bg8[0])   // Background 0
310   AM_RANGE(0x440000, 0x440001) AM_RAM AM_BASE_MEMBER(galpani2_state, m_bg8_scrollx[0])         // Background 0 Scroll X
311   AM_RANGE(0x480000, 0x480001) AM_RAM AM_BASE_MEMBER(galpani2_state, m_bg8_scrolly[0])         // Background 0 Scroll Y
311312   AM_RANGE(0x4c0000, 0x4c0001) AM_WRITENOP                              // ? 0 at startup only
312   AM_RANGE(0x500000, 0x53ffff) AM_RAM_WRITE(galpani2_bg8_1_w) AM_BASE_MEMBER(galpani2_state, m_bg8_1)   // Background 1
313   AM_RANGE(0x540000, 0x540001) AM_RAM AM_BASE_MEMBER(galpani2_state, m_bg8_1_scrollx)         // Background 1 Scroll X
313   AM_RANGE(0x500000, 0x53ffff) AM_RAM_WRITE(galpani2_bg8_1_w) AM_BASE_MEMBER(galpani2_state, m_bg8[1])   // Background 1
314   AM_RANGE(0x540000, 0x540001) AM_RAM AM_BASE_MEMBER(galpani2_state, m_bg8_scrollx[1])         // Background 1 Scroll X
314315
315316   AM_RANGE(0x540572, 0x540573) AM_READNOP                                 // ? galpani2 at F0A4
316317   AM_RANGE(0x54057a, 0x54057b) AM_READNOP                                 // ? galpani2 at F148
r11160r11161
322323   AM_RANGE(0x5405c2, 0x5405c3) AM_READNOP                                 // ? galpani2 at F0A4 and F148
323324   AM_RANGE(0x5405ca, 0x5405cb) AM_READNOP                                 // ? galpani2 at F148
324325
325   AM_RANGE(0x580000, 0x580001) AM_RAM AM_BASE_MEMBER(galpani2_state, m_bg8_1_scrolly)         // Background 1 Scroll Y
326   AM_RANGE(0x580000, 0x580001) AM_RAM AM_BASE_MEMBER(galpani2_state, m_bg8_scrolly[1])         // Background 1 Scroll Y
326327   AM_RANGE(0x5c0000, 0x5c0001) AM_WRITENOP                              // ? 0 at startup only
327328   AM_RANGE(0x600000, 0x600001) AM_WRITENOP                              // Watchdog
328329   AM_RANGE(0x640000, 0x640001) AM_WRITE8(galpani2_mcu_init_w, 0x00ff         )   // ? 0 before resetting and at startup, Reset mcu ?
src/mame/drivers/quizo.c
r11160r11161
3535      : driver_device(machine, config) { }
3636
3737   UINT8 *m_videoram;
38   UINT8 m_port60;
39   UINT8 m_port70;
3840};
3941
4042
r11160r11161
4244#define XTAL2   21477270
4345
4446
45static UINT8 port60;
46static UINT8 port70;
47
4847static const UINT8 rombankLookup[]={ 2, 3, 4, 4, 4, 4, 4, 5, 0, 1};
4948
5049static PALETTE_INIT(quizo)
r11160r11161
110109{
111110   quizo_state *state = space->machine().driver_data<quizo_state>();
112111   UINT8 *videoram = state->m_videoram;
113   int bank=(port70&8)?1:0;
112   int bank=(state->m_port70&8)?1:0;
114113   videoram[offset+bank*0x4000]=data;
115114}
116115
117116static WRITE8_HANDLER(port70_w)
118117{
119   port70=data;
118   quizo_state *state = space->machine().driver_data<quizo_state>();
119   state->m_port70=data;
120120}
121121
122122static WRITE8_HANDLER(port60_w)
123123{
124   quizo_state *state = space->machine().driver_data<quizo_state>();
124125   if(data>9)
125126   {
126127      logerror("ROMBANK %x @ %x\n", data, cpu_get_pc(&space->device()));
127128      data=0;
128129   }
129   port60=data;
130   state->m_port60=data;
130131   memory_set_bankptr(space->machine(),  "bank1", &space->machine().region("user1")->base()[rombankLookup[data]*0x4000] );
131132}
132133
src/mame/drivers/suprnova.c
r11160r11161
157157
158158#define BIOS_SKIP 1 // Skip Bios as it takes too long and doesn't complete atm.
159159
160UINT32 *skns_tilemapA_ram, *skns_tilemapB_ram, *skns_v3slc_ram;
161UINT32 *skns_palette_ram;
162UINT32 *skns_pal_regs, *skns_v3_regs, *skns_spc_regs;
163160
164static UINT32 *skns_v3t_ram, *skns_main_ram, *skns_cache_ram;
165
166/* hit.c */
167
168static struct {
169   UINT16 x1p, y1p, z1p, x1s, y1s, z1s;
170   UINT16 x2p, y2p, z2p, x2s, y2s, z2s;
171   UINT16 org;
172
173   UINT16 x1_p1, x1_p2, y1_p1, y1_p2, z1_p1, z1_p2;
174   UINT16 x2_p1, x2_p2, y2_p1, y2_p2, z2_p1, z2_p2;
175   UINT16 x1tox2, y1toy2, z1toz2;
176   INT16 x_in, y_in, z_in;
177   UINT16 flag;
178
179   UINT8 disconnect;
180} hit;
181
182161static void hit_calc_orig(UINT16 p, UINT16 s, UINT16 org, UINT16 *l, UINT16 *r)
183162{
184163   switch(org & 3) {
r11160r11161
217196   *x_in = x1r-x2l;
218197}
219198
220static void hit_recalc(void)
199static void hit_recalc(running_machine &machine)
221200{
201   skns_state *state = machine.driver_data<skns_state>();
202   hit_t &hit = state->m_hit;
203
222204   hit_calc_axis(hit.x1p, hit.x1s, hit.x2p, hit.x2s, hit.org,
223205      &hit.x1_p1, &hit.x1_p2, &hit.x2_p1, &hit.x2_p2,
224206      &hit.x_in, &hit.x1tox2);
r11160r11161
252234static WRITE32_HANDLER ( skns_hit_w )
253235//void hit_w(UINT32 adr, UINT32 data, int type)
254236{
237   skns_state *state = space->machine().driver_data<skns_state>();
238   hit_t &hit = state->m_hit;
255239   int adr = offset * 4;
256240
257241   switch(adr) {
r11160r11161
310294//      log_write("HIT", adr, data, type);
311295   break;
312296   }
313   hit_recalc();
297   hit_recalc(space->machine());
314298}
315299
316300static WRITE32_HANDLER ( skns_hit2_w )
317301{
302   skns_state *state = space->machine().driver_data<skns_state>();
303   hit_t &hit = state->m_hit;
318304//  log_event("HIT", "Set disconnect to %02x", data);
319305   hit.disconnect = data;
320306}
r11160r11161
323309static READ32_HANDLER( skns_hit_r )
324310//UINT32 hit_r(UINT32 adr, int type)
325311{
312   skns_state *state = space->machine().driver_data<skns_state>();
313   hit_t &hit = state->m_hit;
326314   int adr = offset *4;
327315
328316//  log_read("HIT", adr, type);
r11160r11161
591579INPUT_PORTS_END
592580
593581
594static UINT32 timer_0_temp[4];
595582
596583static WRITE32_HANDLER( skns_msm6242_w )
597584{
598   COMBINE_DATA(&timer_0_temp[offset]);
585   skns_state *state = space->machine().driver_data<skns_state>();
586   COMBINE_DATA(&state->m_timer_0_temp[offset]);
599587
600588   if(offset>=4)
601589   {
r11160r11161
709697
710698static WRITE32_HANDLER( skns_v3t_w )
711699{
700   skns_state *state = space->machine().driver_data<skns_state>();
712701   UINT8 *btiles = space->machine().region("gfx3")->base();
713702
714   COMBINE_DATA(&skns_v3t_ram[offset]);
703   COMBINE_DATA(&state->m_v3t_ram[offset]);
715704
716705   gfx_element_mark_dirty(space->machine().gfx[1], offset/0x40);
717706   gfx_element_mark_dirty(space->machine().gfx[3], offset/0x20);
718707
719   data = skns_v3t_ram[offset];
708   data = state->m_v3t_ram[offset];
720709// i think we need to swap around to decode .. endian issues?
721710   btiles[offset*4+0] = (data & 0xff000000) >> 24;
722711   btiles[offset*4+1] = (data & 0x00ff0000) >> 16;
r11160r11161
736725   AM_RANGE(0x01000000, 0x0100000f) AM_READWRITE(skns_msm6242_r, skns_msm6242_w)
737726   AM_RANGE(0x01800000, 0x01800003) AM_WRITE(skns_hit2_w)
738727   AM_RANGE(0x02000000, 0x02003fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* sprite ram */
739   AM_RANGE(0x02100000, 0x0210003f) AM_RAM AM_BASE(&skns_spc_regs) /* sprite registers */
740   AM_RANGE(0x02400000, 0x0240007f) AM_RAM_WRITE(skns_v3_regs_w) AM_BASE(&skns_v3_regs) /* tilemap registers */
741   AM_RANGE(0x02500000, 0x02503fff) AM_RAM_WRITE(skns_tilemapA_w) AM_BASE(&skns_tilemapA_ram) /* tilemap A */
742   AM_RANGE(0x02504000, 0x02507fff) AM_RAM_WRITE(skns_tilemapB_w) AM_BASE(&skns_tilemapB_ram) /* tilemap B */
743   AM_RANGE(0x02600000, 0x02607fff) AM_RAM AM_BASE(&skns_v3slc_ram) /* tilemap linescroll */
744   AM_RANGE(0x02a00000, 0x02a0001f) AM_RAM_WRITE(skns_pal_regs_w) AM_BASE(&skns_pal_regs)
745   AM_RANGE(0x02a40000, 0x02a5ffff) AM_RAM_WRITE(skns_palette_ram_w) AM_BASE(&skns_palette_ram)
728   AM_RANGE(0x02100000, 0x0210003f) AM_RAM AM_BASE_MEMBER(skns_state, m_spc_regs) /* sprite registers */
729   AM_RANGE(0x02400000, 0x0240007f) AM_RAM_WRITE(skns_v3_regs_w) AM_BASE_MEMBER(skns_state, m_v3_regs) /* tilemap registers */
730   AM_RANGE(0x02500000, 0x02503fff) AM_RAM_WRITE(skns_tilemapA_w) AM_BASE_MEMBER(skns_state, m_tilemapA_ram) /* tilemap A */
731   AM_RANGE(0x02504000, 0x02507fff) AM_RAM_WRITE(skns_tilemapB_w) AM_BASE_MEMBER(skns_state, m_tilemapB_ram) /* tilemap B */
732   AM_RANGE(0x02600000, 0x02607fff) AM_RAM AM_BASE_MEMBER(skns_state, m_v3slc_ram) /* tilemap linescroll */
733   AM_RANGE(0x02a00000, 0x02a0001f) AM_RAM_WRITE(skns_pal_regs_w) AM_BASE_MEMBER(skns_state, m_pal_regs)
734   AM_RANGE(0x02a40000, 0x02a5ffff) AM_RAM_WRITE(skns_palette_ram_w) AM_BASE_MEMBER(skns_state, m_palette_ram)
746735   AM_RANGE(0x02f00000, 0x02f000ff) AM_READWRITE(skns_hit_r, skns_hit_w)
747736   AM_RANGE(0x04000000, 0x041fffff) AM_ROMBANK("bank1") /* GAME ROM */
748   AM_RANGE(0x04800000, 0x0483ffff) AM_RAM_WRITE(skns_v3t_w) AM_BASE(&skns_v3t_ram) /* tilemap b ram based tiles */
749   AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE(&skns_main_ram)
750   AM_RANGE(0xc0000000, 0xc0000fff) AM_RAM AM_BASE(&skns_cache_ram) /* 'cache' RAM */
737   AM_RANGE(0x04800000, 0x0483ffff) AM_RAM_WRITE(skns_v3t_w) AM_BASE_MEMBER(skns_state, m_v3t_ram) /* tilemap b ram based tiles */
738   AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE_MEMBER(skns_state, m_main_ram)
739   AM_RANGE(0xc0000000, 0xc0000fff) AM_RAM AM_BASE_MEMBER(skns_state, m_cache_ram) /* 'cache' RAM */
751740ADDRESS_MAP_END
752741
753742/***** GFX DECODE *****/
r11160r11161
843832
844833static READ32_HANDLER( bios_skip_r )
845834{
835   skns_state *state = space->machine().driver_data<skns_state>();
846836#if BIOS_SKIP
847837   if ((cpu_get_pc(&space->device())==0x6f8) || (cpu_get_pc(&space->device())==0x6fa)) space->write_byte(0x06000029,1);
848838#endif
849   return skns_main_ram[0x00028/4];
839   return state->m_main_ram[0x00028/4];
850840}
851841
852842/***** IDLE SKIPPING *****/
853843
854844static READ32_HANDLER( gutsn_speedup_r )
855845{
846   skns_state *state = space->machine().driver_data<skns_state>();
856847/*
857848    0402206A: MOV.L   @($8C,PC),R5
858849    0402206C: MOV.L   @($8C,PC),R1
r11160r11161
863854*/
864855   if (cpu_get_pc(&space->device())==0x402206e)
865856   {
866      if(skns_main_ram[0x00078/4] == skns_main_ram[0x0c780/4])
857      if(state->m_main_ram[0x00078/4] == state->m_main_ram[0x0c780/4])
867858         device_spin_until_interrupt(&space->device());
868859   }
869   return skns_main_ram[0x0c780/4];
860   return state->m_main_ram[0x0c780/4];
870861}
871862
872863static READ32_HANDLER( cyvern_speedup_r )
873864{
865   skns_state *state = space->machine().driver_data<skns_state>();
874866   if (cpu_get_pc(&space->device())==0x402ebd2) device_spin_until_interrupt(&space->device());
875   return skns_main_ram[0x4d3c8/4];
867   return state->m_main_ram[0x4d3c8/4];
876868}
877869
878870static READ32_HANDLER( puzzloopj_speedup_r )
879871{
872   skns_state *state = space->machine().driver_data<skns_state>();
880873   if (cpu_get_pc(&space->device())==0x401dca0) device_spin_until_interrupt(&space->device());
881   return skns_main_ram[0x86714/4];
874   return state->m_main_ram[0x86714/4];
882875}
883876
884877static READ32_HANDLER( puzzloopa_speedup_r )
885878{
879   skns_state *state = space->machine().driver_data<skns_state>();
886880   if (cpu_get_pc(&space->device())==0x401d9d4) device_spin_until_interrupt(&space->device());
887   return skns_main_ram[0x85bcc/4];
881   return state->m_main_ram[0x85bcc/4];
888882}
889883
890884static READ32_HANDLER( puzzloopu_speedup_r )
891885{
886   skns_state *state = space->machine().driver_data<skns_state>();
892887   if (cpu_get_pc(&space->device())==0x401dab0) device_spin_until_interrupt(&space->device());
893   return skns_main_ram[0x85cec/4];
888   return state->m_main_ram[0x85cec/4];
894889}
895890
896891static READ32_HANDLER( puzzloop_speedup_r )
897892{
893   skns_state *state = space->machine().driver_data<skns_state>();
898894/*
899895    0401DA12: MOV.L   @($80,PC),R1
900896    0401DA14: MOV.L   @R1,R0 (R1=0x6081d38)
r11160r11161
903899    0401DA26: BRA     $0401DA12
904900*/
905901   if (cpu_get_pc(&space->device())==0x401da14) device_spin_until_interrupt(&space->device());
906   return skns_main_ram[0x81d38/4];
902   return state->m_main_ram[0x81d38/4];
907903}
908904
909905static READ32_HANDLER( senknow_speedup_r )
910906{
907   skns_state *state = space->machine().driver_data<skns_state>();
911908   if (cpu_get_pc(&space->device())==0x4017dce) device_spin_until_interrupt(&space->device());
912   return skns_main_ram[0x0000dc/4];
909   return state->m_main_ram[0x0000dc/4];
913910}
914911
915912static READ32_HANDLER( teljan_speedup_r )
916913{
914   skns_state *state = space->machine().driver_data<skns_state>();
917915   if (cpu_get_pc(&space->device())==0x401ba32) device_spin_until_interrupt(&space->device());
918   return skns_main_ram[0x002fb4/4];
916   return state->m_main_ram[0x002fb4/4];
919917}
920918
921919static READ32_HANDLER( jjparads_speedup_r )
922920{
921   skns_state *state = space->machine().driver_data<skns_state>();
923922   if (cpu_get_pc(&space->device())==0x4015e84) device_spin_until_interrupt(&space->device());
924   return skns_main_ram[0x000994/4];
923   return state->m_main_ram[0x000994/4];
925924}
926925
927926static READ32_HANDLER( jjparad2_speedup_r )
928927{
928   skns_state *state = space->machine().driver_data<skns_state>();
929929   if (cpu_get_pc(&space->device())==0x401620a) device_spin_until_interrupt(&space->device());
930   return skns_main_ram[0x000984/4];
930   return state->m_main_ram[0x000984/4];
931931}
932932
933933static READ32_HANDLER( ryouran_speedup_r )
934934{
935   skns_state *state = space->machine().driver_data<skns_state>();
935936   if (cpu_get_pc(&space->device())==0x40182ce) device_spin_until_interrupt(&space->device());
936   return skns_main_ram[0x000a14/4];
937   return state->m_main_ram[0x000a14/4];
937938}
938939
939940static READ32_HANDLER( galpans2_speedup_r )
940941{
942   skns_state *state = space->machine().driver_data<skns_state>();
941943   if (cpu_get_pc(&space->device())==0x4049ae2) device_spin_until_interrupt(&space->device());
942   return skns_main_ram[0x0fb6bc/4];
944   return state->m_main_ram[0x0fb6bc/4];
943945}
944946
945947static READ32_HANDLER( panicstr_speedup_r )
946948{
949   skns_state *state = space->machine().driver_data<skns_state>();
947950   if (cpu_get_pc(&space->device())==0x404e68a) device_spin_until_interrupt(&space->device());
948   return skns_main_ram[0x0f19e4/4];
951   return state->m_main_ram[0x0f19e4/4];
949952}
950953
951954static READ32_HANDLER( sengekis_speedup_r ) // 60006ee  600308e
952955{
956   skns_state *state = space->machine().driver_data<skns_state>();
953957   if (cpu_get_pc(&space->device())==0x60006ec) device_spin_until_interrupt(&space->device());
954   return skns_main_ram[0xb74bc/4];
958   return state->m_main_ram[0xb74bc/4];
955959}
956960
957961static READ32_HANDLER( sengekij_speedup_r ) // 60006ee  600308e
958962{
963   skns_state *state = space->machine().driver_data<skns_state>();
959964   if (cpu_get_pc(&space->device())==0x60006ec) device_spin_until_interrupt(&space->device());
960   return skns_main_ram[0xb7380/4];
965   return state->m_main_ram[0xb7380/4];
961966}
962967
963968static void init_skns(running_machine &machine)
src/mame/drivers/sigmab98.c
r11160r11161
105105
106106   UINT8 *m_spriteram;
107107   size_t m_spriteram_size;
108   UINT8 m_reg;
109   UINT8 m_rombank;
110   UINT8 m_reg2;
111   UINT8 m_rambank;
112   UINT8 m_c0;
113   UINT8 m_c4;
114   UINT8 m_c6;
115   UINT8 m_c8;
116   UINT8 m_vblank;
117   UINT8 m_out[3];
118   UINT8 *m_nvram;
108119};
109120
110121
r11160r11161
266277
267278***************************************************************************/
268279
269static UINT8 reg, rombank;
270static UINT8 reg2, rambank;
271280
272281/***************************************************************************
273282                        GeGeGe no Kitarou Youkai Slot
r11160r11161
276285// rombank
277286static WRITE8_HANDLER( regs_w )
278287{
288   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
279289   if (offset == 0)
280290   {
281      reg = data;
291      state->m_reg = data;
282292      return;
283293   }
284294
285   switch ( reg )
295   switch ( state->m_reg )
286296   {
287297      case 0x1f:
288         rombank = data;
298         state->m_rombank = data;
289299         if (data >= 0x18)
290300            logerror("%s: unknown rom bank = %02x\n", space->machine().describe_context(), data);
291301         else
r11160r11161
293303         break;
294304
295305      default:
296         logerror("%s: unknown reg written: %02x = %02x\n", space->machine().describe_context(), reg, data);
306         logerror("%s: unknown reg written: %02x = %02x\n", space->machine().describe_context(), state->m_reg, data);
297307   }
298308}
299309static READ8_HANDLER( regs_r )
300310{
311   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
301312   if (offset == 0)
302      return reg;
313      return state->m_reg;
303314
304   switch ( reg )
315   switch ( state->m_reg )
305316   {
306317      case 0x1f:
307         return rombank;
318         return state->m_rombank;
308319
309320      default:
310         logerror("%s: unknown reg read: %02x\n", space->machine().describe_context(), reg);
321         logerror("%s: unknown reg read: %02x\n", space->machine().describe_context(), state->m_reg);
311322         return 0x00;
312323   }
313324}
r11160r11161
315326// rambank
316327static WRITE8_HANDLER( regs2_w )
317328{
329   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
318330   if (offset == 0)
319331   {
320      reg2 = data;
332      state->m_reg2 = data;
321333      return;
322334   }
323335
324   switch ( reg2 )
336   switch ( state->m_reg2 )
325337   {
326338      case 0xb5:
327         rambank = data;
339         state->m_rambank = data;
328340         switch (data)
329341         {
330342            case 0x32:
r11160r11161
339351         break;
340352
341353      default:
342         logerror("%s: unknown reg2 written: %02x = %02x\n", space->machine().describe_context(), reg2, data);
354         logerror("%s: unknown reg2 written: %02x = %02x\n", space->machine().describe_context(), state->m_reg2, data);
343355   }
344356}
345357static READ8_HANDLER( regs2_r )
346358{
359   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
347360   if (offset == 0)
348      return reg2;
361      return state->m_reg2;
349362
350   switch ( reg2 )
363   switch ( state->m_reg2 )
351364   {
352365      case 0xb5:
353         return rambank;
366         return state->m_rambank;
354367
355368      default:
356         logerror("%s: unknown reg2 read: %02x\n", space->machine().describe_context(), reg2);
369         logerror("%s: unknown reg2 read: %02x\n", space->machine().describe_context(), state->m_reg2);
357370         return 0x00;
358371   }
359372}
r11160r11161
361374
362375// Outputs
363376
364static UINT8 c0,c4,c6,c8;
365static void show_outputs()
377static void show_outputs(sigmab98_state *state)
366378{
367379#ifdef MAME_DEBUG
368//  popmessage("0: %02X  4: %02X  6: %02X  8: %02X",c0,c4,c6,c8);
380//  popmessage("0: %02X  4: %02X  6: %02X  8: %02X",state->m_c0,state->m_c4,state->m_c6,state->m_c8);
369381#endif
370382}
371383
372384// Port c0
373385static WRITE8_DEVICE_HANDLER( eeprom_w )
374386{
387   sigmab98_state *state = device->machine().driver_data<sigmab98_state>();
375388   // latch the bit
376389   eeprom_write_bit(device, data & 0x40);
377390
378391   // reset line asserted: reset.
379//  if ((c0 ^ data) & 0x20)
392//  if ((state->m_c0 ^ data) & 0x20)
380393      eeprom_set_cs_line(device, (data & 0x20) ? CLEAR_LINE : ASSERT_LINE);
381394
382395   // clock line asserted: write latch or select next bit to read
383396   eeprom_set_clock_line(device, (data & 0x10) ? ASSERT_LINE : CLEAR_LINE);
384397
385   c0 = data;
386   show_outputs();
398   state->m_c0 = data;
399   show_outputs(state);
387400}
388401
389402// Port c4
390403// 10 led?
391404static WRITE8_HANDLER( c4_w )
392405{
406   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
393407   set_led_status(space->machine(), 0, (data & 0x10));
394408
395   c4 = data;
396   show_outputs();
409   state->m_c4 = data;
410   show_outputs(state);
397411}
398412
399413// Port c6
r11160r11161
404418// 20 blinks after coin up
405419static WRITE8_HANDLER( c6_w )
406420{
421   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
407422   coin_lockout_w(space->machine(), 0, (~data) & 0x02);
408423
409424   coin_counter_w(space->machine(), 0,   data  & 0x04);
r11160r11161
412427   set_led_status(space->machine(), 2,   data  & 0x10);
413428   set_led_status(space->machine(), 3,   data  & 0x20);   //
414429
415   c6 = data;
416   show_outputs();
430   state->m_c6 = data;
431   show_outputs(state);
417432}
418433
419434// Port c8
r11160r11161
421436// 02 hopper motor on (active low)?
422437static WRITE8_HANDLER( c8_w )
423438{
439   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
424440   ticket_dispenser_w(space->machine().device("hopper"), 0, (!(data & 0x02) && (data & 0x01)) ? 0x00 : 0x80);
425441
426   c8 = data;
427   show_outputs();
442   state->m_c8 = data;
443   show_outputs(state);
428444}
429445
430446static ADDRESS_MAP_START( gegege_mem_map, AS_PROGRAM, 8 )
r11160r11161
477493// rombank
478494static WRITE8_HANDLER( animalc_rombank_w )
479495{
496   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
480497   if (offset == 0)
481498   {
482      reg = data;
499      state->m_reg = data;
483500      return;
484501   }
485502
486503   UINT8 *rom = space->machine().region("maincpu")->base();
487   switch ( reg )
504   switch ( state->m_reg )
488505   {
489506      case 0x0f:
490         rombank = data;
507         state->m_rombank = data;
491508         switch (data)
492509         {
493510            case 0x10:   memory_set_bankptr(space->machine(), "rombank", rom + 0x400 + 0x4000);   break;
494511            case 0x14:   memory_set_bankptr(space->machine(), "rombank", rom + 0x400 + 0x8000);   break;
495512            case 0x18:   memory_set_bankptr(space->machine(), "rombank", rom + 0x400 + 0xc000);   break;
496513            default:
497               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, reg);
514               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, state->m_reg);
498515         }
499516         break;
500517
501518      default:
502         logerror("%s: unknown reg written: %02x = %02x\n", space->machine().describe_context(), reg, data);
519         logerror("%s: unknown reg written: %02x = %02x\n", space->machine().describe_context(), state->m_reg, data);
503520   }
504521}
505522static READ8_HANDLER( animalc_rombank_r )
506523{
524   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
507525   if (offset == 0)
508      return reg;
526      return state->m_reg;
509527
510   switch ( reg )
528   switch ( state->m_reg )
511529   {
512530      case 0x0f:
513         return rombank;
531         return state->m_rombank;
514532
515533      default:
516         logerror("%s: unknown reg read: %02x\n", space->machine().describe_context(), reg);
534         logerror("%s: unknown reg read: %02x\n", space->machine().describe_context(), state->m_reg);
517535         return 0x00;
518536   }
519537}
r11160r11161
521539// rambank
522540static WRITE8_HANDLER( animalc_rambank_w )
523541{
542   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
524543   if (offset == 0)
525544   {
526      reg2 = data;
545      state->m_reg2 = data;
527546      return;
528547   }
529548
530549   int bank = 0;
531   switch ( reg2 )
550   switch ( state->m_reg2 )
532551   {
533552      case 0x1f:
534         rambank = data;
553         state->m_rambank = data;
535554         switch (data)
536555         {
537556            case 0x58:   bank = 0;   break;
r11160r11161
540559            case 0x64:   bank = 3;   break;
541560            case 0x65:   bank = 4;   break;
542561            default:
543               logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", space->machine().describe_context(), data, reg2);
562               logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", space->machine().describe_context(), data, state->m_reg2);
544563               return;
545564         }
546565         memory_set_bank(space->machine(), "rambank", bank);
r11160r11161
549568         break;
550569
551570      default:
552         logerror("%s: unknown reg2 written: %02x = %02x\n", space->machine().describe_context(), reg2, data);
571         logerror("%s: unknown reg2 written: %02x = %02x\n", space->machine().describe_context(), state->m_reg2, data);
553572   }
554573}
555574static READ8_HANDLER( animalc_rambank_r )
556575{
576   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
557577   if (offset == 0)
558      return reg2;
578      return state->m_reg2;
559579
560   switch ( reg2 )
580   switch ( state->m_reg2 )
561581   {
562582      case 0x1f:
563         return rambank;
583         return state->m_rambank;
564584
565585      default:
566         logerror("%s: unknown reg2 read: %02x\n", space->machine().describe_context(), reg2);
586         logerror("%s: unknown reg2 read: %02x\n", space->machine().describe_context(), state->m_reg2);
567587         return 0x00;
568588   }
569589}
r11160r11161
595615   return 0x01;
596616}
597617
598static UINT8 vblank;
599
600618static READ8_HANDLER( vblank_r )
601619{
620   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
602621   // mask 0x04 must be set before writing sprite list
603622   // mask 0x10 must be set or irq/00 hangs?
604   return   vblank | 0x14;
623   return   state->m_vblank | 0x14;
605624}
606625
607626static WRITE8_HANDLER( vblank_w )
608627{
609   vblank = (vblank & ~0x03) | (data & 0x03);
628   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
629   state->m_vblank = (state->m_vblank & ~0x03) | (data & 0x03);
610630}
611631
612632static SCREEN_EOF( sammymdl )
613633{
614   vblank &= ~0x01;
634   sigmab98_state *state = machine.driver_data<sigmab98_state>();
635   state->m_vblank &= ~0x01;
615636}
616637
617static UINT8 out[3];
618static void show_3_outputs()
638static void show_3_outputs(sigmab98_state *state)
619639{
620640#ifdef MAME_DEBUG
621//  popmessage("COIN: %02X  LED: %02X  HOP: %02X", out[0], out[1], out[2]);
641//  popmessage("COIN: %02X  LED: %02X  HOP: %02X", state->m_out[0], state->m_out[1], state->m_out[2]);
622642#endif
623643}
624644// Port 31
625645static WRITE8_HANDLER( sammymdl_coin_w )
626646{
647   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
627648   coin_counter_w(space->machine(), 0,   data  & 0x01 );   // coin1 in
628649   coin_counter_w(space->machine(), 1,   data  & 0x02 );   // coin2 in
629650   coin_counter_w(space->machine(), 2,   data  & 0x04 );   // medal in
r11160r11161
632653//  coin_lockout_w(space->machine(), 0, (~data) & 0x10 ); // coin1 lockout
633654//  coin_lockout_w(space->machine(), 2, (~data) & 0x20 ); // medal lockout?
634655
635   out[0] = data;
636   show_3_outputs();
656   state->m_out[0] = data;
657   show_3_outputs(state);
637658}
638659
639660// Port 32
640661static WRITE8_HANDLER( sammymdl_leds_w )
641662{
663   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
642664   set_led_status(space->machine(), 0,   data & 0x01);   // button
643665
644   out[1] = data;
645   show_3_outputs();
666   state->m_out[1] = data;
667   show_3_outputs(state);
646668}
647669
648670// Port b0
r11160r11161
650672// 01 hopper motor on (active low)?
651673static WRITE8_HANDLER( sammymdl_hopper_w )
652674{
675   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
653676   ticket_dispenser_w(space->machine().device("hopper"), 0, (!(data & 0x01) && (data & 0x02)) ? 0x00 : 0x80);
654677
655   out[2] = data;
656   show_3_outputs();
678   state->m_out[2] = data;
679   show_3_outputs(state);
657680}
658681
659682static READ8_HANDLER( sammymdl_coin_hopper_r )
r11160r11161
666689   return ret;
667690}
668691
669static UINT8 *nvram;
670692static ADDRESS_MAP_START( animalc_map, AS_PROGRAM, 8 )
671693   AM_RANGE( 0x0000, 0x3fff ) AM_ROM
672694   AM_RANGE( 0x4000, 0x7fff ) AM_ROMBANK( "rombank" )
673   AM_RANGE( 0x8000, 0x8fff ) AM_RAMBANK( "rambank" ) AM_SHARE( "nvram" ) AM_BASE( &nvram )
695   AM_RANGE( 0x8000, 0x8fff ) AM_RAMBANK( "rambank" ) AM_SHARE( "nvram" ) AM_BASE_MEMBER( sigmab98_state, m_nvram )
674696
675697   AM_RANGE( 0x9000, 0x9fff ) AM_RAM
676698   AM_RANGE( 0xa000, 0xafff ) AM_RAM
r11160r11161
710732// rombank
711733static WRITE8_HANDLER( haekaka_rombank_w )
712734{
735   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
713736   if (offset == 0)
714737   {
715      reg = data;
738      state->m_reg = data;
716739      return;
717740   }
718741
719   switch ( reg )
742   switch ( state->m_reg )
720743   {
721744      case 0x2b:
722         rombank = data;
745         state->m_rombank = data;
723746         switch (data)
724747         {
725748            case 0x10:   // ROM
r11160r11161
744767               break;
745768
746769            default:
747               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, reg);
770               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, state->m_reg);
748771         }
749772         break;
750773
751774      default:
752         logerror("%s: unknown reg written: %02x = %02x\n", space->machine().describe_context(), reg, data);
775         logerror("%s: unknown reg written: %02x = %02x\n", space->machine().describe_context(), state->m_reg, data);
753776   }
754777}
755778static READ8_HANDLER( haekaka_rombank_r )
756779{
780   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
757781   if (offset == 0)
758      return reg;
782      return state->m_reg;
759783
760   switch ( reg )
784   switch ( state->m_reg )
761785   {
762786      case 0x2b:
763         return rombank;
787         return state->m_rombank;
764788
765789      default:
766         logerror("%s: unknown reg read: %02x\n", space->machine().describe_context(), reg);
790         logerror("%s: unknown reg read: %02x\n", space->machine().describe_context(), state->m_reg);
767791         return 0x00;
768792   }
769793}
r11160r11161
771795// rambank
772796static WRITE8_HANDLER( haekaka_rambank_w )
773797{
798   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
774799   if (offset == 0)
775800   {
776      reg2 = data;
801      state->m_reg2 = data;
777802      return;
778803   }
779804
780   switch ( reg2 )
805   switch ( state->m_reg2 )
781806   {
782807      case 0x33:
783         rambank = data;
808         state->m_rambank = data;
784809         switch (data)
785810         {
786811            case 0x53:
787812               break;
788813
789814            default:
790               logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", space->machine().describe_context(), data, reg2);
815               logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", space->machine().describe_context(), data, state->m_reg2);
791816         }
792817         break;
793818
794819      default:
795         logerror("%s: unknown reg2 written: %02x = %02x\n", space->machine().describe_context(), reg2, data);
820         logerror("%s: unknown reg2 written: %02x = %02x\n", space->machine().describe_context(), state->m_reg2, data);
796821   }
797822}
798823static READ8_HANDLER( haekaka_rambank_r )
799824{
825   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
800826   if (offset == 0)
801      return reg2;
827      return state->m_reg2;
802828
803   switch ( reg2 )
829   switch ( state->m_reg2 )
804830   {
805831      case 0x33:
806         return rambank;
832         return state->m_rambank;
807833
808834      default:
809         logerror("%s: unknown reg2 read: %02x\n", space->machine().describe_context(), reg2);
835         logerror("%s: unknown reg2 read: %02x\n", space->machine().describe_context(), state->m_reg2);
810836         return 0x00;
811837   }
812838}
r11160r11161
819845static READ8_HANDLER( haekaka_b000_r )
820846{
821847   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
822   switch (rombank)
848   switch (state->m_rombank)
823849   {
824850      case 0x10:   // ROM
825851      case 0x11:
r11160r11161
837863      case 0x1d:
838864      case 0x1e:
839865      case 0x1f:
840         return space->machine().region("maincpu")->base()[offset + 0xb400 + 0x1000 * (rombank-0x10)];
866         return space->machine().region("maincpu")->base()[offset + 0xb400 + 0x1000 * (state->m_rombank-0x10)];
841867
842868      case 0x65:   // SPRITERAM
843869         if (offset < 0x1000)
r11160r11161
851877         break;
852878   }
853879
854   logerror("%s: unknown read from %02x with rombank = %02x\n", space->machine().describe_context(), offset+0xb000, rombank);
880   logerror("%s: unknown read from %02x with rombank = %02x\n", space->machine().describe_context(), offset+0xb000, state->m_rombank);
855881   return 0x00;
856882}
857883
858884static WRITE8_HANDLER( haekaka_b000_w )
859885{
860886   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
861   switch (rombank)
887   switch (state->m_rombank)
862888   {
863889      case 0x65:   // SPRITERAM
864890         if (offset < 0x1000)
r11160r11161
883909         break;
884910   }
885911
886   logerror("%s: unknown write to %02x = %02x with rombank = %02x\n", space->machine().describe_context(), offset+0xb000, data, rombank);
912   logerror("%s: unknown write to %02x = %02x with rombank = %02x\n", space->machine().describe_context(), offset+0xb000, data, state->m_rombank);
887913}
888914
889915static WRITE8_HANDLER( haekaka_leds_w )
890916{
917   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
891918   // All used
892919   set_led_status(space->machine(), 0,   data & 0x01);
893920   set_led_status(space->machine(), 1,   data & 0x02);
r11160r11161
898925   set_led_status(space->machine(), 6,   data & 0x40);
899926   set_led_status(space->machine(), 7,   data & 0x80);
900927
901   out[1] = data;
902   show_3_outputs();
928   state->m_out[1] = data;
929   show_3_outputs(state);
903930}
904931
905932static WRITE8_HANDLER( haekaka_coin_w )
906933{
934   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
907935   coin_counter_w(space->machine(), 0,   data & 0x01 );   // medal out
908936//                                      data & 0x02 ?
909937//                                      data & 0x04 ?
910938//                                      data & 0x10 ?
911939
912   out[0] = data;
913   show_3_outputs();
940   state->m_out[0] = data;
941   show_3_outputs(state);
914942}
915943
916944static ADDRESS_MAP_START( haekaka_map, AS_PROGRAM, 8 )
917945   AM_RANGE( 0x0000, 0x7fff ) AM_ROM
918946   AM_RANGE( 0xb000, 0xcfff ) AM_READWRITE( haekaka_b000_r, haekaka_b000_w )
919   AM_RANGE( 0xd000, 0xefff ) AM_RAM AM_SHARE( "nvram" ) AM_BASE( &nvram )
947   AM_RANGE( 0xd000, 0xefff ) AM_RAM AM_SHARE( "nvram" ) AM_BASE_MEMBER( sigmab98_state, m_nvram )
920948   AM_RANGE( 0xfe00, 0xffff ) AM_RAM   // High speed internal RAM
921949ADDRESS_MAP_END
922950
r11160r11161
947975   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
948976   if (offset == 0)
949977   {
950      reg = data;
978      state->m_reg = data;
951979      return;
952980   }
953981
954982   UINT8 *rom = space->machine().region("maincpu")->base();
955   switch ( reg )
983   switch ( state->m_reg )
956984   {
957985      case 0x0d:
958         rombank = data;
986         state->m_rombank = data;
959987         switch (data)
960988         {
961989            case 0x11:   // 3800 IS ROM
r11160r11161
966994               break;
967995
968996            default:
969               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, reg);
997               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, state->m_reg);
970998         }
971999         break;
9721000
9731001      case 0x4d:
974         rombank = data;
1002         state->m_rombank = data;
9751003         switch (data)
9761004         {
9771005            case 0x14:   // 3800 IS ROM
r11160r11161
9821010               break;
9831011
9841012            default:
985               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, reg);
1013               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, state->m_reg);
9861014         }
9871015         break;
9881016
9891017      case 0x8d:
990         rombank = data;
1018         state->m_rombank = data;
9911019         switch (data)
9921020         {
9931021            case 0x0f:   // 3800 IS ROM
r11160r11161
10211049               break;
10221050
10231051            default:
1024               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, reg);
1052               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, state->m_reg);
10251053         }
10261054         break;
10271055
10281056      case 0xcd:
1029         rombank = data;
1057         state->m_rombank = data;
10301058         switch (data)
10311059         {
10321060            case 0x14:   // 3800 IS ROM
r11160r11161
10371065               break;
10381066
10391067            default:
1040               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, reg);
1068               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, state->m_reg);
10411069         }
10421070         break;
10431071
10441072      default:
1045         logerror("%s: unknown reg written: %02x = %02x\n", space->machine().describe_context(), reg, data);
1073         logerror("%s: unknown reg written: %02x = %02x\n", space->machine().describe_context(), state->m_reg, data);
10461074   }
10471075}
10481076static READ8_HANDLER( itazuram_rombank_r )
10491077{
1078   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
10501079   if (offset == 0)
1051      return reg;
1080      return state->m_reg;
10521081
1053   switch ( reg )
1082   switch ( state->m_reg )
10541083   {
10551084      // FIXME different registers
10561085      case 0x0d:
10571086      case 0x4d:
10581087      case 0x8d:
10591088      case 0xcd:
1060         return rombank;
1089         return state->m_rombank;
10611090
10621091      default:
1063         logerror("%s: unknown reg read: %02x\n", space->machine().describe_context(), reg);
1092         logerror("%s: unknown reg read: %02x\n", space->machine().describe_context(), state->m_reg);
10641093         return 0x00;
10651094   }
10661095}
r11160r11161
10681097// rambank
10691098static WRITE8_HANDLER( itazuram_rambank_w )
10701099{
1100   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
10711101   if (offset == 0)
10721102   {
1073      reg2 = data;
1103      state->m_reg2 = data;
10741104      return;
10751105   }
10761106
1077   switch ( reg2 )
1107   switch ( state->m_reg2 )
10781108   {
10791109      case 0x76:
1080         rambank = data;
1110         state->m_rambank = data;
10811111         switch (data)
10821112         {
1083            case 0x52:   memory_set_bankptr(space->machine(), "palbank", nvram);                           break;
1113            case 0x52:   memory_set_bankptr(space->machine(), "palbank", state->m_nvram);                           break;
10841114            case 0x64:   memory_set_bankptr(space->machine(), "palbank", space->machine().generic.paletteram.u8);   break;
10851115            default:
1086               logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", space->machine().describe_context(), data, reg2);
1116               logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", space->machine().describe_context(), data, state->m_reg2);
10871117               return;
10881118         }
10891119         break;
10901120
10911121      default:
1092         logerror("%s: unknown reg2 written: %02x = %02x\n", space->machine().describe_context(), reg2, data);
1122         logerror("%s: unknown reg2 written: %02x = %02x\n", space->machine().describe_context(), state->m_reg2, data);
10931123   }
10941124}
10951125
10961126static READ8_HANDLER( itazuram_rambank_r )
10971127{
1128   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
10981129   if (offset == 0)
1099      return reg2;
1130      return state->m_reg2;
11001131
1101   switch ( reg2 )
1132   switch ( state->m_reg2 )
11021133   {
11031134      case 0x76:
1104         return rambank;
1135         return state->m_rambank;
11051136
11061137      default:
1107         logerror("%s: unknown reg2 read: %02x\n", space->machine().describe_context(), reg2);
1138         logerror("%s: unknown reg2 read: %02x\n", space->machine().describe_context(), state->m_reg2);
11081139         return 0x00;
11091140   }
11101141}
11111142
11121143static WRITE8_HANDLER( itazuram_nvram_palette_w )
11131144{
1114   if (rambank == 0x64)
1145   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
1146   if (state->m_rambank == 0x64)
11151147   {
11161148      paletteram_xRRRRRGGGGGBBBBB_be_w(space, offset, data);
11171149//      space->machine().generic.paletteram.u8[offset] = data;
11181150   }
1119   else if (rambank == 0x52)
1151   else if (state->m_rambank == 0x52)
11201152   {
1121      nvram[offset] = data;
1153      state->m_nvram[offset] = data;
11221154   }
11231155   else
11241156   {
1125      logerror("%s: itazuram_nvram_palette_w offset = %03x with unknown bank = %02x\n", space->machine().describe_context(), offset, rambank);
1157      logerror("%s: itazuram_nvram_palette_w offset = %03x with unknown bank = %02x\n", space->machine().describe_context(), offset, state->m_rambank);
11261158   }
11271159}
11281160
11291161static WRITE8_HANDLER( itazuram_palette_w )
11301162{
1131   if (rombank == 0x6c)
1163   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
1164   if (state->m_rombank == 0x6c)
11321165   {
11331166      if (offset < 0x200)
11341167         paletteram_xRRRRRGGGGGBBBBB_be_w(space, offset, data);
r11160r11161
11361169   }
11371170   else
11381171   {
1139      logerror("%s: itazuram_palette_w offset = %03x with unknown bank = %02x\n", space->machine().describe_context(), offset, rombank);
1172      logerror("%s: itazuram_palette_w offset = %03x with unknown bank = %02x\n", space->machine().describe_context(), offset, state->m_rombank);
11401173   }
11411174}
11421175static READ8_HANDLER( itazuram_palette_r )
r11160r11161
11541187
11551188   AM_RANGE( 0x6811, 0x6811 ) AM_WRITENOP   // IRQ Enable? Screen disable?
11561189   AM_RANGE( 0x6813, 0x6813 ) AM_WRITENOP   // IRQ Ack?
1157   AM_RANGE( 0xdc00, 0xfdff ) AM_READ_BANK( "palbank" ) AM_WRITE( itazuram_nvram_palette_w ) AM_SHARE( "nvram" ) AM_BASE( &nvram )   // nvram | paletteram
1190   AM_RANGE( 0xdc00, 0xfdff ) AM_READ_BANK( "palbank" ) AM_WRITE( itazuram_nvram_palette_w ) AM_SHARE( "nvram" ) AM_BASE_MEMBER( sigmab98_state, m_nvram )   // nvram | paletteram
11581191
11591192   AM_RANGE( 0xfe00, 0xffff ) AM_RAM   // High speed internal RAM
11601193ADDRESS_MAP_END
r11160r11161
11921225// rombank
11931226static WRITE8_HANDLER( tdoboon_rombank_w )
11941227{
1228   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
11951229   if (offset == 0)
11961230   {
1197      reg = data;
1231      state->m_reg = data;
11981232      return;
11991233   }
12001234
1201   switch ( reg )
1235   switch ( state->m_reg )
12021236   {
12031237      case 0x2f:
1204         rombank = data;
1238         state->m_rombank = data;
12051239         switch (data)
12061240         {
12071241            case 0x10:   // ROM
r11160r11161
12271261               break;
12281262
12291263            default:
1230               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, reg);
1264               logerror("%s: unknown rom bank = %02x, reg = %02x\n", space->machine().describe_context(), data, state->m_reg);
12311265         }
12321266         break;
12331267
12341268      default:
1235         logerror("%s: unknown reg written: %02x = %02x\n", space->machine().describe_context(), reg, data);
1269         logerror("%s: unknown reg written: %02x = %02x\n", space->machine().describe_context(), state->m_reg, data);
12361270   }
12371271}
12381272static READ8_HANDLER( tdoboon_rombank_r )
12391273{
1274   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
12401275   if (offset == 0)
1241      return reg;
1276      return state->m_reg;
12421277
1243   switch ( reg )
1278   switch ( state->m_reg )
12441279   {
12451280      case 0x2f:
1246         return rombank;
1281         return state->m_rombank;
12471282
12481283      default:
1249         logerror("%s: unknown reg read: %02x\n", space->machine().describe_context(), reg);
1284         logerror("%s: unknown reg read: %02x\n", space->machine().describe_context(), state->m_reg);
12501285         return 0x00;
12511286   }
12521287}
r11160r11161
12541289// rambank
12551290static WRITE8_HANDLER( tdoboon_rambank_w )
12561291{
1292   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
12571293   if (offset == 0)
12581294   {
1259      reg2 = data;
1295      state->m_reg2 = data;
12601296      return;
12611297   }
12621298
1263   switch ( reg2 )
1299   switch ( state->m_reg2 )
12641300   {
12651301      case 0x33:
1266         rambank = data;
1302         state->m_rambank = data;
12671303         switch (data)
12681304         {
12691305            case 0x53:
12701306               break;
12711307
12721308            default:
1273               logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", space->machine().describe_context(), data, reg2);
1309               logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", space->machine().describe_context(), data, state->m_reg2);
12741310         }
12751311         break;
12761312
12771313      default:
1278         logerror("%s: unknown reg2 written: %02x = %02x\n", space->machine().describe_context(), reg2, data);
1314         logerror("%s: unknown reg2 written: %02x = %02x\n", space->machine().describe_context(), state->m_reg2, data);
12791315   }
12801316}
12811317static READ8_HANDLER( tdoboon_rambank_r )
12821318{
1319   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
12831320   if (offset == 0)
1284      return reg2;
1321      return state->m_reg2;
12851322
1286   switch ( reg2 )
1323   switch ( state->m_reg2 )
12871324   {
12881325      case 0x33:
1289         return rambank;
1326         return state->m_rambank;
12901327
12911328      default:
1292         logerror("%s: unknown reg2 read: %02x\n", space->machine().describe_context(), reg2);
1329         logerror("%s: unknown reg2 read: %02x\n", space->machine().describe_context(), state->m_reg2);
12931330         return 0x00;
12941331   }
12951332}
r11160r11161
12971334static READ8_HANDLER( tdoboon_c000_r )
12981335{
12991336   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
1300   switch (rombank)
1337   switch (state->m_rombank)
13011338   {
13021339      case 0x10:   // ROM
13031340      case 0x11:
r11160r11161
13151352      case 0x1d:
13161353      case 0x1e:
13171354      case 0x1f:
1318         return space->machine().region("maincpu")->base()[offset + 0xc400 + 0x1000 * (rombank-0x10)];
1355         return space->machine().region("maincpu")->base()[offset + 0xc400 + 0x1000 * (state->m_rombank-0x10)];
13191356
13201357      case 0x64:   // SPRITERAM
13211358         if (offset < 0x1000)
r11160r11161
13331370         break;
13341371   }
13351372
1336   logerror("%s: unknown read from %02x with rombank = %02x\n", space->machine().describe_context(), offset+0xc000, rombank);
1373   logerror("%s: unknown read from %02x with rombank = %02x\n", space->machine().describe_context(), offset+0xc000, state->m_rombank);
13371374   return 0x00;
13381375}
13391376
13401377static WRITE8_HANDLER( tdoboon_c000_w )
13411378{
13421379   sigmab98_state *state = space->machine().driver_data<sigmab98_state>();
1343   switch (rombank)
1380   switch (state->m_rombank)
13441381   {
13451382      case 0x64:   // SPRITERAM
13461383         if (offset < 0x1000)
r11160r11161
13651402         break;
13661403   }
13671404
1368   logerror("%s: unknown write to %02x = %02x with rombank = %02x\n", space->machine().describe_context(), offset+0xc000, data, rombank);
1405   logerror("%s: unknown write to %02x = %02x with rombank = %02x\n", space->machine().describe_context(), offset+0xc000, data, state->m_rombank);
13691406}
13701407
13711408static ADDRESS_MAP_START( tdoboon_map, AS_PROGRAM, 8 )
13721409   AM_RANGE( 0x0000, 0xbfff ) AM_ROM
13731410   AM_RANGE( 0xc000, 0xcfff ) AM_READWRITE( tdoboon_c000_r, tdoboon_c000_w )
1374   AM_RANGE( 0xd000, 0xefff ) AM_RAM AM_SHARE( "nvram" ) AM_BASE( &nvram )
1411   AM_RANGE( 0xd000, 0xefff ) AM_RAM AM_SHARE( "nvram" ) AM_BASE_MEMBER( sigmab98_state, m_nvram )
13751412   AM_RANGE( 0xfe00, 0xffff ) AM_RAM   // High speed internal RAM
13761413ADDRESS_MAP_END
13771414
r11160r11161
19191956   sigmab98_state *state = machine.driver_data<sigmab98_state>();
19201957   // RAM banks
19211958   UINT8 *bankedram = auto_alloc_array(machine, UINT8, 0x1000 * 5);
1922   memory_configure_bank(machine, "rambank", 0, 1, nvram,     0x1000);
1959   memory_configure_bank(machine, "rambank", 0, 1, state->m_nvram,     0x1000);
19231960   memory_configure_bank(machine, "rambank", 1, 4, bankedram, 0x1000);
19241961   memory_set_bank(machine, "rambank", 0);
19251962
r11160r11161
19591996   UINT8 *rom = machine.region("maincpu")->base();
19601997   memory_set_bankptr(machine, "rombank0", rom + 0x3400);
19611998   memory_set_bankptr(machine, "rombank1", rom + 0x4400);
1962   rombank = 0x0f;
1999   state->m_rombank = 0x0f;
19632000
19642001   // RAM banks
19652002   machine.generic.paletteram.u8 = auto_alloc_array(machine, UINT8, 0x3000);
19662003   memset(machine.generic.paletteram.u8, 0, 0x3000);
19672004   memory_set_bankptr(machine, "palbank", machine.generic.paletteram.u8);
1968   rambank = 0x64;
2005   state->m_rambank = 0x64;
19692006
19702007   state->m_spriteram = auto_alloc_array(machine, UINT8, 0x1000 * 5);
19712008   memset(state->m_spriteram, 0, 0x1000 * 5);
r11160r11161
20792116   memset(state->m_spriteram, 0, 0x1000);
20802117   state->m_spriteram_size = 0x1000;
20812118
2082   rombank = 0x65;
2083   rambank = 0x53;
2119   state->m_rombank = 0x65;
2120   state->m_rambank = 0x53;
20842121}
20852122
20862123
src/mame/drivers/calchase.c
r11160r11161
566566static IRQ_CALLBACK(irq_callback)
567567{
568568   calchase_state *state = device->machine().driver_data<calchase_state>();
569   int r = 0;
570   r = pic8259_acknowledge( state->m_pic8259_2);
571   if (r==0)
572   {
573      r = pic8259_acknowledge( state->m_pic8259_1);
574   }
575   return r;
569   return pic8259_acknowledge( state->m_pic8259_1);
576570}
577571
578572static MACHINE_START(calchase)
r11160r11161
598592   cputag_set_input_line(device->machine(), "maincpu", 0, state ? HOLD_LINE : CLEAR_LINE);
599593}
600594
595static READ8_DEVICE_HANDLER( get_slave_ack )
596{
597   calchase_state *state = device->machine().driver_data<calchase_state>();
598   if (offset==2) { // IRQ = 2
599      return pic8259_acknowledge(state->m_pic8259_2);
600   }
601   return 0x00;
602}
603
601604static const struct pic8259_interface calchase_pic8259_1_config =
602605{
603   DEVCB_LINE(calchase_pic8259_1_set_int_line)
606   DEVCB_LINE(calchase_pic8259_1_set_int_line),
607   DEVCB_LINE_VCC,
608   DEVCB_HANDLER(get_slave_ack)
604609};
605610
606611static const struct pic8259_interface calchase_pic8259_2_config =
607612{
608   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w)
613   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w),
614   DEVCB_LINE_GND,
615   DEVCB_NULL
609616};
610617
611618
src/mame/drivers/vegas.c
r11160r11161
577577   /* reset the DCS system if we have one */
578578   if (machine.device("dcs2") != NULL || machine.device("dsio") != NULL || machine.device("denver") != NULL)
579579   {
580      dcs_reset_w(1);
581      dcs_reset_w(0);
580      dcs_reset_w(machine, 1);
581      dcs_reset_w(machine, 0);
582582   }
583583
584584   /* initialize IRQ states */
r11160r11161
13131313      if (!(data & 0x01))
13141314      {
13151315         midway_ioasic_reset(space->machine());
1316         dcs_reset_w(data & 0x01);
1316         dcs_reset_w(space->machine(), data & 0x01);
13171317      }
13181318
13191319      /* they toggle bit 0x08 low to reset the VBLANK */
src/mame/drivers/shuuz.c
r11160r11161
1919
2020#include "emu.h"
2121#include "cpu/m68000/m68000.h"
22#include "sound/okim6295.h"
23#include "video/atarimo.h"
2224#include "includes/shuuz.h"
23#include "sound/okim6295.h"
2425
2526
2627
r11160r11161
151152   AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(shuuz_atarivc_r, shuuz_atarivc_w) AM_BASE_MEMBER(shuuz_state, m_atarivc_data)
152153   AM_RANGE(0x3f4000, 0x3f5eff) AM_RAM_WRITE(atarigen_playfield_latched_msb_w) AM_BASE_MEMBER(shuuz_state, m_playfield)
153154   AM_RANGE(0x3f5f00, 0x3f5f7f) AM_RAM AM_BASE_MEMBER(shuuz_state, m_atarivc_eof_data)
154   AM_RANGE(0x3f5f80, 0x3f5fff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
155   AM_RANGE(0x3f5f80, 0x3f5fff) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
155156   AM_RANGE(0x3f6000, 0x3f7fff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(shuuz_state, m_playfield_upper)
156157   AM_RANGE(0x3f8000, 0x3fcfff) AM_RAM
157   AM_RANGE(0x3fd000, 0x3fd3ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
158   AM_RANGE(0x3fd000, 0x3fd3ff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
158159   AM_RANGE(0x3fd400, 0x3fffff) AM_RAM
159160ADDRESS_MAP_END
160161
src/mame/drivers/system16.c
r11160r11161
30843084   ROM_LOAD( "82s123.2",  0x0000, 0x0020, NO_DUMP ) //same as beauty block?
30853085
30863086   ROM_REGION( 0x0144, "pals", 0 )
3087   ROM_LOAD( "iqpipe.a",  0x0000, 0x0104, CRC(e9cd78fb) SHA1(557d3e7ef3b25c1338b24722cac91bca788c02b8) )
3088   ROM_LOAD( "iqpipe.b",  0x0000, 0x0104, CRC(e9cd78fb) SHA1(557d3e7ef3b25c1338b24722cac91bca788c02b8) )
3089   ROM_LOAD( "iqpipe.c",  0x0000, 0x0104, CRC(e9cd78fb) SHA1(557d3e7ef3b25c1338b24722cac91bca788c02b8) )
3087   ROM_LOAD( "iqpipe.a",  0x0000, 0x0104, BAD_DUMP CRC(e9cd78fb) SHA1(557d3e7ef3b25c1338b24722cac91bca788c02b8) )
3088   ROM_LOAD( "iqpipe.b",  0x0000, 0x0104, BAD_DUMP CRC(e9cd78fb) SHA1(557d3e7ef3b25c1338b24722cac91bca788c02b8) )
3089   ROM_LOAD( "iqpipe.c",  0x0000, 0x0104, BAD_DUMP CRC(e9cd78fb) SHA1(557d3e7ef3b25c1338b24722cac91bca788c02b8) )
30903090   ROM_LOAD( "iqpipe.d",  0x0000, 0x0144, CRC(36e30d71) SHA1(e38f0257f9beedccc9421eec78701a86465d16ad) )
3091   ROM_LOAD( "iqpipe.u4", 0x0000, 0x0104, CRC(e9cd78fb) SHA1(557d3e7ef3b25c1338b24722cac91bca788c02b8) )
3091   ROM_LOAD( "iqpipe.u4", 0x0000, 0x0104, BAD_DUMP CRC(e9cd78fb) SHA1(557d3e7ef3b25c1338b24722cac91bca788c02b8) )
30923092ROM_END
30933093
30943094
src/mame/drivers/scobra.c
r11160r11161
3636#include "cpu/z80/z80.h"
3737#include "machine/8255ppi.h"
3838#include "machine/7474.h"
39#include "includes/galaxold.h"
4039#include "sound/ay8910.h"
40#include "includes/scramble.h"
4141
4242
43class scobra_state : public driver_device
43class scobra_state : public scramble_state
4444{
4545public:
4646   scobra_state(running_machine &machine, const driver_device_config_base &config)
47      : driver_device(machine, config) { }
47      : scramble_state(machine, config) { }
4848
4949   UINT8 *m_soundram;
5050};
r11160r11161
115115static ADDRESS_MAP_START( type1_map, AS_PROGRAM, 8 )
116116   AM_RANGE(0x0000, 0x7fff) AM_ROM
117117   AM_RANGE(0x8000, 0x87ff) AM_RAM
118   AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
118   AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
119119   AM_RANGE(0x8c00, 0x8fff) AM_RAM_WRITE(galaxold_videoram_w)   /* mirror */
120120   AM_RANGE(0x8c00, 0x8fff) AM_READ(galaxold_videoram_r)   /* mirror */
121   AM_RANGE(0x9000, 0x903f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
122   AM_RANGE(0x9040, 0x905f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
123   AM_RANGE(0x9060, 0x907f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
121   AM_RANGE(0x9000, 0x903f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
122   AM_RANGE(0x9040, 0x905f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
123   AM_RANGE(0x9060, 0x907f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
124124   AM_RANGE(0x9080, 0x90ff) AM_RAM
125125   AM_RANGE(0x9800, 0x9803) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w)
126126   AM_RANGE(0xa000, 0xa003) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w)
r11160r11161
135135static ADDRESS_MAP_START( type2_map, AS_PROGRAM, 8 )
136136   AM_RANGE(0x0000, 0x7fff) AM_ROM
137137   AM_RANGE(0x8000, 0x87ff) AM_RAM
138   AM_RANGE(0x8800, 0x883f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
139   AM_RANGE(0x8840, 0x885f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
140   AM_RANGE(0x8860, 0x887f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
138   AM_RANGE(0x8800, 0x883f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
139   AM_RANGE(0x8840, 0x885f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
140   AM_RANGE(0x8860, 0x887f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
141141   AM_RANGE(0x8880, 0x88ff) AM_RAM
142   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
142   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
143143   AM_RANGE(0x9400, 0x97ff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w)   /* mirror */
144144   AM_RANGE(0x9800, 0x9800) AM_READ(watchdog_reset_r)
145145   AM_RANGE(0xa000, 0xa00f) AM_DEVREADWRITE("ppi8255_0", scobra_type2_ppi8255_r, scobra_type2_ppi8255_w)
r11160r11161
155155static ADDRESS_MAP_START( hustler_map, AS_PROGRAM, 8 )
156156   AM_RANGE(0x0000, 0x7fff) AM_ROM
157157   AM_RANGE(0x8000, 0x87ff) AM_RAM
158   AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
159   AM_RANGE(0x9000, 0x903f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
160   AM_RANGE(0x9040, 0x905f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
161   AM_RANGE(0x9060, 0x907f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
158   AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
159   AM_RANGE(0x9000, 0x903f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
160   AM_RANGE(0x9040, 0x905f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
161   AM_RANGE(0x9060, 0x907f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
162162   AM_RANGE(0x9080, 0x90ff) AM_RAM
163163   AM_RANGE(0xa802, 0xa802) AM_WRITE(galaxold_flip_screen_x_w)
164164   AM_RANGE(0xa804, 0xa804) AM_WRITE(galaxold_nmi_enable_w)
r11160r11161
172172static ADDRESS_MAP_START( hustlerb_map, AS_PROGRAM, 8 )
173173   AM_RANGE(0x0000, 0x7fff) AM_RAM
174174   AM_RANGE(0x8000, 0x87ff) AM_RAM
175   AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
176   AM_RANGE(0x9000, 0x903f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
177   AM_RANGE(0x9040, 0x905f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
178   AM_RANGE(0x9060, 0x907f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
175   AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
176   AM_RANGE(0x9000, 0x903f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
177   AM_RANGE(0x9040, 0x905f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
178   AM_RANGE(0x9060, 0x907f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
179179   AM_RANGE(0x9080, 0x90ff) AM_RAM
180180   AM_RANGE(0xa801, 0xa801) AM_WRITE(galaxold_nmi_enable_w)
181181   AM_RANGE(0xa802, 0xa802) AM_WRITENOP   /* coin counters */
r11160r11161
189189static ADDRESS_MAP_START( mimonkey_map, AS_PROGRAM, 8 )
190190   AM_RANGE(0x0000, 0x3fff) AM_ROM
191191   AM_RANGE(0x8000, 0x87ff) AM_RAM
192   AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
192   AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
193193   AM_RANGE(0x8c00, 0x8fff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w)   /* mirror */
194   AM_RANGE(0x9000, 0x903f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
195   AM_RANGE(0x9040, 0x905f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
196   AM_RANGE(0x9060, 0x907f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
194   AM_RANGE(0x9000, 0x903f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
195   AM_RANGE(0x9040, 0x905f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
196   AM_RANGE(0x9060, 0x907f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
197197   AM_RANGE(0x9080, 0x90ff) AM_RAM
198198   AM_RANGE(0x9800, 0x9803) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w)
199199   AM_RANGE(0xa000, 0xa003) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w)
src/mame/drivers/galaxian.c
r11160r11161
434434
435435/*************************************
436436 *
437 *  Globals
438 *
439 *************************************/
440
441static UINT8 gmgalax_selected_game;
442static UINT8 zigzag_ay8910_latch;
443static UINT8 kingball_speech_dip;
444static UINT8 kingball_sound;
445static UINT8 mshuttle_ay8910_cs;
446
447static UINT16 protection_state;
448static UINT8 protection_result;
449
450static UINT8 konami_sound_control;
451static UINT8 sfx_sample_control;
452
453static UINT8 moonwar_port_select;
454
455static UINT8 irq_enabled;
456static int irq_line;
457
458static int tenspot_current_game;
459
460/*************************************
461 *
462437 *  Interrupts
463438 *
464439 *************************************/
465440
466441static INTERRUPT_GEN( interrupt_gen )
467442{
443   galaxian_state *state = device->machine().driver_data<galaxian_state>();
468444   /* interrupt line is clocked at VBLANK */
469445   /* a flip-flop at 6F is held in the preset state based on the NMI ON signal */
470   if (irq_enabled)
471      device_set_input_line(device, irq_line, ASSERT_LINE);
446   if (state->m_irq_enabled)
447      device_set_input_line(device, state->m_irq_line, ASSERT_LINE);
472448}
473449
474450static INTERRUPT_GEN( fakechange_interrupt_gen )
475451{
452   galaxian_state *state = device->machine().driver_data<galaxian_state>();
476453   interrupt_gen(device);
477454
478455   if (input_port_read_safe(device->machine(), "FAKE_SELECT", 0x00))
479456   {
480      tenspot_current_game++;
481      tenspot_current_game%=10;
482      tenspot_set_game_bank(device->machine(), tenspot_current_game, 1);
457      state->m_tenspot_current_game++;
458      state->m_tenspot_current_game%=10;
459      tenspot_set_game_bank(device->machine(), state->m_tenspot_current_game, 1);
483460      cputag_set_input_line(device->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE);
484461   }
485462}
486463
487464static WRITE8_HANDLER( irq_enable_w )
488465{
466   galaxian_state *state = space->machine().driver_data<galaxian_state>();
489467   /* the latched D0 bit here goes to the CLEAR line on the interrupt flip-flop */
490   irq_enabled = data & 1;
468   state->m_irq_enabled = data & 1;
491469
492470   /* if CLEAR is held low, we must make sure the interrupt signal is clear */
493   if (!irq_enabled)
494      device_set_input_line(&space->device(), irq_line, CLEAR_LINE);
471   if (!state->m_irq_enabled)
472      device_set_input_line(&space->device(), state->m_irq_line, CLEAR_LINE);
495473}
496474
497475/*************************************
r11160r11161
562540
563541static WRITE8_DEVICE_HANDLER( konami_sound_control_w )
564542{
565   UINT8 old = konami_sound_control;
566   konami_sound_control = data;
543   galaxian_state *state = device->machine().driver_data<galaxian_state>();
544   UINT8 old = state->m_konami_sound_control;
545   state->m_konami_sound_control = data;
567546
568547   /* the inverse of bit 3 clocks the flip flop to signal an INT */
569548   /* it is automatically cleared on the acknowledge */
r11160r11161
717696
718697static WRITE8_DEVICE_HANDLER( scramble_protection_w )
719698{
699   galaxian_state *state = device->machine().driver_data<galaxian_state>();
720700   /*
721701        This is not fully understood; the low 4 bits of port C are
722702        inputs; the upper 4 bits are outputs. Scramble main set always
723703        writes sequences of 3 or more nibbles to the low port and
724704        expects certain results in the upper nibble afterwards.
725705    */
726   protection_state = (protection_state << 4) | (data & 0x0f);
727   switch (protection_state & 0xfff)
706   state->m_protection_state = (state->m_protection_state << 4) | (data & 0x0f);
707   switch (state->m_protection_state & 0xfff)
728708   {
729709      /* scramble */
730      case 0xf09:      protection_result = 0xff;   break;
731      case 0xa49:      protection_result = 0xbf;   break;
732      case 0x319:      protection_result = 0x4f;   break;
733      case 0x5c9:      protection_result = 0x6f;   break;
710      case 0xf09:      state->m_protection_result = 0xff;   break;
711      case 0xa49:      state->m_protection_result = 0xbf;   break;
712      case 0x319:      state->m_protection_result = 0x4f;   break;
713      case 0x5c9:      state->m_protection_result = 0x6f;   break;
734714
735715      /* scrambls */
736      case 0x246:      protection_result ^= 0x80;   break;
737      case 0xb5f:      protection_result = 0x6f;   break;
716      case 0x246:      state->m_protection_result ^= 0x80;   break;
717      case 0xb5f:      state->m_protection_result = 0x6f;   break;
738718   }
739719}
740720
741721
742722static READ8_DEVICE_HANDLER( scramble_protection_r )
743723{
744   return protection_result;
724   galaxian_state *state = device->machine().driver_data<galaxian_state>();
725   return state->m_protection_result;
745726}
746727
747728
748729static CUSTOM_INPUT( scramble_protection_alt_r )
749730{
731   galaxian_state *state = field->port->machine().driver_data<galaxian_state>();
750732   /*
751733        There are two additional bits that are derived from bit 7 of
752734        the protection result. This is just a guess but works well enough
753735        to boot scrambls.
754736    */
755   return (protection_result >> 7) & 1;
737   return (state->m_protection_result >> 7) & 1;
756738}
757739
758740
r11160r11161
813795
814796static WRITE8_DEVICE_HANDLER( sfx_sample_control_w )
815797{
816   UINT8 old = sfx_sample_control;
817   sfx_sample_control = data;
798   galaxian_state *state = device->machine().driver_data<galaxian_state>();
799   UINT8 old = state->m_sfx_sample_control;
800   state->m_sfx_sample_control = data;
818801
819802   /* the inverse of bit 0 clocks the flip flop to signal an INT */
820803   /* it is automatically cleared on the acknowledge */
r11160r11161
963946
964947static READ8_DEVICE_HANDLER( scorpion_protection_r )
965948{
949   galaxian_state *state = device->machine().driver_data<galaxian_state>();
966950   UINT16 paritybits;
967951   UINT8 parity = 0;
968952
969953   /* compute parity of the current (bitmask & $CE29) */
970   for (paritybits = protection_state & 0xce29; paritybits != 0; paritybits >>= 1)
954   for (paritybits = state->m_protection_state & 0xce29; paritybits != 0; paritybits >>= 1)
971955      if (paritybits & 1)
972956         parity++;
973957
r11160r11161
978962
979963static WRITE8_DEVICE_HANDLER( scorpion_protection_w )
980964{
965   galaxian_state *state = device->machine().driver_data<galaxian_state>();
981966   /* bit 5 low is a reset */
982967   if (!(data & 0x20))
983      protection_state = 0x0000;
968      state->m_protection_state = 0x0000;
984969
985970   /* bit 4 low is a clock */
986971   if (!(data & 0x10))
987972   {
988973      /* each clock shifts left one bit and ORs in the inverse of the parity */
989      protection_state = (protection_state << 1) | (~scorpion_protection_r(device, 0) & 1);
974      state->m_protection_state = (state->m_protection_state << 1) | (~scorpion_protection_r(device, 0) & 1);
990975   }
991976}
992977
r11160r11161
10231008
10241009static INPUT_CHANGED( gmgalax_game_changed )
10251010{
1011   galaxian_state *state = field->port->machine().driver_data<galaxian_state>();
10261012   address_space *space = field->port->machine().device("maincpu")->memory().space(AS_PROGRAM);
10271013
10281014   /* new value is the selected game */
1029   gmgalax_selected_game = newval;
1015   state->m_gmgalax_selected_game = newval;
10301016
10311017   /* select the bank and graphics bank based on it */
1032   memory_set_bank(field->port->machine(), "bank1", gmgalax_selected_game);
1033   galaxian_gfxbank_w(space, 0, gmgalax_selected_game);
1018   memory_set_bank(field->port->machine(), "bank1", state->m_gmgalax_selected_game);
1019   galaxian_gfxbank_w(space, 0, state->m_gmgalax_selected_game);
10341020
10351021   /* reset the stars */
10361022   galaxian_stars_enable_w(space, 0, 0);
r11160r11161
10421028
10431029static CUSTOM_INPUT( gmgalax_port_r )
10441030{
1031   galaxian_state *state = field->port->machine().driver_data<galaxian_state>();
10451032   const char *portname = (const char *)param;
1046   if (gmgalax_selected_game != 0)
1033   if (state->m_gmgalax_selected_game != 0)
10471034      portname += strlen(portname) + 1;
10481035   return input_port_read(field->port->machine(), portname);
10491036}
r11160r11161
10651052
10661053static WRITE8_HANDLER( zigzag_ay8910_w )
10671054{
1055   galaxian_state *state = space->machine().driver_data<galaxian_state>();
10681056   switch (offset & 0x300)
10691057   {
10701058      case 0x000:
r11160r11161
10721060         /* bit 0 = WRITE */
10731061         /* bit 1 = C/D */
10741062         if ((offset & 1) != 0)
1075            ay8910_data_address_w(space->machine().device("aysnd"), offset >> 1, zigzag_ay8910_latch);
1063            ay8910_data_address_w(space->machine().device("aysnd"), offset >> 1, state->m_zigzag_ay8910_latch);
10761064         break;
10771065
10781066      case 0x100:
10791067         /* data latch */
1080         zigzag_ay8910_latch = offset & 0xff;
1068         state->m_zigzag_ay8910_latch = offset & 0xff;
10811069         break;
10821070
10831071      case 0x200:
r11160r11161
11091097
11101098static CUSTOM_INPUT( kingball_muxbit_r )
11111099{
1100   galaxian_state *state = field->port->machine().driver_data<galaxian_state>();
11121101   /* multiplex the service mode switch with a speech DIP switch */
1113   return (input_port_read(field->port->machine(), "FAKE") >> kingball_speech_dip) & 1;
1102   return (input_port_read(field->port->machine(), "FAKE") >> state->m_kingball_speech_dip) & 1;
11141103}
11151104
11161105
r11160r11161
11251114
11261115static WRITE8_HANDLER( kingball_speech_dip_w )
11271116{
1128   kingball_speech_dip = data;
1117   galaxian_state *state = space->machine().driver_data<galaxian_state>();
1118   state->m_kingball_speech_dip = data;
11291119}
11301120
11311121
11321122static WRITE8_HANDLER( kingball_sound1_w )
11331123{
1134   kingball_sound = (kingball_sound & ~0x01) | data;
1124   galaxian_state *state = space->machine().driver_data<galaxian_state>();
1125   state->m_kingball_sound = (state->m_kingball_sound & ~0x01) | data;
11351126}
11361127
11371128
11381129static WRITE8_HANDLER( kingball_sound2_w )
11391130{
1140   kingball_sound = (kingball_sound & ~0x02) | (data << 1);
1141   soundlatch_w(space, 0, kingball_sound | 0xf0);
1131   galaxian_state *state = space->machine().driver_data<galaxian_state>();
1132   state->m_kingball_sound = (state->m_kingball_sound & ~0x02) | (data << 1);
1133   soundlatch_w(space, 0, state->m_kingball_sound | 0xf0);
11421134}
11431135
11441136
r11160r11161
11571149
11581150static WRITE8_HANDLER( mshuttle_ay8910_cs_w )
11591151{
1160   mshuttle_ay8910_cs = data & 1;
1152   galaxian_state *state = space->machine().driver_data<galaxian_state>();
1153   state->m_mshuttle_ay8910_cs = data & 1;
11611154}
11621155
11631156
11641157static WRITE8_HANDLER( mshuttle_ay8910_control_w )
11651158{
1166   if (!mshuttle_ay8910_cs)
1159   galaxian_state *state = space->machine().driver_data<galaxian_state>();
1160   if (!state->m_mshuttle_ay8910_cs)
11671161      ay8910_address_w(space->machine().device("aysnd"), offset, data);
11681162}
11691163
11701164
11711165static WRITE8_HANDLER( mshuttle_ay8910_data_w )
11721166{
1173   if (!mshuttle_ay8910_cs)
1167   galaxian_state *state = space->machine().driver_data<galaxian_state>();
1168   if (!state->m_mshuttle_ay8910_cs)
11741169      ay8910_data_w(space->machine().device("aysnd"), offset, data);
11751170}
11761171
11771172
11781173static READ8_HANDLER( mshuttle_ay8910_data_r )
11791174{
1180   if (!mshuttle_ay8910_cs)
1175   galaxian_state *state = space->machine().driver_data<galaxian_state>();
1176   if (!state->m_mshuttle_ay8910_cs)
11811177      return ay8910_r(space->machine().device("aysnd"), offset);
11821178   return 0xff;
11831179}
r11160r11161
12761272
12771273static WRITE8_DEVICE_HANDLER( moonwar_port_select_w )
12781274{
1279   moonwar_port_select = data & 0x10;
1275   galaxian_state *state = device->machine().driver_data<galaxian_state>();
1276   state->m_moonwar_port_select = data & 0x10;
12801277}
12811278
12821279
r11160r11161
26202617   galaxian_extend_tile_info_func extend_tile_info,
26212618   galaxian_extend_sprite_info_func extend_sprite_info)
26222619{
2623   irq_enabled = 0;
2624   irq_line = INPUT_LINE_NMI;
2625   galaxian_frogger_adjust = FALSE;
2626   galaxian_sfx_tilemap = FALSE;
2627   galaxian_draw_bullet_ptr = (draw_bullet != NULL) ? draw_bullet : galaxian_draw_bullet;
2628   galaxian_draw_background_ptr = (draw_background != NULL) ? draw_background : galaxian_draw_background;
2629   galaxian_extend_tile_info_ptr = extend_tile_info;
2630   galaxian_extend_sprite_info_ptr = extend_sprite_info;
2620   galaxian_state *state = machine.driver_data<galaxian_state>();
2621   state->m_irq_enabled = 0;
2622   state->m_irq_line = INPUT_LINE_NMI;
2623   state->m_frogger_adjust = FALSE;
2624   state->m_sfx_tilemap = FALSE;
2625   state->m_draw_bullet_ptr = (draw_bullet != NULL) ? draw_bullet : galaxian_draw_bullet;
2626   state->m_draw_background_ptr = (draw_background != NULL) ? draw_background : galaxian_draw_background;
2627   state->m_extend_tile_info_ptr = extend_tile_info;
2628   state->m_extend_sprite_info_ptr = extend_sprite_info;
26312629}
26322630
26332631
r11160r11161
26802678
26812679static DRIVER_INIT( gmgalax )
26822680{
2681   galaxian_state *state = machine.driver_data<galaxian_state>();
26832682   address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
26842683
26852684   /* video extensions */
r11160r11161
26912690
26922691   /* callback when the game select is toggled */
26932692   gmgalax_game_changed(machine.m_portlist.first()->fieldlist, NULL, 0, 0);
2694   state_save_register_global(machine, gmgalax_selected_game);
2693   state_save_register_global(machine, state->m_gmgalax_selected_game);
26952694}
26962695
26972696
r11160r11161
27982797
27992798static READ8_HANDLER( tenspot_dsw_read )
28002799{
2800   galaxian_state *state = space->machine().driver_data<galaxian_state>();
28012801   char tmp[64];
2802   sprintf(tmp,"IN2_GAME%d", tenspot_current_game);
2802   sprintf(tmp,"IN2_GAME%d", state->m_tenspot_current_game);
28032803   return input_port_read_safe(space->machine(), tmp, 0x00);
28042804}
28052805
r11160r11161
28492849
28502850static DRIVER_INIT( tenspot )
28512851{
2852   galaxian_state *state = machine.driver_data<galaxian_state>();
28522853   address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
28532854
28542855   /* these are needed for batman part 2 to work properly, this banking is probably a property of the artic board,
r11160r11161
28652866
28662867   space->install_legacy_write_handler(0x6002, 0x6002, 0, 0x7f8, FUNC(artic_gfxbank_w));
28672868
2868   tenspot_current_game = 0;
2869   state->m_tenspot_current_game = 0;
28692870
2870   tenspot_set_game_bank(machine, tenspot_current_game, 0);
2871   tenspot_set_game_bank(machine, state->m_tenspot_current_game, 0);
28712872
28722873   space->install_legacy_read_handler(0x7000, 0x7000, FUNC(tenspot_dsw_read));
28732874}
r11160r11161
28762877
28772878static DRIVER_INIT( devilfsg )
28782879{
2880   galaxian_state *state = machine.driver_data<galaxian_state>();
28792881   /* video extensions */
28802882   common_init(machine, galaxian_draw_bullet, galaxian_draw_background, NULL, NULL);
28812883
28822884   /* IRQ line is INT, not NMI */
2883   irq_line = 0;
2885   state->m_irq_line = 0;
28842886}
28852887
28862888
28872889static DRIVER_INIT( zigzag )
28882890{
2891   galaxian_state *state = machine.driver_data<galaxian_state>();
28892892   address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
28902893
28912894   /* video extensions */
28922895   common_init(machine, NULL, galaxian_draw_background, NULL, NULL);
2893   galaxian_draw_bullet_ptr = NULL;
2896   state->m_draw_bullet_ptr = NULL;
28942897
28952898   /* make ROMs 2 & 3 swappable */
28962899   space->install_read_bank(0x2000, 0x2fff, "bank1");
r11160r11161
30443047
30453048static DRIVER_INIT( mshuttle )
30463049{
3050   galaxian_state *state = machine.driver_data<galaxian_state>();
30473051   static const UINT8 convtable[8][16] =
30483052   {
30493053      /* -1 marks spots which are unused and therefore unknown */
r11160r11161
30613065   common_init(machine, mshuttle_draw_bullet, galaxian_draw_background, mshuttle_extend_tile_info, mshuttle_extend_sprite_info);
30623066
30633067   /* IRQ line is INT, not NMI */
3064   irq_line = 0;
3068   state->m_irq_line = 0;
30653069
30663070   /* decrypt the code */
30673071   mshuttle_decode(machine, convtable);
r11160r11161
30703074
30713075static DRIVER_INIT( mshuttlj )
30723076{
3077   galaxian_state *state = machine.driver_data<galaxian_state>();
30733078   static const UINT8 convtable[8][16] =
30743079   {
30753080      { 0x41,0x54,0x51,0x14,0x05,0x10,0x01,0x55,0x44,0x11,0x00,0x50,0x15,0x40,0x04,0x45 },
r11160r11161
30863091   common_init(machine, mshuttle_draw_bullet, galaxian_draw_background, mshuttle_extend_tile_info, mshuttle_extend_sprite_info);
30873092
30883093   /* IRQ line is INT, not NMI */
3089   irq_line = 0;
3094   state->m_irq_line = 0;
30903095
30913096   /* decrypt the code */
30923097   mshuttle_decode(machine, convtable);
r11160r11161
30953100
30963101static DRIVER_INIT( kingball )
30973102{
3103   galaxian_state *state = machine.driver_data<galaxian_state>();
30983104   address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
30993105
31003106   /* video extensions */
r11160r11161
31053111   space->install_legacy_write_handler(0xb002, 0xb002, 0, 0x7f8, FUNC(kingball_sound2_w));
31063112   space->install_legacy_write_handler(0xb003, 0xb003, 0, 0x7f8, FUNC(kingball_speech_dip_w));
31073113
3108   state_save_register_global(machine, kingball_speech_dip);
3109   state_save_register_global(machine, kingball_sound);
3114   state_save_register_global(machine, state->m_kingball_speech_dip);
3115   state_save_register_global(machine, state->m_kingball_sound);
31103116}
31113117
31123118
r11160r11161
31973203
31983204static DRIVER_INIT( sfx )
31993205{
3206   galaxian_state *state = machine.driver_data<galaxian_state>();
32003207   /* basic configuration */
32013208   common_init(machine, scramble_draw_bullet, scramble_draw_background, upper_extend_tile_info, NULL);
3202   galaxian_sfx_tilemap = TRUE;
3209   state->m_sfx_tilemap = TRUE;
32033210
32043211   /* sound board has space for extra ROM */
32053212   machine.device("audiocpu")->memory().space(AS_PROGRAM)->install_read_bank(0x0000, 0x3fff, "bank1");
r11160r11161
32393246
32403247static DRIVER_INIT( frogger )
32413248{
3249   galaxian_state *state = machine.driver_data<galaxian_state>();
32423250   /* video extensions */
32433251   common_init(machine, NULL, frogger_draw_background, frogger_extend_tile_info, frogger_extend_sprite_info);
3244   galaxian_frogger_adjust = TRUE;
3252   state->m_frogger_adjust = TRUE;
32453253
32463254   /* decrypt */
32473255   decode_frogger_sound(machine);
r11160r11161
33673375
33683376static DRIVER_INIT( moonwar )
33693377{
3378   galaxian_state *state = machine.driver_data<galaxian_state>();
33703379   /* video extensions */
33713380   common_init(machine, scramble_draw_bullet, scramble_draw_background, NULL, NULL);
33723381
3373   state_save_register_global(machine, moonwar_port_select);
3382   state_save_register_global(machine, state->m_moonwar_port_select);
33743383}
33753384
33763385
src/mame/drivers/arcadecl.c
r11160r11161
6969#include "emu.h"
7070#include "cpu/m68000/m68000.h"
7171#include "sound/okim6295.h"
72#include "video/atarimo.h"
7273#include "includes/arcadecl.h"
7374
7475
r11160r11161
155156   AM_RANGE(0x000000, 0x0fffff) AM_ROM
156157   AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE_MEMBER(arcadecl_state, m_bitmap)
157158   AM_RANGE(0x3c0000, 0x3c07ff) AM_RAM_WRITE(atarigen_expanded_666_paletteram_w) AM_BASE_GENERIC(paletteram)
158   AM_RANGE(0x3e0000, 0x3e07ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
159   AM_RANGE(0x3e0000, 0x3e07ff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
159160   AM_RANGE(0x3e0800, 0x3effbf) AM_RAM
160   AM_RANGE(0x3effc0, 0x3effff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
161   AM_RANGE(0x3effc0, 0x3effff) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
161162   AM_RANGE(0x640000, 0x640001) AM_READ_PORT("PLAYER1")
162163   AM_RANGE(0x640002, 0x640003) AM_READ_PORT("PLAYER2")
163164   AM_RANGE(0x640010, 0x640011) AM_READ_PORT("STATUS")
src/mame/drivers/lordgun.c
r11160r11161
271271   AM_RANGE(0x000000, 0x0fffff) AM_ROM
272272   AM_RANGE(0x200000, 0x20ffff) AM_RAM
273273   AM_RANGE(0x210000, 0x21ffff) AM_RAM AM_BASE_MEMBER(lordgun_state, m_priority_ram)                  // PRIORITY
274   AM_RANGE(0x300000, 0x30ffff) AM_RAM_WRITE(lordgun_vram_0_w) AM_BASE_MEMBER(lordgun_state, m_vram_0)   // DISPLAY
275   AM_RANGE(0x310000, 0x313fff) AM_RAM_WRITE(lordgun_vram_1_w) AM_BASE_MEMBER(lordgun_state, m_vram_1)   // DISPLAY
276   AM_RANGE(0x314000, 0x314fff) AM_RAM_WRITE(lordgun_vram_2_w) AM_BASE_MEMBER(lordgun_state, m_vram_2)   // DISPLAY
274   AM_RANGE(0x300000, 0x30ffff) AM_RAM_WRITE(lordgun_vram_0_w) AM_BASE_MEMBER(lordgun_state, m_vram[0])   // DISPLAY
275   AM_RANGE(0x310000, 0x313fff) AM_RAM_WRITE(lordgun_vram_1_w) AM_BASE_MEMBER(lordgun_state, m_vram[1])   // DISPLAY
276   AM_RANGE(0x314000, 0x314fff) AM_RAM_WRITE(lordgun_vram_2_w) AM_BASE_MEMBER(lordgun_state, m_vram[2])   // DISPLAY
277277   AM_RANGE(0x315000, 0x317fff) AM_RAM                                          //
278   AM_RANGE(0x318000, 0x319fff) AM_RAM_WRITE(lordgun_vram_3_w) AM_BASE_MEMBER(lordgun_state, m_vram_3)   // DISPLAY
278   AM_RANGE(0x318000, 0x319fff) AM_RAM_WRITE(lordgun_vram_3_w) AM_BASE_MEMBER(lordgun_state, m_vram[3])   // DISPLAY
279279   AM_RANGE(0x31c000, 0x31c7ff) AM_RAM AM_BASE_MEMBER(lordgun_state, m_scrollram)                     // LINE
280280   AM_RANGE(0x400000, 0x4007ff) AM_RAM AM_BASE_SIZE_MEMBER(lordgun_state, m_spriteram, m_spriteram_size)                  // ANIMATOR
281281   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(lordgun_paletteram_w) AM_BASE_GENERIC(paletteram)
282   AM_RANGE(0x502000, 0x502001) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x_0)
283   AM_RANGE(0x502200, 0x502201) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x_1)
284   AM_RANGE(0x502400, 0x502401) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x_2)
285   AM_RANGE(0x502600, 0x502601) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x_3)
286   AM_RANGE(0x502800, 0x502801) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y_0)
287   AM_RANGE(0x502a00, 0x502a01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y_1)
288   AM_RANGE(0x502c00, 0x502c01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y_2)
289   AM_RANGE(0x502e00, 0x502e01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y_3)
282   AM_RANGE(0x502000, 0x502001) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x[0])
283   AM_RANGE(0x502200, 0x502201) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x[1])
284   AM_RANGE(0x502400, 0x502401) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x[2])
285   AM_RANGE(0x502600, 0x502601) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x[3])
286   AM_RANGE(0x502800, 0x502801) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y[0])
287   AM_RANGE(0x502a00, 0x502a01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y[1])
288   AM_RANGE(0x502c00, 0x502c01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y[2])
289   AM_RANGE(0x502e00, 0x502e01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y[3])
290290   AM_RANGE(0x503000, 0x503001) AM_WRITE(lordgun_priority_w)
291291   AM_RANGE(0x503800, 0x503801) AM_READ(lordgun_gun_0_x_r)
292292   AM_RANGE(0x503a00, 0x503a01) AM_READ(lordgun_gun_1_x_r)
r11160r11161
303303   AM_RANGE(0x000000, 0x1fffff) AM_ROM
304304   AM_RANGE(0x200000, 0x20ffff) AM_RAM
305305   AM_RANGE(0x210000, 0x21ffff) AM_RAM AM_BASE_MEMBER(lordgun_state, m_priority_ram)                  // PRIORITY
306   AM_RANGE(0x300000, 0x30ffff) AM_RAM_WRITE(lordgun_vram_0_w) AM_BASE_MEMBER(lordgun_state, m_vram_0)   // BACKGROUND 1
307   AM_RANGE(0x310000, 0x313fff) AM_RAM_WRITE(lordgun_vram_1_w) AM_BASE_MEMBER(lordgun_state, m_vram_1)   // BACKGROUND 2
308   AM_RANGE(0x314000, 0x314fff) AM_RAM_WRITE(lordgun_vram_2_w) AM_BASE_MEMBER(lordgun_state, m_vram_2)   // BACKGROUND 3
306   AM_RANGE(0x300000, 0x30ffff) AM_RAM_WRITE(lordgun_vram_0_w) AM_BASE_MEMBER(lordgun_state, m_vram[0])   // BACKGROUND 1
307   AM_RANGE(0x310000, 0x313fff) AM_RAM_WRITE(lordgun_vram_1_w) AM_BASE_MEMBER(lordgun_state, m_vram[1])   // BACKGROUND 2
308   AM_RANGE(0x314000, 0x314fff) AM_RAM_WRITE(lordgun_vram_2_w) AM_BASE_MEMBER(lordgun_state, m_vram[2])   // BACKGROUND 3
309309   AM_RANGE(0x315000, 0x317fff) AM_RAM                                          //
310   AM_RANGE(0x318000, 0x319fff) AM_RAM_WRITE(lordgun_vram_3_w) AM_BASE_MEMBER(lordgun_state, m_vram_3)   // TEXT
310   AM_RANGE(0x318000, 0x319fff) AM_RAM_WRITE(lordgun_vram_3_w) AM_BASE_MEMBER(lordgun_state, m_vram[3])   // TEXT
311311   AM_RANGE(0x31c000, 0x31c7ff) AM_RAM AM_BASE_MEMBER(lordgun_state, m_scrollram)                     // LINE OFFSET
312312   AM_RANGE(0x400000, 0x4007ff) AM_RAM AM_BASE_SIZE_MEMBER(lordgun_state, m_spriteram, m_spriteram_size)                  // ANIMATE
313313   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(lordgun_paletteram_w) AM_BASE_GENERIC(paletteram)
314   AM_RANGE(0x502000, 0x502001) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x_0)
315   AM_RANGE(0x502200, 0x502201) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x_1)
316   AM_RANGE(0x502400, 0x502401) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x_2)
317   AM_RANGE(0x502600, 0x502601) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x_3)
318   AM_RANGE(0x502800, 0x502801) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y_0)
319   AM_RANGE(0x502a00, 0x502a01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y_1)
320   AM_RANGE(0x502c00, 0x502c01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y_2)
321   AM_RANGE(0x502e00, 0x502e01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y_3)
314   AM_RANGE(0x502000, 0x502001) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x[0])
315   AM_RANGE(0x502200, 0x502201) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x[1])
316   AM_RANGE(0x502400, 0x502401) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x[2])
317   AM_RANGE(0x502600, 0x502601) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_x[3])
318   AM_RANGE(0x502800, 0x502801) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y[0])
319   AM_RANGE(0x502a00, 0x502a01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y[1])
320   AM_RANGE(0x502c00, 0x502c01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y[2])
321   AM_RANGE(0x502e00, 0x502e01) AM_WRITEONLY AM_BASE_MEMBER(lordgun_state, m_scroll_y[3])
322322   AM_RANGE(0x503000, 0x503001) AM_WRITE(lordgun_priority_w)
323323   AM_RANGE(0x504000, 0x504001) AM_WRITE(lordgun_soundlatch_w)
324324   AM_RANGE(0x506000, 0x506007) AM_DEVREADWRITE8("ppi8255_0", ppi8255_r, ppi8255_w, 0x00ff)
src/mame/drivers/segag80r.c
r11160r11161
160160}
161161
162162
163static MACHINE_RESET( pignewt )
164{
165   sega_usb_reset(machine, 0x10);
166}
167163
168
169
170164/*************************************
171165 *
172166 *  RAM writes/decryption
r11160r11161
196190static WRITE8_HANDLER( monsterb_vidram_w ) { monsterb_videoram_w(space, decrypt_offset(space, offset), data); }
197191static WRITE8_HANDLER( pignewt_vidram_w )  { pignewt_videoram_w(space, decrypt_offset(space, offset), data); }
198192static WRITE8_HANDLER( sindbadm_vidram_w ) { sindbadm_videoram_w(space, decrypt_offset(space, offset), data); }
199static WRITE8_HANDLER( usb_ram_w )         { sega_usb_ram_w(space, decrypt_offset(space, offset), data); }
193static WRITE8_DEVICE_HANDLER( usb_ram_w )         { sega_usb_ram_w(device, decrypt_offset(device->machine().device("maincpu")->memory().space(AS_PROGRAM), offset), data); }
200194
201195
202196
r11160r11161
916910   MCFG_PALETTE_LENGTH(64+64)
917911
918912   /* sound boards */
919   MCFG_MACHINE_RESET(pignewt)
920913   MCFG_FRAGMENT_ADD(sega_universal_sound_board)
921914MACHINE_CONFIG_END
922915
r11160r11161
14391432static DRIVER_INIT( astrob )
14401433{
14411434   segag80r_state *state = machine.driver_data<segag80r_state>();
1435   device_t *speech = machine.device("segaspeech");
1436   address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
14421437
14431438   /* configure the 315-0062 security chip */
14441439   state->m_decrypt = segag80_security(62);
r11160r11161
14471442   state->m_background_pcb = G80_BACKGROUND_NONE;
14481443
14491444   /* install speech board */
1450   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x38, 0x38, FUNC(sega_speech_data_w));
1451   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x3b, 0x3b, FUNC(sega_speech_control_w));
1445   iospace->install_legacy_write_handler(*speech, 0x38, 0x38, FUNC(sega_speech_data_w));
1446   iospace->install_legacy_write_handler(*speech, 0x3b, 0x3b, FUNC(sega_speech_control_w));
14521447
14531448   /* install Astro Blaster sound board */
1454   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x3e, 0x3f, FUNC(astrob_sound_w));
1449   iospace->install_legacy_write_handler(0x3e, 0x3f, FUNC(astrob_sound_w));
14551450}
14561451
14571452
r11160r11161
14701465static DRIVER_INIT( spaceod )
14711466{
14721467   segag80r_state *state = machine.driver_data<segag80r_state>();
1468   address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
14731469
14741470   /* configure the 315-0063 security chip */
14751471   state->m_decrypt = segag80_security(63);
r11160r11161
14781474   state->m_background_pcb = G80_BACKGROUND_SPACEOD;
14791475
14801476   /* configure ports for the background board */
1481   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_readwrite_handler(0x08, 0x0f, FUNC(spaceod_back_port_r), FUNC(spaceod_back_port_w));
1477   iospace->install_legacy_readwrite_handler(0x08, 0x0f, FUNC(spaceod_back_port_r), FUNC(spaceod_back_port_w));
14821478
14831479   /* install Space Odyssey sound board */
1484   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x0e, 0x0f, FUNC(spaceod_sound_w));
1480   iospace->install_legacy_write_handler(0x0e, 0x0f, FUNC(spaceod_sound_w));
14851481
14861482   /* install our wacky mangled ports */
1487   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0xf8, 0xfb, FUNC(spaceod_mangled_ports_r));
1488   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0xfc, 0xfc, FUNC(spaceod_port_fc_r));
1483   iospace->install_legacy_read_handler(0xf8, 0xfb, FUNC(spaceod_mangled_ports_r));
1484   iospace->install_legacy_read_handler(0xfc, 0xfc, FUNC(spaceod_port_fc_r));
14891485}
14901486
14911487
14921488static DRIVER_INIT( monsterb )
14931489{
14941490   segag80r_state *state = machine.driver_data<segag80r_state>();
1491   address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
1492   address_space *pgmspace = machine.device("maincpu")->memory().space(AS_PROGRAM);
14951493
14961494   /* configure the 315-0082 security chip */
14971495   state->m_decrypt = segag80_security(82);
r11160r11161
15011499   monsterb_expand_gfx(machine, "gfx1");
15021500
15031501   /* install background board handlers */
1504   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0xb8, 0xbd, FUNC(monsterb_back_port_w));
1505   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xe000, 0xffff, FUNC(monsterb_vidram_w));
1502   iospace->install_legacy_write_handler(0xb8, 0xbd, FUNC(monsterb_back_port_w));
1503   pgmspace->install_legacy_write_handler(0xe000, 0xffff, FUNC(monsterb_vidram_w));
15061504}
15071505
15081506
15091507static DRIVER_INIT( monster2 )
15101508{
15111509   segag80r_state *state = machine.driver_data<segag80r_state>();
1510   address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
1511   address_space *pgmspace = machine.device("maincpu")->memory().space(AS_PROGRAM);
15121512
15131513   /* configure the 315-5006 security chip */
15141514   spatter_decode(machine, "maincpu");
r11160r11161
15191519   monsterb_expand_gfx(machine, "gfx1");
15201520
15211521   /* install background board handlers */
1522   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0xb4, 0xb5, FUNC(pignewt_back_color_w));
1523   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0xb8, 0xbd, FUNC(pignewt_back_port_w));
1524   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xe000, 0xffff, FUNC(pignewt_vidram_w));
1522   iospace->install_legacy_write_handler(0xb4, 0xb5, FUNC(pignewt_back_color_w));
1523   iospace->install_legacy_write_handler(0xb8, 0xbd, FUNC(pignewt_back_port_w));
1524   pgmspace->install_legacy_write_handler(0xe000, 0xffff, FUNC(pignewt_vidram_w));
15251525}
15261526
15271527
15281528static DRIVER_INIT( pignewt )
15291529{
15301530   segag80r_state *state = machine.driver_data<segag80r_state>();
1531   device_t *usbsnd = machine.device("usbsnd");
1532   address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
1533   address_space *pgmspace = machine.device("maincpu")->memory().space(AS_PROGRAM);
15311534
15321535   /* configure the 315-0063? security chip */
15331536   state->m_decrypt = segag80_security(63);
r11160r11161
15371540   monsterb_expand_gfx(machine, "gfx1");
15381541
15391542   /* install background board handlers */
1540   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0xb4, 0xb5, FUNC(pignewt_back_color_w));
1541   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0xb8, 0xbd, FUNC(pignewt_back_port_w));
1542   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xe000, 0xffff, FUNC(pignewt_vidram_w));
1543   iospace->install_legacy_write_handler(0xb4, 0xb5, FUNC(pignewt_back_color_w));
1544   iospace->install_legacy_write_handler(0xb8, 0xbd, FUNC(pignewt_back_port_w));
1545   pgmspace->install_legacy_write_handler(0xe000, 0xffff, FUNC(pignewt_vidram_w));
15431546
15441547   /* install Universal sound board */
1545   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_readwrite_handler(0x3f, 0x3f, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
1546   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xd000, 0xdfff, FUNC(sega_usb_ram_r), FUNC(usb_ram_w));
1548   iospace->install_legacy_readwrite_handler(*usbsnd, 0x3f, 0x3f, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
1549   pgmspace->install_legacy_readwrite_handler(*usbsnd, 0xd000, 0xdfff, FUNC(sega_usb_ram_r), FUNC(usb_ram_w));
15471550}
15481551
15491552
15501553static DRIVER_INIT( sindbadm )
15511554{
15521555   segag80r_state *state = machine.driver_data<segag80r_state>();
1556   address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
1557   address_space *pgmspace = machine.device("maincpu")->memory().space(AS_PROGRAM);
15531558
15541559   /* configure the encrypted Z80 */
15551560   sindbadm_decode(machine, "maincpu");
r11160r11161
15591564   state->m_background_pcb = G80_BACKGROUND_SINDBADM;
15601565
15611566   /* install background board handlers */
1562   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x40, 0x41, FUNC(sindbadm_back_port_w));
1563   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xe000, 0xffff, FUNC(sindbadm_vidram_w));
1567   iospace->install_legacy_write_handler(0x40, 0x41, FUNC(sindbadm_back_port_w));
1568   pgmspace->install_legacy_write_handler(0xe000, 0xffff, FUNC(sindbadm_vidram_w));
15641569}
15651570
15661571
src/mame/drivers/blitz68k.c
r11160r11161
5555   UINT16 *m_blit_dst_ram_hiword;
5656   UINT16 *m_blit_vregs;
5757   UINT16 *m_blit_transpen;
58   UINT16 *m_leds[3];
5859};
5960
6061/*************************************************************************************************************
r11160r11161
542543    Outputs
543544*************************************************************************************************************/
544545
545UINT16 *leds1, *leds2, *leds3;
546
547static void show_leds123()
546static void show_leds123(blitz68k_state *state)
548547{
549548#ifdef MAME_DEBUG
550   popmessage("led %02x %02x %02x", leds1[0]>>8, leds2[0]>>8, leds3[0]>>8);
549   popmessage("led %02x %02x %02x", state->m_leds[0][0]>>8, state->m_leds[1][0]>>8, state->m_leds[2][0]>>8);
551550#endif
552551}
553static void show_leds12()
552static void show_leds12(blitz68k_state *state)
554553{
555554#ifdef MAME_DEBUG
556   popmessage("led %02x %02x", leds1[0]>>8, leds2[0]>>8);
555   popmessage("led %02x %02x", state->m_leds[0][0]>>8, state->m_leds[1][0]>>8);
557556#endif
558557}
559558
r11160r11161
825824
826825static WRITE16_HANDLER( cjffruit_leds1_w )
827826{
828   data = COMBINE_DATA(leds1);
827   blitz68k_state *state = space->machine().driver_data<blitz68k_state>();
828   data = COMBINE_DATA(state->m_leds[0]);
829829   if (ACCESSING_BITS_8_15)
830830   {
831831      coin_counter_w(space->machine(), 0, data & 0x0100);   // coin in
r11160r11161
836836      set_led_status(space->machine(), 4, data & 0x2000);   // take
837837      set_led_status(space->machine(), 5, data & 0x4000);   // double up
838838      set_led_status(space->machine(), 6, data & 0x8000);   // cancel
839      show_leds123();
839      show_leds123(state);
840840   }
841841}
842842
843843static WRITE16_HANDLER( cjffruit_leds2_w )
844844{
845   data = COMBINE_DATA(leds2);
845   blitz68k_state *state = space->machine().driver_data<blitz68k_state>();
846   data = COMBINE_DATA(state->m_leds[1]);
846847   if (ACCESSING_BITS_8_15)
847848   {
848849      set_led_status(space->machine(),  7, data & 0x0100);   // start
r11160r11161
853854      set_led_status(space->machine(), 12, data & 0x2000);   // hold 2
854855      set_led_status(space->machine(), 13, data & 0x4000);   // collect
855856      set_led_status(space->machine(), 14, data & 0x8000);   // call attendant
856      show_leds123();
857      show_leds123(state);
857858   }
858859}
859860
860861static WRITE16_HANDLER( cjffruit_leds3_w )
861862{
862   data = COMBINE_DATA(leds3);
863   blitz68k_state *state = space->machine().driver_data<blitz68k_state>();
864   data = COMBINE_DATA(state->m_leds[2]);
863865   if (ACCESSING_BITS_8_15)
864866   {
865867      set_led_status(space->machine(), 15, data & 0x0100);   // hopper coins?
866868      set_led_status(space->machine(), 16, data & 0x0400);   // coin out?
867      show_leds123();
869      show_leds123(state);
868870   }
869871}
870872
r11160r11161
929931
930932   AM_RANGE(0x8e0000, 0x8e0001) AM_WRITE( cjffruit_mcu_w )
931933
932   AM_RANGE(0x8f8000, 0x8f8001) AM_WRITE(cjffruit_leds1_w) AM_BASE(&leds1)
933   AM_RANGE(0x8fa000, 0x8fa001) AM_WRITE(cjffruit_leds2_w) AM_BASE(&leds2)
934   AM_RANGE(0x8fc000, 0x8fc001) AM_WRITE(cjffruit_leds3_w) AM_BASE(&leds3)
934   AM_RANGE(0x8f8000, 0x8f8001) AM_WRITE(cjffruit_leds1_w) AM_BASE_MEMBER(blitz68k_state, m_leds[0])
935   AM_RANGE(0x8fa000, 0x8fa001) AM_WRITE(cjffruit_leds2_w) AM_BASE_MEMBER(blitz68k_state, m_leds[1])
936   AM_RANGE(0x8fc000, 0x8fc001) AM_WRITE(cjffruit_leds3_w) AM_BASE_MEMBER(blitz68k_state, m_leds[2])
935937
936938   AM_RANGE(0x8fe000, 0x8fe003) AM_WRITE8(blit_flags_w, 0xffff)   // flipx,y,solid,trans
937939   AM_RANGE(0x8fe004, 0x8fe005) AM_WRITEONLY
r11160r11161
959961
960962static WRITE16_HANDLER( deucesw2_leds1_w )
961963{
962   data = COMBINE_DATA(leds1);
964   blitz68k_state *state = space->machine().driver_data<blitz68k_state>();
965   data = COMBINE_DATA(state->m_leds[0]);
963966   if (ACCESSING_BITS_8_15)
964967   {
965968      coin_counter_w(space->machine(), 0, data & 0x0100);   // coin in
r11160r11161
970973      set_led_status(space->machine(), 4, data & 0x2000);   // take
971974      set_led_status(space->machine(), 5, data & 0x4000);   // double up
972975      set_led_status(space->machine(), 6, data & 0x8000);   // cancel
973      show_leds123();
976      show_leds123(state);
974977   }
975978}
976979
977980static WRITE16_HANDLER( deucesw2_leds2_w )
978981{
979   data = COMBINE_DATA(leds2);
982   blitz68k_state *state = space->machine().driver_data<blitz68k_state>();
983   data = COMBINE_DATA(state->m_leds[1]);
980984   if (ACCESSING_BITS_8_15)
981985   {
982986      set_led_status(space->machine(),  7, data & 0x0100);   // start
r11160r11161
987991      set_led_status(space->machine(), 12, data & 0x2000);   // hold 2
988992      set_led_status(space->machine(), 13, data & 0x4000);   // hold 1
989993      set_led_status(space->machine(), 14, data & 0x8000);   // call attendant
990      show_leds123();
994      show_leds123(state);
991995   }
992996}
993997
994998static WRITE16_HANDLER( deucesw2_leds3_w )
995999{
996   data = COMBINE_DATA(leds3);
1000   blitz68k_state *state = space->machine().driver_data<blitz68k_state>();
1001   data = COMBINE_DATA(state->m_leds[2]);
9971002   if (ACCESSING_BITS_8_15)
9981003   {
9991004      set_led_status(space->machine(), 15, data & 0x0100);   // hopper coins?
10001005      set_led_status(space->machine(), 16, data & 0x0400);   // coin out?
1001      show_leds123();
1006      show_leds123(state);
10021007   }
10031008}
10041009
r11160r11161
10251030
10261031   AM_RANGE(0x896000, 0x896001) AM_WRITE( deucesw2_mcu_w )
10271032
1028   AM_RANGE(0x898000, 0x898001) AM_WRITE(deucesw2_leds1_w) AM_BASE(&leds1)
1029   AM_RANGE(0x89a000, 0x89a001) AM_WRITE(deucesw2_leds2_w) AM_BASE(&leds2)
1030   AM_RANGE(0x89c000, 0x89c001) AM_WRITE(deucesw2_leds3_w) AM_BASE(&leds3)
1033   AM_RANGE(0x898000, 0x898001) AM_WRITE(deucesw2_leds1_w) AM_BASE_MEMBER(blitz68k_state, m_leds[0])
1034   AM_RANGE(0x89a000, 0x89a001) AM_WRITE(deucesw2_leds2_w) AM_BASE_MEMBER(blitz68k_state, m_leds[1])
1035   AM_RANGE(0x89c000, 0x89c001) AM_WRITE(deucesw2_leds3_w) AM_BASE_MEMBER(blitz68k_state, m_leds[2])
10311036
10321037   AM_RANGE(0x89e000, 0x89e003) AM_WRITE8(blit_flags_w, 0xffff)   // flipx,y,solid,trans
10331038   AM_RANGE(0x89e004, 0x89e005) AM_WRITEONLY
r11160r11161
11431148
11441149static WRITE16_HANDLER( hermit_leds1_w )
11451150{
1146   data = COMBINE_DATA(leds1);
1151   blitz68k_state *state = space->machine().driver_data<blitz68k_state>();
1152   data = COMBINE_DATA(state->m_leds[0]);
11471153   if (ACCESSING_BITS_8_15)
11481154   {
11491155      coin_counter_w(space->machine(), 0, data & 0x0100);   // coin in
1150      show_leds12();
1156      show_leds12(state);
11511157   }
11521158}
11531159
11541160static WRITE16_HANDLER( hermit_leds2_w )
11551161{
1156   data = COMBINE_DATA(leds2);
1162   blitz68k_state *state = space->machine().driver_data<blitz68k_state>();
1163   data = COMBINE_DATA(state->m_leds[1]);
11571164   if (ACCESSING_BITS_8_15)
11581165   {
11591166      set_led_status(space->machine(),  7, data & 0x0100);   // button
1160      show_leds12();
1167      show_leds12(state);
11611168   }
11621169}
11631170
r11160r11161
11911198   AM_RANGE(0x9d0000, 0x9d0001) AM_READ_PORT("IN2")
11921199   AM_RANGE(0x9d8000, 0x9d8001) AM_READ_PORT("DSW")
11931200
1194   AM_RANGE(0x9e0000, 0x9e0001) AM_WRITE(hermit_leds1_w) AM_BASE(&leds1)
1195   AM_RANGE(0x9e8000, 0x9e8001) AM_WRITE(hermit_leds2_w) AM_BASE(&leds2)
1201   AM_RANGE(0x9e0000, 0x9e0001) AM_WRITE(hermit_leds1_w) AM_BASE_MEMBER(blitz68k_state, m_leds[0])
1202   AM_RANGE(0x9e8000, 0x9e8001) AM_WRITE(hermit_leds2_w) AM_BASE_MEMBER(blitz68k_state, m_leds[1])
11961203
11971204   AM_RANGE(0x9f0000, 0x9f0003) AM_WRITE8(blit_flags_w, 0xffff)   // flipx,y,solid,trans
11981205   AM_RANGE(0x9f0004, 0x9f0005) AM_WRITEONLY
src/mame/drivers/skullxbo.c
r11160r11161
2020#include "emu.h"
2121#include "cpu/m68000/m68000.h"
2222#include "audio/atarijsa.h"
23#include "video/atarimo.h"
2324#include "includes/skullxbo.h"
2425
2526
r11160r11161
151152   AM_RANGE(0xff8000, 0xff9fff) AM_RAM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE_MEMBER(skullxbo_state, m_playfield)
152153   AM_RANGE(0xffa000, 0xffbfff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(skullxbo_state, m_playfield_upper)
153154   AM_RANGE(0xffc000, 0xffcf7f) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(skullxbo_state, m_alpha)
154   AM_RANGE(0xffcf80, 0xffcfff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
155   AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
155   AM_RANGE(0xffcf80, 0xffcfff) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
156   AM_RANGE(0xffd000, 0xffdfff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
156157   AM_RANGE(0xffe000, 0xffffff) AM_RAM
157158ADDRESS_MAP_END
158159
src/mame/drivers/cps3.c
r11160r11161
5252Capcom, 1996-1999
5353
5454From late 1996 to 1999 Capcom developed another hardware platform to rival the CPS2 System and called
55it CP SYSTEM III. Only 6 games were produced....
55it CP SYSTEM III. Only 6 games were produced. Here's a detailed table of all known releases until now:
5656
57Game                                                 Date   S/W Rev        CD Part#     Label         Cart Part#
58----------------------------------------------------------------------------------------------------------------
59JoJo no Kimyouna Bouken / JoJo's Venture             1998   98/12/02       CAP-JJK000   CAP-JJK-140   JJK98c00F
60                                                            99/01/08                    CAP-JJK-160
61                                                            99/01/28 **
62JoJo no Kimyouna Bouken  Miraie no Isan
63/ JoJo's Bizarre Adventure Heritage for the Future   1999   99/09/13       CAP-JJM000   CAP-JJM-110   JJM99900F
64                                                            99/09/27 **
57                                                           |--------------- Cart ----------------|  |--------------- CD --------------|
58Game                                                 Year  Part #     Label      Region  CD  NO CD  Part #      Catalog #   Label        Revision
59---------------------------------------------------  ----  ---------  ---------  ------  --  -----  ----------  ----------  -----------  --------
60Warzard                                              1996  WZD96a00F  CP300000G  JAPAN   X          CAP-WZD000  CAP-WZD-3   CAP-WZD-3    961023
61Warzard                                                    WZD96a00F  CP300000G  JAPAN   X          CAP-WZD000  CAP-WZD-5   CAP-WZD-5    961121
62Red Earth                                                  WZD96aA0F  CP3000B0G  EUROPE  X          CAP-WZD0A0  CAP-WZD-3   CAP-WZD-3    961023
63Red Earth                                                  WZD96aA0F  CP3000B0G  EUROPE  X          CAP-WZD0A0  CAP-WZD-5   CAP-WZD-5    961121
64Red Earth                                                  WZD96aA0F  CP3000H0G  MEXICO* X          CAP-WZD0A0  CAP-WZD-3   CAP-WZD-3    961023
65Red Earth                                                  WZD96aA0F  CP3000H0G  MEXICO* X          CAP-WZD0A0  CAP-WZD-5   CAP-WZD-5    961121
66Red Earth                                                  WZD96aA0F  CP3000U0G  USA*    X          CAP-WZD0A0  CAP-WZD-3   CAP-WZD-3    961023
67Red Earth                                                  WZD96aA0F  CP3000U0G  USA*    X          CAP-WZD0A0  CAP-WZD-5   CAP-WZD-5    961121
6568
66Street Fighter III New Generation                    1997   97/02/04       CAP-SF3000   CAP-SF3-3     SF397200F
69Street Fighter III: New Generation                   1997  SF397200F  CP300000G  JAPAN   X          CAP-SF3000  CAP-SF3-3   CAP-SF3-3    970204
70Street Fighter III: New Generation                         SF3972A0F  CP3000C0G  ASIA        X                                           970204
71Street Fighter III: New Generation                         SF3972A0F  CP3000H0G  MEXICO  X          CAP-SF30A0  CAP-SF3-3   CAP-SF3-3    970204
72Street Fighter III: New Generation                         SF3972A0F  CP3000U0G  USA     X          CAP-SF30A0  CAP-SF3-3   CAP-SF3-3    970204
6773
68Street Fighter III 2nd Impact Giant Attack           1997   97/09/30       CAP-3GA000   CAP-3GA-1     3GA97a00F
74Street Fighter III 2nd Impact: Giant Attack          1997  3GA97a00F  CP300000G  JAPAN   X          CAP-3GA000  CAP-3GA000  CAP-3GA-1    970930
75Street Fighter III 2nd Impact: Giant Attack                3GA97aA0F  CP3000C0G  ASIA        X                                           970930
76Street Fighter III 2nd Impact: Giant Attack                3GA97aA0F  CP3000U0G  USA     X          CAP-3GA0A0  CAP-3GA000  CAP-3GA-1    970930
6977
70Street Fighter III 3rd Strike Fight for the Future   1999   99/05/12       CAP-33S000   CAP-33S-1     33S99400F
71                                                            99/06/08                    CAP-33S-2
78JoJo no Kimyouna Bouken                              1998  JJK98c00F  CP300000G  JAPAN   X          CAP-JJK000  CAP-JJK000  CAP-JJK-140  981202
79JoJo no Kimyouna Bouken                                    JJK98c00F  CP300000G  JAPAN   X          CAP-JJK000  CAP-JJK-2   CAP-JJK-160  990108
80JoJo no Kimyouna Bouken                                    JJK98c00F  CP300000G  JAPAN   X          CAP-JJK000  ?           ?            990128*
81JoJo's Venture                                             JJK98cA0F  CP3000C0G  ASIA        X                                           981202
82JoJo's Venture                                             JJK98cA0F  CP3000C0G  ASIA        X                                           990108
83JoJo's Venture                                             JJK98cA0F  CP3000C0G  ASIA        X                                           990128*
84JoJo's Venture                                             JJK98cA0F  CP3000U0G  USA     X          CAP-JJK0A0  CAP-JJK000  CAP-JJK-140  981202
85JoJo's Venture                                             JJK98cA0F  CP3000U0G  USA     X          CAP-JJK0A0  CAP-JJK-2   CAP-JJK-160  990108
86JoJo's Venture                                             JJK98cA0F  CP3000U0G  USA     X          CAP-JJK0A0  ?           ?            990128*
7287
73Warzard / Red Earth                                  1996   96/11/21       CAP-WZD000   CAP-WZD-5     WZD96a00F
88Street Fighter III 3rd Strike: Fight for the Future  1999  33S99400F  CP300000G  JAPAN*  X          CAP-33S000  CAP-33S-1   CAP-33S-1    990512
89Street Fighter III 3rd Strike: Fight for the Future        33S99400F  CP300000G  JAPAN*  X          CAP-33S000  CAP-33S-2   CAP-33S-2    990608
90Street Fighter III 3rd Strike: Fight for the Future        33S99400F  CP300000G  JAPAN       X                                           990512
91Street Fighter III 3rd Strike: Fight for the Future        33S99400F  CP300000G  JAPAN       X                                           990608
92Street Fighter III 3rd Strike: Fight for the Future        33S994A0F  CP3000B0G  EUROPE* X          CAP-33S0A0  CAP-33S-1   CAP-33S-1    990512
93Street Fighter III 3rd Strike: Fight for the Future        33S994A0F  CP3000B0G  EUROPE* X          CAP-33S0A0  CAP-33S-2   CAP-33S-2    990608
94Street Fighter III 3rd Strike: Fight for the Future        33S994A0F  CP3000C0G  ASIA*   X          CAP-33S0A0  CAP-33S-1   CAP-33S-1    990512
95Street Fighter III 3rd Strike: Fight for the Future        33S994A0F  CP3000C0G  ASIA*   X          CAP-33S0A0  CAP-33S-2   CAP-33S-2    990608
96Street Fighter III 3rd Strike: Fight for the Future        33S994A0F  CP3000C0G  ASIA*       X                                           990512
97Street Fighter III 3rd Strike: Fight for the Future        33S994A0F  CP3000C0G  ASIA*       X                                           990608
98Street Fighter III 3rd Strike: Fight for the Future        33S994A0F  CP3000H0G  MEXICO* ?          CAP-33S0A0  CAP-33S-1   CAP-33S-1    990512
99Street Fighter III 3rd Strike: Fight for the Future        33S994A0F  CP3000H0G  MEXICO* ?          CAP-33S0A0  CAP-33S-2   CAP-33S-2    990608
100Street Fighter III 3rd Strike: Fight for the Future        33S994A0F  CP3000U0G  USA     X          CAP-33S0A0  CAP-33S-1   CAP-33S-1    990512
101Street Fighter III 3rd Strike: Fight for the Future        33S994A0F  CP3000U0G  USA     X          CAP-33S0A0  CAP-33S-2   CAP-33S-2    990608
74102
75** NOT DUMPED but known to exist
103JoJo no Kimyouna Bouken: Miraie no Isan              1999  JJM99900F  CP300000G  JAPAN   X          CAP-JJM000  CAP-JJM-0   CAP-JJM-110  990913
104JoJo no Kimyouna Bouken: Miraie no Isan                    JJM99900F  CP300000G  JAPAN   X          CAP-JJM000  ?           ?            990927*
105JoJo no Kimyouna Bouken: Miraie no Isan                    JJM99900F  CP300000G  JAPAN       X                                           990913
106JoJo no Kimyouna Bouken: Miraie no Isan                    JJM99900F  CP300000G  JAPAN       X                                           990927*
107JoJo's Bizarre Adventure                                   JJM999A0F  CP3000B0G  EUROPE      X                                           990913
108JoJo's Bizarre Adventure                                   JJM999A0F  CP3000B0G  EUROPE      X                                           990927*
76109
77The Game Region / No CD Flags / Development flags etc. are controlled by a byte in the bios roms.  The CDs
78contain revisions of the game code and are independent of the region.
110* NOT DUMPED but known to exist
79111
112Each game consists of a Cart and a CD having various codes needed to identify them. Carts and CDs have
113both a different Part # printed on their front/top side that includes the game Cart/CD code and ends
114respectively with 00F/000 for all Japan releases and with A0F/0A0 for all the other ones. Therefore,
115the Part # can be used only to identify Japan releases and further parameters need to be introduced.
116The Cart is responsible for the game Region that can be identified by a Label with coloured characters
117and a code printed on back side. The antepenultimate character of the Label code and the colour of the
118sticker vary by Region, exactly as happens on the boot screen when the board is powered on. There are two
119types of Carts. Some require the CD to boot, some don't since the game is already loaded into the SIMMs.
120Both types are externally identical and use the same codes, so the only way to distinguish them is dump
121the BIOSes. The game Region and CD/NO CD flags are controlled by two different bytes in the BIOS rom.
122The CD (and SIMMs too if the Cart is of type NO CD) contains the game Revision that can be identified
123by two codes, the Catalog # and the Label. The Catalog # is the identifying code printed in the mirror
124ring on top side close to the CD's center while the Label is the code appearing on the CD icon when
125it's inserted into a PC CD reader. It has been verified that the Catalog # and Label are the same for
126some games but quite different for some others, so it's better to check both to avoid confusion. It
127has also been verified that the Catalog # and Label (and the data on CDs) don't change between Regions,
128only between Revisions. However, knowing one of them and comparing it with the table above will help
129to understand if a new game Revision has been discovered. Current CD dumps have been documented using
130the Catalog # as name, since the Label is already included into the images used to generate CHDs.
131
80132The CP SYSTEM III comprises a main board with several custom ASICs, custom 72-pin SIMMs for program
81133and graphics storage (the same SIMMs are also used in some CPS2 titles), SCSI CDROM and CDROM disc,
82134and a plug-in security cart containing a boot ROM, an NVRAM and another custom ASIC containing vital
83135decryption information held by a [suicide] battery.
84136
85137Not much is known about the actual CPU used in this system due to the extensive use of encryption,
86and the volatile nature of the security information. There appears to be a custom Hitachi SH-2
87CPU on the mainboard and there has been confirmed to be one in the cart. Tests were done by decrypting
88the BIOS and code and running it on the PCB. It is known that neither of these CPU's will run standard
138and the volatile nature of the security information. There appears to be a custom Hitachi SH-2 CPU on
139the mainboard and there has been confirmed to be one in the cart. Tests were done by decrypting the
140BIOS and code and running it on the PCB. It is known that neither of these CPU's will run standard
89141(i.e. unencrypted) SH2 code.
90142
91The security cart is thought to work like this....  the flashROM in the cart contains a program BIOS which is
92decrypted by the CPU in the cart (the CPU has built-in decryption) then executed by that CPU to boot the BIOS
93code.  Even though the code in the flashROM is encrypted, the cart can run it even if it is dead/suicided because
94it has been discovered that the BIOS contains a hidden security menu allowing the cart to be loaded with the
95security data. This proves the cart runs the BIOS even if it is dead. The special security menu is not
96normally available but is likely accessed with a special key/button combination which is unknown ATM.
143The security cart is thought to work like this: the flashROM in the cart contains a program BIOS which is
144decrypted by the CPU in the cart (the CPU has built-in decryption) then executed by that CPU to boot the
145BIOS code. Even though the code in the flashROM is encrypted, the cart can run it even if it is dead/suicided
146because it has been discovered that the BIOS contains a hidden security menu allowing the cart to be loaded
147with the security data. This proves the cart runs the BIOS even if it is dead. The special security menu is
148not normally available but is likely accessed with a special key/button combination which is unknown ATM.
97149The cart contains a FM1208S NVRAM which appears to either be unused or holds game settings. Because the CPU
98150in the cart is always powered by a battery, it has stealth capability that allows it to continually monitor
99151the situation. If the custom CPU detects any tampering (generally things such as voltage fluctuation or
100152voltage dropping or even removal of the cart with the power on), it immediately erases the SRAM inside the
101153CPU (and thus the key) which effectively kills the security cart dead. This also suggests that the custom
102Capcom CPU contains some additional internal code to initiate the boot process which is battery-backed
103as well. It is known (from decapping it) that the CPU in the security cart does contain an amount of static
154Capcom CPU contains some additional internal code to initiate the boot process which is battery-backed as
155well. It is known (from decapping it) that the CPU in the security cart does contain an amount of static
104156RAM for data storage and a SH2 core.
105157
106158The main board uses the familiar Capcom SIMM modules to hold the data from the CDROM so that the life of
107the CD drive is maximized. The SIMMs don't contain RAM, but instead TSOP48 surface mounted flashROMs
108that can be updated with different games on bootup using a built-in software updating system.
159the CD drive is maximized. The SIMMs don't contain RAM, but instead TSOP48 surface mounted flashROMs that
160can be updated with different games on bootup using a built-in software updating system.
109161The SIMMs that hold the program code are located in positions 1 & 2 and are 64MBit.
110162The SIMMs that hold the graphics are located in positions 3, 4, 5, 6 & 7 and are 128MBit.
111163The data in the SIMMs is not decrypted, it is merely taken directly from the CDROM and shuffled slightly
r11160r11161
142194Due to the built-in upgradability of the hardware, and the higher frame-rates the hardware seems to have,
143195it appears Capcom had big plans for this system and possibly intended to create many games on it, as they
144196did with CPS2. Unfortunately for Capcom, CP SYSTEM III was an absolute flop in the arcades so those plans
145were cancelled. Possible reasons include...
146- The games were essentially just 2D, and already there were many 3D games coming out onto the market that
147  interested operators more than this.
148- The cost of the system was quite expensive when compared to other games on the market.
149- It is rumoured that the system was difficult to program for developers.
150- These PCBs were not popular with operators because the security carts are extremely static-sensitive and most
197were cancelled. Possible reasons include:
198- the games were essentially just 2D, and already there were many 3D games coming out onto the market that
199  interested operators more than this,
200- the cost of the system was quite expensive when compared to other games on the market,
201- it is rumoured that the system was difficult to program for developers,
202- these PCBs were not popular with operators because the security carts are extremely static-sensitive and most
151203  of them failed due to the decryption information being zapped by simple handling of the PCBs or by touching
152204  the security cart edge connector underneath the PCB while the security cart was plugged in, or by power
153205  fluctuations while flashing the SIMMs. You will know if your cart has been zapped because on bootup, you get
r11160r11161
161213-----------
162214
163215CAPCOM
164CP SYSTEMIII
216CP SYSTEM III
16521795682A-4 (older rev 95682A-3)
166218   |----------------------------------------------------------------------|
167219  |= J1             HM514260     |------------|      |  |  |  |  |        |
r11160r11161
26082660   ROM_REGION( 0x200000, "simm5.1", 0 ) ROM_LOAD( "sfiii-simm5.1", 0x00000, 0x200000, CRC(c6f1c066) SHA1(00de492dd1ef7aef05027a8c501c296b6602e917) ) \
26092661
26102662#define SFIII_970204_CDROM \
2611   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "sf3000", 0, SHA1(606e62cc5f46275e366e7dbb412dbaeb7e54cd0c) ) \
2663   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "cap-sf3-3", 0, SHA1(606e62cc5f46275e366e7dbb412dbaeb7e54cd0c) ) \
26122664
26132665#define SFIII2_970930_FLASH \
26142666   ROM_REGION( 0x200000, "simm1.0", 0 ) ROM_LOAD( "sfiii2-simm1.0", 0x00000, 0x200000, CRC(2d666f0b) SHA1(68de034b3a3aeaf4b26122a84ad48b0b763e4122) ) \
r11160r11161
26452697   ROM_REGION( 0x200000, "simm5.7", 0 ) ROM_LOAD( "sfiii2-simm5.7", 0x00000, 0x200000, CRC(93ffa199) SHA1(33ec2379f30c6fdf47ba72c1d0cad8bdd02f17df) ) \
26462698
26472699#define SFIII2_970930_CDROM \
2648   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "3ga000", 0, SHA1(4e162885b0b3265a56e0265037bcf247e820f027) ) \
2700   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "cap-3ga000", 0, SHA1(4e162885b0b3265a56e0265037bcf247e820f027) ) \
26492701
26502702#define SFIII3_990608_FLASH \
26512703   ROM_REGION( 0x200000, "simm1.0", 0 ) ROM_LOAD( "sfiii3-simm1.0", 0x00000, 0x200000, CRC(11dfd3cd) SHA1(dba1f77c46e80317e3279298411154dfb6db2309) ) \
r11160r11161
27352787   ROM_REGION( 0x200000, "simm6.7", 0 ) ROM_LOAD( "sfiii3-simm6.7", 0x00000, 0x200000, CRC(cc5f4187) SHA1(248ddace21ed4736a56e92f77cc6ad219d7fef0b) ) \
27362788
27372789#define SFIII3_990512_CDROM \
2738   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "33s000", 0, SHA1(2f4a9006a31903114f9f9dc09465ae253e565c51) ) \
2790   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "cap-33s-1", 0, SHA1(2f4a9006a31903114f9f9dc09465ae253e565c51) ) \
27392791
27402792#define JOJO_990108_FLASH \
27412793   ROM_REGION( 0x200000, "simm1.0", 0 ) ROM_LOAD( "jojo-simm1.0", 0x00000, 0x200000, CRC(cfbc38d6) SHA1(c33e3a51fe8ab54e0912a1d6e662fe1ade73cee7) ) \
r11160r11161
27662818   ROM_REGION( 0x200000, "simm5.1", 0 ) ROM_LOAD( "jojo-simm5.1", 0x00000, 0x200000, CRC(734fd162) SHA1(16cdfac74d18a6c2216afb1ce6afbd7f15297c32) ) \
27672819
27682820#define JOJO_990108_CDROM \
2769   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "cap-jjk-160", 0, SHA1(0f5c09171409213e191a607ee89ca3a91fe9c96a) ) \
2821   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "cap-jjk-2", 0, SHA1(0f5c09171409213e191a607ee89ca3a91fe9c96a) ) \
27702822
27712823#define JOJO_981202_FLASH \
27722824   ROM_REGION( 0x200000, "simm1.0", 0 ) ROM_LOAD( "jojoa-simm1.0",0x00000, 0x200000, CRC(e06ba886) SHA1(4defd5e8e1e6d0c439fed8a6454e89a59e24ea4c) ) \
r11160r11161
27972849   ROM_REGION( 0x200000, "simm5.1", 0 ) ROM_LOAD( "jojo-simm5.1", 0x00000, 0x200000, CRC(734fd162) SHA1(16cdfac74d18a6c2216afb1ce6afbd7f15297c32) ) \
27982850
27992851#define JOJO_981202_CDROM \
2800   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "jjk000", 0, SHA1(09869f6d8c032b527e02d815749dc8fab1289e86) ) \
2852   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "cap-jjk000", 0, SHA1(09869f6d8c032b527e02d815749dc8fab1289e86) ) \
28012853
28022854#define JOJOBA_990913_FLASH \
28032855   ROM_REGION( 0x200000, "simm1.0", 0 ) ROM_LOAD( "jojoba-simm1.0", 0x00000, 0x200000, CRC(76976231) SHA1(90adde7e5983ec6a4e02789d5cefe9e85c9c52d5) ) \
r11160r11161
28342886   ROM_REGION( 0x200000, "simm5.7", 0 ) ROM_LOAD( "jojoba-simm5.7", 0x00000, 0x200000, CRC(8c8be520) SHA1(c461f3f76a83592b36b29afb316679a7c8972404) ) \
28352887
28362888#define JOJOBA_990913_CDROM \
2837   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "jjm000", 0, SHA1(0678a0baeb853dcff1d230c14f0873cc9f143d7b) ) \
2889   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "cap-jjm-0", 0, SHA1(0678a0baeb853dcff1d230c14f0873cc9f143d7b) ) \
28382890
28392891#define REDEARTH_961121_FLASH \
28402892   ROM_REGION( 0x200000, "simm1.0", 0 ) ROM_LOAD( "redearth-simm1.0", 0x00000, 0x200000, CRC(cad468f8) SHA1(b3aa4f7d3fae84e8821417ccde9528d3eda2b7a6) ) \
r11160r11161
28612913   ROM_REGION( 0x200000, "simm5.1", 0 ) ROM_LOAD( "redearth-simm5.1", 0x00000, 0x200000, CRC(9b8cb56b) SHA1(2ff1081dc99bb7c2f1e036f4c112137c96b83d23) ) \
28622914
28632915#define REDEARTH_961121_CDROM \
2864   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "wzd000", 0, SHA1(e5676752b08283dc4a98c3d7b759e8aa6dcd0679) ) \
2916   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "cap-wzd-5", 0, SHA1(e5676752b08283dc4a98c3d7b759e8aa6dcd0679) ) \
28652917
28662918#define REDEARTH_961023_FLASH \
28672919   ROM_REGION( 0x200000, "simm1.0", 0 ) ROM_LOAD( "redeartha-simm1.0", 0x00000, 0x200000, CRC(65bac346) SHA1(6f4ba0c2cae91a37fc97bea5fc8a50aaf6ca6513) ) \
r11160r11161
28882940   ROM_REGION( 0x200000, "simm5.1", 0 ) ROM_LOAD( "redearth-simm5.1", 0x00000, 0x200000, CRC(9b8cb56b) SHA1(2ff1081dc99bb7c2f1e036f4c112137c96b83d23) ) \
28892941
28902942#define REDEARTH_961023_CDROM \
2891   DISK_REGION( "cdrom" )   DISK_IMAGE_READONLY( "cap-wzd-3", 0, SHA1(a6ff67093db6bc80ee5fc46e4300e0177b213a52) ) \
2943   DISK_REGION( "cdrom" ) DISK_IMAGE_READONLY( "cap-wzd-3", 0, SHA1(a6ff67093db6bc80ee5fc46e4300e0177b213a52) ) \
28922944
28932945
28942946/* CD sets - use CD BIOS roms */
r11160r11161
29112963   SFIII_970204_CDROM
29122964ROM_END
29132965
2966ROM_START( sfiiih )
2967   ROM_REGION32_BE( 0x080000, "user1", 0 ) /* bios region */
2968   ROM_LOAD( "sfiii_hispanic.29f400.u2", 0x000000, 0x080000, CRC(d2b3cd48) SHA1(00ebb270c24a66515c97e35331de54ff5358000e) )
2969
2970   SFIII_970204_FLASH
2971   SFIII_970204_CDROM
2972ROM_END
2973
29142974ROM_START( sfiii2 )
29152975   ROM_REGION32_BE( 0x080000, "user1", 0 ) /* bios region */
29162976   ROM_LOAD( "sfiii2_usa.29f400.u2", 0x000000, 0x080000, CRC(75dd72e0) SHA1(5a12d6ea6734df5de00ecee6f9ef470749d2f242) )
r11160r11161
30073067   JOJO_981202_CDROM
30083068ROM_END
30093069
3010
30113070ROM_START( jojoba )
30123071   ROM_REGION32_BE( 0x080000, "user1", 0 ) /* bios region */
30133072   ROM_LOAD( "jojoba_japan.29f400.u2", 0x000000, 0x080000, CRC(3085478c) SHA1(055eab1fc42816f370a44b17fd7e87ffcb10e8b7) )
r11160r11161
32263285GAME( 1996, warzarda, redearth, redearth, cps3, redearth, ROT0, "Capcom", "Warzard (Japan 961023)", GAME_IMPERFECT_GRAPHICS )
32273286GAME( 1997, sfiii,    0,        sfiii,    cps3, sfiii,    ROT0, "Capcom", "Street Fighter III: New Generation (USA 970204)", GAME_IMPERFECT_GRAPHICS )
32283287GAME( 1997, sfiiij,   sfiii,    sfiii,    cps3, sfiii,    ROT0, "Capcom", "Street Fighter III: New Generation (Japan 970204)", GAME_IMPERFECT_GRAPHICS )
3288GAME( 1997, sfiiih,   sfiii,    sfiii,    cps3, sfiii,    ROT0, "Capcom", "Street Fighter III: New Generation (Hispanic 970204)", GAME_IMPERFECT_GRAPHICS )
32293289GAME( 1997, sfiii2,   0,        sfiii2,   cps3, sfiii2,   ROT0, "Capcom", "Street Fighter III 2nd Impact: Giant Attack (USA 970930)", GAME_IMPERFECT_GRAPHICS )
32303290GAME( 1997, sfiii2j,  sfiii2,   sfiii2,   cps3, sfiii2,   ROT0, "Capcom", "Street Fighter III 2nd Impact: Giant Attack (Japan 970930)", GAME_IMPERFECT_GRAPHICS )
32313291GAME( 1998, jojo,     0,        jojo,     cps3, jojo,     ROT0, "Capcom", "JoJo's Venture (USA 990108)", GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/subsino.c
r11160r11161
213213#include "emu.h"
214214#include "cpu/z180/z180.h"
215215#include "machine/8255ppi.h"
216#include "machine/subsino.h"
216217#include "sound/okim6295.h"
217218#include "sound/2413intf.h"
218219#include "sound/3812intf.h"
220
219221#include "victor5.lh"
220222#include "victor21.lh"
221223#include "crsbingo.lh"
r11160r11161
34753477*                        Driver Init / Decryption                          *
34763478***************************************************************************/
34773479
3478#if 0
3479void dump_decrypted(running_machine& machine, UINT8* decrypt)
3480{
3481    FILE *fp;
3482    char filename[256];
3483    sprintf(filename,"dat_%s", machine.system().name);
3484    fp=fopen(filename, "w+b");
3485    if (fp)
3486    {
3487        fwrite(decrypt, 0x10000, 1, fp);
3488        fclose(fp);
3489    }
3490}
3491#endif
3492
3493static const unsigned char victor5_xors[8] =  { 0x99, 0x99, 0x33, 0x44, 0xbb, 0x88, 0x88, 0xbb };
3494static const unsigned char victor21_xors[8] = { 0x44, 0xbb, 0x66, 0x44, 0xaa, 0x55, 0x88, 0x22 };
3495static const unsigned char crsbingo_xors[8] = { 0xbb, 0xcc, 0xcc, 0xdd, 0xaa, 0x11, 0x44, 0xee };
3496static const unsigned char sharkpy_xors[8] =  { 0xcc, 0xaa, 0x66, 0xaa, 0xee, 0x33, 0xff, 0xff };
3497
3498
3499static void victor5_bitswaps(UINT8* decrypt, int i)
3500{
3501   if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
3502   if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,0,3,2,1,4);
3503   if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
3504   if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
3505   if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,0,7,6,5,4);
3506   if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,0,3,2,1,4);
3507   if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,0,7,2,5,4);
3508   if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,4,3,6,5,0);
3509}
3510
3511
3512static void victor21_bitswaps(UINT8* decrypt, int i)
3513{
3514   if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
3515   if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,4,7,2,5,0);
3516   if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,4,7,6,5,0);
3517   if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
3518   if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
3519   if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],3,6,5,0,7,2,1,4);
3520   if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,4,3,2,1,0);
3521   if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,4,7,6,5,0);
3522}
3523
3524static void crsbingo_bitswaps(UINT8* decrypt, int i)
3525{
3526   if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
3527   if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
3528   if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],3,2,5,0,7,6,1,4);
3529   if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,0,3,6,1,4);
3530   if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,0,3,2,1,4);
3531   if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,4,3,6,5,0);
3532   if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
3533   if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,0,7,6,5,4);
3534}
3535
3536static void sharkpy_bitswaps(UINT8* decrypt, int i)
3537{
3538   if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,0,7,6,5,4);
3539   if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
3540   if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,4,3,6,5,0);
3541   if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,0,7,2,5,4);
3542   if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
3543   if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],3,2,5,4,7,6,1,0);
3544   if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],7,6,1,4,3,2,5,0);
3545   if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,4,7,2,5,0);
3546}
3547
3548static void subsino_decrypt(running_machine& machine, void (*bitswaps)(UINT8* decrypt, int i), const UINT8* xors, int size)
3549{
3550   int i;
3551   UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000);
3552   UINT8* region = machine.region("maincpu")->base();
3553
3554   for (i=0;i<0x10000;i++)
3555   {
3556      if (i<size)
3557      {
3558         decrypt[i] = region[i]^xors[i&7];
3559         bitswaps(decrypt, i);
3560      }
3561      else
3562      {
3563         decrypt[i] = region[i];
3564      }
3565   }
3566//  dump_decrypted(machine, decrypt);
3567   memcpy(region, decrypt, 0x10000);
3568}
3569
3570
3571
35723480static DRIVER_INIT( victor5 )
35733481{
35743482   subsino_decrypt(machine, victor5_bitswaps, victor5_xors, 0xc000);
src/mame/drivers/jchan.c
r11160r11161
175175#include "includes/kaneko16.h"
176176#include "video/sknsspr.h"
177177
178class jchan_state : public driver_device
178class jchan_state : public kaneko16_state
179179{
180180public:
181181   jchan_state(running_machine &machine, const driver_device_config_base &config)
182      : driver_device(machine, config) { }
182      : kaneko16_state(machine, config) { }
183183
184184   bitmap_t *m_sprite_bitmap_1;
185185   bitmap_t *m_sprite_bitmap_2;
r11160r11161
260260   }
261261}
262262
263#define JCHAN_MCU_COM_W(_n_) \
264static WRITE16_HANDLER( jchan_mcu_com##_n_##_w ) \
265{ \
266   jchan_state *state = space->machine().driver_data<jchan_state>(); \
267   COMBINE_DATA(&state->m_mcu_com[_n_]); \
268   if (state->m_mcu_com[0] != 0xFFFF)   return; \
269   if (state->m_mcu_com[1] != 0xFFFF)   return; \
270   if (state->m_mcu_com[2] != 0xFFFF)   return; \
271   if (state->m_mcu_com[3] != 0xFFFF)   return; \
272\
273   memset(state->m_mcu_com, 0, 4 * sizeof( UINT16 ) ); \
274   jchan_mcu_run(space->machine()); \
263INLINE void jchan_mcu_com_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int _n_)
264{
265   jchan_state *state = space->machine().driver_data<jchan_state>();
266   COMBINE_DATA(&state->m_mcu_com[_n_]);
267   if (state->m_mcu_com[0] != 0xFFFF)   return;
268   if (state->m_mcu_com[1] != 0xFFFF)   return;
269   if (state->m_mcu_com[2] != 0xFFFF)   return;
270   if (state->m_mcu_com[3] != 0xFFFF)   return;
271
272   memset(state->m_mcu_com, 0, 4 * sizeof( UINT16 ) );
273   jchan_mcu_run(space->machine());
275274}
276275
277JCHAN_MCU_COM_W(0)
278JCHAN_MCU_COM_W(1)
279JCHAN_MCU_COM_W(2)
280JCHAN_MCU_COM_W(3)
276static WRITE16_HANDLER( jchan_mcu_com0_w ) { jchan_mcu_com_w(space, offset, data, mem_mask, 0); }
277static WRITE16_HANDLER( jchan_mcu_com1_w ) { jchan_mcu_com_w(space, offset, data, mem_mask, 1); }
278static WRITE16_HANDLER( jchan_mcu_com2_w ) { jchan_mcu_com_w(space, offset, data, mem_mask, 2); }
279static WRITE16_HANDLER( jchan_mcu_com3_w ) { jchan_mcu_com_w(space, offset, data, mem_mask, 3); }
281280
282281static READ16_HANDLER( jchan_mcu_status_r )
283282{
r11160r11161
536535   AM_RANGE(0x400000, 0x403fff) AM_RAM AM_BASE_MEMBER(jchan_state, m_mainsub_shared_ram) AM_SHARE("share1")
537536
538537   /* VIEW2 Tilemap - [D] grid tested, cleared ($1d84), also cleared at startup ($810-$826) */
539   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
540   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
541   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                           //
542   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                           //
543   AM_RANGE(0x600000, 0x60001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
538   AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(jchan_state, m_vram[1])   // Layers 0
539   AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(jchan_state, m_vram[0])   //
540   AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE_MEMBER(jchan_state, m_vscroll[1])                           //
541   AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE_MEMBER(jchan_state, m_vscroll[0])                           //
542   AM_RANGE(0x600000, 0x60001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(jchan_state, m_layers_0_regs)   // Layers 0 Regs
544543
545544   /* background prites */
546545   AM_RANGE(0x700000, 0x703fff) AM_RAM_WRITE(jchan_suprnova_sprite32_2_w) AM_BASE_MEMBER(jchan_state, m_spriteram_2)
src/mame/drivers/seattle.c
r11160r11161
555555   /* reset either the DCS2 board or the CAGE board */
556556   if (machine.device("dcs2") != NULL)
557557   {
558      dcs_reset_w(1);
559      dcs_reset_w(0);
558      dcs_reset_w(machine, 1);
559      dcs_reset_w(machine, 0);
560560   }
561561   else if (machine.device("cage") != NULL)
562562   {
src/mame/drivers/namcos22.c
r11160r11161
11471147
11481148#define SS22_MASTER_CLOCK (49152000)   /* info from Guru */
11491149
1150enum namcos22_gametype namcos22_gametype; /* TBR: used for game-specific hacks */
1151
1152static int mbSuperSystem22; /* used to dispatch Sys22/SuperSys22 differences */
1153static int mbEnableDspIrqs;
1154static UINT32 *namcos22_shareram;
1155static UINT32 *namcos22_system_controller;
1156static UINT32 *namcos22_nvmem;
1157static size_t namcos22_nvmem_size;
1158static UINT16 mMasterBIOZ;
1159static UINT32 *mpPointRAM;
1160static UINT32 old_coin_state, credits1, credits2;
1161static UINT16 *mpSlaveExternalRAM;
1162
1163static UINT32 mPointAddr;
1164static UINT32 mPointData;
1165static UINT16 *mpMasterExternalRAM;
1166
1167static UINT16 mSerialDataSlaveToMasterNext;
1168static UINT16 mSerialDataSlaveToMasterCurrent;
1169
1170#define MAX_RENDER_CMD_SEQ 0x1c
1171static int mRenderBufSize;
1172static UINT16 mRenderBufData[MAX_RENDER_CMD_SEQ];
1173
1174static UINT32 mSys22PortBits;
1175
1176static int mFrameCount;
1177
1178static UINT8 stick_input, prev_stick_state;
1179
11801150/**
11811151 * helper function used to read a byte from a chunk of 32 bit memory
11821152 */
r11160r11161
12111181static UINT16
12121182AnalogAsDigital( running_machine &machine )
12131183{
1184   namcos22_state *state = machine.driver_data<namcos22_state>();
12141185   UINT16 stick = input_port_read_safe(machine, "INPUTS", 0);
12151186   UINT16 gas   = input_port_read_safe(machine, "GAS", 0);
12161187   UINT16 steer = input_port_read_safe(machine, "STEER", 0);
12171188   UINT16 result = 0xffff;
12181189
1219   switch( namcos22_gametype )
1190   switch( state->m_gametype )
12201191   {
12211192   case NAMCOS22_RAVE_RACER:
12221193   case NAMCOS22_RIDGE_RACER:
r11160r11161
12621233static void
12631234HandleCoinage(running_machine &machine, int slots)
12641235{
1265   UINT16 *share16 = (UINT16 *)namcos22_shareram;
1236   namcos22_state *state = machine.driver_data<namcos22_state>();
1237   UINT16 *share16 = (UINT16 *)state->m_shareram;
12661238   UINT32 coin_state;
12671239
12681240   coin_state = input_port_read(machine, "INPUTS") & 0x1200;
12691241
1270   if (!(coin_state & 0x1000) && (old_coin_state & 0x1000))
1242   if (!(coin_state & 0x1000) && (state->m_old_coin_state & 0x1000))
12711243   {
1272      credits1++;
1244      state->m_credits1++;
12731245   }
12741246
1275   if (!(coin_state & 0x0200) && (old_coin_state & 0x0200))
1247   if (!(coin_state & 0x0200) && (state->m_old_coin_state & 0x0200))
12761248   {
1277      credits2++;
1249      state->m_credits2++;
12781250   }
12791251
1280   old_coin_state = coin_state;
1252   state->m_old_coin_state = coin_state;
12811253
1282   share16[BYTE_XOR_LE(0x38/2)] = credits1;
1254   share16[BYTE_XOR_LE(0x38/2)] = state->m_credits1;
12831255
12841256   if (slots == 2)
12851257   {
1286      share16[BYTE_XOR_LE(0x3e/2)] = credits2;
1258      share16[BYTE_XOR_LE(0x3e/2)] = state->m_credits2;
12871259   }
12881260} /* HandleCoinage */
12891261
r11160r11161
12911263static void
12921264HandleDrivingIO( running_machine &machine )
12931265{
1294   if( nthbyte(namcos22_system_controller, 0x18) != 0 )
1266   namcos22_state *state = machine.driver_data<namcos22_state>();
1267   if( nthbyte(state->m_system_controller, 0x18) != 0 )
12951268   {
12961269      UINT16 flags = input_port_read(machine, "INPUTS");
12971270      UINT16 gas, brake, steer;
r11160r11161
12991272
13001273      HandleCoinage(machine, 2);
13011274
1302      switch (namcos22_gametype)
1275      switch (state->m_gametype)
13031276      {
13041277         case NAMCOS22_RIDGE_RACER:
13051278         case NAMCOS22_RIDGE_RACER2:
r11160r11161
13371310            break;
13381311      }
13391312
1340      namcos22_shareram[0x000/4] = 0x10<<16; /* SUB CPU ready */
1341      namcos22_shareram[0x030/4] = (flags<<16)|steer;
1342      namcos22_shareram[0x034/4] = (gas<<16)|brake;
1313      state->m_shareram[0x000/4] = 0x10<<16; /* SUB CPU ready */
1314      state->m_shareram[0x030/4] = (flags<<16)|steer;
1315      state->m_shareram[0x034/4] = (gas<<16)|brake;
13431316   }
13441317} /* HandleDrivingIO */
13451318
r11160r11161
13471320static void
13481321HandleCyberCommandoIO( running_machine &machine )
13491322{
1350   if( nthbyte(namcos22_system_controller, 0x18) != 0 )
1323   namcos22_state *state = machine.driver_data<namcos22_state>();
1324   if( nthbyte(state->m_system_controller, 0x18) != 0 )
13511325   {
13521326      UINT16 flags = input_port_read(machine, "INPUTS");
13531327
r11160r11161
13561330      UINT16 volume2 = input_port_read(machine, "STICKX1") * 0x10;
13571331      UINT16 volume3 = input_port_read(machine, "STICKX2") * 0x10;
13581332
1359      namcos22_shareram[0x030/4] = (flags<<16) | volume0;
1360      namcos22_shareram[0x034/4] = (volume1<<16) | volume2;
1361      namcos22_shareram[0x038/4] = volume3<<16;
1333      state->m_shareram[0x030/4] = (flags<<16) | volume0;
1334      state->m_shareram[0x034/4] = (volume1<<16) | volume2;
1335      state->m_shareram[0x038/4] = volume3<<16;
13621336
13631337      HandleCoinage(machine, 1);
13641338   }
r11160r11161
13671341/*********************************************************************************************/
13681342
13691343static void
1370InitDSP( running_machine &machine, int bSuperSystem22 )
1344InitDSP( running_machine &machine )
13711345{
1372   mbSuperSystem22 = bSuperSystem22;
13731346   cputag_set_input_line(machine, "master",INPUT_LINE_RESET,ASSERT_LINE); /* master DSP */
13741347   cputag_set_input_line(machine, "slave",INPUT_LINE_RESET,ASSERT_LINE); /* slave DSP */
13751348   cputag_set_input_line(machine, "mcu",INPUT_LINE_RESET,ASSERT_LINE); /* MCU */
r11160r11161
13771350
13781351static READ16_HANDLER( pdp_status_r )
13791352{
1380   return mMasterBIOZ;
1353   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1354   return state->m_mMasterBIOZ;
13811355} /* pdp_status_r */
13821356
13831357static void
1384WriteToPointRAM( offs_t offs, UINT32 data )
1358WriteToPointRAM( namcos22_state *state, offs_t offs, UINT32 data )
13851359{
13861360   offs &= 0xffffff; /* 24 bit addressing */
1387   if( mbSuperSystem22 )
1361   if( state->m_mbSuperSystem22 )
13881362   {
13891363      if( offs>=0xf80000 && offs<=0xf9ffff )
13901364      {
1391         mpPointRAM[offs-0xf80000] = data;
1365         state->m_mpPointRAM[offs-0xf80000] = data;
13921366      }
13931367   }
13941368   else
13951369   {
13961370      if( offs>=0xf00000 && offs<=0xf1ffff )
13971371      {
1398         mpPointRAM[offs-0xf00000] = data;
1372         state->m_mpPointRAM[offs-0xf00000] = data;
13991373      }
14001374   }
14011375} /* WriteToPointRAM */
14021376
14031377static UINT32
1404ReadFromPointRAM( offs_t offs )
1378ReadFromPointRAM( running_machine &machine, offs_t offs )
14051379{
1380   namcos22_state *state = machine.driver_data<namcos22_state>();
14061381   offs &= 0xffffff; /* 24 bit addressing */
1407   if( mbSuperSystem22 )
1382   if( state->m_mbSuperSystem22 )
14081383   {
14091384      if( offs>=0xf80000 && offs<=0xf9ffff )
14101385      {
1411         return mpPointRAM[offs-0xf80000];
1386         return state->m_mpPointRAM[offs-0xf80000];
14121387      }
14131388   }
14141389   else
14151390   {
14161391      if( offs>=0xf00000 && offs<=0xf1ffff )
14171392      {
1418         return mpPointRAM[offs-0xf00000];
1393         return state->m_mpPointRAM[offs-0xf00000];
14191394      }
14201395   }
1421   return namcos22_point_rom_r(offs);
1396   return namcos22_point_rom_r(machine, offs);
14221397} /* ReadFromPointRAM */
14231398
14241399static UINT32
1425ReadFromCommRAM( offs_t offs )
1400ReadFromCommRAM( namcos22_state *state, offs_t offs )
14261401{
1427   return namcos22_polygonram[offs&0x7fff];
1402   return state->m_polygonram[offs&0x7fff];
14281403} /* ReadFromCommRAM */
14291404
14301405static void
1431WriteToCommRAM( offs_t offs, UINT32 data )
1406WriteToCommRAM( namcos22_state *state, offs_t offs, UINT32 data )
14321407{
1433   namcos22_polygonram[offs&0x7fff] = data;
1408   state->m_polygonram[offs&0x7fff] = data;
14341409} /* WriteToCommRAM */
14351410
14361411static READ16_HANDLER( pdp_begin_r )
14371412{
1413   namcos22_state *state = space->machine().driver_data<namcos22_state>();
14381414   /* this feature appears to be only used on Super System22 hardware */
1439   if( mbSuperSystem22 )
1415   if( state->m_mbSuperSystem22 )
14401416   {
1441      UINT16 offs = namcos22_polygonram[0x20000/4-1];
1442      mMasterBIOZ = 1;
1417      UINT16 offs = state->m_polygonram[0x20000/4-1];
1418      state->m_mMasterBIOZ = 1;
14431419      for(;;)
14441420      {
14451421         UINT16 start = offs;
1446         UINT16 cmd = ReadFromCommRAM(offs++);
1422         UINT16 cmd = ReadFromCommRAM(state, offs++);
14471423         UINT32 srcAddr;
14481424         UINT32 dstAddr;
14491425         UINT32 numWords;
r11160r11161
14551431            break;
14561432
14571433         case 0xfff5: /* write to point ram */
1458            dstAddr = ReadFromCommRAM(offs++); /* 32 bit PointRAM address */
1459            data    = ReadFromCommRAM(offs++);    /* 24 bit data */
1460            WriteToPointRAM( dstAddr, data );
1434            dstAddr = ReadFromCommRAM(state, offs++); /* 32 bit PointRAM address */
1435            data    = ReadFromCommRAM(state, offs++);    /* 24 bit data */
1436            WriteToPointRAM( state, dstAddr, data );
14611437            break;
14621438
14631439         case 0xfff6: /* read word from point ram */
1464            srcAddr = ReadFromCommRAM(offs++); /* 32 bit PointRAM address */
1465            dstAddr = ReadFromCommRAM(offs++); /* CommRAM address; receives 24 bit PointRAM data */
1466            data    = ReadFromPointRAM( srcAddr );
1467            WriteToCommRAM( dstAddr, data );
1440            srcAddr = ReadFromCommRAM(state, offs++); /* 32 bit PointRAM address */
1441            dstAddr = ReadFromCommRAM(state, offs++); /* CommRAM address; receives 24 bit PointRAM data */
1442            data    = ReadFromPointRAM( space->machine(), srcAddr );
1443            WriteToCommRAM( state, dstAddr, data );
14681444            break;
14691445
14701446         case 0xfff7: /* block move (CommRAM to CommRAM) */
1471            srcAddr  = ReadFromCommRAM(offs++);
1472            dstAddr  = ReadFromCommRAM(offs++);
1473            numWords = ReadFromCommRAM(offs++);
1447            srcAddr  = ReadFromCommRAM(state, offs++);
1448            dstAddr  = ReadFromCommRAM(state, offs++);
1449            numWords = ReadFromCommRAM(state, offs++);
14741450            while( numWords-- )
14751451            {
1476               data = ReadFromCommRAM(srcAddr++);
1477               WriteToCommRAM( dstAddr++, data );
1452               data = ReadFromCommRAM(state, srcAddr++);
1453               WriteToCommRAM( state, dstAddr++, data );
14781454            }
14791455            break;
14801456
14811457         case 0xfffa: /* read block from point ram */
1482            srcAddr  = ReadFromCommRAM(offs++); /* 32 bit PointRAM address */
1483            dstAddr  = ReadFromCommRAM(offs++); /* CommRAM address; receives data */
1484            numWords = ReadFromCommRAM(offs++); /* block size */
1458            srcAddr  = ReadFromCommRAM(state, offs++); /* 32 bit PointRAM address */
1459            dstAddr  = ReadFromCommRAM(state, offs++); /* CommRAM address; receives data */
1460            numWords = ReadFromCommRAM(state, offs++); /* block size */
14851461            while( numWords-- )
14861462            {
1487               data = ReadFromPointRAM( srcAddr++ );
1488               WriteToCommRAM( dstAddr++, data );
1463               data = ReadFromPointRAM( space->machine(), srcAddr++ );
1464               WriteToCommRAM( state, dstAddr++, data );
14891465            }
14901466            break;
14911467
14921468         case 0xfffb: /* write block to point ram */
1493            dstAddr  = ReadFromCommRAM(offs++);  /* 32 bit PointRAM address */
1494            numWords = ReadFromCommRAM(offs++); /* block size */
1469            dstAddr  = ReadFromCommRAM(state, offs++);  /* 32 bit PointRAM address */
1470            numWords = ReadFromCommRAM(state, offs++); /* block size */
14951471            while( numWords-- )
14961472            {
1497               data = ReadFromCommRAM( offs++ ); /* 24 bit source data */
1498               WriteToPointRAM( dstAddr++, data );
1473               data = ReadFromCommRAM( state, offs++ ); /* 24 bit source data */
1474               WriteToPointRAM( state, dstAddr++, data );
14991475            }
15001476            break;
15011477
15021478         case 0xfffc: /* point ram to point ram */
1503            srcAddr  = ReadFromCommRAM(offs++);
1504            dstAddr  = ReadFromCommRAM(offs++);
1505            numWords = ReadFromCommRAM(offs++);
1479            srcAddr  = ReadFromCommRAM(state, offs++);
1480            dstAddr  = ReadFromCommRAM(state, offs++);
1481            numWords = ReadFromCommRAM(state, offs++);
15061482            while( numWords-- )
15071483            {
1508               data = ReadFromPointRAM( srcAddr++ );
1509               WriteToPointRAM( dstAddr++, data );
1484               data = ReadFromPointRAM( space->machine(), srcAddr++ );
1485               WriteToPointRAM( state, dstAddr++, data );
15101486            }
15111487            break;
15121488
15131489         case 0xfffd: /* unknown */
1514            numWords = ReadFromCommRAM(offs++);
1490            numWords = ReadFromCommRAM(state, offs++);
15151491            while( numWords-- )
15161492            {
1517               data = ReadFromCommRAM(offs++);
1493               data = ReadFromCommRAM(state, offs++);
15181494               //namcos22_WriteDataToRenderDevice( data );
15191495            }
15201496            break;
15211497
15221498         case 0xfffe: /* unknown */
1523            data = ReadFromCommRAM(offs++); /* ??? */
1499            data = ReadFromCommRAM(state, offs++); /* ??? */
15241500            break;
15251501
15261502         case 0xffff: /* "goto" command */
1527            offs = ReadFromCommRAM(offs);
1503            offs = ReadFromCommRAM(state, offs);
15281504            if( offs == start )
15291505            { /* most commands end with a "goto self" */
15301506               return 0;
r11160r11161
15361512            return 0;
15371513         }
15381514      } /* for(;;) */
1539   } /* mbSuperSystem22 */
1515   } /* state->m_mbSuperSystem22 */
15401516   return 0;
15411517} /* pdp_begin_r */
15421518
15431519static READ16_HANDLER( slave_external_ram_r )
15441520{
1545   return mpSlaveExternalRAM[offset];
1521   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1522   return state->m_mpSlaveExternalRAM[offset];
15461523}
15471524
15481525static WRITE16_HANDLER( slave_external_ram_w )
15491526{
1550   COMBINE_DATA( &mpSlaveExternalRAM[offset] );
1527   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1528   COMBINE_DATA( &state->m_mpSlaveExternalRAM[offset] );
15511529}
15521530
15531531static void HaltSlaveDSP( running_machine &machine )
r11160r11161
15771555
15781556static WRITE16_HANDLER( point_ram_idx_w )
15791557{
1580   mPointAddr<<=16;
1581   mPointAddr |= data;
1558   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1559   state->m_mPointAddr<<=16;
1560   state->m_mPointAddr |= data;
15821561}
15831562
15841563static WRITE16_HANDLER( point_ram_loword_iw )
15851564{
1586   mPointData |= data;
1587   WriteToPointRAM( mPointAddr++, mPointData );
1565   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1566   state->m_mPointData |= data;
1567   WriteToPointRAM( state, state->m_mPointAddr++, state->m_mPointData );
15881568}
15891569
15901570static WRITE16_HANDLER( point_ram_hiword_w )
15911571{
1592   mPointData = (data<<16);
1572   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1573   state->m_mPointData = (data<<16);
15931574}
15941575
15951576static READ16_HANDLER( point_ram_loword_r )
15961577{
1597   return ReadFromPointRAM(mPointAddr)&0xffff;
1578   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1579   return ReadFromPointRAM(space->machine(), state->m_mPointAddr)&0xffff;
15981580}
15991581
16001582static READ16_HANDLER( point_ram_hiword_ir )
16011583{
1602   return ReadFromPointRAM(mPointAddr++)>>16;
1584   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1585   return ReadFromPointRAM(space->machine(), state->m_mPointAddr++)>>16;
16031586}
16041587
16051588static WRITE16_HANDLER( dsp_unk2_w )
r11160r11161
16131596    */
16141597}
16151598
1616static enum
1599enum
16171600{
16181601   eDSP_UPLOAD_READY,
16191602   eDSP_UPLOAD_DEST,
16201603   eDSP_UPLOAD_DATA
1621} mDspUploadState;
1604};
16221605
16231606static READ16_HANDLER( dsp_unk_port3_r )
16241607{
1625   mMasterBIOZ = 0;
1626   mDspUploadState = eDSP_UPLOAD_READY;
1608   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1609   state->m_mMasterBIOZ = 0;
1610   state->m_mDspUploadState = eDSP_UPLOAD_READY;
16271611   return 0;
16281612}
16291613
16301614static WRITE16_HANDLER( upload_code_to_slave_dsp_w )
16311615{
1632   static int mUploadDestIdx;
1616   namcos22_state *state = space->machine().driver_data<namcos22_state>();
16331617
1634   switch( mDspUploadState )
1618   switch( state->m_mDspUploadState )
16351619   {
16361620   case eDSP_UPLOAD_READY:
16371621      logerror( "UPLOAD_READY; cmd = 0x%x\n", data );
r11160r11161
16411625      }
16421626      else if( data==1 )
16431627      {
1644         mDspUploadState = eDSP_UPLOAD_DEST;
1628         state->m_mDspUploadState = eDSP_UPLOAD_DEST;
16451629      }
16461630      else if( data==2 )
16471631      {
r11160r11161
16661650      break;
16671651
16681652   case eDSP_UPLOAD_DEST:
1669      mUploadDestIdx = data-0x8000;
1670      mDspUploadState = eDSP_UPLOAD_DATA;
1653      state->m_mUploadDestIdx = data-0x8000;
1654      state->m_mDspUploadState = eDSP_UPLOAD_DATA;
16711655      break;
16721656
16731657   case eDSP_UPLOAD_DATA:
1674      mpSlaveExternalRAM[mUploadDestIdx++] = data;
1658      state->m_mpSlaveExternalRAM[state->m_mUploadDestIdx++] = data;
16751659      break;
16761660
16771661   default:
r11160r11161
17021686
17031687static READ16_HANDLER( master_external_ram_r )
17041688{
1705   return mpMasterExternalRAM[offset];
1689   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1690   return state->m_mpMasterExternalRAM[offset];
17061691}
17071692
17081693static WRITE16_HANDLER( master_external_ram_w )
17091694{
1710   COMBINE_DATA( &mpMasterExternalRAM[offset] );
1695   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1696   COMBINE_DATA( &state->m_mpMasterExternalRAM[offset] );
17111697}
17121698
17131699#ifdef USE_NAMCOS22_SPEED_HACK
r11160r11161
17181704
17191705static WRITE16_HANDLER( slave_serial_io_w )
17201706{
1721   mSerialDataSlaveToMasterNext = data;
1707   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1708   state->m_mSerialDataSlaveToMasterNext = data;
17221709   logerror( "slave_serial_io_w(%04x)\n", data );
17231710}
17241711
17251712static READ16_HANDLER( master_serial_io_r )
17261713{
1714   namcos22_state *state = space->machine().driver_data<namcos22_state>();
17271715   logerror( "master_serial_io_r() == %04x\n",
1728      mSerialDataSlaveToMasterCurrent );
1729   return mSerialDataSlaveToMasterCurrent;
1716      state->m_mSerialDataSlaveToMasterCurrent );
1717   return state->m_mSerialDataSlaveToMasterCurrent;
17301718}
17311719
17321720static INTERRUPT_GEN( dsp_serial_pulse1 )
17331721{
1734   if( mbEnableDspIrqs )
1722   namcos22_state *state = device->machine().driver_data<namcos22_state>();
1723   if( state->m_mbEnableDspIrqs )
17351724   {
1736      mSerialDataSlaveToMasterCurrent = mSerialDataSlaveToMasterNext;
1725      state->m_mSerialDataSlaveToMasterCurrent = state->m_mSerialDataSlaveToMasterNext;
17371726
17381727      if( cpu_getiloops(device) == 0 )
17391728      {
r11160r11161
17931782 */
17941783static WRITE16_HANDLER( dsp_unk8_w )
17951784{
1796   mRenderBufSize = 0;
1785   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1786   state->m_mRenderBufSize = 0;
17971787}
17981788
17991789static WRITE16_HANDLER( master_render_device_w )
18001790{
1801   if( mRenderBufSize<MAX_RENDER_CMD_SEQ )
1791   namcos22_state *state = space->machine().driver_data<namcos22_state>();
1792   if( state->m_mRenderBufSize<MAX_RENDER_CMD_SEQ )
18021793   {
1803      mRenderBufData[mRenderBufSize++] = data;
1804      if( mRenderBufSize == MAX_RENDER_CMD_SEQ )
1794      state->m_mRenderBufData[state->m_mRenderBufSize++] = data;
1795      if( state->m_mRenderBufSize == MAX_RENDER_CMD_SEQ )
18051796      {
1806         namcos22_draw_direct_poly( space->machine(), mRenderBufData );
1797         namcos22_draw_direct_poly( space->machine(), state->m_mRenderBufData );
18071798      }
18081799   }
18091800}
18101801
18111802static ADDRESS_MAP_START( master_dsp_program, AS_PROGRAM, 16 )
18121803   AM_RANGE(0x0000, 0x0fff) AM_ROM /* internal ROM (4k words) */
1813   AM_RANGE(0x4000, 0x7fff) AM_ROM AM_BASE(&mpMasterExternalRAM)
1804   AM_RANGE(0x4000, 0x7fff) AM_ROM AM_BASE_MEMBER(namcos22_state, m_mpMasterExternalRAM)
18141805ADDRESS_MAP_END
18151806
18161807static ADDRESS_MAP_START( master_dsp_data, AS_DATA, 16 )
r11160r11161
18591850
18601851static READ16_HANDLER( dsp_slave_port5_r )
18611852{
1862/*  int numWords = SlaveBufSize();
1863    int mode = 2;
1864    return (numWords<<4) | mode;
1865*/
1853#if 0
1854   int numWords = SlaveBufSize();
1855   int mode = 2;
1856   return (numWords<<4) | mode;
1857#endif
18661858   return 0;
18671859}
18681860
r11160r11161
19031895
19041896static ADDRESS_MAP_START( slave_dsp_program, AS_PROGRAM, 16 )
19051897   AM_RANGE(0x0000, 0x0fff) AM_ROM /* internal ROM */
1906   AM_RANGE(0x8000, 0x9fff) AM_ROM AM_BASE(&mpSlaveExternalRAM)
1898   AM_RANGE(0x8000, 0x9fff) AM_ROM AM_BASE_MEMBER(namcos22_state, m_mpSlaveExternalRAM)
19071899ADDRESS_MAP_END
19081900
19091901static ADDRESS_MAP_START( slave_dsp_data, AS_DATA, 16 )
r11160r11161
19351927
19361928static NVRAM_HANDLER( namcos22 )
19371929{
1930   namcos22_state *state = machine.driver_data<namcos22_state>();
19381931   int i;
19391932   UINT8 data[4];
19401933   if( read_or_write )
19411934   {
1942      for( i=0; i<namcos22_nvmem_size/4; i++ )
1935      for( i=0; i<state->m_nvmem_size/4; i++ )
19431936      {
1944         UINT32 dword = namcos22_nvmem[i];
1937         UINT32 dword = state->m_nvmem[i];
19451938         data[0] = dword>>24;
19461939         data[1] = (dword&0x00ff0000)>>16;
19471940         data[2] = (dword&0x0000ff00)>>8;
r11160r11161
19531946   {
19541947      if( file )
19551948      {
1956         for( i=0; i<namcos22_nvmem_size/4; i++ )
1949         for( i=0; i<state->m_nvmem_size/4; i++ )
19571950         {
19581951            file->read( data, 4 );
1959            namcos22_nvmem[i] = (data[0]<<24)|(data[1]<<16)|(data[2]<<8)|data[3];
1952            state->m_nvmem[i] = (data[0]<<24)|(data[1]<<16)|(data[2]<<8)|data[3];
19601953         }
19611954      }
19621955      else
19631956      {
1964         memset( namcos22_nvmem, 0x00, namcos22_nvmem_size );
1965         if (machine.region("nvram")->bytes() == namcos22_nvmem_size)
1957         memset( state->m_nvmem, 0x00, state->m_nvmem_size );
1958         if (machine.region("nvram")->bytes() == state->m_nvmem_size)
19661959         {
19671960            UINT8* nvram = machine.region("nvram")->base();
19681961
1969            for( i=0; i<namcos22_nvmem_size/4; i++ )
1962            for( i=0; i<state->m_nvmem_size/4; i++ )
19701963            {
1971               namcos22_nvmem[i] = (nvram[0+i*4]<<24)|(nvram[1+i*4]<<16)|(nvram[2+i*4]<<8)|nvram[3+i*4];
1964               state->m_nvmem[i] = (nvram[0+i*4]<<24)|(nvram[1+i*4]<<16)|(nvram[2+i*4]<<8)|nvram[3+i*4];
19721965            }
19731966         }
19741967      }
r11160r11161
20061999   { 0,1,2,3,4,5,6,7 },
20072000   {
20082001      0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8,8*8,9*8,10*8,11*8,12*8,13*8,14*8,15*8
2009   },
2002   },
20102003   {
20112004      0*16*8,1*16*8,2*16*8,3*16*8,4*16*8,5*16*8,6*16*8,7*16*8,
20122005      8*16*8,9*16*8,10*16*8,11*16*8,12*16*8,13*16*8,14*16*8,15*16*8
2013   },
2006   },
20142007   16*16*8
20152008};
20162009
r11160r11161
20852078
20862079static READ32_HANDLER( namcos22_system_controller_r )
20872080{
2088   return namcos22_system_controller[offset];
2081   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2082   return state->m_system_controller[offset];
20892083}
20902084
20912085static int
2092GetDspControlRegister( void )
2086GetDspControlRegister( namcos22_state *state )
20932087{
20942088   int mode;
2095   if( mbSuperSystem22 )
2089   if( state->m_mbSuperSystem22 )
20962090   {
2097      mode = nthbyte(namcos22_system_controller,0x1c);
2091      mode = nthbyte(state->m_system_controller,0x1c);
20982092   }
20992093   else
21002094   {
2101      mode = nthbyte(namcos22_system_controller,0x1a);
2095      mode = nthbyte(state->m_system_controller,0x1a);
21022096   }
21032097   return mode;
21042098} /* GetDspControlRegister */
r11160r11161
21422136
21432137static WRITE32_HANDLER( namcos22_system_controller_w )
21442138{
2145   int oldReg = GetDspControlRegister();
2139   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2140   int oldReg = GetDspControlRegister(state);
21462141   int newReg;
21472142
21482143   if( 0 )
r11160r11161
21682163      }
21692164   }
21702165
2171   if( mbSuperSystem22 )
2166   if( state->m_mbSuperSystem22 )
21722167   {
21732168      if (offset == 0x14/4 && mem_mask == 0x0000ff00)
21742169      { /* SUBCPU enable for Super System 22 */
r11160r11161
21932188      }
21942189   }
21952190
2196   COMBINE_DATA( &namcos22_system_controller[offset] );
2191   COMBINE_DATA( &state->m_system_controller[offset] );
21972192
2198   newReg = GetDspControlRegister();
2193   newReg = GetDspControlRegister(state);
21992194   if( newReg != oldReg )
22002195   {
22012196      if( newReg == 0 )
22022197      { /* disable DSPs */
22032198         cputag_set_input_line(space->machine(), "master", INPUT_LINE_RESET, ASSERT_LINE); /* master DSP */
22042199         cputag_set_input_line(space->machine(), "slave", INPUT_LINE_RESET, ASSERT_LINE); /* slave DSP */
2205         mbEnableDspIrqs = 0;
2200         state->m_mbEnableDspIrqs = 0;
22062201      }
22072202      else if( newReg == 1 )
22082203      { /*enable dsp and rendering subsystem */
22092204         cputag_set_input_line(space->machine(), "master", INPUT_LINE_RESET, CLEAR_LINE);
2210         namcos22_enable_slave_simulation();
2211         mbEnableDspIrqs = 1;
2205         namcos22_enable_slave_simulation(space->machine());
2206         state->m_mbEnableDspIrqs = 1;
22122207      }
22132208      else if( newReg == 0xff )
22142209      { /* used to upload game-specific code to master/slave dsps */
22152210         cputag_set_input_line(space->machine(), "master", INPUT_LINE_RESET, CLEAR_LINE);
2216         mbEnableDspIrqs = 0;
2211         state->m_mbEnableDspIrqs = 0;
22172212      }
22182213   }
22192214} /* namcos22_system_controller_w */
r11160r11161
22322227*/
22332228static INTERRUPT_GEN( namcos22s_interrupt )
22342229{
2230   namcos22_state *state = device->machine().driver_data<namcos22_state>();
22352231   if( cpu_getiloops(device) == 0 )
22362232   {
2237      int vblank_level   = nthbyte(namcos22_system_controller,0x00)&0x7; /* $700004: ack */
2233      int vblank_level   = nthbyte(state->m_system_controller,0x00)&0x7; /* $700004: ack */
22382234      device_set_input_line(device, vblank_level, HOLD_LINE);
2239      mFrameCount++;
2235      state->m_mFrameCount++;
22402236   }
22412237   else
22422238   {
2243      //int scanline_level = nthbyte(namcos22_system_controller,0x01)&0x7; /* $700005: ack */
2244      //int sci_level      = nthbyte(namcos22_system_controller,0x02)&0x7; /* $700006: ack */
2245      //int unk_irq        = nthbyte(namcos22_system_controller,0x03)&0x7; /* $700007: ack */
2239      //int scanline_level = nthbyte(state->m_system_controller,0x01)&0x7; /* $700005: ack */
2240      //int sci_level      = nthbyte(state->m_system_controller,0x02)&0x7; /* $700006: ack */
2241      //int unk_irq        = nthbyte(state->m_system_controller,0x03)&0x7; /* $700007: ack */
22462242      //device_set_input_line(device, sci_level, HOLD_LINE);
22472243   }
22482244}
22492245
22502246static READ32_HANDLER( namcos22_keycus_r )
22512247{
2248   namcos22_state *state = space->machine().driver_data<namcos22_state>();
22522249//  printf("Hit keycus mask %x PC=%x\n", mem_mask, cpu_get_pc(&space->device()));
22532250
2254   switch( namcos22_gametype )
2251   switch( state->m_gametype )
22552252   {
22562253   case NAMCOS22_RIDGE_RACER:
22572254   case NAMCOS22_RIDGE_RACER2:
r11160r11161
23052302 */
23062303static READ32_HANDLER( namcos22_portbit_r )
23072304{
2308   UINT32 data = mSys22PortBits;
2309   mSys22PortBits>>=1;
2305   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2306   UINT32 data = state->m_mSys22PortBits;
2307   state->m_mSys22PortBits>>=1;
23102308   return data&0x10001;
23112309}
23122310static WRITE32_HANDLER( namcos22_portbit_w )
23132311{
2312   namcos22_state *state = space->machine().driver_data<namcos22_state>();
23142313   unsigned dat50000008 = AnalogAsDigital(space->machine());
23152314   unsigned dat5000000a = 0xffff;
2316   mSys22PortBits = (dat50000008<<16)|dat5000000a;
2315   state->m_mSys22PortBits = (dat50000008<<16)|dat5000000a;
23172316}
23182317
23192318static READ32_HANDLER( namcos22_dipswitch_r )
r11160r11161
23232322
23242323static READ32_HANDLER( namcos22_mcuram_r )
23252324{
2326   return namcos22_shareram[offset];
2325   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2326   return state->m_shareram[offset];
23272327}
23282328
23292329static WRITE32_HANDLER( namcos22_mcuram_w )
23302330{
2331   COMBINE_DATA(&namcos22_shareram[offset]);
2331   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2332   COMBINE_DATA(&state->m_shareram[offset]);
23322333}
23332334
23342335/**
r11160r11161
24042405   }
24052406} /* namcos22_gun_r */
24062407
2407static UINT32 mAlpineSurferProtData;
24082408
24092409static READ32_HANDLER( alpinesa_prot_r )
24102410{
2411   return mAlpineSurferProtData;
2411   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2412   return state->m_mAlpineSurferProtData;
24122413} /* alpinesa_prot_r */
24132414
24142415static WRITE32_HANDLER( alpinesa_prot_w )
24152416{
2417   namcos22_state *state = space->machine().driver_data<namcos22_state>();
24162418#if 1
24172419   switch( data )
24182420   {
24192421   case 0:
2420      mAlpineSurferProtData = 0;
2422      state->m_mAlpineSurferProtData = 0;
24212423      break;
24222424   case 1:
2423      mAlpineSurferProtData = 1;
2425      state->m_mAlpineSurferProtData = 1;
24242426      break;
24252427   case 3:
2426      mAlpineSurferProtData = 2;
2428      state->m_mAlpineSurferProtData = 2;
24272429      break;
24282430   default:
24292431      break;
r11160r11161
24312433#else
24322434   int i;
24332435   unsigned sptr = downcast<cpu_device *>(&space->device())->sp();
2434   mAlpineSurferProtData = 0;
2436   state->m_mAlpineSurferProtData = 0;
24352437   for(i=0;i<4;i++)
24362438   {
2437      mAlpineSurferProtData<<=8;
2438      mAlpineSurferProtData |= space->read_byte(sptr+4+i );
2439      state->m_mAlpineSurferProtData<<=8;
2440      state->m_mAlpineSurferProtData |= space->read_byte(sptr+4+i );
24392441   }
24402442#endif
24412443} /* alpinesa_prot_w */
r11160r11161
24512453   AM_RANGE(0x430000, 0x43000f) AM_READ(namcos22_gun_r) AM_WRITENOP /* LEDs? */
24522454   AM_RANGE(0x440000, 0x440003) AM_READ(namcos22_dipswitch_r)
24532455   AM_RANGE(0x450008, 0x45000b) AM_READ(namcos22_portbit_r) AM_WRITE(namcos22_portbit_w)
2454   AM_RANGE(0x460000, 0x463fff) AM_RAM AM_BASE(&namcos22_nvmem) AM_SIZE(&namcos22_nvmem_size)
2455   AM_RANGE(0x700000, 0x70001f) AM_READ(namcos22_system_controller_r) AM_WRITE(namcos22_system_controller_w) AM_BASE(&namcos22_system_controller)
2456   AM_RANGE(0x460000, 0x463fff) AM_RAM AM_BASE_SIZE_MEMBER(namcos22_state, m_nvmem, m_nvmem_size)
2457   AM_RANGE(0x700000, 0x70001f) AM_READ(namcos22_system_controller_r) AM_WRITE(namcos22_system_controller_w) AM_BASE_MEMBER(namcos22_state, m_system_controller)
24562458   AM_RANGE(0x800000, 0x800003) AM_WRITE(namcos22_port800000_w) /* (C304 C399)  40380000 during SPOT test */
2457   AM_RANGE(0x810000, 0x81000f) AM_RAM AM_BASE(&namcos22_czattr)
2459   AM_RANGE(0x810000, 0x81000f) AM_RAM AM_BASE_MEMBER(namcos22_state, m_czattr)
24582460   AM_RANGE(0x810200, 0x8103ff) AM_READ(namcos22_czram_r) AM_WRITE(namcos22_czram_w)
24592461   AM_RANGE(0x820000, 0x8202ff) AM_RAM /* unknown (air combat) */
2460   AM_RANGE(0x824000, 0x8243ff) AM_READ(namcos22_gamma_r) AM_WRITE(namcos22_gamma_w) AM_BASE(&namcos22_gamma)
2462   AM_RANGE(0x824000, 0x8243ff) AM_READ(namcos22_gamma_r) AM_WRITE(namcos22_gamma_w) AM_BASE_MEMBER(namcos22_state, m_gamma)
24612463   AM_RANGE(0x828000, 0x83ffff) AM_READ(namcos22_paletteram_r) AM_WRITE(namcos22_paletteram_w) AM_BASE_GENERIC(paletteram)
24622464   AM_RANGE(0x860000, 0x860007) AM_READ(spotram_r) AM_WRITE(spotram_w)
2463   AM_RANGE(0x880000, 0x89dfff) AM_RAM_WRITE(namcos22_cgram_w) AM_BASE(&namcos22_cgram)
2464   AM_RANGE(0x89e000, 0x89ffff) AM_READ(namcos22_textram_r) AM_WRITE(namcos22_textram_w) AM_BASE(&namcos22_textram)
2465   AM_RANGE(0x8a0000, 0x8a000f) AM_RAM AM_BASE(&namcos22_tilemapattr)
2466   AM_RANGE(0x900000, 0x90ffff) AM_RAM AM_BASE(&namcos22_vics_data)
2467   AM_RANGE(0x940000, 0x94007f) AM_RAM AM_BASE(&namcos22_vics_control)
2465   AM_RANGE(0x880000, 0x89dfff) AM_RAM_WRITE(namcos22_cgram_w) AM_BASE_MEMBER(namcos22_state, m_cgram)
2466   AM_RANGE(0x89e000, 0x89ffff) AM_READ(namcos22_textram_r) AM_WRITE(namcos22_textram_w) AM_BASE_MEMBER(namcos22_state, m_textram)
2467   AM_RANGE(0x8a0000, 0x8a000f) AM_RAM AM_BASE_MEMBER(namcos22_state, m_tilemapattr)
2468   AM_RANGE(0x900000, 0x90ffff) AM_RAM AM_BASE_MEMBER(namcos22_state, m_vics_data)
2469   AM_RANGE(0x940000, 0x94007f) AM_RAM AM_BASE_MEMBER(namcos22_state, m_vics_control)
24682470   AM_RANGE(0x980000, 0x9affff) AM_RAM AM_BASE_MEMBER(namcos22_state, m_spriteram) /* C374 */
2469   AM_RANGE(0xa04000, 0xa0bfff) AM_READ(namcos22_mcuram_r) AM_WRITE(namcos22_mcuram_w) AM_BASE(&namcos22_shareram) /* COM RAM */
2470   AM_RANGE(0xc00000, 0xc1ffff) AM_READ(namcos22_dspram_r) AM_WRITE(namcos22_dspram_w) AM_BASE(&namcos22_polygonram)
2471   AM_RANGE(0xa04000, 0xa0bfff) AM_READ(namcos22_mcuram_r) AM_WRITE(namcos22_mcuram_w) AM_BASE_MEMBER(namcos22_state, m_shareram) /* COM RAM */
2472   AM_RANGE(0xc00000, 0xc1ffff) AM_READ(namcos22_dspram_r) AM_WRITE(namcos22_dspram_w) AM_BASE_MEMBER(namcos22_state, m_polygonram)
24712473   AM_RANGE(0xe00000, 0xe3ffff) AM_RAM /* workram */
24722474ADDRESS_MAP_END
24732475
24742476static READ16_HANDLER( s22mcu_shared_r )
24752477{
2476   UINT16 *share16 = (UINT16 *)namcos22_shareram;
2478   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2479   UINT16 *share16 = (UINT16 *)state->m_shareram;
24772480
24782481   return share16[BYTE_XOR_BE(offset)];
24792482}
24802483
24812484static WRITE16_HANDLER( s22mcu_shared_w )
24822485{
2483   UINT16 *share16 = (UINT16 *)namcos22_shareram;
2486   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2487   UINT16 *share16 = (UINT16 *)state->m_shareram;
24842488
24852489   COMBINE_DATA(&share16[BYTE_XOR_BE(offset)]);
24862490}
24872491
2488static MACHINE_RESET(namcoss22)
2489{
2490   InitDSP(machine, 1/*super*/);
2491}
2492
24932492/*
24942493  MCU memory map
24952494  --------------
r11160r11161
25392538   AM_RANGE(0x308000, 0x308003) AM_NOP   // volume control IC?
25402539ADDRESS_MAP_END
25412540
2542static int p4;
25432541
25442542static READ8_HANDLER( mcu_port5_r )
25452543{
2544   namcos22_state *state = space->machine().driver_data<namcos22_state>();
25462545   // hack for motor status
2547   if ((namcos22_gametype == NAMCOS22_ALPINE_RACER) || (namcos22_gametype == NAMCOS22_ALPINE_RACER_2) || (namcos22_gametype == NAMCOS22_ALPINE_SURFER))
2546   if ((state->m_gametype == NAMCOS22_ALPINE_RACER) || (state->m_gametype == NAMCOS22_ALPINE_RACER_2) || (state->m_gametype == NAMCOS22_ALPINE_SURFER))
25482547   {
2549      if (p4 & 8)
2548      if (state->m_p4 & 8)
25502549      {
2551         if (mFrameCount & 1)
2550         if (state->m_mFrameCount & 1)
25522551         {
25532552            return input_port_read_safe(space->machine(), "MCUP5A", 0xff) | 0x80;
25542553         }
r11160r11161
25592558      }
25602559      else
25612560      {
2562         if (mFrameCount & 1)
2561         if (state->m_mFrameCount & 1)
25632562         {
25642563            return 0xfe;
25652564         }
r11160r11161
25712570   }
25722571   else
25732572   {
2574      if (p4 & 8)
2573      if (state->m_p4 & 8)
25752574      {
25762575         return input_port_read_safe(space->machine(), "MCUP5A", 0xff);
25772576      }
r11160r11161
25842583
25852584static WRITE8_HANDLER( mcu_port4_w )
25862585{
2587   p4 = data;
2586   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2587   state->m_p4 = data;
25882588}
25892589
25902590static READ8_HANDLER( mcu_port4_r )
25912591{
2592   return p4;
2592   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2593   return state->m_p4;
25932594}
25942595
25952596static WRITE8_HANDLER( mcu_port5_w )
r11160r11161
26182619// H+L = horizontal, 1 H+L = vertical
26192620static READ8_HANDLER( propcycle_mcu_adc_r )
26202621{
2621   static UINT16 ddx, ddy;
2622   UINT16 ddx, ddy;
26222623
26232624   ddx = input_port_read(space->machine(), "STICKX")^0xff;
26242625   if (ddx > 0) ddx -= 1;
r11160r11161
27952796         return ddy & 0xff;
27962797
27972798      case 5:
2798             return (ddy>>8);
2799         return (ddy>>8);
27992800
28002801      default:
28012802         return 0;
r11160r11161
28452846
28462847static READ8_HANDLER( mcu_port4_s22_r )
28472848{
2848   return p4 | 0x10;   // for C74, 0x10 selects sound MCU role, 0x00 selects control-reading role
2849   namcos22_state *state = space->machine().driver_data<namcos22_state>();
2850   return state->m_p4 | 0x10;   // for C74, 0x10 selects sound MCU role, 0x00 selects control-reading role
28492851}
28502852
28512853static ADDRESS_MAP_START( mcu_s22_io, AS_IO, 8 )
r11160r11161
28682870   }
28692871}
28702872
2873static MACHINE_RESET(namcos22)
2874{
2875   InitDSP(machine);
2876}
2877
28712878static MACHINE_CONFIG_START( namcos22s, namcos22_state )
28722879   MCFG_CPU_ADD("maincpu", M68EC020,SS22_MASTER_CLOCK/2)
28732880   MCFG_CPU_PROGRAM_MAP(namcos22s_am)
r11160r11161
29032910   MCFG_PALETTE_LENGTH(NAMCOS22_PALETTE_SIZE)
29042911   MCFG_GFXDECODE(super)
29052912   MCFG_VIDEO_START(namcos22s)
2906   MCFG_MACHINE_RESET(namcoss22)
2913   MCFG_MACHINE_RESET(namcos22)
29072914
29082915   /* sound hardware */
29092916   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
r11160r11161
30373044     * 4000001e
30383045     * 4000001f
30393046     */
3040   AM_RANGE(0x40000000, 0x4000001f) AM_READ(namcos22_system_controller_r) AM_WRITE(namcos22_system_controller_w) AM_BASE(&namcos22_system_controller)
3047   AM_RANGE(0x40000000, 0x4000001f) AM_READ(namcos22_system_controller_r) AM_WRITE(namcos22_system_controller_w) AM_BASE_MEMBER(namcos22_state, m_system_controller)
30413048
30423049   /**
30433050     * Unknown Device (optional for diagnostics?)
r11160r11161
30603067     * Mounted position: CPU 9E
30613068     * Known chip type: HN58C65P-25 (8k x 8bit EEPROM)
30623069     */
3063   AM_RANGE(0x58000000, 0x58001fff) AM_RAM AM_BASE(&namcos22_nvmem) AM_SIZE(&namcos22_nvmem_size)
3070   AM_RANGE(0x58000000, 0x58001fff) AM_RAM AM_BASE_MEMBER(namcos22_state, m_nvmem) AM_SIZE_MEMBER(namcos22_state, m_nvmem_size)
30643071
30653072   /**
30663073     * C74 (Mitsubishi M37702 MCU) Shared RAM (0x60004000 - 0x6000bfff)
r11160r11161
31023109     * +0x0300 - 0x03ff?    Song Title (put messages here from Sound CPU)
31033110     */
31043111   AM_RANGE(0x60000000, 0x60003fff) AM_WRITENOP
3105   AM_RANGE(0x60004000, 0x6000bfff) AM_READ(namcos22_mcuram_r) AM_WRITE(namcos22_mcuram_w) AM_BASE(&namcos22_shareram)
3112   AM_RANGE(0x60004000, 0x6000bfff) AM_READ(namcos22_mcuram_r) AM_WRITE(namcos22_mcuram_w) AM_BASE_MEMBER(namcos22_state, m_shareram)
31063113
31073114   /**
31083115     * C71 (TI TMS320C25 DSP) Shared RAM (0x70000000 - 0x70020000)
r11160r11161
31123119     * Known chip type: TC55328P-25, N341256P-15
31133120     * Notes: connected bits = 0x00ffffff (24bit)
31143121     */
3115   AM_RANGE(0x70000000, 0x7001ffff) AM_READ(namcos22_dspram_r) AM_WRITE(namcos22_dspram_w) AM_BASE(&namcos22_polygonram)
3122   AM_RANGE(0x70000000, 0x7001ffff) AM_READ(namcos22_dspram_r) AM_WRITE(namcos22_dspram_w) AM_BASE_MEMBER(namcos22_state, m_polygonram)
31163123
31173124   /**
31183125     * LED on PCB(?)
r11160r11161
31243131     * Mounted position: VIDEO 8P
31253132     * Known chip type: TC55328P-25
31263133     */
3127   AM_RANGE(0x90010000, 0x90017fff) AM_RAM /* AM_BASE(&namcos22_czram) */
3134   AM_RANGE(0x90010000, 0x90017fff) AM_RAM /* AM_BASE_MEMBER(namcos22_state, m_czram) */
31283135
31293136   /**
31303137     * C305 (Display Controller)
r11160r11161
31443151     *
31453152     * Notes: Boot time check: 0x90020100 - 0x9002027f
31463153     */
3147   AM_RANGE(0x90020000, 0x90027fff) /*AM_RAM*/ AM_READ(namcos22_gamma_r) AM_WRITE(namcos22_gamma_w) AM_BASE(&namcos22_gamma)
3154   AM_RANGE(0x90020000, 0x90027fff) /*AM_RAM*/ AM_READ(namcos22_gamma_r) AM_WRITE(namcos22_gamma_w) AM_BASE_MEMBER(namcos22_state, m_gamma)
31483155
31493156   /**
31503157     * 0x90028000 - 0x9002ffff  Palette (R)
r11160r11161
31653172   /**
31663173     * Tilemap PCG Memory
31673174     */
3168   AM_RANGE(0x90080000, 0x9009dfff) AM_RAM_WRITE(namcos22_cgram_w) AM_BASE(&namcos22_cgram)
3175   AM_RANGE(0x90080000, 0x9009dfff) AM_RAM_WRITE(namcos22_cgram_w) AM_BASE_MEMBER(namcos22_state, m_cgram)
31693176
31703177   /**
31713178     * Tilemap Memory (64 x 64)
r11160r11161
31733180     * Known chip type: HM511664 (64k x 16bit SRAM)
31743181     * Note: Self test: 90084000 - 9009ffff
31753182     */
3176   AM_RANGE(0x9009e000, 0x9009ffff) AM_RAM_WRITE(namcos22_textram_w) AM_BASE(&namcos22_textram)
3183   AM_RANGE(0x9009e000, 0x9009ffff) AM_RAM_WRITE(namcos22_textram_w) AM_BASE_MEMBER(namcos22_state, m_textram)
31773184
31783185   /**
31793186     * Tilemap Register
r11160r11161
31813188     * +0x0000 Position X
31823189     * +0x0002 Position Y
31833190     */
3184   AM_RANGE(0x900a0000, 0x900a000f) AM_RAM AM_BASE(&namcos22_tilemapattr)
3191   AM_RANGE(0x900a0000, 0x900a000f) AM_RAM AM_BASE_MEMBER(namcos22_state, m_tilemapattr)
31853192ADDRESS_MAP_END
31863193
31873194static INTERRUPT_GEN( namcos22_interrupt )
31883195{
3196   namcos22_state *state = device->machine().driver_data<namcos22_state>();
31893197   int irq_level1 = 5;
31903198   int irq_level2 = 6;
31913199
3192   switch( namcos22_gametype )
3200   switch( state->m_gametype )
31933201   {
31943202   case NAMCOS22_RIDGE_RACER:
31953203      HandleDrivingIO(device->machine());
r11160r11161
32303238      // a60 irq
32313239      // abe indirect to 27f1e (SCI)
32323240      // ac4 (rte)
3233      irq_level1 = nthbyte(namcos22_system_controller,0x04)&0x7;
3234      irq_level2 = nthbyte(namcos22_system_controller,0x02)&0x7;
3241      irq_level1 = nthbyte(state->m_system_controller,0x04)&0x7;
3242      irq_level2 = nthbyte(state->m_system_controller,0x02)&0x7;
32353243      break;
32363244
32373245   case NAMCOS22_ACE_DRIVER:
r11160r11161
32543262      //
32553263      //move.b  #$34, $40000004.l
32563264      HandleCyberCommandoIO(device->machine());
3257      irq_level1 = nthbyte(namcos22_system_controller,0x04)&0x7;
3258      irq_level2 = nthbyte(namcos22_system_controller,0x02)&0x7;
3265      irq_level1 = nthbyte(state->m_system_controller,0x04)&0x7;
3266      irq_level2 = nthbyte(state->m_system_controller,0x02)&0x7;
32593267      break;
32603268
32613269   default:
r11160r11161
32793287   }
32803288}
32813289
3282static MACHINE_RESET(namcos22)
3283{
3284   InitDSP(machine, 0);
3285}
3286
32873290static MACHINE_CONFIG_START( namcos22, namcos22_state )
32883291   MCFG_CPU_ADD("maincpu", M68020,SS22_MASTER_CLOCK/2) /* 25 MHz? */
32893292   MCFG_CPU_PROGRAM_MAP(namcos22_am)
r11160r11161
33923395   ROM_LOAD32_BYTE( "ar2ver-c.1", 0x00003, 0x100000, CRC(61323842) SHA1(e3c33248340bee252f230124fa9b7fa935a60565) )
33933396   ROM_LOAD32_BYTE( "ar2ver-c.2", 0x00002, 0x100000, CRC(43795b2d) SHA1(e060f3259661279a36300431c5ca7347bde8b6ec) )
33943397   ROM_LOAD32_BYTE( "ar2ver-c.3", 0x00001, 0x100000, CRC(acb3003b) SHA1(ea0cbf3a1607b06b108df051f38fec1f214f42d2) )
3395        ROM_LOAD32_BYTE( "ar2ver-c.4", 0x00000, 0x100000, CRC(800acc21) SHA1(41d26766da2db46954a2351bbc50aea94bc1d564) )
3398   ROM_LOAD32_BYTE( "ar2ver-c.4", 0x00000, 0x100000, CRC(800acc21) SHA1(41d26766da2db46954a2351bbc50aea94bc1d564) )
33963399
33973400   ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
33983401   ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )
r11160r11161
35013504
35023505ROM_START( alpinr2b )
35033506   ROM_REGION( 0x800000, "maincpu", 0 ) /* main program */
3504        ROM_LOAD32_BYTE( "ars2ver-b.2",  0x000003, 0x200000, CRC(ed977f83) SHA1(26c57cdfc15f799a999ee22f141e1c0cabfc91dc) )
3505        ROM_LOAD32_BYTE( "ars2ver-b.3",  0x000001, 0x200000, CRC(8e7a9983) SHA1(34c82e5f080efe04d6b77a77a8391cb48b69c1af) )
3506        ROM_LOAD32_BYTE( "ars2ver-b.4",  0x000002, 0x200000, CRC(610e49c2) SHA1(433c6d2216551bac31584306f748af1c912c3b07) )
3507        ROM_LOAD32_BYTE( "ars2ver-b.5",  0x000000, 0x200000, CRC(7f3517b0) SHA1(3e6ba1a51bf235f40f933aae1f00638b88bba522) )
3507   ROM_LOAD32_BYTE( "ars2ver-b.2",  0x000003, 0x200000, CRC(ed977f83) SHA1(26c57cdfc15f799a999ee22f141e1c0cabfc91dc) )
3508   ROM_LOAD32_BYTE( "ars2ver-b.3",  0x000001, 0x200000, CRC(8e7a9983) SHA1(34c82e5f080efe04d6b77a77a8391cb48b69c1af) )
3509   ROM_LOAD32_BYTE( "ars2ver-b.4",  0x000002, 0x200000, CRC(610e49c2) SHA1(433c6d2216551bac31584306f748af1c912c3b07) )
3510   ROM_LOAD32_BYTE( "ars2ver-b.5",  0x000000, 0x200000, CRC(7f3517b0) SHA1(3e6ba1a51bf235f40f933aae1f00638b88bba522) )
35083511
35093512   ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
35103513   ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )
r11160r11161
35153518   ROM_REGION( 0x080000, "mcu", ROMREGION_ERASE00 ) /* S22-BIOS ver1.30 */
35163519
35173520   ROM_REGION16_LE( 0x080000, "user4", 0 ) /* MCU BIOS */
3518        ROM_LOAD( "ars2data.8k",  0x000000, 0x080000, CRC(29b36dcb) SHA1(70fde130c11789c822829493a70ecefb077c0c15) )
3521   ROM_LOAD( "ars2data.8k",  0x000000, 0x080000, CRC(29b36dcb) SHA1(70fde130c11789c822829493a70ecefb077c0c15) )
35193522
35203523   ROM_REGION( 0x200000*2, "sprite", 0 ) /* 32x32x8bpp sprite tiles */
3521        ROM_LOAD( "ars1scg0.12f", 0x000000, 0x200000, CRC(bc49ed86) SHA1(289b39f2cb21c723dbe4ddd64ee4b2c5fa65c368) )
3524   ROM_LOAD( "ars1scg0.12f", 0x000000, 0x200000, CRC(bc49ed86) SHA1(289b39f2cb21c723dbe4ddd64ee4b2c5fa65c368) )
35223525
35233526   ROM_REGION( 0xc00000, "textile", 0) /* 16x16x8bpp texture tiles */
3524        ROM_LOAD( "ars1cg0.8d",   0x000000, 0x200000, CRC(74f4515c) SHA1(1e3a96281d543213d10c962b4d387c414d76e0c3) )
3525        ROM_LOAD( "ars1cg1.10d",  0x200000, 0x200000, CRC(329a95c1) SHA1(2cad7fd9e5ca7c64729ca2548ef4f873a0b8de64) )
3526        ROM_LOAD( "ars1cg2.12d",  0x400000, 0x200000, CRC(5648345a) SHA1(0dc7aedba65b7d97687a9e38a63597f16cee6179) )
3527        ROM_LOAD( "ars1cg3.13d",  0x600000, 0x200000, CRC(a752f205) SHA1(373b5a69e4488bc30763568ceae512ab7039f5f8) )
3528        ROM_LOAD( "ars1cg4.14d",  0x800000, 0x200000, CRC(54bf35b6) SHA1(aec43b66e7597ad7d113ae785417bf26164c1bca) )
3529        ROM_LOAD( "ars1cg5.16d",  0xa00000, 0x200000, CRC(e24a19a2) SHA1(34c1b51eea954ae3000602e550eb1cef0a10e651) )
3527   ROM_LOAD( "ars1cg0.8d",   0x000000, 0x200000, CRC(74f4515c) SHA1(1e3a96281d543213d10c962b4d387c414d76e0c3) )
3528   ROM_LOAD( "ars1cg1.10d",  0x200000, 0x200000, CRC(329a95c1) SHA1(2cad7fd9e5ca7c64729ca2548ef4f873a0b8de64) )
3529   ROM_LOAD( "ars1cg2.12d",  0x400000, 0x200000, CRC(5648345a) SHA1(0dc7aedba65b7d97687a9e38a63597f16cee6179) )
3530   ROM_LOAD( "ars1cg3.13d",  0x600000, 0x200000, CRC(a752f205) SHA1(373b5a69e4488bc30763568ceae512ab7039f5f8) )
3531   ROM_LOAD( "ars1cg4.14d",  0x800000, 0x200000, CRC(54bf35b6) SHA1(aec43b66e7597ad7d113ae785417bf26164c1bca) )
3532   ROM_LOAD( "ars1cg5.16d",  0xa00000, 0x200000, CRC(e24a19a2) SHA1(34c1b51eea954ae3000602e550eb1cef0a10e651) )
35303533
35313534   ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
3532        ROM_LOAD( "ars1ccrl.3d",  0x000000, 0x200000, CRC(fc8c9161) SHA1(ad0fcfae27e02d68a6f8d1d03c514dc2f12d9ee8) )
3533        ROM_LOAD( "ars1ccrh.1d",  0x200000, 0x080000, CRC(a17660bb) SHA1(bae2c3f20772c6cea99f271ee3f39b1f999038c6) )
3535   ROM_LOAD( "ars1ccrl.3d",  0x000000, 0x200000, CRC(fc8c9161) SHA1(ad0fcfae27e02d68a6f8d1d03c514dc2f12d9ee8) )
3536   ROM_LOAD( "ars1ccrh.1d",  0x200000, 0x080000, CRC(a17660bb) SHA1(bae2c3f20772c6cea99f271ee3f39b1f999038c6) )
35343537
35353538   ROM_REGION( 0x80000*12, "pointrom", 0 ) /* 3d model data */
3536        ROM_LOAD( "ars1ptrl0.18k", 0x000000, 0x080000, CRC(f04e0e61) SHA1(d58a1d3ca1d0922e134db21a04feaee7dc97b020) )
3537        ROM_LOAD( "ars1ptrl1.16k", 0x080000, 0x080000, CRC(8bdb4970) SHA1(a504cd4beca4bedd1a7a228c83dd6b844ca3a1e0) )
3538        ROM_LOAD( "ars1ptrl2.15k", 0x100000, 0x080000, CRC(ec993a4f) SHA1(883f64e3e8d951415e9cef589c354eba9406c0aa) )
3539        ROM_LOAD( "ars1ptrl3.14k", 0x180000, 0x080000, CRC(4d453f3c) SHA1(7a82e5d8f974d9e56d0031b35e73647fe6aeec2e) )
3539   ROM_LOAD( "ars1ptrl0.18k", 0x000000, 0x080000, CRC(f04e0e61) SHA1(d58a1d3ca1d0922e134db21a04feaee7dc97b020) )
3540   ROM_LOAD( "ars1ptrl1.16k", 0x080000, 0x080000, CRC(8bdb4970) SHA1(a504cd4beca4bedd1a7a228c83dd6b844ca3a1e0) )
3541   ROM_LOAD( "ars1ptrl2.15k", 0x100000, 0x080000, CRC(ec993a4f) SHA1(883f64e3e8d951415e9cef589c354eba9406c0aa) )
3542   ROM_LOAD( "ars1ptrl3.14k", 0x180000, 0x080000, CRC(4d453f3c) SHA1(7a82e5d8f974d9e56d0031b35e73647fe6aeec2e) )
35403543
3541        ROM_LOAD( "ars1ptrm0.18j", 0x200000, 0x080000, CRC(d1bdc524) SHA1(b898bb38de397551ada4da4677dd733bf8fa5010) )
3542        ROM_LOAD( "ars1ptrm1.16j", 0x280000, 0x080000, CRC(86b81c81) SHA1(45096abf46794f06a4b647f5e4222798d8467632) )
3543        ROM_LOAD( "ars1ptrm2.15j", 0x300000, 0x080000, CRC(24116b83) SHA1(41c6a880abce7b543c409fda767682b2537b0d99) )
3544        ROM_LOAD( "ars1ptrm3.14j", 0x380000, 0x080000, CRC(772bede3) SHA1(f9565b7a40f0bbf11081d619fe5a46feafce2e56) )
3544   ROM_LOAD( "ars1ptrm0.18j", 0x200000, 0x080000, CRC(d1bdc524) SHA1(b898bb38de397551ada4da4677dd733bf8fa5010) )
3545   ROM_LOAD( "ars1ptrm1.16j", 0x280000, 0x080000, CRC(86b81c81) SHA1(45096abf46794f06a4b647f5e4222798d8467632) )
3546   ROM_LOAD( "ars1ptrm2.15j", 0x300000, 0x080000, CRC(24116b83) SHA1(41c6a880abce7b543c409fda767682b2537b0d99) )
3547   ROM_LOAD( "ars1ptrm3.14j", 0x380000, 0x080000, CRC(772bede3) SHA1(f9565b7a40f0bbf11081d619fe5a46feafce2e56) )
35453548
3546        ROM_LOAD( "ars1ptru0.18f", 0x400000, 0x080000, CRC(a4cf197a) SHA1(ee78cc259e87395df75179bbe5b6e521e762b582) )
3547        ROM_LOAD( "ars1ptru1.16f", 0x480000, 0x080000, CRC(1deb1fc0) SHA1(bfd1dfcaccf5a0f851b6757995fa7195452a3965) )
3548        ROM_LOAD( "ars1ptru2.15f", 0x500000, 0x080000, CRC(bcfad0ba) SHA1(bee7f2f9ecd2b289c6706e19fa86863913b286b5) )
3549        ROM_LOAD( "ars1ptru3.14f", 0x580000, 0x080000, CRC(73ce6958) SHA1(918b0fb0fca33dbe3be3ac679b8b28f58213f75b) )
3549   ROM_LOAD( "ars1ptru0.18f", 0x400000, 0x080000, CRC(a4cf197a) SHA1(ee78cc259e87395df75179bbe5b6e521e762b582) )
3550   ROM_LOAD( "ars1ptru1.16f", 0x480000, 0x080000, CRC(1deb1fc0) SHA1(bfd1dfcaccf5a0f851b6757995fa7195452a3965) )
3551   ROM_LOAD( "ars1ptru2.15f", 0x500000, 0x080000, CRC(bcfad0ba) SHA1(bee7f2f9ecd2b289c6706e19fa86863913b286b5) )
3552   ROM_LOAD( "ars1ptru3.14f", 0x580000, 0x080000, CRC(73ce6958) SHA1(918b0fb0fca33dbe3be3ac679b8b28f58213f75b) )
35503553
35513554   ROM_REGION( 0x1000000, "c352", 0 ) /* sound samples */
3552        ROM_LOAD( "ars1wavea.2l", 0x000000, 0x400000, CRC(f8d107e9) SHA1(5c418691f0b35403553f21f5570eda8bbb66890f) )
3553        ROM_LOAD( "ars2waveb.1l", 0x800000, 0x400000, CRC(deab4ad1) SHA1(580ad88d516280baaf6cc92b2e07cdc0cfc486f3) )
3555   ROM_LOAD( "ars1wavea.2l", 0x000000, 0x400000, CRC(f8d107e9) SHA1(5c418691f0b35403553f21f5570eda8bbb66890f) )
3556   ROM_LOAD( "ars2waveb.1l", 0x800000, 0x400000, CRC(deab4ad1) SHA1(580ad88d516280baaf6cc92b2e07cdc0cfc486f3) )
35543557ROM_END
35553558
35563559ROM_START( alpinr2a )
35573560   ROM_REGION( 0x800000, "maincpu", 0 ) /* main program */
3558        ROM_LOAD32_BYTE( "ars2ver-a.2",  0x000003, 0x200000, CRC(b07b15a4) SHA1(ea3b2d7b4ef4ccf3aafeef7e7eac92e8d446f4e7) )
3559        ROM_LOAD32_BYTE( "ars2ver-a.3",  0x000002, 0x200000, CRC(90a92e40) SHA1(bf8083256e56e7e33e61b4cdaf9fd03dabfb36ba) )
3560        ROM_LOAD32_BYTE( "ars2ver-a.4",  0x000001, 0x200000, CRC(9e9d771d) SHA1(6fb983e3f4f8233544667b1bbf87864e4fb8698c) )
3561        ROM_LOAD32_BYTE( "ars2ver-a.5",  0x000000, 0x200000, CRC(e93c7771) SHA1(305f35488a55be1b845702df972bba8334c0726c) )
3561   ROM_LOAD32_BYTE( "ars2ver-a.2",  0x000003, 0x200000, CRC(b07b15a4) SHA1(ea3b2d7b4ef4ccf3aafeef7e7eac92e8d446f4e7) )
3562   ROM_LOAD32_BYTE( "ars2ver-a.3",  0x000002, 0x200000, CRC(90a92e40) SHA1(bf8083256e56e7e33e61b4cdaf9fd03dabfb36ba) )
3563   ROM_LOAD32_BYTE( "ars2ver-a.4",  0x000001, 0x200000, CRC(9e9d771d) SHA1(6fb983e3f4f8233544667b1bbf87864e4fb8698c) )
3564   ROM_LOAD32_BYTE( "ars2ver-a.5",  0x000000, 0x200000, CRC(e93c7771) SHA1(305f35488a55be1b845702df972bba8334c0726c) )
35623565
35633566   ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
35643567   ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )
r11160r11161
35693572   ROM_REGION( 0x080000, "mcu", ROMREGION_ERASE00 ) /* S22-BIOS ver1.30 */
35703573
35713574   ROM_REGION16_LE( 0x080000, "user4", 0 ) /* MCU BIOS */
3572        ROM_LOAD( "ars2data.8k",  0x000000, 0x080000, CRC(29b36dcb) SHA1(70fde130c11789c822829493a70ecefb077c0c15) )
3575   ROM_LOAD( "ars2data.8k",  0x000000, 0x080000, CRC(29b36dcb) SHA1(70fde130c11789c822829493a70ecefb077c0c15) )
35733576
35743577   ROM_REGION( 0x200000*2, "sprite", 0 ) /* 32x32x8bpp sprite tiles */
3575        ROM_LOAD( "ars1scg0.12f", 0x000000, 0x200000, CRC(bc49ed86) SHA1(289b39f2cb21c723dbe4ddd64ee4b2c5fa65c368) )
3578   ROM_LOAD( "ars1scg0.12f", 0x000000, 0x200000, CRC(bc49ed86) SHA1(289b39f2cb21c723dbe4ddd64ee4b2c5fa65c368) )
35763579
35773580   ROM_REGION( 0xc00000, "textile", 0) /* 16x16x8bpp texture tiles */
3578        ROM_LOAD( "ars1cg0.8d",   0x000000, 0x200000, CRC(74f4515c) SHA1(1e3a96281d543213d10c962b4d387c414d76e0c3) )
3579        ROM_LOAD( "ars1cg1.10d",  0x200000, 0x200000, CRC(329a95c1) SHA1(2cad7fd9e5ca7c64729ca2548ef4f873a0b8de64) )
3580        ROM_LOAD( "ars1cg2.12d",  0x400000, 0x200000, CRC(5648345a) SHA1(0dc7aedba65b7d97687a9e38a63597f16cee6179) )
3581        ROM_LOAD( "ars1cg3.13d",  0x600000, 0x200000, CRC(a752f205) SHA1(373b5a69e4488bc30763568ceae512ab7039f5f8) )
3582        ROM_LOAD( "ars1cg4.14d",  0x800000, 0x200000, CRC(54bf35b6) SHA1(aec43b66e7597ad7d113ae785417bf26164c1bca) )
3583        ROM_LOAD( "ars1cg5.16d",  0xa00000, 0x200000, CRC(e24a19a2) SHA1(34c1b51eea954ae3000602e550eb1cef0a10e651) )
3581   ROM_LOAD( "ars1cg0.8d",   0x000000, 0x200000, CRC(74f4515c) SHA1(1e3a96281d543213d10c962b4d387c414d76e0c3) )
3582   ROM_LOAD( "ars1cg1.10d",  0x200000, 0x200000, CRC(329a95c1) SHA1(2cad7fd9e5ca7c64729ca2548ef4f873a0b8de64) )
3583   ROM_LOAD( "ars1cg2.12d",  0x400000, 0x200000, CRC(5648345a) SHA1(0dc7aedba65b7d97687a9e38a63597f16cee6179) )
3584   ROM_LOAD( "ars1cg3.13d",  0x600000, 0x200000, CRC(a752f205) SHA1(373b5a69e4488bc30763568ceae512ab7039f5f8) )
3585   ROM_LOAD( "ars1cg4.14d",  0x800000, 0x200000, CRC(54bf35b6) SHA1(aec43b66e7597ad7d113ae785417bf26164c1bca) )
3586   ROM_LOAD( "ars1cg5.16d",  0xa00000, 0x200000, CRC(e24a19a2) SHA1(34c1b51eea954ae3000602e550eb1cef0a10e651) )
35843587
35853588   ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
3586        ROM_LOAD( "ars1ccrl.3d",  0x000000, 0x200000, CRC(fc8c9161) SHA1(ad0fcfae27e02d68a6f8d1d03c514dc2f12d9ee8) )
3587        ROM_LOAD( "ars1ccrh.1d",  0x200000, 0x080000, CRC(a17660bb) SHA1(bae2c3f20772c6cea99f271ee3f39b1f999038c6) )
3589   ROM_LOAD( "ars1ccrl.3d",  0x000000, 0x200000, CRC(fc8c9161) SHA1(ad0fcfae27e02d68a6f8d1d03c514dc2f12d9ee8) )
3590   ROM_LOAD( "ars1ccrh.1d",  0x200000, 0x080000, CRC(a17660bb) SHA1(bae2c3f20772c6cea99f271ee3f39b1f999038c6) )
35883591
35893592   ROM_REGION( 0x80000*12, "pointrom", 0 ) /* 3d model data */
3590        ROM_LOAD( "ars1ptrl0.18k", 0x000000, 0x080000, CRC(f04e0e61) SHA1(d58a1d3ca1d0922e134db21a04feaee7dc97b020) )
3591        ROM_LOAD( "ars1ptrl1.16k", 0x080000, 0x080000, CRC(8bdb4970) SHA1(a504cd4beca4bedd1a7a228c83dd6b844ca3a1e0) )
3592        ROM_LOAD( "ars1ptrl2.15k", 0x100000, 0x080000, CRC(ec993a4f) SHA1(883f64e3e8d951415e9cef589c354eba9406c0aa) )
3593        ROM_LOAD( "ars1ptrl3.14k", 0x180000, 0x080000, CRC(4d453f3c) SHA1(7a82e5d8f974d9e56d0031b35e73647fe6aeec2e) )
3593   ROM_LOAD( "ars1ptrl0.18k", 0x000000, 0x080000, CRC(f04e0e61) SHA1(d58a1d3ca1d0922e134db21a04feaee7dc97b020) )
3594   ROM_LOAD( "ars1ptrl1.16k", 0x080000, 0x080000, CRC(8bdb4970) SHA1(a504cd4beca4bedd1a7a228c83dd6b844ca3a1e0) )
3595   ROM_LOAD( "ars1ptrl2.15k", 0x100000, 0x080000, CRC(ec993a4f) SHA1(883f64e3e8d951415e9cef589c354eba9406c0aa) )
3596   ROM_LOAD( "ars1ptrl3.14k", 0x180000, 0x080000, CRC(4d453f3c) SHA1(7a82e5d8f974d9e56d0031b35e73647fe6aeec2e) )
35943597
3595        ROM_LOAD( "ars1ptrm0.18j", 0x200000, 0x080000, CRC(d1bdc524) SHA1(b898bb38de397551ada4da4677dd733bf8fa5010) )
3596        ROM_LOAD( "ars1ptrm1.16j", 0x280000, 0x080000, CRC(86b81c81) SHA1(45096abf46794f06a4b647f5e4222798d8467632) )
3597        ROM_LOAD( "ars1ptrm2.15j", 0x300000, 0x080000, CRC(24116b83) SHA1(41c6a880abce7b543c409fda767682b2537b0d99) )
3598        ROM_LOAD( "ars1ptrm3.14j", 0x380000, 0x080000, CRC(772bede3) SHA1(f9565b7a40f0bbf11081d619fe5a46feafce2e56) )
3598   ROM_LOAD( "ars1ptrm0.18j", 0x200000, 0x080000, CRC(d1bdc524) SHA1(b898bb38de397551ada4da4677dd733bf8fa5010) )
3599   ROM_LOAD( "ars1ptrm1.16j", 0x280000, 0x080000, CRC(86b81c81) SHA1(45096abf46794f06a4b647f5e4222798d8467632) )
3600   ROM_LOAD( "ars1ptrm2.15j", 0x300000, 0x080000, CRC(24116b83) SHA1(41c6a880abce7b543c409fda767682b2537b0d99) )
3601   ROM_LOAD( "ars1ptrm3.14j", 0x380000, 0x080000, CRC(772bede3) SHA1(f9565b7a40f0bbf11081d619fe5a46feafce2e56) )
35993602
3600        ROM_LOAD( "ars1ptru0.18f", 0x400000, 0x080000, CRC(a4cf197a) SHA1(ee78cc259e87395df75179bbe5b6e521e762b582) )
3601        ROM_LOAD( "ars1ptru1.16f", 0x480000, 0x080000, CRC(1deb1fc0) SHA1(bfd1dfcaccf5a0f851b6757995fa7195452a3965) )
3602        ROM_LOAD( "ars1ptru2.15f", 0x500000, 0x080000, CRC(bcfad0ba) SHA1(bee7f2f9ecd2b289c6706e19fa86863913b286b5) )
3603        ROM_LOAD( "ars1ptru3.14f", 0x580000, 0x080000, CRC(73ce6958) SHA1(918b0fb0fca33dbe3be3ac679b8b28f58213f75b) )
3603   ROM_LOAD( "ars1ptru0.18f", 0x400000, 0x080000, CRC(a4cf197a) SHA1(ee78cc259e87395df75179bbe5b6e521e762b582) )
3604   ROM_LOAD( "ars1ptru1.16f", 0x480000, 0x080000, CRC(1deb1fc0) SHA1(bfd1dfcaccf5a0f851b6757995fa7195452a3965) )
3605   ROM_LOAD( "ars1ptru2.15f", 0x500000, 0x080000, CRC(bcfad0ba) SHA1(bee7f2f9ecd2b289c6706e19fa86863913b286b5) )
3606   ROM_LOAD( "ars1ptru3.14f", 0x580000, 0x080000, CRC(73ce6958) SHA1(918b0fb0fca33dbe3be3ac679b8b28f58213f75b) )
36043607
36053608   ROM_REGION( 0x1000000, "c352", 0 ) /* sound samples */
3606        ROM_LOAD( "ars1wavea.2l", 0x000000, 0x400000, CRC(f8d107e9) SHA1(5c418691f0b35403553f21f5570eda8bbb66890f) )
3607        ROM_LOAD( "ars2waveb.1l", 0x800000, 0x400000, CRC(deab4ad1) SHA1(580ad88d516280baaf6cc92b2e07cdc0cfc486f3) )
3609   ROM_LOAD( "ars1wavea.2l", 0x000000, 0x400000, CRC(f8d107e9) SHA1(5c418691f0b35403553f21f5570eda8bbb66890f) )
3610   ROM_LOAD( "ars2waveb.1l", 0x800000, 0x400000, CRC(deab4ad1) SHA1(580ad88d516280baaf6cc92b2e07cdc0cfc486f3) )
36083611ROM_END
36093612
36103613ROM_START( alpinesa )
36113614   ROM_REGION( 0x800000, "maincpu", 0 ) /* main program */
3612        ROM_LOAD32_BYTE( "af2ver-a_ll.ic2", 0x000003, 0x200000, CRC(e776159d) SHA1(5110364afb7ec606074d58a1d216d7d687b9df62) )
3613        ROM_LOAD32_BYTE( "af2ver-a_lm.ic3", 0x000002, 0x200000, CRC(c5333d38) SHA1(9486cead964f95f8e56dac2f88486f3b98561aa6) )
3614        ROM_LOAD32_BYTE( "af2ver-a_um.ic4", 0x000001, 0x200000, CRC(5977fc6e) SHA1(19b8041789f8987934fa461972976a3570b1b87b) )
3615        ROM_LOAD32_BYTE( "af2ver-a_uu.ic5", 0x000000, 0x200000, CRC(54ee33a1) SHA1(0eaa8707ab13a0a66551f61a08986c98f5c9e446) )
3615   ROM_LOAD32_BYTE( "af2ver-a_ll.ic2", 0x000003, 0x200000, CRC(e776159d) SHA1(5110364afb7ec606074d58a1d216d7d687b9df62) )
3616   ROM_LOAD32_BYTE( "af2ver-a_lm.ic3", 0x000002, 0x200000, CRC(c5333d38) SHA1(9486cead964f95f8e56dac2f88486f3b98561aa6) )
3617   ROM_LOAD32_BYTE( "af2ver-a_um.ic4", 0x000001, 0x200000, CRC(5977fc6e) SHA1(19b8041789f8987934fa461972976a3570b1b87b) )
3618   ROM_LOAD32_BYTE( "af2ver-a_uu.ic5", 0x000000, 0x200000, CRC(54ee33a1) SHA1(0eaa8707ab13a0a66551f61a08986c98f5c9e446) )
36163619
36173620   ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
36183621   ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )
r11160r11161
36233626   ROM_REGION( 0x080000, "mcu", ROMREGION_ERASE00 ) /* S22-BIOS ver1.41 */
36243627
36253628   ROM_REGION16_LE( 0x080000, "user4", 0 ) /* MCU BIOS */
3626        ROM_LOAD( "af1data.8k",   0x000000, 0x080000, CRC(ef13ebe8) SHA1(5d3f697994d4b5b19ee7fea1e2aef8e39449b68e) )
3629   ROM_LOAD( "af1data.8k",   0x000000, 0x080000, CRC(ef13ebe8) SHA1(5d3f697994d4b5b19ee7fea1e2aef8e39449b68e) )
36273630
3628   ROM_REGION( 0x200000*2, "sprite", 0 ) /* 32x32x8bpp sprite tiles */
3629   ROM_LOAD( "af1scg0b.12f", 0x000000, 0x200000, CRC(46a6222a) SHA1(5322ef60690625b9b8dbe1cfe0c49dcd9c8b1a4c) )
3631   ROM_REGION( 0x200000*2, "sprite", 0 ) /* 32x32x8bpp sprite tiles */
3632   ROM_LOAD( "af1scg0b.12f", 0x000000, 0x200000, CRC(46a6222a) SHA1(5322ef60690625b9b8dbe1cfe0c49dcd9c8b1a4c) )
36303633
36313634   ROM_REGION( 0xa00000, "textile", 0) /* 16x16x8bpp texture tiles */
3632        ROM_LOAD( "af1cg0.8d",    0x000000, 0x200000, CRC(7423f3ff) SHA1(6a2fd44823ef46111deb57d328b1b75cc355d413) )
3633        ROM_LOAD( "af1cg1.10d",   0x200000, 0x200000, CRC(ea76689a) SHA1(73dd3af737a3e9903abe5ed9c9ae7eded51d8350) )
3634        ROM_LOAD( "af1cg2.12d",   0x400000, 0x200000, CRC(2a38943a) SHA1(15d737996f49bf6374ef6191bbfbe0298d398378) )
3635        ROM_LOAD( "af1cg3.13d",   0x600000, 0x200000, CRC(7f5a3e0f) SHA1(241f9995323b28df23d20a75e1f43ce6e05434cd) )
3636        ROM_LOAD( "af1cg4.14d",   0x800000, 0x200000, CRC(a5ee13e2) SHA1(48fd3c912690f21cbbc2a39bed0a82be41a0d011) )
3635   ROM_LOAD( "af1cg0.8d",    0x000000, 0x200000, CRC(7423f3ff) SHA1(6a2fd44823ef46111deb57d328b1b75cc355d413) )
3636   ROM_LOAD( "af1cg1.10d",   0x200000, 0x200000, CRC(ea76689a) SHA1(73dd3af737a3e9903abe5ed9c9ae7eded51d8350) )
3637   ROM_LOAD( "af1cg2.12d",   0x400000, 0x200000, CRC(2a38943a) SHA1(15d737996f49bf6374ef6191bbfbe0298d398378) )
3638   ROM_LOAD( "af1cg3.13d",   0x600000, 0x200000, CRC(7f5a3e0f) SHA1(241f9995323b28df23d20a75e1f43ce6e05434cd) )
3639   ROM_LOAD( "af1cg4.14d",   0x800000, 0x200000, CRC(a5ee13e2) SHA1(48fd3c912690f21cbbc2a39bed0a82be41a0d011) )
36373640
36383641   ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
3639        ROM_LOAD( "af1ccrl.3d",   0x000000, 0x200000, CRC(6c054698) SHA1(8537607646b183883c5aa4060fb0af640da4af87) )
3640        ROM_LOAD( "af1ccrh.1d",   0x200000, 0x080000, CRC(95a02a27) SHA1(32ee87b76ae9fcec6d825e3cf4d5cbb97db39544) )
3642   ROM_LOAD( "af1ccrl.3d",   0x000000, 0x200000, CRC(6c054698) SHA1(8537607646b183883c5aa4060fb0af640da4af87) )
3643   ROM_LOAD( "af1ccrh.1d",   0x200000, 0x080000, CRC(95a02a27) SHA1(32ee87b76ae9fcec6d825e3cf4d5cbb97db39544) )
36413644
36423645   ROM_REGION( 0x80000*6, "pointrom", 0 ) /* 3d model data */
3643        ROM_LOAD( "af1ptrl0.18k", 0x80000*0, 0x80000, CRC(31ce46d3) SHA1(568fb9ee9ac14e613a4fd7668cb38315c10be62b) )
3644        ROM_LOAD( "af1ptrl1.16k", 0x80000*1, 0x80000, CRC(e869bf00) SHA1(b3c3026891ae3958d1774c905e97c3b57a414ea7) )
3645        ROM_LOAD( "af1ptrm0.18j", 0x80000*2, 0x80000, CRC(ef7f4d8a) SHA1(02f77c68004b7dccc99b61126e7d07960eb15028) )
3646        ROM_LOAD( "af1ptrm1.16j", 0x80000*3, 0x80000, CRC(7dd01d52) SHA1(adc1087435d31ed6163ad046466955f01517450f) )
3647        ROM_LOAD( "af1ptru0.18f", 0x80000*4, 0x80000, CRC(177f1591) SHA1(3969e780e5603eca0a65f65c1ad14d1cef918b39) )
3648        ROM_LOAD( "af1ptru1.16f", 0x80000*5, 0x80000, CRC(7521d18e) SHA1(dc03ef369db16f59c138ff4e22260d1c04782d1f) )
3646   ROM_LOAD( "af1ptrl0.18k", 0x80000*0, 0x80000, CRC(31ce46d3) SHA1(568fb9ee9ac14e613a4fd7668cb38315c10be62b) )
3647   ROM_LOAD( "af1ptrl1.16k", 0x80000*1, 0x80000, CRC(e869bf00) SHA1(b3c3026891ae3958d1774c905e97c3b57a414ea7) )
3648   ROM_LOAD( "af1ptrm0.18j", 0x80000*2, 0x80000, CRC(ef7f4d8a) SHA1(02f77c68004b7dccc99b61126e7d07960eb15028) )
3649   ROM_LOAD( "af1ptrm1.16j", 0x80000*3, 0x80000, CRC(7dd01d52) SHA1(adc1087435d31ed6163ad046466955f01517450f) )
3650   ROM_LOAD( "af1ptru0.18f", 0x80000*4, 0x80000, CRC(177f1591) SHA1(3969e780e5603eca0a65f65c1ad14d1cef918b39) )
3651   ROM_LOAD( "af1ptru1.16f", 0x80000*5, 0x80000, CRC(7521d18e) SHA1(dc03ef369db16f59c138ff4e22260d1c04782d1f) )
36493652
36503653   ROM_REGION( 0x1000000, "c352", 0 ) /* sound samples */
3651        ROM_LOAD( "af1wavea.2l",  0x000000, 0x400000, CRC(28cca494) SHA1(4ff87ab85fd17bf8dbee5b03d99cc5c31dd6349a) )
3654   ROM_LOAD( "af1wavea.2l",  0x000000, 0x400000, CRC(28cca494) SHA1(4ff87ab85fd17bf8dbee5b03d99cc5c31dd6349a) )
36523655ROM_END
36533656
36543657ROM_START( cybrcomm )
r11160r11161
44374440
44384441ROM_START( ridgerac3 )
44394442   ROM_REGION( 0x200000, "maincpu", 0 ) /* main program */
4440        ROM_LOAD32_BYTE( "rr3prgll-3s.4d", 0x000003, 0x080000, CRC(2c3d8cb7) SHA1(46a7b62938fe3edde5c52ce3fdfe447000cd6af0) )
4441        ROM_LOAD32_BYTE( "rr3prglm-3s.2d", 0x000002, 0x080000, CRC(b15343f2) SHA1(3056eb5a3036a74b2ac641a4c3221986c0be1e27) )
4442        ROM_LOAD32_BYTE( "rr3prgum-3s.8d", 0x000001, 0x080000, CRC(8fda06ac) SHA1(7e9adba198eb0941100cda64ecedac504f6ac696) )
4443        ROM_LOAD32_BYTE( "rr3prguu-3s.6d", 0x000000, 0x080000, CRC(868398df) SHA1(422e0f9884904b0df93fcacd1468b8da0458eb8e) )
4443   ROM_LOAD32_BYTE( "rr3prgll-3s.4d", 0x000003, 0x080000, CRC(2c3d8cb7) SHA1(46a7b62938fe3edde5c52ce3fdfe447000cd6af0) )
4444   ROM_LOAD32_BYTE( "rr3prglm-3s.2d", 0x000002, 0x080000, CRC(b15343f2) SHA1(3056eb5a3036a74b2ac641a4c3221986c0be1e27) )
4445   ROM_LOAD32_BYTE( "rr3prgum-3s.8d", 0x000001, 0x080000, CRC(8fda06ac) SHA1(7e9adba198eb0941100cda64ecedac504f6ac696) )
4446   ROM_LOAD32_BYTE( "rr3prguu-3s.6d", 0x000000, 0x080000, CRC(868398df) SHA1(422e0f9884904b0df93fcacd1468b8da0458eb8e) )
44444447
44454448   ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
44464449   ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )
r11160r11161
46114614   ROM_REGION16_LE( 0x080000, "user4", 0 ) /* MCU BIOS */
46124615   ROM_LOAD( "ts1data.8k", 0, 0x080000, CRC(e68aa973) SHA1(663e80d249be5d5841139d98a9d72e2396851272) )
46134616
4614    ROM_REGION( 0x200000*6, "sprite", 0 ) /* 32x32x8bpp sprite tiles */
4617   ROM_REGION( 0x200000*6, "sprite", 0 ) /* 32x32x8bpp sprite tiles */
46154618   ROM_LOAD( "ts1scg0.12f",0x200000*0, 0x200000,CRC(14a3674d) SHA1(c5792a385572452b43bbc7eb8428335b19daa3c0) )
46164619   ROM_LOAD( "ts1scg1.10f",0x200000*1, 0x200000,CRC(11791dbf) SHA1(3d75b468d69a8bf398d45f310cdb8bc88b63f25c) )
46174620   ROM_LOAD( "ts1scg2.8f", 0x200000*2, 0x200000,CRC(d630fff9) SHA1(691394027b858702f06282f965f5b53e6fed496b) )
r11160r11161
46504653
46514654ROM_START( tokyowar )
46524655   ROM_REGION( 0x400000, "maincpu", 0 ) /* main program */
4653        ROM_LOAD32_BYTE( "tw2ver-a.1",   0x000003, 0x100000, CRC(2b17ca92) SHA1(7bcb1658059c59fb1a0131a41ede7157855130a8) )
4654        ROM_LOAD32_BYTE( "tw2ver-a.2",   0x000002, 0x100000, CRC(12da84e3) SHA1(a9406d0b77f60ba930c30e60bf4b3656c8905585) )
4655        ROM_LOAD32_BYTE( "tw2ver-a.3",   0x000001, 0x100000, CRC(7d42c516) SHA1(28c1596dd55c15207bbb41a8b9a5abc97abc2bc8) )
4656        ROM_LOAD32_BYTE( "tw2ver-a.4",   0x000000, 0x100000, CRC(b904ed16) SHA1(773e11536e1b3fe4971608a63a8e6eca702f8667) )
4656   ROM_LOAD32_BYTE( "tw2ver-a.1",   0x000003, 0x100000, CRC(2b17ca92) SHA1(7bcb1658059c59fb1a0131a41ede7157855130a8) )
4657   ROM_LOAD32_BYTE( "tw2ver-a.2",   0x000002, 0x100000, CRC(12da84e3) SHA1(a9406d0b77f60ba930c30e60bf4b3656c8905585) )
4658   ROM_LOAD32_BYTE( "tw2ver-a.3",   0x000001, 0x100000, CRC(7d42c516) SHA1(28c1596dd55c15207bbb41a8b9a5abc97abc2bc8) )
4659   ROM_LOAD32_BYTE( "tw2ver-a.4",   0x000000, 0x100000, CRC(b904ed16) SHA1(773e11536e1b3fe4971608a63a8e6eca702f8667) )
46574660
46584661   ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
46594662   ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )
r11160r11161
46644667   ROM_REGION( 0x80000, "mcu", ROMREGION_ERASE00 ) /* BIOS */
46654668
46664669   ROM_REGION16_LE( 0x080000, "user4", 0 ) /* MCU BIOS */
4667        ROM_LOAD( "tw1data.8k",   0x000000, 0x080000, CRC(bd046e4b) SHA1(162bc4ab69959ccab49fd69de291d34d472fb1c8) )
4670   ROM_LOAD( "tw1data.8k",   0x000000, 0x080000, CRC(bd046e4b) SHA1(162bc4ab69959ccab49fd69de291d34d472fb1c8) )
46684671
46694672   ROM_REGION( 0x800000, "sprite", 0 ) /* 32x32x8bpp sprite tiles */
4670        ROM_LOAD( "tw1scg0.12f",  0x000000, 0x200000, CRC(e3ec4daa) SHA1(f3a71ae9820d62075b814ffa2fecf3343ae09ffe) )
4671        ROM_LOAD( "tw1scg1.10f",  0x200000, 0x200000, CRC(b18a06e9) SHA1(ecf6a1e11603b8ea5119a036a57595dea021d778) )
4672        ROM_LOAD( "tw1scg2.8f",   0x400000, 0x200000, CRC(36f8c3d8) SHA1(d5c965d5cdd258c77b9db3137ce33404a5a3641c) )
4673        ROM_LOAD( "tw1scg3.7f",   0x600000, 0x200000, CRC(8e14d013) SHA1(ca63105a5c07bb9653499eef7a757db52612b59b) )
4673   ROM_LOAD( "tw1scg0.12f",  0x000000, 0x200000, CRC(e3ec4daa) SHA1(f3a71ae9820d62075b814ffa2fecf3343ae09ffe) )
4674   ROM_LOAD( "tw1scg1.10f",  0x200000, 0x200000, CRC(b18a06e9) SHA1(ecf6a1e11603b8ea5119a036a57595dea021d778) )
4675   ROM_LOAD( "tw1scg2.8f",   0x400000, 0x200000, CRC(36f8c3d8) SHA1(d5c965d5cdd258c77b9db3137ce33404a5a3641c) )
4676   ROM_LOAD( "tw1scg3.7f",   0x600000, 0x200000, CRC(8e14d013) SHA1(ca63105a5c07bb9653499eef7a757db52612b59b) )
46744677
46754678   ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
4676        ROM_LOAD( "tw1cg0.8d",    0x000000, 0x200000, CRC(98b9b070) SHA1(cb920a34700dab330c967cc634717134c04b7e1d) )
4677        ROM_LOAD( "tw1cg1.10d",   0x200000, 0x200000, CRC(f96a723a) SHA1(5ba14963a4c51c875ac8d3b42049bc334de90038) )
4678        ROM_LOAD( "tw1cg2.12d",   0x400000, 0x200000, CRC(573e9ded) SHA1(815bda1ac000532c915c2d65ffdb04fee6fa8201) )
4679        ROM_LOAD( "tw1cg3.13d",   0x600000, 0x200000, CRC(302d5c74) SHA1(5a823f6842cf0f79eb93da47d5bf8c5f51e420db) )
4680        ROM_LOAD( "tw1cg4.14d",   0x800000, 0x200000, CRC(ab8aa1df) SHA1(355192d999f493e0761fbc822fa9b30c33d8e1c4) )
4681        ROM_LOAD( "tw1cg5.16d",   0xa00000, 0x200000, CRC(5063f3d0) SHA1(ad8dd2f4184373a3a3ca748b411a5eec1835dc97) )
4682        ROM_LOAD( "tw1cg6.18d",   0xc00000, 0x200000, CRC(d764027c) SHA1(5cbf93392683885c220628936ba50c09cb40fcfb) )
4683        ROM_LOAD( "tw1cg7.19d",   0xe00000, 0x200000, CRC(8d89877e) SHA1(7d76d48d64d7ac5411d714a4bb83f37e3e5b8df6) )
4679   ROM_LOAD( "tw1cg0.8d",    0x000000, 0x200000, CRC(98b9b070) SHA1(cb920a34700dab330c967cc634717134c04b7e1d) )
4680   ROM_LOAD( "tw1cg1.10d",   0x200000, 0x200000, CRC(f96a723a) SHA1(5ba14963a4c51c875ac8d3b42049bc334de90038) )
4681   ROM_LOAD( "tw1cg2.12d",   0x400000, 0x200000, CRC(573e9ded) SHA1(815bda1ac000532c915c2d65ffdb04fee6fa8201) )
4682   ROM_LOAD( "tw1cg3.13d",   0x600000, 0x200000, CRC(302d5c74) SHA1(5a823f6842cf0f79eb93da47d5bf8c5f51e420db) )
4683   ROM_LOAD( "tw1cg4.14d",   0x800000, 0x200000, CRC(ab8aa1df) SHA1(355192d999f493e0761fbc822fa9b30c33d8e1c4) )
4684   ROM_LOAD( "tw1cg5.16d",   0xa00000, 0x200000, CRC(5063f3d0) SHA1(ad8dd2f4184373a3a3ca748b411a5eec1835dc97) )
4685   ROM_LOAD( "tw1cg6.18d",   0xc00000, 0x200000, CRC(d764027c) SHA1(5cbf93392683885c220628936ba50c09cb40fcfb) )
4686   ROM_LOAD( "tw1cg7.19d",   0xe00000, 0x200000, CRC(8d89877e) SHA1(7d76d48d64d7ac5411d714a4bb83f37e3e5b8df6) )
46844687
46854688   ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
4686        ROM_LOAD( "tw1ccrl.3d",   0x000000, 0x200000, CRC(d08f5794) SHA1(336a97a2b060505e259e3bcedb9eb8aa4ea8815e) )
4687        ROM_LOAD( "tw1ccrh.1d",   0x200000, 0x080000, CRC(ad17e693) SHA1(4f06dc82c03159894fb8e10383862920f94563b1) )
4689   ROM_LOAD( "tw1ccrl.3d",   0x000000, 0x200000, CRC(d08f5794) SHA1(336a97a2b060505e259e3bcedb9eb8aa4ea8815e) )
4690   ROM_LOAD( "tw1ccrh.1d",   0x200000, 0x080000, CRC(ad17e693) SHA1(4f06dc82c03159894fb8e10383862920f94563b1) )
46884691
46894692   ROM_REGION( 0x600000, "pointrom", 0 ) /* 3d model data */
4690        ROM_LOAD( "tw1ptrl0.18k", 0x000000, 0x080000, CRC(44ac5e86) SHA1(5e42db58f2e352c0fe5e49588a9283817dd15ab1) )
4691        ROM_LOAD( "tw1ptrl1.16k", 0x080000, 0x080000, CRC(3c769860) SHA1(19b32c3d262f2a9d07354fbd6ac6be97b05f176e) )
4692        ROM_LOAD( "tw1ptrl2.15k", 0x100000, 0x080000, CRC(6e94103c) SHA1(ee90b77939a9f5780ce271882133cdf977eb643e) )
4693        ROM_LOAD( "tw1ptrl3.14k", 0x180000, 0x080000, CRC(e3ce5eb2) SHA1(4e15a6f630be15eb017cd51c5e7901db3138a061) )
4694        ROM_LOAD( "tw1ptrm0.18j", 0x200000, 0x080000, CRC(e170cea2) SHA1(ca259508d76fdab97a9d0502f871f0e560e6c308) )
4695        ROM_LOAD( "tw1ptrm1.16j", 0x280000, 0x080000, CRC(36a32237) SHA1(f46851dc5c094810ddc42d56310a9f85908bf715) )
4696        ROM_LOAD( "tw1ptrm2.15j", 0x300000, 0x080000, CRC(c426c278) SHA1(64232ac3c1649e0d0adb4b03e58b8b5ea4013f83) )
4697        ROM_LOAD( "tw1ptrm3.14j", 0x380000, 0x080000, CRC(d9b9a651) SHA1(0c49a051526081149d894d629f19cb0f2b66a698) )
4698        ROM_LOAD( "tw1ptru0.18f", 0x400000, 0x080000, CRC(62a9e9fb) SHA1(24739adba029b0acf2d7078962c9d01098a29a6c) )
4699        ROM_LOAD( "tw1ptru1.16f", 0x480000, 0x080000, CRC(2fd36177) SHA1(368b915261d914be01ae9daeb52571bead52d14d) )
4700        ROM_LOAD( "tw1ptru2.15f", 0x500000, 0x080000, CRC(ceacb1c9) SHA1(b86cf576e16bbe26ad0d6d6df8bf28d0071c25e2) )
4701        ROM_LOAD( "tw1ptru3.14f", 0x580000, 0x080000, CRC(939044c2) SHA1(f4c1c0a1c2f07ca7f784d59ef4162a2a6a8bbc43) )
4693   ROM_LOAD( "tw1ptrl0.18k", 0x000000, 0x080000, CRC(44ac5e86) SHA1(5e42db58f2e352c0fe5e49588a9283817dd15ab1) )
4694   ROM_LOAD( "tw1ptrl1.16k", 0x080000, 0x080000, CRC(3c769860) SHA1(19b32c3d262f2a9d07354fbd6ac6be97b05f176e) )
4695   ROM_LOAD( "tw1ptrl2.15k", 0x100000, 0x080000, CRC(6e94103c) SHA1(ee90b77939a9f5780ce271882133cdf977eb643e) )
4696   ROM_LOAD( "tw1ptrl3.14k", 0x180000, 0x080000, CRC(e3ce5eb2) SHA1(4e15a6f630be15eb017cd51c5e7901db3138a061) )
4697   ROM_LOAD( "tw1ptrm0.18j", 0x200000, 0x080000, CRC(e170cea2) SHA1(ca259508d76fdab97a9d0502f871f0e560e6c308) )
4698   ROM_LOAD( "tw1ptrm1.16j", 0x280000, 0x080000, CRC(36a32237) SHA1(f46851dc5c094810ddc42d56310a9f85908bf715) )
4699   ROM_LOAD( "tw1ptrm2.15j", 0x300000, 0x080000, CRC(c426c278) SHA1(64232ac3c1649e0d0adb4b03e58b8b5ea4013f83) )
4700   ROM_LOAD( "tw1ptrm3.14j", 0x380000, 0x080000, CRC(d9b9a651) SHA1(0c49a051526081149d894d629f19cb0f2b66a698) )
4701   ROM_LOAD( "tw1ptru0.18f", 0x400000, 0x080000, CRC(62a9e9fb) SHA1(24739adba029b0acf2d7078962c9d01098a29a6c) )
4702   ROM_LOAD( "tw1ptru1.16f", 0x480000, 0x080000, CRC(2fd36177) SHA1(368b915261d914be01ae9daeb52571bead52d14d) )
4703   ROM_LOAD( "tw1ptru2.15f", 0x500000, 0x080000, CRC(ceacb1c9) SHA1(b86cf576e16bbe26ad0d6d6df8bf28d0071c25e2) )
4704   ROM_LOAD( "tw1ptru3.14f", 0x580000, 0x080000, CRC(939044c2) SHA1(f4c1c0a1c2f07ca7f784d59ef4162a2a6a8bbc43) )
47024705
47034706   ROM_REGION( 0xa00000, "c352", 0 ) /* sound samples */
4704        ROM_LOAD( "tw1wavea.2l",  0x000000, 0x400000, CRC(ebce6366) SHA1(44ebe90ff3c7af5bebbf1baba3b7a2b1863daebb) )
4707   ROM_LOAD( "tw1wavea.2l",  0x000000, 0x400000, CRC(ebce6366) SHA1(44ebe90ff3c7af5bebbf1baba3b7a2b1863daebb) )
47054708ROM_END
47064709
47074710ROM_START( dirtdash )
47084711   ROM_REGION( 0x400000, "maincpu", 0 ) /* main program */
4709        ROM_LOAD32_WORD_SWAP( "dt2vera.1",    0x000002, 0x200000, CRC(402a3d73) SHA1(009b57ed0ea228ccedb139d945b9eaf2a36e2502) )
4710        ROM_LOAD32_WORD_SWAP( "dt2vera.2",    0x000000, 0x200000, CRC(66ed140d) SHA1(a472fdc7b6aaeb4b3643ecdafd32fa665e7c7aa2) )
4712   ROM_LOAD32_WORD_SWAP( "dt2vera.1",    0x000002, 0x200000, CRC(402a3d73) SHA1(009b57ed0ea228ccedb139d945b9eaf2a36e2502) )
4713   ROM_LOAD32_WORD_SWAP( "dt2vera.2",    0x000000, 0x200000, CRC(66ed140d) SHA1(a472fdc7b6aaeb4b3643ecdafd32fa665e7c7aa2) )
47114714
47124715   ROM_REGION( 0x10000*2, "master", 0 ) /* Master DSP */
47134716   ROM_LOAD16_WORD( "c71.bin", 0,0x1000*2, CRC(47c623ab) SHA1(e363ac50f5556f83308d4cc191b455e9b62bcfc8) )
r11160r11161
47184721   ROM_REGION( 0x80000, "mcu", ROMREGION_ERASE00 ) /* BIOS */
47194722
47204723   ROM_REGION16_LE( 0x080000, "user4", 0 ) /* MCU BIOS */
4721        ROM_LOAD( "dt1dataa.8k",  0x000000, 0x080000, CRC(9bcdea21) SHA1(26ae025cf746d3a703a82495eb2bb515b828a650) )
4724   ROM_LOAD( "dt1dataa.8k",  0x000000, 0x080000, CRC(9bcdea21) SHA1(26ae025cf746d3a703a82495eb2bb515b828a650) )
47224725
47234726   ROM_REGION( 0x800000, "sprite", 0 ) /* 32x32x8bpp sprite tiles */
4724        ROM_LOAD( "dt1scg0.12f",  0x000000, 0x200000, CRC(a09b5760) SHA1(3dd54ebebf9da1de76874a1adf491ed15849e1b1) )
4725        ROM_LOAD( "dt1scg1.10f",  0x200000, 0x200000, CRC(f9ac8111) SHA1(814074ae8cc81c6c1201d764a84dd95fe914f19c) )
4727   ROM_LOAD( "dt1scg0.12f",  0x000000, 0x200000, CRC(a09b5760) SHA1(3dd54ebebf9da1de76874a1adf491ed15849e1b1) )
4728   ROM_LOAD( "dt1scg1.10f",  0x200000, 0x200000, CRC(f9ac8111) SHA1(814074ae8cc81c6c1201d764a84dd95fe914f19c) )
47264729
47274730   ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
4728        ROM_LOAD( "dt1cg0.8d",    0x000000, 0x200000, CRC(10ab95e0) SHA1(ffde1f00ac3e82a36fbcfa060c6b97c92dfcfc8b) )
4729        ROM_LOAD( "dt1cg1.10d",   0x200000, 0x200000, CRC(d9f1ba53) SHA1(5a1095b726c55001cc1d4c695adc38097e6a0201) )
4730        ROM_LOAD( "dt1cg2.12d",   0x400000, 0x200000, CRC(bd8b1e0b) SHA1(fcd94e33a0cbd17c9308cb8952e3c618ab56f9fc) )
4731        ROM_LOAD( "dt1cg3.13d",   0x600000, 0x200000, CRC(ba960663) SHA1(e98149bc4652ea7933ac47d760a6f7e6489f15e2) )
4732        ROM_LOAD( "dt1cg4.14d",   0x800000, 0x200000, CRC(424b9652) SHA1(fa8865110db03559740c4e633e123d1a009782c4) )
4733        ROM_LOAD( "dt1cg5.16d",   0xa00000, 0x200000, CRC(29516626) SHA1(1f12c5dc3975b88dc60d87d0409bf311837e9fa4) )
4734        ROM_LOAD( "dt1cg6.18d",   0xc00000, 0x200000, CRC(e6fa7180) SHA1(85316cde282cff1f913cf9f155cfa36adcc1108e) )
4735        ROM_LOAD( "dt1cg7.19d",   0xe00000, 0x200000, CRC(2ca19153) SHA1(c82403c8b40bf85daedf610b1bc7bfea9dfc6206) )
4731   ROM_LOAD( "dt1cg0.8d",    0x000000, 0x200000, CRC(10ab95e0) SHA1(ffde1f00ac3e82a36fbcfa060c6b97c92dfcfc8b) )
4732   ROM_LOAD( "dt1cg1.10d",   0x200000, 0x200000, CRC(d9f1ba53) SHA1(5a1095b726c55001cc1d4c695adc38097e6a0201) )
4733   ROM_LOAD( "dt1cg2.12d",   0x400000, 0x200000, CRC(bd8b1e0b) SHA1(fcd94e33a0cbd17c9308cb8952e3c618ab56f9fc) )
4734   ROM_LOAD( "dt1cg3.13d",   0x600000, 0x200000, CRC(ba960663) SHA1(e98149bc4652ea7933ac47d760a6f7e6489f15e2) )
4735   ROM_LOAD( "dt1cg4.14d",   0x800000, 0x200000, CRC(424b9652) SHA1(fa8865110db03559740c4e633e123d1a009782c4) )
4736   ROM_LOAD( "dt1cg5.16d",   0xa00000, 0x200000, CRC(29516626) SHA1(1f12c5dc3975b88dc60d87d0409bf311837e9fa4) )
4737   ROM_LOAD( "dt1cg6.18d",   0xc00000, 0x200000, CRC(e6fa7180) SHA1(85316cde282cff1f913cf9f155cfa36adcc1108e) )
4738   ROM_LOAD( "dt1cg7.19d",   0xe00000, 0x200000, CRC(2ca19153) SHA1(c82403c8b40bf85daedf610b1bc7bfea9dfc6206) )
47364739
47374740   ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
4738        ROM_LOAD( "dt1ccrl.3d",   0x000000, 0x200000, CRC(e536b313) SHA1(7357da993d2bb3fcc8c1c2feb53689ad368cd80a) )
4739        ROM_LOAD( "dt1ccrh.1d",   0x200000, 0x080000, CRC(af257064) SHA1(0da561d9f8824618c00209ccef6146e9f3ad72bb) )
4741   ROM_LOAD( "dt1ccrl.3d",   0x000000, 0x200000, CRC(e536b313) SHA1(7357da993d2bb3fcc8c1c2feb53689ad368cd80a) )
4742   ROM_LOAD( "dt1ccrh.1d",   0x200000, 0x080000, CRC(af257064) SHA1(0da561d9f8824618c00209ccef6146e9f3ad72bb) )
47404743
47414744   ROM_REGION( 0x600000, "pointrom", 0 ) /* 3d model data */
4742        ROM_LOAD( "dt1ptrl0.18k", 0x000000, 0x080000, CRC(4e0cac3a) SHA1(c2778e9e93be2de729c6f118caf62ac9f48efbb0) )
4743        ROM_LOAD( "dt1ptrl1.16k", 0x080000, 0x080000, CRC(59ba9dba) SHA1(a2e9488cf0ff255284c06a1ef653ae86c0d98adc) )
4744        ROM_LOAD( "dt1ptrl2.15k", 0x100000, 0x080000, CRC(cfe80c67) SHA1(ba3bc48aa39712e63c915070a76974fbd560dee6) )
4745        ROM_LOAD( "dt1ptrm0.18j", 0x180000, 0x080000, CRC(41f34337) SHA1(7e624e7b6fdefe156168b1c9cc5e919db3b2fbaa) )
4746        ROM_LOAD( "dt1ptrm1.16j", 0x200000, 0x080000, CRC(d68541fc) SHA1(6b00079bd8f2db26e71968de289cea93458aebe9) )
4747        ROM_LOAD( "dt1ptrm2.15j", 0x280000, 0x080000, CRC(71e6714d) SHA1(6aad6db3be5020213d7add61c7d927ae9c4fea4e) )
4748        ROM_LOAD( "dt1ptru0.18f", 0x300000, 0x080000, CRC(4909bd7d) SHA1(0e4ef3987c43ef0438331b82b50dcc97363a45d0) )
4749        ROM_LOAD( "dt1ptru1.16f", 0x380000, 0x080000, CRC(4a5097df) SHA1(a9c814b0ed4bd92accd0e57be8e3d887114b06a5) )
4750        ROM_LOAD( "dt1ptru2.15f", 0x400000, 0x080000, CRC(1171eaf5) SHA1(168365ea619386f218585c49025cdd7fd1224082) )
4745   ROM_LOAD( "dt1ptrl0.18k", 0x000000, 0x080000, CRC(4e0cac3a) SHA1(c2778e9e93be2de729c6f118caf62ac9f48efbb0) )
4746   ROM_LOAD( "dt1ptrl1.16k", 0x080000, 0x080000, CRC(59ba9dba) SHA1(a2e9488cf0ff255284c06a1ef653ae86c0d98adc) )
4747   ROM_LOAD( "dt1ptrl2.15k", 0x100000, 0x080000, CRC(cfe80c67) SHA1(ba3bc48aa39712e63c915070a76974fbd560dee6) )
4748   ROM_LOAD( "dt1ptrm0.18j", 0x180000, 0x080000, CRC(41f34337) SHA1(7e624e7b6fdefe156168b1c9cc5e919db3b2fbaa) )
4749   ROM_LOAD( "dt1ptrm1.16j", 0x200000, 0x080000, CRC(d68541fc) SHA1(6b00079bd8f2db26e71968de289cea93458aebe9) )
4750   ROM_LOAD( "dt1ptrm2.15j", 0x280000, 0x080000, CRC(71e6714d) SHA1(6aad6db3be5020213d7add61c7d927ae9c4fea4e) )
4751   ROM_LOAD( "dt1ptru0.18f", 0x300000, 0x080000, CRC(4909bd7d) SHA1(0e4ef3987c43ef0438331b82b50dcc97363a45d0) )
4752   ROM_LOAD( "dt1ptru1.16f", 0x380000, 0x080000, CRC(4a5097df) SHA1(a9c814b0ed4bd92accd0e57be8e3d887114b06a5) )
4753   ROM_LOAD( "dt1ptru2.15f", 0x400000, 0x080000, CRC(1171eaf5) SHA1(168365ea619386f218585c49025cdd7fd1224082) )
47514754
47524755   ROM_REGION( 0x1000000, "c352", 0 ) /* sound samples */
4753        ROM_LOAD( "dt1wavea.2l",  0x000000, 0x400000, CRC(cbd52e40) SHA1(dc995dd919548c96a90efb0375e5b5f1055e05cb) )
4754        ROM_LOAD( "dt1waveb.1l",  0x400000, 0x400000, CRC(6b736f94) SHA1(ac3715480aa9a9c2dec099607f89859bb3b73a6a) )
4756   ROM_LOAD( "dt1wavea.2l",  0x000000, 0x400000, CRC(cbd52e40) SHA1(dc995dd919548c96a90efb0375e5b5f1055e05cb) )
4757   ROM_LOAD( "dt1waveb.1l",  0x400000, 0x400000, CRC(6b736f94) SHA1(ac3715480aa9a9c2dec099607f89859bb3b73a6a) )
47554758ROM_END
47564759
47574760ROM_START( aquajet )
r11160r11161
47704773   ROM_REGION( 0x80000, "mcu", ROMREGION_ERASE00 ) /* BIOS */
47714774
47724775   ROM_REGION16_LE( 0x080000, "user4", 0 ) /* MCU BIOS */
4773        ROM_LOAD( "aj1data.8k",   0x000000, 0x080000, CRC(52bcc6d5) SHA1(25319ea6db35cc9bdcb39cc83d597a2a9f1690f3) )
4776   ROM_LOAD( "aj1data.8k",   0x000000, 0x080000, CRC(52bcc6d5) SHA1(25319ea6db35cc9bdcb39cc83d597a2a9f1690f3) )
47744777
47754778   ROM_REGION( 0x800000, "sprite", 0 ) /* 32x32x8bpp sprite tiles */
4776        ROM_LOAD( "aj1scg0.12f",  0x000000, 0x200000, CRC(13ea766c) SHA1(a1a259bd8f468b90cbc891f1c2875fe03bba9802) )
4777        ROM_LOAD( "aj1scg1.10f",  0x200000, 0x200000, CRC(cb3638de) SHA1(0af99aaf00782036d7f479b00b0c3d9d7ad4fc37) )
4778        ROM_LOAD( "aj1scg2.8f",   0x400000, 0x200000, CRC(1048a09b) SHA1(6859533e24db5ac54e28d480aaac7b411a648dfe) )
4779   ROM_LOAD( "aj1scg0.12f",  0x000000, 0x200000, CRC(13ea766c) SHA1(a1a259bd8f468b90cbc891f1c2875fe03bba9802) )
4780   ROM_LOAD( "aj1scg1.10f",  0x200000, 0x200000, CRC(cb3638de) SHA1(0af99aaf00782036d7f479b00b0c3d9d7ad4fc37) )
4781   ROM_LOAD( "aj1scg2.8f",   0x400000, 0x200000, CRC(1048a09b) SHA1(6859533e24db5ac54e28d480aaac7b411a648dfe) )
47794782
47804783   ROM_REGION( 0x200000*8, "textile", 0) /* 16x16x8bpp texture tiles */
4781        ROM_LOAD( "aj1cg0.8d",    0x000000, 0x200000, CRC(b814e1eb) SHA1(1af29897dcfd0a58743b4fcdd5049d9e6e3d4cbd) )
4782        ROM_LOAD( "aj1cg1.10d",   0x200000, 0x200000, CRC(dc63d496) SHA1(d3c3eea6b134850004062dd513c0f26096101227) )
4783        ROM_LOAD( "aj1cg2.12d",   0x400000, 0x200000, CRC(71fbb571) SHA1(40f84ab5a4a7bb4438fb53751762609671d17800) )
4784        ROM_LOAD( "aj1cg3.13d",   0x600000, 0x200000, CRC(e28052e2) SHA1(3dbc446d7a13312ed4c1d20c2e1209947853f2c4) )
4785        ROM_LOAD( "aj1cg4.14d",   0x800000, 0x200000, CRC(c77ae1a0) SHA1(e15f2ccbadb8634f6e5cfd2cf48f428d68bd92e1) )
4786        ROM_LOAD( "aj1cg5.16d",   0xa00000, 0x200000, CRC(15be0080) SHA1(ca14dfd2a66996f0b32fa1155c04f21d300e8f30) )
4787        ROM_LOAD( "aj1cg6.18d",   0xc00000, 0x200000, CRC(1a4f733a) SHA1(60a991f06e73667fa2c9016189999c4301cba24f) )
4788        ROM_LOAD( "aj1cg7.19d",   0xe00000, 0x200000, CRC(ea118130) SHA1(24ef22e5c8c6f6e8a01c72466be1e7acbfba63bc) )
4784   ROM_LOAD( "aj1cg0.8d",    0x000000, 0x200000, CRC(b814e1eb) SHA1(1af29897dcfd0a58743b4fcdd5049d9e6e3d4cbd) )
4785   ROM_LOAD( "aj1cg1.10d",   0x200000, 0x200000, CRC(dc63d496) SHA1(d3c3eea6b134850004062dd513c0f26096101227) )
4786   ROM_LOAD( "aj1cg2.12d",   0x400000, 0x200000, CRC(71fbb571) SHA1(40f84ab5a4a7bb4438fb53751762609671d17800) )
4787   ROM_LOAD( "aj1cg3.13d",   0x600000, 0x200000, CRC(e28052e2) SHA1(3dbc446d7a13312ed4c1d20c2e1209947853f2c4) )
4788   ROM_LOAD( "aj1cg4.14d",   0x800000, 0x200000, CRC(c77ae1a0) SHA1(e15f2ccbadb8634f6e5cfd2cf48f428d68bd92e1) )
4789   ROM_LOAD( "aj1cg5.16d",   0xa00000, 0x200000, CRC(15be0080) SHA1(ca14dfd2a66996f0b32fa1155c04f21d300e8f30) )
4790   ROM_LOAD( "aj1cg6.18d",   0xc00000, 0x200000, CRC(1a4f733a) SHA1(60a991f06e73667fa2c9016189999c4301cba24f) )
4791   ROM_LOAD( "aj1cg7.19d",   0xe00000, 0x200000, CRC(ea118130) SHA1(24ef22e5c8c6f6e8a01c72466be1e7acbfba63bc) )
47894792
47904793   ROM_REGION16_LE( 0x280000, "textilemap", 0 ) /* texture tilemap */
4791        ROM_LOAD( "aj1ccrl.3d",   0x000000, 0x200000, CRC(3cc7a247) SHA1(336e4dd506d932987e20a5890dd3b0db75c02ccf) )
4792        ROM_LOAD( "aj1ccrh.1d",   0x200000, 0x080000, CRC(9d936030) SHA1(a383bcca494a9f8d9a08fbe9940c8071d4525d65) )
4794   ROM_LOAD( "aj1ccrl.3d",   0x000000, 0x200000, CRC(3cc7a247) SHA1(336e4dd506d932987e20a5890dd3b0db75c02ccf) )
4795   ROM_LOAD( "aj1ccrh.1d",   0x200000, 0x080000, CRC(9d936030) SHA1(a383bcca494a9f8d9a08fbe9940c8071d4525d65) )
47934796
47944797   ROM_REGION( 0x600000, "pointrom", 0 ) /* 3d model data */
4795        ROM_LOAD( "aj1ptrl0.18k", 0x000000, 0x080000, CRC(16205d45) SHA1(7e9681af852e2e875f80cbbe350e4982eaf80884) )
4796        ROM_LOAD( "aj1ptrl1.16k", 0x080000, 0x080000, CRC(6f114da7) SHA1(a1e7349ef8eb0ef043fce06f88bfbb76c2967393) )
4797        ROM_LOAD( "aj1ptrl2.15k", 0x100000, 0x080000, CRC(719b73f0) SHA1(bf8530a706097ae663769090177f1f259c540aa6) )
4798        ROM_LOAD( "aj1ptrl3.14k", 0x180000, 0x080000, CRC(9555fe31) SHA1(03bdd0784817191b3600d643b775191181a21706) )
4799        ROM_LOAD( "aj1ptrm0.18j", 0x200000, 0x080000, CRC(89bee2e0) SHA1(d84b06ef1318814fcf4782fef09a85ae1a87beb8) )
4800        ROM_LOAD( "aj1ptrm1.16j", 0x280000, 0x080000, CRC(0ecf88c7) SHA1(20b7cb09a6a13599cac024ef19c73612ce2952f6) )
4801        ROM_LOAD( "aj1ptrm2.15j", 0x300000, 0x080000, CRC(829bc7ba) SHA1(7104d66a027911e38ecf521f01ff098ccb76d5fb) )
4802        ROM_LOAD( "aj1ptrm3.14j", 0x380000, 0x080000, CRC(7d0a222a) SHA1(e78c405d00429580015c6c7d1bcd35393317a769) )
4803        ROM_LOAD( "aj1ptru0.18f", 0x400000, 0x080000, CRC(90d4e36a) SHA1(bdc44aac6aef5266d289f03c816aa2abdb263e9b) )
4804        ROM_LOAD( "aj1ptru1.16f", 0x480000, 0x080000, CRC(bf0cf4bf) SHA1(bbf06c7605c083d2fb8c72528c5c9d3b8b067073) )
4805        ROM_LOAD( "aj1ptru2.15f", 0x500000, 0x080000, CRC(91ffbb77) SHA1(fbfe7d32ef22037f7190d1b8263b5e8c55f2d892) )
4806        ROM_LOAD( "aj1ptru3.14f", 0x580000, 0x080000, CRC(d83d8d42) SHA1(e1561ce4538b01db92b7e645ad008cd1a2ddaf8a) )
4798   ROM_LOAD( "aj1ptrl0.18k", 0x000000, 0x080000, CRC(16205d45) SHA1(7e9681af852e2e875f80cbbe350e4982eaf80884) )
4799   ROM_LOAD( "aj1ptrl1.16k", 0x080000, 0x080000, CRC(6f114da7) SHA1(a1e7349ef8eb0ef043fce06f88bfbb76c2967393) )
4800   ROM_LOAD( "aj1ptrl2.15k", 0x100000, 0x080000, CRC(719b73f0) SHA1(bf8530a706097ae663769090177f1f259c540aa6) )
4801   ROM_LOAD( "aj1ptrl3.14k", 0x180000, 0x080000, CRC(9555fe31) SHA1(03bdd0784817191b3600d643b775191181a21706) )
4802   ROM_LOAD( "aj1ptrm0.18j", 0x200000, 0x080000, CRC(89bee2e0) SHA1(d84b06ef1318814fcf4782fef09a85ae1a87beb8) )
4803   ROM_LOAD( "aj1ptrm1.16j", 0x280000, 0x080000, CRC(0ecf88c7) SHA1(20b7cb09a6a13599cac024ef19c73612ce2952f6) )
4804   ROM_LOAD( "aj1ptrm2.15j", 0x300000, 0x080000, CRC(829bc7ba) SHA1(7104d66a027911e38ecf521f01ff098ccb76d5fb) )
4805   ROM_LOAD( "aj1ptrm3.14j", 0x380000, 0x080000, CRC(7d0a222a) SHA1(e78c405d00429580015c6c7d1bcd35393317a769) )
4806   ROM_LOAD( "aj1ptru0.18f", 0x400000, 0x080000, CRC(90d4e36a) SHA1(bdc44aac6aef5266d289f03c816aa2abdb263e9b) )
4807   ROM_LOAD( "aj1ptru1.16f", 0x480000, 0x080000, CRC(bf0cf4bf) SHA1(bbf06c7605c083d2fb8c72528c5c9d3b8b067073) )
4808   ROM_LOAD( "aj1ptru2.15f", 0x500000, 0x080000, CRC(91ffbb77) SHA1(fbfe7d32ef22037f7190d1b8263b5e8c55f2d892) )
4809   ROM_LOAD( "aj1ptru3.14f", 0x580000, 0x080000, CRC(d83d8d42) SHA1(e1561ce4538b01db92b7e645ad008cd1a2ddaf8a) )
48074810
48084811   ROM_REGION( 0x1000000, "c352", 0 ) /* sound samples */
4809        ROM_LOAD( "aj1wavea.2l",  0x000000, 0x400000, CRC(8c72ea59) SHA1(3ae8dbd8baae08f1daab2b218932ba9d9451231d) )
4810        ROM_LOAD( "aj1waveb.1l",  0x800000, 0x400000, CRC(ab5a457f) SHA1(c34531fd574eb0c3e78fc31a9af8658df3446adc) )
4812   ROM_LOAD( "aj1wavea.2l",  0x000000, 0x400000, CRC(8c72ea59) SHA1(3ae8dbd8baae08f1daab2b218932ba9d9451231d) )
4813   ROM_LOAD( "aj1waveb.1l",  0x800000, 0x400000, CRC(ab5a457f) SHA1(c34531fd574eb0c3e78fc31a9af8658df3446adc) )
48114814ROM_END
48124815
48134816/*******************************************************************/
r11160r11161
52875290
52885291static CUSTOM_INPUT( acedrvr_shift_read )
52895292{
5293   namcos22_state *state = field->port->machine().driver_data<namcos22_state>();
52905294   int shift = input_port_read(field->port->machine(), "SHIFT");
52915295
5292   if (shift > 0 && shift != prev_stick_state)
5296   if (shift > 0 && shift != state->m_prev_stick_state)
52935297   {
5294      prev_stick_state = shift;
5298      state->m_prev_stick_state = shift;
52955299
52965300      switch (shift)
52975301      {
52985302         case 0x01:
5299            stick_input = 0x01;
5303            state->m_stick_input = 0x01;
53005304            break;
53015305         case 0x02:
5302            stick_input = 0x03;
5306            state->m_stick_input = 0x03;
53035307            break;
53045308         case 0x04:
5305            stick_input = 0x02;
5309            state->m_stick_input = 0x02;
53065310            break;
53075311      }
53085312   }
53095313
5310   return stick_input;
5314   return state->m_stick_input;
53115315}
53125316
53135317static INPUT_PORTS_START( acedrvr )
r11160r11161
54675471
54685472static CUSTOM_INPUT( ridger_gear_read )
54695473{
5474   namcos22_state *state = field->port->machine().driver_data<namcos22_state>();
54705475   int gear = input_port_read(field->port->machine(), "GEARS");
54715476
5472   if (gear > 0 && gear != prev_stick_state)
5477   if (gear > 0 && gear != state->m_prev_stick_state)
54735478   {
5474      prev_stick_state = gear;
5479      state->m_prev_stick_state = gear;
54755480
54765481      switch (gear)
54775482      {
54785483      case 0x01:
5479         stick_input = 0x0a;
5484         state->m_stick_input = 0x0a;
54805485         break;
54815486      case 0x02:
5482         stick_input = 0x09;
5487         state->m_stick_input = 0x09;
54835488         break;
54845489      case 0x04:
5485         stick_input = 0x0e;
5490         state->m_stick_input = 0x0e;
54865491         break;
54875492      case 0x08:
5488         stick_input = 0x0d;
5493         state->m_stick_input = 0x0d;
54895494         break;
54905495      case 0x10:
5491         stick_input = 0x06;
5496         state->m_stick_input = 0x06;
54925497         break;
54935498      case 0x20:
5494         stick_input = 0x05;
5499         state->m_stick_input = 0x05;
54955500         break;
54965501      }
54975502   }
54985503
5499   return stick_input;
5504   return state->m_stick_input;
55005505}
55015506
55025507static INPUT_PORTS_START( ridgera )
r11160r11161
57355740/*****************************************************************************************************/
57365741
57375742// MCU speed cheats (every bit helps with these games)
5738static UINT16 su_82;
57395743
57405744// for MCU BIOS v1.41
57415745static READ16_HANDLER( mcu141_speedup_r )
57425746{
5743   if ((cpu_get_pc(&space->device()) == 0xc12d) && (!(su_82 & 0xff00)))
5747   namcos22_state *state = space->machine().driver_data<namcos22_state>();
5748   if ((cpu_get_pc(&space->device()) == 0xc12d) && (!(state->m_su_82 & 0xff00)))
57445749   {
57455750      device_spin_until_interrupt(&space->device());
57465751   }
57475752
5748   return su_82;
5753   return state->m_su_82;
57495754}
57505755
57515756static WRITE16_HANDLER( mcu_speedup_w )
57525757{
5753   COMBINE_DATA(&su_82);
5758   namcos22_state *state = space->machine().driver_data<namcos22_state>();
5759   COMBINE_DATA(&state->m_su_82);
57545760}
57555761
57565762// for MCU BIOS v1.30
57575763static READ16_HANDLER( mcu130_speedup_r )
57585764{
5759   if ((cpu_get_pc(&space->device()) == 0xc12a) && (!(su_82 & 0xff00)))
5765   namcos22_state *state = space->machine().driver_data<namcos22_state>();
5766   if ((cpu_get_pc(&space->device()) == 0xc12a) && (!(state->m_su_82 & 0xff00)))
57605767   {
57615768      device_spin_until_interrupt(&space->device());
57625769   }
57635770
5764   return su_82;
5771   return state->m_su_82;
57655772}
57665773
57675774// for NSTX7702 v1.00 (C74)
57685775static READ16_HANDLER( mcuc74_speedup_r )
57695776{
5770   if (((cpu_get_pc(&space->device()) == 0xc0df) || (cpu_get_pc(&space->device()) == 0xc101)) && (!(su_82 & 0xff00)))
5777   namcos22_state *state = space->machine().driver_data<namcos22_state>();
5778   if (((cpu_get_pc(&space->device()) == 0xc0df) || (cpu_get_pc(&space->device()) == 0xc101)) && (!(state->m_su_82 & 0xff00)))
57715779   {
57725780      device_spin_until_interrupt(&space->device());
57735781   }
57745782
5775   return su_82;
5783   return state->m_su_82;
57765784}
57775785
57785786static void install_c74_speedup(running_machine &machine)
r11160r11161
57925800   machine.device("mcu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0x82, 0x83, FUNC(mcu141_speedup_r), FUNC(mcu_speedup_w));
57935801}
57945802
5795static void namcos22_init( running_machine &machine, enum namcos22_gametype game_type )
5803static void namcos22_init( running_machine &machine, int game_type )
57965804{
5797   namcos22_gametype = game_type;
5798   mpPointRAM = auto_alloc_array(machine, UINT32, 0x20000);
5805   namcos22_state *state = machine.driver_data<namcos22_state>();
5806   state->m_gametype = game_type;
5807   state->m_mpPointRAM = auto_alloc_array(machine, UINT32, 0x20000);
57995808}
58005809
5801static void namcos22s_init( running_machine &machine, enum namcos22_gametype game_type )
5810static void namcos22s_init( running_machine &machine, int game_type )
58025811{
58035812   namcos22_init(machine, game_type);
58045813   mSpotRAM.RAM = auto_alloc_array(machine, UINT16, SPOTRAM_SIZE);
r11160r11161
58665875
58675876static DRIVER_INIT( ridgeraj )
58685877{
5878   namcos22_state *state = machine.driver_data<namcos22_state>();
58695879   namcos22_init(machine, NAMCOS22_RIDGE_RACER);
58705880
58715881   install_c74_speedup(machine);
58725882
5873   old_coin_state = 0;
5874   credits1 = credits2 = 0;
5875   stick_input = 0xa;
5883   state->m_old_coin_state = 0;
5884   state->m_credits1 = state->m_credits2 = 0;
5885   state->m_stick_input = 0xa;
58765886}
58775887
58785888static DRIVER_INIT( ridger2j )
58795889{
5890   namcos22_state *state = machine.driver_data<namcos22_state>();
58805891   namcos22_init(machine, NAMCOS22_RIDGE_RACER2);
58815892
58825893   install_c74_speedup(machine);
58835894
5884   old_coin_state = 0;
5885   credits1 = credits2 = 0;
5886   stick_input = 0xa;
5895   state->m_old_coin_state = 0;
5896   state->m_credits1 = state->m_credits2 = 0;
5897   state->m_stick_input = 0xa;
58875898}
58885899
58895900static DRIVER_INIT( acedrvr )
58905901{
5902   namcos22_state *state = machine.driver_data<namcos22_state>();
58915903   namcos22_init(machine, NAMCOS22_ACE_DRIVER);
58925904
58935905   install_c74_speedup(machine);
58945906
5895   old_coin_state = 0;
5896   credits1 = credits2 = 0;
5897   stick_input = 0x3;
5907   state->m_old_coin_state = 0;
5908   state->m_credits1 = state->m_credits2 = 0;
5909   state->m_stick_input = 0x3;
58985910}
58995911
59005912static DRIVER_INIT( victlap )
59015913{
5914   namcos22_state *state = machine.driver_data<namcos22_state>();
59025915   namcos22_init(machine, NAMCOS22_VICTORY_LAP);
59035916
59045917   install_c74_speedup(machine);
59055918
5906   old_coin_state = 0;
5907   credits1 = credits2 = 0;
5908   stick_input = 0x3;
5919   state->m_old_coin_state = 0;
5920   state->m_credits1 = state->m_credits2 = 0;
5921   state->m_stick_input = 0x3;
59095922}
59105923
59115924static DRIVER_INIT( raveracw )
59125925{
5926   namcos22_state *state = machine.driver_data<namcos22_state>();
59135927   namcos22_init(machine, NAMCOS22_RAVE_RACER);
59145928
59155929   install_c74_speedup(machine);
59165930
5917   old_coin_state = 0;
5918   credits1 = credits2 = 0;
5919   stick_input = 0xa;
5931   state->m_old_coin_state = 0;
5932   state->m_credits1 = state->m_credits2 = 0;
5933   state->m_stick_input = 0xa;
59205934}
59215935
59225936static DRIVER_INIT( cybrcomm )
59235937{
5938   namcos22_state *state = machine.driver_data<namcos22_state>();
59245939   UINT32 *pROM = (UINT32 *)machine.region("maincpu")->base();
59255940   pROM[0x18ade8/4] = 0x4e714e71;
59265941   pROM[0x18ae38/4] = 0x4e714e71;
r11160r11161
59325947
59335948   install_c74_speedup(machine);
59345949
5935   old_coin_state = 0;
5936   credits1 = credits2 = 0;
5950   state->m_old_coin_state = 0;
5951   state->m_credits1 = state->m_credits2 = 0;
59375952}
59385953
59395954static DRIVER_INIT( cybrcyc )
src/mame/drivers/galaxold.c
r11160r11161
410410static ADDRESS_MAP_START( galaxold_map, AS_PROGRAM, 8 )
411411   AM_RANGE(0x0000, 0x3fff) AM_ROM
412412   AM_RANGE(0x4000, 0x47ff) AM_RAM
413   AM_RANGE(0x5000, 0x53ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
413   AM_RANGE(0x5000, 0x53ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
414414   AM_RANGE(0x5400, 0x57ff) AM_READ(galaxold_videoram_r)
415   AM_RANGE(0x5800, 0x583f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
416   AM_RANGE(0x5840, 0x585f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
417   AM_RANGE(0x5860, 0x587f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
415   AM_RANGE(0x5800, 0x583f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
416   AM_RANGE(0x5840, 0x585f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
417   AM_RANGE(0x5860, 0x587f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
418418   AM_RANGE(0x5880, 0x58ff) AM_RAM
419419   AM_RANGE(0x6000, 0x6000) AM_READ_PORT("IN0")
420420   AM_RANGE(0x6000, 0x6001) AM_WRITE(galaxold_leds_w)
r11160r11161
440440static ADDRESS_MAP_START( mooncrst_map, AS_PROGRAM, 8 )
441441   AM_RANGE(0x0000, 0x5fff) AM_ROM
442442   AM_RANGE(0x8000, 0x87ff) AM_RAM
443   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
443   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
444444   AM_RANGE(0x9400, 0x97ff) AM_READ(galaxold_videoram_r)
445   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
446   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
447   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
445   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
446   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
447   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
448448   AM_RANGE(0x9880, 0x98ff) AM_RAM
449449   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
450450   AM_RANGE(0xa003, 0xa003) AM_WRITE(galaxold_coin_counter_w)
r11160r11161
465465
466466static ADDRESS_MAP_START( rockclim_map, AS_PROGRAM, 8 )
467467   AM_RANGE(0x0000, 0x3fff) AM_ROM
468   AM_RANGE(0x4000, 0x47ff) AM_READWRITE(rockclim_videoram_r, rockclim_videoram_w) AM_BASE(&rockclim_videoram)//4800 - 4803 = bg scroll ?
468   AM_RANGE(0x4000, 0x47ff) AM_READWRITE(rockclim_videoram_r, rockclim_videoram_w) AM_BASE_MEMBER(galaxold_state, m_rockclim_videoram)//4800 - 4803 = bg scroll ?
469469   AM_RANGE(0x4800, 0x4803) AM_WRITE(rockclim_scroll_w)
470470   AM_RANGE(0x5000, 0x53ff) AM_RAM //?
471471   AM_RANGE(0x5800, 0x5800) AM_READ_PORT("IN2")
472472   AM_RANGE(0x6000, 0x7fff) AM_ROM
473473   AM_RANGE(0x8000, 0x87ff) AM_RAM
474474   AM_RANGE(0x8800, 0x8800) AM_READ_PORT("DSW1")
475   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
475   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
476476   AM_RANGE(0x9400, 0x97ff) AM_READ(galaxold_videoram_r)
477   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
478   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
479   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
477   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
478   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
479   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
480480   AM_RANGE(0x9880, 0x98ff) AM_RAM
481481   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
482482   AM_RANGE(0xa000, 0xa002) AM_WRITE(galaxold_gfxbank_w)// a002 - sprite bank
r11160r11161
498498static ADDRESS_MAP_START( ckongg_map, AS_PROGRAM, 8 )
499499   AM_RANGE(0x0000, 0x5fff) AM_ROM
500500   AM_RANGE(0x6000, 0x6fff) AM_RAM
501   AM_RANGE(0x9000, 0x93ff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w) AM_BASE(&galaxold_videoram)
502   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
503   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
504   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
501   AM_RANGE(0x9000, 0x93ff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
502   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
503   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
504   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
505505   AM_RANGE(0x9880, 0x98ff) AM_RAM
506506   AM_RANGE(0xc000, 0xc000) AM_READ_PORT("IN0")
507507   AM_RANGE(0xc000, 0xc001) AM_WRITE(galaxold_leds_w)
r11160r11161
525525static ADDRESS_MAP_START( ckongmc_map, AS_PROGRAM, 8 )
526526   AM_RANGE(0x0000, 0x5fff) AM_ROM
527527   AM_RANGE(0x6000, 0x6fff) AM_RAM
528   AM_RANGE(0x9000, 0x93ff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w) AM_BASE(&galaxold_videoram)
529   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
530   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
531   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
528   AM_RANGE(0x9000, 0x93ff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
529   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
530   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
531   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
532532   AM_RANGE(0x9880, 0x98ff) AM_RAM
533533   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
534534   AM_RANGE(0xa001, 0xa002) AM_WRITE(galaxold_leds_w)                                              /* GUESS */
r11160r11161
552552static ADDRESS_MAP_START( scramblb_map, AS_PROGRAM, 8 )
553553   AM_RANGE(0x0000, 0x3fff) AM_ROM
554554   AM_RANGE(0x4000, 0x47ff) AM_RAM
555   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
556   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
557   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
558   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
555   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
556   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
557   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
558   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
559559   AM_RANGE(0x5080, 0x50ff) AM_RAM
560560   AM_RANGE(0x6000, 0x6000) AM_READ_PORT("IN0")
561561   AM_RANGE(0x6000, 0x6001) AM_WRITENOP  /* sound triggers */
r11160r11161
587587static ADDRESS_MAP_START( scramb2_map, AS_PROGRAM, 8 )
588588   AM_RANGE(0x0000, 0x3fff) AM_ROM
589589   AM_RANGE(0x4000, 0x47ff) AM_RAM
590   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
590   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
591591   AM_RANGE(0x4c00, 0x4fff) AM_WRITE(galaxold_videoram_w) // mirror
592   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
593   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
594   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
592   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
593   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
594   AM_RANGE(0x5060, 0x507f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
595595   AM_RANGE(0x5080, 0x50ff) AM_RAM
596596   AM_RANGE(0x5800, 0x5fff) AM_READ(scramb2_protection_r) // must return 0x25
597597   AM_RANGE(0x6000, 0x6007) AM_READ(scramb2_port0_r) // reads from 8 addresses, 1 bit per address
r11160r11161
612612static ADDRESS_MAP_START( _4in1_map, AS_PROGRAM, 8 )
613613   AM_RANGE(0x0000, 0x3fff) AM_ROMBANK("bank1")   /* banked game code */
614614   AM_RANGE(0x4000, 0x47ff) AM_RAM
615   AM_RANGE(0x5000, 0x53ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
615   AM_RANGE(0x5000, 0x53ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
616616   AM_RANGE(0x5400, 0x57ff) AM_READ(galaxold_videoram_r)
617   AM_RANGE(0x5800, 0x583f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
618   AM_RANGE(0x5840, 0x585f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
619   AM_RANGE(0x5860, 0x587f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
617   AM_RANGE(0x5800, 0x583f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
618   AM_RANGE(0x5840, 0x585f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
619   AM_RANGE(0x5860, 0x587f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
620620   AM_RANGE(0x5880, 0x58ff) AM_RAM
621621   AM_RANGE(0x6000, 0x6000) AM_READ_PORT("IN0")
622622   AM_RANGE(0x6000, 0x6001) AM_WRITE(galaxold_leds_w)
r11160r11161
643643static ADDRESS_MAP_START( bagmanmc_map, AS_PROGRAM, 8 )
644644   AM_RANGE(0x0000, 0x5fff) AM_ROM
645645   AM_RANGE(0x6000, 0x67ff) AM_RAM
646   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
646   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
647647   AM_RANGE(0x9400, 0x97ff) AM_READ(galaxold_videoram_r)
648   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
649   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
650   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
648   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
649   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
650   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
651651   AM_RANGE(0x9880, 0x98ff) AM_RAM
652652   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
653653   AM_RANGE(0xa003, 0xa003) AM_WRITE(galaxold_coin_counter_w)
r11160r11161
665665   AM_RANGE(0x0000, 0x5fff) AM_ROM
666666   AM_RANGE(0x6000, 0x6fff) AM_RAM
667667   AM_RANGE(0x7000, 0x7fff) AM_ROM
668   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
669   AM_RANGE(0x9800, 0x983f) AM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
670   AM_RANGE(0x9840, 0x987f) AM_WRITEONLY AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
671   AM_RANGE(0x98c0, 0x98ff) AM_WRITEONLY AM_BASE(&galaxold_spriteram2) AM_SIZE(&galaxold_spriteram2_size)
668   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
669   AM_RANGE(0x9800, 0x983f) AM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
670   AM_RANGE(0x9840, 0x987f) AM_WRITEONLY AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
671   AM_RANGE(0x98c0, 0x98ff) AM_WRITEONLY AM_BASE_MEMBER(galaxold_state, m_spriteram2) AM_SIZE_MEMBER(galaxold_state, m_spriteram2_size)
672672   AM_RANGE(0xa000, 0xa0ff) AM_READ_PORT("IN0")
673673   AM_RANGE(0xa003, 0xa003) AM_WRITE(galaxold_coin_counter_w)
674674  //AM_RANGE(0xa004, 0xa007) AM_WRITE(galaxian_lfo_freq_w)
r11160r11161
691691   AM_RANGE(0x0000, 0x5fff) AM_ROM
692692   AM_RANGE(0x7000, 0x7000) AM_READ_PORT("DSW0") /* mirror */
693693   AM_RANGE(0x8000, 0x87ff) AM_RAM
694   AM_RANGE(0x8800, 0x883f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
695   AM_RANGE(0x8840, 0x885f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
696   AM_RANGE(0x8860, 0x887f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
694   AM_RANGE(0x8800, 0x883f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
695   AM_RANGE(0x8840, 0x885f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
696   AM_RANGE(0x8860, 0x887f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
697697   AM_RANGE(0x8880, 0x8bff) AM_WRITENOP
698   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
698   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
699699   AM_RANGE(0x9800, 0x9800) AM_READ(watchdog_reset_r)
700700   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
701701   AM_RANGE(0xa7ff, 0xa7ff) AM_READ_PORT("IN0") /* mirror */
r11160r11161
716716   AM_RANGE(0x0000, 0x5fff) AM_ROM
717717   AM_RANGE(0x8000, 0x83ff) AM_RAM
718718   AM_RANGE(0x8400, 0x87ff) AM_WRITENOP // not used
719   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
719   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
720720   AM_RANGE(0x9400, 0x97ff) AM_WRITENOP // not used
721   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
722   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
723   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE(&galaxold_bulletsram) AM_SIZE(&galaxold_bulletsram_size)
721   AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
722   AM_RANGE(0x9840, 0x985f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
723   AM_RANGE(0x9860, 0x987f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_bulletsram) AM_SIZE_MEMBER(galaxold_state, m_bulletsram_size)
724724   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
725725   AM_RANGE(0xa800, 0xa800) AM_READ_PORT("IN1")
726726   AM_RANGE(0xb000, 0xb000) AM_READ_PORT("DSW0")
r11160r11161
742742   AM_RANGE(0x0000, 0x2fff) AM_ROM
743743   AM_RANGE(0x4000, 0x4200) AM_RAM
744744   AM_RANGE(0x4300, 0x43ff) AM_RAM
745   AM_RANGE(0x4800, 0x4bff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w) AM_BASE(&galaxold_videoram)
745   AM_RANGE(0x4800, 0x4bff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
746746   AM_RANGE(0x4c00, 0x4fff) AM_WRITE(galaxold_videoram_w)
747   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
748   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
747   AM_RANGE(0x5000, 0x503f) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
748   AM_RANGE(0x5040, 0x505f) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
749749   AM_RANGE(0x6801, 0x6801) AM_WRITENOP //continuosly 0 and 1
750750   AM_RANGE(0x6802, 0x6802) AM_WRITE(galaxold_coin_counter_w)
751751   AM_RANGE(0x6806, 0x6806) AM_WRITE(galaxold_flip_screen_x_w)
r11160r11161
766766   AM_RANGE(0x0000, 0x1fff) AM_ROM
767767   AM_RANGE(0x2000, 0x27ff) AM_RAM
768768   AM_RANGE(0x4000, 0x47ff) AM_RAM
769   AM_RANGE(0x4800, 0x4fff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w) AM_BASE(&galaxold_videoram)
769   AM_RANGE(0x4800, 0x4fff) AM_READWRITE(galaxold_videoram_r, galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
770770   AM_RANGE(0x5000, 0x5000) AM_WRITENOP
771771   AM_RANGE(0x5800, 0x5800) AM_READNOP AM_WRITE(interrupt_enable_w)
772772   AM_RANGE(0x5801, 0x5807) AM_WRITENOP
773773   AM_RANGE(0x6101, 0x6101) AM_READ_PORT("IN0")
774774   AM_RANGE(0x6102, 0x6102) AM_READ_PORT("IN1")
775775   AM_RANGE(0x6103, 0x6103) AM_WRITENOP
776   AM_RANGE(0x6200, 0x6203) AM_WRITENOP AM_BASE(&galaxold_attributesram)
776   AM_RANGE(0x6200, 0x6203) AM_WRITENOP AM_BASE_MEMBER(galaxold_state, m_attributesram)
777777   AM_RANGE(0x8000, 0x9fff) AM_ROM
778   AM_RANGE(0xffe6, 0xffff) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
778   AM_RANGE(0xffe6, 0xffff) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
779779ADDRESS_MAP_END
780780
781781static ADDRESS_MAP_START( harem_cpu2, AS_PROGRAM, 8 )
r11160r11161
797797
798798static ADDRESS_MAP_START( hunchbkg, AS_PROGRAM, 8 )
799799   AM_RANGE(0x0000, 0x0fff) AM_ROM
800   AM_RANGE(0x1480, 0x14bf) AM_MIRROR(0x6000) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
801   AM_RANGE(0x14c0, 0x14ff) AM_MIRROR(0x6000) AM_WRITEONLY AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
800   AM_RANGE(0x1480, 0x14bf) AM_MIRROR(0x6000) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
801   AM_RANGE(0x14c0, 0x14ff) AM_MIRROR(0x6000) AM_WRITEONLY AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
802802   AM_RANGE(0x1500, 0x1500) AM_MIRROR(0x6000) AM_READ_PORT("IN0")
803803   AM_RANGE(0x1500, 0x1501) AM_MIRROR(0x6000) AM_WRITE(galaxold_leds_w)         /* not connected ... */
804804   AM_RANGE(0x1502, 0x1502) AM_MIRROR(0x6000) AM_WRITE(galaxold_coin_lockout_w)   /* not connected ... */
r11160r11161
815815   AM_RANGE(0x1606, 0x1606) AM_MIRROR(0x6000) AM_WRITE(galaxold_flip_screen_x_w)
816816   AM_RANGE(0x1607, 0x1607) AM_MIRROR(0x6000) AM_WRITE(galaxold_flip_screen_y_w)
817817   AM_RANGE(0x1680, 0x1680) AM_MIRROR(0x6000) AM_READ(watchdog_reset_r) AM_DEVWRITE(GAL_AUDIO, galaxian_pitch_w)
818   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
818   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
819819   AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM
820820   AM_RANGE(0x2000, 0x2fff) AM_ROM
821821   AM_RANGE(0x4000, 0x4fff) AM_ROM
r11160r11161
832832
833833static ADDRESS_MAP_START( drivfrcg, AS_PROGRAM, 8 )
834834   AM_RANGE(0x0000, 0x0fff) AM_ROM
835   AM_RANGE(0x1480, 0x14bf) AM_MIRROR(0x6000) AM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
836   AM_RANGE(0x14c0, 0x14ff) AM_MIRROR(0x6000) AM_WRITEONLY AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
835   AM_RANGE(0x1480, 0x14bf) AM_MIRROR(0x6000) AM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
836   AM_RANGE(0x14c0, 0x14ff) AM_MIRROR(0x6000) AM_WRITEONLY AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
837837   AM_RANGE(0x1500, 0x1500) AM_MIRROR(0x6000) AM_READ_PORT("IN0")
838838   AM_RANGE(0x1503, 0x1503) AM_MIRROR(0x6000) AM_WRITE(galaxold_coin_counter_w)
839839   AM_RANGE(0x1580, 0x1580) AM_MIRROR(0x6000) AM_READ_PORT("IN1")
r11160r11161
845845   AM_RANGE(0x1700, 0x1700) AM_MIRROR(0x6000) AM_READ_PORT("DSW1") AM_WRITENOP
846846   AM_RANGE(0x1701, 0x1701) AM_MIRROR(0x6000) AM_WRITENOP
847847   AM_RANGE(0x1704, 0x1707) AM_MIRROR(0x6000) AM_DEVWRITE(GAL_AUDIO, galaxian_vol_w)
848   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
848   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
849849   AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM
850850   AM_RANGE(0x2000, 0x2fff) AM_ROM
851851   AM_RANGE(0x4000, 0x4fff) AM_ROM
r11160r11161
860860
861861static ADDRESS_MAP_START( racknrol, AS_PROGRAM, 8 )
862862   AM_RANGE(0x0000, 0x0fff) AM_ROM
863   AM_RANGE(0x1400, 0x143f) AM_MIRROR(0x6000) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE(&galaxold_attributesram)
864   AM_RANGE(0x1440, 0x14bf) AM_MIRROR(0x6000) AM_RAM AM_BASE(&galaxold_spriteram) AM_SIZE(&galaxold_spriteram_size)
863   AM_RANGE(0x1400, 0x143f) AM_MIRROR(0x6000) AM_RAM_WRITE(galaxold_attributesram_w) AM_BASE_MEMBER(galaxold_state, m_attributesram)
864   AM_RANGE(0x1440, 0x14bf) AM_MIRROR(0x6000) AM_RAM AM_BASE_MEMBER(galaxold_state, m_spriteram) AM_SIZE_MEMBER(galaxold_state, m_spriteram_size)
865865   AM_RANGE(0x14c0, 0x14ff) AM_MIRROR(0x6000) AM_RAM
866866   AM_RANGE(0x1500, 0x1500) AM_MIRROR(0x6000) AM_READ_PORT("IN0")
867867   AM_RANGE(0x1580, 0x1580) AM_MIRROR(0x6000) AM_READ_PORT("IN1")
r11160r11161
872872   AM_RANGE(0x1680, 0x1680) AM_MIRROR(0x6000) AM_READNOP
873873//  AM_RANGE(0x1700, 0x1700) AM_MIRROR(0x6000) AM_READ(trvchlng_question_r)
874874//  AM_RANGE(0x1701, 0x1703) AM_MIRROR(0x6000) AM_READ(trvchlng_question_w)
875   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
875   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_WRITE(galaxold_videoram_w) AM_BASE_MEMBER(galaxold_state, m_videoram)
876876   AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM
877877   AM_RANGE(0x2000, 0x2fff) AM_ROM
878878   AM_RANGE(0x4000, 0x4fff) AM_ROM
r11160r11161
883883   AM_RANGE(0x1d, 0x1d) AM_DEVWRITE("sn1", sn76496_w)
884884   AM_RANGE(0x1e, 0x1e) AM_DEVWRITE("sn2", sn76496_w)
885885   AM_RANGE(0x1f, 0x1f) AM_DEVWRITE("sn3", sn76496_w)
886   AM_RANGE(0x20, 0x3f) AM_WRITE(racknrol_tiles_bank_w) AM_BASE(&racknrol_tiles_bank)
886   AM_RANGE(0x20, 0x3f) AM_WRITE(racknrol_tiles_bank_w) AM_BASE_MEMBER(galaxold_state, m_racknrol_tiles_bank)
887887   AM_RANGE(S2650_SENSE_PORT, S2650_SENSE_PORT) AM_READ_PORT("SENSE")
888888ADDRESS_MAP_END
889889
r11160r11161
903903
904904static ADDRESS_MAP_START( hexpoola_io, AS_IO, 8 )
905905   AM_RANGE(0x00, 0x00) AM_READNOP
906   AM_RANGE(0x20, 0x3f) AM_WRITE(racknrol_tiles_bank_w) AM_BASE(&racknrol_tiles_bank)
906   AM_RANGE(0x20, 0x3f) AM_WRITE(racknrol_tiles_bank_w) AM_BASE_MEMBER(galaxold_state, m_racknrol_tiles_bank)
907907   AM_RANGE(S2650_DATA_PORT, S2650_DATA_PORT) AM_READ(hexpoola_data_port_r) AM_DEVWRITE("snsnd", sn76496_w)
908908   AM_RANGE(S2650_SENSE_PORT, S2650_SENSE_PORT) AM_READ_PORT("SENSE")
909909ADDRESS_MAP_END
r11160r11161
21172117};
21182118
21192119
2120static MACHINE_CONFIG_START( galaxold_base, driver_device )
2120static MACHINE_CONFIG_START( galaxold_base, galaxold_state )
21212121
21222122   /* basic machine hardware */
21232123   MCFG_CPU_ADD("maincpu", Z80, PIXEL_CLOCK/2)   /* 3.072 MHz */
r11160r11161
22762276   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
22772277MACHINE_CONFIG_END
22782278
2279static MACHINE_CONFIG_START( drivfrcg, driver_device )
2279static MACHINE_CONFIG_START( drivfrcg, galaxold_state )
22802280
22812281   /* basic machine hardware */
22822282   MCFG_CPU_ADD("maincpu", S2650, MASTER_CLOCK/6)
r11160r11161
23702370   MCFG_CPU_PROGRAM_MAP(tazzmang)
23712371MACHINE_CONFIG_END
23722372
2373static MACHINE_CONFIG_START( racknrol, driver_device )
2373static MACHINE_CONFIG_START( racknrol, galaxold_state )
23742374
23752375   /* basic machine hardware */
23762376   MCFG_CPU_ADD("maincpu", S2650, PIXEL_CLOCK/2)
r11160r11161
24262426MACHINE_CONFIG_END
24272427
24282428
2429static MACHINE_CONFIG_START( hexpoola, driver_device )
2429static MACHINE_CONFIG_START( hexpoola, galaxold_state )
24302430
24312431   /* basic machine hardware */
24322432   MCFG_CPU_ADD("maincpu", S2650, PIXEL_CLOCK/2)
src/mame/drivers/atarisy1.c
r11160r11161
193193#include "cpu/m6502/m6502.h"
194194#include "machine/atarigen.h"
195195#include "machine/6522via.h"
196#include "includes/atarisy1.h"
197196#include "sound/tms5220.h"
198197#include "sound/2151intf.h"
199198#include "sound/pokey.h"
199#include "video/atarimo.h"
200#include "includes/atarisy1.h"
200201
201202
202203
r11160r11161
481482   AM_RANGE(0x8c0000, 0x8c0001) AM_WRITE(atarigen_eeprom_enable_w)
482483   AM_RANGE(0x900000, 0x9fffff) AM_RAM
483484   AM_RANGE(0xa00000, 0xa01fff) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(atarisy1_state, m_playfield)
484   AM_RANGE(0xa02000, 0xa02fff) AM_RAM_WRITE(atarisy1_spriteram_w) AM_BASE(&atarimo_0_spriteram)
485   AM_RANGE(0xa02000, 0xa02fff) AM_READWRITE(atarimo_0_spriteram_r, atarisy1_spriteram_w)
485486   AM_RANGE(0xa03000, 0xa03fff) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(atarisy1_state, m_alpha)
486487   AM_RANGE(0xb00000, 0xb007ff) AM_RAM_WRITE(paletteram16_IIIIRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram)
487488   AM_RANGE(0xf00000, 0xf00fff) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_SHARE("eeprom")
src/mame/drivers/dec0.c
r11160r11161
3939
4040ToDo:
4141- Fix protection simulation in Birdie Try (that part needs a complete rewrite);
42- IPT_VBLANK doesn't work properly, that's particularly true for Birdie Try hang when you clear an hole (in any way it never clears out)
43  and for Boulder Dash fade in / fade out transitions (they are far too slow right now);
4442- graphics are completely broken in Automat and Secret Agent (bootleg);
4543- Fighting Fantasy (bootleg) doesn't boot at all;
46- Hook up the 68705 in Midnight Resistance (bootleg)
47   (it might not be used, leftover from the Fighting Fantasy bootleg on the same PCB?)
44- Hook up the 68705 in Midnight Resistance (bootleg) (it might not be used, leftover from the Fighting Fantasy bootleg on the same PCB?)
4845- Get rid of ROM patches in Sly Spy and Hippodrome;
46- Accurate pixel clock parameters;
47- background pen in Birdie Try is presumably wrong.
4948- Finally, get a proper decap of the MCUs used by Bad Dudes and Birdie Try;
5049
5150
r11160r11161
199198         break;
200199
201200      case 8: /* Interrupt ack (VBL - IRQ 6) */
201         cputag_set_input_line(space->machine(), "maincpu", 6, CLEAR_LINE);
202202         break;
203203
204204      case 0xa: /* Mix Psel(?). */
r11160r11161
13581358   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
13591359MACHINE_CONFIG_END
13601360
1361//   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK, DEC0_HTOTAL, DEC0_HBEND, DEC0_HBSTART, DEC0_VTOTAL, DEC0_VBEND, DEC0_VBSTART)
13611362
1363/* TODO: These are raw guesses, only to get ~57,41 Hz */
1364#define DEC0_PIXEL_CLOCK XTAL_20MHz/4
1365#define DEC0_HTOTAL 256+74
1366#define DEC0_HBEND 0
1367#define DEC0_HBSTART 256
1368#define DEC0_VTOTAL 264
1369#define DEC0_VBEND 8
1370#define DEC0_VBSTART 256-8
13621371
1372
13631373static MACHINE_CONFIG_DERIVED( automat, dec0_base )
13641374
13651375   /* basic machine hardware */
r11160r11161
13721382
13731383   /* video hardware */
13741384   MCFG_SCREEN_ADD("screen", RASTER)
1375   MCFG_SCREEN_REFRESH_RATE(57.41)
1376   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
1385//   MCFG_SCREEN_REFRESH_RATE(57.41)
1386//   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
13771387   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1378   MCFG_SCREEN_SIZE(32*8, 32*8)
1379   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
1388   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK,DEC0_HTOTAL,DEC0_HBEND,DEC0_HBSTART,DEC0_VTOTAL,DEC0_VBEND,DEC0_VBSTART)
13801389   MCFG_SCREEN_UPDATE(robocop)
13811390
13821391   MCFG_GFXDECODE(automat)
r11160r11161
14071416   /* basic machine hardware */
14081417   MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2)
14091418   MCFG_CPU_PROGRAM_MAP(dec0_map)
1410   MCFG_CPU_VBLANK_INT("screen", irq6_line_hold)/* VBL, level 5 interrupts from i8751 */
1419   MCFG_CPU_VBLANK_INT("screen", irq6_line_assert)/* VBL, level 5 interrupts from i8751 */
14111420
14121421   MCFG_CPU_ADD("audiocpu", M6502, XTAL_12MHz / 8)
14131422   MCFG_CPU_PROGRAM_MAP(dec0_s_map)
r11160r11161
14171426
14181427   /* video hardware */
14191428   MCFG_SCREEN_ADD("screen", RASTER)
1420   MCFG_SCREEN_REFRESH_RATE(57.41)
1421   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
1429   //MCFG_SCREEN_REFRESH_RATE(57.41)
1430   //MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
14221431   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1423   MCFG_SCREEN_SIZE(32*8, 32*8)
1424   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
1432   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK,DEC0_HTOTAL,DEC0_HBEND,DEC0_HBSTART,DEC0_VTOTAL,DEC0_VBEND,DEC0_VBSTART)
1433   //MCFG_SCREEN_SIZE(32*8, 32*8)
1434   //MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
14251435   MCFG_SCREEN_UPDATE(hbarrel)
14261436MACHINE_CONFIG_END
14271437
r11160r11161
14301440   /* basic machine hardware */
14311441   MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2)
14321442   MCFG_CPU_PROGRAM_MAP(dec0_map)
1433   MCFG_CPU_VBLANK_INT("screen", irq6_line_hold)/* VBL, level 5 interrupts from i8751 */
1443   MCFG_CPU_VBLANK_INT("screen", irq6_line_assert)/* VBL, level 5 interrupts from i8751 */
14341444
14351445   MCFG_CPU_ADD("audiocpu", M6502, XTAL_12MHz / 8)
14361446   MCFG_CPU_PROGRAM_MAP(dec0_s_map)
14371447
14381448   /* video hardware */
14391449   MCFG_SCREEN_ADD("screen", RASTER)
1440   MCFG_SCREEN_REFRESH_RATE(57.41)
1441   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
1450//   MCFG_SCREEN_REFRESH_RATE(57.41)
1451//   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
14421452   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1443   MCFG_SCREEN_SIZE(32*8, 32*8)
1444   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
1453   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK,DEC0_HTOTAL,DEC0_HBEND,DEC0_HBSTART,DEC0_VTOTAL,DEC0_VBEND,DEC0_VBSTART)
1454//   MCFG_SCREEN_SIZE(32*8, 32*8)
1455//   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
14451456   MCFG_SCREEN_UPDATE(baddudes)
14461457MACHINE_CONFIG_END
14471458
r11160r11161
14501461   /* basic machine hardware */
14511462   MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2)
14521463   MCFG_CPU_PROGRAM_MAP(dec0_map)
1453   MCFG_CPU_VBLANK_INT("screen", irq6_line_hold)/* VBL, level 5 interrupts from i8751 */
1464   MCFG_CPU_VBLANK_INT("screen", irq6_line_assert)/* VBL, level 5 interrupts from i8751 */
14541465
14551466   MCFG_CPU_ADD("audiocpu", M6502, XTAL_12MHz / 8)
14561467   MCFG_CPU_PROGRAM_MAP(dec0_s_map)
14571468
14581469   /* video hardware */
14591470   MCFG_SCREEN_ADD("screen", RASTER)
1460   MCFG_SCREEN_REFRESH_RATE(57.41)
1461   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
1471//   MCFG_SCREEN_REFRESH_RATE(57.41)
1472//   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
14621473   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1463   MCFG_SCREEN_SIZE(32*8, 32*8)
1464   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
1474   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK,DEC0_HTOTAL,DEC0_HBEND,DEC0_HBSTART,DEC0_VTOTAL,DEC0_VBEND,DEC0_VBSTART)
1475//   MCFG_SCREEN_SIZE(32*8, 32*8)
1476//   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
14651477   MCFG_SCREEN_UPDATE(birdtry)
14661478MACHINE_CONFIG_END
14671479
r11160r11161
14701482   /* basic machine hardware */
14711483   MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2)
14721484   MCFG_CPU_PROGRAM_MAP(dec0_map)
1473   MCFG_CPU_VBLANK_INT("screen", irq6_line_hold)/* VBL */
1485   MCFG_CPU_VBLANK_INT("screen", irq6_line_assert)/* VBL */
14741486
14751487   MCFG_CPU_ADD("audiocpu", M6502, XTAL_12MHz / 8)
14761488   MCFG_CPU_PROGRAM_MAP(dec0_s_map)
r11160r11161
14821494
14831495   /* video hardware */
14841496   MCFG_SCREEN_ADD("screen", RASTER)
1485   MCFG_SCREEN_REFRESH_RATE(57.41)
1486   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
1497//   MCFG_SCREEN_REFRESH_RATE(57.41)
1498//   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
14871499   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1488   MCFG_SCREEN_SIZE(32*8, 32*8)
1489   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
1500   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK,DEC0_HTOTAL,DEC0_HBEND,DEC0_HBSTART,DEC0_VTOTAL,DEC0_VBEND,DEC0_VBSTART)
1501//   MCFG_SCREEN_SIZE(32*8, 32*8)
1502//   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
14901503   MCFG_SCREEN_UPDATE(robocop)
14911504MACHINE_CONFIG_END
14921505
r11160r11161
14951508   /* basic machine hardware */
14961509   MCFG_CPU_ADD("maincpu", M68000, 10000000)
14971510   MCFG_CPU_PROGRAM_MAP(dec0_map)
1498   MCFG_CPU_VBLANK_INT("screen", irq6_line_hold)/* VBL */
1511   MCFG_CPU_VBLANK_INT("screen", irq6_line_assert)/* VBL */
14991512
15001513   MCFG_CPU_ADD("audiocpu", M6502, 1500000)
15011514   MCFG_CPU_PROGRAM_MAP(dec0_s_map)
15021515
15031516   /* video hardware */
15041517   MCFG_SCREEN_ADD("screen", RASTER)
1505   MCFG_SCREEN_REFRESH_RATE(57.41)
1506   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
1518//   MCFG_SCREEN_REFRESH_RATE(57.41)
1519//   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
15071520   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1508   MCFG_SCREEN_SIZE(32*8, 32*8)
1509   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
1521   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK,DEC0_HTOTAL,DEC0_HBEND,DEC0_HBSTART,DEC0_VTOTAL,DEC0_VBEND,DEC0_VBSTART)
1522//   MCFG_SCREEN_SIZE(32*8, 32*8)
1523//   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
15101524   MCFG_SCREEN_UPDATE(robocop)
15111525MACHINE_CONFIG_END
15121526
r11160r11161
15151529   /* basic machine hardware */
15161530   MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2)
15171531   MCFG_CPU_PROGRAM_MAP(dec0_map)
1518   MCFG_CPU_VBLANK_INT("screen", irq6_line_hold)/* VBL */
1532   MCFG_CPU_VBLANK_INT("screen", irq6_line_assert)/* VBL */
15191533
15201534   MCFG_CPU_ADD("audiocpu", M6502, XTAL_12MHz / 8)
15211535   MCFG_CPU_PROGRAM_MAP(dec0_s_map)
r11160r11161
15271541
15281542   /* video hardware */
15291543   MCFG_SCREEN_ADD("screen", RASTER)
1530   MCFG_SCREEN_REFRESH_RATE(57.41)
1531   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
1544//   MCFG_SCREEN_REFRESH_RATE(57.41)
1545//   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
15321546   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1533   MCFG_SCREEN_SIZE(32*8, 32*8)
1534   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
1547   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK,DEC0_HTOTAL,DEC0_HBEND,DEC0_HBSTART,DEC0_VTOTAL,DEC0_VBEND,DEC0_VBSTART)
1548//   MCFG_SCREEN_SIZE(32*8, 32*8)
1549//   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
15351550   MCFG_SCREEN_UPDATE(hippodrm)
15361551MACHINE_CONFIG_END
15371552
r11160r11161
15461561   /* basic machine hardware */
15471562   MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */
15481563   MCFG_CPU_PROGRAM_MAP(slyspy_map)
1549   MCFG_CPU_VBLANK_INT("screen", irq6_line_hold)/* VBL */
1564   MCFG_CPU_VBLANK_INT("screen", irq6_line_hold) /* VBL, apparently it auto-acks */
15501565
15511566   MCFG_CPU_ADD("audiocpu", H6280, XTAL_12MHz/2/3) /* verified on pcb (6Mhz is XIN on pin 10 of H6280, verified on pcb */
15521567   MCFG_CPU_PROGRAM_MAP(slyspy_s_map)
15531568
15541569   /* video hardware */
15551570   MCFG_SCREEN_ADD("screen", RASTER)
1556   MCFG_SCREEN_REFRESH_RATE(57.41)
1557   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
1571//   MCFG_SCREEN_REFRESH_RATE(57.41)
1572//   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
15581573   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1559   MCFG_SCREEN_SIZE(32*8, 32*8)
1560   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
1574   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK,DEC0_HTOTAL,DEC0_HBEND,DEC0_HBSTART,DEC0_VTOTAL,DEC0_VBEND,DEC0_VBSTART)
1575//   MCFG_SCREEN_SIZE(32*8, 32*8)
1576//   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
15611577   MCFG_SCREEN_UPDATE(slyspy)
15621578
15631579   MCFG_VIDEO_START(dec0_nodma)
r11160r11161
15801596
15811597   /* video hardware */
15821598   MCFG_SCREEN_ADD("screen", RASTER)
1583   MCFG_SCREEN_REFRESH_RATE(57.41)
1584   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
1599//   MCFG_SCREEN_REFRESH_RATE(57.41)
1600//   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
15851601   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1586   MCFG_SCREEN_SIZE(32*8, 32*8)
1587   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
1602   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK,DEC0_HTOTAL,DEC0_HBEND,DEC0_HBSTART,DEC0_VTOTAL,DEC0_VBEND,DEC0_VBSTART)
1603//   MCFG_SCREEN_SIZE(32*8, 32*8)
1604//   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
15881605   MCFG_SCREEN_UPDATE(robocop)
15891606
15901607   MCFG_GFXDECODE(secretab)
r11160r11161
16031620
16041621   /* video hardware */
16051622   MCFG_SCREEN_ADD("screen", RASTER)
1606   MCFG_SCREEN_REFRESH_RATE(57.41)
1607   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
1623//   MCFG_SCREEN_REFRESH_RATE(57.41)
1624//   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
16081625   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1609   MCFG_SCREEN_SIZE(32*8, 32*8)
1610   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
1626   MCFG_SCREEN_RAW_PARAMS(DEC0_PIXEL_CLOCK,DEC0_HTOTAL,DEC0_HBEND,DEC0_HBSTART,DEC0_VTOTAL,DEC0_VBEND,DEC0_VBSTART)
1627//   MCFG_SCREEN_SIZE(32*8, 32*8)
1628//   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
16111629   MCFG_SCREEN_UPDATE(midres)
16121630
16131631   MCFG_GFXDECODE(midres)
src/mame/drivers/vindictr.c
r11160r11161
2020#include "emu.h"
2121#include "cpu/m68000/m68000.h"
2222#include "audio/atarijsa.h"
23#include "video/atarimo.h"
2324#include "includes/vindictr.h"
2425
2526
r11160r11161
9798   AM_RANGE(0x360030, 0x360031) AM_WRITE(atarigen_sound_w)
9899   AM_RANGE(0x3e0000, 0x3e0fff) AM_RAM_WRITE(vindictr_paletteram_w) AM_BASE_GENERIC(paletteram)
99100   AM_RANGE(0x3f0000, 0x3f1fff) AM_MIRROR(0x8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(vindictr_state, m_playfield)
100   AM_RANGE(0x3f2000, 0x3f3fff) AM_MIRROR(0x8000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
101   AM_RANGE(0x3f2000, 0x3f3fff) AM_MIRROR(0x8000) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
101102   AM_RANGE(0x3f4000, 0x3f4f7f) AM_MIRROR(0x8000) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(vindictr_state, m_alpha)
102   AM_RANGE(0x3f4f80, 0x3f4fff) AM_MIRROR(0x8000) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
103   AM_RANGE(0x3f4f80, 0x3f4fff) AM_MIRROR(0x8000) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
103104   AM_RANGE(0x3f5000, 0x3f7fff) AM_MIRROR(0x8000) AM_RAM
104105ADDRESS_MAP_END
105106
src/mame/drivers/midvunit.c
r11160r11161
5353static MACHINE_RESET( midvunit )
5454{
5555   midvunit_state *state = machine.driver_data<midvunit_state>();
56   dcs_reset_w(1);
57   dcs_reset_w(0);
56   dcs_reset_w(machine, 1);
57   dcs_reset_w(machine, 0);
5858
5959   memcpy(state->m_ram_base, machine.region("user1")->base(), 0x20000*4);
6060   machine.device("maincpu")->reset();
r11160r11161
6767static MACHINE_RESET( midvplus )
6868{
6969   midvunit_state *state = machine.driver_data<midvunit_state>();
70   dcs_reset_w(1);
71   dcs_reset_w(0);
70   dcs_reset_w(machine, 1);
71   dcs_reset_w(machine, 0);
7272
7373   memcpy(state->m_ram_base, machine.region("user1")->base(), 0x20000*4);
7474   machine.device("maincpu")->reset();
r11160r11161
203203      watchdog_reset_w(space, 0, 0);
204204
205205   /* bit 1 is the DCS sound reset */
206   dcs_reset_w((~state->m_control_data >> 1) & 1);
206   dcs_reset_w(space->machine(), (~state->m_control_data >> 1) & 1);
207207
208208   /* log anything unusual */
209209   if ((olddata ^ state->m_control_data) & ~0x00e8)
r11160r11161
218218   COMBINE_DATA(&state->m_control_data);
219219
220220   /* bit 11 is the DCS sound reset */
221   dcs_reset_w((~state->m_control_data >> 11) & 1);
221   dcs_reset_w(space->machine(), (~state->m_control_data >> 11) & 1);
222222
223223   /* bit 9 is the watchdog */
224224   if ((olddata ^ state->m_control_data) & 0x0200)
r11160r11161
235235static WRITE32_HANDLER( midvunit_sound_w )
236236{
237237   logerror("Sound W = %02X\n", data);
238   dcs_data_w(data & 0xff);
238   dcs_data_w(space->machine(), data & 0xff);
239239}
240240
241241
src/mame/drivers/batman.c
r11160r11161
2020#include "emu.h"
2121#include "cpu/m68000/m68000.h"
2222#include "audio/atarijsa.h"
23#include "video/atarimo.h"
2324#include "includes/batman.h"
2425
2526
r11160r11161
147148   AM_RANGE(0x3f0000, 0x3f1fff) AM_MIRROR(0x100000) AM_WRITE(atarigen_playfield2_latched_msb_w) AM_BASE_MEMBER(batman_state, m_playfield2)
148149   AM_RANGE(0x3f2000, 0x3f3fff) AM_MIRROR(0x100000) AM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE_MEMBER(batman_state, m_playfield)
149150   AM_RANGE(0x3f4000, 0x3f5fff) AM_MIRROR(0x100000) AM_WRITE(atarigen_playfield_dual_upper_w) AM_BASE_MEMBER(batman_state, m_playfield_upper)
150   AM_RANGE(0x3f6000, 0x3f7fff) AM_MIRROR(0x100000) AM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
151   AM_RANGE(0x3f8000, 0x3f8fef) AM_MIRROR(0x100000) AM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(batman_state, m_alpha)
151   AM_RANGE(0x3f6000, 0x3f7fff) AM_MIRROR(0x100000) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
152   AM_RANGE(0x3f8000, 0x3f8eff) AM_MIRROR(0x100000) AM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(batman_state, m_alpha)
152153   AM_RANGE(0x3f8f00, 0x3f8f7f) AM_MIRROR(0x100000) AM_BASE_MEMBER(batman_state, m_atarivc_eof_data)
153   AM_RANGE(0x3f8f80, 0x3f8fff) AM_MIRROR(0x100000) AM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
154   AM_RANGE(0x3f8f80, 0x3f8fff) AM_MIRROR(0x100000) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
154155   AM_RANGE(0x3f0000, 0x3fffff) AM_MIRROR(0x100000) AM_RAM
155156ADDRESS_MAP_END
156157
src/mame/drivers/segag80v.c
r11160r11161
178178}
179179
180180
181static MACHINE_RESET( g80v )
182{
183   segag80v_state *state = machine.driver_data<segag80v_state>();
184   /* if we have a Universal Sound Board, reset it here */
185   if (state->m_has_usb)
186      sega_usb_reset(machine, 0x10);
187}
188181
189
190
191182/*************************************
192183 *
193184 *  RAM writes/decryption
r11160r11161
213204   state->m_mainram[decrypt_offset(space, offset)] = data;
214205}
215206
216static WRITE8_HANDLER( usb_ram_w ) { sega_usb_ram_w(space, decrypt_offset(space, offset), data); }
217
207static WRITE8_DEVICE_HANDLER( usb_ram_w ) { sega_usb_ram_w(device, decrypt_offset(device->machine().device("maincpu")->memory().space(AS_PROGRAM), offset), data); }
218208static WRITE8_HANDLER( vectorram_w )
219209{
220210   segag80v_state *state = space->machine().driver_data<segag80v_state>();
r11160r11161
919909   MCFG_CPU_VBLANK_INT("screen", irq0_line_hold)
920910
921911   MCFG_MACHINE_START(g80v)
922   MCFG_MACHINE_RESET(g80v)
923912
924913   /* video hardware */
925914   MCFG_SCREEN_ADD("screen", VECTOR)
r11160r11161
13181307   state->m_decrypt = segag80_security(70);
13191308
13201309   /* configure sound */
1321   state->m_has_usb = FALSE;
1310   state->m_usb = NULL;
13221311   iospace->install_legacy_write_handler(0x3e, 0x3e, FUNC(elim1_sh_w));
13231312   iospace->install_legacy_write_handler(0x3f, 0x3f, FUNC(elim2_sh_w));
13241313}
r11160r11161
13331322   state->m_decrypt = segag80_security(76);
13341323
13351324   /* configure sound */
1336   state->m_has_usb = FALSE;
1325   state->m_usb = NULL;
13371326   iospace->install_legacy_write_handler(0x3e, 0x3e, FUNC(elim1_sh_w));
13381327   iospace->install_legacy_write_handler(0x3f, 0x3f, FUNC(elim2_sh_w));
13391328
r11160r11161
13521341   state->m_decrypt = segag80_security(64);
13531342
13541343   /* configure sound */
1355   state->m_has_usb = FALSE;
1356   iospace->install_legacy_write_handler(0x38, 0x38, FUNC(sega_speech_data_w));
1357   iospace->install_legacy_write_handler(0x3b, 0x3b, FUNC(sega_speech_control_w));
1344   state->m_usb = NULL;
1345   iospace->install_legacy_write_handler(*machine.device("segaspeech"), 0x38, 0x38, FUNC(sega_speech_data_w));
1346   iospace->install_legacy_write_handler(*machine.device("segaspeech"), 0x3b, 0x3b, FUNC(sega_speech_control_w));
13581347   iospace->install_legacy_write_handler(0x3e, 0x3e, FUNC(spacfury1_sh_w));
13591348   iospace->install_legacy_write_handler(0x3f, 0x3f, FUNC(spacfury2_sh_w));
13601349}
r11160r11161
13701359   state->m_decrypt = segag80_security(82);
13711360
13721361   /* configure sound */
1373   state->m_has_usb = FALSE;
1374   iospace->install_legacy_write_handler(0x38, 0x38, FUNC(sega_speech_data_w));
1375   iospace->install_legacy_write_handler(0x3b, 0x3b, FUNC(sega_speech_control_w));
1362   state->m_usb = NULL;
1363   iospace->install_legacy_write_handler(*machine.device("segaspeech"), 0x38, 0x38, FUNC(sega_speech_data_w));
1364   iospace->install_legacy_write_handler(*machine.device("segaspeech"), 0x3b, 0x3b, FUNC(sega_speech_control_w));
13761365   iospace->install_legacy_write_handler(*ay, 0x3c, 0x3d, FUNC(ay8910_address_data_w));
13771366   iospace->install_legacy_write_handler(0x3e, 0x3e, FUNC(zektor1_sh_w));
13781367   iospace->install_legacy_write_handler(0x3f, 0x3f, FUNC(zektor2_sh_w));
r11160r11161
13931382   state->m_decrypt = segag80_security(76);
13941383
13951384   /* configure sound */
1396   state->m_has_usb = TRUE;
1397   iospace->install_legacy_readwrite_handler(0x3f, 0x3f, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
1398   pgmspace->install_legacy_readwrite_handler(0xd000, 0xdfff, FUNC(sega_usb_ram_r), FUNC(usb_ram_w));
1385   state->m_usb = machine.device("usbsnd");
1386   iospace->install_legacy_readwrite_handler(*state->m_usb, 0x3f, 0x3f, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
1387   pgmspace->install_legacy_readwrite_handler(*state->m_usb, 0xd000, 0xdfff, FUNC(sega_usb_ram_r), FUNC(usb_ram_w));
13991388
14001389   /* configure inputs */
14011390   iospace->install_legacy_write_handler(0xf8, 0xf8, FUNC(spinner_select_w));
r11160r11161
14131402   state->m_decrypt = segag80_security(64);
14141403
14151404   /* configure sound */
1416   state->m_has_usb = TRUE;
1417   iospace->install_legacy_write_handler(0x38, 0x38, FUNC(sega_speech_data_w));
1418   iospace->install_legacy_write_handler(0x3b, 0x3b, FUNC(sega_speech_control_w));
1405   state->m_usb = machine.device("usbsnd");
1406   iospace->install_legacy_write_handler(*machine.device("segaspeech"), 0x38, 0x38, FUNC(sega_speech_data_w));
1407   iospace->install_legacy_write_handler(*machine.device("segaspeech"), 0x3b, 0x3b, FUNC(sega_speech_control_w));
14191408
1420   iospace->install_legacy_readwrite_handler(0x3f, 0x3f, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
1421   pgmspace->install_legacy_readwrite_handler(0xd000, 0xdfff, FUNC(sega_usb_ram_r), FUNC(usb_ram_w));
1409   iospace->install_legacy_readwrite_handler(*state->m_usb, 0x3f, 0x3f, FUNC(sega_usb_status_r), FUNC(sega_usb_data_w));
1410   pgmspace->install_legacy_readwrite_handler(*state->m_usb, 0xd000, 0xdfff, FUNC(sega_usb_ram_r), FUNC(usb_ram_w));
14221411
14231412   /* configure inputs */
14241413   iospace->install_legacy_write_handler(0xf8, 0xf8, FUNC(spinner_select_w));
src/mame/drivers/astrocde.c
r11160r11161
125125#include "gorf.lh"
126126
127127
128static UINT8 *protected_ram;
129
130static UINT8 port_1_last;
131static UINT8 port_2_last;
132static UINT8 ram_write_enable;
133static UINT8 input_select;
134static UINT8 profpac_bank;
135
136
137
138128/*************************************
139129 *
140130 *  Machine setup
r11160r11161
143133
144134static MACHINE_START( astrocde )
145135{
146   state_save_register_global(machine, port_1_last);
147   state_save_register_global(machine, port_2_last);
148   state_save_register_global(machine, ram_write_enable);
149   state_save_register_global(machine, input_select);
150   state_save_register_global(machine, profpac_bank);
136   astrocde_state *state = machine.driver_data<astrocde_state>();
137   state_save_register_global(machine, state->m_port_1_last);
138   state_save_register_global(machine, state->m_port_2_last);
139   state_save_register_global(machine, state->m_ram_write_enable);
140   state_save_register_global(machine, state->m_input_select);
141   state_save_register_global(machine, state->m_profpac_bank);
151142
152   port_1_last = port_2_last = 0xff;
143   state->m_port_1_last = state->m_port_2_last = 0xff;
153144}
154145
155146
r11160r11161
162153
163154static WRITE8_HANDLER( protected_ram_enable_w )
164155{
165   ram_write_enable = TRUE;
156   astrocde_state *state = space->machine().driver_data<astrocde_state>();
157   state->m_ram_write_enable = TRUE;
166158}
167159
168160
169161static READ8_HANDLER( protected_ram_r )
170162{
171   ram_write_enable = FALSE;
172   return protected_ram[offset];
163   astrocde_state *state = space->machine().driver_data<astrocde_state>();
164   state->m_ram_write_enable = FALSE;
165   return state->m_protected_ram[offset];
173166}
174167
175168
176169static WRITE8_HANDLER( protected_ram_w )
177170{
178   if (ram_write_enable)
179      protected_ram[offset] = data;
180   ram_write_enable = FALSE;
171   astrocde_state *state = space->machine().driver_data<astrocde_state>();
172   if (state->m_ram_write_enable)
173      state->m_protected_ram[offset] = data;
174   state->m_ram_write_enable = FALSE;
181175}
182176
183177
r11160r11161
210204
211205static WRITE8_HANDLER( seawolf2_sound_1_w )  // Port 40
212206{
207   astrocde_state *state = space->machine().driver_data<astrocde_state>();
213208   device_t *samples = space->machine().device("samples");
214   UINT8 rising_bits = data & ~port_1_last;
215   port_1_last = data;
209   UINT8 rising_bits = data & ~state->m_port_1_last;
210   state->m_port_1_last = data;
216211
217212   if (rising_bits & 0x01) sample_start(samples, 1, 1, 0);  /* Left Torpedo */
218213   if (rising_bits & 0x02) sample_start(samples, 0, 0, 0);  /* Left Ship Hit */
r11160r11161
225220
226221static WRITE8_HANDLER( seawolf2_sound_2_w )  // Port 41
227222{
223   astrocde_state *state = space->machine().driver_data<astrocde_state>();
228224   device_t *samples = space->machine().device("samples");
229   UINT8 rising_bits = data & ~port_2_last;
230   port_2_last = data;
225   UINT8 rising_bits = data & ~state->m_port_2_last;
226   state->m_port_2_last = data;
231227
232228   sample_set_volume(samples, 0, (data & 0x80) ? 1.0 : 0.0);
233229   sample_set_volume(samples, 1, (data & 0x80) ? 1.0 : 0.0);
r11160r11161
263259
264260static CUSTOM_INPUT( ebases_trackball_r )
265261{
262   astrocde_state *state = field->port->machine().driver_data<astrocde_state>();
266263   static const char *const names[] = { "TRACKX2", "TRACKY2", "TRACKX1", "TRACKY1" };
267   return input_port_read(field->port->machine(), names[input_select]);
264   return input_port_read(field->port->machine(), names[state->m_input_select]);
268265}
269266
270267
271268static WRITE8_HANDLER( ebases_trackball_select_w )
272269{
273   input_select = data & 3;
270   astrocde_state *state = space->machine().driver_data<astrocde_state>();
271   state->m_input_select = data & 3;
274272}
275273
276274
r11160r11161
304302
305303static READ8_HANDLER( wow_io_r )
306304{
305   astrocde_state *state = space->machine().driver_data<astrocde_state>();
307306   UINT8 data = (offset >> 8) & 1;
308307
309308   switch ((offset >> 9) & 7)
310309   {
311310      case 0: coin_counter_w(space->machine(), 0, data);      break;
312311      case 1: coin_counter_w(space->machine(), 1, data);      break;
313      case 2: astrocade_sparkle[0] = data;   break;
314      case 3: astrocade_sparkle[1] = data;   break;
315      case 4: astrocade_sparkle[2] = data;   break;
316      case 5: astrocade_sparkle[3] = data;   break;
312      case 2: state->m_sparkle[0] = data;   break;
313      case 3: state->m_sparkle[1] = data;   break;
314      case 4: state->m_sparkle[2] = data;   break;
315      case 5: state->m_sparkle[3] = data;   break;
317316      case 7: coin_counter_w(space->machine(), 2, data);      break;
318317   }
319318   return 0xff;
r11160r11161
329328
330329static READ8_HANDLER( gorf_io_1_r )
331330{
331   astrocde_state *state = space->machine().driver_data<astrocde_state>();
332332   UINT8 data = (offset >> 8) & 1;
333333
334334   switch ((offset >> 9) & 7)
335335   {
336336      case 0: coin_counter_w(space->machine(), 0, data);      break;
337337      case 1: coin_counter_w(space->machine(), 1, data);      break;
338      case 2: astrocade_sparkle[0] = data;   break;
339      case 3: astrocade_sparkle[1] = data;   break;
340      case 4: astrocade_sparkle[2] = data;   break;
341      case 5: astrocade_sparkle[3] = data;   break;
338      case 2: state->m_sparkle[0] = data;   break;
339      case 3: state->m_sparkle[1] = data;   break;
340      case 4: state->m_sparkle[2] = data;   break;
341      case 5: state->m_sparkle[3] = data;   break;
342342      case 6:
343343         space->machine().device<astrocade_device>("astrocade1")->set_output_gain(0, data ? 0.0 : 1.0);
344344         space->machine().device<samples_device>("samples")->set_output_gain(0, data ? 1.0 : 0.0);
r11160r11161
422422
423423static WRITE8_HANDLER( profpac_banksw_w )
424424{
425   astrocde_state *state = space->machine().driver_data<astrocde_state>();
425426   int bank = (data >> 5) & 3;
426427
427428   /* this is accessed from I/O space but modifies program space, so we normalize here */
428429   space = space->device().memory().space(AS_PROGRAM);
429430
430431   /* remember the banking bits for save state support */
431   profpac_bank = data;
432   state->m_profpac_bank = data;
432433
433434   /* set the main banking */
434435   space->install_read_bank(0x4000, 0xbfff, "bank1");
r11160r11161
458459
459460static STATE_POSTLOAD( profbank_banksw_restore )
460461{
462   astrocde_state *state = machine.driver_data<astrocde_state>();
461463   address_space *space = machine.device("maincpu")->memory().space(AS_IO);
462464
463   profpac_banksw_w(space, 0, profpac_bank);
465   profpac_banksw_w(space, 0, state->m_profpac_bank);
464466}
465467
466468
r11160r11161
473475
474476static READ8_HANDLER( demndrgn_io_r )
475477{
478   astrocde_state *state = space->machine().driver_data<astrocde_state>();
476479   coin_counter_w(space->machine(), 0, (offset >> 8) & 1);
477480   coin_counter_w(space->machine(), 1, (offset >> 9) & 1);
478481   set_led_status(space->machine(), 0, (offset >> 10) & 1);
479482   set_led_status(space->machine(), 1, (offset >> 11) & 1);
480   input_select = (offset >> 12) & 1;
483   state->m_input_select = (offset >> 12) & 1;
481484   return 0xff;
482485}
483486
484487
485488static CUSTOM_INPUT( demndragn_joystick_r )
486489{
490   astrocde_state *state = field->port->machine().driver_data<astrocde_state>();
487491   static const char *const names[] = { "MOVEX", "MOVEY" };
488   return input_port_read(field->port->machine(), names[input_select]);
492   return input_port_read(field->port->machine(), names[state->m_input_select]);
489493}
490494
491495
r11160r11161
602606   AM_RANGE(0x0000, 0x3fff) AM_ROM
603607   AM_RANGE(0x0000, 0x3fff) AM_WRITE(astrocade_funcgen_w)
604608   AM_RANGE(0x4000, 0x7fff) AM_RAM AM_BASE_MEMBER(astrocde_state, m_videoram)
605   AM_RANGE(0xd000, 0xd03f) AM_READWRITE(protected_ram_r, protected_ram_w) AM_BASE(&protected_ram)
609   AM_RANGE(0xd000, 0xd03f) AM_READWRITE(protected_ram_r, protected_ram_w) AM_BASE_MEMBER(astrocde_state, m_protected_ram)
606610   AM_RANGE(0xd040, 0xd7ff) AM_RAM
607611ADDRESS_MAP_END
608612
r11160r11161
612616   AM_RANGE(0x0000, 0x3fff) AM_WRITE(astrocade_funcgen_w)
613617   AM_RANGE(0x4000, 0x7fff) AM_RAM AM_BASE_MEMBER(astrocde_state, m_videoram)
614618   AM_RANGE(0x8000, 0xcfff) AM_ROM
615   AM_RANGE(0xd000, 0xd03f) AM_READWRITE(protected_ram_r, protected_ram_w) AM_BASE(&protected_ram)
619   AM_RANGE(0xd000, 0xd03f) AM_READWRITE(protected_ram_r, protected_ram_w) AM_BASE_MEMBER(astrocde_state, m_protected_ram)
616620   AM_RANGE(0xd040, 0xdfff) AM_RAM
617621ADDRESS_MAP_END
618622
r11160r11161
622626   AM_RANGE(0x0000, 0x3fff) AM_WRITE(astrocade_funcgen_w)
623627   AM_RANGE(0x4000, 0x7fff) AM_RAM AM_BASE_MEMBER(astrocde_state, m_videoram)
624628   AM_RANGE(0x8000, 0xdfff) AM_ROM
625   AM_RANGE(0xe000, 0xe1ff) AM_READWRITE(protected_ram_r, protected_ram_w) AM_BASE(&protected_ram)
629   AM_RANGE(0xe000, 0xe1ff) AM_READWRITE(protected_ram_r, protected_ram_w) AM_BASE_MEMBER(astrocde_state, m_protected_ram)
626630   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_SHARE("nvram")
627631   AM_RANGE(0xe800, 0xffff) AM_RAM
628632ADDRESS_MAP_END
r11160r11161
634638   AM_RANGE(0x4000, 0x7fff) AM_READWRITE(profpac_videoram_r, profpac_videoram_w)
635639   AM_RANGE(0x4000, 0xbfff) AM_ROMBANK("bank1")
636640   AM_RANGE(0xc000, 0xdfff) AM_ROM
637   AM_RANGE(0xe000, 0xe1ff) AM_READWRITE(protected_ram_r, protected_ram_w) AM_BASE(&protected_ram)
641   AM_RANGE(0xe000, 0xe1ff) AM_READWRITE(protected_ram_r, protected_ram_w) AM_BASE_MEMBER(astrocde_state, m_protected_ram)
638642   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_SHARE("nvram")
639643   AM_RANGE(0xe800, 0xffff) AM_RAM
640644ADDRESS_MAP_END
r11160r11161
837841
838842static INPUT_CHANGED( spacezap_monitor )
839843{
844   astrocde_state *state = field->port->machine().driver_data<astrocde_state>();
840845   if (newval)
841      astrocade_video_config &= ~AC_MONITOR_BW;
846      state->m_video_config &= ~AC_MONITOR_BW;
842847   else
843      astrocade_video_config |= AC_MONITOR_BW;
848      state->m_video_config |= AC_MONITOR_BW;
844849}
845850
846851static INPUT_PORTS_START( spacezap )
r11160r11161
17281733
17291734static DRIVER_INIT( seawolf2 )
17301735{
1731   astrocade_video_config = 0x00;
1736   astrocde_state *state = machine.driver_data<astrocde_state>();
1737   state->m_video_config = 0x00;
17321738   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x40, 0x40, 0, 0xff18, FUNC(seawolf2_sound_1_w));
17331739   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x41, 0x41, 0, 0xff18, FUNC(seawolf2_sound_2_w));
17341740   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x42, 0x43, 0, 0xff18, FUNC(seawolf2_lamps_w));
r11160r11161
17371743
17381744static DRIVER_INIT( ebases )
17391745{
1740   astrocade_video_config = AC_SOUND_PRESENT;
1746   astrocde_state *state = machine.driver_data<astrocde_state>();
1747   state->m_video_config = AC_SOUND_PRESENT;
17411748   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x20, 0x20, 0, 0xff07, FUNC(ebases_coin_w));
17421749   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_write_handler(0x28, 0x28, 0, 0xff07, FUNC(ebases_trackball_select_w));
17431750}
r11160r11161
17451752
17461753static DRIVER_INIT( spacezap )
17471754{
1748   astrocade_video_config = AC_SOUND_PRESENT | AC_MONITOR_BW;
1755   astrocde_state *state = machine.driver_data<astrocde_state>();
1756   state->m_video_config = AC_SOUND_PRESENT | AC_MONITOR_BW;
17491757   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x13, 0x13, 0x03ff, 0xff00, FUNC(spacezap_io_r));
17501758}
17511759
17521760
17531761static DRIVER_INIT( wow )
17541762{
1755   astrocade_video_config = AC_SOUND_PRESENT | AC_LIGHTPEN_INTS | AC_STARS;
1763   astrocde_state *state = machine.driver_data<astrocde_state>();
1764   state->m_video_config = AC_SOUND_PRESENT | AC_LIGHTPEN_INTS | AC_STARS;
17561765   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x15, 0x15, 0x0fff, 0xff00, FUNC(wow_io_r));
17571766   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x17, 0x17, 0xffff, 0xff00, FUNC(wow_speech_r));
17581767}
r11160r11161
17601769
17611770static DRIVER_INIT( gorf )
17621771{
1763   astrocade_video_config = AC_SOUND_PRESENT | AC_LIGHTPEN_INTS | AC_STARS;
1772   astrocde_state *state = machine.driver_data<astrocde_state>();
1773   state->m_video_config = AC_SOUND_PRESENT | AC_LIGHTPEN_INTS | AC_STARS;
17641774   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x15, 0x15, 0x0fff, 0xff00, FUNC(gorf_io_1_r));
17651775   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x16, 0x16, 0x0fff, 0xff00, FUNC(gorf_io_2_r));
17661776   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x17, 0x17, 0xffff, 0xff00, FUNC(gorf_speech_r));
r11160r11161
17691779
17701780static DRIVER_INIT( robby )
17711781{
1772   astrocade_video_config = AC_SOUND_PRESENT;
1782   astrocde_state *state = machine.driver_data<astrocde_state>();
1783   state->m_video_config = AC_SOUND_PRESENT;
17731784   machine.device("maincpu")->memory().space(AS_IO)->install_legacy_read_handler(0x15, 0x15, 0x0fff, 0xff00, FUNC(robby_io_r));
17741785}
17751786
17761787
17771788static DRIVER_INIT( profpac )
17781789{
1790   astrocde_state *state = machine.driver_data<astrocde_state>();
17791791   address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
17801792
1781   astrocade_video_config = AC_SOUND_PRESENT;
1793   state->m_video_config = AC_SOUND_PRESENT;
17821794   iospace->install_legacy_read_handler(0x14, 0x14, 0x0fff, 0xff00, FUNC(profpac_io_1_r));
17831795   iospace->install_legacy_read_handler(0x15, 0x15, 0x77ff, 0xff00, FUNC(profpac_io_2_r));
17841796
r11160r11161
17901802
17911803static DRIVER_INIT( demndrgn )
17921804{
1805   astrocde_state *state = machine.driver_data<astrocde_state>();
17931806   address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
17941807
1795   astrocade_video_config = 0x00;
1808   state->m_video_config = 0x00;
17961809   iospace->install_legacy_read_handler(0x14, 0x14, 0x1fff, 0xff00, FUNC(demndrgn_io_r));
17971810   iospace->install_read_port(0x1c, 0x1c, 0x0000, 0xff00, "FIREX");
17981811   iospace->install_read_port(0x1d, 0x1d, 0x0000, 0xff00, "FIREY");
r11160r11161
18061819
18071820static DRIVER_INIT( tenpindx )
18081821{
1822   astrocde_state *state = machine.driver_data<astrocde_state>();
18091823   address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
18101824
1811   astrocade_video_config = 0x00;
1825   state->m_video_config = 0x00;
18121826   iospace->install_read_port(0x60, 0x60, 0x0000, 0xff00, "P60");
18131827   iospace->install_read_port(0x61, 0x61, 0x0000, 0xff00, "P61");
18141828   iospace->install_read_port(0x62, 0x62, 0x0000, 0xff00, "P62");
src/mame/drivers/blstroid.c
r11160r11161
2121#include "cpu/m68000/m68000.h"
2222#include "machine/atarigen.h"
2323#include "audio/atarijsa.h"
24#include "video/atarimo.h"
2425#include "includes/blstroid.h"
2526
2627
r11160r11161
108109   AM_RANGE(0xffa000, 0xffa3ff) AM_MIRROR(0x7f8c00) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
109110   AM_RANGE(0xffb000, 0xffb3ff) AM_MIRROR(0x7f8c00) AM_READWRITE(atarigen_eeprom_r, atarigen_eeprom_w) AM_SHARE("eeprom")
110111   AM_RANGE(0xffc000, 0xffcfff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(blstroid_state, m_playfield)
111   AM_RANGE(0xffd000, 0xffdfff) AM_MIRROR(0x7f8000) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
112   AM_RANGE(0xffd000, 0xffdfff) AM_MIRROR(0x7f8000) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
112113   AM_RANGE(0xffe000, 0xffffff) AM_MIRROR(0x7f8000) AM_RAM
113114ADDRESS_MAP_END
114115
src/mame/drivers/spoker.c
r11160r11161
66- Understand how to reset NVRAM
77- Map DSW (Operator mode doesn't help)
88- Map Leds and Coin counters
9- 3super8 randomly crashes
10- 3super8 doesn't have the 8x32 tilemap, change the video emulation accordingly
911***************************************************************************/
1012
1113#include "emu.h"
1214#include "cpu/z180/z180.h"
15#include "cpu/z80/z80.h"
1316#include "sound/2413intf.h"
1417#include "sound/okim6295.h"
1518#include "machine/nvram.h"
r11160r11161
3336   tilemap_t *m_fg_tilemap;
3437
3538   int m_video_enable;
36   int m_nmi_enable;
39   int m_nmi_ack;
3740   int m_hopper;
3841   UINT8 m_igs_magic[2];
3942   UINT8 m_out[3];
r11160r11161
120123{
121124   spoker_state *state = space->machine().driver_data<spoker_state>();
122125
123   if ((state->m_nmi_enable ^ data) & (~0xdd))
126   if ((data) & (0x22))
124127   {
125128      logerror("PC %06X: nmi_and_coins = %02x\n",cpu_get_pc(&space->device()),data);
126129//      popmessage("%02x",data);
r11160r11161
133136
134137   set_led_status(space->machine(), 6,      data & 0x40);   // led for coin out / hopper active
135138
136   state->m_nmi_enable = data;   //  data & 0x80     // nmi enable?
139   if(((state->m_nmi_ack & 0x80) == 0) && data & 0x80)
140      cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
137141
142   state->m_nmi_ack = data & 0x80;     // nmi acknowledge, 0 -> 1
143
138144   state->m_out[0] = data;
139145   show_out(state->m_out);
140146}
r11160r11161
227233
228234   AM_RANGE( 0x5000, 0x5fff ) AM_RAM_WRITE( fg_tile_w )  AM_BASE_MEMBER( spoker_state,m_fg_tile_ram )
229235
236   /* TODO: ppi #1 */
230237   AM_RANGE( 0x6480, 0x6480 ) AM_WRITE( spoker_nmi_and_coins_w )
231
232238   AM_RANGE( 0x6481, 0x6481 ) AM_READ_PORT( "SERVICE" )
233239   AM_RANGE( 0x6482, 0x6482 ) AM_READ_PORT( "COINS" )
240
241   /* TODO: ppi #2 */
234242   AM_RANGE( 0x6490, 0x6490 ) AM_READ_PORT( "BUTTONS1" )
235243   AM_RANGE( 0x6491, 0x6491 ) AM_WRITE( spoker_video_and_leds_w )
236244   AM_RANGE( 0x6492, 0x6492 ) AM_WRITE( spoker_leds_w )
245
237246   AM_RANGE( 0x64a0, 0x64a0 ) AM_READ_PORT( "BUTTONS2" )
238247
239248   AM_RANGE( 0x64b0, 0x64b1 ) AM_DEVWRITE( "ymsnd", ym2413_w )
r11160r11161
245254   AM_RANGE( 0x7000, 0x7fff ) AM_RAM_WRITE( fg_color_w ) AM_BASE_MEMBER( spoker_state,m_fg_color_ram )
246255ADDRESS_MAP_END
247256
257static ADDRESS_MAP_START( 3super8_portmap, AS_IO, 8 )
258//   AM_RANGE( 0x1000, 0x1fff ) AM_WRITENOP
248259
260   AM_RANGE( 0x2000, 0x27ff ) AM_RAM_WRITE( paletteram_xBBBBBGGGGGRRRRR_split1_w ) AM_BASE_GENERIC( paletteram )
261   AM_RANGE( 0x2800, 0x2fff ) AM_RAM_WRITE( paletteram_xBBBBBGGGGGRRRRR_split2_w ) AM_BASE_GENERIC( paletteram2 )
249262
263   AM_RANGE( 0x3000, 0x33ff ) AM_RAM_WRITE( bg_tile_w ) AM_BASE_MEMBER( spoker_state,m_bg_tile_ram )
250264
265   AM_RANGE( 0x4000, 0x4000 ) AM_READ_PORT( "DSW1" )
266   AM_RANGE( 0x4001, 0x4001 ) AM_READ_PORT( "DSW2" )
267   AM_RANGE( 0x4002, 0x4002 ) AM_READ_PORT( "DSW3" )
268   AM_RANGE( 0x4003, 0x4003 ) AM_READ_PORT( "DSW4" )
269   AM_RANGE( 0x4004, 0x4004 ) AM_READ_PORT( "DSW5" )
270
271//   AM_RANGE( 0x4000, 0x40ff ) AM_WRITENOP
272
273   AM_RANGE( 0x5000, 0x5fff ) AM_RAM_WRITE( fg_tile_w )  AM_BASE_MEMBER( spoker_state,m_fg_tile_ram )
274
275   AM_RANGE( 0x6480, 0x6480 ) AM_READ_PORT( "IN0" )
276   AM_RANGE( 0x6490, 0x6490 ) AM_READ_PORT( "IN1" )
277   AM_RANGE( 0x6491, 0x6491 ) AM_DEVREADWRITE_MODERN("oki", okim6295_device, read, write)
278   AM_RANGE( 0x64a0, 0x64a0 ) AM_READ_PORT( "IN2" )
279   AM_RANGE( 0x64b0, 0x64b0 ) AM_WRITE( spoker_leds_w )
280   AM_RANGE( 0x64c0, 0x64c0 ) AM_READNOP //irq ack?
281
282   AM_RANGE( 0x64f0, 0x64f0 ) AM_WRITE(spoker_nmi_and_coins_w )
283
284   AM_RANGE( 0x7000, 0x7fff ) AM_RAM_WRITE( fg_color_w ) AM_BASE_MEMBER( spoker_state,m_fg_color_ram )
285ADDRESS_MAP_END
286
287
251288/***************************************************************************
252289                                Input Ports
253290***************************************************************************/
r11160r11161
324361   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
325362INPUT_PORTS_END
326363
364static INPUT_PORTS_START( 3super8 )
365   PORT_START("DSW1")
366   PORT_DIPUNKNOWN( 0x01, 0x01 )
367   PORT_DIPUNKNOWN( 0x02, 0x02 )
368   PORT_DIPUNKNOWN( 0x04, 0x04 )
369   PORT_DIPUNKNOWN( 0x08, 0x08 )
370   PORT_DIPUNKNOWN( 0x10, 0x10 )
371   PORT_DIPUNKNOWN( 0x20, 0x20 )
372   PORT_DIPUNKNOWN( 0x40, 0x40 )
373   PORT_DIPUNKNOWN( 0x80, 0x80 )
374
375   PORT_START("DSW2")
376   PORT_DIPUNKNOWN( 0x01, 0x01 )
377   PORT_DIPUNKNOWN( 0x02, 0x02 )
378   PORT_DIPUNKNOWN( 0x04, 0x04 )
379   PORT_DIPUNKNOWN( 0x08, 0x08 )
380   PORT_DIPUNKNOWN( 0x10, 0x10 )
381   PORT_DIPUNKNOWN( 0x20, 0x20 )
382   PORT_DIPUNKNOWN( 0x40, 0x40 )
383   PORT_DIPUNKNOWN( 0x80, 0x80 )
384
385   PORT_START("DSW3")
386   PORT_DIPUNKNOWN( 0x01, 0x01 )
387   PORT_DIPUNKNOWN( 0x02, 0x02 )
388   PORT_DIPUNKNOWN( 0x04, 0x04 )
389   PORT_DIPUNKNOWN( 0x08, 0x08 )
390   PORT_DIPUNKNOWN( 0x10, 0x10 )
391   PORT_DIPUNKNOWN( 0x20, 0x20 )
392   PORT_DIPUNKNOWN( 0x40, 0x40 )
393   PORT_DIPUNKNOWN( 0x80, 0x80 )
394
395   PORT_START("DSW4")
396   PORT_DIPUNKNOWN( 0xff, 0xff )
397
398   PORT_START("DSW5")
399   PORT_DIPUNKNOWN( 0xff, 0xff )
400
401   PORT_START("IN0")
402   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN  )
403   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL  ) PORT_CUSTOM( hopper_r, (void *)0 ) PORT_NAME("HPSW")   // hopper sensor
404   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
405   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_GAMBLE_BOOK ) PORT_NAME("Statistics")
406   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1   )
407   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2   )
408   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_GAMBLE_KEYOUT ) PORT_NAME("Key Down")
409   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT )
410
411   PORT_START("IN1")
412   PORT_DIPNAME( 0x01, 0x01, "IN1" )
413   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
414   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
415   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
416   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
417   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
418   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
419   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
420   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
421   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
422   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
423   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
424   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
425   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
426   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
427   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
428   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
429   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
430   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
431   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
432   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
433   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
434   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
435   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
436
437   PORT_START("IN2")
438   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
439   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_POKER_HOLD1 ) PORT_NAME("Hold 1 / High / Low")
440   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_POKER_HOLD5 ) PORT_NAME("Hold 5 / Bet")
441   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_POKER_HOLD4 ) PORT_NAME("Hold 4 / Take")
442   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_HOLD3 ) PORT_NAME("Hold 3 / W-Up")
443   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_POKER_HOLD2 ) PORT_NAME("Hold 2 / Red / Black")
444   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN  )
445   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN  )
446INPUT_PORTS_END
447
327448/***************************************************************************
328449                                Graphics Layout
329450***************************************************************************/
r11160r11161
354475   8*32*2
355476};
356477
478static const gfx_layout layout3s8_8x8x6 =
479{
480   8,8,
481   RGN_FRAC(1,3),
482   6,
483   { RGN_FRAC(0,3)+2*8, RGN_FRAC(0,3)+0, RGN_FRAC(1,3)+2*8, RGN_FRAC(1,3)+0,RGN_FRAC(2,3)+2*8, RGN_FRAC(2,3)+0 },
484   { 0, 1,2,3,4,5,6,7 },
485   { 0*8, 1*8, 4*8, 5*8, 8*8, 9*8,  12*8, 13*8 },
486   16*8
487};
488
357489static GFXDECODE_START( spoker )
358490   GFXDECODE_ENTRY( "gfx1", 0x00000, layout_8x8x6,   0, 16 )
359491   GFXDECODE_ENTRY( "gfx2", 0x04000, layout_8x32x6,  0, 16 )
r11160r11161
362494   GFXDECODE_ENTRY( "gfx2", 0x00000, layout_8x32x6,  0, 16 )
363495GFXDECODE_END
364496
497static GFXDECODE_START( 3super8 )
498   GFXDECODE_ENTRY( "gfx1", 0x00000, layout3s8_8x8x6,   0, 16 )
499   GFXDECODE_ENTRY( "gfx2", 0x04000, layout_8x32x6,     0, 16 )
500   GFXDECODE_ENTRY( "gfx2", 0x08000, layout_8x32x6,     0, 16 )
501   GFXDECODE_ENTRY( "gfx2", 0x0c000, layout_8x32x6,     0, 16 )
502   GFXDECODE_ENTRY( "gfx2", 0x00000, layout_8x32x6,     0, 16 )
503GFXDECODE_END
365504
366505
367
368506/***************************************************************************
369507                                Machine Drivers
370508***************************************************************************/
r11160r11161
373511{
374512   spoker_state *state = machine.driver_data<spoker_state>();
375513
376   state->m_nmi_enable      =   0;
514   state->m_nmi_ack      =   0;
377515   state->m_hopper         =   0;
378516   state->m_video_enable   =   1;
379517}
380518
381519static INTERRUPT_GEN( spoker_interrupt )
382520{
383   spoker_state *state = device->machine().driver_data<spoker_state>();
521//   spoker_state *state = device->machine().driver_data<spoker_state>();
384522
385    if (state->m_nmi_enable & 0x80)
386      device_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
523   device_set_input_line(device, INPUT_LINE_NMI, ASSERT_LINE);
387524}
388525
389526static MACHINE_CONFIG_START( spoker, spoker_state )
r11160r11161
421558   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
422559MACHINE_CONFIG_END
423560
561static MACHINE_CONFIG_DERIVED( 3super8, spoker )
424562
563   MCFG_CPU_REPLACE("maincpu", Z80, XTAL_24MHz / 4)   /* z840006, 24/4 MHz? */
564   MCFG_CPU_MODIFY("maincpu")
565   MCFG_CPU_PROGRAM_MAP(spoker_map)
566   MCFG_CPU_IO_MAP(3super8_portmap)
567   MCFG_CPU_VBLANK_INT("screen",spoker_interrupt)
568   MCFG_CPU_PERIODIC_INT(irq0_line_hold,120) // this signal comes from the PIC
569
570   MCFG_GFXDECODE(3super8)
571
572   MCFG_DEVICE_REMOVE("ymsnd")
573MACHINE_CONFIG_END
574
425575static DRIVER_INIT( spk116it )
426576{
427577   int A;
r11160r11161
438588   }
439589}
440590
441
442ROM_START( spk115it )
591ROM_START( spk116it )
443592   ROM_REGION( 0x10000, "maincpu", 0 )
444   ROM_LOAD( "v.bin",   0x0000, 0x10000, CRC(df52997b) SHA1(72a76e84aeedfdebd4c6cb47809117a28b5d3892) )
593   ROM_LOAD( "v.bin",   0x0000, 0x10000, CRC(e44e943a) SHA1(78e32d07e2be9a452be10735641cbcf269068c55) )
445594
446595   ROM_REGION( 0xc0000, "gfx1", 0 )
447   ROM_LOAD( "6.bin",  0x80000, 0x40000, CRC(f9b027f8) SHA1(c4686a4024062482f9864e0445087e32899fc775) )
448   ROM_LOAD( "5.bin",  0x40000, 0x40000, CRC(baca51b6) SHA1(c97322c814729332378b6304a79062fea385ca97) )
449   ROM_LOAD( "4.bin",  0x00000, 0x40000, CRC(1172c790) SHA1(43f1d019ecae5c605722e3fe77ae2f022b01260b) )
596   ROM_LOAD( "6.bin",  0x80000, 0x40000, CRC(55b54b11) SHA1(decf27d40ec842374af02c93d761375690be83a3) )
597   ROM_LOAD( "5.bin",  0x40000, 0x40000, CRC(163f5b64) SHA1(5d3a5c2a64691ee9e2bb3a7c283aa9efa53fb35e) )
598   ROM_LOAD( "4.bin",  0x00000, 0x40000, CRC(ec2c6ac3) SHA1(e0a38da26202d2b9a481060fe5b88a38e284201e) )
450599
451600   ROM_REGION( 0x30000, "gfx2", 0 )
452601   ROM_LOAD( "3.bin",  0x20000, 0x10000, CRC(5f18b012) SHA1(c9a96237eaf3138f136bbaffb29dde0ef568ce73) )
r11160r11161
457606   ROM_LOAD( "7.bin",   0x0000, 0x40000, CRC(67789f1c) SHA1(1bef621b4d6399f76020c6310e2e1c2f861679de) )
458607ROM_END
459608
460
461ROM_START( spk116it )
609ROM_START( spk115it )
462610   ROM_REGION( 0x10000, "maincpu", 0 )
463   ROM_LOAD( "v.bin",   0x0000, 0x10000, CRC(e44e943a) SHA1(78e32d07e2be9a452be10735641cbcf269068c55) )
611   ROM_LOAD( "v.bin",   0x0000, 0x10000, CRC(df52997b) SHA1(72a76e84aeedfdebd4c6cb47809117a28b5d3892) )
464612
465613   ROM_REGION( 0xc0000, "gfx1", 0 )
466   ROM_LOAD( "6.bin",  0x80000, 0x40000, CRC(55b54b11) SHA1(decf27d40ec842374af02c93d761375690be83a3) )
467   ROM_LOAD( "5.bin",  0x40000, 0x40000, CRC(163f5b64) SHA1(5d3a5c2a64691ee9e2bb3a7c283aa9efa53fb35e) )
468   ROM_LOAD( "4.bin",  0x00000, 0x40000, CRC(ec2c6ac3) SHA1(e0a38da26202d2b9a481060fe5b88a38e284201e) )
614   ROM_LOAD( "6.bin",  0x80000, 0x40000, CRC(f9b027f8) SHA1(c4686a4024062482f9864e0445087e32899fc775) )
615   ROM_LOAD( "5.bin",  0x40000, 0x40000, CRC(baca51b6) SHA1(c97322c814729332378b6304a79062fea385ca97) )
616   ROM_LOAD( "4.bin",  0x00000, 0x40000, CRC(1172c790) SHA1(43f1d019ecae5c605722e3fe77ae2f022b01260b) )
469617
470618   ROM_REGION( 0x30000, "gfx2", 0 )
471619   ROM_LOAD( "3.bin",  0x20000, 0x10000, CRC(5f18b012) SHA1(c9a96237eaf3138f136bbaffb29dde0ef568ce73) )
r11160r11161
476624   ROM_LOAD( "7.bin",   0x0000, 0x40000, CRC(67789f1c) SHA1(1bef621b4d6399f76020c6310e2e1c2f861679de) )
477625ROM_END
478626
479GAME( 1993?, spk116it, 0,        spoker, spoker,  spk116it, ROT0, "IGS", "Super Poker (v116IT)", 0 )
480GAME( 1993?, spk115it, spk116it, spoker, spoker,  spk116it, ROT0, "IGS", "Super Poker (v115IT)", 0 )
627/*
628
629Produttore  ?Italy?
630N.revisione
631CPU
632
6331x 24mhz osc
6342x fpga
6351x z840006
6361x PIC16c65a-20/p
6371x 6295 oki
638
639ROMs
640
641Note
642
6434x 8 dipswitch
6441x 4 dispwitch
645
646*/
647
648// all gfx / sound roms are bad.  they're definitely meant to have different data
649//  in each half, and maybe even be twice the size.
650//  in all cases the first half is missing (the sample table in the samples rom for example)
651//1.bin                                           1ST AND 2ND HALF IDENTICAL
652//2.bin                                           1ST AND 2ND HALF IDENTICAL
653//3.bin                                           1ST AND 2ND HALF IDENTICAL
654//sound.bin                                       1ST AND 2ND HALF IDENTICAL
655
656
657ROM_START( 3super8 )
658   ROM_REGION( 0x20000, "maincpu", 0 )
659   ROM_LOAD( "prgrom.bin", 0x00000, 0x20000, CRC(37c85dfe) SHA1(56bd2fb859b17dda1e675a385b6bcd6867ecceb0)  )
660
661   ROM_REGION( 0x1000, "pic", 0 )
662   ROM_LOAD( "pic16c65a-20-p", 0x0000, 0x1000, NO_DUMP )
663
664   ROM_REGION( 0xc0000, "gfx1", 0 )
665   ROM_LOAD( "1.bin", 0x00000, 0x40000, BAD_DUMP CRC(d9d3e21e) SHA1(2f3f07ca427d9f56f0ff143d15d95cbf15255e33) )
666   ROM_LOAD( "2.bin", 0x40000, 0x40000, BAD_DUMP CRC(fbb50ab1) SHA1(50a7ef9219c38d59117c510fe6d53fb3ba1fa456) )
667   ROM_LOAD( "3.bin", 0x80000, 0x40000, BAD_DUMP CRC(545aa4e6) SHA1(3348d4b692900c9e9cd4a52b20922a84e596cd35) )
668   ROM_FILL( 0x00000 ,0x20000, 0x00 )
669   ROM_FILL( 0x40000 ,0x20000, 0x00 )
670   ROM_FILL( 0x80000 ,0x20000, 0x00 )
671
672   ROM_REGION( 0x30000, "gfx2", ROMREGION_ERASE00 )
673
674   ROM_REGION( 0xc0000, "rep_gfx", 0 ) //not real, taken from spk116it
675   ROM_LOAD( "4.bin",  0x00000, 0x40000, BAD_DUMP CRC(ec2c6ac3) SHA1(e0a38da26202d2b9a481060fe5b88a38e284201e) )
676   ROM_LOAD( "5.bin",  0x40000, 0x40000, BAD_DUMP CRC(163f5b64) SHA1(5d3a5c2a64691ee9e2bb3a7c283aa9efa53fb35e) )
677   ROM_LOAD( "6.bin",  0x80000, 0x40000, BAD_DUMP CRC(55b54b11) SHA1(decf27d40ec842374af02c93d761375690be83a3) )
678
679   ROM_REGION( 0x40000, "oki", 0 )
680   ROM_LOAD( "sound.bin", 0x00000, 0x40000, BAD_DUMP CRC(230b31c3) SHA1(38c107325d3a4e9781912078b1317dc9ba3e1ced) )
681ROM_END
682
683static DRIVER_INIT( 3super8 )
684{
685   UINT8 *ROM = machine.region("maincpu")->base();
686   int i;
687
688   /* Decryption is probably done using one macrocell/output on an address decoding pal which we do not have a dump of */
689   /* The encryption is quite awful actually, especially since the program rom is entirely blank/0xFF but encrypted on its second half, exposing the entire function in plaintext */
690   /* Input: A6, A7, A8, A9, A11; Output: D5 XOR */
691   /* function: (A6&A8)&((!A7&A11)|(A9&!A11)); */
692   /* nor-reduced: !(!(!(!A6|!A8))|!(!(A7|!A11)|!(!A9|A11))); */
693   for(i=0;i<0x20000;i++)
694   {
695      UINT8 a6, a7, a8, a9, a11, d5 = 0;
696      a6 = BIT(i,6); a7 = BIT(i,7); a8 = BIT(i,8); a9 = BIT(i,9); a11 = BIT(i,11);
697      d5 = (a6&a8)&((!a7&a11)|(a9&!a11));
698      ROM[i] ^= d5*0x20;
699   }
700
701   /* cheesy hack: take gfx roms from spk116it and rearrange them for this game needs */
702   {
703      UINT8 *src = machine.region("rep_gfx")->base();
704      UINT8 *dst = machine.region("gfx1")->base();
705      UINT8 x;
706
707      for(x=0;x<3;x++)
708      {
709         for(i=0;i<0x20000;i+=4)
710         {
711            dst[i+0+x*0x40000] = src[i+0+x*0x40000];
712            dst[i+1+x*0x40000] = src[i+2+x*0x40000];
713            dst[i+2+x*0x40000] = src[i+1+x*0x40000];
714            dst[i+3+x*0x40000] = src[i+3+x*0x40000];
715         }
716      }
717   }
718}
719
720GAME( 1993?, spk116it, 0,        spoker, spoker,  spk116it, ROT0, "IGS",       "Super Poker (v116IT)", 0 )
721GAME( 1993?, spk115it, spk116it, spoker, spoker,  spk116it, ROT0, "IGS",       "Super Poker (v115IT)", 0 )
722GAME( 1993?, 3super8,  spk116it, 3super8,3super8, 3super8,  ROT0, "<unknown>", "3 Super 8 (Italy)",    GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) //roms are badly dumped
src/mame/drivers/mcr68.c
r11160r11161
210210{
211211   mcr68_state *state = space->machine().driver_data<mcr68_state>();
212212   COMBINE_DATA(&state->m_control_word);
213   williams_cvsd_reset_w(~state->m_control_word & 0x0400);
213   williams_cvsd_reset_w(space->machine(), ~state->m_control_word & 0x0400);
214214   williams_cvsd_data_w(space->machine(), state->m_control_word & 0x3ff);
215215}
216216
src/mame/drivers/funworld.c
r11160r11161
11/**********************************************************************************
22
3
43  FUNWORLD / TAB.
54
65  Original preliminary driver:    Curt Coder, Peter Trauner.
r11160r11161
98
109  Games running on this hardware:
1110
12  * Jolly Card (austrian),                            TAB Austria,        1985.
11  * Jolly Card (Austrian),                            TAB Austria,        1985.
1312  * Jolly Card (3x3 deal),                            TAB Austria,        1985.
1413  * Jolly Card Professional 2.0 (MZS Tech),           MZS Tech,           1993.
1514  * Jolly Card Professional 2.0 (Spale Soft),         Spale Soft,         2000.
1615  * Jolly Card (Evona Electronic),                    Evona Electronic    1998.
17  * Jolly Card (croatian, set 1),                     TAB Austria,        1985.
18  * Jolly Card (croatian, set 2),                     Soft Design,        1993.
19  * Jolly Card (italian, blue TAB board, encrypted),  bootleg,            199?.
20  * Jolly Card (italian, encrypted bootleg),          bootleg,            1990.
16  * Jolly Card (Croatian, set 1),                     TAB Austria,        1985.
17  * Jolly Card (Croatian, set 2),                     Soft Design,        1993.
18  * Jolly Card (Italian, blue TAB board, encrypted),  bootleg,            199?.
19  * Jolly Card (Italian, encrypted bootleg),          bootleg,            1990.
2120  * Super Joly 2000 - 3x,                             M.P.                1985.
22  * Jolly Card (austrian, Funworld, bootleg),         Inter Games,        1986.
23  * Big Deal (hungarian, set 1),                      Funworld,           1986.
24  * Big Deal (hungarian, set 2),                      Funworld,           1986.
25  * Jolly Card (austrian, Funworld),                  Funworld,           1986.
26  * Cuore 1 (italian),                                C.M.C.,             1996.
27  * Elephant Family (italian, new),                   C.M.C.,             1997.
28  * Elephant Family (italian, old),                   C.M.C.,             1996.
29  * Pool 10 (italian, set 1),                         C.M.C.,             1996.
30  * Pool 10 (italian, set 2),                         C.M.C.,             1996.
31  * Pool 10 (italian, set 3),                         C.M.C.,             1996.
32  * Pool 10 (italian, set 4),                         C.M.C.,             1997.
33  * Tortuga Family (italian),                         C.M.C.,             1997.
34  * Pot Game (italian),                               C.M.C.,             1996.
35  * Bottle 10 (italian, set 1),                       C.M.C.,             1996.
36  * Bottle 10 (italian, set 2),                       C.M.C.,             1996.
37  * Royal Card (austrian, set 1),                     TAB Austria,        1991.
38  * Royal Card (austrian, set 2),                     TAB Austria,        1991.
39  * Royal Card (austrian/polish, set 3),              TAB Austria,        1991.
40  * Royal Card (austrian, set 4),                     TAB Austria,        1991.
41  * Royal Card (austrian, set 5),                     TAB Austria,        1991.
42  * Royal Card (austrian, set 6),                     TAB Austria,        1991.
21  * Jolly Card (Austrian, Funworld, bootleg),         Inter Games,        1986.
22  * Big Deal (Hungarian, set 1),                      Funworld,           1986.
23  * Big Deal (Hungarian, set 2),                      Funworld,           1986.
24  * Jolly Card (Austrian, Funworld),                  Funworld,           1986.
25  * Cuore 1 (Italian),                                C.M.C.,             1996.
26  * Elephant Family (Italian, new),                   C.M.C.,             1997.
27  * Elephant Family (Italian, old),                   C.M.C.,             1996.
28  * Pool 10 (Italian, set 1),                         C.M.C.,             1996.
29  * Pool 10 (Italian, set 2),                         C.M.C.,             1996.
30  * Pool 10 (Italian, set 3),                         C.M.C.,             1996.
31  * Pool 10 (Italian, set 4),                         C.M.C.,             1997.
32  * Tortuga Family (Italian),                         C.M.C.,             1997.
33  * Pot Game (Italian),                               C.M.C.,             1996.
34  * Bottle 10 (Italian, set 1),                       C.M.C.,             1996.
35  * Bottle 10 (Italian, set 2),                       C.M.C.,             1996.
36  * Royal Card (Austrian, set 1),                     TAB Austria,        1991.
37  * Royal Card (Austrian, set 2),                     TAB Austria,        1991.
38  * Royal Card (Austrian/Polish, set 3),              TAB Austria,        1991.
39  * Royal Card (Austrian, set 4),                     TAB Austria,        1991.
40  * Royal Card (Austrian, set 5),                     TAB Austria,        1991.
41  * Royal Card (Austrian, set 6),                     TAB Austria,        1991.
4342  * Royal Card (TAB original),                        TAB Austria,        1991.
44  * Royal Card (slovak, encrypted),                   Evona Electronic,   1991.
43  * Royal Card (Slovak, encrypted),                   Evona Electronic,   1991.
4544  * Royal Card Professional 2.0,                      Digital Dreams,     1993.
4645  * Lucky Lady (3x3 deal),                            TAB Austria,        1991.
4746  * Lucky Lady (4x1 aces),                            TAB Austria,        1991.
48  * Magic Card II (bulgarian),                        Impera,             1996.
49  * Magic Card II (green TAB or Impera board),        Impera,             1996.
50  * Magic Card II (blue TAB board, encrypted),        Impera,             1996.
51  * Royal Vegas Joker Card (slow deal),               Funworld,           1993.
52  * Royal Vegas Joker Card (fast deal),               Soft Design,        1993.
53  * Royal Vegas Joker Card (fast deal, english gfx),  Soft Design,        1993.
54  * Royal Vegas Joker Card (fast deal, Mile),         Mile,               1993.
47  * Magic Card II (Bulgarian),                        Impera,             1996.
48  * Magic Card II (Green TAB or Impera board),        Impera,             1996.
49  * Magic Card II (Blue TAB board, encrypted),        Impera,             1996.
50  * Royal Vegas Joker Card (Slow deal),               Funworld,           1993.
51  * Royal Vegas Joker Card (Fast deal),               Soft Design,        1993.
52  * Royal Vegas Joker Card (Fast deal, english gfx),  Soft Design,        1993.
53  * Royal Vegas Joker Card (Fast deal, Mile),         Mile,               1993.
5554  * Jolly Joker (98bet, set 1).                       Impera,             198?.
5655  * Jolly Joker (98bet, set 2).                       Impera,             198?.
5756  * Jolly Joker (40bet, croatian hack),               Impera,             198?.
5857  * Multi Win (Ver.0167, encrypted),                  Funworld,           1992.
5958  * Joker Card (Ver.A267BC, encrypted),               Vesely Svet,        1993.
60  * Mongolfier New (italian),                         bootleg,            199?.
61  * Soccer New (italian),                             bootleg,            199?.
62  * Saloon (french, encrypted),                       unknown,            199?.
63  * Fun World Quiz (austrian),                        Funworld,           198?.
59  * Mongolfier New (Italian),                         bootleg,            199?.
60  * Soccer New (Italian),                             bootleg,            199?.
61  * Saloon (French, encrypted),                       unknown,            199?.
62  * Fun World Quiz (Austrian),                        Funworld,           198?.
63  * Witch Royal (Export version 2.1),                 Video Klein,        199?.
6464
65
6665***********************************************************************************
6766
68
6967  The hardware is generally composed by:
7068
7169  CPU:    1x 65SC02 or 65C02 at 2MHz.
r11160r11161
321319  Beschreibung / Description
322320  --------------------------
323321
324  F?r OES 5,-- Einwurf werden 3 Kredite gegeben. F?r einen Kredit bekommt der Spieler
322  Fur OES 5,-- Einwurf werden 3 Kredite gegeben. Fur einen Kredit bekommt der Spieler
325323  500 Spielpunkte. Bei jeder Frage kann der Spieler 100, 500 oder alle Punkte einsetzen.
326324  Wird die Frage richtig beantwortet, wird der Einsatz aufaddiert. Erreicht der Spieler
327325  nach 5 Fragen mehr als 2500 Punkte, bekommt er Bonusfragen. Das Spiel endet bei einer
r11160r11161
350348  as soon as the current game ends.
351349
352350
353
354351***********************************************************************************
355352
356353
r11160r11161
719716  - Now principal Royal Card sets have a working bet button.
720717  - Added default NVRAM to the new sets.
721718
719  [2011/04/04]
720  - Added 'Witch Royal' from Video Klein. Seems a hybrid game
721     from Witch Card and Royal Card...
722  - Reworked the button-lamps layout to get the hold buttons
723     more centered.
722724
723725
724726  *** TO DO ***
r11160r11161
902904
903905*/
904906
907static ADDRESS_MAP_START( witchryl_map, AS_PROGRAM, 8 )
908   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_SHARE("nvram")
909   AM_RANGE(0x0800, 0x0803) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
910   AM_RANGE(0x0a00, 0x0a03) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
911   AM_RANGE(0x0c00, 0x0c00) AM_DEVREAD("ay8910", ay8910_r)
912   AM_RANGE(0x0c00, 0x0c01) AM_DEVWRITE("ay8910", ay8910_address_data_w)
913   AM_RANGE(0x0e00, 0x0e00) AM_DEVWRITE("crtc", mc6845_address_w)
914   AM_RANGE(0x0e01, 0x0e01) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
915   AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE_MEMBER(funworld_state, m_videoram)
916   AM_RANGE(0x5000, 0x5fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE_MEMBER(funworld_state, m_colorram)
917   AM_RANGE(0x6000, 0x6000) AM_READ_PORT("DSW2")
918   AM_RANGE(0x8000, 0xffff) AM_ROM
919ADDRESS_MAP_END
905920
921
906922/*************************
907923*      Input ports       *
908924*************************/
r11160r11161
19541970   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
19551971INPUT_PORTS_END
19561972
1973static INPUT_PORTS_START( witchryl )
1974   PORT_START("IN0")
1975   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_KEYIN )   PORT_NAME("Remote")
1976   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_POKER_HOLD1 )   PORT_NAME("Halten (Hold) 1 / Hoch (High)")
1977   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_POKER_CANCEL )   PORT_NAME("Loeschen/Gamble (Cancel/Play)")
1978   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )         PORT_NAME("Geben (Start)")
1979   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_HOLD5 )   PORT_NAME("Halten (Hold) 5 / Half Gamble")
1980   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 )      PORT_NAME("Buchhalt (Service1)")
1981   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE2 )      PORT_NAME("Einstellen (Service2)")
1982   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_POKER_HOLD4 )   PORT_NAME("Halten (Hold) 4 / Kassieren (Take)")
19571983
1984   PORT_START("IN1")
1985   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_POKER_HOLD2 )   PORT_NAME("Halten (Hold) 2")
1986   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_POKER_HOLD3 )   PORT_NAME("Halten (Hold) 3 / Tief (Low)")
1987   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1988   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE )      PORT_NAME("unknown bit 08") PORT_CODE(KEYCODE_8)
1989   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE )      PORT_NAME("Hoppersch") PORT_CODE(KEYCODE_H)
1990   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
1991   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1992   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_GAMBLE_KEYOUT )   PORT_NAME("Abschreib (Payout)")
1993
1994   PORT_START("IN2")
1995   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
1996   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1997   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1998   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1999   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
2000   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
2001   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2002   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2003
2004   PORT_START("DSW")
2005   PORT_DIPNAME( 0x01, 0x01, "State" )            PORT_DIPLOCATION("SW1:8")
2006   PORT_DIPSETTING(    0x00, "Keyboard Test" )
2007   PORT_DIPSETTING(    0x01, "Game" )
2008   PORT_DIPNAME( 0x02, 0x02, "Remote Value" )      PORT_DIPLOCATION("SW1:7")
2009   PORT_DIPSETTING(    0x00, "10 Points/Pulse" )
2010   PORT_DIPSETTING(    0x02, "100 Points/Pulse" )
2011   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Coin_B ) )   PORT_DIPLOCATION("SW1:6")
2012   PORT_DIPSETTING(    0x00, "5 Points/Coin" )
2013   PORT_DIPSETTING(    0x04, "10 Points/Coin" )
2014   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Coin_A ) )   PORT_DIPLOCATION("SW1:5")
2015   PORT_DIPSETTING(    0x00, "5 Points/Coin" )
2016   PORT_DIPSETTING(    0x08, "10 Points/Coin" )
2017   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SW1:4")
2018   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2019   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2020   PORT_DIPNAME( 0x20, 0x00, "Joker" )            PORT_DIPLOCATION("SW1:3")
2021   PORT_DIPSETTING(    0x00, "With Joker" )      /* also enable Five of a Kind */
2022   PORT_DIPSETTING(    0x20, "Without Joker" )
2023   PORT_DIPNAME( 0x40, 0x00, "Hold" )            PORT_DIPLOCATION("SW1:2")
2024   PORT_DIPSETTING(    0x00, "Auto Hold" )
2025   PORT_DIPSETTING(    0x40, "No Auto Hold" )
2026   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SW1:1")
2027   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2028   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2029
2030   PORT_START("DSW2")
2031   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SW2:8")
2032   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
2033   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2034   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SW2:7")
2035   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2036   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2037   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SW2:6")
2038   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
2039   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2040   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SW2:5")
2041   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2042   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2043   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SW2:4")
2044   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2045   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2046   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SW2:3")
2047   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2048   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2049   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SW2:2")
2050   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2051   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2052   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SW2:1")
2053   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2054   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2055INPUT_PORTS_END
2056
2057
19582058/*************************
19592059*    Graphics Layouts    *
19602060*************************/
r11160r11161
22092309   MCFG_CPU_VBLANK_INT("screen", nmi_line_pulse)
22102310MACHINE_CONFIG_END
22112311
2312static MACHINE_CONFIG_DERIVED( witchryl, fw1stpal )
22122313
2314   MCFG_CPU_REPLACE("maincpu", M65C02, MASTER_CLOCK/8)   /* 2MHz */
2315   MCFG_CPU_PROGRAM_MAP(witchryl_map)
2316   MCFG_CPU_VBLANK_INT("screen", nmi_line_pulse)
2317MACHINE_CONFIG_END
22132318
2319
22142320/*************************
22152321*        Rom Load        *
22162322*************************/
r11160r11161
39194025/**** Fun World Quiz ****
39204026
39214027  Fun World Quiz
3922  ?hlinger Ges.m.b.H.
4028  Oehlinger Ges.m.b.H.
39234029
39244030  Horizontal Display
39254031  Currents
r11160r11161
40224128ROM_END
40234129
40244130
4131/*
4132  Witch Royal
4133  by Video Klein
40254134
4135  Original Video Klein PCB
4136  with CPU box.
4137 
4138*/
4139ROM_START( witchryl )
4140   ROM_REGION( 0x10000, "maincpu", 0 )
4141   ROM_LOAD( "hn58c256.bin", 0x8000, 0x8000, CRC(b89a47b9) SHA1(11fcdd5756f2998748d2f1084b1db459e90126df) )
4142
4143   ROM_REGION( 0x10000, "gfx1", 0 )
4144   ROM_LOAD( "2.u11", 0x0000, 0x8000, CRC(7edc8f44) SHA1(cabad613fa8a72dc12587d19a72bc9c6861486bd) )
4145   ROM_IGNORE(                0x8000 )   /* Identical halves. Discarding 2nd half */
4146   ROM_LOAD( "3.u4",  0x8000, 0x8000, CRC(5e4a0d59) SHA1(08eb9b1a617a7b2e6f87377819dba07082cf38b4) )
4147   ROM_IGNORE(                0x8000 )   /* Identical halves. Discarding 2nd half */
4148
4149   ROM_REGION( 0x0800,   "nvram", 0 )   /* default NVRAM */
4150   ROM_LOAD( "witchryl_nvram.bin", 0x0000, 0x0800, CRC(98366bed) SHA1(279a5ce4639b8b2ac29146b32512615253c45991) )
4151
4152   ROM_REGION( 0x0200, "proms", 0 )
4153   ROM_LOAD( "27s29.u26", 0x0000, 0x0200, CRC(8bc86f48) SHA1(4c677ab9314a1f571e35104b22659e6811aeb194) )
4154ROM_END
4155
4156
40264157/**************************
40274158*  Driver Initialization  *
40284159**************************/
r11160r11161
43694500GAME(  199?, mongolnw,  0,        royalcd1, royalcrd,  0,        ROT0, "bootleg",         "Mongolfier New (Italian)",                        GAME_NOT_WORKING )
43704501GAME(  199?, soccernw,  0,        royalcd1, royalcrd,  soccernw, ROT0, "bootleg",         "Soccer New (Italian)",                            GAME_NOT_WORKING )
43714502GAME(  198?, saloon,    0,        saloon,   saloon,    saloon,   ROT0, "<unknown>",       "Saloon (French, encrypted)",                      GAME_NOT_WORKING )
4372GAME(  198?, funquiz,   0,        funquiz,  funquiz,   0,        ROT0, "Funworld / " O_UMLAUT "hlinger", "Fun World Quiz (Austrian)",                   0 )
4373
4503GAME(  198?, funquiz,   0,        funquiz,  funquiz,   0,        ROT0, "Funworld / " O_UMLAUT "hlinger", "Fun World Quiz (Austrian)",        0 )
4504GAMEL( 199?, witchryl,  0,        witchryl, witchryl,  0,        ROT0, "Video Klein",     "Witch Royal (Export version 2.1)",                0,                       layout_jollycrd )
src/mame/drivers/2mindril.c
r11160r11161
77 preliminary driver by
88  David Haywood
99  Tomasz Slanina
10  Angelo Salese
1011
1112TODO:
1213 - understand the ball hit sensor
1314 - simulate the sensors (there are still some shutter errors/defender errors that pops up)
1415 - Hook-up timers for shutter/defender sensors (check service mode)
1516 - Dip-Switches
16 - find video control regs (layer enable, scroll)
1717
18BG scroll:
19BG maps are 2048x256 (128x16 16x16 tiles).
20There's some kind of double buffering - odd/even screens are at
21x offsets 0 and 512 (it's visible during distance count after throw (odd/even numbers))
22
23looks like regs @460000 are used,  pairs at N, and N+8, so
24460000, 460008
25460002, 46000a
26460004, 46000c
27460006, 46000e
28
29
3018 Brief hardware overview:
3119 ------------------------
3220
r11160r11161
3422
3523 Sound            - Yamaha YM2610B
3624
37 Taito custom ICs - TC0400YSC
38                  - TC0260DAR
39                  - TC0630FDP
40                  - TC0510NI0
25 Taito custom ICs - TC0400YSC (m68k -> ym2610 communication)
26                  - TC0260DAR (palette chip)
27                  - TC0630FDP (Taito F3 video chip)
28                  - TC0510NIO (known input chip)
4129
4230DAC               -26.6860Mhz
4331                  -32.0000Mhz
r11160r11161
4735#include "emu.h"
4836#include "cpu/m68000/m68000.h"
4937#include "sound/2610intf.h"
38#include "includes/taito_f3.h"
5039
5140
52class _2mindril_state : public driver_device
41class _2mindril_state : public taito_f3_state
5342{
5443public:
5544   _2mindril_state(running_machine &machine, const driver_device_config_base &config)
56      : driver_device(machine, config) { }
45      : taito_f3_state(machine, config) { }
5746
5847   /* memory pointers */
59   UINT16 *      m_map1ram;
60   UINT16 *      m_map2ram;
61   UINT16 *      m_map3ram;
62   UINT16 *      m_map4ram;
63   UINT16 *      m_charram;
64   UINT16 *      m_textram;
65   UINT16 *      m_unkram;
66//  UINT16 *      m_paletteram;   // currently this uses generic palette handling
6748   UINT16 *      m_iodata;
6849
6950   /* input-related */
7051   UINT16        m_defender_sensor;
7152   UINT16        m_shutter_sensor;
53   UINT16        irq_reg;
7254
7355   /* devices */
7456   device_t *m_maincpu;
7557};
7658
7759
78
79#define DRAW_MAP(map,num)   \
80         {   int x, y; \
81            for (y = 0; y < 16; y++) \
82               for (x = 0; x < 128; x++) \
83               { \
84                  UINT16 data0 = map[y * 128 + x * 2]; \
85                  UINT16 data1 = map[y * 128 + x * 2 + 1]; \
86                  drawgfx_transpen(bitmap, \
87                     cliprect,screen->machine().gfx[0], data1, \
88                     data0 & 0xff, \
89                     data0 & 0x4000, data0 & 0x8000, \
90                     x * 16 - 512 /*+(((INT16)(state->m_unkram[0x60000 / 2 + num])) / 32)*/, \
91                     y * 16 /*+(((INT16)(state->m_unkram[0x60008 / 2 + num])) / 32)*/,0); \
92               }   \
93         }
94
95static SCREEN_UPDATE( drill )
96{
97   _2mindril_state *state = screen->machine().driver_data<_2mindril_state>();
98   bitmap_fill(bitmap, NULL, 0);
99
100   DRAW_MAP(state->m_map1ram, 0)
101   DRAW_MAP(state->m_map2ram, 1)
102   DRAW_MAP(state->m_map3ram, 2)
103   DRAW_MAP(state->m_map4ram, 3)
104
105   {
106      int x, y;
107      for (y = 0; y < 64; y++)
108         for(x = 0; x < 64; x++)
109         {
110            drawgfx_transpen(   bitmap,
111                  cliprect,
112                  screen->machine().gfx[1],
113                  state->m_textram[y * 64 + x] & 0xff, //1ff ??
114                  ((state->m_textram[y * 64 + x] >> 9) & 0xf),
115                  0, 0,
116                  x*8,y*8,0);
117         }
118   }
119   /*printf("%.4X %.4X %.4X %.4X %.4X %.4X\n", state->m_unkram[0x60000 / 2], state->m_unkram[0x60000 / 2 + 1], state->m_unkram[0x60000 / 2 + 2],
120                                    state->m_unkram[0x60000 / 2 + 3], state->m_unkram[0x60000 / 2 + 4], state->m_unkram[0x60000 / 2 + 5]);*/
121   return 0;
122}
123
124static VIDEO_START( drill )
125{
126   _2mindril_state *state = machine.driver_data<_2mindril_state>();
127
128   machine.gfx[0]->color_granularity = 16;
129   gfx_element_set_source(machine.gfx[1], (UINT8 *)state->m_charram);
130}
131
13260static READ16_HANDLER( drill_io_r )
13361{
13462   _2mindril_state *state = space->machine().driver_data<_2mindril_state>();
r11160r11161
235163   }
236164}
237165
238static WRITE16_HANDLER( charram_w )
166static READ16_HANDLER( drill_irq_r )
239167{
240168   _2mindril_state *state = space->machine().driver_data<_2mindril_state>();
169   return state->irq_reg;
170}
241171
242   COMBINE_DATA(&state->m_charram[offset]);
243   gfx_element_mark_dirty(space->machine().gfx[1], offset / 16);
172static WRITE16_HANDLER( drill_irq_w )
173{
174   _2mindril_state *state = space->machine().driver_data<_2mindril_state>();
175   /*
176   (note: could rather be irq mask)
177   ---- ---- ---x ---- irq lv 5 ack, 0->1 latch
178   ---- ---- ---- x--- irq lv 4 ack, 0->1 latch
179   ---- ---- -??- -??? connected to the other levels?
180   */
181   if(((state->irq_reg & 8) == 0) && data & 8)
182      cputag_set_input_line(space->machine(), "maincpu", 4, CLEAR_LINE);
183
184   if(((state->irq_reg & 0x10) == 0) && data & 0x10)
185      cputag_set_input_line(space->machine(), "maincpu", 5, CLEAR_LINE);
186
187   if(data & 0xffe7)
188      printf("%04x\n",data);
189
190   COMBINE_DATA(&state->irq_reg);
244191}
245192
246193static ADDRESS_MAP_START( drill_map, AS_PROGRAM, 16 )
247194   AM_RANGE(0x000000, 0x07ffff) AM_ROM
248195   AM_RANGE(0x200000, 0x20ffff) AM_RAM
249196   AM_RANGE(0x300000, 0x3000ff) AM_RAM
250   AM_RANGE(0x410000, 0x411fff) AM_RAM AM_BASE_MEMBER(_2mindril_state, m_map1ram)
251   AM_RANGE(0x412000, 0x413fff) AM_RAM AM_BASE_MEMBER(_2mindril_state, m_map2ram)
252   AM_RANGE(0x414000, 0x415fff) AM_RAM AM_BASE_MEMBER(_2mindril_state, m_map3ram)
253   AM_RANGE(0x416000, 0x417fff) AM_RAM AM_BASE_MEMBER(_2mindril_state, m_map4ram)
254   AM_RANGE(0x41c000, 0x41dfff) AM_RAM AM_BASE_MEMBER(_2mindril_state, m_textram)
255   AM_RANGE(0x41e000, 0x41ffff) AM_RAM_WRITE(charram_w) AM_BASE_MEMBER(_2mindril_state, m_charram)
256   AM_RANGE(0x400000, 0x4fffff) AM_RAM AM_BASE_MEMBER(_2mindril_state, m_unkram)// video stuff, 460000 - video regs ?
197   AM_RANGE(0x400000, 0x40ffff) AM_READWRITE(f3_spriteram_r,f3_spriteram_w)
198   AM_RANGE(0x410000, 0x41bfff) AM_READWRITE(f3_pf_data_r,f3_pf_data_w)
199   AM_RANGE(0x41c000, 0x41dfff) AM_READWRITE(f3_videoram_r,f3_videoram_w)
200   AM_RANGE(0x41e000, 0x41ffff) AM_READWRITE(f3_vram_r,f3_vram_w)
201   AM_RANGE(0x420000, 0x42ffff) AM_READWRITE(f3_lineram_r,f3_lineram_w)
202   AM_RANGE(0x430000, 0x43ffff) AM_READWRITE(f3_pivot_r,f3_pivot_w)
203   AM_RANGE(0x460000, 0x46000f) AM_WRITE(f3_control_0_w)
204   AM_RANGE(0x460010, 0x46001f) AM_WRITE(f3_control_1_w)
257205   AM_RANGE(0x500000, 0x501fff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE_GENERIC(paletteram)
258   AM_RANGE(0x502000, 0x503fff) AM_RAM
206   AM_RANGE(0x502022, 0x502023) AM_WRITENOP //countinously switches between 0 and 2
259207   AM_RANGE(0x600000, 0x600007) AM_DEVREADWRITE8("ymsnd", ym2610_r, ym2610_w, 0x00ff)
260   AM_RANGE(0x60000c, 0x60000d) AM_RAM
261   AM_RANGE(0x60000e, 0x60000f) AM_RAM
208   AM_RANGE(0x60000c, 0x60000d) AM_READWRITE(drill_irq_r,drill_irq_w)
209   AM_RANGE(0x60000e, 0x60000f) AM_RAM // unknown purpose, zeroed at start-up and nothing else
262210   AM_RANGE(0x700000, 0x70000f) AM_READWRITE(drill_io_r,drill_io_w) AM_BASE_MEMBER(_2mindril_state, m_iodata) // i/o
263211   AM_RANGE(0x800000, 0x800001) AM_WRITE(sensors_w)
264212ADDRESS_MAP_END
r11160r11161
379327   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Select SW-4")
380328INPUT_PORTS_END
381329
382static const gfx_layout drill_layout =
330static const gfx_layout charlayout =
383331{
332   8,8,
333   256,
334   4,
335   { 0,1,2,3 },
336    { 20, 16, 28, 24, 4, 0, 12, 8 },
337   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
338   32*8
339};
340
341static const gfx_layout pivotlayout =
342{
343   8,8,
344   2048,
345   4,
346   { 0,1,2,3 },
347    { 20, 16, 28, 24, 4, 0, 12, 8 },
348   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
349   32*8
350};
351
352static const gfx_layout spriteram_layout =
353{
384354   16,16,
385355   RGN_FRAC(1,2),
386   6,
387   { RGN_FRAC(1,2)+1, RGN_FRAC(1,2)+0 ,0,1,2,3 },
388   { 20, 16, 28, 24, 4, 0, 12, 8,        52, 48, 60, 56, 36, 32, 44, 40 },
389   { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
390   16*64
356   6,   /* Palettes have 4 bpp indexes despite up to 6 bpp data */
357   { RGN_FRAC(1,2)+0, RGN_FRAC(1,2)+1, 0, 1, 2, 3 },
358   {
359   4, 0, 12, 8,
360   16+4, 16+0, 16+12, 16+8,
361   32+4, 32+0, 32+12, 32+8,
362   48+4, 48+0, 48+12, 48+8 },
363   { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
364         8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
365   128*8   /* every sprite takes 128 consecutive bytes */
391366};
392367
393static const gfx_layout vramlayout=
368static const gfx_layout tile_layout =
394369{
395    8,8,
396    256,
397    4,
398    { 0, 1, 2, 3 },
399    {20,16,28,24,4,0,12,8},
400     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
401    32*8
370   16,16,
371   RGN_FRAC(1,2),
372   6,   /* Palettes have 4 bpp indexes despite up to 6 bpp data */
373   { RGN_FRAC(1,2)+2, RGN_FRAC(1,2)+3, 0, 1, 2, 3 },
374   {
375   4, 0, 16+4, 16+0,
376    8+4, 8+0, 24+4, 24+0,
377   32+4, 32+0, 48+4, 48+0,
378    40+4, 40+0, 56+4, 56+0,
379   },
380   { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
381         8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
382   128*8   /* every sprite takes 128 consecutive bytes */
402383};
403384
404385static GFXDECODE_START( 2mindril )
405   GFXDECODE_ENTRY( "gfx1", 0, drill_layout,  0, 256  )
406   GFXDECODE_ENTRY( NULL,   0, vramlayout,    0, 256 )
386   GFXDECODE_ENTRY( NULL,   0x000000, charlayout,       0x0000, 0x0400>>4 ) /* Dynamically modified */
387   GFXDECODE_ENTRY( "gfx2", 0x000000, tile_layout,     0x0000, 0x2000>>4 ) /* Tiles area */
388   GFXDECODE_ENTRY( "gfx1", 0x000000, spriteram_layout, 0x1000, 0x1000>>4 ) /* Sprites area */
389   GFXDECODE_ENTRY( NULL,   0x000000, pivotlayout,      0x0000,  0x400>>4 ) /* Dynamically modified */
407390GFXDECODE_END
408391
409392
410static INTERRUPT_GEN( drill_interrupt )
393static INTERRUPT_GEN( drill_vblank_irq )
411394{
412   device_set_input_line(device, 4, HOLD_LINE);
395   device_set_input_line(device, 4, ASSERT_LINE);
413396}
414397
398#if 0
399static INTERRUPT_GEN( drill_device_irq )
400{
401   device_set_input_line(device, 5, ASSERT_LINE);
402}
403#endif
404
415405/* WRONG,it does something with 60000c & 700002,likely to be called when the player throws the ball.*/
416406static void irqhandler(device_t *device, int irq)
417407{
r11160r11161
441431
442432   state->m_defender_sensor = 0;
443433   state->m_shutter_sensor = 0;
434   state->irq_reg = 0;
444435}
445436
446437static MACHINE_CONFIG_START( drill, _2mindril_state )
447438
448439   MCFG_CPU_ADD("maincpu", M68000, 16000000 )
449440   MCFG_CPU_PROGRAM_MAP(drill_map)
450   MCFG_CPU_VBLANK_INT("screen", drill_interrupt)
441   MCFG_CPU_VBLANK_INT("screen", drill_vblank_irq)
442   //MCFG_CPU_PERIODIC_INT(drill_device_irq,60)
451443   MCFG_GFXDECODE(2mindril)
452444
453445   MCFG_MACHINE_START(drill)
r11160r11161
455447
456448   MCFG_SCREEN_ADD("screen", RASTER)
457449   MCFG_SCREEN_REFRESH_RATE(60)
458   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
459   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
460   MCFG_SCREEN_SIZE(128*16, 64*8)
461   MCFG_SCREEN_VISIBLE_AREA(0, 319, 0, 239-16)
462   MCFG_SCREEN_UPDATE(drill)
450   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* inaccurate, same as Taito F3? (needs screen raw params anyway) */
451   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
452   MCFG_SCREEN_SIZE(40*8+48*2, 32*8)
453   MCFG_SCREEN_VISIBLE_AREA(46, 40*8-1 + 46, 24, 24+224-1)
454   MCFG_SCREEN_UPDATE(f3)
455   MCFG_SCREEN_EOF(f3)
463456
464   MCFG_PALETTE_LENGTH(0x1000)
457   MCFG_PALETTE_LENGTH(0x2000)
465458
466   MCFG_VIDEO_START(drill)
459   MCFG_VIDEO_START(f3)
467460
468461   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
469462
470   MCFG_SOUND_ADD("ymsnd", YM2610, 16000000/2)
463   MCFG_SOUND_ADD("ymsnd", YM2610B, 16000000/2)
471464   MCFG_SOUND_CONFIG(ym2610_config)
472465   MCFG_SOUND_ROUTE(0, "lspeaker",  0.25)
473466   MCFG_SOUND_ROUTE(0, "rspeaker", 0.25)
r11160r11161
485478   ROM_LOAD( "d58-11.ic31", 0x000000, 0x200000,  CRC(dc26d58d) SHA1(cffb18667da18f5367b02af85a2f7674dd61ae97) )
486479
487480   ROM_REGION( 0x800000, "gfx1", ROMREGION_ERASE00 )
488   ROM_LOAD32_WORD( "d58-09.ic28", 0x000000, 0x200000, CRC(d8f6a86a) SHA1(d6b2ec309e21064574ee63e025ae4716b1982a98) )
489   ROM_LOAD32_WORD( "d58-08.ic27", 0x000002, 0x200000, CRC(9f5a3f52) SHA1(7b696bd823819965b974c853cebc1660750db61e) )
490481
491   ROM_REGION( 0x400000, "gfx2", 0 )
492   ROM_LOAD32_WORD( "d58-10.ic29", 0x000000, 0x200000, CRC(74c87e08) SHA1(f39b3a64f8338ccf5ca6eb76cee92a10fe0aad8f) )
482   ROM_REGION( 0x800000, "gfx2", 0 )
483   ROM_LOAD16_BYTE( "d58-09.ic28", 0x000001, 0x200000, CRC(d8f6a86a) SHA1(d6b2ec309e21064574ee63e025ae4716b1982a98) )
484   ROM_LOAD16_BYTE( "d58-08.ic27", 0x000000, 0x200000, CRC(9f5a3f52) SHA1(7b696bd823819965b974c853cebc1660750db61e) )
485   ROM_LOAD( "d58-10.ic29", 0x400000, 0x200000, CRC(74c87e08) SHA1(f39b3a64f8338ccf5ca6eb76cee92a10fe0aad8f) )
486   ROM_RELOAD(              0x600000, 0x200000 )
493487ROM_END
494488
495static DRIVER_INIT( drill )
489static void tile_decode(running_machine &machine)
496490{
497   // rearrange gfx roms to something we can decode, two of the roms form 4bpp of the graphics, the third forms another 2bpp but is in a different format
498   UINT32 *src = (UINT32*)machine.region( "gfx2" )->base();
499   UINT32 *dst = (UINT32*)machine.region( "gfx1" )->base();// + 0x400000;
500//  UINT8 *rom = machine.region( "maincpu" )->base();
501   int i;
491   UINT8 lsb,msb;
492   UINT32 offset,i;
493   UINT8 *gfx = machine.region("gfx2")->base();
494   int size=machine.region("gfx2")->bytes();
495   int data;
502496
503   for (i = 0; i < 0x400000 / 4; i++)
497   /* Setup ROM formats:
498
499        Some games will only use 4 or 5 bpp sprites, and some only use 4 bpp tiles,
500        I don't believe this is software or prom controlled but simply the unused data lines
501        are tied low on the game board if unused.  This is backed up by the fact the palette
502        indices are always related to 4 bpp data, even in 6 bpp games.
503
504        Most (all?) games with 5bpp tiles have the sixth bit set. Also, in Arabian Magic
505        sprites 1200-120f contain 6bpp data which is probably bogus.
506        VIDEO_START( f3 ) clears the fifth and sixth bit of the decoded graphics according
507        to the bit depth specified in f3_config_table.
508
509    */
510
511   offset = size/2;
512   for (i = size/2+size/4; i<size; i+=2)
504513   {
505      UINT32 dat1 = src[i];
506      dat1 = BITSWAP32(dat1, 3, 11, 19, 27, 2, 10, 18, 26, 1, 9, 17, 25, 0, 8, 16, 24, 7, 15, 23, 31, 6, 14, 22, 30, 5, 13, 21, 29, 4, 12, 20, 28 );
507      dst[(0x400000 / 4) + i] = dat1;
514      /* Expand 2bits into 4bits format */
515      lsb = gfx[i+1];
516      msb = gfx[i];
517
518      gfx[offset+0]=((msb&0x02)<<3) | ((msb&0x01)>>0) | ((lsb&0x02)<<4) | ((lsb&0x01)<<1);
519      gfx[offset+2]=((msb&0x08)<<1) | ((msb&0x04)>>2) | ((lsb&0x08)<<2) | ((lsb&0x04)>>1);
520      gfx[offset+1]=((msb&0x20)>>1) | ((msb&0x10)>>4) | ((lsb&0x20)<<0) | ((lsb&0x10)>>3);
521      gfx[offset+3]=((msb&0x80)>>3) | ((msb&0x40)>>6) | ((lsb&0x80)>>2) | ((lsb&0x40)>>5);
522
523      offset+=4;
508524   }
509525
510   //enable some kind of debug mode (ignore errors)
511//  rom[0x7fffb] = 0;
512//  rom[0x7fffc] = 0;
513//  rom[0x7fffd] = 0;
514//  rom[0x7fffe] = 0;
526   gfx = machine.region("gfx1")->base();
527   size=machine.region("gfx1")->bytes();
528
529   offset = size/2;
530   for (i = size/2+size/4; i<size; i++)
531   {
532      int d1,d2,d3,d4;
533
534      /* Expand 2bits into 4bits format */
535      data = gfx[i];
536      d1 = (data>>0) & 3;
537      d2 = (data>>2) & 3;
538      d3 = (data>>4) & 3;
539      d4 = (data>>6) & 3;
540
541      gfx[offset] = (d1<<2) | (d2<<6);
542      offset++;
543
544      gfx[offset] = (d3<<2) | (d4<<6);
545      offset++;
546   }
515547}
516548
549static DRIVER_INIT( drill )
550{
551   taito_f3_state *state = machine.driver_data<taito_f3_state>();
552   state->m_f3_game=TMDRILL;
553   tile_decode(machine);
554}
555
517556GAME( 1993, 2mindril,    0,        drill,    drill,    drill, ROT0,  "Taito", "Two Minute Drill", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE | GAME_MECHANICAL)
src/mame/drivers/corona.c
r11160r11161
299299
300300**************************************************************************/
301301
302#include "emu.h"
303#include "cpu/z80/z80.h"
304#include "sound/ay8910.h"
305#include "machine/nvram.h"
306#include "re800.lh"
307#include "luckyrlt.lh"
308
302309#define WC81_MAIN_XTAL      (XTAL_24MHz)      /* Main crystal for Winners Circle 28*28 pins PCB's */
303310#define WC82_MAIN_XTAL      (XTAL_18_432MHz)   /* Main crystal for Winners Circle 18*22 pins PCB's */
304311#define RE_MAIN_XTAL      (XTAL_16MHz)      /* Main for roulette boards */
r11160r11161
307314#define AY_CLK2            (2000000)         /* AY-3-8910 clock for 81b & 82 (18*22 PCB), guessed */
308315
309316
310#include "emu.h"
311#include "cpu/z80/z80.h"
312#include "sound/ay8910.h"
313#include "machine/nvram.h"
314#include "re800.lh"
315#include "luckyrlt.lh"
316
317317#define VIDEOBUF_SIZE 512*512
318318
319static UINT8 blitter_x_reg = 0;
320static UINT8 blitter_y_reg = 0;
321static UINT8 blitter_aux_reg = 0;
322static UINT8 blitter_unk_reg = 0;
323static UINT8 *videobuf;
324319
325static UINT8 lamp = 0;
326static UINT8 lamp_old = 0;
320class corona_state : public driver_device
321{
322public:
323   corona_state(running_machine &machine, const driver_device_config_base &config)
324      : driver_device(machine, config) { }
327325
326   UINT8 m_blitter_x_reg;
327   UINT8 m_blitter_y_reg;
328   UINT8 m_blitter_aux_reg;
329   UINT8 m_blitter_unk_reg;
330   UINT8 *m_videobuf;
331   UINT8 m_lamp;
332   UINT8 m_lamp_old;
333   int m_input_selector;
334};
328335
336
329337/*********************************************
330338*               Video Hardware               *
331339*********************************************/
r11160r11161
359367
360368static WRITE8_HANDLER( blitter_y_w )
361369{
362   blitter_y_reg = data;
370   corona_state *state = space->machine().driver_data<corona_state>();
371   state->m_blitter_y_reg = data;
363372}
364373
365374static WRITE8_HANDLER( blitter_unk_w )
366375{
367   blitter_unk_reg = data;
376   corona_state *state = space->machine().driver_data<corona_state>();
377   state->m_blitter_unk_reg = data;
368378}
369379
370380static WRITE8_HANDLER( blitter_x_w )
371381{
372   blitter_x_reg = data;
382   corona_state *state = space->machine().driver_data<corona_state>();
383   state->m_blitter_x_reg = data;
373384}
374385
375386static WRITE8_HANDLER( blitter_aux_w )
376387{
377   blitter_aux_reg = data;
388   corona_state *state = space->machine().driver_data<corona_state>();
389   state->m_blitter_aux_reg = data;
378390}
379391
380392static READ8_HANDLER( blitter_status_r )
r11160r11161
389401   return 0x80 | ((space->machine().primary_screen->vblank() & 1) << 6);
390402}
391403
392static void blitter_execute(int x, int y, int color, int width, int flag)
404static void blitter_execute(corona_state *state, int x, int y, int color, int width, int flag)
393405{
394406   int i;
395407   int xdir = (flag & 0x10)    ? -1 : 1;
r11160r11161
407419
408420      for(yp = 0; yp < 0x100; yp++)
409421         for(xp = 0; xp < 0x100; xp++)
410            videobuf[(yp & 0x1ff) * 512 + (xp & 0x1ff)] = color;
422            state->m_videobuf[(yp & 0x1ff) * 512 + (xp & 0x1ff)] = color;
411423   }
412424   else /* line shape */
413425   {
r11160r11161
415427
416428      for(i = 0; i < width; i++)
417429      {
418         videobuf[(y & 0x1ff) * 512 + (x & 0x1ff)] = color;
430         state->m_videobuf[(y & 0x1ff) * 512 + (x & 0x1ff)] = color;
419431
420432         if(flag & 0x40) { x+=xdir; }
421433         if(flag & 0x80) { y+=ydir; }
r11160r11161
425437
426438static WRITE8_HANDLER( blitter_trig_wdht_w)
427439{
428   blitter_execute(blitter_x_reg, 0x100 - blitter_y_reg, blitter_aux_reg & 0xf, data, blitter_aux_reg & 0xf0);
440   corona_state *state = space->machine().driver_data<corona_state>();
441   blitter_execute(state, state->m_blitter_x_reg, 0x100 - state->m_blitter_y_reg, state->m_blitter_aux_reg & 0xf, data, state->m_blitter_aux_reg & 0xf0);
429442}
430443
431444static VIDEO_START(winner)
432445{
433   videobuf = auto_alloc_array_clear(machine, UINT8, VIDEOBUF_SIZE);
446   corona_state *state = machine.driver_data<corona_state>();
447   state->m_videobuf = auto_alloc_array_clear(machine, UINT8, VIDEOBUF_SIZE);
434448}
435449
436450static SCREEN_UPDATE(winner)
437451{
452   corona_state *state = screen->machine().driver_data<corona_state>();
438453   int x, y;
439454
440455   for (y = 0; y < 256; y++)
441456      for (x = 0; x < 256; x++)
442         *BITMAP_ADDR16(bitmap, y, x) = videobuf[y * 512 + x];
457         *BITMAP_ADDR16(bitmap, y, x) = state->m_videobuf[y * 512 + x];
443458
444459   return 0;
445460}
446461
447462static SCREEN_UPDATE(luckyrlt)
448463{
464   corona_state *state = screen->machine().driver_data<corona_state>();
449465   int x, y;
450466
451467   for (y = 0; y < 256; y++)
452468      for (x = 0; x < 256; x++)
453         *BITMAP_ADDR16(bitmap, 255 - y, x) = videobuf[y * 512 + x];
469         *BITMAP_ADDR16(bitmap, 255 - y, x) = state->m_videobuf[y * 512 + x];
454470
455471   return 0;
456472}
r11160r11161
475491
476492static WRITE8_HANDLER( ball_w )
477493{
478   lamp = data;
494   corona_state *state = space->machine().driver_data<corona_state>();
495   state->m_lamp = data;
479496
480497   output_set_lamp_value(data, 1);
481   output_set_lamp_value(lamp_old, 0);
482   lamp_old = lamp;
498   output_set_lamp_value(state->m_lamp_old, 0);
499   state->m_lamp_old = state->m_lamp;
483500}
484501
485502
486503/********  Multiplexed Inputs  ********/
487504
488static int input_selector = 0;
489505
490506static READ8_HANDLER( mux_port_r )
491507{
492   switch( input_selector )
508   corona_state *state = space->machine().driver_data<corona_state>();
509   switch( state->m_input_selector )
493510   {
494511      case 0x01: return input_port_read(space->machine(), "IN0-1");
495512      case 0x02: return input_port_read(space->machine(), "IN0-2");
r11160r11161
504521
505522static WRITE8_HANDLER( mux_port_w )
506523{
524   corona_state *state = space->machine().driver_data<corona_state>();
507525/*  - bits -
508526    7654 3210
509527    --xx xxxx   Input selector.
r11160r11161
513531   Data is written inverted.
514532
515533*/
516   input_selector = (data ^ 0xff) & 0x3f;   /* Input Selector,  */
534   state->m_input_selector = (data ^ 0xff) & 0x3f;   /* Input Selector,  */
517535
518536   coin_counter_w(space->machine(), 0, (data ^ 0xff) & 0x40);   /* Credits In (mechanical meters) */
519537   coin_counter_w(space->machine(), 1, (data ^ 0xff) & 0x80);   /* Credits Out (mechanical meters) */
520538
521//  logerror("muxsel: %02x \n", input_selector);
539//  logerror("muxsel: %02x \n", state->m_input_selector);
522540}
523541
524542static WRITE8_HANDLER( wc_meters_w )
r11160r11161
13261344*             Machine Drivers              *
13271345*******************************************/
13281346
1329static MACHINE_CONFIG_START( winner81, driver_device )
1347static MACHINE_CONFIG_START( winner81, corona_state )
13301348   /* basic machine hardware */
13311349   MCFG_CPU_ADD("maincpu", Z80, WC81_MAIN_XTAL/8)   /* measured */
13321350   MCFG_CPU_PROGRAM_MAP(winner81_map)
r11160r11161
13611379   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
13621380MACHINE_CONFIG_END
13631381
1364static MACHINE_CONFIG_START( winner82, driver_device )
1382static MACHINE_CONFIG_START( winner82, corona_state )
13651383   /* basic machine hardware */
13661384   MCFG_CPU_ADD("maincpu", Z80, WC82_MAIN_XTAL/8)   /* measured */
13671385   MCFG_CPU_PROGRAM_MAP(winner82_map)
r11160r11161
13941412   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
13951413MACHINE_CONFIG_END
13961414
1397static MACHINE_CONFIG_START( re800, driver_device )
1415static MACHINE_CONFIG_START( re800, corona_state )
13981416   /* basic machine hardware */
13991417   MCFG_CPU_ADD("maincpu", Z80, RE_MAIN_XTAL/8)   /* measured 2MHz */
14001418   MCFG_CPU_PROGRAM_MAP(re800_map)
r11160r11161
14281446   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
14291447MACHINE_CONFIG_END
14301448
1431static MACHINE_CONFIG_START( rcirulet, driver_device )
1449static MACHINE_CONFIG_START( rcirulet, corona_state )
14321450   /* basic machine hardware */
14331451   MCFG_CPU_ADD("maincpu", Z80, RE_MAIN_XTAL/8)   /* measured 2MHz */
14341452   MCFG_CPU_PROGRAM_MAP(re800_map)
r11160r11161
14611479   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
14621480MACHINE_CONFIG_END
14631481
1464static MACHINE_CONFIG_START( luckyrlt, driver_device )
1482static MACHINE_CONFIG_START( luckyrlt, corona_state )
14651483   /* basic machine hardware */
14661484   MCFG_CPU_ADD("maincpu", Z80, RE_MAIN_XTAL/8)   /* measured 2MHz */
14671485   MCFG_CPU_PROGRAM_MAP(luckyrlt_map)
src/mame/drivers/taitowlf.c
r11160r11161
562562static IRQ_CALLBACK(irq_callback)
563563{
564564   taitowlf_state *state = device->machine().driver_data<taitowlf_state>();
565   int r = pic8259_acknowledge( state->m_pic8259_2);
566   if (r==0)
567   {
568      r = pic8259_acknowledge( state->m_pic8259_1);
569   }
570   return r;
565   return pic8259_acknowledge( state->m_pic8259_1);
571566}
572567
573568static MACHINE_START(taitowlf)
r11160r11161
599594   cputag_set_input_line(device->machine(), "maincpu", 0, state ? HOLD_LINE : CLEAR_LINE);
600595}
601596
597static READ8_DEVICE_HANDLER( get_slave_ack )
598{
599   taitowlf_state *state = device->machine().driver_data<taitowlf_state>();
600   if (offset==2) { // IRQ = 2
601      return pic8259_acknowledge(state->m_pic8259_2);
602   }
603   return 0x00;
604}
605
602606static const struct pic8259_interface taitowlf_pic8259_1_config =
603607{
604   DEVCB_LINE(taitowlf_pic8259_1_set_int_line)
608   DEVCB_LINE(taitowlf_pic8259_1_set_int_line),
609   DEVCB_LINE_VCC,
610   DEVCB_HANDLER(get_slave_ack)
605611};
606612
607613static const struct pic8259_interface taitowlf_pic8259_2_config =
608614{
609   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w)
615   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w),
616   DEVCB_LINE_GND,
617   DEVCB_NULL
610618};
611619
612620
src/mame/drivers/metalmx.c
r11160r11161
351351   UINT32 result = 0;
352352
353353   if (ACCESSING_BITS_0_15)
354      result |= cage_control_r();
354      result |= cage_control_r(space->machine());
355355   if (ACCESSING_BITS_16_31)
356      result |= main_from_cage_r(space) << 16;
356      result |= cage_main_r(space) << 16;
357357   return result;
358358}
359359
r11160r11161
362362   if (ACCESSING_BITS_0_15)
363363      cage_control_w(space->machine(), data);
364364   if (ACCESSING_BITS_16_31)
365      main_to_cage_w(data >> 16);
365      cage_main_w(space, data >> 16);
366366}
367367
368368static void cage_irq_callback(running_machine &machine, int reason)
src/mame/drivers/klax.c
r11160r11161
1919
2020#include "emu.h"
2121#include "cpu/m68000/m68000.h"
22#include "sound/okim6295.h"
23#include "video/atarimo.h"
2224#include "includes/klax.h"
23#include "sound/okim6295.h"
2425
2526
2627
r11160r11161
9394   AM_RANGE(0x360000, 0x360001) AM_WRITE(interrupt_ack_w)
9495   AM_RANGE(0x3e0000, 0x3e07ff) AM_RAM_WRITE(atarigen_expanded_666_paletteram_w) AM_BASE_GENERIC(paletteram)
9596   AM_RANGE(0x3f0000, 0x3f0f7f) AM_RAM_WRITE(atarigen_playfield_w) AM_BASE_MEMBER(klax_state, m_playfield)
96   AM_RANGE(0x3f0f80, 0x3f0fff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
97   AM_RANGE(0x3f0f80, 0x3f0fff) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
9798   AM_RANGE(0x3f1000, 0x3f1fff) AM_RAM_WRITE(atarigen_playfield_upper_w) AM_BASE_MEMBER(klax_state, m_playfield_upper)
98   AM_RANGE(0x3f2000, 0x3f27ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
99   AM_RANGE(0x3f2000, 0x3f27ff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
99100   AM_RANGE(0x3f2800, 0x3f3fff) AM_RAM
100101ADDRESS_MAP_END
101102
src/mame/drivers/thunderj.c
r11160r11161
2121#include "cpu/m68000/m68000.h"
2222#include "machine/atarigen.h"
2323#include "audio/atarijsa.h"
24#include "video/atarimo.h"
2425#include "includes/thunderj.h"
2526
2627
r11160r11161
168169   AM_RANGE(0x3f0000, 0x3f1fff) AM_RAM_WRITE(atarigen_playfield2_latched_msb_w) AM_BASE_MEMBER(thunderj_state, m_playfield2)
169170   AM_RANGE(0x3f2000, 0x3f3fff) AM_RAM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE_MEMBER(thunderj_state, m_playfield)
170171   AM_RANGE(0x3f4000, 0x3f5fff) AM_RAM_WRITE(atarigen_playfield_dual_upper_w) AM_BASE_MEMBER(thunderj_state, m_playfield_upper)
171   AM_RANGE(0x3f6000, 0x3f7fff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
172   AM_RANGE(0x3f6000, 0x3f7fff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
172173   AM_RANGE(0x3f8000, 0x3f8eff) AM_RAM_WRITE(atarigen_alpha_w) AM_BASE_MEMBER(thunderj_state, m_alpha)
173174   AM_RANGE(0x3f8f00, 0x3f8f7f) AM_RAM AM_BASE_MEMBER(thunderj_state, m_atarivc_eof_data)
174   AM_RANGE(0x3f8f80, 0x3f8fff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
175   AM_RANGE(0x3f8f80, 0x3f8fff) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
175176   AM_RANGE(0x3f9000, 0x3fffff) AM_RAM
176177ADDRESS_MAP_END
177178
src/mame/drivers/sandscrp.c
r11160r11161
8080#include "video/kan_pand.h"
8181
8282
83class sandscrp_state : public driver_device
83class sandscrp_state : public kaneko16_state
8484{
8585public:
8686   sandscrp_state(running_machine &machine, const driver_device_config_base &config)
87      : driver_device(machine, config) { }
87      : kaneko16_state(machine, config) { }
8888
8989   UINT8 m_sprite_irq;
9090   UINT8 m_unknown_irq;
r11160r11161
9696
9797static MACHINE_RESET( sandscrp )
9898{
99   kaneko16_sprite_type  = 0;
99   sandscrp_state *state = machine.driver_data<sandscrp_state>();
100   state->m_sprite_type  = 0;
100101
101   kaneko16_sprite_xoffs = 0;
102   kaneko16_sprite_yoffs = 0;
102   state->m_sprite_xoffs = 0;
103   state->m_sprite_yoffs = 0;
103104
104   kaneko16_priority.sprite[0] = 1;   // above tile[0],   below the others
105   kaneko16_priority.sprite[1] = 2;   // above tile[0-1], below the others
106   kaneko16_priority.sprite[2] = 3;   // above tile[0-2], below the others
107   kaneko16_priority.sprite[3] = 8;   // above all
108   kaneko16_sprite_type = 3;   // "different" sprites layout
105   state->m_priority.sprite[0] = 1;   // above tile[0],   below the others
106   state->m_priority.sprite[1] = 2;   // above tile[0-1], below the others
107   state->m_priority.sprite[2] = 3;   // above tile[0-2], below the others
108   state->m_priority.sprite[3] = 8;   // above all
109   state->m_sprite_type = 3;   // "different" sprites layout
109110}
110111
111112/* Sand Scorpion */
r11160r11161
158159   sandscrp_state *state = space->machine().driver_data<sandscrp_state>();
159160   if (ACCESSING_BITS_0_7)
160161   {
161      kaneko16_sprite_flipx   =   data & 1;
162      kaneko16_sprite_flipy   =   data & 1;
162      state->m_sprite_flipx   =   data & 1;
163      state->m_sprite_flipy   =   data & 1;
163164
164165      if (data & 0x08)   state->m_sprite_irq  = 0;
165166      if (data & 0x10)   state->m_unknown_irq = 0;
r11160r11161
227228
228229   AM_RANGE(0x700000, 0x70ffff) AM_RAM      // RAM
229230   AM_RANGE(0x200000, 0x20001f) AM_READWRITE(galpanib_calc_r,galpanib_calc_w)   // Protection
230   AM_RANGE(0x300000, 0x30000f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
231   AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE(&kaneko16_vram_1)   // Layers 0
232   AM_RANGE(0x401000, 0x401fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE(&kaneko16_vram_0)   //
233   AM_RANGE(0x402000, 0x402fff) AM_RAM AM_BASE(&kaneko16_vscroll_1)                           //
234   AM_RANGE(0x403000, 0x403fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)                           //
231   AM_RANGE(0x300000, 0x30000f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(sandscrp_state, m_layers_0_regs)   // Layers 0 Regs
232   AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(sandscrp_state, m_vram[1])   // Layers 0
233   AM_RANGE(0x401000, 0x401fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(sandscrp_state, m_vram[0])   //
234   AM_RANGE(0x402000, 0x402fff) AM_RAM AM_BASE_MEMBER(sandscrp_state, m_vscroll[1])                           //
235   AM_RANGE(0x403000, 0x403fff) AM_RAM AM_BASE_MEMBER(sandscrp_state, m_vscroll[0])                           //
235236   AM_RANGE(0x500000, 0x501fff) AM_DEVREADWRITE("pandora", pandora_spriteram_LSB_r, pandora_spriteram_LSB_w ) // sprites
236237   AM_RANGE(0x600000, 0x600fff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram)   // Palette
237238   AM_RANGE(0xa00000, 0xa00001) AM_WRITE(sandscrp_coin_counter_w)   // Coin Counters (Lockout unused)
src/mame/drivers/gamecstl.c
r11160r11161
603603static IRQ_CALLBACK(irq_callback)
604604{
605605   gamecstl_state *state = device->machine().driver_data<gamecstl_state>();
606   int r = 0;
607   r = pic8259_acknowledge(state->m_pic8259_2);
608   if (r==0)
609   {
610      r = pic8259_acknowledge(state->m_pic8259_1);
611   }
612   return r;
606   return pic8259_acknowledge(state->m_pic8259_1);
613607}
614608
615609static MACHINE_START(gamecstl)
r11160r11161
641635   cputag_set_input_line(device->machine(), "maincpu", 0, state ? HOLD_LINE : CLEAR_LINE);
642636}
643637
638static READ8_DEVICE_HANDLER( get_slave_ack )
639{
640   gamecstl_state *state = device->machine().driver_data<gamecstl_state>();
641   if (offset==2) { // IRQ = 2
642      return pic8259_acknowledge(state->m_pic8259_2);
643   }
644   return 0x00;
645}
646
644647static const struct pic8259_interface gamecstl_pic8259_1_config =
645648{
646   DEVCB_LINE(gamecstl_pic8259_1_set_int_line)
649   DEVCB_LINE(gamecstl_pic8259_1_set_int_line),
650   DEVCB_LINE_VCC,
651   DEVCB_HANDLER(get_slave_ack)
647652};
648653
649654static const struct pic8259_interface gamecstl_pic8259_2_config =
650655{
651   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w)
656   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w),
657   DEVCB_LINE_GND,
658   DEVCB_NULL
652659};
653660
654661
src/mame/drivers/nwk-tr.c
r11160r11161
770770   ROM_LOAD( "m48t58y-70pc1", 0x000000, 0x002000, CRC(47e1628c) SHA1(7c42d06ae2f2cd24d083890f333552cbf4f1d3c9) )
771771ROM_END
772772
773ROM_START(racingj2)
773ROM_START(racingj2j)
774774   ROM_REGION32_BE(0x200000, "user1", 0)   /* PowerPC program roms */
775775   ROM_LOAD16_WORD_SWAP("888a01.27p", 0x000000, 0x200000, CRC(d077890a) SHA1(08b252324cf46fbcdb95e8f9312287920cd87c5d) )
776776
r11160r11161
794794   ROM_LOAD( "m48t58y-70pc1", 0x000000, 0x002000, CRC(f691f5ab) SHA1(e81f652c5caa2caa8bd1c6d6db488d849bda058e) )
795795ROM_END
796796
797ROM_START(racingj2)
798   ROM_REGION32_BE(0x200000, "user1", 0)   /* PowerPC program roms */
799   ROM_LOAD16_WORD_SWAP("888a01.27p", 0x000000, 0x200000, CRC(d077890a) SHA1(08b252324cf46fbcdb95e8f9312287920cd87c5d) )
800
801   ROM_REGION32_BE(0x800000, "user2", 0)      /* Data roms */
802   ROM_LOAD32_WORD_SWAP( "676a04.bin",   0x000000, 0x200000, CRC(d7808cb6) SHA1(0668fae5bb94cc120fe196d4b18200f7b512317f) )
803   ROM_LOAD32_WORD_SWAP( "676a05.bin",   0x000002, 0x200000, CRC(fb4de1ad) SHA1(f6aa4eb1b5d22901a2aaf899ed3237a9dfdc55b5) )
804   ROM_LOAD32_WORD_SWAP( "888a06.12t",   0x400000, 0x200000, CRC(00cbec4d) SHA1(1ce7807d86e90edbf4eecba462a27c725f5ad862) )
805
806   ROM_REGION32_BE(0x800000, "user5", 0)   /* CG Board Texture roms */
807   ROM_LOAD32_WORD_SWAP( "888a13.8x",    0x000000, 0x400000, CRC(2292f530) SHA1(0f4d1332708fd5366a065e0a928cc9610558b42d) )
808   ROM_LOAD32_WORD_SWAP( "888a14.16x",   0x000002, 0x400000, CRC(6a834a26) SHA1(d1fbd7ae6afd05f0edac4efde12a5a45aa2bc7df) )
809
810   ROM_REGION(0x80000, "audiocpu", 0)      /* 68k program roms */
811   ROM_LOAD16_WORD_SWAP( "888a08.7s",    0x000000, 0x080000, CRC(55fbea65) SHA1(ad953f758181731efccadcabc4326e6634c359e8) )
812
813   ROM_REGION(0x1000000, "rfsnd", 0)      /* PCM sample roms */
814   ROM_LOAD( "888a09.16p",   0x000000, 0x400000, CRC(11e2fed2) SHA1(24b8a367b59fedb62c56f066342f2fa87b135fc5) )
815   ROM_LOAD( "888a10.14p",   0x400000, 0x400000, CRC(328ce610) SHA1(dbbc779a1890c53298c0db129d496df048929496) )
816
817   ROM_REGION(0x2000, "m48t58",0)
818   ROM_LOAD( "m48t58y-70pc1.35d", 0x000000, 0x002000, CRC(1aa43a1f) SHA1(814b691b8a358bf1545a13d595d17070e612e9a4) )
819ROM_END
820
797821ROM_START(thrilld)
798822   ROM_REGION32_BE(0x200000, "user1", 0)   /* PowerPC program roms */
799823   ROM_LOAD16_WORD_SWAP("713be01.27p", 0x000000, 0x200000, CRC(d84a7723) SHA1(f4e9e08591b7e5e8419266dbe744d56a185384ed) )
r11160r11161
840864   ROM_LOAD( "m48t58y-70pc1", 0x000000, 0x002000, CRC(5d8fbcb2) SHA1(74ad91544d2a200cf599a565005476623075e7d6) )
841865ROM_END
842866
867ROM_START(thrilldae)
868   ROM_REGION32_BE(0x200000, "user1", 0)   /* PowerPC program roms */
869   ROM_LOAD16_WORD_SWAP("713bb01.27p", 0x000000, 0x200000, CRC(535fe4e8) SHA1(acd8194a4dafce289dbdfd874f0b799f25aeb73f) )
870
871   ROM_REGION32_BE(0x800000, "user2", 0)      /* Data roms */
872   ROM_LOAD32_WORD_SWAP("713a04.16t", 0x000000, 0x200000, CRC(c994aaa8) SHA1(d82b9930a11e5384ad583684a27c95beec03cd5a) )
873   ROM_LOAD32_WORD_SWAP("713a05.14t", 0x000002, 0x200000, CRC(6f1e6802) SHA1(91f8a170327e9b4ee6a64aee0c106b981a317e69) )
874
875   ROM_REGION32_BE(0x800000, "user5", 0)   /* CG Board Texture roms */
876   ROM_LOAD32_WORD_SWAP( "713a13.8x",    0x000000, 0x400000, CRC(b795c66b) SHA1(6e50de0d5cc444ffaa0fec7ada8c07f643374bb2) )
877   ROM_LOAD32_WORD_SWAP( "713a14.16x",   0x000002, 0x400000, CRC(5275a629) SHA1(16fadef06975f0f3625cac8f84e2e77ed7d75e15) )
878
879   ROM_REGION(0x80000, "audiocpu", 0)      /* 68k program roms */
880   ROM_LOAD16_WORD_SWAP( "713a08.7s",    0x000000, 0x080000, CRC(6a72a825) SHA1(abeac99c5343efacabcb0cdff6d34f9f967024db) )
881
882   ROM_REGION(0x1000000, "rfsnd", 0)      /* PCM sample roms */
883   ROM_LOAD( "713a09.16p",   0x000000, 0x400000, CRC(058f250a) SHA1(63b8e60004ec49009633e86b4992c00083def9a8) )
884   ROM_LOAD( "713a10.14p",   0x400000, 0x400000, CRC(27f9833e) SHA1(1540f00d2571ecb81b914c553682b67fca94bbbd) )
885
886   ROM_REGION(0x2000, "m48t58",0)
887   ROM_LOAD( "m48t58y-70pc1", 0x000000, 0x002000, CRC(056ea8fa) SHA1(23574e0c1d011dab8644f3d98763d4a2d11a05b3)  )
888ROM_END
889
843890/*****************************************************************************/
844891
845GAME( 1998, racingj,    0,       nwktr,   nwktr, nwktr, ROT0, "Konami", "Racing Jam", GAME_NOT_WORKING | GAME_NO_SOUND )
846GAME( 1999, racingj2,   racingj, nwktr,   nwktr, nwktr, ROT0, "Konami", "Racing Jam: Chapter 2", GAME_NOT_WORKING | GAME_NO_SOUND )
892GAME( 1998, racingj,    0,       nwktr,   nwktr, nwktr, ROT0, "Konami", "Racing Jam (JAC)", GAME_NOT_WORKING | GAME_NO_SOUND )
893GAME( 1999, racingj2,   racingj, nwktr,   nwktr, nwktr, ROT0, "Konami", "Racing Jam: Chapter 2 (EAE)", GAME_NOT_WORKING | GAME_NO_SOUND )
894GAME( 1999, racingj2j,  racingj, nwktr,   nwktr, nwktr, ROT0, "Konami", "Racing Jam: Chapter 2 (JAE)", GAME_NOT_WORKING | GAME_NO_SOUND )
847895GAME( 1998, thrilld,    0,       thrilld, nwktr, nwktr, ROT0, "Konami", "Thrill Drive (JAE)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND )
848896GAME( 1998, thrilldb,   thrilld, thrilld, nwktr, nwktr, ROT0, "Konami", "Thrill Drive (JAB)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND )
897GAME( 1998, thrilldae,  thrilld, thrilld, nwktr, nwktr, ROT0, "Konami", "Thrill Drive (EAA)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND )
898
src/mame/drivers/relief.c
r11160r11161
2020#include "emu.h"
2121#include "cpu/m68000/m68000.h"
2222#include "machine/atarigen.h"
23#include "includes/relief.h"
2423#include "sound/okim6295.h"
2524#include "sound/2413intf.h"
25#include "video/atarimo.h"
26#include "includes/relief.h"
2627
2728
2829/*************************************
r11160r11161
165166   AM_RANGE(0x3f0000, 0x3f1fff) AM_RAM_WRITE(atarigen_playfield2_latched_msb_w) AM_BASE_MEMBER(relief_state, m_playfield2)
166167   AM_RANGE(0x3f2000, 0x3f3fff) AM_RAM_WRITE(atarigen_playfield_latched_lsb_w) AM_BASE_MEMBER(relief_state, m_playfield)
167168   AM_RANGE(0x3f4000, 0x3f5fff) AM_RAM_WRITE(atarigen_playfield_dual_upper_w) AM_BASE_MEMBER(relief_state, m_playfield_upper)
168   AM_RANGE(0x3f6000, 0x3f67ff) AM_RAM_WRITE(atarimo_0_spriteram_w) AM_BASE(&atarimo_0_spriteram)
169   AM_RANGE(0x3f6000, 0x3f67ff) AM_READWRITE(atarimo_0_spriteram_r, atarimo_0_spriteram_w)
169170   AM_RANGE(0x3f6800, 0x3f8eff) AM_RAM
170171   AM_RANGE(0x3f8f00, 0x3f8f7f) AM_RAM AM_BASE_MEMBER(relief_state, m_atarivc_eof_data)
171   AM_RANGE(0x3f8f80, 0x3f8fff) AM_RAM_WRITE(atarimo_0_slipram_w) AM_BASE(&atarimo_0_slipram)
172   AM_RANGE(0x3f8f80, 0x3f8fff) AM_READWRITE(atarimo_0_slipram_r, atarimo_0_slipram_w)
172173   AM_RANGE(0x3f9000, 0x3fffff) AM_RAM
173174ADDRESS_MAP_END
174175
src/mame/drivers/taito_f3.c
r11160r11161
1212
1313    Other Issues:
1414    - Dsp isn't hooked up.
15    - Crowd/boards not shown in the football games
15    - Various hacks in video core that needs squashing;
1616    - Sound doesn't work in RidingF/RingRage?
1717      (for RingRage it's probably a timing / cpu sync bug, if you go into test mode
1818       for a while then exit you'll have sound, this doesn't work on RidingF)
19    - It does work in ringrage but you have to enter test mode first
19      \- It does work in ringrage but you have to enter test mode first
2020    - Sound balance is not emulated (see arabianm test mode)
2121    - When playing space invaders dx in original mode, t.t. with overlay, the
22    alpha blending effect is wrong (see Taito B version of game)
22      alpha blending effect is wrong (see Taito B version of game)
2323    - Bubble Symphony has an alpha transition effect that doesn't appear in Mame
2424    - Various other missing blending effects (see Mametesters)
25    - Find how this HW drives the CRTC, and convert video timings to use screen raw params;
2526
2627    Feel free to report any other issues to me.
2728
r11160r11161
147148   }
148149}
149150
151static WRITE16_HANDLER( f3_unk_w )
152{
153   /*
154   Several games writes a value here at POST, dunno what kind of config this is ...
155   ringrage:  0x0000
156   arabianm:  0x0000
157   ridingf: (no init)
158   gseeker: (no init)
159   commandw:(no init)
160   cupfinal:  0x0100
161   trstar:  (no init)
162   gunlock:   0x0000
163   scfinals:  0x0100
164   lightbr: (no init)
165   intcup94:  0x0100
166   kaiserkn:  0x0100
167   dariusg:   0x278b
168   bublbob2:(no init)
169   pwrgoal:   0x0100
170   qtheater:  0x0090
171   elvactr:   0x278b
172   recalh:    0x0090
173   spcinv95:  0x0100
174   twinqix: (no init)
175   quizhuhu:  0x0000
176   pbobble2:  0x278b
177   gekiridn:  0x278b
178   tcobra2:   0x0000
179   bubblem: (no init)
180   cleopatr:  0x0100
181   pbobble3:  0x278b
182   arkretn:   0x0000
183   kirameki:  0x0100
184   puchicar:  0x0000
185   pbobble4:  0x278b
186   popnpop:   0x0000
187   landmakr:  0x278b
188   */
189   if(offset == 0)
190      logerror("0x4c0000 write %04x\n",data);
191   else
192      popmessage("0x4c0002 write %04x, contact MAMEdev",data); //shouldn't happen
193}
194
150195/******************************************************************************/
151196
152197static ADDRESS_MAP_START( f3_map, AS_PROGRAM, 32 )
r11160r11161
155200   AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x20000) AM_RAM AM_BASE_MEMBER(taito_f3_state, m_f3_ram)
156201   AM_RANGE(0x440000, 0x447fff) AM_RAM_WRITE(f3_palette_24bit_w) AM_BASE_GENERIC(paletteram)
157202   AM_RANGE(0x4a0000, 0x4a001f) AM_READWRITE(f3_control_r,  f3_control_w)
158   AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE_SIZE_MEMBER(taito_f3_state, m_spriteram, m_spriteram_size)
159   AM_RANGE(0x610000, 0x61bfff) AM_RAM_WRITE(f3_pf_data_w) AM_BASE_MEMBER(taito_f3_state, m_f3_pf_data)
160   AM_RANGE(0x61c000, 0x61dfff) AM_RAM_WRITE(f3_videoram_w) AM_BASE_MEMBER(taito_f3_state, m_videoram)
161   AM_RANGE(0x61e000, 0x61ffff) AM_RAM_WRITE(f3_vram_w) AM_BASE_MEMBER(taito_f3_state, m_f3_vram)
162   AM_RANGE(0x620000, 0x62ffff) AM_RAM_WRITE(f3_lineram_w) AM_BASE_MEMBER(taito_f3_state, m_f3_line_ram)
163   AM_RANGE(0x630000, 0x63ffff) AM_RAM_WRITE(f3_pivot_w) AM_BASE_MEMBER(taito_f3_state, m_f3_pivot_ram)
164   AM_RANGE(0x660000, 0x66000f) AM_WRITE(f3_control_0_w)
165   AM_RANGE(0x660010, 0x66001f) AM_WRITE(f3_control_1_w)
203   AM_RANGE(0x4c0000, 0x4c0003) AM_WRITE16(f3_unk_w,0xffffffff)
204   AM_RANGE(0x600000, 0x60ffff) AM_READWRITE16(f3_spriteram_r,f3_spriteram_w,0xffffffff) //AM_BASE_SIZE_MEMBER(taito_f3_state, m_spriteram, m_spriteram_size)
205   AM_RANGE(0x610000, 0x61bfff) AM_READWRITE16(f3_pf_data_r,f3_pf_data_w,0xffffffff)       //AM_BASE_MEMBER(taito_f3_state, m_f3_pf_data)
206   AM_RANGE(0x61c000, 0x61dfff) AM_READWRITE16(f3_videoram_r,f3_videoram_w,0xffffffff)      //AM_BASE_MEMBER(taito_f3_state, m_videoram)
207   AM_RANGE(0x61e000, 0x61ffff) AM_READWRITE16(f3_vram_r,f3_vram_w,0xffffffff)          //AM_BASE_MEMBER(taito_f3_state, m_f3_vram)
208   AM_RANGE(0x620000, 0x62ffff) AM_READWRITE16(f3_lineram_r,f3_lineram_w,0xffffffff)      //AM_BASE_MEMBER(taito_f3_state, m_f3_line_ram)
209   AM_RANGE(0x630000, 0x63ffff) AM_READWRITE16(f3_pivot_r,f3_pivot_w,0xffffffff)          //AM_BASE_MEMBER(taito_f3_state, m_f3_pivot_ram)
210   AM_RANGE(0x660000, 0x66000f) AM_WRITE16(f3_control_0_w,0xffffffff)
211   AM_RANGE(0x660010, 0x66001f) AM_WRITE16(f3_control_1_w,0xffffffff)
166212   AM_RANGE(0xc00000, 0xc007ff) AM_RAM AM_SHARE("f3_shared")
167213   AM_RANGE(0xc80000, 0xc80003) AM_WRITE(f3_sound_reset_0_w)
168214   AM_RANGE(0xc80100, 0xc80103) AM_WRITE(f3_sound_reset_1_w)
r11160r11161
288334
289335/******************************************************************************/
290336
291#define XOR(a) WORD2_XOR_BE(a)
292
293337static const gfx_layout charlayout =
294338{
295339   8,8,
296340   256,
297341   4,
298342   { 0,1,2,3 },
299   { XOR(7)*4, XOR(6)*4, XOR(5)*4, XOR(4)*4, XOR(3)*4, XOR(2)*4, XOR(1)*4, XOR(0)*4 },
343    { 20, 16, 28, 24, 4, 0, 12, 8 },
300344   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
301345   32*8
302346};
r11160r11161
307351   2048,
308352   4,
309353   { 0,1,2,3 },
310   { XOR(7)*4, XOR(6)*4, XOR(5)*4, XOR(4)*4, XOR(3)*4, XOR(2)*4, XOR(1)*4, XOR(0)*4 },
354    { 20, 16, 28, 24, 4, 0, 12, 8 },
311355   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
312356   32*8
313357};
r11160r11161
346390};
347391
348392static GFXDECODE_START( taito_f3 )
349   GFXDECODE_ENTRY( NULL,           0x000000, charlayout,       0x0000,  0x400>>4 ) /* Dynamically modified */
350   GFXDECODE_ENTRY( "gfx2", 0x000000, tile_layout,        0x0000, 0x2000>>4 ) /* Tiles area */
393   GFXDECODE_ENTRY( NULL,   0x000000, charlayout,       0x0000, 0x0400>>4 ) /* Dynamically modified */
394   GFXDECODE_ENTRY( "gfx2", 0x000000, tile_layout,     0x0000, 0x2000>>4 ) /* Tiles area */
351395   GFXDECODE_ENTRY( "gfx1", 0x000000, spriteram_layout, 0x1000, 0x1000>>4 ) /* Sprites area */
352   GFXDECODE_ENTRY( NULL,           0x000000, pivotlayout,      0x0000,  0x400>>4 ) /* Dynamically modified */
396   GFXDECODE_ENTRY( NULL,   0x000000, pivotlayout,      0x0000,  0x400>>4 ) /* Dynamically modified */
353397GFXDECODE_END
354398
355399/******************************************************************************/
r11160r11161
445489
446490   MCFG_DEVICE_REMOVE("eeprom")
447491   MCFG_EEPROM_93C46_ADD("eeprom")
448   MCFG_EEPROM_DATA(recalh_eeprom, 128)
492   MCFG_EEPROM_DATA(recalh_eeprom, 128) //TODO: convert this into ROM
449493MACHINE_CONFIG_END
450494
451495static MACHINE_CONFIG_DERIVED( f3_224b_eeprom, f3 )
452496
453497   MCFG_DEVICE_REMOVE("eeprom")
454498   MCFG_EEPROM_93C46_ADD("eeprom")
455   MCFG_EEPROM_DATA(recalh_eeprom, 128)
499   MCFG_EEPROM_DATA(recalh_eeprom, 128) //TODO: convert this into ROM
456500MACHINE_CONFIG_END
457501
458502static const gfx_layout bubsympb_sprite_layout =
r11160r11161
538582   ROM_LOAD       ("d21-08.51", 0x180000, 0x080000, CRC(a0d95be9) SHA1(1746097e827ac10906f012c5c4f93c388a30f4b3) )
539583   ROM_FILL       (             0x100000, 0x080000, 0 )
540584
585
586
541587   ROM_REGION(0x140000, "audiocpu", 0)   /* sound CPU */
542588   ROM_LOAD16_BYTE("d21-18.5", 0x100000, 0x20000, CRC(133b55d0) SHA1(feb5c9d0b1adcae3b16eb206c8ac4e73fd88bef4) )
543589   ROM_LOAD16_BYTE("d21-19.6", 0x100001, 0x20000, CRC(1f98908f) SHA1(972c8f7e4e417831466714efd0b4cadca1f3e8e5) )
r11160r11161
567613   ROM_LOAD       ("d21-08.51", 0x180000, 0x080000, CRC(a0d95be9) SHA1(1746097e827ac10906f012c5c4f93c388a30f4b3) )
568614   ROM_FILL       (             0x100000, 0x080000, 0 )
569615
616
617
570618   ROM_REGION(0x140000, "audiocpu", 0)   /* sound CPU */
571619   ROM_LOAD16_BYTE("d21-18.5", 0x100000, 0x20000, CRC(133b55d0) SHA1(feb5c9d0b1adcae3b16eb206c8ac4e73fd88bef4) )
572620   ROM_LOAD16_BYTE("d21-19.6", 0x100001, 0x20000, CRC(1f98908f) SHA1(972c8f7e4e417831466714efd0b4cadca1f3e8e5) )
r11160r11161
11721220   ROM_LOAD       ("d53-11.50", 0x300000, 0x100000, CRC(39c0a546) SHA1(53f03586f6586032fc3b4f90e987c1128edbb0a7) )
11731221   ROM_FILL       (             0x200000, 0x100000, 0 )
11741222
1223
1224
11751225   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
11761226   ROM_LOAD16_BYTE("d53-13.10", 0x100000, 0x20000, CRC(877f0361) SHA1(eda58d71fb06f739bee1451d7aa7e7e6dee10e03) )
11771227   ROM_LOAD16_BYTE("d53-14.23", 0x100001, 0x20000, CRC(a8664867) SHA1(dffddca469019abac33a1abe41c3fe83fbf553ce) )
r11160r11161
12001250   ROM_LOAD       ("d66-08.ic49", 0x300000, 0x100000, CRC(9959f30b) SHA1(64bf2bf995c283c00d968e3c078b824de4084d3d) )
12011251   ROM_FILL       (              0x200000, 0x100000, 0 )
12021252
1253
1254
12031255   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 code */
12041256   ROM_LOAD16_BYTE("d66-23.ic10", 0x100000, 0x40000, CRC(57fb7c49) SHA1(f8709fd1e9ea7cee10ee2288d13339f675a7d3ae) )
12051257   ROM_LOAD16_BYTE("d66-22.ic23", 0x100001, 0x40000, CRC(83dd7f9b) SHA1(dae21f64232d3e268f22b5e9899e0b726fdc9a9f) )
r11160r11161
12281280   ROM_LOAD       ("d66-08.ic49", 0x300000, 0x100000, CRC(9959f30b) SHA1(64bf2bf995c283c00d968e3c078b824de4084d3d) )
12291281   ROM_FILL       (              0x200000, 0x100000, 0 )
12301282
1283
1284
12311285   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 code */
12321286   ROM_LOAD16_BYTE("d66-23.ic10", 0x100000, 0x40000, CRC(57fb7c49) SHA1(f8709fd1e9ea7cee10ee2288d13339f675a7d3ae) )
12331287   ROM_LOAD16_BYTE("d66-22.ic23", 0x100001, 0x40000, CRC(83dd7f9b) SHA1(dae21f64232d3e268f22b5e9899e0b726fdc9a9f) )
r11160r11161
12561310   ROM_LOAD       ("d66-08.ic49", 0x300000, 0x100000, CRC(9959f30b) SHA1(64bf2bf995c283c00d968e3c078b824de4084d3d) )
12571311   ROM_FILL       (              0x200000, 0x100000, 0 )
12581312
1313
1314
12591315   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 code */
12601316   ROM_LOAD16_BYTE("d66-23.ic10", 0x100000, 0x40000, CRC(57fb7c49) SHA1(f8709fd1e9ea7cee10ee2288d13339f675a7d3ae) )
12611317   ROM_LOAD16_BYTE("d66-22.ic23", 0x100001, 0x40000, CRC(83dd7f9b) SHA1(dae21f64232d3e268f22b5e9899e0b726fdc9a9f) )
r11160r11161
12871343   ROM_LOAD       ("d49-11", 0x180000, 0x080000, CRC(11318b26) SHA1(a7153f9f406d52189f59cbe58d65f88f4e2e6fcc) )
12881344   ROM_FILL       (          0x100000, 0x080000, 0 )
12891345
1346
1347
12901348   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
12911349   ROM_LOAD16_BYTE("d49-17.32", 0x100000, 0x40000, CRC(49942466) SHA1(5e355a079b81f129919c7599c0cc09a9e193ea41) )
12921350   ROM_LOAD16_BYTE("d49-18.33", 0x100001, 0x40000, CRC(9d75b7d4) SHA1(1dc823327294f5c81b78f151fcd3d0550c208697) )
r11160r11161
13191377   ROM_LOAD       ("d69-05.bin", 0x600000, 0x200000, CRC(f9f5433c) SHA1(d3de66385d883c72967c44bc29983d7a79f665d1) )
13201378   ROM_FILL       (              0x400000, 0x200000, 0 )
13211379
1380
1381
13221382   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
13231383   ROM_LOAD16_BYTE("d69-18.bin", 0x100000, 0x20000, CRC(04600d7b) SHA1(666cfab09b61fd6e0bc4ff277018ebf1cda01b0e) )
13241384   ROM_LOAD16_BYTE("d69-19.bin", 0x100001, 0x20000, CRC(1484e853) SHA1(4459c18ba005786483c652857e527c6093efb036) )
r11160r11161
13501410   ROM_LOAD       ("d69-05.bin", 0x600000, 0x200000, CRC(f9f5433c) SHA1(d3de66385d883c72967c44bc29983d7a79f665d1) )
13511411   ROM_FILL       (              0x400000, 0x200000, 0 )
13521412
1413
1414
13531415   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
13541416   ROM_LOAD16_BYTE("d69-18.bin", 0x100000, 0x20000, CRC(04600d7b) SHA1(666cfab09b61fd6e0bc4ff277018ebf1cda01b0e) )
13551417   ROM_LOAD16_BYTE("d69-19.bin", 0x100001, 0x20000, CRC(1484e853) SHA1(4459c18ba005786483c652857e527c6093efb036) )
r11160r11161
13811443   ROM_LOAD       ("d69-05.bin", 0x600000, 0x200000, CRC(f9f5433c) SHA1(d3de66385d883c72967c44bc29983d7a79f665d1) )
13821444   ROM_FILL       (              0x400000, 0x200000, 0 )
13831445
1446
1447
13841448   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
13851449   ROM_LOAD16_BYTE("d69-18.bin", 0x100000, 0x20000, CRC(04600d7b) SHA1(666cfab09b61fd6e0bc4ff277018ebf1cda01b0e) )
13861450   ROM_LOAD16_BYTE("d69-19.bin", 0x100001, 0x20000, CRC(1484e853) SHA1(4459c18ba005786483c652857e527c6093efb036) )
r11160r11161
14721536   ROM_LOAD       ("d69-05.bin", 0x600000, 0x200000, CRC(f9f5433c) SHA1(d3de66385d883c72967c44bc29983d7a79f665d1) )
14731537   ROM_FILL       (              0x400000, 0x200000, 0 )
14741538
1539
1540
14751541   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
14761542   ROM_LOAD16_BYTE("d69-18.bin", 0x100000, 0x20000, CRC(04600d7b) SHA1(666cfab09b61fd6e0bc4ff277018ebf1cda01b0e) )
14771543   ROM_LOAD16_BYTE("d69-19.bin", 0x100001, 0x20000, CRC(1484e853) SHA1(4459c18ba005786483c652857e527c6093efb036) )
r11160r11161
15031569   ROM_LOAD       ("d78-03.43", 0x180000, 0x080000, CRC(a8bc36e5) SHA1(5777b9457292e8a9cbb4e8226ba939530ffab07c) )
15041570   ROM_FILL       (          0x100000, 0x080000, 0 )
15051571
1572
1573
15061574   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
15071575   ROM_LOAD16_BYTE("d78-08.32", 0x100000, 0x20000, CRC(a629d07c) SHA1(b2904e106633a3960ceb2bc58b600ea60034ff0b) )
15081576   ROM_LOAD16_BYTE("d78-09.33", 0x100001, 0x20000, CRC(1f0efe01) SHA1(7bff748b9fcee170e430d90ee07eb9975d8fba59) )
r11160r11161
15351603   ROM_LOAD       ("d78-03.43", 0x180000, 0x080000, CRC(a8bc36e5) SHA1(5777b9457292e8a9cbb4e8226ba939530ffab07c) )
15361604   ROM_FILL       (          0x100000, 0x080000, 0 )
15371605
1606
1607
15381608   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
15391609   ROM_LOAD16_BYTE("d78-08.32", 0x100000, 0x20000, CRC(a629d07c) SHA1(b2904e106633a3960ceb2bc58b600ea60034ff0b) )
15401610   ROM_LOAD16_BYTE("d78-09.33", 0x100001, 0x20000, CRC(1f0efe01) SHA1(7bff748b9fcee170e430d90ee07eb9975d8fba59) )
r11160r11161
15621632   ROM_LOAD16_BYTE("rh_scrm.bin", 0x000001, 0x100000, CRC(37200968) SHA1(4a8d5a17af7eb732f481bf174099845e8d8d6b87) )
15631633   ROM_FILL       (               0x200000, 0x200000, 0 )
15641634
1635
1636
15651637   ROM_REGION(0x140000, "audiocpu", 0)   /* sound CPU */
15661638   ROM_LOAD16_BYTE("rh_spr1.bin", 0x100000, 0x20000, CRC(504cbc1d) SHA1(35a775c1ebc8107c553e43b9d84eb735446c26fd) )
15671639   ROM_LOAD16_BYTE("rh_spr0.bin", 0x100001, 0x20000, CRC(78fba467) SHA1(4586b061724be7ec413784b820c33cc0d6bbcd0c) )
r11160r11161
16031675   ROM_LOAD       ("d84-18.rom", 0xb00000, 0x100000, CRC(e812bcc5) SHA1(3574e4a99232d9fc7989ec5d1e8fe76b4b30784a) )
16041676   ROM_FILL       (              0x600000, 0x300000, 0 )
16051677
1678
1679
16061680   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
16071681   ROM_LOAD16_BYTE("d84-26.32", 0x100000, 0x40000, CRC(4f5b8563) SHA1(1d4e06cbea7bc73a99d6e30be714fff420151bbc) )
16081682   ROM_LOAD16_BYTE("d84-27.33", 0x100001, 0x40000, CRC(fb0cb1ba) SHA1(16a79b53651a6131f7636db19738b456b7c28bff) )
r11160r11161
16461720   ROM_LOAD       ("d84-18.rom", 0xb00000, 0x100000, CRC(e812bcc5) SHA1(3574e4a99232d9fc7989ec5d1e8fe76b4b30784a) )
16471721   ROM_FILL       (              0x600000, 0x300000, 0 )
16481722
1723
1724
16491725   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
16501726   ROM_LOAD16_BYTE("d84-26.32", 0x100000, 0x40000, CRC(4f5b8563) SHA1(1d4e06cbea7bc73a99d6e30be714fff420151bbc) )
16511727   ROM_LOAD16_BYTE("d84-27.33", 0x100001, 0x40000, CRC(fb0cb1ba) SHA1(16a79b53651a6131f7636db19738b456b7c28bff) )
r11160r11161
16891765   ROM_LOAD       ("d84-18.rom", 0xb00000, 0x100000, CRC(e812bcc5) SHA1(3574e4a99232d9fc7989ec5d1e8fe76b4b30784a) )
16901766   ROM_FILL       (              0x600000, 0x300000, 0 )
16911767
1768
1769
16921770   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
16931771   ROM_LOAD16_BYTE("d84-26.32", 0x100000, 0x40000, CRC(4f5b8563) SHA1(1d4e06cbea7bc73a99d6e30be714fff420151bbc) )
16941772   ROM_LOAD16_BYTE("d84-27.33", 0x100001, 0x40000, CRC(fb0cb1ba) SHA1(16a79b53651a6131f7636db19738b456b7c28bff) )
r11160r11161
17321810   ROM_LOAD       ("d84-18.rom", 0xb00000, 0x100000, CRC(e812bcc5) SHA1(3574e4a99232d9fc7989ec5d1e8fe76b4b30784a) )
17331811   ROM_FILL       (              0x600000, 0x300000, 0 )
17341812
1813
1814
17351815   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
17361816   ROM_LOAD16_BYTE("d84-26.32", 0x100000, 0x40000, CRC(4f5b8563) SHA1(1d4e06cbea7bc73a99d6e30be714fff420151bbc) )
17371817   ROM_LOAD16_BYTE("d84-27.33", 0x100001, 0x40000, CRC(fb0cb1ba) SHA1(16a79b53651a6131f7636db19738b456b7c28bff) )
r11160r11161
17631843   ROM_LOAD       ("d87-08.bin", 0x600000, 0x200000, CRC(76d23602) SHA1(ca53ea6641182c44a4038bbeaa5effb1687f1980) )
17641844   ROM_FILL       (              0x400000, 0x200000, 0 )
17651845
1846
1847
17661848   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
17671849   ROM_LOAD16_BYTE("d87-13.bin", 0x100000, 0x40000, CRC(15b1fff4) SHA1(28692b731ae98a47c2c5e11a8a71b61a813d9a64) )
17681850   ROM_LOAD16_BYTE("d87-14.bin", 0x100001, 0x40000, CRC(eecda29a) SHA1(6eb238e47bc7bf635ffbdbb25fb06a37db980ef8) )
r11160r11161
17911873   ROM_LOAD       ("d87-08.bin", 0x600000, 0x200000, CRC(76d23602) SHA1(ca53ea6641182c44a4038bbeaa5effb1687f1980) )
17921874   ROM_FILL       (              0x400000, 0x200000, 0 )
17931875
1876
1877
17941878   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
17951879   ROM_LOAD16_BYTE("d87-13.bin", 0x100000, 0x40000, CRC(15b1fff4) SHA1(28692b731ae98a47c2c5e11a8a71b61a813d9a64) )
17961880   ROM_LOAD16_BYTE("d87-14.bin", 0x100001, 0x40000, CRC(eecda29a) SHA1(6eb238e47bc7bf635ffbdbb25fb06a37db980ef8) )
r11160r11161
18191903   ROM_LOAD       ("d87-08.bin", 0x600000, 0x200000, CRC(76d23602) SHA1(ca53ea6641182c44a4038bbeaa5effb1687f1980) )
18201904   ROM_FILL       (              0x400000, 0x200000, 0 )
18211905
1906
1907
18221908   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
18231909   ROM_LOAD16_BYTE("d87-13.bin", 0x100000, 0x40000, CRC(15b1fff4) SHA1(28692b731ae98a47c2c5e11a8a71b61a813d9a64) )
18241910   ROM_LOAD16_BYTE("d87-14.bin", 0x100001, 0x40000, CRC(eecda29a) SHA1(6eb238e47bc7bf635ffbdbb25fb06a37db980ef8) )
r11160r11161
18471933   ROM_LOAD       ("d87-08.bin", 0x600000, 0x200000, CRC(76d23602) SHA1(ca53ea6641182c44a4038bbeaa5effb1687f1980) )
18481934   ROM_FILL       (              0x400000, 0x200000, 0 )
18491935
1936
1937
18501938   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
18511939   ROM_LOAD16_BYTE("d87-13.bin", 0x100000, 0x40000, CRC(15b1fff4) SHA1(28692b731ae98a47c2c5e11a8a71b61a813d9a64) )
18521940   ROM_LOAD16_BYTE("d87-14.bin", 0x100001, 0x40000, CRC(eecda29a) SHA1(6eb238e47bc7bf635ffbdbb25fb06a37db980ef8) )
r11160r11161
18751963   ROM_LOAD       ("d90-06", 0x300000, 0x100000, CRC(166a72b8) SHA1(7f70b8c960794322e1dc88e6600a2d13d948d873) )
18761964   ROM_FILL       (          0x200000, 0x100000, 0 )
18771965
1966
1967
18781968   ROM_REGION(0x180000, "audiocpu", 0)   /* sound CPU */
18791969   ROM_LOAD16_BYTE("d90-13", 0x100000, 0x40000, CRC(6762bd90) SHA1(771db0382bc8dab2caf13d0fc20648366c685829) )
18801970   ROM_LOAD16_BYTE("d90-14", 0x100001, 0x40000, CRC(8e33357e) SHA1(68b81693c22e6357e37244f2a416818a81338138) )
r11160r11161
19031993   ROM_LOAD       ("d90-06", 0x300000, 0x100000, CRC(166a72b8) SHA1(7f70b8c960794322e1dc88e6600a2d13d948d873) )
19041994   ROM_FILL       (          0x200000, 0x100000, 0 )
19051995
1996
1997
19061998   ROM_REGION(0x180000, "audiocpu", 0)   /* sound CPU */
19071999   ROM_LOAD16_BYTE("d90-13", 0x100000, 0x40000, CRC(6762bd90) SHA1(771db0382bc8dab2caf13d0fc20648366c685829) )
19082000   ROM_LOAD16_BYTE("d90-14", 0x100001, 0x40000, CRC(8e33357e) SHA1(68b81693c22e6357e37244f2a416818a81338138) )
r11160r11161
19312023   ROM_LOAD       ("d90-06", 0x300000, 0x100000, CRC(166a72b8) SHA1(7f70b8c960794322e1dc88e6600a2d13d948d873) )
19322024   ROM_FILL       (          0x200000, 0x100000, 0 )
19332025
2026
2027
19342028   ROM_REGION(0x180000, "audiocpu", 0)   /* sound CPU */
19352029   ROM_LOAD16_BYTE("d90-13", 0x100000, 0x40000, CRC(6762bd90) SHA1(771db0382bc8dab2caf13d0fc20648366c685829) )
19362030   ROM_LOAD16_BYTE("d90-14", 0x100001, 0x40000, CRC(8e33357e) SHA1(68b81693c22e6357e37244f2a416818a81338138) )
r11160r11161
20202114   ROM_LOAD       ("d90-06", 0x300000, 0x100000, CRC(166a72b8) SHA1(7f70b8c960794322e1dc88e6600a2d13d948d873) )
20212115   ROM_FILL       (          0x200000, 0x100000, 0 )
20222116
2117
2118
20232119   ROM_REGION(0x180000, "audiocpu", 0)   /* sound CPU */
20242120   ROM_LOAD16_BYTE("d90-13", 0x100000, 0x40000, CRC(6762bd90) SHA1(771db0382bc8dab2caf13d0fc20648366c685829) )
20252121   ROM_LOAD16_BYTE("d90-14", 0x100001, 0x40000, CRC(8e33357e) SHA1(68b81693c22e6357e37244f2a416818a81338138) )
r11160r11161
20462142   ROM_LOAD16_BYTE("d93-10.45", 0x000001, 0x20000, CRC(8a3f531b) SHA1(69f9971c45971018108a5d312d5bbcfd3caf9bd0) )
20472143   ROM_FILL       (             0x040000, 0x40000, 0 )
20482144
2145
2146
20492147   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
20502148   ROM_LOAD16_BYTE("d93-05.bin", 0x100000, 0x20000, CRC(ff365596) SHA1(4cf2e0d6f42cf3fb69796be6092eff8a47f7f8b9) )
20512149   ROM_LOAD16_BYTE("d93-06.bin", 0x100001, 0x20000, CRC(ef7ad400) SHA1(01be403d575a543f089b910a5a8c381a6603e67e) )
r11160r11161
20822180   ROM_LOAD       ("d94-12.bin", 0x300000, 0x100000, CRC(47064189) SHA1(99ceeb326dcc2e1c3acba8ac14d94dcb17c6e032) )
20832181   ROM_FILL       (              0x200000, 0x100000,0 )
20842182
2183
2184
20852185   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
20862186   ROM_LOAD16_BYTE("d94-19.bin", 0x100000, 0x40000, CRC(c93dbcf4) SHA1(413520e652d809651aff9b1b74e6353112d34c12) )
20872187   ROM_LOAD16_BYTE("d94-20.bin", 0x100001, 0x40000, CRC(f232bf64) SHA1(bbfeae0785fc49c12aa6d9b1bd6ff7c8515f8fe7) )
r11160r11161
21162216   ROM_LOAD       ("d94-12.bin", 0x300000, 0x100000, CRC(47064189) SHA1(99ceeb326dcc2e1c3acba8ac14d94dcb17c6e032) )
21172217   ROM_FILL       (              0x200000, 0x100000,0 )
21182218
2219
2220
21192221   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
21202222   ROM_LOAD16_BYTE("d94-19.bin", 0x100000, 0x40000, CRC(c93dbcf4) SHA1(413520e652d809651aff9b1b74e6353112d34c12) )
21212223   ROM_LOAD16_BYTE("d94-20.bin", 0x100001, 0x40000, CRC(f232bf64) SHA1(bbfeae0785fc49c12aa6d9b1bd6ff7c8515f8fe7) )
r11160r11161
21502252   ROM_LOAD       ("d94-12.bin", 0x300000, 0x100000, CRC(47064189) SHA1(99ceeb326dcc2e1c3acba8ac14d94dcb17c6e032) )
21512253   ROM_FILL       (              0x200000, 0x100000,0 )
21522254
2255
2256
21532257   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
21542258   ROM_LOAD16_BYTE("d94-19.bin", 0x100000, 0x40000, CRC(c93dbcf4) SHA1(413520e652d809651aff9b1b74e6353112d34c12) )
21552259   ROM_LOAD16_BYTE("d94-20.bin", 0x100001, 0x40000, CRC(f232bf64) SHA1(bbfeae0785fc49c12aa6d9b1bd6ff7c8515f8fe7) )
r11160r11161
21762280   ROM_LOAD16_BYTE("d95-05.45", 0x000001, 0x200000, CRC(1a1a852b) SHA1(89827485a31af4e2457775a5d16f747a764b6d67) )
21772281   ROM_FILL       (             0x400000, 0x400000, 0 )
21782282
2283
2284
21792285   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
21802286   ROM_LOAD16_BYTE("d95-07.32", 0x100000, 0x40000, CRC(3c201d70) SHA1(89fe4d363f4e1a847ba7d2894a2092708b287a33) )
21812287   ROM_LOAD16_BYTE("d95-08.33", 0x100001, 0x40000, CRC(01c23354) SHA1(7b332edc844b1b1c1513e879215089987645fa3f) )
r11160r11161
22042310   ROM_LOAD       ("e06-06", 0x300000, 0x100000, CRC(9380db3c) SHA1(83f5a46a01b9c15499e0dc2222df496d26baa0d4) )
22052311   ROM_FILL       (          0x200000, 0x100000, 0 )
22062312
2313
2314
22072315   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
22082316   ROM_LOAD16_BYTE("e06-09.32", 0x100000, 0x40000, CRC(9bcafc87) SHA1(10b3f6da00a41550fe6a705232f0e33fda3c7e7c) )
22092317   ROM_LOAD16_BYTE("e06-10.33", 0x100001, 0x40000, CRC(b752b61f) SHA1(e948a8af19c70ba8b8e908c869bc88ed0cac8420) )
r11160r11161
22392347   ROM_LOAD       ("e06-06", 0x300000, 0x100000, CRC(9380db3c) SHA1(83f5a46a01b9c15499e0dc2222df496d26baa0d4) )
22402348   ROM_FILL       (          0x200000, 0x100000, 0 )
22412349
2350
2351
22422352   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
22432353   ROM_LOAD16_BYTE("e06-09.32", 0x100000, 0x40000, CRC(9bcafc87) SHA1(10b3f6da00a41550fe6a705232f0e33fda3c7e7c) )
22442354   ROM_LOAD16_BYTE("e06-10.33", 0x100001, 0x40000, CRC(b752b61f) SHA1(e948a8af19c70ba8b8e908c869bc88ed0cac8420) )
r11160r11161
22742384   ROM_LOAD       ("e06-06", 0x300000, 0x100000, CRC(9380db3c) SHA1(83f5a46a01b9c15499e0dc2222df496d26baa0d4) )
22752385   ROM_FILL       (          0x200000, 0x100000, 0 )
22762386
2387
2388
22772389   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
22782390   ROM_LOAD16_BYTE("e06-09.32", 0x100000, 0x40000, CRC(9bcafc87) SHA1(10b3f6da00a41550fe6a705232f0e33fda3c7e7c) )
22792391   ROM_LOAD16_BYTE("e06-10.33", 0x100001, 0x40000, CRC(b752b61f) SHA1(e948a8af19c70ba8b8e908c869bc88ed0cac8420) )
r11160r11161
23872499   ROM_LOAD       ("e02-06.43", 0x600000, 0x200000, CRC(4c8726e9) SHA1(8ce2320a087f43c49428a39dafffec8c40d61b03) )
23882500   ROM_FILL       (             0x400000, 0x200000, 0 )
23892501
2502
2503
23902504   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
23912505   ROM_LOAD16_BYTE("e02-13.32", 0x100000, 0x40000, CRC(80932702) SHA1(c468234d03aa31b2aa0c3bd6bec32034216c2ae4) )
23922506   ROM_LOAD16_BYTE("e02-14.33", 0x100001, 0x40000, CRC(706671a5) SHA1(1ac90647d617e73f12a67274a025ae43a6b3a316) )
r11160r11161
24242538   ROM_LOAD       ("e02-06.43", 0x600000, 0x200000, CRC(4c8726e9) SHA1(8ce2320a087f43c49428a39dafffec8c40d61b03) )
24252539   ROM_FILL       (             0x400000, 0x200000, 0 )
24262540
2541
2542
24272543   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
24282544   ROM_LOAD16_BYTE("e02-13.32", 0x100000, 0x40000, CRC(80932702) SHA1(c468234d03aa31b2aa0c3bd6bec32034216c2ae4) )
24292545   ROM_LOAD16_BYTE("e02-14.33", 0x100001, 0x40000, CRC(706671a5) SHA1(1ac90647d617e73f12a67274a025ae43a6b3a316) )
r11160r11161
24522568   ROM_LOAD       ("e02-06.43", 0x600000, 0x200000, CRC(4c8726e9) SHA1(8ce2320a087f43c49428a39dafffec8c40d61b03) )
24532569   ROM_FILL       (             0x400000, 0x200000, 0 )
24542570
2571
2572
24552573   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
24562574   ROM_LOAD16_BYTE("e02-13.32", 0x100000, 0x40000, CRC(80932702) SHA1(c468234d03aa31b2aa0c3bd6bec32034216c2ae4) )
24572575   ROM_LOAD16_BYTE("e02-14.33", 0x100001, 0x40000, CRC(706671a5) SHA1(1ac90647d617e73f12a67274a025ae43a6b3a316) )
r11160r11161
24812599   ROM_LOAD16_BYTE("scr0-4.b03",  0x300000, 0x080000, CRC(d32280fe) SHA1(56b120128c5e4b8c6598a1de51269e6702a63175) )
24822600   ROM_LOAD16_BYTE("scr0-5.b02",  0x300001, 0x080000, CRC(fdd1a85b) SHA1(1d94a4858baef3e78c456049dc58249a574205fe) )
24832601
2602
2603
24842604   ROM_REGION(0x180000, "audiocpu", 0)   /* sound CPU */
24852605   ROM_LOAD16_BYTE("spr0-1.b66", 0x100000, 0x40000, CRC(4b20e99d) SHA1(faf184daea0f1131bafa50edb48bd470d4c0b141) )
24862606   ROM_LOAD16_BYTE("spr0-0.b65", 0x100001, 0x40000, CRC(2569eb30) SHA1(ec804131025e600198cd8342925823340e7ef458) )
r11160r11161
25232643   ROM_LOAD       ("e08-10.43", 0x300000, 0x100000, CRC(60abc71b) SHA1(f4aa906920c6134c33a4dfb51724f3adbd3d7de4) )
25242644   ROM_FILL       (             0x200000, 0x100000, 0 )
25252645
2646
2647
25262648   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
25272649   ROM_LOAD16_BYTE("e08-18.32", 0x100000, 0x20000, CRC(e695497e) SHA1(9d845b4c0bd9b40471fb4b5ab2f9240058bc324f) )
25282650   ROM_LOAD16_BYTE("e08-17.33", 0x100001, 0x20000, CRC(fafc7e4e) SHA1(26f46d5900fbf26d25651e7e818e486fc7a878ec) )
r11160r11161
25532675   ROM_LOAD       ("e10-05.rom", 0x300000, 0x100000, CRC(81266151) SHA1(aa3b144f32995425db97efce440e234a3c7a6715) )
25542676   ROM_FILL       (              0x200000, 0x100000, 0 )
25552677
2678
2679
25562680   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
25572681   ROM_LOAD16_BYTE("e10-12.32", 0x100000, 0x40000, CRC(b92dc8ad) SHA1(0c1428d313507b1ae5a2af3b2fbaaa5650135e1e) )
25582682   ROM_LOAD16_BYTE("e10-13.33", 0x100001, 0x40000, CRC(87842c13) SHA1(d15b47c7430e677ae172f86fd5be595e4fe72e42) )
r11160r11161
25852709   ROM_LOAD       ("e10-05.rom", 0x300000, 0x100000, CRC(81266151) SHA1(aa3b144f32995425db97efce440e234a3c7a6715) )
25862710   ROM_FILL       (              0x200000, 0x100000, 0 )
25872711
2712
2713
25882714   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
25892715   ROM_LOAD16_BYTE("e10-12.32", 0x100000, 0x40000, CRC(b92dc8ad) SHA1(0c1428d313507b1ae5a2af3b2fbaaa5650135e1e) )
25902716   ROM_LOAD16_BYTE("e10-13.33", 0x100001, 0x40000, CRC(87842c13) SHA1(d15b47c7430e677ae172f86fd5be595e4fe72e42) )
r11160r11161
26122738   ROM_LOAD       ("e10-05.rom", 0x300000, 0x100000, CRC(81266151) SHA1(aa3b144f32995425db97efce440e234a3c7a6715) )
26132739   ROM_FILL       (              0x200000, 0x100000, 0 )
26142740
2741
2742
26152743   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
26162744   ROM_LOAD16_BYTE("e10-12.32", 0x100000, 0x40000, CRC(b92dc8ad) SHA1(0c1428d313507b1ae5a2af3b2fbaaa5650135e1e) )
26172745   ROM_LOAD16_BYTE("e10-13.33", 0x100001, 0x40000, CRC(87842c13) SHA1(d15b47c7430e677ae172f86fd5be595e4fe72e42) )
r11160r11161
26392767   ROM_LOAD       ("e10-05.rom", 0x300000, 0x100000, CRC(81266151) SHA1(aa3b144f32995425db97efce440e234a3c7a6715) )
26402768   ROM_FILL       (              0x200000, 0x100000, 0 )
26412769
2770
2771
26422772   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
26432773   ROM_LOAD16_BYTE("e10-16.32", 0x100000, 0x40000, CRC(765ce77a) SHA1(e2723bd6238da91d28307081909a7172a1825c83) )
26442774   ROM_LOAD16_BYTE("e10-17.33", 0x100001, 0x40000, CRC(0aec3b1e) SHA1(a76a020cefcfbf86b0d893a6eb8ff93cb571abeb) )
r11160r11161
26662796   ROM_LOAD       ("e10-05.rom", 0x300000, 0x100000, CRC(81266151) SHA1(aa3b144f32995425db97efce440e234a3c7a6715) )
26672797   ROM_FILL       (              0x200000, 0x100000, 0 )
26682798
2799
2800
26692801   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
26702802   ROM_LOAD16_BYTE("e10-30.32", 0x100000, 0x40000, CRC(bb090c1e) SHA1(af2ff23d6f9bd56c25530cb9bf9f452b6f5210f5) )
26712803   ROM_LOAD16_BYTE("e10-31.33", 0x100001, 0x40000, CRC(f4b88d65) SHA1(c74dcb4bed979039fad1d5c7528c14ce4db1d5ec) )
r11160r11161
27012833   ROM_LOAD       ("e11-06.ic43", 0x600000, 0x200000, CRC(200ce305) SHA1(c80a0b96510913a6411e6763fb72bf413fb792da) )
27022834   ROM_FILL       (               0x400000, 0x200000, 0 )
27032835
2836
2837
27042838   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
27052839   ROM_LOAD16_BYTE("e11-13.ic32", 0x100000, 0x40000, CRC(f5c5486a) SHA1(4091f3ddb1e6cbc9dc89485e1e784a4b6fa191b7) )
27062840   ROM_LOAD16_BYTE("e11-14.ic33", 0x100001, 0x40000, CRC(7fa10f96) SHA1(50efefd890535e952022a494c5b4e9b33bb90fad) )
r11160r11161
27292863   ROM_LOAD       ("e11-06.ic43", 0x600000, 0x200000, CRC(200ce305) SHA1(c80a0b96510913a6411e6763fb72bf413fb792da) )
27302864   ROM_FILL       (               0x400000, 0x200000, 0 )
27312865
2866
2867
27322868   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
27332869   ROM_LOAD16_BYTE("e11-13.ic32", 0x100000, 0x40000, CRC(f5c5486a) SHA1(4091f3ddb1e6cbc9dc89485e1e784a4b6fa191b7) )
27342870   ROM_LOAD16_BYTE("e11-14.ic33", 0x100001, 0x40000, CRC(7fa10f96) SHA1(50efefd890535e952022a494c5b4e9b33bb90fad) )
r11160r11161
27592895   ROM_LOAD16_BYTE("e15-07.bin", 0x400001, 0x100000, CRC(8164f7ee) SHA1(4550521f820e93ec08b86d148135966d016cbf22) )
27602896   ROM_FILL       (              0x600000, 0x600000, 0 )
27612897
2898
2899
27622900   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
27632901   ROM_LOAD16_BYTE("e15-15.bin", 0x100000, 0x20000, CRC(22126dfb) SHA1(a1af17e5c3440f1bab50d79f92c251f1a4536ca0) )
27642902   ROM_LOAD16_BYTE("e15-16.bin", 0x100001, 0x20000, CRC(f8b58ea0) SHA1(c9e196620765efc4c7b535793a5d1f586698ce55) )
r11160r11161
27892927   ROM_LOAD16_BYTE("e15-07.bin", 0x400001, 0x100000, CRC(8164f7ee) SHA1(4550521f820e93ec08b86d148135966d016cbf22) )
27902928   ROM_FILL       (              0x600000, 0x600000, 0 )
27912929
2930
2931
27922932   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
27932933   ROM_LOAD16_BYTE("e15-15.bin", 0x100000, 0x20000, CRC(22126dfb) SHA1(a1af17e5c3440f1bab50d79f92c251f1a4536ca0) )
27942934   ROM_LOAD16_BYTE("e15-16.bin", 0x100001, 0x20000, CRC(f8b58ea0) SHA1(c9e196620765efc4c7b535793a5d1f586698ce55) )
r11160r11161
28192959   ROM_LOAD16_BYTE("e15-07.bin", 0x400001, 0x100000, CRC(8164f7ee) SHA1(4550521f820e93ec08b86d148135966d016cbf22) )
28202960   ROM_FILL       (              0x600000, 0x600000, 0 )
28212961
2962
2963
28222964   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
28232965   ROM_LOAD16_BYTE("e15-15.bin", 0x100000, 0x20000, CRC(22126dfb) SHA1(a1af17e5c3440f1bab50d79f92c251f1a4536ca0) )
28242966   ROM_LOAD16_BYTE("e15-16.bin", 0x100001, 0x20000, CRC(f8b58ea0) SHA1(c9e196620765efc4c7b535793a5d1f586698ce55) )
r11160r11161
28462988   ROM_LOAD       ("e21-05.rom", 0x300000, 0x100000, CRC(07eab58f) SHA1(ae2d7b839b39d88d11652df74804a39230674467) )
28472989   ROM_FILL       (              0x200000, 0x100000, 0 )
28482990
2991
2992
28492993   ROM_REGION(0x180000, "audiocpu", 0)   /* Sound CPU */
28502994   ROM_LOAD16_BYTE("e21-12.32", 0x100000, 0x40000, CRC(34093de1) SHA1(d69d6b5f10b8fe86f727d739ed5aecceb15e01f7) )
28512995   ROM_LOAD16_BYTE("e21-13.33", 0x100001, 0x40000, CRC(9e9ec437) SHA1(b0265b688846c642d240b2f3677d2330d31eaa87) )
r11160r11161
28763020   ROM_LOAD       ("e21-05.rom", 0x300000, 0x100000, CRC(07eab58f) SHA1(ae2d7b839b39d88d11652df74804a39230674467) )
28773021   ROM_FILL       (              0x200000, 0x100000, 0 )
28783022
3023
3024
28793025   ROM_REGION(0x180000, "audiocpu", 0)   /* Sound CPU */
28803026   ROM_LOAD16_BYTE("e21-12.32", 0x100000, 0x40000, CRC(34093de1) SHA1(d69d6b5f10b8fe86f727d739ed5aecceb15e01f7) )
28813027   ROM_LOAD16_BYTE("e21-13.33", 0x100001, 0x40000, CRC(9e9ec437) SHA1(b0265b688846c642d240b2f3677d2330d31eaa87) )
r11160r11161
29063052   ROM_LOAD       ("e28-04.bin", 0x300000, 0x100000, CRC(57aef029) SHA1(5c07209015d4749d1ffb3e9c1a890e6cfeec8cb0) )
29073053   ROM_FILL       (              0x200000, 0x100000, 0 )
29083054
3055
3056
29093057   ROM_REGION(0x140000, "audiocpu", 0)   /* Sound CPU */
29103058   ROM_LOAD16_BYTE("e28-11.bin", 0x100000, 0x20000, CRC(01a06950) SHA1(94d22cd839f9027e9d45264c366e0cb5d698e0b6) )
29113059   ROM_LOAD16_BYTE("e28-12.bin", 0x100001, 0x20000, CRC(dc19260f) SHA1(fa0ca03a236326652e4f9898d07cd837c1507a9d) )
r11160r11161
29323080   ROM_LOAD       ("e29-06.rom", 0x300000, 0x100000, CRC(c16184f8) SHA1(ded417d9d116b5a2f7518fa404bc2dda1c6a6366) )
29333081   ROM_FILL       (              0x200000, 0x100000, 0 )
29343082
3083
3084
29353085   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 code */
29363086   ROM_LOAD16_BYTE("e29-13.rom", 0x100000, 0x40000, CRC(1ef551ef) SHA1(527defe8f35314304adb4b483285b08cd6ebe865) )
29373087   ROM_LOAD16_BYTE("e29-14.rom", 0x100001, 0x40000, CRC(7ee7e688) SHA1(d65aa9c449e1d64f10d1be9727a9d93ab1571e65) )
r11160r11161
29613111   ROM_LOAD       ("e29-06.rom", 0x300000, 0x100000, CRC(c16184f8) SHA1(ded417d9d116b5a2f7518fa404bc2dda1c6a6366) )
29623112   ROM_FILL       (              0x200000, 0x100000, 0 )
29633113
3114
3115
29643116   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 code */
29653117   ROM_LOAD16_BYTE("e29-13.rom", 0x100000, 0x40000, CRC(1ef551ef) SHA1(527defe8f35314304adb4b483285b08cd6ebe865) )
29663118   ROM_LOAD16_BYTE("e29-14.rom", 0x100001, 0x40000, CRC(7ee7e688) SHA1(d65aa9c449e1d64f10d1be9727a9d93ab1571e65) )
r11160r11161
29903142   ROM_LOAD       ("e29-06.rom", 0x300000, 0x100000, CRC(c16184f8) SHA1(ded417d9d116b5a2f7518fa404bc2dda1c6a6366) )
29913143   ROM_FILL       (              0x200000, 0x100000, 0 )
29923144
3145
3146
29933147   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 code */
29943148   ROM_LOAD16_BYTE("e29-13.rom", 0x100000, 0x40000, CRC(1ef551ef) SHA1(527defe8f35314304adb4b483285b08cd6ebe865) )
29953149   ROM_LOAD16_BYTE("e29-14.rom", 0x100001, 0x40000, CRC(7ee7e688) SHA1(d65aa9c449e1d64f10d1be9727a9d93ab1571e65) )
r11160r11161
30083162   ROM_LOAD32_BYTE("e36-09", 0x000002, 0x040000, CRC(f16985e0) SHA1(a74cfee8f958e7a32354d4353eeb199a7fb1ce64) )
30093163   ROM_LOAD32_BYTE("e36-08", 0x000003, 0x040000, CRC(aa699e1b) SHA1(6bde0759940e0f238e4fa5bd228115574ff927d8) )
30103164
3165
3166
30113167   ROM_REGION(0x180000, "audiocpu", 0)   /* Sound CPU */
30123168   ROM_LOAD16_BYTE("e36-12", 0x100000, 0x40000, CRC(3bae39be) SHA1(777142ecc24799b934ed51ac4cd8700bb6da7e3c) )
30133169   ROM_LOAD16_BYTE("e36-13", 0x100001, 0x40000, CRC(94448e82) SHA1(d7766490318623be770545918391c5e6144dd619) )
r11160r11161
30603216   ROM_LOAD       ("e44-09.42", 0xb00000, 0x100000, CRC(a8e68eb7) SHA1(843bbb8a61bd4b9cbb14c7242281ce0c83c432ff) )
30613217   ROM_FILL       (             0x600000, 0x300000, 0 )
30623218
3219
3220
30633221   ROM_REGION(0x400000, "audiocpu", 0)   /* 68000 sound CPU */
30643222   ROM_LOAD16_BYTE("e44-20.51",      0x100000, 0x080000, CRC(4df7e051) SHA1(db0f5758458764a1c04116d5d5bbb20d4d36c875) )
30653223   ROM_LOAD16_BYTE("e44-21.52",      0x100001, 0x080000, CRC(d31b94b8) SHA1(41ee381d10254dc6e7163c5f353568539a96fc20) )
r11160r11161
30923250   ROM_LOAD       ("e46-10", 0x300000, 0x100000, CRC(1999b76a) SHA1(83d6d2efe250bf3b119982bbf701f9b9d856af2d) )
30933251   ROM_FILL       (          0x200000, 0x100000, 0 )
30943252
3253
3254
30953255   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
30963256   ROM_LOAD16_BYTE("e46-21", 0x100000, 0x40000, CRC(b466cff6) SHA1(0757984f15a6ac9939c1e8625d5b9bfcbc788acc) )
30973257   ROM_LOAD16_BYTE("e46-22", 0x100001, 0x40000, CRC(c67b767e) SHA1(19f3db6615d7a6ed4d2636b6beabe2f3ed6d0c38) )
r11160r11161
31323292   ROM_LOAD       ("e46-10", 0x300000, 0x100000, CRC(1999b76a) SHA1(83d6d2efe250bf3b119982bbf701f9b9d856af2d) )
31333293   ROM_FILL       (          0x200000, 0x100000, 0 )
31343294
3295
3296
31353297   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
31363298   ROM_LOAD16_BYTE("e46-19", 0x100000, 0x40000, CRC(2624eba0) SHA1(ba0b13bda241c648c7f8520106acd8c0c888fe29) )
31373299   ROM_LOAD16_BYTE("e46-20", 0x100001, 0x40000, CRC(065e934f) SHA1(0ec1b5ae33b1c43776b9327c9d380787d64ed5f9) )
r11160r11161
31683330   ROM_LOAD       ("e49-06", 0x300000, 0x100000, CRC(ec85f7ce) SHA1(9fead68c38fc9ca84d34d70343b13665978c362b) )
31693331   ROM_FILL       (          0x200000, 0x100000, 0 )
31703332
3333
3334
31713335   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 code */
31723336   ROM_LOAD16_BYTE("e49-13.32", 0x100000, 0x40000, CRC(83536f7f) SHA1(2252cee00ae260954cc76d92af8eb2a87d23cbfb) )
31733337   ROM_LOAD16_BYTE("e49-14.33", 0x100001, 0x40000, CRC(19815bdb) SHA1(38ad682236c7df0710055dd8dbdec30d5da0839d) )
r11160r11161
32043368   ROM_LOAD       ("e49-06", 0x300000, 0x100000, CRC(ec85f7ce) SHA1(9fead68c38fc9ca84d34d70343b13665978c362b) )
32053369   ROM_FILL       (          0x200000, 0x100000, 0 )
32063370
3371
3372
32073373   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 code */
32083374   ROM_LOAD16_BYTE("e49-13.32", 0x100000, 0x40000, CRC(83536f7f) SHA1(2252cee00ae260954cc76d92af8eb2a87d23cbfb) )
32093375   ROM_LOAD16_BYTE("e49-14.33", 0x100001, 0x40000, CRC(19815bdb) SHA1(38ad682236c7df0710055dd8dbdec30d5da0839d) )
r11160r11161
32403406   ROM_LOAD       ("e49-06", 0x300000, 0x100000, CRC(ec85f7ce) SHA1(9fead68c38fc9ca84d34d70343b13665978c362b) )
32413407   ROM_FILL       (          0x200000, 0x100000, 0 )
32423408
3409
3410
32433411   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 code */
32443412   ROM_LOAD16_BYTE("e49-13.32", 0x100000, 0x40000, CRC(83536f7f) SHA1(2252cee00ae260954cc76d92af8eb2a87d23cbfb) )
32453413   ROM_LOAD16_BYTE("e49-14.33", 0x100001, 0x40000, CRC(19815bdb) SHA1(38ad682236c7df0710055dd8dbdec30d5da0839d) )
r11160r11161
32773445   ROM_LOAD       ("e51-06.43", 0x600000, 0x200000, CRC(c240d6c8) SHA1(6f3b5224b7eb8783893375d432bbbfc37f81c230) )
32783446   ROM_FILL       (             0x400000, 0x200000, 0 )
32793447
3448
3449
32803450   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
32813451   ROM_LOAD16_BYTE("e51-13.32", 0x100000, 0x40000, CRC(3b9e3986) SHA1(26340bda0ad2ea580e2395135617966676a71ad5) )
32823452   ROM_LOAD16_BYTE("e51-14.33", 0x100001, 0x40000, CRC(1f9a5015) SHA1(5da38c5fe2a50bcde6bd46ab1cb9a56dbab1a882) )
r11160r11161
33123482   ROM_LOAD       ("e51-06.43", 0x600000, 0x200000, CRC(c240d6c8) SHA1(6f3b5224b7eb8783893375d432bbbfc37f81c230) )
33133483   ROM_FILL       (             0x400000, 0x200000, 0 )
33143484
3485
3486
33153487   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
33163488   ROM_LOAD16_BYTE("e51-13.32", 0x100000, 0x40000, CRC(3b9e3986) SHA1(26340bda0ad2ea580e2395135617966676a71ad5) )
33173489   ROM_LOAD16_BYTE("e51-14.33", 0x100001, 0x40000, CRC(1f9a5015) SHA1(5da38c5fe2a50bcde6bd46ab1cb9a56dbab1a882) )
r11160r11161
33473519   ROM_LOAD       ("e51-06.43", 0x600000, 0x200000, CRC(c240d6c8) SHA1(6f3b5224b7eb8783893375d432bbbfc37f81c230) )
33483520   ROM_FILL       (             0x400000, 0x200000, 0 )
33493521
3522
3523
33503524   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
33513525   ROM_LOAD16_BYTE("e51-13.32", 0x100000, 0x40000, CRC(3b9e3986) SHA1(26340bda0ad2ea580e2395135617966676a71ad5) )
33523526   ROM_LOAD16_BYTE("e51-14.33", 0x100001, 0x40000, CRC(1f9a5015) SHA1(5da38c5fe2a50bcde6bd46ab1cb9a56dbab1a882) )
r11160r11161
34243598   ROM_LOAD       ("e61-07.43", 0x600000, 0x200000, CRC(4a57965d) SHA1(8e80788e0f47fb242da9af3aa19077dc0ec829b8) )
34253599   ROM_FILL       (             0x400000, 0x200000, 0 )
34263600
3601
3602
34273603   ROM_REGION(0x140000, "audiocpu", 0)   /* 68000 sound CPU */
34283604   ROM_LOAD16_BYTE("e61-14.32", 0x100000, 0x20000, CRC(b905f4a7) SHA1(613b954e3e129fd44b4ce64958f16e5636012d6e) )
34293605   ROM_LOAD16_BYTE("e61-15.33", 0x100001, 0x20000, CRC(87909869) SHA1(7b90c23899a673966cac3352d375d17b83e66596) )
r11160r11161
34723648   ROM_LOAD16_BYTE("scr1-5.14",0x700001, 0x080000, CRC(24aba128) SHA1(b03804c738d86bfafc1f8fb91f8e77e878d2dc83) )
34733649   ROM_FILL       (            0x400000, 0x200000, 0 )
34743650
3651
3652
34753653   ROM_REGION(0x180000, "audiocpu", 0)   /* 68000 sound CPU */
34763654   ROM_LOAD16_BYTE("spro-1.66", 0x100000, 0x40000, CRC(18961bbb) SHA1(df054def35a49c0754356c15ec15336cbf28b063) )
34773655   ROM_LOAD16_BYTE("spro-0.65", 0x100001, 0x40000, CRC(2c64557a) SHA1(768007162d5d2cbe650c735bc1af2c10ed13b046) )
src/mame/drivers/igs011.c
r11160r11161
476476   COMBINE_DATA(&state->m_igs_dips_sel);
477477}
478478
479#define IGS_DIPS_R( NUM )                                                \
480static READ16_HANDLER( igs_##NUM##_dips_r )                                    \
481{ \
482   igs011_state *state = space->machine().driver_data<igs011_state>();                                                                  \
483   int i;                                                            \
484   UINT16 ret=0;                                                      \
485   static const char *const dipnames[] = { "DSW1", "DSW2", "DSW3", "DSW4", "DSW5" };   \
486                                                                  \
487   for (i = 0; i < NUM; i++)                                             \
488      if ((~state->m_igs_dips_sel) & (1 << i) )                                    \
489         ret = input_port_read(space->machine(), dipnames[i]);                     \
490                                                                  \
491   /* 0x0100 is blitter busy */                                          \
492   return   (ret & 0xff) | 0x0000;                                          \
479INLINE UINT16 igs_dips_r(address_space *space, int NUM)
480{
481   igs011_state *state = space->machine().driver_data<igs011_state>();
482   int i;
483   UINT16 ret=0;
484   static const char *const dipnames[] = { "DSW1", "DSW2", "DSW3", "DSW4", "DSW5" };
485
486   for (i = 0; i < NUM; i++)
487      if ((~state->m_igs_dips_sel) & (1 << i) )
488         ret = input_port_read(space->machine(), dipnames[i]);
489   /* 0x0100 is blitter busy */
490   return   (ret & 0xff) | 0x0000;
493491}
494492
495493// Games have 3 to 5 dips
496IGS_DIPS_R( 3 )
497IGS_DIPS_R( 4 )
498IGS_DIPS_R( 5 )
494static READ16_HANDLER( igs_3_dips_r ) { return igs_dips_r(space, 3); }
495static READ16_HANDLER( igs_4_dips_r ) { return igs_dips_r(space, 4); }
496static READ16_HANDLER( igs_5_dips_r ) { return igs_dips_r(space, 5); }
499497
500498/***************************************************************************
501499
src/mame/drivers/cave.c
r11160r11161
441441   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0x00ff)               // YMZ280
442442/**/AM_RANGE(0x400000, 0x407fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)      // Sprites
443443/**/AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_BASE_MEMBER(cave_state, m_spriteram_2)                     // Sprites?
444/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
445/**/AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram_1)         // Layer 1
444/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
445/**/AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram[1])         // Layer 1
446446/**/AM_RANGE(0x708000, 0x708fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
447447/**/AM_RANGE(0x710000, 0x710bff) AM_READONLY                                             // ?
448448   AM_RANGE(0x710c00, 0x710fff) AM_RAM                                                   // ?
449449   AM_RANGE(0x800000, 0x800007) AM_READ(cave_irq_cause_r)                                    // IRQ Cause
450450   AM_RANGE(0x800000, 0x80007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                  // Video Regs
451/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                        // Layer 0 Control
452/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_1)                        // Layer 1 Control
451/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                        // Layer 0 Control
452/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[1])                        // Layer 1 Control
453453   AM_RANGE(0xb00000, 0xb00001) AM_READ_PORT("IN0")                                       // Inputs
454454   AM_RANGE(0xb00002, 0xb00003) AM_READ_PORT("IN1")                                       // Inputs + EEPROM
455455   AM_RANGE(0xc00000, 0xc00001) AM_DEVWRITE("eeprom", cave_eeprom_msb_w)                        // EEPROM
r11160r11161
466466   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0x00ff)               // YMZ280
467467/**/AM_RANGE(0x400000, 0x407fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)      // Sprites
468468/**/AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_BASE_MEMBER(cave_state, m_spriteram_2)                     // Sprites?
469/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
470/**/AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram_1)         // Layer 1
471/**/AM_RANGE(0x700000, 0x70ffff) AM_RAM_WRITE(cave_vram_2_8x8_w) AM_BASE_MEMBER(cave_state, m_vram_2)      // Layer 2
469/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
470/**/AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram[1])         // Layer 1
471/**/AM_RANGE(0x700000, 0x70ffff) AM_RAM_WRITE(cave_vram_2_8x8_w) AM_BASE_MEMBER(cave_state, m_vram[2])      // Layer 2
472472   AM_RANGE(0x800000, 0x800007) AM_READ(cave_irq_cause_r)                                    // IRQ Cause
473473   AM_RANGE(0x800000, 0x80007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                  // Video Regs
474/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                        // Layer 0 Control
475/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_1)                        // Layer 1 Control
476/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_2)                        // Layer 2 Control
474/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                        // Layer 0 Control
475/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[1])                        // Layer 1 Control
476/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[2])                        // Layer 2 Control
477477/**/AM_RANGE(0xc00000, 0xc0ffff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
478478   AM_RANGE(0xd00000, 0xd00001) AM_READ_PORT("IN0")                                       // Inputs
479479   AM_RANGE(0xd00002, 0xd00003) AM_READ_PORT("IN1")                                       // Inputs + EEPROM
r11160r11161
514514static ADDRESS_MAP_START( donpachi_map, AS_PROGRAM, 16 )
515515   AM_RANGE(0x000000, 0x07ffff) AM_ROM                                                      // ROM
516516   AM_RANGE(0x100000, 0x10ffff) AM_RAM                                                      // RAM
517   AM_RANGE(0x200000, 0x207fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram_1)            // Layer 1
518   AM_RANGE(0x300000, 0x307fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)            // Layer 0
519   AM_RANGE(0x400000, 0x407fff) AM_RAM_WRITE(cave_vram_2_8x8_w) AM_BASE_MEMBER(cave_state, m_vram_2)         // Layer 2
517   AM_RANGE(0x200000, 0x207fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram[1])            // Layer 1
518   AM_RANGE(0x300000, 0x307fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])            // Layer 0
519   AM_RANGE(0x400000, 0x407fff) AM_RAM_WRITE(cave_vram_2_8x8_w) AM_BASE_MEMBER(cave_state, m_vram[2])         // Layer 2
520520   AM_RANGE(0x500000, 0x507fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)         // Sprites
521521   AM_RANGE(0x508000, 0x50ffff) AM_RAM AM_BASE_MEMBER(cave_state, m_spriteram_2)                        // Sprites?
522/**/AM_RANGE(0x600000, 0x600005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_1)                           // Layer 1 Control
523/**/AM_RANGE(0x700000, 0x700005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                           // Layer 0 Control
524/**/AM_RANGE(0x800000, 0x800005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_2)                           // Layer 2 Control
522/**/AM_RANGE(0x600000, 0x600005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[1])                           // Layer 1 Control
523/**/AM_RANGE(0x700000, 0x700005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                           // Layer 0 Control
524/**/AM_RANGE(0x800000, 0x800005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[2])                           // Layer 2 Control
525525   AM_RANGE(0x900000, 0x90007f) AM_RAM_READ(donpachi_videoregs_r) AM_BASE_MEMBER(cave_state, m_videoregs)   // Video Regs
526526/**/AM_RANGE(0xa08000, 0xa08fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)      // Palette
527527   AM_RANGE(0xb00000, 0xb00003) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0x00ff)               // M6295
r11160r11161
543543   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0x00ff)               // YMZ280
544544/**/AM_RANGE(0x400000, 0x407fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)      // Sprites
545545/**/AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_BASE_MEMBER(cave_state, m_spriteram_2)                     // Sprites?
546/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
547/**/AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram_1)         // Layer 1
548/**/AM_RANGE(0x700000, 0x707fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram_2)         // Layer 2
546/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
547/**/AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram[1])         // Layer 1
548/**/AM_RANGE(0x700000, 0x707fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram[2])         // Layer 2
549549   AM_RANGE(0x800000, 0x800007) AM_READ(cave_irq_cause_r)                                    // IRQ Cause
550550   AM_RANGE(0x800000, 0x80007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                  // Video Regs
551/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                        // Layer 0 Control
552/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_1)                        // Layer 1 Control
553/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_2)                        // Layer 2 Control
551/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                        // Layer 0 Control
552/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[1])                        // Layer 1 Control
553/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[2])                        // Layer 2 Control
554554/**/AM_RANGE(0xc00000, 0xc0ffff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
555555   AM_RANGE(0xd00000, 0xd00001) AM_READ_PORT("IN0" )                                       // Inputs
556556   AM_RANGE(0xd00002, 0xd00003) AM_READ_PORT("IN1" )                                       // Inputs + EEPROM
r11160r11161
568568   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0x00ff)               // YMZ280
569569   AM_RANGE(0x400000, 0x407fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)      // Sprite bank 1
570570   AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_BASE_MEMBER(cave_state, m_spriteram_2)                     // Sprite bank 2
571   AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
571   AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
572572   AM_RANGE(0x508000, 0x50ffff) AM_RAM                                                   // More Layer 0, Tested but not used?
573   AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram_1)         // Layer 1
573   AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram[1])         // Layer 1
574574   AM_RANGE(0x608000, 0x60ffff) AM_RAM                                                   // More Layer 1, Tested but not used?
575   AM_RANGE(0x700000, 0x707fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram_2)         // Layer 2
575   AM_RANGE(0x700000, 0x707fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram[2])         // Layer 2
576576   AM_RANGE(0x708000, 0x70ffff) AM_RAM                                                   // More Layer 2, Tested but not used?
577577   AM_RANGE(0x800000, 0x800007) AM_READ(cave_irq_cause_r)                                    // IRQ Cause
578578   AM_RANGE(0x800000, 0x80007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                  // Video Regs
579/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                        // Layer 0 Control
580/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_1)                        // Layer 1 Control
581/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_2)                        // Layer 2 Control
579/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                        // Layer 0 Control
580/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[1])                        // Layer 1 Control
581/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[2])                        // Layer 2 Control
582582   AM_RANGE(0xc00000, 0xc0ffff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
583583   AM_RANGE(0xd00010, 0xd00011) AM_READ_PORT("IN0")                                       // Inputs
584584   AM_RANGE(0xd00010, 0xd00011) AM_WRITE(gaia_coin_lsb_w)                                    // Coin counter only
r11160r11161
599599   AM_RANGE(0x300000, 0x30007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                  // Video Regs
600600/**/AM_RANGE(0x400000, 0x407fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)      // Sprites
601601/**/AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_BASE_MEMBER(cave_state, m_spriteram_2)                     // Sprites?
602/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
603/**/AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram_1)         // Layer 1
604/**/AM_RANGE(0x700000, 0x707fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram_2)         // Layer 2
602/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
603/**/AM_RANGE(0x600000, 0x607fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram[1])         // Layer 1
604/**/AM_RANGE(0x700000, 0x707fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram[2])         // Layer 2
605605   AM_RANGE(0x800000, 0x800003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0x00ff)               // YMZ280
606/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                        // Layer 0 Control
607/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_1)                        // Layer 1 Control
608/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_2)                        // Layer 2 Control
606/**/AM_RANGE(0x900000, 0x900005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                        // Layer 0 Control
607/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[1])                        // Layer 1 Control
608/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[2])                        // Layer 2 Control
609609/**/AM_RANGE(0xc00000, 0xc0ffff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
610610   AM_RANGE(0xd00010, 0xd00011) AM_READ_PORT("IN0")                                       // Inputs
611611   AM_RANGE(0xd00010, 0xd00011) AM_DEVWRITE("eeprom", cave_eeprom_lsb_w)                        // EEPROM
r11160r11161
623623   AM_RANGE(0x000000, 0x0fffff) AM_ROM                                                   // ROM
624624   AM_RANGE(0x300000, 0x30ffff) AM_RAM                                                   // RAM
625625/**/AM_RANGE(0x408000, 0x408fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
626/**/AM_RANGE(0x880000, 0x887fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
627/**/AM_RANGE(0x900000, 0x907fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram_1)         // Layer 1
628/**/AM_RANGE(0x980000, 0x987fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram_2)         // Layer 2
626/**/AM_RANGE(0x880000, 0x887fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
627/**/AM_RANGE(0x900000, 0x907fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram[1])         // Layer 1
628/**/AM_RANGE(0x980000, 0x987fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram[2])         // Layer 2
629629   AM_RANGE(0xa80000, 0xa80007) AM_READ(cave_irq_cause_r)                                    // IRQ Cause
630630//  AM_RANGE(0xa8006e, 0xa8006f) AM_READ(soundlatch_ack_r)                                              // From Sound CPU
631631   AM_RANGE(0xa8006e, 0xa8006f) AM_WRITE(sound_cmd_w)                                       // To Sound CPU
632632   AM_RANGE(0xa80000, 0xa8007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                  // Video Regs
633/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                        // Layer 0 Control
634/**/AM_RANGE(0xb80000, 0xb80005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_1)                        // Layer 1 Control
635/**/AM_RANGE(0xc00000, 0xc00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_2)                        // Layer 2 Control
633/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                        // Layer 0 Control
634/**/AM_RANGE(0xb80000, 0xb80005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[1])                        // Layer 1 Control
635/**/AM_RANGE(0xc00000, 0xc00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[2])                        // Layer 2 Control
636636   AM_RANGE(0xc80000, 0xc80001) AM_READ_PORT("IN0")                                       // Inputs
637637   AM_RANGE(0xc80002, 0xc80003) AM_READ_PORT("IN1")                                       // Inputs + EEPROM
638638   AM_RANGE(0xd00000, 0xd00001) AM_DEVWRITE("eeprom", hotdogst_eeprom_msb_w)                     // EEPROM
r11160r11161
713713
714714static ADDRESS_MAP_START( korokoro_map, AS_PROGRAM, 16 )
715715   AM_RANGE(0x000000, 0x07ffff) AM_ROM                                                      // ROM
716   AM_RANGE(0x100000, 0x107fff) AM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)               // Layer 0
717   AM_RANGE(0x140000, 0x140005) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_vctrl_0)                     // Layer 0 Control
716   AM_RANGE(0x100000, 0x107fff) AM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])               // Layer 0
717   AM_RANGE(0x140000, 0x140005) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_vctrl[0])                     // Layer 0 Control
718718   AM_RANGE(0x180000, 0x187fff) AM_WRITEONLY AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)   // Sprites
719719   AM_RANGE(0x1c0000, 0x1c0007) AM_READ(cave_irq_cause_r)                                       // IRQ Cause
720720   AM_RANGE(0x1c0000, 0x1c007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                     // Video Regs
r11160r11161
731731
732732static ADDRESS_MAP_START( crusherm_map, AS_PROGRAM, 16 )
733733   AM_RANGE(0x000000, 0x07ffff) AM_ROM                                                      // ROM
734   AM_RANGE(0x100000, 0x107fff) AM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)               // Layer 0
735   AM_RANGE(0x140000, 0x140005) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_vctrl_0)                     // Layer 0 Control
734   AM_RANGE(0x100000, 0x107fff) AM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])               // Layer 0
735   AM_RANGE(0x140000, 0x140005) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_vctrl[0])                     // Layer 0 Control
736736   AM_RANGE(0x180000, 0x187fff) AM_WRITEONLY AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)   // Sprites
737737   AM_RANGE(0x200000, 0x207fff) AM_WRITEONLY AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
738738   AM_RANGE(0x240000, 0x240003) AM_DEVWRITE8( "ymz", ymz280b_w, 0x00ff)                           // YMZ280
r11160r11161
759759   AM_RANGE(0x300068, 0x300069) AM_WRITE(watchdog_reset16_w)                                 // Watchdog
760760   AM_RANGE(0x30006e, 0x30006f) AM_READWRITE(soundlatch_ack_r, sound_cmd_w)                     // From Sound CPU
761761   AM_RANGE(0x300000, 0x30007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                  // Video Regs
762   AM_RANGE(0x400000, 0x407fff) AM_RAM_WRITE(cave_vram_1_8x8_w) AM_BASE_MEMBER(cave_state, m_vram_1)      // Layer 1
763/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_8x8_w) AM_BASE_MEMBER(cave_state, m_vram_0)      // Layer 0
764/**/AM_RANGE(0x600000, 0x600005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_1)                        // Layer 1 Control
765/**/AM_RANGE(0x700000, 0x700005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                        // Layer 0 Control
762   AM_RANGE(0x400000, 0x407fff) AM_RAM_WRITE(cave_vram_1_8x8_w) AM_BASE_MEMBER(cave_state, m_vram[1])      // Layer 1
763/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_8x8_w) AM_BASE_MEMBER(cave_state, m_vram[0])      // Layer 0
764/**/AM_RANGE(0x600000, 0x600005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[1])                        // Layer 1 Control
765/**/AM_RANGE(0x700000, 0x700005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                        // Layer 0 Control
766766   AM_RANGE(0x800000, 0x800001) AM_READ_PORT("IN0")                                       // Inputs
767767   AM_RANGE(0x800002, 0x800003) AM_READ_PORT("IN1")                                       // Inputs + EEPROM
768768   AM_RANGE(0x900000, 0x900001) AM_DEVWRITE("eeprom", cave_eeprom_msb_w)                        // EEPROM
r11160r11161
781781   AM_RANGE(0x200000, 0x27ffff) AM_ROM                                                   // ROM
782782   AM_RANGE(0x408000, 0x408fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
783783   AM_RANGE(0x600000, 0x600001) AM_READ(watchdog_reset16_r)                                 // Watchdog?
784   AM_RANGE(0x880000, 0x887fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram_2)         // Layer 2
784   AM_RANGE(0x880000, 0x887fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram[2])         // Layer 2
785785   AM_RANGE(0x888000, 0x88ffff) AM_RAM                                                   //
786   AM_RANGE(0x900000, 0x907fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram_1)         // Layer 1
786   AM_RANGE(0x900000, 0x907fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram[1])         // Layer 1
787787   AM_RANGE(0x908000, 0x90ffff) AM_RAM                                                   //
788   AM_RANGE(0x980000, 0x987fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
788   AM_RANGE(0x980000, 0x987fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
789789   AM_RANGE(0x988000, 0x98ffff) AM_RAM                                                   //
790790   AM_RANGE(0xa80000, 0xa80007) AM_READ(cave_irq_cause_r)                                    // IRQ Cause
791791   AM_RANGE(0xa80068, 0xa80069) AM_WRITE(watchdog_reset16_w)                                 // Watchdog?
792792   AM_RANGE(0xa8006c, 0xa8006d) AM_READ(soundflags_ack_r) AM_WRITENOP                           // Communication
793793   AM_RANGE(0xa8006e, 0xa8006f) AM_READWRITE(soundlatch_ack_r, sound_cmd_w)                     // From Sound CPU
794794   AM_RANGE(0xa80000, 0xa8007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                  // Video Regs
795/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_2)                        // Layer 2 Control
796/**/AM_RANGE(0xb80000, 0xb80005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_1)                        // Layer 1 Control
797/**/AM_RANGE(0xc00000, 0xc00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                        // Layer 0 Control
795/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[2])                        // Layer 2 Control
796/**/AM_RANGE(0xb80000, 0xb80005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[1])                        // Layer 1 Control
797/**/AM_RANGE(0xc00000, 0xc00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                        // Layer 0 Control
798798   AM_RANGE(0xc80000, 0xc80001) AM_READ_PORT("IN0")                                       // Inputs
799799   AM_RANGE(0xc80002, 0xc80003) AM_READ_PORT("IN1")                                       // Inputs + EEPROM
800800   AM_RANGE(0xd00000, 0xd00001) AM_DEVWRITE("eeprom", metmqstr_eeprom_msb_w)                     // EEPROM
r11160r11161
812812   return ~8 + ((eeprom_read_bit(device) & 1) ? 8 : 0);
813813}
814814
815INLINE void vctrl_w(UINT16 *VCTRL, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask)
815INLINE void vctrl_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int GFX)
816816{
817   cave_state *state = space->machine().driver_data<cave_state>();
818   UINT16 *VCTRL = state->m_vctrl[GFX];
817819   if (offset == 4 / 2)
818820   {
819821      switch (data & 0x000f)
r11160r11161
827829   }
828830   COMBINE_DATA(&VCTRL[offset]);
829831}
830static WRITE16_HANDLER( pwrinst2_vctrl_0_w )   { cave_state *state = space->machine().driver_data<cave_state>(); vctrl_w(state->m_vctrl_0, offset, data, mem_mask); }
831static WRITE16_HANDLER( pwrinst2_vctrl_1_w )   { cave_state *state = space->machine().driver_data<cave_state>(); vctrl_w(state->m_vctrl_1, offset, data, mem_mask); }
832static WRITE16_HANDLER( pwrinst2_vctrl_2_w )   { cave_state *state = space->machine().driver_data<cave_state>(); vctrl_w(state->m_vctrl_2, offset, data, mem_mask); }
833static WRITE16_HANDLER( pwrinst2_vctrl_3_w )   { cave_state *state = space->machine().driver_data<cave_state>(); vctrl_w(state->m_vctrl_3, offset, data, mem_mask); }
832static WRITE16_HANDLER( pwrinst2_vctrl_0_w )   { vctrl_w(space, offset, data, mem_mask, 0); }
833static WRITE16_HANDLER( pwrinst2_vctrl_1_w )   { vctrl_w(space, offset, data, mem_mask, 1); }
834static WRITE16_HANDLER( pwrinst2_vctrl_2_w )   { vctrl_w(space, offset, data, mem_mask, 2); }
835static WRITE16_HANDLER( pwrinst2_vctrl_3_w )   { vctrl_w(space, offset, data, mem_mask, 3); }
834836
835837static ADDRESS_MAP_START( pwrinst2_map, AS_PROGRAM, 16 )
836838   AM_RANGE(0x000000, 0x1fffff) AM_ROM                                                      // ROM
r11160r11161
839841   AM_RANGE(0x500002, 0x500003) AM_READ_PORT("IN1")                                          //
840842   AM_RANGE(0x600000, 0x6fffff) AM_ROM AM_REGION("user1", 0)                                    // extra data ROM space
841843   AM_RANGE(0x700000, 0x700001) AM_DEVWRITE("eeprom", cave_eeprom_msb_w)                           // EEPROM
842   AM_RANGE(0x800000, 0x807fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram_2)            // Layer 2
843   AM_RANGE(0x880000, 0x887fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)            // Layer 0
844   AM_RANGE(0x900000, 0x907fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram_1)            // Layer 1
845   AM_RANGE(0x980000, 0x987fff) AM_RAM_WRITE(cave_vram_3_8x8_w) AM_BASE_MEMBER(cave_state, m_vram_3)         // Layer 3
844   AM_RANGE(0x800000, 0x807fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram[2])            // Layer 2
845   AM_RANGE(0x880000, 0x887fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])            // Layer 0
846   AM_RANGE(0x900000, 0x907fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram[1])            // Layer 1
847   AM_RANGE(0x980000, 0x987fff) AM_RAM_WRITE(cave_vram_3_8x8_w) AM_BASE_MEMBER(cave_state, m_vram[3])         // Layer 3
846848   AM_RANGE(0xa00000, 0xa07fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)         // Sprites
847849   AM_RANGE(0xa08000, 0xa0ffff) AM_RAM AM_BASE_MEMBER(cave_state, m_spriteram_2)                        // Sprites?
848850   AM_RANGE(0xa10000, 0xa1ffff) AM_RAM                                                      // Sprites?
849851   AM_RANGE(0xa80000, 0xa8007f) AM_RAM_READ(donpachi_videoregs_r) AM_BASE_MEMBER(cave_state, m_videoregs)   // Video Regs
850/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM_WRITE(pwrinst2_vctrl_2_w) AM_BASE_MEMBER(cave_state, m_vctrl_2)      // Layer 2 Control
851/**/AM_RANGE(0xb80000, 0xb80005) AM_RAM_WRITE(pwrinst2_vctrl_0_w) AM_BASE_MEMBER(cave_state, m_vctrl_0)      // Layer 0 Control
852/**/AM_RANGE(0xc00000, 0xc00005) AM_RAM_WRITE(pwrinst2_vctrl_1_w) AM_BASE_MEMBER(cave_state, m_vctrl_1)      // Layer 1 Control
853/**/AM_RANGE(0xc80000, 0xc80005) AM_RAM_WRITE(pwrinst2_vctrl_3_w) AM_BASE_MEMBER(cave_state, m_vctrl_3)      // Layer 3 Control
852/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM_WRITE(pwrinst2_vctrl_2_w) AM_BASE_MEMBER(cave_state, m_vctrl[2])      // Layer 2 Control
853/**/AM_RANGE(0xb80000, 0xb80005) AM_RAM_WRITE(pwrinst2_vctrl_0_w) AM_BASE_MEMBER(cave_state, m_vctrl[0])      // Layer 0 Control
854/**/AM_RANGE(0xc00000, 0xc00005) AM_RAM_WRITE(pwrinst2_vctrl_1_w) AM_BASE_MEMBER(cave_state, m_vctrl[1])      // Layer 1 Control
855/**/AM_RANGE(0xc80000, 0xc80005) AM_RAM_WRITE(pwrinst2_vctrl_3_w) AM_BASE_MEMBER(cave_state, m_vctrl[3])      // Layer 3 Control
854856   AM_RANGE(0xd80000, 0xd80001) AM_READ(soundlatch_ack_r)                                       // ? From Sound CPU
855857   AM_RANGE(0xe00000, 0xe00001) AM_WRITE(sound_cmd_w)                                          // To Sound CPU
856858   AM_RANGE(0xe80000, 0xe80001) AM_DEVREAD("eeprom", pwrinst2_eeprom_r)                           // EEPROM
r11160r11161
883885   AM_RANGE(0x600000, 0x600001) AM_READ(sailormn_input0_r)                                    // Inputs + Watchdog!
884886   AM_RANGE(0x600002, 0x600003) AM_READ_PORT("IN1")                                       // Inputs + EEPROM
885887   AM_RANGE(0x700000, 0x700001) AM_DEVWRITE("eeprom", sailormn_eeprom_msb_w)                     // EEPROM
886   AM_RANGE(0x800000, 0x807fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
887   AM_RANGE(0x880000, 0x887fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram_1)         // Layer 1
888   AM_RANGE(0x900000, 0x907fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram_2)         // Layer 2
888   AM_RANGE(0x800000, 0x807fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
889   AM_RANGE(0x880000, 0x887fff) AM_RAM_WRITE(cave_vram_1_w) AM_BASE_MEMBER(cave_state, m_vram[1])         // Layer 1
890   AM_RANGE(0x900000, 0x907fff) AM_RAM_WRITE(cave_vram_2_w) AM_BASE_MEMBER(cave_state, m_vram[2])         // Layer 2
889891   AM_RANGE(0x908000, 0x908001) AM_RAM                                                   // (agallet)
890/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                        // Layer 0 Control
891/**/AM_RANGE(0xa80000, 0xa80005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_1)                        // Layer 1 Control
892/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_2)                        // Layer 2 Control
892/**/AM_RANGE(0xa00000, 0xa00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                        // Layer 0 Control
893/**/AM_RANGE(0xa80000, 0xa80005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[1])                        // Layer 1 Control
894/**/AM_RANGE(0xb00000, 0xb00005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[2])                        // Layer 2 Control
893895   AM_RANGE(0xb80000, 0xb80007) AM_READ(cave_irq_cause_r)                                    // IRQ Cause (bit 2 tested!)
894896   AM_RANGE(0xb8006c, 0xb8006d) AM_READ(soundflags_ack_r)                                    // Communication
895897   AM_RANGE(0xb8006e, 0xb8006f) AM_READ(soundlatch_ack_r)                                    // From Sound CPU
r11160r11161
950952   AM_RANGE(0x200000, 0x207fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)      // Sprites
951953   AM_RANGE(0x208000, 0x20ffff) AM_RAM AM_BASE_MEMBER(cave_state, m_spriteram_2)                     // Sprite bank 2
952954   AM_RANGE(0x304000, 0x307fff) AM_WRITE(cave_vram_0_w)                                    // Layer 0 - 16x16 tiles mapped here
953   AM_RANGE(0x300000, 0x307fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
954   AM_RANGE(0x400000, 0x400005) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_vctrl_0)                  // Layer 0 Control
955   AM_RANGE(0x300000, 0x307fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
956   AM_RANGE(0x400000, 0x400005) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_vctrl[0])                  // Layer 0 Control
955957   AM_RANGE(0x500000, 0x50ffff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
956958   AM_RANGE(0x600000, 0x600001) AM_READ_PORT("IN0")                                       // Inputs + EEPROM + Hopper
957959   AM_RANGE(0x600002, 0x600003) AM_READ_PORT("IN1")                                       // Inputs
r11160r11161
990992   AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_SHARE("nvram")                                    // RAM
991993   AM_RANGE(0x200000, 0x207fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)      // Sprites
992994   AM_RANGE(0x208000, 0x20ffff) AM_RAM AM_BASE_MEMBER(cave_state, m_spriteram_2)                     // Sprite bank 2
993   AM_RANGE(0x300000, 0x307fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
995   AM_RANGE(0x300000, 0x307fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
994996   AM_RANGE(0x400000, 0x400007) AM_READ(cave_irq_cause_r)                                    // IRQ Cause
995997   AM_RANGE(0x400068, 0x400069) AM_WRITE(watchdog_reset16_w)                                 // Watchdog
996998   AM_RANGE(0x400000, 0x40007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                  // Video Regs
997   AM_RANGE(0x500000, 0x500005) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_vctrl_0)                  // Layer 0 Control
999   AM_RANGE(0x500000, 0x500005) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_vctrl[0])                  // Layer 0 Control
9981000   AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
9991001   AM_RANGE(0x700000, 0x700001) AM_READ_PORT("IN0")                                       // Inputs + EEPROM + Hopper
10001002   AM_RANGE(0x700002, 0x700003) AM_READ_PORT("IN1")                                       // Inputs
r11160r11161
10141016   AM_RANGE(0x300000, 0x300003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0x00ff)               // YMZ280
10151017/**/AM_RANGE(0x400000, 0x407fff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_spriteram, m_spriteram_size)      // Sprites
10161018/**/AM_RANGE(0x408000, 0x40ffff) AM_RAM AM_BASE_MEMBER(cave_state, m_spriteram_2)                     // Sprites?
1017/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram_0)         // Layer 0
1019/**/AM_RANGE(0x500000, 0x507fff) AM_RAM_WRITE(cave_vram_0_w) AM_BASE_MEMBER(cave_state, m_vram[0])         // Layer 0
10181020   AM_RANGE(0x600000, 0x600007) AM_READ(cave_irq_cause_r)                                    // IRQ Cause
10191021   AM_RANGE(0x600000, 0x60007f) AM_WRITEONLY AM_BASE_MEMBER(cave_state, m_videoregs)                  // Video Regs
1020/**/AM_RANGE(0x700000, 0x700005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl_0)                        // Layer 0 Control
1022/**/AM_RANGE(0x700000, 0x700005) AM_RAM AM_BASE_MEMBER(cave_state, m_vctrl[0])                        // Layer 0 Control
10211023/**/AM_RANGE(0x800000, 0x80ffff) AM_RAM AM_BASE_SIZE_MEMBER(cave_state, m_paletteram, m_paletteram_size)   // Palette
10221024   AM_RANGE(0x900000, 0x900001) AM_READ_PORT("IN0")                                       // Inputs
10231025   AM_RANGE(0x900002, 0x900003) AM_READ_PORT("IN1")                                       // Inputs + EEPROM
src/mame/drivers/fuukifg3.c
r11160r11161
234234   AM_RANGE(0x400000, 0x40ffff) AM_RAM                                                // Work RAM
235235   AM_RANGE(0x410000, 0x41ffff) AM_RAM                                                // Work RAM (used by asurabus)
236236
237   AM_RANGE(0x500000, 0x501fff) AM_RAM_WRITE(fuuki32_vram_0_w) AM_BASE_MEMBER(fuuki32_state, m_vram_0)               // Tilemap 1
238   AM_RANGE(0x502000, 0x503fff) AM_RAM_WRITE(fuuki32_vram_1_w) AM_BASE_MEMBER(fuuki32_state, m_vram_1)               // Tilemap 2
239   AM_RANGE(0x504000, 0x505fff) AM_RAM_WRITE(fuuki32_vram_2_w) AM_BASE_MEMBER(fuuki32_state, m_vram_2)               // Tilemap bg
240   AM_RANGE(0x506000, 0x507fff) AM_RAM_WRITE(fuuki32_vram_3_w) AM_BASE_MEMBER(fuuki32_state, m_vram_3)               // Tilemap bg2
237   AM_RANGE(0x500000, 0x501fff) AM_RAM_WRITE(fuuki32_vram_0_w) AM_BASE_MEMBER(fuuki32_state, m_vram[0])               // Tilemap 1
238   AM_RANGE(0x502000, 0x503fff) AM_RAM_WRITE(fuuki32_vram_1_w) AM_BASE_MEMBER(fuuki32_state, m_vram[1])               // Tilemap 2
239   AM_RANGE(0x504000, 0x505fff) AM_RAM_WRITE(fuuki32_vram_2_w) AM_BASE_MEMBER(fuuki32_state, m_vram[2])               // Tilemap bg
240   AM_RANGE(0x506000, 0x507fff) AM_RAM_WRITE(fuuki32_vram_3_w) AM_BASE_MEMBER(fuuki32_state, m_vram[3])               // Tilemap bg2
241241   AM_RANGE(0x508000, 0x517fff) AM_RAM                                                // More tilemap, or linescroll? Seems to be empty all of the time
242242
243243   AM_RANGE(0x600000, 0x601fff) AM_RAM AM_BASE_SIZE_MEMBER(fuuki32_state, m_spriteram, m_spriteram_size)               // Sprites
src/mame/drivers/atarigt.c
r11160r11161
204204
205205   if (ACCESSING_BITS_16_23)
206206   {
207//      cage_reset_w(data & 0x00100000);
207      //cage_reset_w(space, data & 0x00100000);
208208      coin_counter_w(space->machine(), 0, data & 0x00080000);
209209      coin_counter_w(space->machine(), 1, data & 0x00010000);
210210   }
r11160r11161
238238   UINT32 result = 0;
239239
240240   if (ACCESSING_BITS_0_15)
241      result |= cage_control_r();
241      result |= cage_control_r(space->machine());
242242   if (ACCESSING_BITS_16_31)
243      result |= main_from_cage_r(space) << 16;
243      result |= cage_main_r(space) << 16;
244244   return result;
245245}
246246
r11160r11161
250250   if (ACCESSING_BITS_0_15)
251251      cage_control_w(space->machine(), data);
252252   if (ACCESSING_BITS_16_31)
253      main_to_cage_w(data >> 16);
253      cage_main_w(space, data >> 16);
254254}
255255
256256
src/mame/drivers/shisen.c
r11160r11161
5353static ADDRESS_MAP_START( shisen_io_map, AS_IO, 8 )
5454   ADDRESS_MAP_GLOBAL_MASK(0xff)
5555   AM_RANGE(0x00, 0x00) AM_READWRITE(sichuan2_dsw1_r, sichuan2_coin_w)
56   AM_RANGE(0x01, 0x01) AM_READ_PORT("DSW2") AM_WRITE(m72_sound_command_byte_w)
56   AM_RANGE(0x01, 0x01) AM_READ_PORT("DSW2") AM_DEVWRITE("m72", m72_sound_command_byte_w)
5757   AM_RANGE(0x02, 0x02) AM_READ_PORT("P1") AM_WRITE(sichuan2_bankswitch_w)
5858   AM_RANGE(0x03, 0x03) AM_READ_PORT("P2")
5959   AM_RANGE(0x04, 0x04) AM_READ_PORT("COIN")
r11160r11161
6868   ADDRESS_MAP_GLOBAL_MASK(0xff)
6969   AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
7070   AM_RANGE(0x80, 0x80) AM_READ(soundlatch_r)
71   AM_RANGE(0x80, 0x81) AM_WRITE(shisen_sample_addr_w)
72   AM_RANGE(0x82, 0x82) AM_DEVWRITE("dac", m72_sample_w)
73   AM_RANGE(0x83, 0x83) AM_WRITE(m72_sound_irq_ack_w)
74   AM_RANGE(0x84, 0x84) AM_READ(m72_sample_r)
71   AM_RANGE(0x80, 0x81) AM_DEVWRITE("m72", shisen_sample_addr_w)
72   AM_RANGE(0x82, 0x82) AM_DEVWRITE("m72", m72_sample_w)
73   AM_RANGE(0x83, 0x83) AM_DEVWRITE("m72", m72_sound_irq_ack_w)
74   AM_RANGE(0x84, 0x84) AM_DEVREAD("m72", m72_sample_r)
7575ADDRESS_MAP_END
7676
7777
r11160r11161
222222   MCFG_CPU_IO_MAP(shisen_sound_io_map)
223223   MCFG_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1? (Vigilante) */
224224                        /* IRQs are generated by main Z80 and YM2151 */
225
226   MCFG_SOUND_START(m72)
227   MCFG_SOUND_RESET(m72)
228
229225   /* video hardware */
230226   MCFG_SCREEN_ADD("screen", RASTER)
231227   MCFG_SCREEN_REFRESH_RATE(55)
r11160r11161
243239   /* sound hardware */
244240   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
245241
242   MCFG_SOUND_ADD("m72", M72, 0)
243
246244   MCFG_SOUND_ADD("ymsnd", YM2151, 3579545)
247245   MCFG_SOUND_CONFIG(ym2151_config)
248246   MCFG_SOUND_ROUTE(0, "lspeaker", 0.5)
src/osd/windows/windows.mak
r11160r11161
222222
223223# debug build: enable guard pages on all memory allocations
224224ifdef DEBUG
225#DEFS += -DMALLOC_DEBUG
225DEFS += -DMALLOC_DEBUG
226226endif
227227
228228
src/osd/windows/winmisc.c
r11160r11161
4545#include <tchar.h>
4646
4747// MAME headers
48#include "osdcore.h"
48#include "emucore.h"
4949
5050// MAMEOS headers
5151#include "winutf8.h"
src/emu/drivers/xtal.h
r11160r11161
188188   XTAL_73_728MHz     = 73728000,      /* Ms. Pac-Man/Galaga 20th Anniversary */
189189   XTAL_100MHz       = 100000000,   /* PSX-based Namco System 12, Vegas, Sony ZN1-2-based */
190190   XTAL_101_4912MHz   = 101491200,   /* PSX-based Namco System 10 */
191   XTAL_200MHz         = 200000000,   /* Base SH4 CPU (Naomi, Hikaru etc.) */
191192
192193/* Resonators (There are probably more. Almost always used for driving OKI sound chips) */
193194
src/emu/info.c
r11160r11161
198198   for (port = portlist.first(); port != NULL; port = port->next())
199199      for (field = port->fieldlist; field != NULL; field = field->next)
200200      {
201
201202         if (nplayer < field->player + 1)
202203            nplayer = field->player + 1;
203204
src/mess/mess.mak
r11160r11161
476476   $(MAME_MACHINE)/neoprot.o   \
477477   $(MAME_MACHINE)/neocrypt.o   \
478478   $(MAME_MACHINE)/psx.o      \
479   $(MESS_MACHINE)/psxcd.o      \
480   $(MESS_MACHINE)/psxcddrv.o   \
481   $(MESS_MACHINE)/psxcard.o     \
482479   $(MAME_VIDEO)/psx.o         \
483480   $(MAME_DRIVERS)/cdi.o      \
484481   $(MAME_MACHINE)/cdi070.o   \
r11160r11161
14531450
14541451$(MESSOBJ)/sony.a:            \
14551452   $(MESS_DRIVERS)/psx.o      \
1453   $(MESS_MACHINE)/psxcd.o      \
1454   $(MESS_MACHINE)/psxcddrv.o   \
1455   $(MESS_MACHINE)/psxcard.o     \
14561456   $(MESS_DRIVERS)/pockstat.o   \
14571457   $(MESS_DRIVERS)/smc777.o   \
14581458
src/mess/drivers/astrocde.c
r11160r11161
307307
308308static DRIVER_INIT( astrocde )
309309{
310   astrocade_video_config = AC_SOUND_PRESENT | AC_LIGHTPEN_INTS;
310   astrocde_state *state = machine.driver_data<astrocde_state>();
311   state->m_video_config = AC_SOUND_PRESENT | AC_LIGHTPEN_INTS;
311312}
312313
313314MACHINE_RESET( astrocde )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team