src/mess/drivers/cdi.c
| r6232 | r6233 | |
| 49 | 49 | |
| 50 | 50 | #define ENABLE_UART_PRINTING (0) |
| 51 | 51 | |
| 52 | | #define VERBOSE_LEVEL (5) |
| 52 | #define VERBOSE_LEVEL (6) |
| 53 | 53 | |
| 54 | 54 | #define ENABLE_VERBOSE_LOG (1) |
| 55 | 55 | |
| r6232 | r6233 | |
| 1669 | 1669 | (rounded_next_msf & 0x000f0000) >> 16, |
| 1670 | 1670 | (rounded_next_msf & 0x00f00000) >> 20 |
| 1671 | 1671 | }; |
| 1672 | | cdic_regs.time = next_msf << 8; |
| 1672 | |
| 1673 | 1673 | lba = nybbles[0] + nybbles[1]*10 + ((nybbles[2] + nybbles[3]*10)*75) + ((nybbles[4] + nybbles[5]*10)*75*60); |
| 1674 | 1674 | |
| 1675 | 1675 | cdrom_read_data(cdic_regs.cd, lba, buffer, CD_TRACK_RAW_DONTCARE); |
| r6232 | r6233 | |
| 1684 | 1684 | |
| 1685 | 1685 | } |
| 1686 | 1686 | |
| 1687 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x924/2] = 0x0001; // CTRL |
| 1688 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x926/2] = 0x0001; // TRACK |
| 1689 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x928/2] = 0x0000; // INDEX |
| 1690 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x92a/2] = (cdic_regs.time >> 24) & 0x000000ff; // MIN |
| 1691 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x92c/2] = (cdic_regs.time >> 16) & 0x000000ff; // SEC |
| 1692 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x92e/2] = (cdic_regs.time >> 8) & 0x0000007f; // FRAC |
| 1693 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x930/2] = 0x0000; // ZERO |
| 1694 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x932/2] = (cdic_regs.time >> 24) & 0x000000ff; // AMIN |
| 1695 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x934/2] = (cdic_regs.time >> 16) & 0x000000ff; // ASEC |
| 1696 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x936/2] = (cdic_regs.time >> 8) & 0x0000007f; // AFRAC |
| 1697 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x938/2] = 0x0000; // CRC1 |
| 1698 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x93a/2] = 0x0000; // CRC2 |
| 1699 | |
| 1700 | cdic_regs.time = next_msf << 8; |
| 1701 | |
| 1687 | 1702 | timer_adjust_oneshot(cdic_regs.interrupt_timer, ATTOTIME_IN_HZ(75), 0); |
| 1688 | 1703 | |
| 1689 | 1704 | cdic_regs.x_buffer |= 0x8000; |
| r6232 | r6233 | |
| 1730 | 1745 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + (index - 6)] = (buffer[index*2] << 8) | buffer[index*2 + 1]; |
| 1731 | 1746 | } |
| 1732 | 1747 | |
| 1733 | | cdram[0x924/2] = 0x0041; // CTRL |
| 1734 | | cdram[0x926/2] = 0x0001; // TRACK |
| 1735 | | cdram[0x928/2] = 0x0000; // INDEX |
| 1736 | | cdram[0x92a/2] = (cdic_regs.time >> 24) & 0x000000ff; // MIN |
| 1737 | | cdram[0x92c/2] = (cdic_regs.time >> 16) & 0x000000ff; // SEC |
| 1738 | | cdram[0x92e/2] = (cdic_regs.time >> 8) & 0x0000007f; // FRAC |
| 1739 | | cdram[0x930/2] = 0x0000; // ZERO |
| 1740 | | cdram[0x932/2] = (cdic_regs.time >> 24) & 0x000000ff; // AMIN |
| 1741 | | cdram[0x934/2] = (cdic_regs.time >> 16) & 0x000000ff; // ASEC |
| 1742 | | cdram[0x936/2] = (cdic_regs.time >> 8) & 0x0000007f; // AFRAC |
| 1743 | | cdram[0x938/2] = 0x0000; // CRC1 |
| 1744 | | cdram[0x93a/2] = 0x0000; // CRC2 |
| 1748 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x924/2] = 0x0041; // CTRL |
| 1749 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x926/2] = 0x0001; // TRACK |
| 1750 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x928/2] = 0x0000; // INDEX |
| 1751 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x92a/2] = (cdic_regs.time >> 24) & 0x000000ff; // MIN |
| 1752 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x92c/2] = (cdic_regs.time >> 16) & 0x000000ff; // SEC |
| 1753 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x92e/2] = (cdic_regs.time >> 8) & 0x0000007f; // FRAC |
| 1754 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x930/2] = 0x0000; // ZERO |
| 1755 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x932/2] = (cdic_regs.time >> 24) & 0x000000ff; // AMIN |
| 1756 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x934/2] = (cdic_regs.time >> 16) & 0x000000ff; // ASEC |
| 1757 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x936/2] = (cdic_regs.time >> 8) & 0x0000007f; // AFRAC |
| 1758 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x938/2] = 0x0000; // CRC1 |
| 1759 | cdram[(cdic_regs.data_buffer & 5) * (0xa00/2) + 0x93a/2] = 0x0000; // CRC2 |
| 1745 | 1760 | |
| 1746 | 1761 | cdic_regs.time = next_msf << 8; |
| 1747 | 1762 | |
| r6232 | r6233 | |
| 2478 | 2493 | #define MCD212_RC_OP 0xf00000 // Operation |
| 2479 | 2494 | #define MCD212_RC_OP_SHIFT 20 |
| 2480 | 2495 | |
| 2496 | #define MCD212_CSR1W_ST 0x0002 // Standard |
| 2497 | #define MCD212_CSR1W_BE 0x0001 // Bus Error |
| 2498 | |
| 2481 | 2499 | #define MCD212_CSR2R_IT1 0x0004 // Interrupt 1 |
| 2482 | 2500 | #define MCD212_CSR2R_IT2 0x0002 // Interrupt 2 |
| 2483 | 2501 | #define MCD212_CSR2R_BE 0x0001 // Bus Error |
| r6232 | r6233 | |
| 2611 | 2629 | return 0; |
| 2612 | 2630 | } |
| 2613 | 2631 | |
| 2632 | static void mcd212_update_visible_area(running_machine *machine) |
| 2633 | { |
| 2634 | rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); |
| 2635 | attoseconds_t period = video_screen_get_frame_period(machine->primary_screen).attoseconds; |
| 2636 | int width = 0; |
| 2637 | |
| 2638 | if((mcd212.channel[0].dcr & (MCD212_DCR_CF | MCD212_DCR_FD)) && (mcd212.channel[0].csrw & MCD212_CSR1W_ST)) |
| 2639 | { |
| 2640 | width = 360; |
| 2641 | } |
| 2642 | else |
| 2643 | { |
| 2644 | width = 384; |
| 2645 | } |
| 2646 | |
| 2647 | visarea.max_x = width-1; |
| 2648 | |
| 2649 | video_screen_configure(machine->primary_screen, width, 262, &visarea, period); |
| 2650 | } |
| 2651 | |
| 2614 | 2652 | static WRITE16_HANDLER(mcd212_w) |
| 2615 | 2653 | { |
| 2616 | 2654 | switch(offset) |
| r6232 | r6233 | |
| 2619 | 2657 | case 0x10/2: |
| 2620 | 2658 | verboselog(space->machine, 2, "mcd212_w: Status Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, data, mem_mask); |
| 2621 | 2659 | COMBINE_DATA(&mcd212.channel[1 - (offset / 8)].csrw); |
| 2660 | mcd212_update_visible_area(space->machine); |
| 2622 | 2661 | break; |
| 2623 | 2662 | case 0x02/2: |
| 2624 | 2663 | case 0x12/2: |
| 2625 | 2664 | verboselog(space->machine, 2, "mcd212_w: Display Command Register %d: %04x & %04x\n", (1 - (offset / 8)) + 1, data, mem_mask); |
| 2626 | 2665 | COMBINE_DATA(&mcd212.channel[1 - (offset / 8)].dcr); |
| 2666 | mcd212_update_visible_area(space->machine); |
| 2627 | 2667 | break; |
| 2628 | 2668 | case 0x04/2: |
| 2629 | 2669 | case 0x14/2: |
| r6232 | r6233 | |
| 3328 | 3368 | } |
| 3329 | 3369 | } |
| 3330 | 3370 | |
| 3371 | static int mcd212_get_screen_width(running_machine *machine) |
| 3372 | { |
| 3373 | if((mcd212.channel[0].dcr & (MCD212_DCR_CF | MCD212_DCR_FD)) && (mcd212.channel[0].csrw & MCD212_CSR1W_ST)) |
| 3374 | { |
| 3375 | return 720; |
| 3376 | } |
| 3377 | return 768; |
| 3378 | } |
| 3379 | |
| 3331 | 3380 | static void mcd212_process_vsr(running_machine *machine, int channel, UINT8 *pixels_r, UINT8 *pixels_g, UINT8 *pixels_b) |
| 3332 | 3381 | { |
| 3333 | 3382 | UINT8 *data = channel ? (UINT8*)planeb : (UINT8*)planea; |
| r6232 | r6233 | |
| 3343 | 3392 | UINT8 mosaic_enable = ((mcd212.channel[channel].ddr & MCD212_DDR_FT) == MCD212_DDR_FT_MOSAIC); |
| 3344 | 3393 | UINT8 mosaic_factor = 1 << (((mcd212.channel[channel].ddr & MCD212_DDR_MT) >> MCD212_DDR_MT_SHIFT) + 1); |
| 3345 | 3394 | int mosaic_index = 0; |
| 3395 | int width = mcd212_get_screen_width(machine); |
| 3346 | 3396 | |
| 3347 | 3397 | //printf( "vsr before: %08x: ", vsr ); |
| 3348 | 3398 | //fflush(stdout); |
| 3349 | 3399 | |
| 3350 | 3400 | if(!icm || !vsr) |
| 3351 | 3401 | { |
| 3352 | | memset(pixels_r, 0x10, 768); |
| 3353 | | memset(pixels_g, 0x10, 768); |
| 3354 | | memset(pixels_b, 0x10, 768); |
| 3402 | memset(pixels_r, 0x10, width); |
| 3403 | memset(pixels_g, 0x10, width); |
| 3404 | memset(pixels_b, 0x10, width); |
| 3355 | 3405 | return; |
| 3356 | 3406 | } |
| 3357 | 3407 | |
| r6232 | r6233 | |
| 3393 | 3443 | bY = bU = bV = 0x80; |
| 3394 | 3444 | break; |
| 3395 | 3445 | } |
| 3396 | | for(; x < 768; x += 2) |
| 3446 | for(; x < width; x += 2) |
| 3397 | 3447 | { |
| 3398 | 3448 | BYTE68K b0 = byte; |
| 3399 | 3449 | BYTE68K bU1 = bU + mcd212_abDeltaUV[b0]; |
| r6232 | r6233 | |
| 3470 | 3520 | } |
| 3471 | 3521 | else if(icm == 1 || icm == 3 || icm == 4) |
| 3472 | 3522 | { |
| 3473 | | for(; x < 768; x += 2) |
| 3523 | for(; x < width; x += 2) |
| 3474 | 3524 | { |
| 3475 | 3525 | UINT8 clut_entry = BYTE_TO_CLUT(channel, icm, byte); |
| 3476 | 3526 | pixels_r[x + 0] = clut_r[clut_entry]; |
| r6232 | r6233 | |
| 3499 | 3549 | } |
| 3500 | 3550 | else if(icm == 11) |
| 3501 | 3551 | { |
| 3502 | | for(; x < 768; x += 2) |
| 3552 | for(; x < width; x += 2) |
| 3503 | 3553 | { |
| 3504 | 3554 | UINT8 even_entry = BYTE_TO_CLUT(channel, icm, byte >> 4); |
| 3505 | 3555 | UINT8 odd_entry = BYTE_TO_CLUT(channel, icm, byte); |
| r6232 | r6233 | |
| 3535 | 3585 | } |
| 3536 | 3586 | else |
| 3537 | 3587 | { |
| 3538 | | for(; x < 768; x++) |
| 3588 | for(; x < width; x++) |
| 3539 | 3589 | { |
| 3540 | 3590 | pixels_r[x] = 0x10; |
| 3541 | 3591 | pixels_g[x] = 0x10; |
| r6232 | r6233 | |
| 3564 | 3614 | UINT8 g = clut_g[clut_entry]; |
| 3565 | 3615 | UINT8 b = clut_b[clut_entry]; |
| 3566 | 3616 | // Go to the end of the line |
| 3567 | | for(; x < 768; x++) |
| 3617 | for(; x < width; x++) |
| 3568 | 3618 | { |
| 3569 | 3619 | pixels_r[x] = r; |
| 3570 | 3620 | pixels_g[x] = g; |
| r6232 | r6233 | |
| 3584 | 3634 | UINT8 r = clut_r[clut_entry]; |
| 3585 | 3635 | UINT8 g = clut_g[clut_entry]; |
| 3586 | 3636 | UINT8 b = clut_b[clut_entry]; |
| 3587 | | for(; x < end && x < 768; x++) |
| 3637 | for(; x < end && x < width; x++) |
| 3588 | 3638 | { |
| 3589 | 3639 | pixels_r[x] = r; |
| 3590 | 3640 | pixels_g[x] = g; |
| r6232 | r6233 | |
| 3594 | 3644 | pixels_g[x] = g; |
| 3595 | 3645 | pixels_b[x] = b; |
| 3596 | 3646 | } |
| 3597 | | if(x >= 768) |
| 3647 | if(x >= width) |
| 3598 | 3648 | { |
| 3599 | 3649 | done = 1; |
| 3600 | 3650 | mcd212_set_vsr(channel, vsr); |
| r6232 | r6233 | |
| 3613 | 3663 | pixels_g[x] = clut_g[clut_entry]; |
| 3614 | 3664 | pixels_b[x] = clut_b[clut_entry]; |
| 3615 | 3665 | x++; |
| 3616 | | if(x >= 768) |
| 3666 | if(x >= width) |
| 3617 | 3667 | { |
| 3618 | 3668 | done = 1; |
| 3619 | 3669 | mcd212_set_vsr(channel, vsr); |