| Previous | 15994 Revisions | Next |
| r14572 Wednesday 22nd February, 2012 at 15:35:03 UTC by MooglyGuy |
|---|
| [N64] Miscellaneous machine fixes, gets Conker's Bad Fur Day to boot through its legal screens with interpreter MIPS. [Ryan Holtz] - Increase the amount of time consumed by PI DMA, makes certain RSP microcodes that test DMA speed land in the correct window. - Force the main CPU to yield when the RSP reads its atomic semaphore. - Force the RSP to yield when PI DMA completes. - Flush the RSP DRC cache when touching IMEM with SP DMA. (nw) Last N64 update before I move tomorrow! |
| [src/mame/machine] | n64.c |
| r14571 | r14572 | |
|---|---|---|
| 76 | 76 | rspcpu = machine().device("rsp"); |
| 77 | 77 | mem_map = maincpu->memory().space(AS_PROGRAM); |
| 78 | 78 | |
| 79 | mi_version = 0x0 | |
| 79 | mi_version = 0x01010101; | |
| 80 | 80 | mi_interrupt = 0; |
| 81 | 81 | mi_intr_mask = 0; |
| 82 | 82 | mi_mode = 0; |
| r14571 | r14572 | |
| 144 | 144 | dd_seq_ctrl_reg = 0; |
| 145 | 145 | dd_int = 0; |
| 146 | 146 | |
| 147 | memset(ri_regs, 0, sizeof(ri_regs)); | |
| 148 | ||
| 149 | //ri_regs[3] = 1; | |
| 147 | 150 | memset(pif_ram, 0, sizeof(pif_ram)); |
| 148 | 151 | memset(pif_cmd, 0, sizeof(pif_cmd)); |
| 149 | 152 | si_dram_addr = 0; |
| r14571 | r14572 | |
| 514 | 517 | |
| 515 | 518 | if(direction == 0)// RDRAM -> I/DMEM |
| 516 | 519 | { |
| 520 | UINT32 imem_touched = 0; | |
| 517 | 521 | for(int c = 0; c <= sp_dma_count; c++) |
| 518 | 522 | { |
| 519 | 523 | UINT32 src = (sp_dram_addr & 0x007fffff) >> 2; |
| r14571 | r14572 | |
| 522 | 526 | for(int i = 0; i < length / 4; i++) |
| 523 | 527 | { |
| 524 | 528 | sp_mem[(dst + i) >> 10][(dst + i) & 0x3ff] = rdram[src + i]; |
| 529 | imem_touched |= (dst + i) >> 10; | |
| 525 | 530 | } |
| 526 | 531 | |
| 527 | 532 | sp_mem_addr += length; |
| r14571 | r14572 | |
| 529 | 534 | |
| 530 | 535 | sp_mem_addr += sp_dma_skip; |
| 531 | 536 | } |
| 537 | if(imem_touched) | |
| 538 | { | |
| 539 | rspdrc_flush_drc_cache(machine().device("rsp")); | |
| 540 | } | |
| 532 | 541 | } |
| 533 | 542 | else // I/DMEM -> RDRAM |
| 534 | 543 | { |
| r14571 | r14572 | |
| 608 | 617 | |
| 609 | 618 | case 0x1c/4: // SP_SEMAPHORE_REG |
| 610 | 619 | //machine().scheduler().boost_interleave(attotime::from_usec(1), attotime::from_usec(1)); |
| 620 | device_yield(machine().device("maincpu")); | |
| 611 | 621 | if( sp_semaphore ) |
| 612 | 622 | { |
| 613 | 623 | ret = 1; |
| 614 | 624 | } |
| 615 | 625 | else |
| 616 | 626 | { |
| 627 | //printf("Semaphore is now acquired, returning 0\n"); | |
| 617 | 628 | sp_semaphore = 1; |
| 618 | 629 | ret = 0; |
| 619 | 630 | } |
| r14571 | r14572 | |
| 720 | 731 | { |
| 721 | 732 | device_set_input_line(rspcpu, INPUT_LINE_HALT, CLEAR_LINE); |
| 722 | 733 | newstatus &= ~RSP_STATUS_HALT; |
| 734 | //printf("***SP HALT CLR***\n"); fflush(stdout); | |
| 723 | 735 | } |
| 724 | 736 | if (data & 0x00000002) // set halt |
| 725 | 737 | { |
| 726 | 738 | device_set_input_line(rspcpu, INPUT_LINE_HALT, ASSERT_LINE); |
| 727 | 739 | newstatus |= RSP_STATUS_HALT; |
| 740 | //printf("***SP HALT SET***\n"); fflush(stdout); | |
| 728 | 741 | } |
| 729 | 742 | if (data & 0x00000004) |
| 730 | 743 | { |
| 731 | 744 | newstatus &= ~RSP_STATUS_BROKE; |
| 745 | //printf("***SP BROKE CLR***\n"); fflush(stdout); | |
| 732 | 746 | } |
| 733 | 747 | if (data & 0x00000008) // clear interrupt |
| 734 | 748 | { |
| 749 | //printf("***SP INT CLR***\n"); fflush(stdout); | |
| 735 | 750 | clear_rcp_interrupt(SP_INTERRUPT); |
| 736 | 751 | } |
| 737 | 752 | if (data & 0x00000010) // set interrupt |
| 738 | 753 | { |
| 754 | //printf("***SP INT SET***\n"); fflush(stdout); | |
| 739 | 755 | signal_rcp_interrupt(SP_INTERRUPT); |
| 740 | 756 | } |
| 741 | 757 | if (data & 0x00000020) |
| 742 | 758 | { |
| 743 | 759 | newstatus &= ~RSP_STATUS_SSTEP; |
| 760 | //printf("***SP SSTEP CLR***\n"); fflush(stdout); | |
| 744 | 761 | } |
| 745 | 762 | if (data & 0x00000040) |
| 746 | 763 | { |
| 747 | 764 | newstatus |= RSP_STATUS_SSTEP; // set single step |
| 765 | //printf("***SP SSTEP SET***\n"); fflush(stdout); | |
| 748 | 766 | if(!(oldstatus & (RSP_STATUS_BROKE | RSP_STATUS_HALT))) |
| 749 | 767 | { |
| 750 | 768 | cpu_set_reg(rspcpu, RSP_STEPCNT, 1 ); |
| 751 | device_yield(machine().device(" | |
| 769 | device_yield(machine().device("rs | |
| 752 | 770 | } |
| 753 | 771 | } |
| 754 | 772 | if (data & 0x00000080) |
| 755 | 773 | { |
| 756 | 774 | newstatus &= ~RSP_STATUS_INTR_BREAK; // clear interrupt on break |
| 775 | //printf("***SP INTRBRK CLR***\n"); fflush(stdout); | |
| 757 | 776 | } |
| 758 | 777 | if (data & 0x00000100) |
| 759 | 778 | { |
| 760 | 779 | newstatus |= RSP_STATUS_INTR_BREAK; // set interrupt on break |
| 780 | //printf("***SP INTRBRK SET***\n"); fflush(stdout); | |
| 761 | 781 | } |
| 762 | 782 | if (data & 0x00000200) |
| 763 | 783 | { |
| 764 | 784 | newstatus &= ~RSP_STATUS_SIGNAL0; // clear signal 0 |
| 785 | //printf("***SP YIELD CLR***\n"); fflush(stdout); | |
| 765 | 786 | } |
| 766 | 787 | if (data & 0x00000400) |
| 767 | 788 | { |
| 768 | 789 | newstatus |= RSP_STATUS_SIGNAL0; // set signal 0 |
| 790 | //printf("***SP YIELD SET***\n"); fflush(stdout); | |
| 769 | 791 | } |
| 770 | 792 | if (data & 0x00000800) |
| 771 | 793 | { |
| 772 | 794 | newstatus &= ~RSP_STATUS_SIGNAL1; // clear signal 1 |
| 795 | //printf("***SP YIELDED CLR***\n"); fflush(stdout); | |
| 773 | 796 | } |
| 774 | 797 | if (data & 0x00001000) |
| 775 | 798 | { |
| 776 | 799 | newstatus |= RSP_STATUS_SIGNAL1; // set signal 1 |
| 800 | //printf("***SP YIELDED SET***\n"); fflush(stdout); | |
| 777 | 801 | } |
| 778 | 802 | if (data & 0x00002000) |
| 779 | 803 | { |
| 780 | 804 | newstatus &= ~RSP_STATUS_SIGNAL2 ; // clear signal 2 |
| 805 | //printf("***SP TASKDONE CLR***\n"); fflush(stdout); | |
| 781 | 806 | } |
| 782 | 807 | if (data & 0x00004000) |
| 783 | 808 | { |
| 784 | 809 | newstatus |= RSP_STATUS_SIGNAL2; // set signal 2 |
| 810 | //printf("***SP TASKDONE SET***\n"); fflush(stdout); | |
| 785 | 811 | } |
| 786 | 812 | if (data & 0x00008000) |
| 787 | 813 | { |
| 788 | 814 | newstatus &= ~RSP_STATUS_SIGNAL3; // clear signal 3 |
| 815 | //printf("***SP SIG3 CLR***\n"); fflush(stdout); | |
| 789 | 816 | } |
| 790 | 817 | if (data & 0x00010000) |
| 791 | 818 | { |
| 792 | 819 | newstatus |= RSP_STATUS_SIGNAL3; // set signal 3 |
| 820 | //printf("***SP SIG3 SET***\n"); fflush(stdout); | |
| 793 | 821 | } |
| 794 | 822 | if (data & 0x00020000) |
| 795 | 823 | { |
| 796 | 824 | newstatus &= ~RSP_STATUS_SIGNAL4; // clear signal 4 |
| 825 | //printf("***SP SIG4 CLR***\n"); fflush(stdout); | |
| 797 | 826 | } |
| 798 | 827 | if (data & 0x00040000) |
| 799 | 828 | { |
| 800 | 829 | newstatus |= RSP_STATUS_SIGNAL4; // set signal 4 |
| 830 | //printf("***SP SIG4 SET***\n"); fflush(stdout); | |
| 801 | 831 | } |
| 802 | 832 | if (data & 0x00080000) |
| 803 | 833 | { |
| 804 | 834 | newstatus &= ~RSP_STATUS_SIGNAL5; // clear signal 5 |
| 835 | //printf("***SP SIG5 CLR***\n"); fflush(stdout); | |
| 805 | 836 | } |
| 806 | 837 | if (data & 0x00100000) |
| 807 | 838 | { |
| 808 | 839 | newstatus |= RSP_STATUS_SIGNAL5; // set signal 5 |
| 840 | //printf("***SP SIG5 SET***\n"); fflush(stdout); | |
| 809 | 841 | } |
| 810 | 842 | if (data & 0x00200000) |
| 811 | 843 | { |
| 812 | 844 | newstatus &= ~RSP_STATUS_SIGNAL6; // clear signal 6 |
| 845 | //printf("***SP SIG6 CLR***\n"); fflush(stdout); | |
| 813 | 846 | } |
| 814 | 847 | if (data & 0x00400000) |
| 815 | 848 | { |
| 816 | 849 | newstatus |= RSP_STATUS_SIGNAL6; // set signal 6 |
| 850 | //printf("***SP SIG6 SET***\n"); fflush(stdout); | |
| 817 | 851 | } |
| 818 | 852 | if (data & 0x00800000) |
| 819 | 853 | { |
| 820 | 854 | newstatus &= ~RSP_STATUS_SIGNAL7; // clear signal 7 |
| 855 | //printf("***SP SIG7 CLR***\n"); fflush(stdout); | |
| 821 | 856 | } |
| 822 | 857 | if (data & 0x01000000) |
| 823 | 858 | { |
| 824 | 859 | newstatus |= RSP_STATUS_SIGNAL7; // set signal 7 |
| 860 | //printf("***SP SIG7 SET***\n"); fflush(stdout); | |
| 825 | 861 | } |
| 826 | 862 | cpu_set_reg(rspcpu, RSP_SR, newstatus); |
| 827 | 863 | break; |
| r14571 | r14572 | |
| 829 | 865 | |
| 830 | 866 | case 0x1c/4: // SP_SEMAPHORE_REG |
| 831 | 867 | //machine().scheduler().boost_interleave(attotime::from_usec(1), attotime::from_usec(1)); |
| 868 | //printf("Semaphore is being released\n"); | |
| 832 | 869 | if(data == 0) |
| 833 | 870 | { |
| 834 | 871 | sp_semaphore = 0; |
| r14571 | r14572 | |
| 1336 | 1373 | switch (offset) |
| 1337 | 1374 | { |
| 1338 | 1375 | case 0x00/4: // AI_DRAM_ADDR_REG |
| 1339 | ai_dram_addr = data & 0xfffff | |
| 1376 | ai_dram_addr = data & 0xfffff8; | |
| 1340 | 1377 | break; |
| 1341 | 1378 | |
| 1342 | 1379 | case 0x04/4: // AI_LEN_REG |
| r14571 | r14572 | |
| 1375 | 1412 | static TIMER_CALLBACK(pi_dma_callback) |
| 1376 | 1413 | { |
| 1377 | 1414 | machine.device<n64_periphs>("rcp")->pi_dma_tick(); |
| 1415 | device_yield(machine.device("rsp")); | |
| 1378 | 1416 | } |
| 1379 | 1417 | |
| 1380 | 1418 | void n64_periphs::pi_dma_tick() |
| r14571 | r14572 | |
| 1420 | 1458 | pi_cart_addr += dma_length; |
| 1421 | 1459 | pi_dram_addr += dma_length; |
| 1422 | 1460 | } |
| 1423 | ||
| 1424 | if (pi_first_dma) | |
| 1425 | { | |
| 1426 | // TODO: CIC-6105 has different address... | |
| 1427 | mem_map->write_dword(0x00000318, 0x400000); | |
| 1428 | mem_map->write_dword(0x000003f0, 0x800000); | |
| 1429 | pi_first_dma = 0; | |
| 1430 | } | |
| 1431 | 1461 | } |
| 1432 | 1462 | else |
| 1433 | 1463 | { |
| r14571 | r14572 | |
| 1538 | 1568 | pi_dma_dir = 0; |
| 1539 | 1569 | pi_status |= 1; |
| 1540 | 1570 | |
| 1541 | attotime dma_period = attotime::from_hz(93750000) * (pi_rd_len + 1) * | |
| 1571 | attotime dma_period = attotime::from_hz(93750000) * (int)((float)(pi_rd_len + 1) * 10.2f); | |
| 1542 | 1572 | //printf("want read dma in %d\n", (pi_rd_len + 1)); |
| 1543 | 1573 | pi_dma_timer->adjust(dma_period); |
| 1544 | 1574 | //pi_dma_tick(); |
| r14571 | r14572 | |
| 1551 | 1581 | pi_dma_dir = 1; |
| 1552 | 1582 | pi_status |= 1; |
| 1553 | 1583 | |
| 1554 | attotime dma_period = attotime::from_hz(93750000) * (pi_wr_len + 1) * | |
| 1584 | attotime dma_period = attotime::from_hz(93750000) * (int)((float)(pi_wr_len + 1) * 10.2f); | |
| 1555 | 1585 | //printf("want write dma in %d\n", (pi_wr_len + 1)); |
| 1556 | 1586 | pi_dma_timer->adjust(dma_period); |
| 1587 | ||
| 1588 | if (pi_first_dma) | |
| 1589 | { | |
| 1590 | // TODO: CIC-6105 has different address... | |
| 1591 | //mem_map->write_dword(0x00000318, 0x800000); | |
| 1592 | mem_map->write_dword(0x000003f0, 0x800000); | |
| 1593 | pi_first_dma = 0; | |
| 1594 | } | |
| 1595 | ||
| 1557 | 1596 | //pi_dma_tick(); |
| 1558 | 1597 | break; |
| 1559 | 1598 | } |
| Previous | 15994 Revisions | Next |