Previous 199869 Revisions Next

r17622 Monday 3rd September, 2012 at 20:41:50 UTC by Aaron Giles
First pass at modernizing the jaguar/cojag driver. Removed all
static variables and use of AM_LEGACY_BASE/SIZE.
[src/mame/audio]jaguar.c
[src/mame/drivers]jaguar.c
[src/mame/includes]jaguar.h
[src/mame/video]jagblit.c jagobj.c jaguar.c

trunk/src/mame/audio/jaguar.c
r17621r17622
145145#include "emu.h"
146146#include "includes/jaguar.h"
147147#include "cpu/jaguar/jaguar.h"
148#include "sound/dac.h"
149148
150149
151150/* Jerry registers */
r17621r17622
161160
162161
163162
164/* DSP variables */
165static UINT16 dsp_regs[DSP_REGS];
166
167static UINT16 serial_frequency;
168
169static UINT8 gpu_irq_state;
170
171#if ENABLE_SPEEDUP_HACKS
172static WRITE32_HANDLER( dsp_flags_w );
173#endif
174
175
176
177163/*************************************
178164 *
179 *  DSP optimization control
180 *
181 *************************************/
182
183void jaguar_dsp_suspend(running_machine &machine)
184{
185   machine.device<cpu_device>("audiocpu")->suspend(SUSPEND_REASON_SPIN, 1);
186}
187
188
189void jaguar_dsp_resume(running_machine &machine)
190{
191   machine.device<cpu_device>("audiocpu")->resume(SUSPEND_REASON_SPIN);
192}
193
194
195
196/*************************************
197 *
198165 *  Jerry -> GPU interrupts
199166 *
200167 *************************************/
201168
202static void update_gpu_irq(running_machine &machine)
169void jaguar_state::update_gpu_irq()
203170{
204   if (gpu_irq_state & dsp_regs[JINTCTRL] & 0x1f)
171   if (m_gpu_irq_state & m_dsp_regs[JINTCTRL] & 0x1f)
205172   {
206      cputag_set_input_line(machine, "gpu", 1, ASSERT_LINE);
207      jaguar_gpu_resume(machine);
173      m_gpu->set_input_line(1, ASSERT_LINE);
174      gpu_resume();
208175   }
209176   else
210      cputag_set_input_line(machine, "gpu", 1, CLEAR_LINE);
177      m_gpu->set_input_line(1, CLEAR_LINE);
211178}
212179
213180
214void jaguar_external_int(device_t *device, int state)
181void jaguar_state::external_int(device_t *device, int newstate)
215182{
216   if (state != CLEAR_LINE)
217      gpu_irq_state |= 1;
183   jaguar_state &state = *device->machine().driver_data<jaguar_state>();
184   if (newstate != CLEAR_LINE)
185      state.m_gpu_irq_state |= 1;
218186   else
219      gpu_irq_state &= ~1;
220   update_gpu_irq(device->machine());
187      state.m_gpu_irq_state &= ~1;
188   state.update_gpu_irq();
221189}
222190
223191
r17621r17622
228196 *
229197 *************************************/
230198
231void cojag_sound_init(running_machine &machine)
199void jaguar_state::sound_start()
232200{
233   int i;
201   m_serial_timer = timer_alloc(TID_SERIAL);
234202
235   /* fill the wave ROM -- these are pretty cheesy guesses */
236   for (i = 0; i < 0x80; i++)
237   {
238      /* F1D000 = triangle wave */
239      jaguar_wave_rom[0x000 + i] = ((i <= 0x40) ? i : 0x80 - i) * 32767 / 0x40;
240
241      /* F1D200 = full sine wave */
242      jaguar_wave_rom[0x080 + i] = (int)(32767. * sin(2.0 * M_PI * (double)i / (double)0x80));
243
244      /* F1D400 = amplitude modulated sine wave? */
245      jaguar_wave_rom[0x100 + i] = (int)(32767. * sin(2.0 * M_PI * (double)i / (double)0x80));
246
247      /* F1D600 = sine wave and second order harmonic */
248      jaguar_wave_rom[0x180 + i] = (int)(32767. * sin(2.0 * M_PI * (double)i / (double)0x80));
249
250      /* F1D800 = chirp (sine wave of increasing frequency) */
251      jaguar_wave_rom[0x200 + i] = (int)(32767. * sin(2.0 * M_PI * (double)i / (double)0x80));
252
253      /* F1DA00 = triangle wave with noise */
254      jaguar_wave_rom[0x280 + i] = jaguar_wave_rom[0x000 + i] * (machine.rand() % 32768) / 32768;
255
256      /* F1DC00 = spike */
257      jaguar_wave_rom[0x300 + i] = (i == 0x40) ? 32767 : 0;
258
259      /* F1DE00 = white noise */
260      jaguar_wave_rom[0x380 + i] = machine.rand() % 32768;
261   }
262
263203#if ENABLE_SPEEDUP_HACKS
264   if (jaguar_hacks_enabled)
265      machine.device("audiocpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xf1a100, 0xf1a103, FUNC(dsp_flags_w));
266
204   if (m_hacks_enabled)
205      m_dsp->space(AS_PROGRAM)->install_write_handler(0xf1a100, 0xf1a103, write32_delegate(FUNC(jaguar_state::dsp_flags_w), this));
267206#endif
268207}
269208
r17621r17622
275214 *
276215 *************************************/
277216
278READ16_HANDLER( jaguar_jerry_regs_r )
217READ16_MEMBER( jaguar_state::jerry_regs_r )
279218{
280219   if (offset != JINTCTRL && offset != JINTCTRL+2)
281      logerror("%08X:jerry read register @ F10%03X\n", cpu_get_previouspc(&space->device()), offset * 2);
220      logerror("%08X:jerry read register @ F10%03X\n", cpu_get_previouspc(&space.device()), offset * 2);
282221
283222   switch (offset)
284223   {
285224      case JINTCTRL:
286         return gpu_irq_state;
225         return m_gpu_irq_state;
287226      case ASICTRL:
288         return (dsp_regs[offset] & 0xfeff) | 0x100; // assume fifo empty
227         return (m_dsp_regs[offset] & 0xfeff) | 0x100; // assume fifo empty
289228   }
290229
291   return dsp_regs[offset];
230   return m_dsp_regs[offset];
292231}
293232
294233
295WRITE16_HANDLER( jaguar_jerry_regs_w )
234WRITE16_MEMBER( jaguar_state::jerry_regs_w )
296235{
297   COMBINE_DATA(&dsp_regs[offset]);
236   COMBINE_DATA(&m_dsp_regs[offset]);
298237
299238   switch (offset)
300239   {
301240      case JINTCTRL:
302         gpu_irq_state &= ~(dsp_regs[JINTCTRL] >> 8);
303         update_gpu_irq(space->machine());
241         m_gpu_irq_state &= ~(m_dsp_regs[JINTCTRL] >> 8);
242         update_gpu_irq();
304243         break;
305244   }
306245
307246   if (offset != JINTCTRL && offset != JINTCTRL+2 && offset != ASICTRL)
308      logerror("%08X:jerry write register @ F10%03X = %04X\n", cpu_get_previouspc(&space->device()), offset * 2, data);
247      logerror("%08X:jerry write register @ F10%03X = %04X\n", cpu_get_previouspc(&space.device()), offset * 2, data);
309248}
310249
311250
r17621r17622
318257
319258#if ENABLE_SPEEDUP_HACKS
320259
321static WRITE32_HANDLER( dsp_flags_w )
260WRITE32_MEMBER( jaguar_state::dsp_flags_w )
322261{
323262   /* write the data through */
324   jaguardsp_ctrl_w(space->machine().device("audiocpu"), offset, data, mem_mask);
263   jaguardsp_ctrl_w(m_dsp, offset, data, mem_mask);
325264
326265   /* if they were clearing the A2S interrupt, see if we are headed for the spin */
327266   /* loop with R22 != 0; if we are, just start spinning again */
328   if (&space->device() == space->machine().device("audiocpu") && ACCESSING_BITS_8_15 && (data & 0x400))
267   if (&space.device() == m_dsp && ACCESSING_BITS_8_15 && (data & 0x400))
329268   {
330269      /* see if we're going back to the spin loop */
331      if (!(data & 0x04000) && cpu_get_reg(&space->device(), JAGUAR_R22) != 0)
270      if (!(data & 0x04000) && m_dsp->state(JAGUAR_R22) != 0)
332271      {
333         UINT32 r30 = cpu_get_reg(&space->device(), JAGUAR_R30) & 0xffffff;
272         UINT32 r30 = m_dsp->state(JAGUAR_R30) & 0xffffff;
334273         if (r30 >= 0xf1b124 && r30 <= 0xf1b126)
335            jaguar_dsp_suspend(space->machine());
274            dsp_suspend();
336275      }
337276   }
338277}
r17621r17622
347286 *
348287 *************************************/
349288
350#if ENABLE_SPEEDUP_HACKS
351
352TIMER_DEVICE_CALLBACK( jaguar_serial_callback )
289void jaguar_state::serial_update()
353290{
354   if (jaguar_hacks_enabled) {
291   if (m_hacks_enabled)
292   {
355293      /* assert the A2S IRQ on CPU #2 (DSP) */
356      cputag_set_input_line(timer.machine(), "audiocpu", 1, ASSERT_LINE);
357      jaguar_dsp_resume(timer.machine());
294      m_dsp->set_input_line(1, ASSERT_LINE);
295      dsp_resume();
358296
359297      /* fix flaky code in interrupt handler which thwarts our speedup */
360      if ((jaguar_dsp_ram[0x3e/4] & 0xffff) == 0xbfbc &&
361         (jaguar_dsp_ram[0x42/4] & 0xffff) == 0xe400)
298      if ((m_dsp_ram[0x3e/4] & 0xffff) == 0xbfbc &&
299         (m_dsp_ram[0x42/4] & 0xffff) == 0xe400)
362300      {
363301         /* move the store r28,(r29) into the branch delay slot, swapping it with */
364302         /* the nop that's currently there */
365         jaguar_dsp_ram[0x3e/4] = (jaguar_dsp_ram[0x3e/4] & 0xffff0000) | 0xe400;
366         jaguar_dsp_ram[0x42/4] = (jaguar_dsp_ram[0x42/4] & 0xffff0000) | 0xbfbc;
303         m_dsp_ram[0x3e/4] = (m_dsp_ram[0x3e/4] & 0xffff0000) | 0xe400;
304         m_dsp_ram[0x42/4] = (m_dsp_ram[0x42/4] & 0xffff0000) | 0xbfbc;
367305      }
368   } else {
306   }
307   else
308   {
369309      /* assert the A2S IRQ on CPU #2 (DSP) */
370      cputag_set_input_line(timer.machine(), "audiocpu", 1, ASSERT_LINE);
371      jaguar_dsp_resume(timer.machine());
310      m_dsp->set_input_line(1, ASSERT_LINE);
311      dsp_resume();
372312   }
373313}
374314
375#else
376315
377TIMER_DEVICE_CALLBACK( jaguar_serial_callback )
378{
379   /* assert the A2S IRQ on CPU #2 (DSP) */
380   cputag_set_input_line(timer.machine(), "audiocpu", 1, ASSERT_LINE);
381   jaguar_dsp_resume(timer.machine());
382}
383316
384#endif
385
386
387
388317/*************************************
389318 *
390319 *  Serial port handlers
391320 *
392321 *************************************/
393322
394READ32_HANDLER( jaguar_serial_r )
323READ32_MEMBER( jaguar_state::serial_r )
395324{
396   logerror("%08X:jaguar_serial_r(%X)\n", cpu_get_previouspc(&space->device()), offset);
325   logerror("%08X:jaguar_serial_r(%X)\n", cpu_get_previouspc(&space.device()), offset);
397326   return 0;
398327}
399328
400329
401WRITE32_HANDLER( jaguar_serial_w )
330WRITE32_MEMBER( jaguar_state::serial_w )
402331{
403332   switch (offset)
404333   {
405334      /* right DAC */
406335      case 2:
407         space->machine().device<dac_device>("dac2")->write_signed16((data & 0xffff) ^ 0x8000);
336         m_dac2->write_signed16((data & 0xffff) ^ 0x8000);
408337         break;
409338
410339      /* left DAC */
411340      case 3:
412         space->machine().device<dac_device>("dac1")->write_signed16((data & 0xffff) ^ 0x8000);
341         m_dac1->write_signed16((data & 0xffff) ^ 0x8000);
413342         break;
414343
415344      /* frequency register */
416345      case 4:
417         serial_frequency = data & 0xffff;
346         m_serial_frequency = data & 0xffff;
418347         break;
419348
420349      /* control register -- only very specific modes supported */
r17621r17622
423352            logerror("Unexpected write to SMODE = %X\n", data);
424353         if ((data & 0x3f) == 0x15)
425354         {
426            attotime rate = attotime::from_hz(26000000) * (32 * 2 * (serial_frequency + 1));
427            timer_device *serial_timer = space->machine().device<timer_device>("serial_timer");
428            serial_timer->adjust(rate, 0, rate);
355            attotime rate = attotime::from_hz(26000000) * (32 * 2 * (m_serial_frequency + 1));
356            m_serial_timer->adjust(rate, 0, rate);
429357         }
430358         break;
431359
432360      default:
433         logerror("%08X:jaguar_serial_w(%X,%X)\n", cpu_get_previouspc(&space->device()), offset, data);
361         logerror("%08X:jaguar_serial_w(%X,%X)\n", cpu_get_previouspc(&space.device()), offset, data);
434362         break;
435363   }
436364}
trunk/src/mame/video/jagblit.c
r17621r17622
3535#define PIXEL_SHIFT_1(a)      ((~a##_x >> 16) & 7)
3636#define PIXEL_OFFSET_1(a)     BYTE4_XOR_BE(((UINT32)a##_y >> 16) * a##_width / 8 + (((UINT32)a##_x >> 19) & ~7) * (1 + a##_pitch) + (((UINT32)a##_x >> 19) & 7))
3737#define ZDATA_OFFSET_1(a)     0 /* huh? */
38#define READ_RDATA_1(r,a,p)   ((p) ? (((((UINT8 *)&blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 19) & 7)]) >> PIXEL_SHIFT_1(a)) & 0x01) : (blitter_regs[r] & 0x01))
38#define READ_RDATA_1(r,a,p)   ((p) ? (((((UINT8 *)&m_blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 19) & 7)]) >> PIXEL_SHIFT_1(a)) & 0x01) : (m_blitter_regs[r] & 0x01))
3939#define READ_PIXEL_1(a)       (((((UINT8 *)a##_base_mem)[PIXEL_OFFSET_1(a)]) >> PIXEL_SHIFT_1(a)) & 0x01)
4040#define READ_ZDATA_1(a)       0 /* huh? */
4141#define WRITE_PIXEL_1(a,d)    do { UINT8 *pix = &((UINT8 *)a##_base_mem)[PIXEL_OFFSET_1(a)]; *pix = (*pix & ~(0x01 << PIXEL_SHIFT_1(a))) | ((d) << PIXEL_SHIFT_1(a)); } while (0)
r17621r17622
4444#define PIXEL_SHIFT_2(a)      ((~a##_x >> 15) & 6)
4545#define PIXEL_OFFSET_2(a)     BYTE4_XOR_BE(((UINT32)a##_y >> 16) * a##_width / 4 + (((UINT32)a##_x >> 18) & ~7) * (1 + a##_pitch) + (((UINT32)a##_x >> 18) & 7))
4646#define ZDATA_OFFSET_2(a)     0 /* huh? */
47#define READ_RDATA_2(r,a,p)   ((p) ? (((((UINT8 *)&blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 18) & 7)]) >> PIXEL_SHIFT_2(a)) & 0x03) : (blitter_regs[r] & 0x03))
47#define READ_RDATA_2(r,a,p)   ((p) ? (((((UINT8 *)&m_blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 18) & 7)]) >> PIXEL_SHIFT_2(a)) & 0x03) : (m_blitter_regs[r] & 0x03))
4848#define READ_PIXEL_2(a)       (((((UINT8 *)a##_base_mem)[PIXEL_OFFSET_2(a)]) >> PIXEL_SHIFT_2(a)) & 0x03)
4949#define READ_ZDATA_2(a)       0 /* huh? */
5050#define WRITE_PIXEL_2(a,d)    do { UINT8 *pix = &((UINT8 *)a##_base_mem)[PIXEL_OFFSET_2(a)]; *pix = (*pix & ~(0x03 << PIXEL_SHIFT_2(a))) | ((d) << PIXEL_SHIFT_2(a)); } while (0)
r17621r17622
5353#define PIXEL_SHIFT_4(a)      ((~a##_x >> 14) & 4)
5454#define PIXEL_OFFSET_4(a)     BYTE4_XOR_BE(((UINT32)a##_y >> 16) * a##_width / 2 + (((UINT32)a##_x >> 17) & ~7) * (1 + a##_pitch) + (((UINT32)a##_x >> 17) & 7))
5555#define ZDATA_OFFSET_4(a)     0 /* huh? */
56#define READ_RDATA_4(r,a,p)   ((p) ? (((((UINT8 *)&blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 17) & 7)]) >> PIXEL_SHIFT_4(a)) & 0x0f) : (blitter_regs[r] & 0x0f))
56#define READ_RDATA_4(r,a,p)   ((p) ? (((((UINT8 *)&m_blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 17) & 7)]) >> PIXEL_SHIFT_4(a)) & 0x0f) : (m_blitter_regs[r] & 0x0f))
5757#define READ_PIXEL_4(a)       (((((UINT8 *)a##_base_mem)[PIXEL_OFFSET_4(a)]) >> PIXEL_SHIFT_4(a)) & 0x0f)
5858#define READ_ZDATA_4(a)       0 /* huh? */
5959#define WRITE_PIXEL_4(a,d)    do { UINT8 *pix = &((UINT8 *)a##_base_mem)[PIXEL_OFFSET_4(a)]; *pix = (*pix & ~(0x0f << PIXEL_SHIFT_4(a))) | ((d) << PIXEL_SHIFT_4(a)); } while (0)
r17621r17622
6161
6262#define PIXEL_OFFSET_8(a)     BYTE4_XOR_BE(((UINT32)a##_y >> 16) * a##_width + (((UINT32)a##_x >> 16) & ~7) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 7))
6363#define ZDATA_OFFSET_8(a)     (PIXEL_OFFSET_8(a) + a##_zoffs * 8)
64#define READ_RDATA_8(r,a,p)   ((p) ? (((UINT8 *)&blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 16) & 7)]) : (blitter_regs[r] & 0xff))
64#define READ_RDATA_8(r,a,p)   ((p) ? (((UINT8 *)&m_blitter_regs[r])[BYTE4_XOR_BE(((UINT32)a##_x >> 16) & 7)]) : (m_blitter_regs[r] & 0xff))
6565#define READ_PIXEL_8(a)       (((UINT8 *)a##_base_mem)[PIXEL_OFFSET_8(a)])
6666#define READ_ZDATA_8(a)       (((UINT8 *)a##_base_mem)[ZDATA_OFFSET_8(a)])
6767#define WRITE_PIXEL_8(a,d)    do { ((UINT8 *)a##_base_mem)[PIXEL_OFFSET_8(a)] = (d); } while (0)
r17621r17622
6969
7070#define PIXEL_OFFSET_16(a)    BYTE_XOR_BE(((UINT32)a##_y >> 16) * a##_width + (((UINT32)a##_x >> 16) & ~3) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 3))
7171#define ZDATA_OFFSET_16(a)    (PIXEL_OFFSET_16(a) + a##_zoffs * 4)
72#define READ_RDATA_16(r,a,p)  ((p) ? (((UINT16 *)&blitter_regs[r])[BYTE_XOR_BE(((UINT32)a##_x >> 16) & 3)]) : (blitter_regs[r] & 0xffff))
72#define READ_RDATA_16(r,a,p)  ((p) ? (((UINT16 *)&m_blitter_regs[r])[BYTE_XOR_BE(((UINT32)a##_x >> 16) & 3)]) : (m_blitter_regs[r] & 0xffff))
7373#define READ_PIXEL_16(a)      (((UINT16 *)a##_base_mem)[PIXEL_OFFSET_16(a)])
7474#define READ_ZDATA_16(a)      (((UINT16 *)a##_base_mem)[ZDATA_OFFSET_16(a)])
7575#define WRITE_PIXEL_16(a,d)   do { ((UINT16 *)a##_base_mem)[PIXEL_OFFSET_16(a)] = (d); } while (0)
r17621r17622
7777
7878#define PIXEL_OFFSET_32(a)    (((UINT32)a##_y >> 16) * a##_width + (((UINT32)a##_x >> 16) & ~1) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 1))
7979#define ZDATA_OFFSET_32(a)    (PIXEL_OFFSET_32(a) + a##_zoffs * 2)
80#define READ_RDATA_32(r,a,p)  ((p) ? (blitter_regs[r + (((UINT32)a##_x >> 16) & 1)]) : blitter_regs[r])
80#define READ_RDATA_32(r,a,p)  ((p) ? (m_blitter_regs[r + (((UINT32)a##_x >> 16) & 1)]) : m_blitter_regs[r])
8181#define READ_PIXEL_32(a)      (((UINT32 *)a##_base_mem)[PIXEL_OFFSET_32(a)])
8282#define READ_ZDATA_32(a)      (((UINT32 *)a##_base_mem)[ZDATA_OFFSET_32(a)])
8383#define WRITE_PIXEL_32(a,d)   do { ((UINT32 *)a##_base_mem)[PIXEL_OFFSET_32(a)] = (d); } while (0)
r17621r17622
130130   } while (0)
131131#endif
132132
133static void FUNCNAME(running_machine &machine, UINT32 command, UINT32 a1flags, UINT32 a2flags)
133void jaguar_state::FUNCNAME(UINT32 command, UINT32 a1flags, UINT32 a2flags)
134134{
135   UINT32 a1_base = blitter_regs[A1_BASE];
135   UINT32 a1_base = m_blitter_regs[A1_BASE];
136136   INT32 a1_pitch = (A1FIXED & 3) ^ ((A1FIXED & 2) >> 1);
137137   INT32 a1_zoffs = (A1FIXED >> 6) & 7;
138138   INT32 a1_width = ((4 | ((a1flags >> 9) & 3)) << ((a1flags >> 11) & 15)) >> 2;
139139   INT32 a1_xadd = (A1FIXED >> 16) & 0x03;
140140   INT32 a1_yadd = (A1FIXED >> 18) & 0x01;
141   INT32 a1_x = (blitter_regs[A1_PIXEL] << 16) | (blitter_regs[A1_FPIXEL] & 0xffff);
142   INT32 a1_y = (blitter_regs[A1_PIXEL] & 0xffff0000) | (blitter_regs[A1_FPIXEL] >> 16);
141   INT32 a1_x = (m_blitter_regs[A1_PIXEL] << 16) | (m_blitter_regs[A1_FPIXEL] & 0xffff);
142   INT32 a1_y = (m_blitter_regs[A1_PIXEL] & 0xffff0000) | (m_blitter_regs[A1_FPIXEL] >> 16);
143143   INT32 a1_xstep = 0;
144144   INT32 a1_ystep = 0;
145145   UINT32 a1_xmask = 0xffffffff;
146146   UINT32 a1_ymask = 0xffffffff;
147147
148   UINT32 a2_base = blitter_regs[A2_BASE];
148   UINT32 a2_base = m_blitter_regs[A2_BASE];
149149   INT32 a2_pitch = (A2FIXED & 3) ^ ((A2FIXED & 2) >> 1);
150150   INT32 a2_zoffs = (A2FIXED >> 6) & 7;
151151   INT32 a2_width = ((4 | ((a2flags >> 9) & 3)) << ((a2flags >> 11) & 15)) >> 2;
152152   INT32 a2_xadd = (A2FIXED >> 16) & 0x03;
153153   INT32 a2_yadd = (A2FIXED >> 18) & 0x01;
154   INT32 a2_x = (blitter_regs[A2_PIXEL] << 16);
155   INT32 a2_y = (blitter_regs[A2_PIXEL] & 0xffff0000);
154   INT32 a2_x = (m_blitter_regs[A2_PIXEL] << 16);
155   INT32 a2_y = (m_blitter_regs[A2_PIXEL] & 0xffff0000);
156156   INT32 a2_xstep = 0;
157157   INT32 a2_ystep = 0;
158158   UINT32 a2_xmask = 0xffffffff;
159159   UINT32 a2_ymask = 0xffffffff;
160160
161   int inner_count = blitter_regs[B_COUNT] & 0xffff;
162   int outer_count = blitter_regs[B_COUNT] >> 16;
161   int inner_count = m_blitter_regs[B_COUNT] & 0xffff;
162   int outer_count = m_blitter_regs[B_COUNT] >> 16;
163163   int inner, outer;
164164
165165   UINT8 a1_phrase_mode = 0;
166166   UINT8 a2_phrase_mode = 0;
167167
168   void *a1_base_mem = get_jaguar_memory(machine, a1_base);
169   void *a2_base_mem = get_jaguar_memory(machine, a2_base);
168   void *a1_base_mem = memory_base(a1_base);
169   void *a2_base_mem = memory_base(a2_base);
170170
171171   void *asrc_base_mem =   (COMMAND & 0x00000800) ? a1_base_mem : a2_base_mem;
172172   UINT32 asrcflags =      (COMMAND & 0x00000800) ? A1FIXED : A2FIXED;
r17621r17622
195195   {
196196      if (LOG_BAD_BLITS)
197197      {
198      logerror("%s:Blit!\n", machine.describe_context());
198      logerror("%s:Blit!\n", machine().describe_context());
199199      logerror("  a1_base  = %08X\n", a1_base);
200200      logerror("  a2_base  = %08X\n", a2_base);
201201      }
202202      return;
203203   }
204204
205   // ignore nonsensical blits
206   if (outer_count > 2000 || inner_count > 2000)
207   {
208      if (LOG_BAD_BLITS)
209      {
210      logerror("%s:Blit!\n", machine().describe_context());
211      logerror("  inner_count = %08X\n", inner_count);
212      logerror("  outer_count = %08X\n", inner_count);
213      }
214      return;
215   }
216
205217   /* determine actual xadd/yadd for A1 */
206218   a1_yadd <<= 16;
207219   if (A1FIXED & 0x00100000)
r17621r17622
210222   a1_phrase_mode = (a1_xadd == 0);
211223   if (a1_xadd == 3)
212224   {
213      a1_xadd = (blitter_regs[A1_INC] << 16) | (blitter_regs[A1_FINC] & 0xffff);
214      a1_yadd = (blitter_regs[A1_INC] & 0xffff0000) | (blitter_regs[A1_FINC] >> 16);
225      a1_xadd = (m_blitter_regs[A1_INC] << 16) | (m_blitter_regs[A1_FINC] & 0xffff);
226      a1_yadd = (m_blitter_regs[A1_INC] & 0xffff0000) | (m_blitter_regs[A1_FINC] >> 16);
215227   }
216228   else if (a1_xadd == 2)
217229      a1_xadd = 0;
r17621r17622
236248   /* set up the A2 mask */
237249   if (A2FIXED & 0x00008000)
238250   {
239      a2_xmask = ((blitter_regs[A2_MASK] & 0x0000ffff) << 16) | 0xffff;
240      a2_ymask = (blitter_regs[A2_MASK] & 0xffff0000) | 0xffff;
251      a2_xmask = ((m_blitter_regs[A2_MASK] & 0x0000ffff) << 16) | 0xffff;
252      a2_ymask = (m_blitter_regs[A2_MASK] & 0xffff0000) | 0xffff;
241253   }
242254
243255   /* modify outer loop steps based on command */
244256   if (command & 0x00000100)
245257   {
246      a1_xstep = blitter_regs[A1_FSTEP] & 0xffff;
247      a1_ystep = blitter_regs[A1_FSTEP] >> 16;
258      a1_xstep = m_blitter_regs[A1_FSTEP] & 0xffff;
259      a1_ystep = m_blitter_regs[A1_FSTEP] >> 16;
248260   }
249261   if (command & 0x00000200)
250262   {
251      a1_xstep += blitter_regs[A1_STEP] << 16;
252      a1_ystep += blitter_regs[A1_STEP] & 0xffff0000;
263      a1_xstep += m_blitter_regs[A1_STEP] << 16;
264      a1_ystep += m_blitter_regs[A1_STEP] & 0xffff0000;
253265   }
254266   if (command & 0x00000400)
255267   {
256      a2_xstep = blitter_regs[A2_STEP] << 16;
257      a2_ystep = blitter_regs[A2_STEP] & 0xffff0000;
268      a2_xstep = m_blitter_regs[A2_STEP] << 16;
269      a2_ystep = m_blitter_regs[A2_STEP] & 0xffff0000;
258270   }
259271
260272   asrc_phrase_mode   = (COMMAND & 0x00000800) ? a1_phrase_mode : a2_phrase_mode;
r17621r17622
275287
276288   if (LOG_BLITS)
277289   {
278   logerror("%s:Blit!\n", machine.describe_context());
290   logerror("%s:Blit!\n", machine().describe_context());
279291   logerror("  a1_base  = %08X\n", a1_base);
280292   logerror("  a1_pitch = %d\n", a1_pitch);
281293   logerror("  a1_psize = %d\n", 1 << ((A1FIXED >> 3) & 7));
r17621r17622
357369            if (COMMAND & 0x00000040)
358370            {
359371            if (adest_x < 0 || adest_y < 0 ||
360               (adest_x >> 16) >= (blitter_regs[A1_CLIP] & 0x7fff) ||
361               (adest_y >> 16) >= ((blitter_regs[A1_CLIP] >> 16) & 0x7fff))
372               (adest_x >> 16) >= (m_blitter_regs[A1_CLIP] & 0x7fff) ||
373               (adest_y >> 16) >= ((m_blitter_regs[A1_CLIP] >> 16) & 0x7fff))
362374                  inhibit = 1;
363375            }
364376
r17621r17622
417429            if (COMMAND & 0x40000000)
418430            {
419431               int intensity = srcdata & 0x00ff;
420               intensity += (INT8) (blitter_regs[B_Z3] >> 16);
432               intensity += (INT8) (m_blitter_regs[B_Z3] >> 16);
421433               if (intensity < 0)
422434                  intensity = 0;
423435               else if (intensity > 0xff)
r17621r17622
474486   a2_x =   (COMMAND & 0x00000800) ? adest_x : asrc_x;
475487   a2_y =   (COMMAND & 0x00000800) ? adest_y : asrc_y;
476488
477   blitter_regs[A1_PIXEL] = (a1_y & 0xffff0000) | ((a1_x >> 16) & 0xffff);
478   blitter_regs[A1_FPIXEL] = (a1_y << 16) | (a1_x & 0xffff);
479   blitter_regs[A2_PIXEL] = (a2_y & 0xffff0000) | ((a2_x >> 16) & 0xffff);
489   m_blitter_regs[A1_PIXEL] = (a1_y & 0xffff0000) | ((a1_x >> 16) & 0xffff);
490   m_blitter_regs[A1_FPIXEL] = (a1_y << 16) | (a1_x & 0xffff);
491   m_blitter_regs[A2_PIXEL] = (a2_y & 0xffff0000) | ((a2_x >> 16) & 0xffff);
480492}
trunk/src/mame/video/jagobj.c
r17621r17622
1212#define LOG_OBJECTS         0
1313
1414
15static UINT16 *scanline;
16static UINT16 *clutbase;
17static UINT8 *blend_y, *blend_cc;
18
19
20
2115/*************************************
2216 *
2317 *  Object processor init
2418 *
2519 *************************************/
2620
27void jagobj_init(running_machine &machine)
21void jaguar_state::jagobj_init()
2822{
2923   int i;
3024
31   /* allocate memory for tables */
32   blend_y = auto_alloc_array(machine, UINT8, 256 * 256);
33   blend_cc = auto_alloc_array(machine, UINT8, 256 * 256);
34
3525   /* fill tables */
3626   for (i = 0; i < 256 * 256; i++)
3727   {
r17621r17622
4535      y += dy;
4636      if (y < 0) y = 0;
4737      else if (y > 0xff) y = 0xff;
48      blend_y[i] = y;
38      m_blend_y[i] = y;
4939
5040      c1 += dc1;
5141      if (c1 < 0) c1 = 0;
r17621r17622
5343      c2 += dc2;
5444      if (c2 < 0) c2 = 0;
5545      else if (c2 > 0x0f) c2 = 0x0f;
56      blend_cc[i] = (c2 << 4) | c1;
46      m_blend_cc[i] = (c2 << 4) | c1;
5747   }
5848}
5949
r17621r17622
6656 *************************************/
6757
6858#define BLEND(dst, src)      \
69   (dst) = (blend_cc[((dst) & 0xff00) | (((src) >> 8) & 0xff)] << 8) | blend_y[(((dst) & 0xff) << 8) | ((src) & 0xff)];
59   (dst) = (m_blend_cc[((dst) & 0xff00) | (((src) >> 8) & 0xff)] << 8) | m_blend_y[(((dst) & 0xff) << 8) | ((src) & 0xff)];
7060
7161
7262
r17621r17622
7666 *
7767 *************************************/
7868
79INLINE void bitmap_4_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
69inline void jaguar_state::bitmap_4_draw(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos, UINT16 *clutbase)
8070{
8171   if (firstpix & 7)
8272   {
r17621r17622
182172   }
183173}
184174
185static void bitmap_4_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
175void jaguar_state::bitmap_4_0(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
186176{
187   bitmap_4_draw(firstpix, iwidth, src, xpos, 0, 1);
177   bitmap_4_draw(scanline, firstpix, iwidth, src, xpos, 0, 1, clutbase);
188178}
189179
190static void bitmap_4_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
180void jaguar_state::bitmap_4_1(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
191181{
192   bitmap_4_draw(firstpix, iwidth, src, xpos, 1, -1);
182   bitmap_4_draw(scanline, firstpix, iwidth, src, xpos, 1, -1, clutbase);
193183}
194184
195static void bitmap_4_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
185void jaguar_state::bitmap_4_2(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
196186{
197   bitmap_4_draw(firstpix, iwidth, src, xpos, 2, 1);
187   bitmap_4_draw(scanline, firstpix, iwidth, src, xpos, 2, 1, clutbase);
198188}
199189
200static void bitmap_4_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
190void jaguar_state::bitmap_4_3(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
201191{
202   bitmap_4_draw(firstpix, iwidth, src, xpos, 3, -1);
192   bitmap_4_draw(scanline, firstpix, iwidth, src, xpos, 3, -1, clutbase);
203193}
204194
205static void bitmap_4_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
195void jaguar_state::bitmap_4_4(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
206196{
207   bitmap_4_draw(firstpix, iwidth, src, xpos, 4, 1);
197   bitmap_4_draw(scanline, firstpix, iwidth, src, xpos, 4, 1, clutbase);
208198}
209199
210static void bitmap_4_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
200void jaguar_state::bitmap_4_5(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
211201{
212   bitmap_4_draw(firstpix, iwidth, src, xpos, 5, -1);
202   bitmap_4_draw(scanline, firstpix, iwidth, src, xpos, 5, -1, clutbase);
213203}
214204
215static void bitmap_4_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
205void jaguar_state::bitmap_4_6(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
216206{
217   bitmap_4_draw(firstpix, iwidth, src, xpos, 6, 1);
207   bitmap_4_draw(scanline, firstpix, iwidth, src, xpos, 6, 1, clutbase);
218208}
219209
220static void bitmap_4_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
210void jaguar_state::bitmap_4_7(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
221211{
222   bitmap_4_draw(firstpix, iwidth, src, xpos, 7, -1);
212   bitmap_4_draw(scanline, firstpix, iwidth, src, xpos, 7, -1, clutbase);
223213}
224214
225static void (*const bitmap4[8])(INT32, INT32, UINT32 *, INT32) =
215void (jaguar_state::*const jaguar_state::bitmap4[8])(UINT16 *, INT32, INT32, UINT32 *, INT32, UINT16 *) =
226216{
227   bitmap_4_0,
228   bitmap_4_1,
229   bitmap_4_2,
230   bitmap_4_3,
231   bitmap_4_4,
232   bitmap_4_5,
233   bitmap_4_6,
234   bitmap_4_7
217   &jaguar_state::bitmap_4_0,
218   &jaguar_state::bitmap_4_1,
219   &jaguar_state::bitmap_4_2,
220   &jaguar_state::bitmap_4_3,
221   &jaguar_state::bitmap_4_4,
222   &jaguar_state::bitmap_4_5,
223   &jaguar_state::bitmap_4_6,
224   &jaguar_state::bitmap_4_7
235225};
236226
237227
r17621r17622
242232 *
243233 *************************************/
244234
245INLINE void bitmap_8_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
235inline void jaguar_state::bitmap_8_draw(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos, UINT16 *clutbase)
246236{
247237   if (firstpix & 3)
248238   {
r17621r17622
312302   }
313303}
314304
315static void bitmap_8_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
305void jaguar_state::bitmap_8_0(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
316306{
317   bitmap_8_draw(firstpix, iwidth, src, xpos, 0, 1);
307   bitmap_8_draw(scanline, firstpix, iwidth, src, xpos, 0, 1, clutbase);
318308}
319309
320static void bitmap_8_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
310void jaguar_state::bitmap_8_1(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
321311{
322   bitmap_8_draw(firstpix, iwidth, src, xpos, 1, -1);
312   bitmap_8_draw(scanline, firstpix, iwidth, src, xpos, 1, -1, clutbase);
323313}
324314
325static void bitmap_8_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
315void jaguar_state::bitmap_8_2(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
326316{
327   bitmap_8_draw(firstpix, iwidth, src, xpos, 2, 1);
317   bitmap_8_draw(scanline, firstpix, iwidth, src, xpos, 2, 1, clutbase);
328318}
329319
330static void bitmap_8_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
320void jaguar_state::bitmap_8_3(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
331321{
332   bitmap_8_draw(firstpix, iwidth, src, xpos, 3, -1);
322   bitmap_8_draw(scanline, firstpix, iwidth, src, xpos, 3, -1, clutbase);
333323}
334324
335static void bitmap_8_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
325void jaguar_state::bitmap_8_4(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
336326{
337   bitmap_8_draw(firstpix, iwidth, src, xpos, 4, 1);
327   bitmap_8_draw(scanline, firstpix, iwidth, src, xpos, 4, 1, clutbase);
338328}
339329
340static void bitmap_8_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
330void jaguar_state::bitmap_8_5(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
341331{
342   bitmap_8_draw(firstpix, iwidth, src, xpos, 5, -1);
332   bitmap_8_draw(scanline, firstpix, iwidth, src, xpos, 5, -1, clutbase);
343333}
344334
345static void bitmap_8_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
335void jaguar_state::bitmap_8_6(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
346336{
347   bitmap_8_draw(firstpix, iwidth, src, xpos, 6, 1);
337   bitmap_8_draw(scanline, firstpix, iwidth, src, xpos, 6, 1, clutbase);
348338}
349339
350static void bitmap_8_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
340void jaguar_state::bitmap_8_7(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase)
351341{
352   bitmap_8_draw(firstpix, iwidth, src, xpos, 7, -1);
342   bitmap_8_draw(scanline, firstpix, iwidth, src, xpos, 7, -1, clutbase);
353343}
354344
355static void (*const bitmap8[8])(INT32, INT32, UINT32 *, INT32) =
345void (jaguar_state::*const jaguar_state::bitmap8[8])(UINT16 *, INT32, INT32, UINT32 *, INT32, UINT16 *) =
356346{
357   bitmap_8_0,
358   bitmap_8_1,
359   bitmap_8_2,
360   bitmap_8_3,
361   bitmap_8_4,
362   bitmap_8_5,
363   bitmap_8_6,
364   bitmap_8_7
347   &jaguar_state::bitmap_8_0,
348   &jaguar_state::bitmap_8_1,
349   &jaguar_state::bitmap_8_2,
350   &jaguar_state::bitmap_8_3,
351   &jaguar_state::bitmap_8_4,
352   &jaguar_state::bitmap_8_5,
353   &jaguar_state::bitmap_8_6,
354   &jaguar_state::bitmap_8_7
365355};
366356
367357
r17621r17622
372362 *
373363 *************************************/
374364
375INLINE void bitmap_16_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
365inline void jaguar_state::bitmap_16_draw(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
376366{
377367   if (firstpix & 1)
378368   {
r17621r17622
419409   }
420410}
421411
422static void bitmap_16_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
412void jaguar_state::bitmap_16_0(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
423413{
424   bitmap_16_draw(firstpix, iwidth, src, xpos, 0, 1);
414   bitmap_16_draw(scanline, firstpix, iwidth, src, xpos, 0, 1);
425415}
426416
427static void bitmap_16_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
417void jaguar_state::bitmap_16_1(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
428418{
429   bitmap_16_draw(firstpix, iwidth, src, xpos, 1, -1);
419   bitmap_16_draw(scanline, firstpix, iwidth, src, xpos, 1, -1);
430420}
431421
432static void bitmap_16_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
422void jaguar_state::bitmap_16_2(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
433423{
434   bitmap_16_draw(firstpix, iwidth, src, xpos, 2, 1);
424   bitmap_16_draw(scanline, firstpix, iwidth, src, xpos, 2, 1);
435425}
436426
437static void bitmap_16_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
427void jaguar_state::bitmap_16_3(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
438428{
439   bitmap_16_draw(firstpix, iwidth, src, xpos, 3, -1);
429   bitmap_16_draw(scanline, firstpix, iwidth, src, xpos, 3, -1);
440430}
441431
442static void bitmap_16_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
432void jaguar_state::bitmap_16_4(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
443433{
444   bitmap_16_draw(firstpix, iwidth, src, xpos, 4, 1);
434   bitmap_16_draw(scanline, firstpix, iwidth, src, xpos, 4, 1);
445435}
446436
447static void bitmap_16_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
437void jaguar_state::bitmap_16_5(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
448438{
449   bitmap_16_draw(firstpix, iwidth, src, xpos, 5, -1);
439   bitmap_16_draw(scanline, firstpix, iwidth, src, xpos, 5, -1);
450440}
451441
452static void bitmap_16_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
442void jaguar_state::bitmap_16_6(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
453443{
454   bitmap_16_draw(firstpix, iwidth, src, xpos, 6, 1);
444   bitmap_16_draw(scanline, firstpix, iwidth, src, xpos, 6, 1);
455445}
456446
457static void bitmap_16_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
447void jaguar_state::bitmap_16_7(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
458448{
459   bitmap_16_draw(firstpix, iwidth, src, xpos, 7, -1);
449   bitmap_16_draw(scanline, firstpix, iwidth, src, xpos, 7, -1);
460450}
461451
462static void (*const bitmap16[8])(INT32, INT32, UINT32 *, INT32) =
452void (jaguar_state::*const jaguar_state::bitmap16[8])(UINT16 *, INT32, INT32, UINT32 *, INT32) =
463453{
464   bitmap_16_0,
465   bitmap_16_1,
466   bitmap_16_2,
467   bitmap_16_3,
468   bitmap_16_4,
469   bitmap_16_5,
470   bitmap_16_6,
471   bitmap_16_7
454   &jaguar_state::bitmap_16_0,
455   &jaguar_state::bitmap_16_1,
456   &jaguar_state::bitmap_16_2,
457   &jaguar_state::bitmap_16_3,
458   &jaguar_state::bitmap_16_4,
459   &jaguar_state::bitmap_16_5,
460   &jaguar_state::bitmap_16_6,
461   &jaguar_state::bitmap_16_7
472462};
473463
474464
r17621r17622
481471 *
482472 *************************************/
483473
484INLINE void bitmap_32_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
474inline void jaguar_state::bitmap_32_draw(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
485475{
486476   iwidth -= firstpix;
487477
r17621r17622
497487   }
498488}
499489
500static void bitmap_32_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
490void jaguar_state::bitmap_32_0(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
501491{
502   bitmap_32_draw(firstpix, iwidth, src, xpos, 0, 1);
492   bitmap_32_draw(scanline, firstpix, iwidth, src, xpos, 0, 1);
503493}
504494
505static void bitmap_32_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
495void jaguar_state::bitmap_32_1(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
506496{
507   bitmap_32_draw(firstpix, iwidth, src, xpos, 1, -1);
497   bitmap_32_draw(scanline, firstpix, iwidth, src, xpos, 1, -1);
508498}
509499
510static void bitmap_32_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
500void jaguar_state::bitmap_32_2(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
511501{
512   bitmap_32_draw(firstpix, iwidth, src, xpos, 2, 1);
502   bitmap_32_draw(scanline, firstpix, iwidth, src, xpos, 2, 1);
513503}
514504
515static void bitmap_32_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
505void jaguar_state::bitmap_32_3(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
516506{
517   bitmap_32_draw(firstpix, iwidth, src, xpos, 3, -1);
507   bitmap_32_draw(scanline, firstpix, iwidth, src, xpos, 3, -1);
518508}
519509
520static void bitmap_32_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
510void jaguar_state::bitmap_32_4(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
521511{
522   bitmap_32_draw(firstpix, iwidth, src, xpos, 4, 1);
512   bitmap_32_draw(scanline, firstpix, iwidth, src, xpos, 4, 1);
523513}
524514
525static void bitmap_32_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
515void jaguar_state::bitmap_32_5(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
526516{
527   bitmap_32_draw(firstpix, iwidth, src, xpos, 5, -1);
517   bitmap_32_draw(scanline, firstpix, iwidth, src, xpos, 5, -1);
528518}
529519
530static void bitmap_32_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
520void jaguar_state::bitmap_32_6(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
531521{
532   bitmap_32_draw(firstpix, iwidth, src, xpos, 6, 1);
522   bitmap_32_draw(scanline, firstpix, iwidth, src, xpos, 6, 1);
533523}
534524
535static void bitmap_32_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
525void jaguar_state::bitmap_32_7(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
536526{
537   bitmap_32_draw(firstpix, iwidth, src, xpos, 7, -1);
527   bitmap_32_draw(scanline, firstpix, iwidth, src, xpos, 7, -1);
538528}
539529
540static void (*const bitmap32[8])(INT32, INT32, UINT32 *, INT32) =
530void (jaguar_state::*const jaguar_state::bitmap32[8])(UINT16 *, INT32, INT32, UINT32 *, INT32) =
541531{
542   bitmap_32_0,
543   bitmap_32_1,
544   bitmap_32_2,
545   bitmap_32_3,
546   bitmap_32_4,
547   bitmap_32_5,
548   bitmap_32_6,
549   bitmap_32_7
532   &jaguar_state::bitmap_32_0,
533   &jaguar_state::bitmap_32_1,
534   &jaguar_state::bitmap_32_2,
535   &jaguar_state::bitmap_32_3,
536   &jaguar_state::bitmap_32_4,
537   &jaguar_state::bitmap_32_5,
538   &jaguar_state::bitmap_32_6,
539   &jaguar_state::bitmap_32_7
550540};
551541
552542
553543
554INLINE UINT8 lookup_pixel(const UINT32 *src, int i, int pitch, int depth)
544static inline UINT8 lookup_pixel(const UINT32 *src, int i, int pitch, int depth)
555545{
556546   int ppl      = 32 / depth;
557547   UINT32 data   = src[((i & ppl) / ppl) + ((i / (ppl<<1)) * (pitch<<1))];
r17621r17622
567557 *
568558 *************************************/
569559
570static UINT32 *process_bitmap(running_machine &machine, UINT32 *objdata, int vc, int logit)
560UINT32 *jaguar_state::process_bitmap(UINT16 *scanline, UINT32 *objdata, int vc, int logit)
571561{
572562   /* extract minimal data */
573563   UINT32 upper = objdata[0];
r17621r17622
576566   UINT32 height = (lower >> 14) & 0x3ff;
577567   UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8);
578568   UINT32 data = (upper >> 11);
579   UINT32 *src = (UINT32 *)get_jaguar_memory(machine, data << 3);
569   UINT32 *src = (UINT32 *)memory_base(data << 3);
580570
581571   if (logit)
582572   {
r17621r17622
625615         /* 1bpp case */
626616         case 0:
627617         {
628            UINT16 *clut = (UINT16 *)jaguar_gpu_clut + _index;
618            UINT16 *clut = (UINT16 *)&m_gpu_clut[0] + _index;
629619
630620            /* non-blending */
631621            if (!(flags & 2))
r17621r17622
658648         /* 2bpp case */
659649         case 1:
660650         {
661            UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xfc);
651            UINT16 *clut = (UINT16 *)&m_gpu_clut[0] + (_index & 0xfc);
662652
663653            /* non-blending */
664654            if (!(flags & 2))
r17621r17622
694684            if (pitch != 1)
695685               logerror("Unhandled pitch = %d\n", pitch);
696686
697            clutbase = (UINT16 *)jaguar_gpu_clut + (_index & 0xf8);
698            (*bitmap4[flags])(firstpix, iwidth, src, xpos);
687            (this->*bitmap4[flags])(scanline, firstpix, iwidth, src, xpos, (UINT16 *)&m_gpu_clut[0] + (_index & 0xf8));
699688            break;
700689
701690         /* 8bpp case */
r17621r17622
704693            if (pitch != 1)
705694               logerror("Unhandled pitch = %d\n", pitch);
706695
707            clutbase = (UINT16 *)jaguar_gpu_clut;
708            (*bitmap8[flags])(firstpix, iwidth, src, xpos);
696            (this->*bitmap8[flags])(scanline, firstpix, iwidth, src, xpos, (UINT16 *)&m_gpu_clut[0]);
709697            break;
710698
711699         /* 16bpp case */
r17621r17622
714702            if (pitch != 1)
715703               logerror("Unhandled pitch = %d\n", pitch);
716704
717            (*bitmap16[flags])(firstpix, iwidth, src, xpos);
705            (this->*bitmap16[flags])(scanline, firstpix, iwidth, src, xpos);
718706            break;
719707
720708         /* 32bpp case */
r17621r17622
723711            if (pitch != 1)
724712               logerror("Unhandled pitch = %d\n", pitch);
725713
726            (*bitmap32[flags])(firstpix, iwidth, src, xpos);
714            (this->*bitmap32[flags])(scanline, firstpix, iwidth, src, xpos);
727715            break;
728716
729717         default:
r17621r17622
736724      objdata[1] = lower - (1 << 14);
737725   }
738726
739   return (UINT32 *)get_jaguar_memory(machine, link << 3);
727   return (UINT32 *)memory_base(link << 3);
740728}
741729
742730
r17621r17622
747735 *
748736 *************************************/
749737
750static UINT32 *process_scaled_bitmap(running_machine &machine, UINT32 *objdata, int vc, int logit)
738UINT32 *jaguar_state::process_scaled_bitmap(UINT16 *scanline, UINT32 *objdata, int vc, int logit)
751739{
752740   /* extract data */
753741   UINT32 upper = objdata[0];
r17621r17622
756744   UINT32 height = (lower >> 14) & 0x3ff;
757745   UINT32 link = (lower >> 24) | ((upper & 0x7ff) << 8);
758746   UINT32 data = (upper >> 11);
759   UINT32 *src = (UINT32 *)get_jaguar_memory(machine, data << 3);
747   UINT32 *src = (UINT32 *)memory_base(data << 3);
760748
761749   /* third phrase */
762750   UINT32 lower3 = objdata[5];
r17621r17622
829817         {
830818            case 0:
831819            {
832               UINT16 *clut = (UINT16 *)jaguar_gpu_clut + _index;
820               UINT16 *clut = (UINT16 *)&m_gpu_clut[0] + _index;
833821
834822               /* render in phrases */
835823               while (xpix < iwidth)
r17621r17622
851839
852840            case 1:
853841            {
854               UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xfc);
842               UINT16 *clut = (UINT16 *)&m_gpu_clut[0] + (_index & 0xfc);
855843
856844               /* render in phrases */
857845               while (xpix < iwidth)
r17621r17622
873861
874862            case 2:
875863            {
876               UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xf8);
864               UINT16 *clut = (UINT16 *)&m_gpu_clut[0] + (_index & 0xf8);
877865
878866               /* render in phrases */
879867               while (xpix < iwidth)
r17621r17622
895883
896884            case 3:
897885            {
898               UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
886               UINT16 *clut = (UINT16 *)&m_gpu_clut[0];
899887
900888               /* render in phrases */
901889               while (xpix < iwidth)
r17621r17622
952940      objdata[5] = (lower3 & ~0xff0000) | ((remainder & 0xff) << 16);
953941   }
954942
955   return (UINT32 *)get_jaguar_memory(machine, link << 3);
943   return (UINT32 *)memory_base(link << 3);
956944}
957945
958946
r17621r17622
963951 *
964952 *************************************/
965953
966static UINT32 *process_branch(running_machine &machine, UINT32 *objdata, int vc, int logit)
954UINT32 *jaguar_state::process_branch(UINT32 *objdata, int vc, int logit)
967955{
968956   UINT32 upper = objdata[0];
969957   UINT32 lower = objdata[1];
r17621r17622
998986      /* 3: branch if object processor flag is set */
999987      case 3:
1000988         if (logit) logerror("        branch if object flag set to %06X\n", link << 3);
1001         taken = gpu_regs[OBF] & 1;
989         taken = m_gpu_regs[OBF] & 1;
1002990         break;
1003991
1004992      /* 4: branch on second half of display line */
r17621r17622
10141002   }
10151003
10161004   /* handle the branch */
1017   return taken ? (UINT32 *)get_jaguar_memory(machine, link << 3) : (objdata + 2);
1005   return taken ? (UINT32 *)memory_base(link << 3) : (objdata + 2);
10181006}
10191007
10201008
r17621r17622
10251013 *
10261014 *************************************/
10271015
1028static void process_object_list(running_machine &machine, int vc, UINT16 *_scanline)
1016void jaguar_state::process_object_list(int vc, UINT16 *scanline)
10291017{
10301018   int done = 0, count = 0;
10311019   UINT32 *objdata;
r17621r17622
10331021   int x;
10341022
10351023   /* erase the scanline first */
1036   scanline = _scanline;
10371024   for (x = 0; x < 760; x++)
1038      scanline[x] = gpu_regs[BG];
1025      scanline[x] = m_gpu_regs[BG];
10391026
10401027   logit = LOG_OBJECTS;
10411028
10421029   /* fetch the object pointer */
1043   objdata = (UINT32 *)get_jaguar_memory(machine, (gpu_regs[OLP_H] << 16) | gpu_regs[OLP_L]);
1030   objdata = (UINT32 *)memory_base((m_gpu_regs[OLP_H] << 16) | m_gpu_regs[OLP_L]);
10441031   while (!done && objdata && count++ < 100)
10451032   {
10461033      /* the low 3 bits determine the command */
r17621r17622
10501037         case 0:
10511038            if (logit)
10521039               logerror("bitmap = %08X-%08X %08X-%08X\n", objdata[0], objdata[1], objdata[2], objdata[3]);
1053            objdata = process_bitmap(machine, objdata, vc, logit);
1040            objdata = process_bitmap(scanline, objdata, vc, logit);
10541041            break;
10551042
10561043         /* scaled bitmap object */
10571044         case 1:
10581045            if (logit)
10591046               logerror("scaled = %08X-%08X %08X-%08X %08X-%08X\n", objdata[0], objdata[1], objdata[2], objdata[3], objdata[4], objdata[5]);
1060            objdata = process_scaled_bitmap(machine, objdata, vc, logit);
1047            objdata = process_scaled_bitmap(scanline, objdata, vc, logit);
10611048            break;
10621049
10631050
10641051         /* GPU interrupt */
10651052         case 2:
1066            gpu_regs[OB_HH]=(objdata[1]&0xffff0000)>>16;
1067            gpu_regs[OB_HL]=objdata[1]&0xffff;
1068            gpu_regs[OB_LH]=(objdata[0]&0xffff0000)>>16;
1069            gpu_regs[OB_LL]=objdata[0]&0xffff;
1070            cpu_irq_state |= 2;
1071            update_cpu_irq(machine);
1053            m_gpu_regs[OB_HH]=(objdata[1]&0xffff0000)>>16;
1054            m_gpu_regs[OB_HL]=objdata[1]&0xffff;
1055            m_gpu_regs[OB_LH]=(objdata[0]&0xffff0000)>>16;
1056            m_gpu_regs[OB_LL]=objdata[0]&0xffff;
1057            m_cpu_irq_state |= 2;
1058            update_cpu_irq();
10721059            done=1;
10731060            break;
10741061
r17621r17622
10761063         case 3:
10771064            if (logit)
10781065               logerror("branch = %08X-%08X\n", objdata[0], objdata[1]);
1079            objdata = process_branch(machine, objdata, vc, logit);
1066            objdata = process_branch(objdata, vc, logit);
10801067            break;
10811068
10821069         /* stop */
r17621r17622
10901077            if (interrupt)
10911078            {
10921079//                  fprintf(stderr, "stop int=%d\n", interrupt);
1093               cpu_irq_state |= 4;
1094               update_cpu_irq(machine);
1080               m_cpu_irq_state |= 4;
1081               update_cpu_irq();
10951082            }
10961083            break;
10971084         }
trunk/src/mame/video/jaguar.c
r17621r17622
151151#define LOG_UNHANDLED_BLITS   0
152152
153153
154// FIXME: this should be 1, but then MAME performance will be s*** with this
155//    (i.e. it drops the performance from 400% to 6% on an i5 machine).
156// But the PIT irq is definitely needed by some games (for example Pitfall refuses
157//    to enter into gameplay without this enabled).
158const int PIT_MULT_DBG_HACK = 64;
159
160
154161// interrupts to main CPU:
155162//  0 = video (on the VI scanline)
156163//  1 = GPU (write from GPU coprocessor)
r17621r17622
183190
184191/*************************************
185192 *
186 *  Local variables
187 *
188 *************************************/
189
190/* blitter variables */
191static UINT32 blitter_regs[BLITTER_REGS];
192static UINT16 gpu_regs[GPU_REGS];
193
194static emu_timer *object_timer;
195static UINT8 cpu_irq_state;
196
197static bitmap_rgb32 *screen_bitmap;
198
199static pen_t *pen_table;
200static int pixel_clock;
201
202UINT8 blitter_status;
203
204
205/*************************************
206 *
207193 *  Prototypes
208194 *
209195 *************************************/
210196
211/* from jagobj.c */
212static void jagobj_init(running_machine &machine);
213static void process_object_list(running_machine &machine, int vc, UINT16 *_scanline);
214197
215/* from jagblit.c */
216static void generic_blitter(running_machine &machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
217static void blitter_09800001_010020_010020(running_machine &machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
218static void blitter_09800009_000020_000020(running_machine &machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
219static void blitter_01800009_000028_000028(running_machine &machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
220static void blitter_01800001_000018_000018(running_machine &machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
221static void blitter_01c00001_000018_000018(running_machine &machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
222static void blitter_00010000_xxxxxx_xxxxxx(running_machine &machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
223static void blitter_01800001_xxxxxx_xxxxxx(running_machine &machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
224static void blitter_x1800x01_xxxxxx_xxxxxx(running_machine &machine, UINT32 command, UINT32 a1flags, UINT32 a2flags);
225198
226
227
228199/*************************************
229200 *
230201 *  Compute X/Y coordinates
231202 *
232203 *************************************/
233204
234INLINE void get_crosshair_xy(running_machine &machine, int player, int *x, int *y)
205inline void jaguar_state::get_crosshair_xy(int player, int &x, int &y)
235206{
236   const rectangle &visarea = machine.primary_screen->visible_area();
207   const rectangle &visarea = machine().primary_screen->visible_area();
237208
238   int width = visarea.width();
239   int height = visarea.height();
240209   /* only 2 lightguns are connected */
241   *x = visarea.min_x + (((machine.root_device().ioport(player ? "FAKE2_X" : "FAKE1_X")->read() & 0xff) * width) >> 8);
242   *y = visarea.min_y + (((machine.root_device().ioport(player ? "FAKE2_Y" : "FAKE1_Y")->read() & 0xff) * height) >> 8);
210   x = visarea.min_x + (((ioport(player ? "FAKE2_X" : "FAKE1_X")->read() & 0xff) * visarea.width()) >> 8);
211   y = visarea.min_y + (((ioport(player ? "FAKE2_Y" : "FAKE1_Y")->read() & 0xff) * visarea.height()) >> 8);
243212}
244213
245214
r17621r17622
250219 *
251220 *************************************/
252221
253INLINE int effective_hvalue(int value)
222inline int jaguar_state::effective_hvalue(int value)
254223{
255224   if (!(value & 0x400))
256225      return value & 0x3ff;
257226   else
258      return (value & 0x3ff) + (gpu_regs[HP] & 0x3ff) + 1;
227      return (value & 0x3ff) + (m_gpu_regs[HP] & 0x3ff) + 1;
259228}
260229
261230
r17621r17622
266235 *
267236 *************************************/
268237
269INLINE int adjust_object_timer(running_machine &machine, int vc)
238inline bool jaguar_state::adjust_object_timer(int vc)
270239{
240   /* extract the display begin registers */
271241   int hdbpix[2];
272   int hdb = 0;
242   hdbpix[0] = (m_gpu_regs[HDB1] & 0x7ff) / 2;
243   hdbpix[1] = (m_gpu_regs[HDB2] & 0x7ff) / 2;
273244
274   /* extract the display begin registers */
275   hdbpix[0] = (gpu_regs[HDB1] & 0x7ff) / 2;
276   hdbpix[1] = (gpu_regs[HDB2] & 0x7ff) / 2;
277
278245   /* sort */
279246   if (hdbpix[0] > hdbpix[1])
280247   {
r17621r17622
284251   }
285252
286253   /* select the target one */
287   hdb = hdbpix[vc % 2];
254   int hdb = hdbpix[vc % 2];
288255
289256   /* if setting the second one in a line, make sure we will ever actually hit it */
290   if (vc % 2 == 1 && (hdbpix[1] == hdbpix[0] || hdbpix[1] >= machine.primary_screen->width()))
291      return FALSE;
257   if (vc % 2 == 1 && (hdbpix[1] == hdbpix[0] || hdbpix[1] >= machine().primary_screen->width()))
258      return false;
292259
293260   /* adjust the timer */
294   object_timer->adjust(machine.primary_screen->time_until_pos(vc / 2, hdb), vc | (hdb << 16));
295   return TRUE;
261   m_object_timer->adjust(machine().primary_screen->time_until_pos(vc / 2, hdb), vc | (hdb << 16));
262   return true;
296263}
297264
298265
299266
300267/*************************************
301268 *
302 *  GPU optimization control
303 *
304 *************************************/
305
306void jaguar_gpu_suspend(running_machine &machine)
307{
308   machine.device<cpu_device>("gpu")->suspend(SUSPEND_REASON_SPIN, 1);
309}
310
311
312void jaguar_gpu_resume(running_machine &machine)
313{
314   machine.device<cpu_device>("gpu")->resume(SUSPEND_REASON_SPIN);
315}
316
317
318
319/*************************************
320 *
321269 *  Main CPU interrupts
322270 *
323271 *************************************/
324272
325static void update_cpu_irq(running_machine &machine)
273void jaguar_state::update_cpu_irq()
326274{
327   if (cpu_irq_state & gpu_regs[INT1] & 0x1f)
328      cputag_set_input_line(machine, "maincpu", cojag_is_r3000 ? R3000_IRQ4 : M68K_IRQ_6, ASSERT_LINE);
275   if ((m_cpu_irq_state & m_gpu_regs[INT1] & 0x1f) != 0)
276      m_main_cpu->set_input_line(m_is_r3000 ? R3000_IRQ4 : M68K_IRQ_6, ASSERT_LINE);
329277   else
330      cputag_set_input_line(machine, "maincpu", cojag_is_r3000 ? R3000_IRQ4 : M68K_IRQ_6, CLEAR_LINE);
278      m_main_cpu->set_input_line(m_is_r3000 ? R3000_IRQ4 : M68K_IRQ_6, CLEAR_LINE);
331279}
332280
333281
334void jaguar_gpu_cpu_int(device_t *device)
282void jaguar_state::gpu_cpu_int(device_t *device)
335283{
336   cpu_irq_state |= 2;
337   update_cpu_irq(device->machine());
284   jaguar_state &state = *device->machine().driver_data<jaguar_state>();
285   state.m_cpu_irq_state |= 2;
286   state.update_cpu_irq();
338287}
339288
340
341void jaguar_dsp_cpu_int(device_t *device)
289void jaguar_state::dsp_cpu_int(device_t *device)
342290{
343   cpu_irq_state |= 16;
344   update_cpu_irq(device->machine());
291   jaguar_state &state = *device->machine().driver_data<jaguar_state>();
292   state.m_cpu_irq_state |= 16;
293   state.update_cpu_irq();
345294}
346295
347296
r17621r17622
352301 *
353302 *************************************/
354303
355static void jaguar_set_palette(UINT16 vmode)
304void jaguar_state::set_palette(UINT16 vmode)
356305{
357306   static const UINT8 red_lookup[256] =
358307   {
r17621r17622
428377            UINT8 r = (red_lookup[i >> 8] * (i & 0xff)) >> 8;
429378            UINT8 g = (grn_lookup[i >> 8] * (i & 0xff)) >> 8;
430379            UINT8 b = (blu_lookup[i >> 8] * (i & 0xff)) >> 8;
431            pen_table[i] = MAKE_RGB(r, g, b);
380            m_pen_table[i] = MAKE_RGB(r, g, b);
432381         }
433382         break;
434383
r17621r17622
450399               g = (g << 3) | (g >> 2);
451400               b = (b << 3) | (b >> 2);
452401            }
453            pen_table[i] = MAKE_RGB(r, g, b);
402            m_pen_table[i] = MAKE_RGB(r, g, b);
454403         }
455404         break;
456405
r17621r17622
459408         for (i = 0; i < 65536; i++)
460409         {
461410            if (i & 1) // FIXME: controls RGB 5-5-5 / 5-6-5 format or it's just ignored? Used by UBI Soft logo in Rayman
462               pen_table[i] = MAKE_RGB(pal5bit(i >> 11), pal5bit(i >> 1), pal5bit(i >> 6));
411               m_pen_table[i] = MAKE_RGB(pal5bit(i >> 11), pal5bit(i >> 1), pal5bit(i >> 6));
463412            else
464               pen_table[i] = MAKE_RGB(pal5bit(i >> 11), pal6bit(i >> 0), pal5bit(i >> 6));
413               m_pen_table[i] = MAKE_RGB(pal5bit(i >> 11), pal6bit(i >> 0), pal5bit(i >> 6));
465414         }
466415         break;
467416
468417      /* RGB full */
469418      case 0x006:
470419         for (i = 0; i < 65536; i++)
471            pen_table[i] = MAKE_RGB(pal5bit(i >> 11), pal6bit(i >> 0), pal5bit(i >> 6));
420            m_pen_table[i] = MAKE_RGB(pal5bit(i >> 11), pal6bit(i >> 0), pal5bit(i >> 6));
472421         break;
473422
474423      /* others */
r17621r17622
483432
484433/*************************************
485434 *
486 *  Fast memory accessors
487 *
488 *************************************/
489
490static UINT8 *get_jaguar_memory(running_machine &machine, UINT32 offset)
491{
492   address_space *space = machine.device("gpu")->memory().space(AS_PROGRAM);
493   return (UINT8 *)space->get_read_ptr(offset);
494}
495
496
497
498/*************************************
499 *
500435 *  32-bit access to the blitter
501436 *
502437 *************************************/
503438
504static void blitter_run(running_machine &machine)
439void jaguar_state::blitter_run()
505440{
506   UINT32 command = blitter_regs[B_CMD] & STATIC_COMMAND_MASK;
507   UINT32 a1flags = blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK;
508   UINT32 a2flags = blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK;
441   UINT32 command = m_blitter_regs[B_CMD] & STATIC_COMMAND_MASK;
442   UINT32 a1flags = m_blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK;
443   UINT32 a2flags = m_blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK;
509444
510445   g_profiler.start(PROFILER_USER1);
511446
r17621r17622
513448   {
514449      if (command == 0x09800001 && a1flags == 0x010020)
515450      {
516         blitter_09800001_010020_010020(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
451         blitter_09800001_010020_010020(m_blitter_regs[B_CMD], m_blitter_regs[A1_FLAGS], m_blitter_regs[A2_FLAGS]);
517452         return;
518453      }
519454      if (command == 0x09800009 && a1flags == 0x000020)
520455      {
521         blitter_09800009_000020_000020(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
456         blitter_09800009_000020_000020(m_blitter_regs[B_CMD], m_blitter_regs[A1_FLAGS], m_blitter_regs[A2_FLAGS]);
522457         return;
523458      }
524459      if (command == 0x01800009 && a1flags == 0x000028)
525460      {
526         blitter_01800009_000028_000028(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
461         blitter_01800009_000028_000028(m_blitter_regs[B_CMD], m_blitter_regs[A1_FLAGS], m_blitter_regs[A2_FLAGS]);
527462         return;
528463      }
529464
530465      if (command == 0x01800001 && a1flags == 0x000018)
531466      {
532         blitter_01800001_000018_000018(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
467         blitter_01800001_000018_000018(m_blitter_regs[B_CMD], m_blitter_regs[A1_FLAGS], m_blitter_regs[A2_FLAGS]);
533468         return;
534469      }
535470
536471      if (command == 0x01c00001 && a1flags == 0x000018)
537472      {
538         blitter_01c00001_000018_000018(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
473         blitter_01c00001_000018_000018(m_blitter_regs[B_CMD], m_blitter_regs[A1_FLAGS], m_blitter_regs[A2_FLAGS]);
539474         return;
540475      }
541476   }
542477
543478   if (command == 0x00010000)
544479   {
545      blitter_00010000_xxxxxx_xxxxxx(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
480      blitter_00010000_xxxxxx_xxxxxx(m_blitter_regs[B_CMD], m_blitter_regs[A1_FLAGS], m_blitter_regs[A2_FLAGS]);
546481      return;
547482   }
548483
549484   if (command == 0x01800001)
550485   {
551      blitter_01800001_xxxxxx_xxxxxx(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
486      blitter_01800001_xxxxxx_xxxxxx(m_blitter_regs[B_CMD], m_blitter_regs[A1_FLAGS], m_blitter_regs[A2_FLAGS]);
552487      return;
553488   }
554489
555490   if ((command & 0x0ffff0ff) == 0x01800001)
556491   {
557      blitter_x1800x01_xxxxxx_xxxxxx(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
492      blitter_x1800x01_xxxxxx_xxxxxx(m_blitter_regs[B_CMD], m_blitter_regs[A1_FLAGS], m_blitter_regs[A2_FLAGS]);
558493      return;
559494   }
560495
r17621r17622
566501static int reps = 0;
567502int i;
568503for (i = 0; i < blitter_count; i++)
569   if (blitter_stats[i][0] == (blitter_regs[B_CMD] & STATIC_COMMAND_MASK) &&
570      blitter_stats[i][1] == (blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK) &&
571      blitter_stats[i][2] == (blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK))
504   if (blitter_stats[i][0] == (m_blitter_regs[B_CMD] & STATIC_COMMAND_MASK) &&
505      blitter_stats[i][1] == (m_blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK) &&
506      blitter_stats[i][2] == (m_blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK))
572507      break;
573508if (i == blitter_count)
574509{
575   blitter_stats[i][0] = blitter_regs[B_CMD] & STATIC_COMMAND_MASK;
576   blitter_stats[i][1] = blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK;
577   blitter_stats[i][2] = blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK;
510   blitter_stats[i][0] = m_blitter_regs[B_CMD] & STATIC_COMMAND_MASK;
511   blitter_stats[i][1] = m_blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK;
512   blitter_stats[i][2] = m_blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK;
578513   blitter_stats[i][3] = 0;
579514   blitter_pixels[i] = 0;
580515   blitter_count++;
581516}
582517blitter_stats[i][3]++;
583blitter_pixels[i] += (blitter_regs[B_COUNT] & 0xffff) * (blitter_regs[B_COUNT] >> 16);
518blitter_pixels[i] += (m_blitter_regs[B_COUNT] & 0xffff) * (m_blitter_regs[B_COUNT] >> 16);
584519if (++reps % 100 == 99)
585520{
586521   mame_printf_debug("---\nBlitter stats:\n");
r17621r17622
592527}
593528}
594529
595   generic_blitter(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
530   generic_blitter(m_blitter_regs[B_CMD], m_blitter_regs[A1_FLAGS], m_blitter_regs[A2_FLAGS]);
596531   g_profiler.stop();
597532}
598533
599static TIMER_CALLBACK( blitter_done )
534READ32_MEMBER( jaguar_state::blitter_r )
600535{
601   blitter_status = 1;
602}
603
604READ32_HANDLER( jaguar_blitter_r )
605{
606536   switch (offset)
607537   {
608538      case B_CMD:   /* B_CMD */
609         return blitter_status & 3;
539         return m_blitter_status & 3;
610540
611541      default:
612         logerror("%08X:Blitter read register @ F022%02X\n", cpu_get_previouspc(&space->device()), offset * 4);
542         logerror("%08X:Blitter read register @ F022%02X\n", cpu_get_previouspc(&space.device()), offset * 4);
613543         return 0;
614544   }
615545}
616546
617547
618WRITE32_HANDLER( jaguar_blitter_w )
548WRITE32_MEMBER( jaguar_state::blitter_w )
619549{
620   COMBINE_DATA(&blitter_regs[offset]);
550   COMBINE_DATA(&m_blitter_regs[offset]);
621551   if ((offset == B_CMD) && (mem_mask & 0x0000ffff))
622552   {
623      blitter_status = 0;
624      space->machine().scheduler().timer_set(attotime::from_usec(100), FUNC(blitter_done));
625      blitter_run(space->machine());
553      m_blitter_status = 0;
554      timer_set(attotime::from_usec(100), TID_BLITTER_DONE);
555      blitter_run();
626556   }
627557
628558   if (LOG_BLITTER_WRITE)
629   logerror("%08X:Blitter write register @ F022%02X = %08X\n", cpu_get_previouspc(&space->device()), offset * 4, data);
559   logerror("%08X:Blitter write register @ F022%02X = %08X\n", cpu_get_previouspc(&space.device()), offset * 4, data);
630560}
631561
632562
r17621r17622
637567 *
638568 *************************************/
639569
640READ16_HANDLER( jaguar_tom_regs_r )
570READ16_MEMBER( jaguar_state::tom_regs_r )
641571{
642572   if (offset != INT1 && offset != INT2 && offset != HC && offset != VC)
643      logerror("%08X:TOM read register @ F00%03X\n", cpu_get_previouspc(&space->device()), offset * 2);
573      logerror("%08X:TOM read register @ F00%03X\n", cpu_get_previouspc(&space.device()), offset * 2);
644574
645575   switch (offset)
646576   {
647577      case INT1:
648         return cpu_irq_state;
578         return m_cpu_irq_state;
649579
650580      case HC:
651         return space->machine().primary_screen->hpos() % (space->machine().primary_screen->width() / 2);
581         return machine().primary_screen->hpos() % (machine().primary_screen->width() / 2);
652582
653583      case VC:
654584      {
655585         UINT8 half_line;
656586
657         if(space->machine().primary_screen->hpos() >= (space->machine().primary_screen->width() / 2))
587         if(machine().primary_screen->hpos() >= (machine().primary_screen->width() / 2))
658588            half_line = 1;
659589         else
660590            half_line = 0;
661591
662         return space->machine().primary_screen->vpos() * 2 + half_line;
592         return machine().primary_screen->vpos() * 2 + half_line;
663593      }
664594   }
665595
666   return gpu_regs[offset];
596   return m_gpu_regs[offset];
667597}
668598
669/*
670FIXME: this should be 1, but then MAME performance will be s*** with this (i.e. it drops the performance from 400% to 6% on an i5 machine).
671But the PIT irq is definitely needed by some games (for example Pitfall refuses to enter into gameplay without this enabled).
672*/
673#define PIT_MULT_DBG_HACK 64
674
675static TIMER_CALLBACK( jaguar_pit )
599WRITE16_MEMBER( jaguar_state::tom_regs_w )
676600{
601   UINT32 reg_store = m_gpu_regs[offset];
677602   attotime sample_period;
678   cpu_irq_state |= 4;
679   update_cpu_irq(machine);
680
681   if (gpu_regs[PIT0])
682   {
683      sample_period = attotime::from_nsec(((machine.device("gpu")->unscaled_clock()*PIT_MULT_DBG_HACK) / (1+gpu_regs[PIT0])) / (1+gpu_regs[PIT1]));
684      machine.scheduler().timer_set(sample_period, FUNC(jaguar_pit));
685   }
686}
687
688
689WRITE16_HANDLER( jaguar_tom_regs_w )
690{
691   UINT32 reg_store = gpu_regs[offset];
692   attotime sample_period;
693603   if (offset < GPU_REGS)
694604   {
695      COMBINE_DATA(&gpu_regs[offset]);
605      COMBINE_DATA(&m_gpu_regs[offset]);
696606
697607      switch (offset)
698608      {
699609         case MEMCON1:
700            if((gpu_regs[offset] & 1) == 0)
610            if((m_gpu_regs[offset] & 1) == 0)
701611               printf("Warning: ROMHI = 0!\n");
702612
703613            break;
704614         case PIT0:
705615         case PIT1:
706            if (gpu_regs[PIT0] && gpu_regs[PIT0] != 0xffff) //FIXME: avoid too much small timers for now
616            if (m_gpu_regs[PIT0] && m_gpu_regs[PIT0] != 0xffff) //FIXME: avoid too much small timers for now
707617            {
708               sample_period = attotime::from_nsec(((space->machine().device("gpu")->unscaled_clock()*PIT_MULT_DBG_HACK) / (1+gpu_regs[PIT0])) / (1+gpu_regs[PIT1]));
709               space->machine().scheduler().timer_set(sample_period, FUNC(jaguar_pit));
618               sample_period = attotime::from_nsec(((m_gpu->unscaled_clock()*PIT_MULT_DBG_HACK) / (1+m_gpu_regs[PIT0])) / (1+m_gpu_regs[PIT1]));
619               timer_set(sample_period, TID_PIT);
710620            }
711621            break;
712622
713623         case INT1:
714            cpu_irq_state &= ~(gpu_regs[INT1] >> 8);
715            update_cpu_irq(space->machine());
624            m_cpu_irq_state &= ~(m_gpu_regs[INT1] >> 8);
625            update_cpu_irq();
716626            break;
717627
718628         case VMODE:
719            if (reg_store != gpu_regs[offset])
720               jaguar_set_palette(gpu_regs[VMODE]);
629            if (reg_store != m_gpu_regs[offset])
630               set_palette(m_gpu_regs[VMODE]);
721631            break;
722632
723633         case OBF:   /* clear GPU interrupt */
724            cpu_irq_state &= 0xfd;
725            update_cpu_irq(space->machine());
634            m_cpu_irq_state &= 0xfd;
635            update_cpu_irq();
726636            break;
727637
728638         case HP:
r17621r17622
737647         case VDB:
738648         case VDE:
739649         {
740            if (reg_store != gpu_regs[offset])
650            if (reg_store != m_gpu_regs[offset])
741651            {
742               int hperiod = 2 * ((gpu_regs[HP] & 0x3ff) + 1);
743               int hbend = effective_hvalue(ENABLE_BORDERS ? gpu_regs[HBE] : MIN(gpu_regs[HDB1], gpu_regs[HDB2]));
744               int hbstart = effective_hvalue(gpu_regs[ENABLE_BORDERS ? HBB : HDE]);
745               int vperiod = (gpu_regs[VP] & 0x7ff) + 1;
746               int vbend = MAX(gpu_regs[VBE],gpu_regs[VDB]) & 0x7ff;
747               int vbstart = gpu_regs[VBB] & 0x7ff;
652               int hperiod = 2 * ((m_gpu_regs[HP] & 0x3ff) + 1);
653               int hbend = effective_hvalue(ENABLE_BORDERS ? m_gpu_regs[HBE] : MIN(m_gpu_regs[HDB1], m_gpu_regs[HDB2]));
654               int hbstart = effective_hvalue(m_gpu_regs[ENABLE_BORDERS ? HBB : HDE]);
655               int vperiod = (m_gpu_regs[VP] & 0x7ff) + 1;
656               int vbend = MAX(m_gpu_regs[VBE],m_gpu_regs[VDB]) & 0x7ff;
657               int vbstart = m_gpu_regs[VBB] & 0x7ff;
748658
749659               /* adjust for the half-lines */
750660               if (hperiod != 0 && vperiod != 0 && hbend < hbstart && vbend < vbstart && hbstart < hperiod)
751661               {
752662                  rectangle visarea(hbend / 2, hbstart / 2 - 1, vbend / 2, vbstart / 2 - 1);
753                  space->machine().primary_screen->configure(hperiod / 2, vperiod / 2, visarea, HZ_TO_ATTOSECONDS((double)pixel_clock * 2 / hperiod / vperiod));
663                  machine().primary_screen->configure(hperiod / 2, vperiod / 2, visarea, HZ_TO_ATTOSECONDS(double(m_pixel_clock) * 2 / hperiod / vperiod));
754664               }
755665            }
756666            break;
r17621r17622
759669   }
760670
761671   if (offset != INT2 && offset != VI && offset != INT1)
762      logerror("%08X:TOM write register @ F00%03X = %04X\n", cpu_get_previouspc(&space->device()), offset * 2, data);
672      logerror("%08X:TOM write register @ F00%03X = %04X\n", cpu_get_previouspc(&space.device()), offset * 2, data);
763673}
764674
765675
r17621r17622
770680 *
771681 *************************************/
772682
773READ32_HANDLER( cojag_gun_input_r )
683READ32_MEMBER( jaguar_state::cojag_gun_input_r )
774684{
775685   int beamx, beamy;
776686
777687   switch (offset)
778688   {
779689      case 0:
780         get_crosshair_xy(space->machine(), 1, &beamx, &beamy);
690         get_crosshair_xy(1, beamx, beamy);
781691         return (beamy << 16) | (beamx ^ 0x1ff);
782692
783693      case 1:
784         get_crosshair_xy(space->machine(), 0, &beamx, &beamy);
694         get_crosshair_xy(0, beamx, beamy);
785695         return (beamy << 16) | (beamx ^ 0x1ff);
786696
787697      case 2:
788         return space->machine().root_device().ioport("IN3")->read();
698         return ioport("IN3")->read();
789699   }
790700   return 0;
791701}
r17621r17622
798708 *
799709 *************************************/
800710
801static TIMER_CALLBACK( cojag_scanline_update )
711void jaguar_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
802712{
713   switch (id)
714   {
715      case TID_SCANLINE:
716         scanline_update(param);
717         break;
718     
719      case TID_BLITTER_DONE:
720         m_blitter_status = 1;
721         break;
722     
723      case TID_PIT:
724         m_cpu_irq_state |= 4;
725         update_cpu_irq();
726         if (m_gpu_regs[PIT0] != 0)
727         {
728            attotime sample_period = attotime::from_nsec(((m_gpu->unscaled_clock()*PIT_MULT_DBG_HACK) / (1+m_gpu_regs[PIT0])) / (1+m_gpu_regs[PIT1]));
729            timer_set(sample_period, TID_PIT);
730         }
731         break;
732     
733      case TID_SERIAL:
734         serial_update();
735         break;
736     
737      case TID_GPU_SYNC:
738         // if a command is still pending, and we haven't maxed out our timer, set a new one
739         if (m_gpu_command_pending && param < 1000)
740            timer_set(attotime::from_usec(50), TID_GPU_SYNC, ++param);
741         break;
742   }
743}
744
745void jaguar_state::scanline_update(int param)
746{
803747   int vc = param & 0xffff;
804748   int hdb = param >> 16;
805   const rectangle &visarea = machine.primary_screen->visible_area();
749   const rectangle &visarea = machine().primary_screen->visible_area();
806750
807751   /* only run if video is enabled and we are past the "display begin" */
808   if ((gpu_regs[VMODE] & 1) && vc >= (gpu_regs[VDB] & 0x7ff))
752   if ((m_gpu_regs[VMODE] & 1) && vc >= (m_gpu_regs[VDB] & 0x7ff))
809753   {
810      UINT32 *dest = &screen_bitmap->pix32(vc >> 1);
754      UINT32 *dest = &m_screen_bitmap.pix32(vc >> 1);
811755      int maxx = visarea.max_x;
812      int hde = effective_hvalue(gpu_regs[HDE]) >> 1;
756      int hde = effective_hvalue(m_gpu_regs[HDE]) >> 1;
813757      UINT16 x,scanline[760];
814      UINT8 y,pixel_width = ((gpu_regs[VMODE]>>10)&3)+1;
758      UINT8 y,pixel_width = ((m_gpu_regs[VMODE]>>10)&3)+1;
815759
816760      /* if we are first on this scanline, clear to the border color */
817761      if (ENABLE_BORDERS && vc % 2 == 0)
818762      {
819         rgb_t border = MAKE_RGB(gpu_regs[BORD1] & 0xff, gpu_regs[BORD1] >> 8, gpu_regs[BORD2] & 0xff);
763         rgb_t border = MAKE_RGB(m_gpu_regs[BORD1] & 0xff, m_gpu_regs[BORD1] >> 8, m_gpu_regs[BORD2] & 0xff);
820764         for (x = visarea.min_x; x <= visarea.max_x; x++)
821765            dest[x] = border;
822766      }
823767
824768      /* process the object list for this counter value */
825      process_object_list(machine, vc, scanline);
769      process_object_list(vc, scanline);
826770
827771      /* copy the data to the target, clipping */
828      if ((gpu_regs[VMODE] & 0x106) == 0x002)   /* RGB24 */
772      if ((m_gpu_regs[VMODE] & 0x106) == 0x002)   /* RGB24 */
829773      {
830774         for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x+=2)
831775            for (y = 0; y < pixel_width; y++)
832776            {
833               UINT8 r = pen_table[(scanline[x]&0xff)|256];
834               UINT8 g = pen_table[(scanline[x]>>8)|512];
835               UINT8 b = pen_table[scanline[x+1]&0xff];
777               UINT8 r = m_pen_table[(scanline[x]&0xff)|256];
778               UINT8 g = m_pen_table[(scanline[x]>>8)|512];
779               UINT8 b = m_pen_table[scanline[x+1]&0xff];
836780               dest[hdb++] = MAKE_RGB(r, g, b);
837781            }
838782      }
r17621r17622
840784      {
841785         for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x++)
842786            for (y = 0; y < pixel_width; y++)
843               dest[hdb++] = pen_table[scanline[x]];
787               dest[hdb++] = m_pen_table[scanline[x]];
844788      }
845789   }
846790
r17621r17622
848792   do
849793   {
850794      /* handle vertical interrupts */
851      if (vc == gpu_regs[VI])
795      if (vc == m_gpu_regs[VI])
852796      {
853         cpu_irq_state |= 1;
854         update_cpu_irq(machine);
797         m_cpu_irq_state |= 1;
798         update_cpu_irq();
855799      }
856800
857801      /* point to the next counter value */
858      if (++vc / 2 >= machine.primary_screen->height())
802      if (++vc / 2 >= machine().primary_screen->height())
859803         vc = 0;
860804
861   } while (!adjust_object_timer(machine, vc));
805   } while (!adjust_object_timer(vc));
862806}
863807
864VIDEO_START( cojag )
808void jaguar_state::video_start()
865809{
866   memset(&blitter_regs, 0, sizeof(blitter_regs));
867   memset(&gpu_regs, 0, sizeof(gpu_regs));
868   cpu_irq_state = 0;
810   memset(&m_blitter_regs, 0, sizeof(m_blitter_regs));
811   memset(&m_gpu_regs, 0, sizeof(m_gpu_regs));
812   m_cpu_irq_state = 0;
869813
870   object_timer = machine.scheduler().timer_alloc(FUNC(cojag_scanline_update));
871   adjust_object_timer(machine, 0);
814   m_object_timer = timer_alloc(TID_SCANLINE);
815   adjust_object_timer(0);
872816
873   screen_bitmap = auto_bitmap_rgb32_alloc(machine, 760, 512);
817   m_screen_bitmap.allocate(760, 512);
874818
875   jagobj_init(machine);
819   jagobj_init();
876820
877   pen_table = auto_alloc_array(machine, pen_t, 65536);
878
879   state_save_register_global_pointer(machine, pen_table, 65536);
880   state_save_register_global_array(machine, blitter_regs);
881   state_save_register_global_array(machine, gpu_regs);
882   state_save_register_global(machine, cpu_irq_state);
883   machine.save().register_postload(save_prepost_delegate(FUNC(update_cpu_irq), &machine));
884   pixel_clock = COJAG_PIXEL_CLOCK;
821   save_item(NAME(m_pen_table));
822   save_item(NAME(m_blitter_regs));
823   save_item(NAME(m_gpu_regs));
824   save_item(NAME(m_cpu_irq_state));
825   m_pixel_clock = m_is_cojag ? COJAG_PIXEL_CLOCK : JAGUAR_CLOCK;
885826}
886827
887VIDEO_START( jaguar )
828
829void jaguar_state::device_postload()
888830{
889   VIDEO_START_CALL( cojag );
890   pixel_clock = JAGUAR_CLOCK;
831   update_cpu_irq();
891832}
892833
893834
r17621r17622
897838 *
898839 *************************************/
899840
900SCREEN_UPDATE_RGB32( cojag )
841UINT32 jaguar_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
901842{
902843   /* if not enabled, just blank */
903   if (!(gpu_regs[VMODE] & 1))
844   if (!(m_gpu_regs[VMODE] & 1))
904845   {
905846      bitmap.fill(0, cliprect);
906847      return 0;
907848   }
908849
909850   /* render the object list */
910   copybitmap(bitmap, *screen_bitmap, 0, 0, 0, 0, cliprect);
851   copybitmap(bitmap, m_screen_bitmap, 0, 0, 0, 0, cliprect);
911852   return 0;
912853}
913854
trunk/src/mame/includes/jaguar.h
r17621r17622
44
55*************************************************************************/
66
7#include "cpu/jaguar/jaguar.h"
8#include "machine/nvram.h"
9#include "sound/dac.h"
10
711#ifndef ENABLE_SPEEDUP_HACKS
812#define ENABLE_SPEEDUP_HACKS 1
913#endif
r17621r17622
1317#define JAGUAR_CLOCK         XTAL_25_590906MHz // NTSC
1418// XTAL_25_593900MHz PAL, TODO
1519
16/*----------- defined in drivers/cojag.c -----------*/
20class jaguar_state : public driver_device
21{
22public:
23   jaguar_state(const machine_config &mconfig, device_type type, const char *tag)
24      : driver_device(mconfig, type, tag),
25        m_main_cpu(*this, "maincpu"),
26        m_gpu(*this, "gpu"),
27        m_dsp(*this, "dsp"),
28        m_dac1(*this, "dac1"),
29        m_dac2(*this, "dac2"),
30        m_nvram(*this, "nvram"),
31        m_rom_base(*this, "rom"),
32        m_cart_base(*this, "cart"),
33        m_dsp_ram(*this, "dspram"),
34        m_wave_rom(*this, "waverom"),
35        m_shared_ram(*this, "sharedram"),
36        m_gpu_ram(*this, "gpuram"),
37        m_gpu_clut(*this, "gpuclut"),
38        m_is_r3000(false),
39        m_is_cojag(false),
40        m_hacks_enabled(false),
41        m_using_cart(false),
42        m_misc_control_data(0),
43        m_eeprom_enable(true),
44        m_gpu_jump_address(NULL),
45        m_gpu_command_pending(false),
46        m_gpu_spin_pc(0),
47        m_main_speedup(NULL),
48        m_main_speedup_hits(0),
49        m_main_speedup_last_cycles(0),
50        m_main_speedup_max_cycles(0),
51        m_main_gpu_wait(NULL),
52        m_joystick_data(0),
53        m_eeprom_bit_count(0),
54        m_protection_check(0) { }
1755
18extern UINT8 cojag_is_r3000;
56   // devices
57   required_device<cpu_device> m_main_cpu;
58   required_device<jaguargpu_device> m_gpu;
59   required_device<jaguardsp_device> m_dsp;
60   required_device<dac_device> m_dac1;
61   required_device<dac_device> m_dac2;
1962
20extern UINT32 *jaguar_shared_ram;
21extern UINT32 *jaguar_gpu_ram;
22extern UINT32 *jaguar_gpu_clut;
23extern UINT32 *jaguar_dsp_ram;
24extern UINT32 *jaguar_wave_rom;
25extern bool jaguar_hacks_enabled;
63   // memory
64   optional_shared_ptr<UINT32>   m_nvram;      // not used on console
65   required_shared_ptr<UINT32> m_rom_base;
66   optional_shared_ptr<UINT32> m_cart_base;   // not used in cojag
67   required_shared_ptr<UINT32> m_dsp_ram;
68   required_shared_ptr<UINT32> m_wave_rom;
69   required_shared_ptr<UINT32> m_shared_ram;
70   required_shared_ptr<UINT32> m_gpu_ram;
71   required_shared_ptr<UINT32> m_gpu_clut;
2672
27/*----------- defined in audio/jaguar.c -----------*/
73   // configuration
74   bool m_is_r3000;
75   bool m_is_cojag;
76   bool m_hacks_enabled;
77   int m_pixel_clock;
78   bool m_using_cart;
2879
29TIMER_DEVICE_CALLBACK( jaguar_serial_callback );
80   UINT32 m_misc_control_data;
81   bool m_eeprom_enable;
82   UINT32 *m_gpu_jump_address;
83   bool m_gpu_command_pending;
84   UINT32 m_gpu_spin_pc;
85   UINT32 *m_main_speedup;
86   int m_main_speedup_hits;
87   UINT64 m_main_speedup_last_cycles;
88   UINT64 m_main_speedup_max_cycles;
89   UINT32 *m_main_gpu_wait;
3090
31void jaguar_dsp_suspend(running_machine &machine);
32void jaguar_dsp_resume(running_machine &machine);
91   // driver data
92   UINT32 m_joystick_data;
93   UINT8 m_eeprom_bit_count;
94   UINT8 m_protection_check;   /* 0 = check hasn't started yet; 1= check in progress; 2 = check is finished. */
3395
34void cojag_sound_init(running_machine &machine);
96   // audio data
97   UINT16 m_dsp_regs[0x40/2];
98   UINT16 m_serial_frequency;
99   UINT8 m_gpu_irq_state;
100   emu_timer *m_serial_timer;
101   
102   // blitter variables
103   UINT32 m_blitter_regs[40];
104   UINT16 m_gpu_regs[0x100/2];
105   emu_timer *m_object_timer;
106   UINT8 m_cpu_irq_state;
107   bitmap_rgb32 m_screen_bitmap;
108   UINT8 m_blitter_status;
109   pen_t m_pen_table[65536];
110   UINT8 m_blend_y[65536];
111   UINT8 m_blend_cc[65536];
35112
36void jaguar_external_int(device_t *device, int state);
113   static void (jaguar_state::*const bitmap4[8])(UINT16 *, INT32, INT32, UINT32 *, INT32, UINT16 *);
114   static void (jaguar_state::*const bitmap8[8])(UINT16 *, INT32, INT32, UINT32 *, INT32, UINT16 *);
115   static void (jaguar_state::*const bitmap16[8])(UINT16 *, INT32, INT32, UINT32 *, INT32);
116   static void (jaguar_state::*const bitmap32[8])(UINT16 *, INT32, INT32, UINT32 *, INT32);
117   
118   DECLARE_WRITE32_MEMBER(eeprom_w);
119   DECLARE_READ32_MEMBER(eeprom_clk);
120   DECLARE_READ32_MEMBER(eeprom_cs);
121   DECLARE_READ32_MEMBER(misc_control_r);
122   DECLARE_WRITE32_MEMBER(misc_control_w);
123   DECLARE_READ32_MEMBER(gpuctrl_r);
124   DECLARE_WRITE32_MEMBER(gpuctrl_w);
125   DECLARE_READ32_MEMBER(dspctrl_r);
126   DECLARE_WRITE32_MEMBER(dspctrl_w);
127   DECLARE_READ32_MEMBER(joystick_r);
128   DECLARE_WRITE32_MEMBER(joystick_w);
129   DECLARE_WRITE32_MEMBER(latch_w);
130   DECLARE_READ32_MEMBER(eeprom_data_r);
131   DECLARE_WRITE32_MEMBER(eeprom_enable_w);
132   DECLARE_WRITE32_MEMBER(eeprom_data_w);
133   DECLARE_WRITE32_MEMBER(gpu_jump_w);
134   DECLARE_READ32_MEMBER(gpu_jump_r);
135   DECLARE_READ32_MEMBER(cojagr3k_main_speedup_r);
136   DECLARE_READ32_MEMBER(main_gpu_wait_r);
137   DECLARE_WRITE32_MEMBER(area51_main_speedup_w);
138   DECLARE_WRITE32_MEMBER(area51mx_main_speedup_w);
139   DECLARE_READ16_MEMBER(gpuctrl_r16);
140   DECLARE_WRITE16_MEMBER(gpuctrl_w16);
141   DECLARE_READ16_MEMBER(blitter_r16);
142   DECLARE_WRITE16_MEMBER(blitter_w16);
143   DECLARE_READ16_MEMBER(serial_r16);
144   DECLARE_WRITE16_MEMBER(serial_w16);
145   DECLARE_READ16_MEMBER(dspctrl_r16);
146   DECLARE_WRITE16_MEMBER(dspctrl_w16);
147   DECLARE_READ16_MEMBER(eeprom_cs16);
148   DECLARE_READ16_MEMBER(eeprom_clk16);
149   DECLARE_WRITE16_MEMBER(eeprom_w16);
150   DECLARE_READ16_MEMBER(joystick_r16);
151   DECLARE_WRITE16_MEMBER(joystick_w16);
152   DECLARE_READ32_MEMBER(shared_ram_r);
153   DECLARE_WRITE32_MEMBER(shared_ram_w);
154   DECLARE_READ32_MEMBER(rom_base_r);
155   DECLARE_WRITE32_MEMBER(rom_base_w);
156   DECLARE_READ32_MEMBER(cart_base_r);
157   DECLARE_WRITE32_MEMBER(cart_base_w);
158   DECLARE_READ32_MEMBER(wave_rom_r);
159   DECLARE_WRITE32_MEMBER(wave_rom_w);
160   DECLARE_READ32_MEMBER(dsp_ram_r);
161   DECLARE_WRITE32_MEMBER(dsp_ram_w);
162   DECLARE_READ32_MEMBER(gpu_clut_r);
163   DECLARE_WRITE32_MEMBER(gpu_clut_w);
164   DECLARE_READ32_MEMBER(gpu_ram_r);
165   DECLARE_WRITE32_MEMBER(gpu_ram_w);
166   DECLARE_READ16_MEMBER(shared_ram_r16);
167   DECLARE_WRITE16_MEMBER(shared_ram_w16);
168   DECLARE_READ16_MEMBER(rom_base_r16);
169   DECLARE_WRITE16_MEMBER(rom_base_w16);
170   DECLARE_READ16_MEMBER(cart_base_r16);
171   DECLARE_WRITE16_MEMBER(cart_base_w16);
172   DECLARE_READ16_MEMBER(wave_rom_r16);
173   DECLARE_WRITE16_MEMBER(wave_rom_w16);
174   DECLARE_READ16_MEMBER(dsp_ram_r16);
175   DECLARE_WRITE16_MEMBER(dsp_ram_w16);
176   DECLARE_READ16_MEMBER(gpu_clut_r16);
177   DECLARE_WRITE16_MEMBER(gpu_clut_w16);
178   DECLARE_READ16_MEMBER(gpu_ram_r16);
179   DECLARE_WRITE16_MEMBER(gpu_ram_w16);
180   DECLARE_DRIVER_INIT(jaguar);
181   DECLARE_DRIVER_INIT(area51mx);
182   DECLARE_DRIVER_INIT(maxforce);
183   DECLARE_DRIVER_INIT(freezeat);
184   DECLARE_DRIVER_INIT(fishfren);
185   DECLARE_DRIVER_INIT(a51mxr3k);
186   DECLARE_DRIVER_INIT(area51);
187   DECLARE_DRIVER_INIT(freezeat4);
188   DECLARE_DRIVER_INIT(freezeat5);
189   DECLARE_DRIVER_INIT(freezeat6);
190   DECLARE_DRIVER_INIT(vcircle);
191   DECLARE_DRIVER_INIT(freezeat3);
192   DECLARE_DRIVER_INIT(freezeat2);
193   DECLARE_DRIVER_INIT(area51a);
37194
38READ16_HANDLER( jaguar_jerry_regs_r );
39WRITE16_HANDLER( jaguar_jerry_regs_w );
195   // from audio/jaguar.c
196   DECLARE_READ16_MEMBER( jerry_regs_r );
197   DECLARE_WRITE16_MEMBER( jerry_regs_w );
198   DECLARE_READ32_MEMBER( serial_r );
199   DECLARE_WRITE32_MEMBER( serial_w );
200   void serial_update();
40201
41READ32_HANDLER( jaguar_serial_r );
42WRITE32_HANDLER( jaguar_serial_w );
202   // from video/jaguar.c
203   DECLARE_READ32_MEMBER( blitter_r );
204   DECLARE_WRITE32_MEMBER( blitter_w );
205   DECLARE_READ16_MEMBER( tom_regs_r );
206   DECLARE_WRITE16_MEMBER( tom_regs_w );
207   DECLARE_READ32_MEMBER( cojag_gun_input_r );
208   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
43209
210   static void gpu_cpu_int(device_t *device);
211   static void dsp_cpu_int(device_t *device);
212   static void external_int(device_t *device, int state);
44213
45/*----------- defined in video/jaguar.c -----------*/
214   int quickload(device_image_interface &image, const char *file_type, int quickload_size);
215   void cart_start();
216   int cart_load(device_image_interface &image);
46217
47extern UINT8 blitter_status;
218protected:
219   // timer IDs
220   enum
221   {
222      TID_SCANLINE,
223      TID_BLITTER_DONE,
224      TID_PIT,
225      TID_SERIAL,
226      TID_GPU_SYNC
227   };
48228
49void jaguar_gpu_suspend(running_machine &machine);
50void jaguar_gpu_resume(running_machine &machine);
229   // device overrides
230   virtual void machine_reset();
231   virtual void sound_start();
232   virtual void video_start();
233   virtual void device_postload();
234   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
51235
52void jaguar_gpu_cpu_int(device_t *device);
53void jaguar_dsp_cpu_int(device_t *device);
236   void gpu_suspend() { m_gpu->suspend(SUSPEND_REASON_SPIN, 1); }
237   void gpu_resume() { m_gpu->resume(SUSPEND_REASON_SPIN); }
238   void dsp_suspend() { m_dsp->suspend(SUSPEND_REASON_SPIN, 1); }
239   void dsp_resume() { m_dsp->resume(SUSPEND_REASON_SPIN); }
54240
55READ32_HANDLER( jaguar_blitter_r );
56WRITE32_HANDLER( jaguar_blitter_w );
241   void fix_endian( UINT32 addr, UINT32 size );
242   void cojag_common_init(UINT16 gpu_jump_offs, UINT16 spin_pc);
243   void init_freeze_common(offs_t main_speedup_addr);
57244
58READ16_HANDLER( jaguar_tom_regs_r );
59WRITE16_HANDLER( jaguar_tom_regs_w );
245   // from audio/jaguar.c
246   void update_gpu_irq();
247   DECLARE_WRITE32_MEMBER( dsp_flags_w );
60248
61READ32_HANDLER( cojag_gun_input_r );
249   // from video/jaguar.c
250   void get_crosshair_xy(int player, int &x, int &y);
251   int effective_hvalue(int value);
252   bool adjust_object_timer(int vc);
253   void update_cpu_irq();
254   UINT8 *memory_base(UINT32 offset) { return reinterpret_cast<UINT8 *>(m_gpu->space(AS_PROGRAM)->get_read_ptr(offset)); }
255   void blitter_run();
256   void scanline_update(int param);
257   void set_palette(UINT16 vmode);
62258
63VIDEO_START( cojag );
64VIDEO_START( jaguar );
65SCREEN_UPDATE_RGB32( cojag );
259   /* from jagobj.c */
260   void jagobj_init();
261   UINT32 *process_bitmap(UINT16 *scanline, UINT32 *objdata, int vc, int logit);
262   UINT32 *process_scaled_bitmap(UINT16 *scanline, UINT32 *objdata, int vc, int logit);
263   UINT32 *process_branch(UINT32 *objdata, int vc, int logit);
264   void process_object_list(int vc, UINT16 *_scanline);
265   void bitmap_4_draw(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos, UINT16 *clutbase);
266   void bitmap_4_0(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
267   void bitmap_4_1(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
268   void bitmap_4_2(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
269   void bitmap_4_3(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
270   void bitmap_4_4(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
271   void bitmap_4_5(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
272   void bitmap_4_6(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
273   void bitmap_4_7(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
274   void bitmap_8_draw(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos, UINT16 *clutbase);
275   void bitmap_8_0(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
276   void bitmap_8_1(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
277   void bitmap_8_2(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
278   void bitmap_8_3(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
279   void bitmap_8_4(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
280   void bitmap_8_5(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
281   void bitmap_8_6(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
282   void bitmap_8_7(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT16 *clutbase);
283   void bitmap_16_draw(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos);
284   void bitmap_16_0(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
285   void bitmap_16_1(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
286   void bitmap_16_2(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
287   void bitmap_16_3(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
288   void bitmap_16_4(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
289   void bitmap_16_5(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
290   void bitmap_16_6(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
291   void bitmap_16_7(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
292   void bitmap_32_draw(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos);
293   void bitmap_32_0(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
294   void bitmap_32_1(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
295   void bitmap_32_2(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
296   void bitmap_32_3(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
297   void bitmap_32_4(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
298   void bitmap_32_5(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
299   void bitmap_32_6(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
300   void bitmap_32_7(UINT16 *scanline, INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos);
301
302   /* from jagblit.c */
303   void generic_blitter(UINT32 command, UINT32 a1flags, UINT32 a2flags);
304   void blitter_09800001_010020_010020(UINT32 command, UINT32 a1flags, UINT32 a2flags);
305   void blitter_09800009_000020_000020(UINT32 command, UINT32 a1flags, UINT32 a2flags);
306   void blitter_01800009_000028_000028(UINT32 command, UINT32 a1flags, UINT32 a2flags);
307   void blitter_01800001_000018_000018(UINT32 command, UINT32 a1flags, UINT32 a2flags);
308   void blitter_01c00001_000018_000018(UINT32 command, UINT32 a1flags, UINT32 a2flags);
309   void blitter_00010000_xxxxxx_xxxxxx(UINT32 command, UINT32 a1flags, UINT32 a2flags);
310   void blitter_01800001_xxxxxx_xxxxxx(UINT32 command, UINT32 a1flags, UINT32 a2flags);
311   void blitter_x1800x01_xxxxxx_xxxxxx(UINT32 command, UINT32 a1flags, UINT32 a2flags);
312
313};
trunk/src/mame/drivers/jaguar.c
r17621r17622
335335#include "cpu/mips/r3000.h"
336336#include "cpu/jaguar/jaguar.h"
337337#include "machine/idectrl.h"
338#include "machine/nvram.h"
339338#include "sound/dac.h"
340339#include "includes/jaguar.h"
341340#include "emuopts.h"
r17621r17622
353352static DEVICE_IMAGE_LOAD( jaguar );
354353
355354
356class cojag_state : public driver_device
357{
358public:
359   cojag_state(const machine_config &mconfig, device_type type, const char *tag)
360      : driver_device(mconfig, type, tag),
361        m_nvram(*this, "nvram") ,
362      m_rom_base(*this, "robase"){ }
363355
364   optional_shared_ptr<UINT32>   m_nvram;
365   cpu_device *m_main_cpu;
366   UINT32 m_misc_control_data;
367   UINT8 m_eeprom_enable;
368   optional_shared_ptr<UINT32> m_rom_base;
369   UINT32 *m_gpu_jump_address;
370   UINT8 m_gpu_command_pending;
371   UINT32 m_gpu_spin_pc;
372   UINT32 *m_main_speedup;
373   int m_main_speedup_hits;
374   UINT64 m_main_speedup_last_cycles;
375   UINT64 m_main_speedup_max_cycles;
376   UINT32 *m_main_gpu_wait;
377   DECLARE_WRITE32_MEMBER(jaguar_eeprom_w);
378   DECLARE_READ32_MEMBER(jaguar_eeprom_clk);
379   DECLARE_READ32_MEMBER(jaguar_eeprom_cs);
380   DECLARE_READ32_MEMBER(misc_control_r);
381   DECLARE_WRITE32_MEMBER(misc_control_w);
382   DECLARE_READ32_MEMBER(gpuctrl_r);
383   DECLARE_WRITE32_MEMBER(gpuctrl_w);
384   DECLARE_READ32_MEMBER(dspctrl_r);
385   DECLARE_WRITE32_MEMBER(dspctrl_w);
386   DECLARE_READ32_MEMBER(jaguar_wave_rom_r);
387   DECLARE_READ32_MEMBER(joystick_r);
388   DECLARE_WRITE32_MEMBER(joystick_w);
389   DECLARE_WRITE32_MEMBER(latch_w);
390   DECLARE_READ32_MEMBER(eeprom_data_r);
391   DECLARE_WRITE32_MEMBER(eeprom_enable_w);
392   DECLARE_WRITE32_MEMBER(eeprom_data_w);
393   DECLARE_WRITE32_MEMBER(gpu_jump_w);
394   DECLARE_READ32_MEMBER(gpu_jump_r);
395   DECLARE_READ32_MEMBER(cojagr3k_main_speedup_r);
396   DECLARE_READ32_MEMBER(main_gpu_wait_r);
397   DECLARE_WRITE32_MEMBER(area51_main_speedup_w);
398   DECLARE_WRITE32_MEMBER(area51mx_main_speedup_w);
399   DECLARE_READ16_MEMBER(gpuctrl_r16);
400   DECLARE_WRITE16_MEMBER(gpuctrl_w16);
401   DECLARE_READ16_MEMBER(jaguar_blitter_r16);
402   DECLARE_WRITE16_MEMBER(jaguar_blitter_w16);
403   DECLARE_READ16_MEMBER(jaguar_serial_r16);
404   DECLARE_WRITE16_MEMBER(jaguar_serial_w16);
405   DECLARE_READ16_MEMBER(dspctrl_r16);
406   DECLARE_WRITE16_MEMBER(dspctrl_w16);
407   DECLARE_READ16_MEMBER(jaguar_eeprom_cs16);
408   DECLARE_READ16_MEMBER(jaguar_eeprom_clk16);
409   DECLARE_WRITE16_MEMBER(jaguar_eeprom_w16);
410   DECLARE_READ16_MEMBER(joystick_r16);
411   DECLARE_WRITE16_MEMBER(joystick_w16);
412   DECLARE_READ32_MEMBER(jaguar_shared_ram_r);
413   DECLARE_WRITE32_MEMBER(jaguar_shared_ram_w);
414   DECLARE_READ32_MEMBER(jaguar_rom_base_r);
415   DECLARE_WRITE32_MEMBER(jaguar_rom_base_w);
416   DECLARE_READ32_MEMBER(jaguar_cart_base_r);
417   DECLARE_WRITE32_MEMBER(jaguar_cart_base_w);
418   DECLARE_READ32_MEMBER(high_rom_base_r);
419   DECLARE_WRITE32_MEMBER(high_rom_base_w);
420   DECLARE_READ32_MEMBER(jaguar_dsp_ram_r);
421   DECLARE_WRITE32_MEMBER(jaguar_dsp_ram_w);
422   DECLARE_READ32_MEMBER(jaguar_gpu_clut_r);
423   DECLARE_WRITE32_MEMBER(jaguar_gpu_clut_w);
424   DECLARE_READ32_MEMBER(jaguar_gpu_ram_r);
425   DECLARE_WRITE32_MEMBER(jaguar_gpu_ram_w);
426   DECLARE_READ16_MEMBER(jaguar_shared_ram_r16);
427   DECLARE_WRITE16_MEMBER(jaguar_shared_ram_w16);
428   DECLARE_READ16_MEMBER(jaguar_rom_base_r16);
429   DECLARE_WRITE16_MEMBER(jaguar_rom_base_w16);
430   DECLARE_READ16_MEMBER(jaguar_cart_base_r16);
431   DECLARE_WRITE16_MEMBER(jaguar_cart_base_w16);
432   DECLARE_READ16_MEMBER(high_rom_base_r16);
433   DECLARE_WRITE16_MEMBER(high_rom_base_w16);
434   DECLARE_READ16_MEMBER(jaguar_dsp_ram_r16);
435   DECLARE_WRITE16_MEMBER(jaguar_dsp_ram_w16);
436   DECLARE_READ16_MEMBER(jaguar_gpu_clut_r16);
437   DECLARE_WRITE16_MEMBER(jaguar_gpu_clut_w16);
438   DECLARE_READ16_MEMBER(jaguar_gpu_ram_r16);
439   DECLARE_WRITE16_MEMBER(jaguar_gpu_ram_w16);
440   DECLARE_DRIVER_INIT(jaguar);
441   DECLARE_DRIVER_INIT(area51mx);
442   DECLARE_DRIVER_INIT(maxforce);
443   DECLARE_DRIVER_INIT(freezeat);
444   DECLARE_DRIVER_INIT(fishfren);
445   DECLARE_DRIVER_INIT(a51mxr3k);
446   DECLARE_DRIVER_INIT(area51);
447   DECLARE_DRIVER_INIT(freezeat4);
448   DECLARE_DRIVER_INIT(freezeat5);
449   DECLARE_DRIVER_INIT(freezeat6);
450   DECLARE_DRIVER_INIT(vcircle);
451   DECLARE_DRIVER_INIT(freezeat3);
452   DECLARE_DRIVER_INIT(freezeat2);
453   DECLARE_DRIVER_INIT(area51a);
454};
455
456
457
458356/*************************************
459357 *
460 *  Global variables
461 *
462 *************************************/
463
464UINT32 *jaguar_shared_ram;
465UINT32 *jaguar_gpu_ram;
466UINT32 *jaguar_gpu_clut;
467UINT32 *jaguar_dsp_ram;
468UINT32 *jaguar_wave_rom;
469UINT32* high_rom_base;
470UINT8 cojag_is_r3000;
471bool jaguar_hacks_enabled;
472static int is_jaguar;
473
474
475
476/*************************************
477 *
478358 *  Local variables
479359 *
480360 *************************************/
481361
482static UINT32 joystick_data;
483static UINT32 *rom_base;
484static size_t rom_size;
485static UINT32 *cart_base;
486static size_t cart_size;
487static UINT8 eeprom_bit_count;
488static UINT8 protection_check = 0;   /* 0 = check hasn't started yet; 1= check in progress; 2 = check is finished. */
489extern UINT8 blitter_status;
490static UINT8 using_cart = 0;
491
492362static IRQ_CALLBACK(jaguar_irq_callback)
493363{
494364   return (irqline == 6) ? 0x40 : -1;
r17621r17622
502372 *
503373 *************************************/
504374
505static MACHINE_RESET( cojag )
375void jaguar_state::machine_reset()
506376{
507   cojag_state *state = machine.driver_data<cojag_state>();
508   UINT8 *rom = state->memregion("user2")->base();
377   if (!m_is_cojag)
378      m_main_cpu->set_irq_acknowledge_callback(jaguar_irq_callback);
509379
380   m_protection_check = 0;
381
510382   /* 68020 only: copy the interrupt vectors into RAM */
511   if (!cojag_is_r3000)
512      memcpy(jaguar_shared_ram, state->m_rom_base, 0x10);
383   if (!m_is_r3000)
384   {
385      memcpy(m_shared_ram, m_rom_base, 0x400);   // do not increase, or Doom breaks
386      m_main_cpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
387   }
513388
514389   /* configure banks for gfx/sound ROMs */
515   if (rom)
390   UINT8 *romboard = memregion("romboard")->base();
391   if (romboard != NULL)
516392   {
517393      /* graphics banks */
518      if (cojag_is_r3000)
394      if (m_is_r3000)
519395      {
520         state->membank("bank1")->configure_entries(0, 2, rom + 0x800000, 0x400000);
521         state->membank("bank1")->set_entry(0);
396         membank("maingfxbank")->configure_entries(0, 2, romboard + 0x800000, 0x400000);
397         membank("maingfxbank")->set_entry(0);
522398      }
523      state->membank("bank8")->configure_entries(0, 2, rom + 0x800000, 0x400000);
524      state->membank("bank8")->set_entry(0);
399      membank("gpugfxbank")->configure_entries(0, 2, romboard + 0x800000, 0x400000);
400      membank("gpugfxbank")->set_entry(0);
525401
526402      /* sound banks */
527      state->membank("bank2")->configure_entries(0, 8, rom + 0x000000, 0x200000);
528      state->membank("bank9")->configure_entries(0, 8, rom + 0x000000, 0x200000);
529      state->membank("bank2")->set_entry(0);
530      state->membank("bank9")->set_entry(0);
403      membank("mainsndbank")->configure_entries(0, 8, romboard + 0x000000, 0x200000);
404      membank("mainsndbank")->set_entry(0);
405      membank("dspsndbank")->configure_entries(0, 8, romboard + 0x000000, 0x200000);
406      membank("dspsndbank")->set_entry(0);
531407   }
532408
533409   /* clear any spinuntil stuff */
534   jaguar_gpu_resume(machine);
535   jaguar_dsp_resume(machine);
410   gpu_resume();
411   dsp_resume();
536412
537413   /* halt the CPUs */
538   jaguargpu_ctrl_w(machine.device("gpu"), G_CTRL, 0, 0xffffffff);
539   jaguardsp_ctrl_w(machine.device("audiocpu"), D_CTRL, 0, 0xffffffff);
414   jaguargpu_ctrl_w(m_gpu, G_CTRL, 0, 0xffffffff);
415   jaguardsp_ctrl_w(m_dsp, D_CTRL, 0, 0xffffffff);
540416
541417   /* set blitter idle flag */
542   blitter_status = 1;
418   m_blitter_status = 1;
419   m_joystick_data = 0xffffffff;
420   m_eeprom_bit_count = 0;
543421
544   // normal handling of 'protection'
545   is_jaguar = 0;
546}
547
548
549static MACHINE_RESET( jaguar )
550{
551   device_set_irq_callback(machine.device("maincpu"), jaguar_irq_callback);
552
553   protection_check = 0;
554
555   /* Set up pointers for Jaguar logo */
556
557   memcpy(jaguar_shared_ram, rom_base, 0x400);   // do not increase, or Doom breaks
558
559   device_set_input_line(machine.device("maincpu"), INPUT_LINE_RESET, PULSE_LINE);
560
561   /* clear any spinuntil stuff */
562   jaguar_gpu_resume(machine);
563   jaguar_dsp_resume(machine);
564
565   /* halt the CPUs */
566   jaguargpu_ctrl_w(machine.device("gpu"), G_CTRL, 0, 0xffffffff);
567   jaguardsp_ctrl_w(machine.device("audiocpu"), D_CTRL, 0, 0xffffffff);
568
569   joystick_data = 0xffffffff;
570   eeprom_bit_count = 0;
571   blitter_status = 1;
572   if ((using_cart) && (machine.root_device().ioport("CONFIG")->read() & 2))
422   if ((m_using_cart) && (ioport("CONFIG")->read() & 2))
573423   {
574      cart_base[0x102] = 1;
575      using_cart = 0;
424      m_cart_base[0x102] = 1;
425      m_using_cart = false;
576426   }
577
578   // custom handling of 'protection'
579   is_jaguar = 1;
580427}
581428
582429
r17621r17622
659506    }
660507}
661508*/
662WRITE32_MEMBER(cojag_state::jaguar_eeprom_w)
509WRITE32_MEMBER(jaguar_state::eeprom_w)
663510{
664511   eeprom_device *eeprom = machine().device<eeprom_device>("eeprom");
665   eeprom_bit_count++;
666   if (eeprom_bit_count != 9)      /* kill extra bit at end of address */
512   m_eeprom_bit_count++;
513   if (m_eeprom_bit_count != 9)      /* kill extra bit at end of address */
667514   {
668515      eeprom->write_bit(data >> 31);
669516      eeprom->set_clock_line(PULSE_LINE);
670517   }
671518}
672519
673READ32_MEMBER(cojag_state::jaguar_eeprom_clk)
520READ32_MEMBER(jaguar_state::eeprom_clk)
674521{
675522   eeprom_device *eeprom = machine().device<eeprom_device>("eeprom");
676523   eeprom->set_clock_line(PULSE_LINE);   /* get next bit when reading */
677524   return 0;
678525}
679526
680READ32_MEMBER(cojag_state::jaguar_eeprom_cs)
527READ32_MEMBER(jaguar_state::eeprom_cs)
681528{
682529   eeprom_device *eeprom = machine().device<eeprom_device>("eeprom");
683530   eeprom->set_cs_line(ASSERT_LINE);   /* must do at end of an operation */
684531   eeprom->set_cs_line(CLEAR_LINE);      /* enable chip for next operation */
685532   eeprom->write_bit(1);         /* write a start bit */
686533   eeprom->set_clock_line(PULSE_LINE);
687   eeprom_bit_count = 0;
534   m_eeprom_bit_count = 0;
688535   return 0;
689536}
690537
r17621r17622
696543 *
697544 *************************************/
698545
699READ32_MEMBER(cojag_state::misc_control_r)
546READ32_MEMBER(jaguar_state::misc_control_r)
700547{
701548   /*  D7    = board reset (low)
702549        D6    = audio must & reset (high)
r17621r17622
709556}
710557
711558
712WRITE32_MEMBER(cojag_state::misc_control_w)
559WRITE32_MEMBER(jaguar_state::misc_control_w)
713560{
714561   logerror("%08X:misc_control_w(%02X)\n", cpu_get_previouspc(&space.device()), data);
715562
r17621r17622
724571   if (!(data & 0x80))
725572   {
726573      /* clear any spinuntil stuff */
727      jaguar_gpu_resume(machine());
728      jaguar_dsp_resume(machine());
574      gpu_resume();
575      dsp_resume();
729576
730577      /* halt the CPUs */
731      jaguargpu_ctrl_w(machine().device("gpu"), G_CTRL, 0, 0xffffffff);
732      jaguardsp_ctrl_w(machine().device("audiocpu"), D_CTRL, 0, 0xffffffff);
578      jaguargpu_ctrl_w(m_gpu, G_CTRL, 0, 0xffffffff);
579      jaguardsp_ctrl_w(m_dsp, D_CTRL, 0, 0xffffffff);
733580   }
734581
735582   /* adjust banking */
736   if (machine().root_device().memregion("user2")->base())
583   if (machine().root_device().memregion("romboard")->base())
737584   {
738      membank("bank2")->set_entry((data >> 1) & 7);
739      membank("bank9")->set_entry((data >> 1) & 7);
585      membank("mainsndbank")->set_entry((data >> 1) & 7);
586      membank("dspsndbank")->set_entry((data >> 1) & 7);
740587   }
741588
742589   COMBINE_DATA(&m_misc_control_data);
r17621r17622
750597 *************************************/
751598
752599// shouldn't the DSPs be doing this calc, why is this needed for Jaguar?
753READ32_MEMBER(cojag_state::gpuctrl_r)
600READ32_MEMBER(jaguar_state::gpuctrl_r)
754601{
755   UINT32 result = jaguargpu_ctrl_r(machine().device("gpu"), offset);
602   UINT32 result = jaguargpu_ctrl_r(m_gpu, offset);
756603
757   if (is_jaguar)
604   if (!m_is_cojag)
758605   {
759      if (protection_check != 1) return result;
606      if (m_protection_check != 1) return result;
760607
761      protection_check++;
762      jaguar_gpu_ram[0] = 0x3d0dead;
608      m_protection_check++;
609      m_gpu_ram[0] = 0x3d0dead;
763610      return 0x80000000;
764611   }
765612   else
r17621r17622
767614}
768615
769616
770WRITE32_MEMBER(cojag_state::gpuctrl_w)
617WRITE32_MEMBER(jaguar_state::gpuctrl_w)
771618{
772   if (is_jaguar)
773      if ((!protection_check) && (offset == 5) && (data == 1)) protection_check++;
619   if (!m_is_cojag)
620      if ((!m_protection_check) && (offset == 5) && (data == 1)) m_protection_check++;
774621
775   jaguargpu_ctrl_w(machine().device("gpu"), offset, data, mem_mask);
622   jaguargpu_ctrl_w(m_gpu, offset, data, mem_mask);
776623}
777624
778625
r17621r17622
783630 *
784631 *************************************/
785632
786READ32_MEMBER(cojag_state::dspctrl_r)
633READ32_MEMBER(jaguar_state::dspctrl_r)
787634{
788   return jaguardsp_ctrl_r(machine().device("audiocpu"), offset);
635   return jaguardsp_ctrl_r(machine().device("dsp"), offset);
789636}
790637
791638
792WRITE32_MEMBER(cojag_state::dspctrl_w)
639WRITE32_MEMBER(jaguar_state::dspctrl_w)
793640{
794   jaguardsp_ctrl_w(machine().device("audiocpu"), offset, data, mem_mask);
641   jaguardsp_ctrl_w(machine().device("dsp"), offset, data, mem_mask);
795642}
796643
797644
798READ32_MEMBER(cojag_state::jaguar_wave_rom_r)
799{
800   return jaguar_wave_rom[offset];
801}
802
803
804645/*************************************
805646 *
806647 *  Input ports
r17621r17622
810651 *
811652 *************************************/
812653
813READ32_MEMBER(cojag_state::joystick_r)
654READ32_MEMBER(jaguar_state::joystick_r)
814655{
815656   UINT16 joystick_result = 0xfffe;
816657   UINT16 joybuts_result = 0xffef;
r17621r17622
837678
838679   for (i = 0; i < 8; i++)
839680   {
840      if ((joystick_data & (0x10000 << i)) == 0)
681      if ((m_joystick_data & (0x10000 << i)) == 0)
841682      {
842683         joystick_result &= ioport(keynames[0][i])->read();
843684         joybuts_result &= ioport(keynames[1][i])->read();
r17621r17622
850691   return (joystick_result << 16) | joybuts_result;
851692}
852693
853WRITE32_MEMBER(cojag_state::joystick_w)
694WRITE32_MEMBER(jaguar_state::joystick_w)
854695{
855696   /*
856697     *   16        12         8         4         0
r17621r17622
898739     *      Set this bit to read from the joysticks, clear it to write
899740     *      to them.
900741     */
901   COMBINE_DATA(&joystick_data);
742   COMBINE_DATA(&m_joystick_data);
902743}
903744
904745
r17621r17622
908749 *
909750 *************************************/
910751
911WRITE32_MEMBER(cojag_state::latch_w)
752WRITE32_MEMBER(jaguar_state::latch_w)
912753{
913754   logerror("%08X:latch_w(%X)\n", cpu_get_previouspc(&space.device()), data);
914755
915756   /* adjust banking */
916   if (machine().root_device().memregion("user2")->base())
757   if (machine().root_device().memregion("romboard")->base())
917758   {
918      if (cojag_is_r3000)
919         membank("bank1")->set_entry(data & 1);
920      membank("bank8")->set_entry(data & 1);
759      if (m_is_r3000)
760         membank("maingfxbank")->set_entry(data & 1);
761      membank("gpugfxbank")->set_entry(data & 1);
921762   }
922763}
923764
r17621r17622
929770 *
930771 *************************************/
931772
932READ32_MEMBER(cojag_state::eeprom_data_r)
773READ32_MEMBER(jaguar_state::eeprom_data_r)
933774{
934   if (cojag_is_r3000)
775   if (m_is_r3000)
935776      return m_nvram[offset] | 0xffffff00;
936777   else
937778      return m_nvram[offset] | 0x00ffffff;
938779}
939780
940781
941WRITE32_MEMBER(cojag_state::eeprom_enable_w)
782WRITE32_MEMBER(jaguar_state::eeprom_enable_w)
942783{
943   m_eeprom_enable = 1;
784   m_eeprom_enable = true;
944785}
945786
946787
947WRITE32_MEMBER(cojag_state::eeprom_data_w)
788WRITE32_MEMBER(jaguar_state::eeprom_data_w)
948789{
949790//  if (m_eeprom_enable)
950791   {
951      if (cojag_is_r3000)
792      if (m_is_r3000)
952793         m_nvram[offset] = data & 0x000000ff;
953794      else
954795         m_nvram[offset] = data & 0xff000000;
955796   }
956797//  else
957798//      logerror("%08X:error writing to disabled EEPROM\n", cpu_get_previouspc(&space.device()));
958   m_eeprom_enable = 0;
799   m_eeprom_enable = false;
959800}
960801
961802
r17621r17622
988829*/
989830
990831
991static TIMER_CALLBACK( gpu_sync_timer )
832WRITE32_MEMBER(jaguar_state::gpu_jump_w)
992833{
993   cojag_state *state = machine.driver_data<cojag_state>();
994   /* if a command is still pending, and we haven't maxed out our timer, set a new one */
995   if (state->m_gpu_command_pending && param < 1000)
996      machine.scheduler().timer_set(attotime::from_usec(50), FUNC(gpu_sync_timer), ++param);
997}
998
999
1000WRITE32_MEMBER(cojag_state::gpu_jump_w)
1001{
1002834   /* update the data in memory */
1003835   COMBINE_DATA(m_gpu_jump_address);
1004836   logerror("%08X:GPU jump address = %08X\n", cpu_get_previouspc(&space.device()), *m_gpu_jump_address);
1005837
1006838   /* if the GPU is suspended, release it now */
1007   jaguar_gpu_resume(machine());
839   gpu_resume();
1008840
1009841   /* start the sync timer going, and note that there is a command pending */
1010   machine().scheduler().synchronize(FUNC(gpu_sync_timer));
1011   m_gpu_command_pending = 1;
842   synchronize(TID_GPU_SYNC);
843   m_gpu_command_pending = true;
1012844}
1013845
1014846
1015READ32_MEMBER(cojag_state::gpu_jump_r)
847READ32_MEMBER(jaguar_state::gpu_jump_r)
1016848{
1017849   /* if the current GPU command is just pointing back to the spin loop, and */
1018850   /* we're reading it from the spin loop, we can optimize */
r17621r17622
1020852   {
1021853#if ENABLE_SPEEDUP_HACKS
1022854      /* spin if we're allowed */
1023      if (jaguar_hacks_enabled) jaguar_gpu_suspend(machine());
855      if (m_hacks_enabled) gpu_suspend();
1024856#endif
1025857
1026858      /* no command is pending */
1027      m_gpu_command_pending = 0;
859      m_gpu_command_pending = false;
1028860   }
1029861
1030862   /* return the current value */
r17621r17622
1053885#if ENABLE_SPEEDUP_HACKS
1054886
1055887
1056READ32_MEMBER(cojag_state::cojagr3k_main_speedup_r)
888READ32_MEMBER(jaguar_state::cojagr3k_main_speedup_r)
1057889{
1058890   UINT64 curcycles = m_main_cpu->total_cycles();
1059891
r17621r17622
1101933#if ENABLE_SPEEDUP_HACKS
1102934
1103935
1104READ32_MEMBER(cojag_state::main_gpu_wait_r)
936READ32_MEMBER(jaguar_state::main_gpu_wait_r)
1105937{
1106938   if (m_gpu_command_pending)
1107939      device_spin_until_interrupt(&space.device());
r17621r17622
1127959
1128960#if ENABLE_SPEEDUP_HACKS
1129961
1130WRITE32_MEMBER(cojag_state::area51_main_speedup_w)
962WRITE32_MEMBER(jaguar_state::area51_main_speedup_w)
1131963{
1132964   UINT64 curcycles = m_main_cpu->total_cycles();
1133965
r17621r17622
1161993    against 0 must handle that explicitly.
1162994*/
1163995
1164WRITE32_MEMBER(cojag_state::area51mx_main_speedup_w)
996WRITE32_MEMBER(jaguar_state::area51mx_main_speedup_w)
1165997{
1166998   UINT64 curcycles = m_main_cpu->total_cycles();
1167999
r17621r17622
12031035// surely these should be 16-bit natively if the standard Jaguar is driven by a plain 68k?
12041036// all these trampolines are not good for performance ;-)
12051037
1206READ16_MEMBER(cojag_state::gpuctrl_r16){ if (!(offset&1)) { return gpuctrl_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return gpuctrl_r(space, offset>>1, mem_mask); } }
1207WRITE16_MEMBER(cojag_state::gpuctrl_w16){ if (!(offset&1)) { gpuctrl_w(space, offset>>1, data << 16, mem_mask << 16); } else { gpuctrl_w(space, offset>>1, data, mem_mask); } }
1208READ16_MEMBER(cojag_state::jaguar_blitter_r16){ if (!(offset&1)) { return jaguar_blitter_r(&space, offset>>1, mem_mask<<16) >> 16;  } else { return jaguar_blitter_r(&space, offset>>1, mem_mask); } }
1209WRITE16_MEMBER(cojag_state::jaguar_blitter_w16){ if (!(offset&1)) { jaguar_blitter_w(&space, offset>>1, data << 16, mem_mask << 16); } else { jaguar_blitter_w(&space, offset>>1, data, mem_mask); } }
1210READ16_MEMBER(cojag_state::jaguar_serial_r16){ if (!(offset&1)) { return jaguar_serial_r(&space, offset>>1, mem_mask<<16) >> 16;  } else { return jaguar_serial_r(&space, offset>>1, mem_mask); } }
1211WRITE16_MEMBER(cojag_state::jaguar_serial_w16){ if (!(offset&1)) { jaguar_serial_w(&space, offset>>1, data << 16, mem_mask << 16); } else { jaguar_serial_w(&space, offset>>1, data, mem_mask); } }
1212READ16_MEMBER(cojag_state::dspctrl_r16){ if (!(offset&1)) { return dspctrl_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return dspctrl_r(space, offset>>1, mem_mask); } }
1213WRITE16_MEMBER(cojag_state::dspctrl_w16){ if (!(offset&1)) { dspctrl_w(space, offset>>1, data << 16, mem_mask << 16); } else { dspctrl_w(space, offset>>1, data, mem_mask); } }
1214READ16_MEMBER(cojag_state::jaguar_eeprom_cs16){ if (!(offset&1)) { return jaguar_eeprom_cs(space, offset>>1, mem_mask<<16) >> 16;  } else { return jaguar_eeprom_cs(space, offset>>1, mem_mask); } }
1215READ16_MEMBER(cojag_state::jaguar_eeprom_clk16){ if (!(offset&1)) { return jaguar_eeprom_clk(space, offset>>1, mem_mask<<16) >> 16;  } else { return jaguar_eeprom_clk(space, offset>>1, mem_mask); } }
1216WRITE16_MEMBER(cojag_state::jaguar_eeprom_w16){ if (!(offset&1)) { jaguar_eeprom_w(space, offset>>1, data << 16, mem_mask << 16); } else { jaguar_eeprom_w(space, offset>>1, data, mem_mask); } }
1217READ16_MEMBER(cojag_state::joystick_r16){ if (!(offset&1)) { return joystick_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return joystick_r(space, offset>>1, mem_mask); } }
1218WRITE16_MEMBER(cojag_state::joystick_w16){ if (!(offset&1)) { joystick_w(space, offset>>1, data << 16, mem_mask << 16); } else { joystick_w(space, offset>>1, data, mem_mask); } }
1038READ16_MEMBER(jaguar_state::gpuctrl_r16){ if (!(offset&1)) { return gpuctrl_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return gpuctrl_r(space, offset>>1, mem_mask); } }
1039WRITE16_MEMBER(jaguar_state::gpuctrl_w16){ if (!(offset&1)) { gpuctrl_w(space, offset>>1, data << 16, mem_mask << 16); } else { gpuctrl_w(space, offset>>1, data, mem_mask); } }
1040READ16_MEMBER(jaguar_state::blitter_r16){ if (!(offset&1)) { return blitter_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return blitter_r(space, offset>>1, mem_mask); } }
1041WRITE16_MEMBER(jaguar_state::blitter_w16){ if (!(offset&1)) { blitter_w(space, offset>>1, data << 16, mem_mask << 16); } else { blitter_w(space, offset>>1, data, mem_mask); } }
1042READ16_MEMBER(jaguar_state::serial_r16){ if (!(offset&1)) { return serial_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return serial_r(space, offset>>1, mem_mask); } }
1043WRITE16_MEMBER(jaguar_state::serial_w16){ if (!(offset&1)) { serial_w(space, offset>>1, data << 16, mem_mask << 16); } else { serial_w(space, offset>>1, data, mem_mask); } }
1044READ16_MEMBER(jaguar_state::dspctrl_r16){ if (!(offset&1)) { return dspctrl_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return dspctrl_r(space, offset>>1, mem_mask); } }
1045WRITE16_MEMBER(jaguar_state::dspctrl_w16){ if (!(offset&1)) { dspctrl_w(space, offset>>1, data << 16, mem_mask << 16); } else { dspctrl_w(space, offset>>1, data, mem_mask); } }
1046READ16_MEMBER(jaguar_state::eeprom_cs16){ if (!(offset&1)) { return eeprom_cs(space, offset>>1, mem_mask<<16) >> 16;  } else { return eeprom_cs(space, offset>>1, mem_mask); } }
1047READ16_MEMBER(jaguar_state::eeprom_clk16){ if (!(offset&1)) { return eeprom_clk(space, offset>>1, mem_mask<<16) >> 16;  } else { return eeprom_clk(space, offset>>1, mem_mask); } }
1048WRITE16_MEMBER(jaguar_state::eeprom_w16){ if (!(offset&1)) { eeprom_w(space, offset>>1, data << 16, mem_mask << 16); } else { eeprom_w(space, offset>>1, data, mem_mask); } }
1049READ16_MEMBER(jaguar_state::joystick_r16){ if (!(offset&1)) { return joystick_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return joystick_r(space, offset>>1, mem_mask); } }
1050WRITE16_MEMBER(jaguar_state::joystick_w16){ if (!(offset&1)) { joystick_w(space, offset>>1, data << 16, mem_mask << 16); } else { joystick_w(space, offset>>1, data, mem_mask); } }
12191051
1220READ32_MEMBER(cojag_state::jaguar_shared_ram_r){ return jaguar_shared_ram[offset]; }
1221WRITE32_MEMBER(cojag_state::jaguar_shared_ram_w){   COMBINE_DATA(&jaguar_shared_ram[offset]); }
1222READ32_MEMBER(cojag_state::jaguar_rom_base_r){ return rom_base[offset]; }
1223WRITE32_MEMBER(cojag_state::jaguar_rom_base_w){ /*ROM!*/ }
1224READ32_MEMBER(cojag_state::jaguar_cart_base_r){ return cart_base[offset]; }
1225WRITE32_MEMBER(cojag_state::jaguar_cart_base_w){ /*ROM!*/ }
1226READ32_MEMBER(cojag_state::high_rom_base_r){ return high_rom_base[offset]; }
1227WRITE32_MEMBER(cojag_state::high_rom_base_w){ /*ROM!*/ }
1228READ32_MEMBER(cojag_state::jaguar_dsp_ram_r){   return jaguar_dsp_ram[offset]; }
1229WRITE32_MEMBER(cojag_state::jaguar_dsp_ram_w){ COMBINE_DATA(&jaguar_dsp_ram[offset]); }
1230READ32_MEMBER(cojag_state::jaguar_gpu_clut_r){ return jaguar_gpu_clut[offset]; }
1231WRITE32_MEMBER(cojag_state::jaguar_gpu_clut_w){ COMBINE_DATA(&jaguar_gpu_clut[offset]); }
1232READ32_MEMBER(cojag_state::jaguar_gpu_ram_r){ return jaguar_gpu_ram[offset]; }
1233WRITE32_MEMBER(cojag_state::jaguar_gpu_ram_w){ COMBINE_DATA(&jaguar_gpu_ram[offset]); }
1052READ32_MEMBER(jaguar_state::shared_ram_r){ return m_shared_ram[offset]; }
1053WRITE32_MEMBER(jaguar_state::shared_ram_w){   COMBINE_DATA(&m_shared_ram[offset]); }
1054READ32_MEMBER(jaguar_state::rom_base_r){ return m_rom_base[offset]; }
1055WRITE32_MEMBER(jaguar_state::rom_base_w){ /*ROM!*/ }
1056READ32_MEMBER(jaguar_state::cart_base_r){ return m_cart_base[offset]; }
1057WRITE32_MEMBER(jaguar_state::cart_base_w){ /*ROM!*/ }
1058READ32_MEMBER(jaguar_state::wave_rom_r){ return m_wave_rom[offset]; }
1059WRITE32_MEMBER(jaguar_state::wave_rom_w){ /*ROM!*/ }
1060READ32_MEMBER(jaguar_state::dsp_ram_r){   return m_dsp_ram[offset]; }
1061WRITE32_MEMBER(jaguar_state::dsp_ram_w){ COMBINE_DATA(&m_dsp_ram[offset]); }
1062READ32_MEMBER(jaguar_state::gpu_clut_r){ return m_gpu_clut[offset]; }
1063WRITE32_MEMBER(jaguar_state::gpu_clut_w){ COMBINE_DATA(&m_gpu_clut[offset]); }
1064READ32_MEMBER(jaguar_state::gpu_ram_r){ return m_gpu_ram[offset]; }
1065WRITE32_MEMBER(jaguar_state::gpu_ram_w){ COMBINE_DATA(&m_gpu_ram[offset]); }
12341066
1235READ16_MEMBER(cojag_state::jaguar_shared_ram_r16){ if (!(offset&1)) { return jaguar_shared_ram_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return jaguar_shared_ram_r(space, offset>>1, mem_mask); } }
1236WRITE16_MEMBER(cojag_state::jaguar_shared_ram_w16){ if (!(offset&1)) { jaguar_shared_ram_w(space, offset>>1, data << 16, mem_mask << 16); } else { jaguar_shared_ram_w(space, offset>>1, data, mem_mask); } }
1237READ16_MEMBER(cojag_state::jaguar_rom_base_r16){ if (!(offset&1)) { return jaguar_rom_base_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return jaguar_rom_base_r(space, offset>>1, mem_mask); } }
1238WRITE16_MEMBER(cojag_state::jaguar_rom_base_w16){ if (!(offset&1)) { jaguar_rom_base_w(space, offset>>1, data << 16, mem_mask << 16); } else { jaguar_rom_base_w(space, offset>>1, data, mem_mask); } }
1239READ16_MEMBER(cojag_state::jaguar_cart_base_r16){ if (!(offset&1)) { return jaguar_cart_base_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return jaguar_cart_base_r(space, offset>>1, mem_mask); } }
1240WRITE16_MEMBER(cojag_state::jaguar_cart_base_w16){ if (!(offset&1)) { jaguar_cart_base_w(space, offset>>1, data << 16, mem_mask << 16); } else { jaguar_cart_base_w(space, offset>>1, data, mem_mask); } }
1241READ16_MEMBER(cojag_state::high_rom_base_r16){ if (!(offset&1)) { return high_rom_base_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return high_rom_base_r(space, offset>>1, mem_mask); } }
1242WRITE16_MEMBER(cojag_state::high_rom_base_w16){ if (!(offset&1)) { high_rom_base_w(space, offset>>1, data << 16, mem_mask << 16); } else { high_rom_base_w(space, offset>>1, data, mem_mask); } }
1067READ16_MEMBER(jaguar_state::shared_ram_r16){ if (!(offset&1)) { return shared_ram_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return shared_ram_r(space, offset>>1, mem_mask); } }
1068WRITE16_MEMBER(jaguar_state::shared_ram_w16){ if (!(offset&1)) { shared_ram_w(space, offset>>1, data << 16, mem_mask << 16); } else { shared_ram_w(space, offset>>1, data, mem_mask); } }
1069READ16_MEMBER(jaguar_state::rom_base_r16){ if (!(offset&1)) { return rom_base_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return rom_base_r(space, offset>>1, mem_mask); } }
1070WRITE16_MEMBER(jaguar_state::rom_base_w16){ if (!(offset&1)) { rom_base_w(space, offset>>1, data << 16, mem_mask << 16); } else { rom_base_w(space, offset>>1, data, mem_mask); } }
1071READ16_MEMBER(jaguar_state::cart_base_r16){ if (!(offset&1)) { return cart_base_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return cart_base_r(space, offset>>1, mem_mask); } }
1072WRITE16_MEMBER(jaguar_state::cart_base_w16){ if (!(offset&1)) { cart_base_w(space, offset>>1, data << 16, mem_mask << 16); } else { cart_base_w(space, offset>>1, data, mem_mask); } }
1073READ16_MEMBER(jaguar_state::wave_rom_r16){ if (!(offset&1)) { return wave_rom_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return wave_rom_r(space, offset>>1, mem_mask); } }
1074WRITE16_MEMBER(jaguar_state::wave_rom_w16){ if (!(offset&1)) { wave_rom_w(space, offset>>1, data << 16, mem_mask << 16); } else { wave_rom_w(space, offset>>1, data, mem_mask); } }
12431075
1244READ16_MEMBER(cojag_state::jaguar_dsp_ram_r16){ if (!(offset&1)) { return jaguar_dsp_ram_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return jaguar_dsp_ram_r(space, offset>>1, mem_mask); } }
1245WRITE16_MEMBER(cojag_state::jaguar_dsp_ram_w16){ if (!(offset&1)) { jaguar_dsp_ram_w(space, offset>>1, data << 16, mem_mask << 16); } else { jaguar_dsp_ram_w(space, offset>>1, data, mem_mask); } }
1246READ16_MEMBER(cojag_state::jaguar_gpu_clut_r16){ if (!(offset&1)) { return jaguar_gpu_clut_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return jaguar_gpu_clut_r(space, offset>>1, mem_mask); } }
1247WRITE16_MEMBER(cojag_state::jaguar_gpu_clut_w16){ if (!(offset&1)) { jaguar_gpu_clut_w(space, offset>>1, data << 16, mem_mask << 16); } else { jaguar_gpu_clut_w(space, offset>>1, data, mem_mask); } }
1248READ16_MEMBER(cojag_state::jaguar_gpu_ram_r16){ if (!(offset&1)) { return jaguar_gpu_ram_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return jaguar_gpu_ram_r(space, offset>>1, mem_mask); } }
1249WRITE16_MEMBER(cojag_state::jaguar_gpu_ram_w16){ if (!(offset&1)) { jaguar_gpu_ram_w(space, offset>>1, data << 16, mem_mask << 16); } else { jaguar_gpu_ram_w(space, offset>>1, data, mem_mask); } }
1076READ16_MEMBER(jaguar_state::dsp_ram_r16){ if (!(offset&1)) { return dsp_ram_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return dsp_ram_r(space, offset>>1, mem_mask); } }
1077WRITE16_MEMBER(jaguar_state::dsp_ram_w16){ if (!(offset&1)) { dsp_ram_w(space, offset>>1, data << 16, mem_mask << 16); } else { dsp_ram_w(space, offset>>1, data, mem_mask); } }
1078READ16_MEMBER(jaguar_state::gpu_clut_r16){ if (!(offset&1)) { return gpu_clut_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return gpu_clut_r(space, offset>>1, mem_mask); } }
1079WRITE16_MEMBER(jaguar_state::gpu_clut_w16){ if (!(offset&1)) { gpu_clut_w(space, offset>>1, data << 16, mem_mask << 16); } else { gpu_clut_w(space, offset>>1, data, mem_mask); } }
1080READ16_MEMBER(jaguar_state::gpu_ram_r16){ if (!(offset&1)) { return gpu_ram_r(space, offset>>1, mem_mask<<16) >> 16;  } else { return gpu_ram_r(space, offset>>1, mem_mask); } }
1081WRITE16_MEMBER(jaguar_state::gpu_ram_w16){ if (!(offset&1)) { gpu_ram_w(space, offset>>1, data << 16, mem_mask << 16); } else { gpu_ram_w(space, offset>>1, data, mem_mask); } }
12501082
1251static ADDRESS_MAP_START( jaguar_map, AS_PROGRAM, 16, cojag_state )
1083static ADDRESS_MAP_START( jaguar_map, AS_PROGRAM, 16, jaguar_state )
12521084   ADDRESS_MAP_GLOBAL_MASK(0xffffff)
1253   AM_RANGE(0x000000, 0x1fffff) AM_MIRROR(0x200000) AM_READWRITE(jaguar_shared_ram_r16, jaguar_shared_ram_w16 );
1254   AM_RANGE(0x800000, 0xdfffff) AM_READWRITE(jaguar_cart_base_r16, jaguar_cart_base_w16 )
1255   AM_RANGE(0xe00000, 0xe1ffff) AM_READWRITE(jaguar_rom_base_r16, jaguar_rom_base_w16 )
1256   AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE_LEGACY(jaguar_tom_regs_r, jaguar_tom_regs_w) // might be reversed endian of the others..
1257   AM_RANGE(0xf00400, 0xf005ff) AM_MIRROR(0x000200) AM_READWRITE(jaguar_gpu_clut_r16, jaguar_gpu_clut_w16 )
1085   AM_RANGE(0x000000, 0x1fffff) AM_MIRROR(0x200000) AM_READWRITE(shared_ram_r16, shared_ram_w16 );
1086   AM_RANGE(0x800000, 0xdfffff) AM_READWRITE(cart_base_r16, cart_base_w16 )
1087   AM_RANGE(0xe00000, 0xe1ffff) AM_READWRITE(rom_base_r16, rom_base_w16 )
1088   AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE(tom_regs_r, tom_regs_w) // might be reversed endian of the others..
1089   AM_RANGE(0xf00400, 0xf005ff) AM_MIRROR(0x000200) AM_READWRITE(gpu_clut_r16, gpu_clut_w16 )
12581090   AM_RANGE(0xf02100, 0xf021ff) AM_MIRROR(0x008000) AM_READWRITE(gpuctrl_r16, gpuctrl_w16)
1259   AM_RANGE(0xf02200, 0xf022ff) AM_MIRROR(0x008000) AM_READWRITE(jaguar_blitter_r16, jaguar_blitter_w16)
1260   AM_RANGE(0xf03000, 0xf03fff) AM_MIRROR(0x008000) AM_READWRITE(jaguar_gpu_ram_r16, jaguar_gpu_ram_w16 )
1261   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE_LEGACY(jaguar_jerry_regs_r, jaguar_jerry_regs_w) // might be reversed endian of the others..
1091   AM_RANGE(0xf02200, 0xf022ff) AM_MIRROR(0x008000) AM_READWRITE(blitter_r16, blitter_w16)
1092   AM_RANGE(0xf03000, 0xf03fff) AM_MIRROR(0x008000) AM_READWRITE(gpu_ram_r16, gpu_ram_w16 )
1093   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE(jerry_regs_r, jerry_regs_w) // might be reversed endian of the others..
12621094   AM_RANGE(0xf14000, 0xf14003) AM_READWRITE(joystick_r16, joystick_w16)
1263   AM_RANGE(0xf14800, 0xf14803) AM_READWRITE(jaguar_eeprom_clk16,jaguar_eeprom_w16)   // GPI00
1264   AM_RANGE(0xf15000, 0xf15003) AM_READ(jaguar_eeprom_cs16)            // GPI01
1095   AM_RANGE(0xf14800, 0xf14803) AM_READWRITE(eeprom_clk16,eeprom_w16)   // GPI00
1096   AM_RANGE(0xf15000, 0xf15003) AM_READ(eeprom_cs16)            // GPI01
12651097   AM_RANGE(0xf1a100, 0xf1a13f) AM_READWRITE(dspctrl_r16, dspctrl_w16)
1266   AM_RANGE(0xf1a140, 0xf1a17f) AM_READWRITE(jaguar_serial_r16, jaguar_serial_w16)
1267   AM_RANGE(0xf1b000, 0xf1cfff) AM_READWRITE(jaguar_dsp_ram_r16, jaguar_dsp_ram_w16)
1268   AM_RANGE(0xf1d000, 0xf1dfff) AM_READWRITE(high_rom_base_r16, high_rom_base_w16 )
1098   AM_RANGE(0xf1a140, 0xf1a17f) AM_READWRITE(serial_r16, serial_w16)
1099   AM_RANGE(0xf1b000, 0xf1cfff) AM_READWRITE(dsp_ram_r16, dsp_ram_w16)
1100   AM_RANGE(0xf1d000, 0xf1dfff) AM_READWRITE(wave_rom_r16, wave_rom_w16 )
12691101ADDRESS_MAP_END
12701102
12711103
r17621r17622
12761108 *
12771109 *************************************/
12781110
1279static ADDRESS_MAP_START( r3000_map, AS_PROGRAM, 32, cojag_state )
1280   AM_RANGE(0x04000000, 0x047fffff) AM_RAM AM_BASE_LEGACY(&jaguar_shared_ram) AM_SHARE("share1")
1281   AM_RANGE(0x04800000, 0x04bfffff) AM_ROMBANK("bank1")
1282   AM_RANGE(0x04c00000, 0x04dfffff) AM_ROMBANK("bank2")
1111static ADDRESS_MAP_START( r3000_map, AS_PROGRAM, 32, jaguar_state )
1112   AM_RANGE(0x04000000, 0x047fffff) AM_RAM AM_SHARE("sharedram")
1113   AM_RANGE(0x04800000, 0x04bfffff) AM_ROMBANK("maingfxbank")
1114   AM_RANGE(0x04c00000, 0x04dfffff) AM_ROMBANK("mainsndbank")
12831115   AM_RANGE(0x04e00000, 0x04e003ff) AM_DEVREADWRITE_LEGACY("ide", ide_controller32_r, ide_controller32_w)
1284   AM_RANGE(0x04f00000, 0x04f003ff) AM_READWRITE16_LEGACY(jaguar_tom_regs_r, jaguar_tom_regs_w, 0xffffffff)
1285   AM_RANGE(0x04f00400, 0x04f007ff) AM_RAM AM_BASE_LEGACY(&jaguar_gpu_clut) AM_SHARE("share2")
1116   AM_RANGE(0x04f00000, 0x04f003ff) AM_READWRITE16(tom_regs_r, tom_regs_w, 0xffffffff)
1117   AM_RANGE(0x04f00400, 0x04f007ff) AM_RAM AM_SHARE("gpuclut")
12861118   AM_RANGE(0x04f02100, 0x04f021ff) AM_READWRITE(gpuctrl_r, gpuctrl_w)
1287   AM_RANGE(0x04f02200, 0x04f022ff) AM_READWRITE_LEGACY(jaguar_blitter_r, jaguar_blitter_w)
1288   AM_RANGE(0x04f03000, 0x04f03fff) AM_MIRROR(0x00008000) AM_RAM AM_BASE_LEGACY(&jaguar_gpu_ram) AM_SHARE("share3")
1289   AM_RANGE(0x04f10000, 0x04f103ff) AM_READWRITE16_LEGACY(jaguar_jerry_regs_r, jaguar_jerry_regs_w, 0xffffffff)
1290   AM_RANGE(0x04f16000, 0x04f1600b) AM_READ_LEGACY(cojag_gun_input_r)   // GPI02
1119   AM_RANGE(0x04f02200, 0x04f022ff) AM_READWRITE(blitter_r, blitter_w)
1120   AM_RANGE(0x04f03000, 0x04f03fff) AM_MIRROR(0x00008000) AM_RAM AM_SHARE("gpuram")
1121   AM_RANGE(0x04f10000, 0x04f103ff) AM_READWRITE16(jerry_regs_r, jerry_regs_w, 0xffffffff)
1122   AM_RANGE(0x04f16000, 0x04f1600b) AM_READ(cojag_gun_input_r)   // GPI02
12911123   AM_RANGE(0x04f17000, 0x04f17003) AM_READ_PORT("SYSTEM")      // GPI03
12921124   AM_RANGE(0x04f17800, 0x04f17803) AM_WRITE(latch_w)         // GPI04
12931125   AM_RANGE(0x04f17c00, 0x04f17c03) AM_READ_PORT("P1_P2")      // GPI05
12941126   AM_RANGE(0x04f1a100, 0x04f1a13f) AM_READWRITE(dspctrl_r, dspctrl_w)
1295   AM_RANGE(0x04f1a140, 0x04f1a17f) AM_READWRITE_LEGACY(jaguar_serial_r, jaguar_serial_w)
1296   AM_RANGE(0x04f1b000, 0x04f1cfff) AM_RAM AM_BASE_LEGACY(&jaguar_dsp_ram) AM_SHARE("share4")
1127   AM_RANGE(0x04f1a140, 0x04f1a17f) AM_READWRITE(serial_r, serial_w)
1128   AM_RANGE(0x04f1b000, 0x04f1cfff) AM_RAM AM_SHARE("dspram")
12971129
12981130   AM_RANGE(0x06000000, 0x06000003) AM_READWRITE(misc_control_r, misc_control_w)
12991131   AM_RANGE(0x10000000, 0x1007ffff) AM_RAM
r17621r17622
13011133   AM_RANGE(0x14000004, 0x14000007) AM_WRITE(watchdog_reset32_w)
13021134   AM_RANGE(0x16000000, 0x16000003) AM_WRITE(eeprom_enable_w)
13031135   AM_RANGE(0x18000000, 0x18001fff) AM_READWRITE(eeprom_data_r, eeprom_data_w) AM_SHARE("nvram")
1304   AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION("user1", 0) AM_SHARE("robase")
1136   AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION("maincpu", 0) AM_SHARE("rom")
13051137ADDRESS_MAP_END
13061138
13071139
1308static ADDRESS_MAP_START( m68020_map, AS_PROGRAM, 32, cojag_state )
1309   AM_RANGE(0x000000, 0x7fffff) AM_RAM AM_BASE_LEGACY(&jaguar_shared_ram) AM_SHARE("share1")
1310   AM_RANGE(0x800000, 0x9fffff) AM_ROM AM_REGION("user1", 0) AM_SHARE("robase")
1140static ADDRESS_MAP_START( m68020_map, AS_PROGRAM, 32, jaguar_state )
1141   AM_RANGE(0x000000, 0x7fffff) AM_RAM AM_SHARE("sharedram")
1142   AM_RANGE(0x800000, 0x9fffff) AM_ROM AM_REGION("maincpu", 0) AM_SHARE("rom")
13111143   AM_RANGE(0xa00000, 0xa1ffff) AM_RAM
13121144   AM_RANGE(0xa20000, 0xa21fff) AM_READWRITE(eeprom_data_r, eeprom_data_w) AM_SHARE("nvram")
13131145   AM_RANGE(0xa30000, 0xa30003) AM_WRITE(watchdog_reset32_w)
13141146   AM_RANGE(0xa40000, 0xa40003) AM_WRITE(eeprom_enable_w)
13151147   AM_RANGE(0xb70000, 0xb70003) AM_READWRITE(misc_control_r, misc_control_w)
1316   AM_RANGE(0xc00000, 0xdfffff) AM_ROMBANK("bank2")
1148   AM_RANGE(0xc00000, 0xdfffff) AM_ROMBANK("mainsndbank")
13171149   AM_RANGE(0xe00000, 0xe003ff) AM_DEVREADWRITE_LEGACY("ide",  ide_controller32_r, ide_controller32_w)
1318   AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE16_LEGACY(jaguar_tom_regs_r, jaguar_tom_regs_w, 0xffffffff)
1319   AM_RANGE(0xf00400, 0xf007ff) AM_RAM AM_BASE_LEGACY(&jaguar_gpu_clut) AM_SHARE("share2")
1150   AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE16(tom_regs_r, tom_regs_w, 0xffffffff)
1151   AM_RANGE(0xf00400, 0xf007ff) AM_RAM AM_SHARE("gpuclut")
13201152   AM_RANGE(0xf02100, 0xf021ff) AM_READWRITE(gpuctrl_r, gpuctrl_w)
1321   AM_RANGE(0xf02200, 0xf022ff) AM_READWRITE_LEGACY(jaguar_blitter_r, jaguar_blitter_w)
1322   AM_RANGE(0xf03000, 0xf03fff) AM_MIRROR(0x008000) AM_RAM AM_BASE_LEGACY(&jaguar_gpu_ram) AM_SHARE("share3")
1323   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE16_LEGACY(jaguar_jerry_regs_r, jaguar_jerry_regs_w, 0xffffffff)
1324   AM_RANGE(0xf16000, 0xf1600b) AM_READ_LEGACY(cojag_gun_input_r)   // GPI02
1153   AM_RANGE(0xf02200, 0xf022ff) AM_READWRITE(blitter_r, blitter_w)
1154   AM_RANGE(0xf03000, 0xf03fff) AM_MIRROR(0x008000) AM_RAM AM_SHARE("gpuram")
1155   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE16(jerry_regs_r, jerry_regs_w, 0xffffffff)
1156   AM_RANGE(0xf16000, 0xf1600b) AM_READ(cojag_gun_input_r)   // GPI02
13251157   AM_RANGE(0xf17000, 0xf17003) AM_READ_PORT("SYSTEM")      // GPI03
13261158//  AM_RANGE(0xf17800, 0xf17803) AM_WRITE(latch_w)          // GPI04
13271159   AM_RANGE(0xf17c00, 0xf17c03) AM_READ_PORT("P1_P2")      // GPI05
13281160   AM_RANGE(0xf1a100, 0xf1a13f) AM_READWRITE(dspctrl_r, dspctrl_w)
1329   AM_RANGE(0xf1a140, 0xf1a17f) AM_READWRITE_LEGACY(jaguar_serial_r, jaguar_serial_w)
1330   AM_RANGE(0xf1b000, 0xf1cfff) AM_RAM AM_BASE_LEGACY(&jaguar_dsp_ram) AM_SHARE("share4")
1161   AM_RANGE(0xf1a140, 0xf1a17f) AM_READWRITE(serial_r, serial_w)
1162   AM_RANGE(0xf1b000, 0xf1cfff) AM_RAM AM_SHARE("dspram")
13311163ADDRESS_MAP_END
13321164
13331165
r17621r17622
13381170 *
13391171 *************************************/
13401172
1341static ADDRESS_MAP_START( gpu_map, AS_PROGRAM, 32, cojag_state )
1342   AM_RANGE(0x000000, 0x7fffff) AM_RAM AM_SHARE("share1")
1343   AM_RANGE(0x800000, 0xbfffff) AM_ROMBANK("bank8")
1344   AM_RANGE(0xc00000, 0xdfffff) AM_ROMBANK("bank9")
1173static ADDRESS_MAP_START( gpu_map, AS_PROGRAM, 32, jaguar_state )
1174   AM_RANGE(0x000000, 0x7fffff) AM_RAM AM_SHARE("sharedram")
1175   AM_RANGE(0x800000, 0xbfffff) AM_ROMBANK("gpugfxbank")
1176   AM_RANGE(0xc00000, 0xdfffff) AM_ROMBANK("dspsndbank")
13451177   AM_RANGE(0xe00000, 0xe003ff) AM_DEVREADWRITE_LEGACY("ide", ide_controller32_r, ide_controller32_w)
1346   AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE16_LEGACY(jaguar_tom_regs_r, jaguar_tom_regs_w, 0xffffffff)
1347   AM_RANGE(0xf00400, 0xf007ff) AM_RAM AM_SHARE("share2")
1178   AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE16(tom_regs_r, tom_regs_w, 0xffffffff)
1179   AM_RANGE(0xf00400, 0xf007ff) AM_RAM AM_SHARE("gpuclut")
13481180   AM_RANGE(0xf02100, 0xf021ff) AM_READWRITE(gpuctrl_r, gpuctrl_w)
1349   AM_RANGE(0xf02200, 0xf022ff) AM_READWRITE_LEGACY(jaguar_blitter_r, jaguar_blitter_w)
1350   AM_RANGE(0xf03000, 0xf03fff) AM_RAM AM_SHARE("share3")
1351   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE16_LEGACY(jaguar_jerry_regs_r, jaguar_jerry_regs_w, 0xffffffff)
1181   AM_RANGE(0xf02200, 0xf022ff) AM_READWRITE(blitter_r, blitter_w)
1182   AM_RANGE(0xf03000, 0xf03fff) AM_RAM AM_SHARE("gpuram")
1183   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE16(jerry_regs_r, jerry_regs_w, 0xffffffff)
13521184ADDRESS_MAP_END
13531185
13541186
r17621r17622
13591191 *
13601192 *************************************/
13611193
1362static ADDRESS_MAP_START( dsp_map, AS_PROGRAM, 32, cojag_state )
1363   AM_RANGE(0x000000, 0x7fffff) AM_RAM AM_SHARE("share1")
1364   AM_RANGE(0x800000, 0xbfffff) AM_ROMBANK("bank8")
1365   AM_RANGE(0xc00000, 0xdfffff) AM_ROMBANK("bank9")
1366   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE16_LEGACY(jaguar_jerry_regs_r, jaguar_jerry_regs_w, 0xffffffff)
1194static ADDRESS_MAP_START( dsp_map, AS_PROGRAM, 32, jaguar_state )
1195   AM_RANGE(0x000000, 0x7fffff) AM_RAM AM_SHARE("sharedram")
1196   AM_RANGE(0x800000, 0xbfffff) AM_ROMBANK("gpugfxbank")
1197   AM_RANGE(0xc00000, 0xdfffff) AM_ROMBANK("dspsndbank")
1198   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE16(jerry_regs_r, jerry_regs_w, 0xffffffff)
13671199   AM_RANGE(0xf1a100, 0xf1a13f) AM_READWRITE(dspctrl_r, dspctrl_w)
1368   AM_RANGE(0xf1a140, 0xf1a17f) AM_READWRITE_LEGACY(jaguar_serial_r, jaguar_serial_w)
1369   AM_RANGE(0xf1b000, 0xf1cfff) AM_RAM AM_SHARE("share4")
1370   AM_RANGE(0xf1d000, 0xf1dfff) AM_READ(jaguar_wave_rom_r) AM_BASE_LEGACY(&jaguar_wave_rom)
1200   AM_RANGE(0xf1a140, 0xf1a17f) AM_READWRITE(serial_r, serial_w)
1201   AM_RANGE(0xf1b000, 0xf1cfff) AM_RAM AM_SHARE("dspram")
1202   AM_RANGE(0xf1d000, 0xf1dfff) AM_READ(wave_rom_r) AM_SHARE("waverom") AM_REGION("waverom", 0)
13711203ADDRESS_MAP_END
13721204
13731205/* ToDo, these maps SHOULD be merged with the ones above */
13741206
1375static ADDRESS_MAP_START( jag_gpu_map, AS_PROGRAM, 32, cojag_state )
1207static ADDRESS_MAP_START( jag_gpu_map, AS_PROGRAM, 32, jaguar_state )
13761208   ADDRESS_MAP_GLOBAL_MASK(0xffffff)
1377   AM_RANGE(0x000000, 0x1fffff) AM_RAM AM_BASE_LEGACY(&jaguar_shared_ram) AM_MIRROR(0x200000)  AM_SHARE("share1") AM_REGION("maincpu", 0)
1378   AM_RANGE(0x800000, 0xdfffff) AM_ROM AM_BASE_LEGACY(&cart_base) AM_SIZE_LEGACY(&cart_size)  AM_SHARE("share15") AM_REGION("maincpu", 0x800000)
1379   AM_RANGE(0xe00000, 0xe1ffff) AM_ROM AM_BASE_LEGACY(&rom_base) AM_SIZE_LEGACY(&rom_size)  AM_SHARE("share16") AM_REGION("maincpu", 0xe00000)
1380   AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE16_LEGACY(jaguar_tom_regs_r, jaguar_tom_regs_w, 0xffffffff)
1381   AM_RANGE(0xf00400, 0xf005ff) AM_BASE_LEGACY(&jaguar_gpu_clut) AM_MIRROR(0x000200) AM_RAM AM_SHARE("share2")
1209   AM_RANGE(0x000000, 0x1fffff) AM_RAM AM_MIRROR(0x200000)  AM_SHARE("sharedram") AM_REGION("maincpu", 0)
1210   AM_RANGE(0x800000, 0xdfffff) AM_ROM AM_SHARE("cart") AM_REGION("maincpu", 0x800000)
1211   AM_RANGE(0xe00000, 0xe1ffff) AM_ROM AM_SHARE("rom") AM_REGION("maincpu", 0xe00000)
1212   AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE16(tom_regs_r, tom_regs_w, 0xffffffff)
1213   AM_RANGE(0xf00400, 0xf005ff) AM_MIRROR(0x000200) AM_RAM AM_SHARE("gpuclut")
13821214   AM_RANGE(0xf02100, 0xf021ff) AM_MIRROR(0x008000) AM_READWRITE(gpuctrl_r, gpuctrl_w)
1383   AM_RANGE(0xf02200, 0xf022ff) AM_MIRROR(0x008000) AM_READWRITE_LEGACY(jaguar_blitter_r, jaguar_blitter_w)
1384   AM_RANGE(0xf03000, 0xf03fff) AM_BASE_LEGACY(&jaguar_gpu_ram) AM_MIRROR(0x008000) AM_RAM AM_SHARE("share3")
1385   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE16_LEGACY(jaguar_jerry_regs_r, jaguar_jerry_regs_w, 0xffffffff)
1215   AM_RANGE(0xf02200, 0xf022ff) AM_MIRROR(0x008000) AM_READWRITE(blitter_r, blitter_w)
1216   AM_RANGE(0xf03000, 0xf03fff) AM_MIRROR(0x008000) AM_RAM AM_SHARE("gpuram")
1217   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE16(jerry_regs_r, jerry_regs_w, 0xffffffff)
13861218   AM_RANGE(0xf14000, 0xf14003) AM_READWRITE(joystick_r, joystick_w)
13871219   AM_RANGE(0xf1a100, 0xf1a13f) AM_READWRITE(dspctrl_r, dspctrl_w)
1388   AM_RANGE(0xf1a140, 0xf1a17f) AM_READWRITE_LEGACY(jaguar_serial_r, jaguar_serial_w)
1389   AM_RANGE(0xf1b000, 0xf1cfff) AM_BASE_LEGACY(&jaguar_dsp_ram) AM_RAM AM_SHARE("share4")
1390   AM_RANGE(0xf1d000, 0xf1dfff) AM_ROM AM_BASE_LEGACY(&high_rom_base) AM_REGION("maincpu", 0xf1d000)
1220   AM_RANGE(0xf1a140, 0xf1a17f) AM_READWRITE(serial_r, serial_w)
1221   AM_RANGE(0xf1b000, 0xf1cfff) AM_RAM AM_SHARE("dspram")
1222   AM_RANGE(0xf1d000, 0xf1dfff) AM_ROM AM_SHARE("waverom") AM_REGION("waverom", 0)
13911223ADDRESS_MAP_END
13921224
1393static ADDRESS_MAP_START( jag_dsp_map, AS_PROGRAM, 32, cojag_state )
1225static ADDRESS_MAP_START( jag_dsp_map, AS_PROGRAM, 32, jaguar_state )
13941226   ADDRESS_MAP_GLOBAL_MASK(0xffffff)
1395   AM_RANGE(0x000000, 0x1fffff) AM_MIRROR(0x200000) AM_RAM AM_SHARE("share1") AM_REGION("maincpu", 0)
1396   AM_RANGE(0x800000, 0xdfffff) AM_ROM AM_SHARE("share15") AM_REGION("maincpu", 0x800000)
1397   AM_RANGE(0xe00000, 0xe1ffff) AM_ROM AM_SHARE("share16") AM_REGION("maincpu", 0xe00000)
1398   AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE16_LEGACY(jaguar_tom_regs_r, jaguar_tom_regs_w, 0xffffffff)
1399   AM_RANGE(0xf00400, 0xf005ff) AM_MIRROR(0x000200) AM_RAM AM_SHARE("share2")
1227   AM_RANGE(0x000000, 0x1fffff) AM_MIRROR(0x200000) AM_RAM AM_SHARE("sharedram") AM_REGION("maincpu", 0)
1228   AM_RANGE(0x800000, 0xdfffff) AM_ROM AM_SHARE("cart") AM_REGION("maincpu", 0x800000)
1229   AM_RANGE(0xe00000, 0xe1ffff) AM_ROM AM_SHARE("rom") AM_REGION("maincpu", 0xe00000)
1230   AM_RANGE(0xf00000, 0xf003ff) AM_READWRITE16(tom_regs_r, tom_regs_w, 0xffffffff)
1231   AM_RANGE(0xf00400, 0xf005ff) AM_MIRROR(0x000200) AM_RAM AM_SHARE("gpuclut")
14001232   AM_RANGE(0xf02100, 0xf021ff) AM_MIRROR(0x008000) AM_READWRITE(gpuctrl_r, gpuctrl_w)
1401   AM_RANGE(0xf02200, 0xf022ff) AM_MIRROR(0x008000) AM_READWRITE_LEGACY(jaguar_blitter_r, jaguar_blitter_w)
1402   AM_RANGE(0xf03000, 0xf03fff) AM_MIRROR(0x008000) AM_RAM AM_SHARE("share3")
1403   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE16_LEGACY(jaguar_jerry_regs_r, jaguar_jerry_regs_w, 0xffffffff)
1233   AM_RANGE(0xf02200, 0xf022ff) AM_MIRROR(0x008000) AM_READWRITE(blitter_r, blitter_w)
1234   AM_RANGE(0xf03000, 0xf03fff) AM_MIRROR(0x008000) AM_RAM AM_SHARE("gpuram")
1235   AM_RANGE(0xf10000, 0xf103ff) AM_READWRITE16(jerry_regs_r, jerry_regs_w, 0xffffffff)
14041236   AM_RANGE(0xf14000, 0xf14003) AM_READWRITE(joystick_r, joystick_w)
14051237   AM_RANGE(0xf1a100, 0xf1a13f) AM_READWRITE(dspctrl_r, dspctrl_w)
1406   AM_RANGE(0xf1a140, 0xf1a17f) AM_READWRITE_LEGACY(jaguar_serial_r, jaguar_serial_w)
1407   AM_RANGE(0xf1b000, 0xf1cfff) AM_RAM AM_SHARE("share4")
1408   AM_RANGE(0xf1d000, 0xf1dfff) AM_ROM AM_REGION("maincpu", 0xf1d000)
1238   AM_RANGE(0xf1a140, 0xf1a17f) AM_READWRITE(serial_r, serial_w)
1239   AM_RANGE(0xf1b000, 0xf1cfff) AM_RAM AM_SHARE("dspram")
1240   AM_RANGE(0xf1d000, 0xf1dfff) AM_ROM AM_REGION("waverom", 0)
14091241ADDRESS_MAP_END
14101242
14111243/*************************************
r17621r17622
17231555
17241556static const jaguar_cpu_config gpu_config =
17251557{
1726   jaguar_gpu_cpu_int
1558   &jaguar_state::gpu_cpu_int
17271559};
17281560
17291561
17301562static const jaguar_cpu_config dsp_config =
17311563{
1732   jaguar_dsp_cpu_int
1564   &jaguar_state::dsp_cpu_int
17331565};
17341566
17351567static const ide_config ide_intf =
17361568{
1737   jaguar_external_int,
1569   &jaguar_state::external_int,
17381570   NULL,
17391571   0
17401572};
17411573
1742static MACHINE_CONFIG_START( cojagr3k, cojag_state )
1574static MACHINE_CONFIG_START( cojagr3k, jaguar_state )
17431575
17441576   /* basic machine hardware */
17451577   MCFG_CPU_ADD("maincpu", R3041BE, R3000_CLOCK)
r17621r17622
17501582   MCFG_CPU_CONFIG(gpu_config)
17511583   MCFG_CPU_PROGRAM_MAP(gpu_map)
17521584
1753   MCFG_CPU_ADD("audiocpu", JAGUARDSP, COJAG_CLOCK/2)
1585   MCFG_CPU_ADD("dsp", JAGUARDSP, COJAG_CLOCK/2)
17541586   MCFG_CPU_CONFIG(dsp_config)
17551587   MCFG_CPU_PROGRAM_MAP(dsp_map)
17561588
1757   MCFG_MACHINE_RESET(cojag)
17581589   MCFG_NVRAM_ADD_1FILL("nvram")
17591590
17601591   MCFG_IDE_CONTROLLER_ADD("ide", ide_intf, ide_devices, "hdd", NULL, true)
17611592
1762   MCFG_TIMER_ADD("serial_timer", jaguar_serial_callback)
1763
17641593   /* video hardware */
17651594   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
17661595
17671596   MCFG_SCREEN_ADD("screen", RASTER)
17681597   MCFG_SCREEN_RAW_PARAMS(COJAG_PIXEL_CLOCK/2, 456, 42, 402, 262, 17, 257)
1769   MCFG_SCREEN_UPDATE_STATIC(cojag)
1598   MCFG_SCREEN_UPDATE_DRIVER(jaguar_state,screen_update)
17701599
1771   MCFG_VIDEO_START(cojag)
1772
17731600   /* sound hardware */
17741601   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
17751602
r17621r17622
17931620MACHINE_CONFIG_END
17941621
17951622
1796static MACHINE_CONFIG_START( jaguar, cojag_state )
1623static MACHINE_CONFIG_START( jaguar, jaguar_state )
17971624
17981625   /* basic machine hardware */
17991626   MCFG_CPU_ADD("maincpu", M68000, JAGUAR_CLOCK/2)
r17621r17622
18031630   MCFG_CPU_CONFIG(gpu_config)
18041631   MCFG_CPU_PROGRAM_MAP(jag_gpu_map)
18051632
1806   MCFG_CPU_ADD("audiocpu", JAGUARDSP, JAGUAR_CLOCK)
1633   MCFG_CPU_ADD("dsp", JAGUARDSP, JAGUAR_CLOCK)
18071634   MCFG_CPU_CONFIG(dsp_config)
18081635   MCFG_CPU_PROGRAM_MAP(jag_dsp_map)
18091636
1810   MCFG_MACHINE_RESET(jaguar)
18111637//  MCFG_NVRAM_HANDLER(jaguar)
18121638
1813   MCFG_TIMER_ADD("serial_timer", jaguar_serial_callback)
1814
18151639   /* video hardware */
18161640   MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
18171641   MCFG_SCREEN_ADD("screen", RASTER)
18181642   MCFG_SCREEN_REFRESH_RATE(60)
18191643   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
18201644   MCFG_SCREEN_RAW_PARAMS(JAGUAR_CLOCK, 456, 42, 402, 262, 17, 257)
1821   MCFG_SCREEN_UPDATE_STATIC(cojag)
1645   MCFG_SCREEN_UPDATE_DRIVER(jaguar_state,screen_update)
18221646
1823   MCFG_VIDEO_START(jaguar)
1824
18251647   /* sound hardware */
18261648   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
18271649   MCFG_DAC_ADD("dac1")
r17621r17622
18531675 *
18541676 *************************************/
18551677
1856static void jaguar_fix_endian( running_machine &machine, UINT32 addr, UINT32 size )
1678void jaguar_state::fix_endian( UINT32 addr, UINT32 size )
18571679{
1858   UINT8 j[4], *RAM = machine.root_device().memregion("maincpu")->base();
1680   UINT8 j[4], *ram = memregion("maincpu")->base();
18591681   UINT32 i;
18601682   size += addr;
18611683   logerror("File Loaded to address range %X to %X\n",addr,size-1);
18621684   for (i = addr; i < size; i+=4)
18631685   {
1864      j[0] = RAM[i];
1865      j[1] = RAM[i+1];
1866      j[2] = RAM[i+2];
1867      j[3] = RAM[i+3];
1868      RAM[i] = j[3];
1869      RAM[i+1] = j[2];
1870      RAM[i+2] = j[1];
1871      RAM[i+3] = j[0];
1686      j[0] = ram[i];
1687      j[1] = ram[i+1];
1688      j[2] = ram[i+2];
1689      j[3] = ram[i+3];
1690      ram[i] = j[3];
1691      ram[i+1] = j[2];
1692      ram[i+2] = j[1];
1693      ram[i+3] = j[0];
18721694   }
18731695}
18741696
1875DRIVER_INIT_MEMBER(cojag_state,jaguar)
1697DRIVER_INIT_MEMBER(jaguar_state,jaguar)
18761698{
1877   jaguar_hacks_enabled = false;
1878   state_save_register_global(machine(), joystick_data);
1879   using_cart = 0;
1699   m_hacks_enabled = false;
1700   save_item(NAME(m_joystick_data));
1701   m_using_cart = false;
18801702
18811703   for (int i=0;i<0x20000/4;i++) // the cd bios is bigger.. check
18821704   {
1883      rom_base[i] = ((rom_base[i] & 0xffff0000)>>16) | ((rom_base[i] & 0x0000ffff)<<16);
1705      m_rom_base[i] = ((m_rom_base[i] & 0xffff0000)>>16) | ((m_rom_base[i] & 0x0000ffff)<<16);
18841706   }
18851707
18861708   for (int i=0;i<0x1000/4;i++)
18871709   {
1888      high_rom_base[i] = ((high_rom_base[i] & 0xffff0000)>>16) | ((high_rom_base[i] & 0x0000ffff)<<16);
1710      m_wave_rom[i] = ((m_wave_rom[i] & 0xffff0000)>>16) | ((m_wave_rom[i] & 0x0000ffff)<<16);
18891711   }
18901712}
18911713
1892static QUICKLOAD_LOAD( jaguar )
1714QUICKLOAD_LOAD( jaguar )
18931715{
1716   return image.device().machine().driver_data<jaguar_state>()->quickload(image, file_type, quickload_size);
1717}
1718
1719int jaguar_state::quickload(device_image_interface &image, const char *file_type, int quickload_size)
1720{
18941721   offs_t quickload_begin = 0x4000, start = quickload_begin, skip = 0;
1895   memset(jaguar_shared_ram, 0, 0x200000);
1722
1723   memset(m_shared_ram, 0, 0x200000);
18961724   quickload_size = MIN(quickload_size, 0x200000 - quickload_begin);
18971725
1898   image.fread( &image.device().machine().root_device().memregion("maincpu")->base()[quickload_begin], quickload_size);
1726   image.fread( &memregion("maincpu")->base()[quickload_begin], quickload_size);
18991727
1900   jaguar_fix_endian(image.device().machine(), quickload_begin, quickload_size);
1728   fix_endian(quickload_begin, quickload_size);
19011729
19021730   /* Deal with some of the numerous homebrew header systems */
19031731      /* COF */
1904   if ((jaguar_shared_ram[0x1000] & 0xffff0000) == 0x01500000)
1732   if ((m_shared_ram[0x1000] & 0xffff0000) == 0x01500000)
19051733   {
1906      start = jaguar_shared_ram[0x100e];
1907      skip = jaguar_shared_ram[0x1011];
1734      start = m_shared_ram[0x100e];
1735      skip = m_shared_ram[0x1011];
19081736   }
19091737   else   /* PRG */
1910   if (((jaguar_shared_ram[0x1000] & 0xffff0000) == 0x601A0000) && (jaguar_shared_ram[0x1007] == 0x4A414752))
1738   if (((m_shared_ram[0x1000] & 0xffff0000) == 0x601A0000) && (m_shared_ram[0x1007] == 0x4A414752))
19111739   {
1912      UINT32 type = jaguar_shared_ram[0x1008] >> 16;
1913      start = ((jaguar_shared_ram[0x1008] & 0xffff) << 16) | (jaguar_shared_ram[0x1009] >> 16);
1740      UINT32 type = m_shared_ram[0x1008] >> 16;
1741      start = ((m_shared_ram[0x1008] & 0xffff) << 16) | (m_shared_ram[0x1009] >> 16);
19141742      skip = 28;
19151743      if (type == 2) skip = 42;
19161744      else if (type == 3) skip = 46;
19171745   }
19181746   else   /* ABS with header */
1919   if ((jaguar_shared_ram[0x1000] & 0xffff0000) == 0x601B0000)
1747   if ((m_shared_ram[0x1000] & 0xffff0000) == 0x601B0000)
19201748   {
1921      start = ((jaguar_shared_ram[0x1005] & 0xffff) << 16) | (jaguar_shared_ram[0x1006] >> 16);
1749      start = ((m_shared_ram[0x1005] & 0xffff) << 16) | (m_shared_ram[0x1006] >> 16);
19221750      skip = 36;
19231751   }
19241752
19251753   else   /* A header used by Badcoder */
1926   if ((jaguar_shared_ram[0x1000] & 0xffff0000) == 0x72000000)
1754   if ((m_shared_ram[0x1000] & 0xffff0000) == 0x72000000)
19271755      skip = 96;
19281756
19291757   else   /* ABS binary */
r17621r17622
19381766   /* Now that we have the info, reload the file */
19391767   if ((start != quickload_begin) || (skip))
19401768   {
1941      memset(jaguar_shared_ram, 0, 0x200000);
1769      memset(m_shared_ram, 0, 0x200000);
19421770      image.fseek(0, SEEK_SET);
1943      image.fread( &image.device().machine().root_device().memregion("maincpu")->base()[start-skip], quickload_size);
1771      image.fread( &memregion("maincpu")->base()[start-skip], quickload_size);
19441772      quickload_begin = start;
1945      jaguar_fix_endian(image.device().machine(), (start-skip)&0xfffffc, quickload_size);
1773      fix_endian((start-skip)&0xfffffc, quickload_size);
19461774   }
19471775
19481776
19491777   /* Some programs are too lazy to set a stack pointer */
1950   cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENSP, 0x1000);
1951   jaguar_shared_ram[0]=0x1000;
1778   m_main_cpu->set_state(STATE_GENSP, 0x1000);
1779   m_shared_ram[0]=0x1000;
19521780
19531781   /* Transfer control to image */
1954   cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, quickload_begin);
1955   jaguar_shared_ram[1]=quickload_begin;
1782   m_main_cpu->set_state(STATE_GENPC, quickload_begin);
1783   m_shared_ram[1]=quickload_begin;
19561784   return IMAGE_INIT_PASS;
19571785}
19581786
19591787static DEVICE_START( jaguar_cart )
19601788{
1789   device->machine().driver_data<jaguar_state>()->cart_start();
1790}
1791
1792void jaguar_state::cart_start()
1793{
19611794   /* Initialize for no cartridge present */
1962   using_cart = 0;
1963   memset( cart_base, 0, cart_size );
1795   m_using_cart = false;
1796   memset( m_cart_base, 0, memshare("cart")->bytes() );
19641797}
19651798
19661799static DEVICE_IMAGE_LOAD( jaguar )
19671800{
1801   return image.device().machine().driver_data<jaguar_state>()->cart_load(image);
1802}
1803
1804int jaguar_state::cart_load(device_image_interface &image)
1805{
19681806   UINT32 size, load_offset = 0;
19691807
19701808   if (image.software_entry() == NULL)
r17621r17622
19751813      if (!mame_stricmp(image.filetype(), "rom"))
19761814      {
19771815         load_offset = 0x2000;      // fix load address
1978         cart_base[0x101]=0x802000;   // fix exec address
1816         m_cart_base[0x101]=0x802000;   // fix exec address
19791817      }
19801818
19811819      /* Load cart into memory */
1982      image.fread( &image.device().machine().root_device().memregion("maincpu")->base()[0x800000+load_offset], size);
1820      image.fread( &memregion("maincpu")->base()[0x800000+load_offset], size);
19831821   }
19841822   else
19851823   {
19861824      size = image.get_software_region_length("rom");
19871825
1988      memcpy(cart_base, image.get_software_region("rom"), size);
1826      memcpy(m_cart_base, image.get_software_region("rom"), size);
19891827   }
19901828
1991   memset(jaguar_shared_ram, 0, 0x200000);
1829   memset(m_shared_ram, 0, 0x200000);
19921830
1993   jaguar_fix_endian(image.device().machine(), 0x800000+load_offset, size);
1831   fix_endian(0x800000+load_offset, size);
19941832
19951833   /* Skip the logo */
1996   using_cart = 1;
1997//  cart_base[0x102] = 1;
1834   m_using_cart = true;
1835//  m_cart_base[0x102] = 1;
19981836
19991837   /* Transfer control to the bios */
2000   cpu_set_reg(image.device().machine().device("maincpu"), STATE_GENPC, rom_base[1]);
1838   m_main_cpu->set_state(STATE_GENPC, m_rom_base[1]);
20011839   return IMAGE_INIT_PASS;
20021840}
20031841
r17621r17622
20171855   ROM_REGION( 0x1000000, "maincpu", 0 )  /* 4MB for RAM at 0 */
20181856   ROM_LOAD16_WORD( "jagboot.rom", 0xe00000, 0x020000, CRC(fb731aaa) SHA1(f8991b0c385f4e5002fa2a7e2f5e61e8c5213356) )
20191857   ROM_CART_LOAD("cart", 0x800000, 0x600000, ROM_NOMIRROR)
2020   ROM_LOAD16_WORD("jagwave.rom", 0xf1d000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
1858
1859   ROM_REGION( 0x1000, "waverom", 0 )
1860   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
20211861ROM_END
20221862
20231863ROM_START( jaguarcd )
r17621r17622
20271867   ROM_SYSTEM_BIOS( 1, "dev", "Jaguar Developer CD" )
20281868   ROMX_LOAD( "jagdevcd.bin", 0xe00000, 0x040000, CRC(55a0669c) SHA1(d61b7b5912118f114ef00cf44966a5ef62e455a5), ROM_BIOS(2) )
20291869   ROM_CART_LOAD("cart", 0x800000, 0x600000, ROM_NOMIRROR)
2030   ROM_LOAD16_WORD("jagwave.rom", 0xf1d000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
1870
1871   ROM_REGION( 0x1000, "waverom", 0 )
1872   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
20311873ROM_END
20321874
20331875
r17621r17622
20401882/* There is known to exist an Area 51 set with "136105-000x Q" labels - currently not dumped */
20411883
20421884ROM_START( area51t ) /* 68020 based, Area51 Time Warner License  Date: Nov 15, 1995 */
2043   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for 68020 code */
1885   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for 68020 code */
20441886   ROM_LOAD32_BYTE( "136105-0003c.3h", 0x00000, 0x80000, CRC(e70a97c4) SHA1(39dabf6bf3dc6f717a587f362d040bfb332be9e1) ) /* Usually found with "green" labels */
20451887   ROM_LOAD32_BYTE( "136105-0002c.3p", 0x00001, 0x80000, CRC(e9c9f4bd) SHA1(7c6c50372d45dca8929767241b092339f3bab4d2) )
20461888   ROM_LOAD32_BYTE( "136105-0001c.3m", 0x00002, 0x80000, CRC(6f135a81) SHA1(2d9660f240b14481e8c46bc98713e9dc12035063) )
20471889   ROM_LOAD32_BYTE( "136105-0000c.3k", 0x00003, 0x80000, CRC(94f50c14) SHA1(a54552e3ac5c4f481ba4f2fc7d724534576fe76c) )
20481890
1891   ROM_REGION( 0x1000, "waverom", 0 )
1892   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
1893
20491894   DISK_REGION( "drive_0" )
20501895   DISK_IMAGE( "area51t", 0, SHA1(d2865cc7b1bb08a4393a72013a90e18d8a8f9860) )
20511896ROM_END
20521897
20531898ROM_START( area51a ) /* 68020 based, Area51 Atari Games License  Date: Oct 25, 1995 */
2054   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for 68020 code */
1899   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for 68020 code */
20551900   ROM_LOAD32_BYTE( "136105-0003a.3h", 0x00000, 0x80000, CRC(116d37e6) SHA1(5d36cae792dd349faa77cd2d8018722a28ee55c1) ) /* Usually found with "orange" labels */
20561901   ROM_LOAD32_BYTE( "136105-0002a.3p", 0x00001, 0x80000, CRC(eb10f539) SHA1(dadc4be5a442dd4bd17385033056555e528ed994) )
20571902   ROM_LOAD32_BYTE( "136105-0001a.3m", 0x00002, 0x80000, CRC(c6d8322b) SHA1(90cf848a4195c51b505653cc2c74a3b9e3c851b8) )
20581903   ROM_LOAD32_BYTE( "136105-0000a.3k", 0x00003, 0x80000, CRC(729eb1b7) SHA1(21864b4281b1ad17b2903e3aa294e4be74161e80) )
20591904
1905   ROM_REGION( 0x1000, "waverom", 0 )
1906   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
1907
20601908   DISK_REGION( "drive_0" )
20611909   DISK_IMAGE( "area51", 0, SHA1(3b303bc37e206a6d7339352c869f050d04186f11) )
20621910ROM_END
20631911
20641912ROM_START( area51 ) /* R3000 based, labeled as "Area51 2-C"  Date: Nov 11 1996 */
2065   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for IDT 79R3041 code */
1913   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for IDT 79R3041 code */
20661914   ROM_LOAD32_BYTE( "a51_2-c.hh", 0x00000, 0x80000, CRC(13af6a1e) SHA1(69da54ed6886e825156bbcc256e8d7abd4dc1ff8) ) /* Usually found with "green" labels */
20671915   ROM_LOAD32_BYTE( "a51_2-c.hl", 0x00001, 0x80000, CRC(8ab6649b) SHA1(9b4945bc04f8a73161638a2c5fa2fd84c6fd31b4) )
20681916   ROM_LOAD32_BYTE( "a51_2-c.lh", 0x00002, 0x80000, CRC(a6524f73) SHA1(ae377a6803a4f7d1bbcc111725af121a3e82317d) )
20691917   ROM_LOAD32_BYTE( "a51_2-c.ll", 0x00003, 0x80000, CRC(471b15d2) SHA1(4b5f45ee140b03a6be61475cae1c2dbef0f07457) )
20701918
1919   ROM_REGION( 0x1000, "waverom", 0 )
1920   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
1921
20711922   DISK_REGION( "drive_0" )
20721923   DISK_IMAGE( "area51", 0, SHA1(3b303bc37e206a6d7339352c869f050d04186f11) )
20731924ROM_END
20741925
20751926ROM_START( maxforce ) /* R3000 based, labeled as "Maximum Force 5-23-97 v1.05" */
2076   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for IDT 79R3041 code */
1927   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for IDT 79R3041 code */
20771928   ROM_LOAD32_BYTE( "maxf_105.hh", 0x00000, 0x80000, CRC(ec7f8167) SHA1(0cf057bfb1f30c2c9621d3ed25021e7ba7bdd46e) ) /* Usually found with "light grey" labels */
20781929   ROM_LOAD32_BYTE( "maxf_105.hl", 0x00001, 0x80000, CRC(3172611c) SHA1(00f14f871b737c66c20f95743740d964d0be3f24) )
20791930   ROM_LOAD32_BYTE( "maxf_105.lh", 0x00002, 0x80000, CRC(84d49423) SHA1(88d9a6724f1118f2bbef5dfa27accc2b65c5ba1d) )
20801931   ROM_LOAD32_BYTE( "maxf_105.ll", 0x00003, 0x80000, CRC(16d0768d) SHA1(665a6d7602a7f2f5b1f332b0220b1533143d56b1) )
20811932
1933   ROM_REGION( 0x1000, "waverom", 0 )
1934   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
1935
20821936   DISK_REGION( "drive_0" )
20831937   DISK_IMAGE( "maxforce", 0, SHA1(d54e7a8f3866bb2a1d28ae637e7c92ffa4dbe558) )
20841938ROM_END
20851939
20861940
20871941ROM_START( maxf_102 ) /* R3000 based, labeled as "Maximum Force 2-27-97 v1.02" */
2088   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for IDT 79R3041 code */
1942   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for IDT 79R3041 code */
20891943   ROM_LOAD32_BYTE( "maxf_102.hh", 0x00000, 0x80000, CRC(8ff7009d) SHA1(da22eae298a6e0e36f503fa091ac3913423dcd0f) ) /* Usually found with "yellow" labels */
20901944   ROM_LOAD32_BYTE( "maxf_102.hl", 0x00001, 0x80000, CRC(96c2cc1d) SHA1(b332b8c042b92c736131c478cefac1c3c2d2673b) )
20911945   ROM_LOAD32_BYTE( "maxf_102.lh", 0x00002, 0x80000, CRC(459ffba5) SHA1(adb40db6904e84c17f32ac6518fd2e994da7883f) )
20921946   ROM_LOAD32_BYTE( "maxf_102.ll", 0x00003, 0x80000, CRC(e491be7f) SHA1(cbe281c099a4aa87067752d68cf2bb0ab3900531) )
20931947
1948   ROM_REGION( 0x1000, "waverom", 0 )
1949   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
1950
20941951   DISK_REGION( "drive_0" )
20951952   DISK_IMAGE( "maxforce", 0, SHA1(d54e7a8f3866bb2a1d28ae637e7c92ffa4dbe558) )
20961953ROM_END
20971954
20981955
20991956ROM_START( maxf_ng ) /* R3000 based, stickers say 'NO GORE' */
2100   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for IDT 79R3041 code */
1957   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for IDT 79R3041 code */
21011958   ROM_LOAD32_BYTE( "mf_ng_hh.21v", 0x00000, 0x80000, CRC(08791c02) SHA1(9befbff3201c7d345109b26c296fd8548dbfc95b) )
21021959   ROM_LOAD32_BYTE( "mf_ng_hl.17v", 0x00001, 0x80000, CRC(52cf482c) SHA1(ff98b3f04987acef82a97a2ad35a9085fa84e6d5) )
21031960   ROM_LOAD32_BYTE( "mf_ng_lh.21y", 0x00002, 0x80000, CRC(ab4ee992) SHA1(69f0fe111d3f5f31151d2922579e5073e484b1e1) )
21041961   ROM_LOAD32_BYTE( "mf_ng_ll.17y", 0x00003, 0x80000, CRC(674aab43) SHA1(f79d790538756d1100b7e4ffed192a62a031a2cb) )
21051962
1963   ROM_REGION( 0x1000, "waverom", 0 )
1964   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
1965
21061966   ROM_REGION( 0x800, "user2", 0 ) /* 28C16 style eeprom, currently loaded but not used */
21071967   ROM_LOAD( "28c16.17z", 0x000, 0x800, CRC(1cdd9088) SHA1(4f01f02ff95f31ced87a3cdd7f171afd92551266) )
21081968
r17621r17622
21121972
21131973
21141974ROM_START( area51mx )   /* 68020 based, Labeled as "68020 MAX/A51 KIT 2.0" Date: Apr 22, 1998 */
2115   ROM_REGION32_BE( 0x200000, "user1", 0 ) /* 2MB for 68020 code */
1975   ROM_REGION32_BE( 0x200000, "maincpu", 0 ) /* 2MB for 68020 code */
21161976   ROM_LOAD32_BYTE( "area51mx.3h", 0x00000, 0x80000, CRC(47cbf30b) SHA1(23377bcc65c0fc330d5bc7e76e233bae043ac364) )
21171977   ROM_LOAD32_BYTE( "area51mx.3p", 0x00001, 0x80000, CRC(a3c93684) SHA1(f6b3357bb69900a176fd6bc6b819b2f57b7d0f59) )
21181978   ROM_LOAD32_BYTE( "area51mx.3m", 0x00002, 0x80000, CRC(d800ac17) SHA1(3d515c8608d8101ee9227116175b3c3f1fe22e0c) )
21191979   ROM_LOAD32_BYTE( "area51mx.3k", 0x00003, 0x80000, CRC(0e78f308) SHA1(adc4c8e441eb8fe525d0a6220eb3a2a8791a7289) )
21201980
1981   ROM_REGION( 0x1000, "waverom", 0 )
1982   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
1983
21211984   DISK_REGION( "drive_0" )
21221985   DISK_IMAGE( "area51mx", 0, SHA1(5ff10f4e87094d4449eabf3de7549564ca568c7e) )
21231986ROM_END
21241987
21251988
21261989ROM_START( a51mxr3k ) /* R3000 based, Labeled as "R3K Max/A51 Kit Ver 1.0" */
2127   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for IDT 79R3041 code */
1990   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for IDT 79R3041 code */
21281991   ROM_LOAD32_BYTE( "a51mxr3k.hh", 0x00000, 0x80000, CRC(a984dab2) SHA1(debb3bc11ff49e87a52e89a69533a1bab7db700e) )
21291992   ROM_LOAD32_BYTE( "a51mxr3k.hl", 0x00001, 0x80000, CRC(0af49d74) SHA1(c19f26056a823fd32293e9a7b3ea868640eabf49) )
21301993   ROM_LOAD32_BYTE( "a51mxr3k.lh", 0x00002, 0x80000, CRC(d7d94dac) SHA1(2060a74715f36a0d7f5dd0855eda48ad1f20f095) )
21311994   ROM_LOAD32_BYTE( "a51mxr3k.ll", 0x00003, 0x80000, CRC(ece9e5ae) SHA1(7e44402726f5afa6d1670b27aa43ad13d21c4ad9) )
21321995
1996   ROM_REGION( 0x1000, "waverom", 0 )
1997   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
1998
21331999   DISK_REGION( "drive_0" )
21342000   DISK_IMAGE( "area51mx", 0, SHA1(5ff10f4e87094d4449eabf3de7549564ca568c7e) )
21352001ROM_END
21362002
21372003
21382004ROM_START( vcircle )
2139   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for R3000 code */
2005   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for R3000 code */
21402006   ROM_LOAD32_BYTE( "hh", 0x00000, 0x80000, CRC(7276f5f5) SHA1(716287e370a4f300b1743103f8031afc82de38ca) )
21412007   ROM_LOAD32_BYTE( "hl", 0x00001, 0x80000, CRC(146060a1) SHA1(f291989f1f0ef228757f1990fb14da5ff8f3cf8d) )
21422008   ROM_LOAD32_BYTE( "lh", 0x00002, 0x80000, CRC(be4b2ef6) SHA1(4332b3036e9cb12685e914d085d9a63aa856f0be) )
21432009   ROM_LOAD32_BYTE( "ll", 0x00003, 0x80000, CRC(ba8753eb) SHA1(0322e0e37d814a38d08ba191b1a97fb1a55fe461) )
21442010
2011   ROM_REGION( 0x1000, "waverom", 0 )
2012   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
2013
21452014   DISK_REGION( "drive_0" )
21462015   DISK_IMAGE( "vcircle", 0, SHA1(bfa79c4cacdc9c2cd6362f62a23056b3e35a2034) )
21472016ROM_END
r17621r17622
21562025
21572026
21582027ROM_START( fishfren )
2159   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for R3000 code */
2028   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for R3000 code */
21602029   ROM_LOAD32_BYTE( "hh", 0x00000, 0x80000, CRC(2ef79767) SHA1(abcea584f2cbd71b05f9d7e61f40ca9da6799215) )
21612030   ROM_LOAD32_BYTE( "hl", 0x00001, 0x80000, CRC(7eefd4a2) SHA1(181be04836704098082fd78cacc68ffa70e77892) )
21622031   ROM_LOAD32_BYTE( "lh", 0x00002, 0x80000, CRC(bbe9ed15) SHA1(889af29afe6d984b39105aa238400392a5dfb2c5) )
21632032   ROM_LOAD32_BYTE( "ll", 0x00003, 0x80000, CRC(d70d0f2c) SHA1(2689cbe56ae3d491348b241528b0fe345fa8484c) )
21642033
2165   ROM_REGION32_BE( 0x1000000, "user2", 0 )   /* 16MB for 64-bit ROM data */
2034   ROM_REGION( 0x1000, "waverom", 0 )
2035   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
2036
2037   ROM_REGION32_BE( 0x1000000, "romboard", 0 )   /* 16MB for 64-bit ROM data */
21662038   ROMX_LOAD( "l63-56", 0x000000, 0x100000, CRC(42764ea5) SHA1(805245f01006bd974fbac56f688cfcf137ddc914), ROM_SKIP(7) )
21672039   ROMX_LOAD( "l55-48", 0x000001, 0x100000, CRC(0c7592bb) SHA1(d5bd6b872abad58947842205f9eac46fd065e88f), ROM_SKIP(7) )
21682040   ROMX_LOAD( "l47-40", 0x000002, 0x100000, CRC(6d7dcdb1) SHA1(914dae3b9df5c861f794b683571c5fb0c2c3c3fd), ROM_SKIP(7) )
r17621r17622
21792051   ROMX_LOAD( "h23-16", 0x800005, 0x080000, CRC(ab477a76) SHA1(ae9aa97dbc758cd741710fe08c6ea94a0a318451), ROM_SKIP(7) )
21802052   ROMX_LOAD( "h15-08", 0x800006, 0x080000, CRC(25a423f1) SHA1(7530cf2e28e0755bfcbd70789ef5cbbfb3d94f9f), ROM_SKIP(7) )
21812053   ROMX_LOAD( "h07-00", 0x800007, 0x080000, CRC(0f5f4cc6) SHA1(caa2b514fb1f2a815e63f7b8c6b79ce2dfa308c4), ROM_SKIP(7) )
2182   ROM_COPY( "user2", 0x800000, 0xc00000, 0x400000 )
2054   ROM_COPY( "romboard", 0x800000, 0xc00000, 0x400000 )
21832055ROM_END
21842056
21852057ROM_START( freezeat )
2186   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for R3000 code */
2058   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for R3000 code */
21872059   ROM_LOAD32_BYTE( "prog_eng.hh",          0x000000, 0x040000, CRC(f7cffafd) SHA1(62369de4cf0a5abab86f6bcf9621028b9e171ec3) )
21882060   ROM_LOAD32_BYTE( "prog_eng.hl",          0x000001, 0x040000, CRC(17150705) SHA1(c5a32d334bffb58a816920cc1251a21acc5a6f92) )
21892061   ROM_LOAD32_BYTE( "prog_eng.lh",          0x000002, 0x040000, CRC(12a903bf) SHA1(41f5949d7ed2081917af8411f92666b754564b37) )
21902062   ROM_LOAD32_BYTE( "prog_eng.ll",          0x000003, 0x040000, CRC(cf69f971) SHA1(132b06f5fb49801fff7e5deb7aa71b44d5b1c6ca) )
21912063
2192   ROM_REGION32_BE( 0x1000000, "user2", 0 )   /* 16MB for 64-bit ROM data */
2064   ROM_REGION( 0x1000, "waverom", 0 )
2065   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
2066
2067   ROM_REGION32_BE( 0x1000000, "romboard", 0 )   /* 16MB for 64-bit ROM data */
21932068   ROMX_LOAD( "fish_gr0.63-56", 0x000000, 0x100000, CRC(b61061c5) SHA1(aeb409aa5073232d80ed81b27946e753290234f4), ROM_SKIP(7) )
21942069   ROMX_LOAD( "fish_gr0.55-48", 0x000001, 0x100000, CRC(c85acf42) SHA1(c3365caeb126a83a7e7afcda25f05849ceb5c98b), ROM_SKIP(7) )
21952070   ROMX_LOAD( "fish_gr0.47-40", 0x000002, 0x100000, CRC(67f78f59) SHA1(40b256a8939fad365c7e896cff4a959fcc70a477), ROM_SKIP(7) )
r17621r17622
22092084ROM_END
22102085
22112086ROM_START( freezeatjp )
2212   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for R3000 code */
2087   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for R3000 code */
22132088   ROM_LOAD32_BYTE( "prog_jpn.hh",          0x000000, 0x040000, CRC(989302bf) SHA1(232927ec0a52b8bb587a3c206af8e1c6cde67860) )
22142089   ROM_LOAD32_BYTE( "prog_jpn.hl",          0x000001, 0x040000, CRC(6262b760) SHA1(12ca749f5cdc6db7d19f88a21f5f955b80206784) )
22152090   ROM_LOAD32_BYTE( "prog_jpn.lh",          0x000002, 0x040000, CRC(c6a12b0c) SHA1(971242b5b09e15164e7c335e684b5043510c6462) )
22162091   ROM_LOAD32_BYTE( "prog_jpn.ll",          0x000003, 0x040000, CRC(241ea755) SHA1(0db3cfbe577fc78387528390ebb14dbb7a09c97d) )
22172092
2218   ROM_REGION32_BE( 0x1000000, "user2", 0 )   /* 16MB for 64-bit ROM data */
2093   ROM_REGION( 0x1000, "waverom", 0 )
2094   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
2095
2096   ROM_REGION32_BE( 0x1000000, "romboard", 0 )   /* 16MB for 64-bit ROM data */
22192097   ROMX_LOAD( "fish_gr0.63-56", 0x000000, 0x100000, CRC(b61061c5) SHA1(aeb409aa5073232d80ed81b27946e753290234f4), ROM_SKIP(7) )
22202098   ROMX_LOAD( "fish_gr0.55-48", 0x000001, 0x100000, CRC(c85acf42) SHA1(c3365caeb126a83a7e7afcda25f05849ceb5c98b), ROM_SKIP(7) )
22212099   ROMX_LOAD( "fish_gr0.47-40", 0x000002, 0x100000, CRC(67f78f59) SHA1(40b256a8939fad365c7e896cff4a959fcc70a477), ROM_SKIP(7) )
r17621r17622
22352113ROM_END
22362114
22372115ROM_START( freezeat2 )
2238   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for R3000 code */
2116   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for R3000 code */
22392117   ROM_LOAD32_BYTE( "prog(__961018).hh",  0x000000, 0x040000, CRC(a8aefa52) SHA1(ba95da93035520de4b15245f68217c59dfb69dbd) )
22402118   ROM_LOAD32_BYTE( "prog(__961018).hl",  0x000001, 0x040000, CRC(152dd641) SHA1(52fa260baf1979ed8f15f8abcbbeebd8e595d0e4) )
22412119   ROM_LOAD32_BYTE( "prog(__961018).lh",  0x000002, 0x040000, CRC(416d26ed) SHA1(11cf3b88415a8a5d0bb8e1df08603a85202186ef) )
22422120   ROM_LOAD32_BYTE( "prog(__961018).ll",  0x000003, 0x040000, CRC(d6a5dbc8) SHA1(0e2176c35cbc59b2a5283366210409d0e930bac7) )
22432121
2244   ROM_REGION32_BE( 0x1000000, "user2", 0 )   /* 16MB for 64-bit ROM data */
2122   ROM_REGION( 0x1000, "waverom", 0 )
2123   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
2124
2125   ROM_REGION32_BE( 0x1000000, "romboard", 0 )   /* 16MB for 64-bit ROM data */
22452126   ROMX_LOAD( "fish_gr0(__961018).63-56", 0x000000, 0x100000, CRC(99d0dc75) SHA1(b32126eea70c7584d1c34a6ca33282fbaf4b03aa), ROM_SKIP(7) )
22462127   ROMX_LOAD( "fish_gr0(__961018).55-48", 0x000001, 0x100000, CRC(2dfdfe62) SHA1(e0554d36ef5cf4b6ce171857ea4f2737f11286a5), ROM_SKIP(7) )
22472128   ROMX_LOAD( "fish_gr0(__961018).47-40", 0x000002, 0x100000, CRC(722aee2a) SHA1(bc79433131bed5b08453d1b80324a28a552783de), ROM_SKIP(7) )
r17621r17622
22612142ROM_END
22622143
22632144ROM_START( freezeat3 )
2264   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for R3000 code */
2145   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for R3000 code */
22652146   ROM_LOAD32_BYTE( "prog(__961007).hh",  0x000000, 0x040000, CRC(863942e6) SHA1(c7429c8a5c86ff93c64950e201cffca83dd7b7b0) )
22662147   ROM_LOAD32_BYTE( "prog(__961007).hl",  0x000001, 0x040000, CRC(2acc18ef) SHA1(ead02566f7641b1d1066bd2e257b695e5c7e8437) )
22672148   ROM_LOAD32_BYTE( "prog(__961007).lh",  0x000002, 0x040000, CRC(948cf20c) SHA1(86c757aa3c849ef5ba94ed4d5dbf10e833dab6bd) )
22682149   ROM_LOAD32_BYTE( "prog(__961007).ll",  0x000003, 0x040000, CRC(5f44969e) SHA1(32345d7c56a3a890e71f8c71f25414d442b60af8) )
22692150
2270   ROM_REGION32_BE( 0x1000000, "user2", 0 )   /* 16MB for 64-bit ROM data */
2151   ROM_REGION( 0x1000, "waverom", 0 )
2152   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
2153
2154   ROM_REGION32_BE( 0x1000000, "romboard", 0 )   /* 16MB for 64-bit ROM data */
22712155   ROMX_LOAD( "fish_gr0(__961007).63-56", 0x000000, 0x100000, CRC(36799449) SHA1(bb706fe7fdc68f840702a127eed7d4519dd45869), ROM_SKIP(7) )
22722156   ROMX_LOAD( "fish_gr0(__961007).55-48", 0x000001, 0x100000, CRC(23959947) SHA1(a35a6e62c7b2be57d41b1b64be93713cbf897f0a), ROM_SKIP(7) )
22732157   ROMX_LOAD( "fish_gr0(__961007).47-40", 0x000002, 0x100000, CRC(4657e4e0) SHA1(b6c07182babcb0a106bf4a8f2e3f524371dd882d), ROM_SKIP(7) )
r17621r17622
22872171ROM_END
22882172
22892173ROM_START( freezeat4 )
2290   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for R3000 code */
2174   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for R3000 code */
22912175   ROM_LOAD32_BYTE( "prog(__961003).hh",  0x000000, 0x040000, CRC(80336f5e) SHA1(9946e8eebec2cd68db059f40f535ea212f41913d) )
22922176   ROM_LOAD32_BYTE( "prog(__961003).hl",  0x000001, 0x040000, CRC(55125520) SHA1(13be4fbf32bcd94a2ea97fd690bd1dfdff146d33) )
22932177   ROM_LOAD32_BYTE( "prog(__961003).lh",  0x000002, 0x040000, CRC(9d99c794) SHA1(f443f05a5979db66d61ef4174f0369a1cf4b7793) )
22942178   ROM_LOAD32_BYTE( "prog(__961003).ll",  0x000003, 0x040000, CRC(e03700e0) SHA1(24d41750f02ee7e8fb379e517751b661400aa521) )
22952179
2296   ROM_REGION32_BE( 0x1000000, "user2", 0 )   /* 16MB for 64-bit ROM data */
2180   ROM_REGION( 0x1000, "waverom", 0 )
2181   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
2182
2183   ROM_REGION32_BE( 0x1000000, "romboard", 0 )   /* 16MB for 64-bit ROM data */
22972184   ROMX_LOAD( "fish_gr0(__961003).63-56", 0x000000, 0x100000, CRC(36799449) SHA1(bb706fe7fdc68f840702a127eed7d4519dd45869), ROM_SKIP(7) )
22982185   ROMX_LOAD( "fish_gr0(__961003).55-48", 0x000001, 0x100000, CRC(23959947) SHA1(a35a6e62c7b2be57d41b1b64be93713cbf897f0a), ROM_SKIP(7) )
22992186   ROMX_LOAD( "fish_gr0(__961003).47-40", 0x000002, 0x100000, CRC(4657e4e0) SHA1(b6c07182babcb0a106bf4a8f2e3f524371dd882d), ROM_SKIP(7) )
r17621r17622
23132200ROM_END
23142201
23152202ROM_START( freezeat5 )
2316   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for R3000 code */
2203   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for R3000 code */
23172204   ROM_LOAD32_BYTE( "prog(__960920).hh",  0x000000, 0x040000, CRC(95c4fc64) SHA1(cd00efe7f760ef1e4cdc4bc8a3b368427cb15d8a) )
23182205   ROM_LOAD32_BYTE( "prog(__960920).hl",  0x000001, 0x040000, CRC(ffb9cb71) SHA1(35d6a5440d63bc5b94c4447645365039169da368) )
23192206   ROM_LOAD32_BYTE( "prog(__960920).lh",  0x000002, 0x040000, CRC(3ddacd80) SHA1(79f9650531847eefd83908b6ea1e8362688b377c) )
23202207   ROM_LOAD32_BYTE( "prog(__960920).ll",  0x000003, 0x040000, CRC(95ebefb0) SHA1(b88b12adabd7b0902c3a78919bcec8d9a2b04168) )
23212208
2322   ROM_REGION32_BE( 0x1000000, "user2", 0 )   /* 16MB for 64-bit ROM data */
2209   ROM_REGION( 0x1000, "waverom", 0 )
2210   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
2211
2212   ROM_REGION32_BE( 0x1000000, "romboard", 0 )   /* 16MB for 64-bit ROM data */
23232213   ROMX_LOAD( "fish_gr0(__960920).63-56", 0x000000, 0x100000, CRC(404a10c3) SHA1(8e353ac7608bd54f0fea610c85166ad14f2faadb), ROM_SKIP(7) )
23242214   ROMX_LOAD( "fish_gr0(__960920).55-48", 0x000001, 0x100000, CRC(0b262f2f) SHA1(2a963cb5c3344091406d090edfdda498709c6aa6), ROM_SKIP(7) )
23252215   ROMX_LOAD( "fish_gr0(__960920).47-40", 0x000002, 0x100000, CRC(43f86d26) SHA1(b31d36b11052514b5bcd5bf8e400457ca572c306), ROM_SKIP(7) )
r17621r17622
23392229ROM_END
23402230
23412231ROM_START( freezeat6 )
2342   ROM_REGION32_BE( 0x200000, "user1", 0 )   /* 2MB for R3000 code */
2232   ROM_REGION32_BE( 0x200000, "maincpu", 0 )   /* 2MB for R3000 code */
23432233   ROM_LOAD32_BYTE( "prog(__960907).hh",  0x000000, 0x040000, CRC(120711fe) SHA1(387e3cc8a1a9ea7d65c528387891d09ed9889fe3) )
23442234   ROM_LOAD32_BYTE( "prog(__960907).hl",  0x000001, 0x040000, CRC(18dd292a) SHA1(00e79851140716985f43594142c97e510a06b24a) )
23452235   ROM_LOAD32_BYTE( "prog(__960907).lh",  0x000002, 0x040000, CRC(ce387e72) SHA1(021a274da0b828550a47c3778e1059d4e759693a) )
23462236   ROM_LOAD32_BYTE( "prog(__960907).ll",  0x000003, 0x040000, CRC(9b307b7c) SHA1(71b696802fe7c867525d2626351dcfacedabd696) )
23472237
2348   ROM_REGION32_BE( 0x1000000, "user2", 0 )   /* 16MB for 64-bit ROM data */
2238   ROM_REGION( 0x1000, "waverom", 0 )
2239   ROM_LOAD16_WORD("jagwave.rom", 0x0000, 0x1000, CRC(7a25ee5b) SHA1(58117e11fd6478c521fbd3fdbe157f39567552f0) )
2240
2241   ROM_REGION32_BE( 0x1000000, "romboard", 0 )   /* 16MB for 64-bit ROM data */
23492242   ROMX_LOAD( "fish_gr0(__960907).63-56", 0x000000, 0x100000, CRC(293a3308) SHA1(e4c88759c3b8f8a359db83817dbd0428350b4f7e), ROM_SKIP(7) )
23502243   ROMX_LOAD( "fish_gr0(__960907).55-48", 0x000001, 0x100000, CRC(18bb4bdf) SHA1(1f6c49b3b5946390fa7582b531f8d9af3baa2567), ROM_SKIP(7) )
23512244   ROMX_LOAD( "fish_gr0(__960907).47-40", 0x000002, 0x100000, CRC(1faedcc6) SHA1(1e4ecbe4553fb3ebfbd03bd7e16066ccb531d00b), ROM_SKIP(7) )
r17621r17622
23712264 *
23722265 *************************************/
23732266
2374static void cojag_common_init(running_machine &machine, UINT16 gpu_jump_offs, UINT16 spin_pc)
2267void jaguar_state::cojag_common_init(UINT16 gpu_jump_offs, UINT16 spin_pc)
23752268{
2376   cojag_state *state = machine.driver_data<cojag_state>();
2269   m_is_cojag = true;
2270
23772271   /* copy over the ROM */
2378   state->m_main_cpu = machine.device<cpu_device>("maincpu");
2379   cojag_is_r3000 = (state->m_main_cpu->type() == R3041BE);
2272   m_is_r3000 = (m_main_cpu->type() == R3041BE);
23802273
23812274   /* install synchronization hooks for GPU */
2382   if (cojag_is_r3000)
2383      machine.device("maincpu")->memory().space(AS_PROGRAM)->install_write_handler(0x04f0b000 + gpu_jump_offs, 0x04f0b003 + gpu_jump_offs, write32_delegate(FUNC(cojag_state::gpu_jump_w),state));
2275   if (m_is_r3000)
2276      m_main_cpu->space(AS_PROGRAM)->install_write_handler(0x04f0b000 + gpu_jump_offs, 0x04f0b003 + gpu_jump_offs, write32_delegate(FUNC(jaguar_state::gpu_jump_w), this));
23842277   else
2385      machine.device("maincpu")->memory().space(AS_PROGRAM)->install_write_handler(0xf0b000 + gpu_jump_offs, 0xf0b003 + gpu_jump_offs, write32_delegate(FUNC(cojag_state::gpu_jump_w),state));
2386   machine.device("gpu")->memory().space(AS_PROGRAM)->install_read_handler(0xf03000 + gpu_jump_offs, 0xf03003 + gpu_jump_offs, read32_delegate(FUNC(cojag_state::gpu_jump_r),state));
2387   state->m_gpu_jump_address = &jaguar_gpu_ram[gpu_jump_offs/4];
2388   state->m_gpu_spin_pc = 0xf03000 + spin_pc;
2278      m_main_cpu->space(AS_PROGRAM)->install_write_handler(0xf0b000 + gpu_jump_offs, 0xf0b003 + gpu_jump_offs, write32_delegate(FUNC(jaguar_state::gpu_jump_w), this));
2279   m_gpu->space(AS_PROGRAM)->install_read_handler(0xf03000 + gpu_jump_offs, 0xf03003 + gpu_jump_offs, read32_delegate(FUNC(jaguar_state::gpu_jump_r), this));
2280   m_gpu_jump_address = &m_gpu_ram[gpu_jump_offs/4];
2281   m_gpu_spin_pc = 0xf03000 + spin_pc;
23892282
2390   /* init the sound system and install DSP speedups */
2391   cojag_sound_init(machine);
2283   for (int i=0;i<0x1000/4;i++)
2284   {
2285      m_wave_rom[i] = ((m_wave_rom[i] & 0xffff0000)>>16) | ((m_wave_rom[i] & 0x0000ffff)<<16);
2286   }
23922287}
23932288
23942289
2395DRIVER_INIT_MEMBER(cojag_state,area51a)
2290DRIVER_INIT_MEMBER(jaguar_state,area51a)
23962291{
2397   jaguar_hacks_enabled = true;
2398   cojag_common_init(machine(), 0x5c4, 0x5a0);
2292   m_hacks_enabled = true;
2293   cojag_common_init(0x5c4, 0x5a0);
23992294
24002295#if ENABLE_SPEEDUP_HACKS
2401   {
2402
2403      /* install speedup for main CPU */
2404      m_main_speedup = machine().device("maincpu")->memory().space(AS_PROGRAM)->install_write_handler(0xa02030, 0xa02033, write32_delegate(FUNC(cojag_state::area51_main_speedup_w),this));
2405   }
2296   /* install speedup for main CPU */
2297   m_main_speedup = m_main_cpu->space(AS_PROGRAM)->install_write_handler(0xa02030, 0xa02033, write32_delegate(FUNC(jaguar_state::area51_main_speedup_w),this));
24062298#endif
24072299}
24082300
24092301
2410DRIVER_INIT_MEMBER(cojag_state,area51)
2302DRIVER_INIT_MEMBER(jaguar_state,area51)
24112303{
2412   jaguar_hacks_enabled = true;
2413   cojag_common_init(machine(), 0x0c0, 0x09e);
2304   m_hacks_enabled = true;
2305   cojag_common_init(0x0c0, 0x09e);
24142306
24152307#if ENABLE_SPEEDUP_HACKS
2416   {
2417
2418      /* install speedup for main CPU */
2419      m_main_speedup_max_cycles = 120;
2420      m_main_speedup = machine().device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x100062e8, 0x100062eb, read32_delegate(FUNC(cojag_state::cojagr3k_main_speedup_r),this));
2421   }
2308   /* install speedup for main CPU */
2309   m_main_speedup_max_cycles = 120;
2310   m_main_speedup = m_main_cpu->space(AS_PROGRAM)->install_read_handler(0x100062e8, 0x100062eb, read32_delegate(FUNC(jaguar_state::cojagr3k_main_speedup_r),this));
24222311#endif
24232312}
24242313
2425DRIVER_INIT_MEMBER(cojag_state,maxforce)
2314DRIVER_INIT_MEMBER(jaguar_state,maxforce)
24262315{
2427   jaguar_hacks_enabled = true;
2428   cojag_common_init(machine(), 0x0c0, 0x09e);
2316   m_hacks_enabled = true;
2317   cojag_common_init(0x0c0, 0x09e);
24292318
24302319   /* patch the protection */
24312320   m_rom_base[0x220/4] = 0x03e00008;
r17621r17622
24332322#if ENABLE_SPEEDUP_HACKS
24342323   /* install speedup for main CPU */
24352324   m_main_speedup_max_cycles = 120;
2436   m_main_speedup = machine().device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x1000865c, 0x1000865f, read32_delegate(FUNC(cojag_state::cojagr3k_main_speedup_r),this));
2325   m_main_speedup = m_main_cpu->space(AS_PROGRAM)->install_read_handler(0x1000865c, 0x1000865f, read32_delegate(FUNC(jaguar_state::cojagr3k_main_speedup_r),this));
24372326#endif
24382327}
24392328
24402329
2441DRIVER_INIT_MEMBER(cojag_state,area51mx)
2330DRIVER_INIT_MEMBER(jaguar_state,area51mx)
24422331{
2443   jaguar_hacks_enabled = true;
2444   cojag_common_init(machine(), 0x0c0, 0x09e);
2332   m_hacks_enabled = true;
2333   cojag_common_init(0x0c0, 0x09e);
24452334
24462335   /* patch the protection */
24472336   m_rom_base[0x418/4] = 0x4e754e75;
24482337
24492338#if ENABLE_SPEEDUP_HACKS
24502339   /* install speedup for main CPU */
2451   m_main_speedup = machine().device("maincpu")->memory().space(AS_PROGRAM)->install_write_handler(0xa19550, 0xa19557, write32_delegate(FUNC(cojag_state::area51mx_main_speedup_w),this));
2340   m_main_speedup = m_main_cpu->space(AS_PROGRAM)->install_write_handler(0xa19550, 0xa19557, write32_delegate(FUNC(jaguar_state::area51mx_main_speedup_w),this));
24522341#endif
24532342}
24542343
24552344
2456DRIVER_INIT_MEMBER(cojag_state,a51mxr3k)
2345DRIVER_INIT_MEMBER(jaguar_state,a51mxr3k)
24572346{
2458   jaguar_hacks_enabled = true;
2459   cojag_common_init(machine(), 0x0c0, 0x09e);
2347   m_hacks_enabled = true;
2348   cojag_common_init(0x0c0, 0x09e);
24602349
24612350   /* patch the protection */
24622351   m_rom_base[0x220/4] = 0x03e00008;
r17621r17622
24642353#if ENABLE_SPEEDUP_HACKS
24652354   /* install speedup for main CPU */
24662355   m_main_speedup_max_cycles = 120;
2467   m_main_speedup = machine().device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x10006f0c, 0x10006f0f, read32_delegate(FUNC(cojag_state::cojagr3k_main_speedup_r),this));
2356   m_main_speedup = m_main_cpu->space(AS_PROGRAM)->install_read_handler(0x10006f0c, 0x10006f0f, read32_delegate(FUNC(jaguar_state::cojagr3k_main_speedup_r),this));
24682357#endif
24692358}
24702359
24712360
2472DRIVER_INIT_MEMBER(cojag_state,fishfren)
2361DRIVER_INIT_MEMBER(jaguar_state,fishfren)
24732362{
2474   jaguar_hacks_enabled = true;
2475   cojag_common_init(machine(), 0x578, 0x554);
2363   m_hacks_enabled = true;
2364   cojag_common_init(0x578, 0x554);
24762365
24772366#if ENABLE_SPEEDUP_HACKS
2478   {
2479
2480      /* install speedup for main CPU */
2481      m_main_speedup_max_cycles = 200;
2482      m_main_speedup = machine().device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x10021b60, 0x10021b63, read32_delegate(FUNC(cojag_state::cojagr3k_main_speedup_r),this));
2483   }
2367   /* install speedup for main CPU */
2368   m_main_speedup_max_cycles = 200;
2369   m_main_speedup = m_main_cpu->space(AS_PROGRAM)->install_read_handler(0x10021b60, 0x10021b63, read32_delegate(FUNC(jaguar_state::cojagr3k_main_speedup_r),this));
24842370#endif
24852371}
24862372
24872373
2488static void init_freeze_common(running_machine &machine, offs_t main_speedup_addr)
2374void jaguar_state::init_freeze_common(offs_t main_speedup_addr)
24892375{
2490   cojag_common_init(machine, 0x0bc, 0x09c);
2376   cojag_common_init(0x0bc, 0x09c);
24912377
24922378#if ENABLE_SPEEDUP_HACKS
2493   {
2494      cojag_state *state = machine.driver_data<cojag_state>();
2495
2496      /* install speedup for main CPU */
2497      state->m_main_speedup_max_cycles = 200;
2498      if (main_speedup_addr != 0)
2499         state->m_main_speedup = machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(main_speedup_addr, main_speedup_addr + 3, read32_delegate(FUNC(cojag_state::cojagr3k_main_speedup_r),state));
2500      state->m_main_gpu_wait = machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x0400d900, 0x0400d900 + 3, read32_delegate(FUNC(cojag_state::main_gpu_wait_r),state));
2501   }
2379   /* install speedup for main CPU */
2380   m_main_speedup_max_cycles = 200;
2381   if (main_speedup_addr != 0)
2382      m_main_speedup = m_main_cpu->space(AS_PROGRAM)->install_read_handler(main_speedup_addr, main_speedup_addr + 3, read32_delegate(FUNC(jaguar_state::cojagr3k_main_speedup_r), this));
2383   m_main_gpu_wait = m_main_cpu->space(AS_PROGRAM)->install_read_handler(0x0400d900, 0x0400d900 + 3, read32_delegate(FUNC(jaguar_state::main_gpu_wait_r), this));
25022384#endif
25032385}
25042386
2505DRIVER_INIT_MEMBER(cojag_state,freezeat) { jaguar_hacks_enabled = true; init_freeze_common(machine(), 0x1001a9f4); }
2506DRIVER_INIT_MEMBER(cojag_state,freezeat2) { jaguar_hacks_enabled = true; init_freeze_common(machine(), 0x1001a8c4); }
2507DRIVER_INIT_MEMBER(cojag_state,freezeat3) { jaguar_hacks_enabled = true; init_freeze_common(machine(), 0x1001a134); }
2508DRIVER_INIT_MEMBER(cojag_state,freezeat4) { jaguar_hacks_enabled = true; init_freeze_common(machine(), 0x1001a134); }
2509DRIVER_INIT_MEMBER(cojag_state,freezeat5) { jaguar_hacks_enabled = true; init_freeze_common(machine(), 0x10019b34); }
2510DRIVER_INIT_MEMBER(cojag_state,freezeat6) { jaguar_hacks_enabled = true; init_freeze_common(machine(), 0x10019684); }
2387DRIVER_INIT_MEMBER(jaguar_state,freezeat) { m_hacks_enabled = true; init_freeze_common(0x1001a9f4); }
2388DRIVER_INIT_MEMBER(jaguar_state,freezeat2) { m_hacks_enabled = true; init_freeze_common(0x1001a8c4); }
2389DRIVER_INIT_MEMBER(jaguar_state,freezeat3) { m_hacks_enabled = true; init_freeze_common(0x1001a134); }
2390DRIVER_INIT_MEMBER(jaguar_state,freezeat4) { m_hacks_enabled = true; init_freeze_common(0x1001a134); }
2391DRIVER_INIT_MEMBER(jaguar_state,freezeat5) { m_hacks_enabled = true; init_freeze_common(0x10019b34); }
2392DRIVER_INIT_MEMBER(jaguar_state,freezeat6) { m_hacks_enabled = true; init_freeze_common(0x10019684); }
25112393
2512DRIVER_INIT_MEMBER(cojag_state,vcircle)
2394DRIVER_INIT_MEMBER(jaguar_state,vcircle)
25132395{
2514   jaguar_hacks_enabled = true;
2515   cojag_common_init(machine(), 0x5c0, 0x5a0);
2396   m_hacks_enabled = true;
2397   cojag_common_init(0x5c0, 0x5a0);
25162398
25172399#if ENABLE_SPEEDUP_HACKS
2518   {
2519
2520      /* install speedup for main CPU */
2521      m_main_speedup_max_cycles = 50;
2522      m_main_speedup = machine().device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x12005b34, 0x12005b37, read32_delegate(FUNC(cojag_state::cojagr3k_main_speedup_r),this));
2523   }
2400   /* install speedup for main CPU */
2401   m_main_speedup_max_cycles = 50;
2402   m_main_speedup = m_main_cpu->space(AS_PROGRAM)->install_read_handler(0x12005b34, 0x12005b37, read32_delegate(FUNC(jaguar_state::cojagr3k_main_speedup_r),this));
25242403#endif
25252404}
25262405
r17621r17622
25332412 *************************************/
25342413
25352414/*    YEAR   NAME      PARENT    COMPAT  MACHINE   INPUT     INIT      COMPANY    FULLNAME */
2536CONS( 1993,  jaguar,   0,        0,      jaguar,   jaguar,   cojag_state, jaguar,   "Atari",   "Jaguar", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
2537CONS( 1995,  jaguarcd, jaguar,   0,      jaguar,   jaguar,   cojag_state, jaguar,   "Atari",   "Jaguar CD", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
2415CONS( 1993,  jaguar,   0,        0,      jaguar,   jaguar,   jaguar_state, jaguar,   "Atari",   "Jaguar", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
2416CONS( 1995,  jaguarcd, jaguar,   0,      jaguar,   jaguar,   jaguar_state, jaguar,   "Atari",   "Jaguar CD", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
25382417
2539GAME( 1996, area51,    0,        cojagr3k,  area51, cojag_state,   area51,   ROT0, "Atari Games", "Area 51 (R3000)", 0 )
2540GAME( 1995, area51t,   area51,   cojag68k,  area51, cojag_state,   area51a,  ROT0, "Atari Games (Time Warner license)", "Area 51 (Time Warner license)", 0 )
2541GAME( 1995, area51a,   area51,   cojag68k,  area51, cojag_state,   area51a,  ROT0, "Atari Games", "Area 51 (Atari Games license)", 0 )
2542GAME( 1995, fishfren,  0,        cojagr3k_rom,  fishfren, cojag_state, fishfren, ROT0, "Time Warner Interactive", "Fishin' Frenzy (prototype)", 0 )
2543GAME( 1996, freezeat,  0,        cojagr3k_rom,  freezeat, cojag_state, freezeat, ROT0, "Atari Games", "Freeze (Atari) (prototype, English voice, 96/10/25)", 0 )
2544GAME( 1996, freezeatjp,freezeat, cojagr3k_rom,  freezeat, cojag_state, freezeat, ROT0, "Atari Games", "Freeze (Atari) (prototype, Japanese voice, 96/10/25)", 0 )
2545GAME( 1996, freezeat2, freezeat, cojagr3k_rom,  freezeat, cojag_state, freezeat2,ROT0, "Atari Games", "Freeze (Atari) (prototype, 96/10/18)", 0 )
2546GAME( 1996, freezeat3, freezeat, cojagr3k_rom,  freezeat, cojag_state, freezeat3,ROT0, "Atari Games", "Freeze (Atari) (prototype, 96/10/07)", 0 )
2547GAME( 1996, freezeat4, freezeat, cojagr3k_rom,  freezeat, cojag_state, freezeat4,ROT0, "Atari Games", "Freeze (Atari) (prototype, 96/10/03)", 0 )
2548GAME( 1996, freezeat5, freezeat, cojagr3k_rom,  freezeat, cojag_state, freezeat5,ROT0, "Atari Games", "Freeze (Atari) (prototype, 96/09/20, AMOA-96)", 0 )
2549GAME( 1996, freezeat6, freezeat, cojagr3k_rom,  freezeat, cojag_state, freezeat6,ROT0, "Atari Games", "Freeze (Atari) (prototype, 96/09/07, Jamma-96)", 0 )
2550GAME( 1996, maxforce,  0,        cojagr3k,  area51, cojag_state,   maxforce, ROT0, "Atari Games", "Maximum Force v1.05", 0 )
2551GAME( 1996, maxf_102,  maxforce, cojagr3k,  area51, cojag_state,   maxforce, ROT0, "Atari Games", "Maximum Force v1.02", 0 )
2552GAME( 1996, maxf_ng,   maxforce, cojagr3k,  area51, cojag_state,   maxforce, ROT0, "Atari Games", "Maximum Force (No Gore version)", 0 )
2553GAME( 1998, area51mx,  0,        cojag68k,  area51, cojag_state,   area51mx, ROT0, "Atari Games", "Area 51 / Maximum Force Duo v2.0", 0 )
2554GAME( 1998, a51mxr3k,  area51mx, cojagr3k,  area51, cojag_state,   a51mxr3k, ROT0, "Atari Games", "Area 51 / Maximum Force Duo (R3000)", 0 )
2555GAME( 1996, vcircle,   0,        cojagr3k,  vcircle, cojag_state,  vcircle,  ROT0, "Atari Games", "Vicious Circle (prototype)", 0 )
2418GAME( 1996, area51,    0,        cojagr3k,  area51, jaguar_state,   area51,   ROT0, "Atari Games", "Area 51 (R3000)", 0 )
2419GAME( 1995, area51t,   area51,   cojag68k,  area51, jaguar_state,   area51a,  ROT0, "Atari Games (Time Warner license)", "Area 51 (Time Warner license)", 0 )
2420GAME( 1995, area51a,   area51,   cojag68k,  area51, jaguar_state,   area51a,  ROT0, "Atari Games", "Area 51 (Atari Games license)", 0 )
2421GAME( 1995, fishfren,  0,        cojagr3k_rom,  fishfren, jaguar_state, fishfren, ROT0, "Time Warner Interactive", "Fishin' Frenzy (prototype)", 0 )
2422GAME( 1996, freezeat,  0,        cojagr3k_rom,  freezeat, jaguar_state, freezeat, ROT0, "Atari Games", "Freeze (Atari) (prototype, English voice, 96/10/25)", 0 )
2423GAME( 1996, freezeatjp,freezeat, cojagr3k_rom,  freezeat, jaguar_state, freezeat, ROT0, "Atari Games", "Freeze (Atari) (prototype, Japanese voice, 96/10/25)", 0 )
2424GAME( 1996, freezeat2, freezeat, cojagr3k_rom,  freezeat, jaguar_state, freezeat2,ROT0, "Atari Games", "Freeze (Atari) (prototype, 96/10/18)", 0 )
2425GAME( 1996, freezeat3, freezeat, cojagr3k_rom,  freezeat, jaguar_state, freezeat3,ROT0, "Atari Games", "Freeze (Atari) (prototype, 96/10/07)", 0 )
2426GAME( 1996, freezeat4, freezeat, cojagr3k_rom,  freezeat, jaguar_state, freezeat4,ROT0, "Atari Games", "Freeze (Atari) (prototype, 96/10/03)", 0 )
2427GAME( 1996, freezeat5, freezeat, cojagr3k_rom,  freezeat, jaguar_state, freezeat5,ROT0, "Atari Games", "Freeze (Atari) (prototype, 96/09/20, AMOA-96)", 0 )
2428GAME( 1996, freezeat6, freezeat, cojagr3k_rom,  freezeat, jaguar_state, freezeat6,ROT0, "Atari Games", "Freeze (Atari) (prototype, 96/09/07, Jamma-96)", 0 )
2429GAME( 1996, maxforce,  0,        cojagr3k,  area51, jaguar_state,   maxforce, ROT0, "Atari Games", "Maximum Force v1.05", 0 )
2430GAME( 1996, maxf_102,  maxforce, cojagr3k,  area51, jaguar_state,   maxforce, ROT0, "Atari Games", "Maximum Force v1.02", 0 )
2431GAME( 1996, maxf_ng,   maxforce, cojagr3k,  area51, jaguar_state,   maxforce, ROT0, "Atari Games", "Maximum Force (No Gore version)", 0 )
2432GAME( 1998, area51mx,  0,        cojag68k,  area51, jaguar_state,   area51mx, ROT0, "Atari Games", "Area 51 / Maximum Force Duo v2.0", 0 )
2433GAME( 1998, a51mxr3k,  area51mx, cojagr3k,  area51, jaguar_state,   a51mxr3k, ROT0, "Atari Games", "Area 51 / Maximum Force Duo (R3000)", 0 )
2434GAME( 1996, vcircle,   0,        cojagr3k,  vcircle, jaguar_state,  vcircle,  ROT0, "Atari Games", "Vicious Circle (prototype)", 0 )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team