Previous 15994 Revisions Next

r9389 Friday 15th October, 2010 at 09:36:30 UTC by Angelo Salese
[Mega CD]: Added irq 3 hook-up, allows Mega CD EU and JP versions to animate [David Haywood]
[src/mame/drivers]megadriv.c

src/mame/drivers/megadriv.c
r9388r9389
342342/* SegaCD! */
343343static cpu_device *_segacd_68k_cpu;
344344static emu_timer *segacd_gfx_conversion_timer;
345static emu_timer *segacd_irq3_timer;
345346static int segacd_wordram_mapped = 0;
347static TIMER_CALLBACK( segacd_irq3_timer_callback );
346348
347349/* SVP (virtua racing) */
348350static cpu_device *_svp_cpu;
r9388r9389
48484850   segacd_gfx_conversion_timer = timer_alloc(machine, segacd_gfx_conversion_timer_callback, 0);
48494851   timer_adjust_oneshot(segacd_gfx_conversion_timer, attotime_never, 0);
48504852
4853   segacd_irq3_timer = timer_alloc(machine, segacd_irq3_timer_callback, 0);
4854   timer_adjust_oneshot(segacd_irq3_timer, attotime_never, 0);
48514855
4856
4857
48524858   /* create the char set (gfx will then be updated dynamically from RAM) */
48534859   machine->gfx[0] = gfx_element_alloc(machine, &sega_16x16_r00_f0_layout, (UINT8 *)segacd_dataram, 0, 0);
48544860   machine->gfx[1] = gfx_element_alloc(machine, &sega_16x16_r01_f0_layout, (UINT8 *)segacd_dataram, 0, 0);
r9388r9389
55235529   COMBINE_DATA(&segacd_imagebuffer_hdot_size);
55245530}
55255531
5532static UINT16 segacd_irq3_timer_reg;
55265533
5534static READ16_HANDLER( segacd_irq3timer_r )
5535{
5536   return segacd_irq3_timer_reg; // always returns value written, not current counter!
5537}
55275538
5539#define SEGACD_IRQ3_TIMER_SPEED (ATTOTIME_IN_NSEC(segacd_irq3_timer_reg*30720))
5540
5541static WRITE16_HANDLER( segacd_irq3timer_w )
5542{
5543   if (ACCESSING_BITS_0_7)
5544   {
5545      segacd_irq3_timer_reg = data & 0xff;
5546
5547      // time = reg * 30.72 us
5548
5549      if (segacd_irq3_timer_reg)
5550         timer_adjust_oneshot(segacd_irq3_timer, SEGACD_IRQ3_TIMER_SPEED, 0);
5551      else
5552         timer_adjust_oneshot(segacd_irq3_timer, attotime_never, 0);
5553
5554      printf("segacd_irq3timer_w %02x\n", segacd_irq3_timer_reg);
5555   }
5556}
5557
5558static TIMER_CALLBACK( segacd_irq3_timer_callback )
5559{
5560   if (segacd_irq_mask & 0x08)
5561      cputag_set_input_line(machine, "segacd_68k", 3, HOLD_LINE);
5562     
5563   timer_adjust_oneshot(segacd_irq3_timer, SEGACD_IRQ3_TIMER_SPEED, 0);
5564}
5565
5566
55285567static ADDRESS_MAP_START( segacd_map, ADDRESS_SPACE_PROGRAM, 16 )
55295568   AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_BASE(&segacd_4meg_prgram)
55305569
r9388r9389
55455584   AM_RANGE(0xff800e ,0xff800f) AM_READWRITE(segacd_comms_flags_r, segacd_comms_flags_subcpu_w)
55465585   AM_RANGE(0xff8010 ,0xff801f) AM_READWRITE(segacd_comms_sub_part1_r, segacd_comms_sub_part1_w)
55475586   AM_RANGE(0xff8020 ,0xff802f) AM_READWRITE(segacd_comms_sub_part2_r, segacd_comms_sub_part2_w)
5548//   AM_RANGE(0xff8030, 0xff8031) // Timer W/INT3
5587   AM_RANGE(0xff8030, 0xff8031) AM_READWRITE(segacd_irq3timer_r, segacd_irq3timer_w) // Timer W/INT3
55495588   AM_RANGE(0xff8032, 0xff8033) AM_READWRITE(segacd_irq_mask_r,segacd_irq_mask_w)
55505589   AM_RANGE(0xff8034, 0xff8035) AM_NOP // CD Fader
55515590   AM_RANGE(0xff8036, 0xff8037) AM_READWRITE(segacd_cdd_ctrl_r,segacd_cdd_ctrl_w)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team