Previous 15994 Revisions Next

r14581 Thursday 23rd February, 2012 at 00:42:23 UTC by MooglyGuy
[N64] Don't flush the RSP DRC cache on DMA. Fixes Mario 64 and others. [Ryan Holtz]
[src/mame/machine]n64.c

src/mame/machine/n64.c
r14580r14581
266266         break;
267267   }
268268
269   //printf("mi_reg_r %08x = %08x\n", offset * 4, ret);
269   //printf("mi_reg_r %08x = %08x\n", offset * 4, ret); fflush(stdout);
270270   return ret;
271271}
272272
273273WRITE32_MEMBER( n64_periphs::mi_reg_w )
274274{
275   //printf("mi_reg_w %08x %08x %08x\n", offset * 4, data, mem_mask);
275   //printf("mi_reg_w %08x %08x %08x\n", offset * 4, data, mem_mask); fflush(stdout);
276276   switch (offset)
277277   {
278278      case 0x00/4:      // MI_INIT_MODE_REG
r14580r14581
363363{
364364   if (mi_intr_mask & mi_interrupt)
365365   {
366      //printf("Asserting IRQ, %02x : %02x\n", mi_intr_mask, mi_interrupt);
366      //printf("Asserting IRQ, %02x : %02x\n", mi_intr_mask, mi_interrupt); fflush(stdout);
367367      cputag_set_input_line(machine(), "maincpu", INPUT_LINE_IRQ0, ASSERT_LINE);
368368   }
369369   else
370370   {
371      //printf("Deasserting IRQ, %02x : %02x\n", mi_intr_mask, mi_interrupt);
371      //printf("Deasserting IRQ, %02x : %02x\n", mi_intr_mask, mi_interrupt); fflush(stdout);
372372      cputag_set_input_line(machine(), "maincpu", INPUT_LINE_IRQ0, CLEAR_LINE);
373373   }
374374}
r14580r14581
465465
466466READ32_MEMBER( n64_periphs::rdram_reg_r )
467467{
468   //printf("rdram_reg_r %08x = %08x\n", offset * 4, rdram_regs[offset]);
468   //printf("rdram_reg_r %08x = %08x\n", offset * 4, rdram_regs[offset]); fflush(stdout);
469469   if(offset > 0x24/4)
470470   {
471471      logerror("rdram_reg_r: %08X, %08X at %08X\n", offset, mem_mask, cpu_get_pc(maincpu));
r14580r14581
476476
477477WRITE32_MEMBER( n64_periphs::rdram_reg_w )
478478{
479   //printf("rdram_reg_w %08x %08x %08x\n", offset * 4, data, mem_mask);
479   //printf("rdram_reg_w %08x %08x %08x\n", offset * 4, data, mem_mask); fflush(stdout);
480480   if(offset > 0x24/4)
481481   {
482482      logerror("rdram_reg_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, cpu_get_pc(maincpu));
r14580r14581
496496        length = (length + 7) & ~7;
497497   }
498498
499   //printf("Length %08x Skip %08x Count %08x\n", length, sp_dma_skip, sp_dma_count);
499   //printf("Length %08x Skip %08x Count %08x\n", length, sp_dma_skip, sp_dma_count); fflush(stdout);
500500   if (sp_mem_addr & 0x3)
501501   {
502502        sp_mem_addr = sp_mem_addr & ~3;
r14580r14581
517517
518518   if(direction == 0)// RDRAM -> I/DMEM
519519   {
520      UINT32 imem_touched = 0;
521520        for(int c = 0; c <= sp_dma_count; c++)
522521        {
523522            UINT32 src = (sp_dram_addr & 0x007fffff) >> 2;
r14580r14581
526525            for(int i = 0; i < length / 4; i++)
527526            {
528527            sp_mem[(dst + i) >> 10][(dst + i) & 0x3ff] = rdram[src + i];
529            imem_touched |= (dst + i) >> 10;
530528            }
531529
532530            sp_mem_addr += length;
r14580r14581
534532
535533            sp_mem_addr += sp_dma_skip;
536534        }
537        if(imem_touched)
538        {
539         rspdrc_flush_drc_cache(machine().device("rsp"));
540      }
541535   }
542536   else               // I/DMEM -> RDRAM
543537   {
r14580r14581
682676            break;
683677   }
684678
685   //printf("%08x sp_reg_r %08x = %08x\n", (UINT32)cpu_get_reg(maincpu, MIPS3_PC), offset * 4, ret);
679   //printf("%08x sp_reg_r %08x = %08x\n", (UINT32)cpu_get_reg(maincpu, MIPS3_PC), offset * 4, ret); fflush(stdout);
686680   return ret;
687681}
688682
r14580r14581
693687
694688void n64_periphs::sp_reg_w(UINT32 offset, UINT32 data, UINT32 mem_mask)
695689{
696   //printf("%08x sp_reg_w %08x %08x %08x\n", (UINT32)cpu_get_reg(maincpu, MIPS3_PC), offset * 4, data, mem_mask);
690   //printf("%08x sp_reg_w %08x %08x %08x\n", (UINT32)cpu_get_reg(maincpu, MIPS3_PC), offset * 4, data, mem_mask); fflush(stdout);
697691
698692   if ((offset & 0x10000) == 0)
699693   {
r14580r14581
949943         break;
950944   }
951945
952   //printf("%08x dp_reg_r %08x = %08x\n", (UINT32)cpu_get_reg(device->machine().device("rsp"), RSP_PC), offset, ret);
946   //printf("%08x dp_reg_r %08x = %08x\n", (UINT32)cpu_get_reg(device->machine().device("rsp"), RSP_PC), offset, ret); fflush(stdout);
953947   return ret;
954948}
955949
r14580r14581
958952   n64_state *state = device->machine().driver_data<n64_state>();
959953   n64_periphs *periphs = device->machine().device<n64_periphs>("rcp");
960954
961   //printf("%08x dp_reg_w %08x %08x %08x\n", (UINT32)cpu_get_reg(device->machine().device("rsp"), RSP_PC), offset, data, mem_mask);
955   //printf("%08x dp_reg_w %08x %08x %08x\n", (UINT32)cpu_get_reg(device->machine().device("rsp"), RSP_PC), offset, data, mem_mask); fflush(stdout);
962956   switch (offset)
963957   {
964958      case 0x00/4:      // DP_START_REG
r14580r14581
14381432       cart_addr &= ((machine().region("user2")->bytes() >> 1) - 1);
14391433   }
14401434
1441   //printf("%08x Cart, %08x Dram\n", cart_addr << 1, dram_addr << 1);
1435   //printf("%08x Cart, %08x Dram\n", cart_addr << 1, dram_addr << 1); fflush(stdout);
14421436
14431437   if(pi_dma_dir == 1)
14441438   {
r14580r14581
15471541
15481542WRITE32_MEMBER( n64_periphs::pi_reg_w )
15491543{
1550   //printf("pi_reg_w %08x %08x %08x\n", offset * 4, data, mem_mask);
1544   //printf("pi_reg_w %08x %08x %08x\n", offset * 4, data, mem_mask); fflush(stdout);
15511545   switch (offset)
15521546   {
15531547      case 0x00/4:      // PI_DRAM_ADDR_REG
r14580r14581
15881582         if (pi_first_dma)
15891583         {
15901584            // TODO: CIC-6105 has different address...
1591            //mem_map->write_dword(0x00000318, 0x800000);
1585            mem_map->write_dword(0x00000318, 0x800000);
15921586            mem_map->write_dword(0x000003f0, 0x800000);
15931587            pi_first_dma = 0;
15941588         }
r14580r14581
19561950
19571951void n64_periphs::handle_pif()
19581952{
1959   /*printf("Before:\n");
1953   /*printf("Before:\n"); fflush(stdout);
19601954   for(int i = 0; i < 0x40; i++)
19611955    {
19621956        printf("%02x ", pif_cmd[i]);
19631957        if((i & 0xf) == 0xf)
19641958        {
1965            printf("\n");
1959            printf("\n"); fflush(stdout);
19661960        }
19671961    }*/
19681962   if(pif_cmd[0x3f] == 0x1)      // only handle the command if the last byte is 1
r14580r14581
20352029      //pif_ram[0x3f] = 0;
20362030   }
20372031
2038   /*printf("After:\n");
2032   /*printf("After:\n"); fflush(stdout);
20392033    for(int i = 0; i < 0x40; i++)
20402034    {
2041        printf("%02x ", pif_ram[i]);
2035        printf("%02x ", pif_ram[i]); fflush(stdout);
20422036        if((i & 0xf) == 0xf)
20432037        {
2044            printf("\n");
2038            printf("\n"); fflush(stdout);
20452039        }
20462040    }*/
20472041}
r14580r14581
21042098         ret = si_status;
21052099   }
21062100
2107   //printf("si_reg_r %08x = %08x\n", offset * 4, ret);
2101   //printf("si_reg_r %08x = %08x\n", offset * 4, ret); fflush(stdout);
21082102   return ret;
21092103}
21102104
21112105WRITE32_MEMBER( n64_periphs::si_reg_w )
21122106{
2113   //printf("si_reg_w %08x %08x %08x\n", offset * 4, data, mem_mask);
2107   //printf("si_reg_w %08x %08x %08x\n", offset * 4, data, mem_mask); fflush(stdout);
21142108   switch (offset)
21152109   {
21162110      case 0x00/4:      // SI_DRAM_ADDR_REG

Previous 15994 Revisions Next


© 1998-2018 The MESS Team