src/mame/drivers/megadriv.c
| r9388 | r9389 | |
| 342 | 342 | /* SegaCD! */ |
| 343 | 343 | static cpu_device *_segacd_68k_cpu; |
| 344 | 344 | static emu_timer *segacd_gfx_conversion_timer; |
| 345 | static emu_timer *segacd_irq3_timer; |
| 345 | 346 | static int segacd_wordram_mapped = 0; |
| 347 | static TIMER_CALLBACK( segacd_irq3_timer_callback ); |
| 346 | 348 | |
| 347 | 349 | /* SVP (virtua racing) */ |
| 348 | 350 | static cpu_device *_svp_cpu; |
| r9388 | r9389 | |
| 4848 | 4850 | segacd_gfx_conversion_timer = timer_alloc(machine, segacd_gfx_conversion_timer_callback, 0); |
| 4849 | 4851 | timer_adjust_oneshot(segacd_gfx_conversion_timer, attotime_never, 0); |
| 4850 | 4852 | |
| 4853 | segacd_irq3_timer = timer_alloc(machine, segacd_irq3_timer_callback, 0); |
| 4854 | timer_adjust_oneshot(segacd_irq3_timer, attotime_never, 0); |
| 4851 | 4855 | |
| 4856 | |
| 4857 | |
| 4852 | 4858 | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| 4853 | 4859 | machine->gfx[0] = gfx_element_alloc(machine, &sega_16x16_r00_f0_layout, (UINT8 *)segacd_dataram, 0, 0); |
| 4854 | 4860 | machine->gfx[1] = gfx_element_alloc(machine, &sega_16x16_r01_f0_layout, (UINT8 *)segacd_dataram, 0, 0); |
| r9388 | r9389 | |
| 5523 | 5529 | COMBINE_DATA(&segacd_imagebuffer_hdot_size); |
| 5524 | 5530 | } |
| 5525 | 5531 | |
| 5532 | static UINT16 segacd_irq3_timer_reg; |
| 5526 | 5533 | |
| 5534 | static READ16_HANDLER( segacd_irq3timer_r ) |
| 5535 | { |
| 5536 | return segacd_irq3_timer_reg; // always returns value written, not current counter! |
| 5537 | } |
| 5527 | 5538 | |
| 5539 | #define SEGACD_IRQ3_TIMER_SPEED (ATTOTIME_IN_NSEC(segacd_irq3_timer_reg*30720)) |
| 5540 | |
| 5541 | static 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 | |
| 5558 | static 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 | |
| 5528 | 5567 | static ADDRESS_MAP_START( segacd_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| 5529 | 5568 | AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_BASE(&segacd_4meg_prgram) |
| 5530 | 5569 | |
| r9388 | r9389 | |
| 5545 | 5584 | AM_RANGE(0xff800e ,0xff800f) AM_READWRITE(segacd_comms_flags_r, segacd_comms_flags_subcpu_w) |
| 5546 | 5585 | AM_RANGE(0xff8010 ,0xff801f) AM_READWRITE(segacd_comms_sub_part1_r, segacd_comms_sub_part1_w) |
| 5547 | 5586 | 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 |
| 5549 | 5588 | AM_RANGE(0xff8032, 0xff8033) AM_READWRITE(segacd_irq_mask_r,segacd_irq_mask_w) |
| 5550 | 5589 | AM_RANGE(0xff8034, 0xff8035) AM_NOP // CD Fader |
| 5551 | 5590 | AM_RANGE(0xff8036, 0xff8037) AM_READWRITE(segacd_cdd_ctrl_r,segacd_cdd_ctrl_w) |