Previous 15994 Revisions Next

r7668 Tuesday 30th March, 2010 at 08:13:26 UTC by Fabio Priuli
[SNES] wip:
- fixed reserved memory address read not returning open_bus
- fixed a few add-on chip reads not returning open_bus
[src/emu/cpu/superfx]superfx.c superfx.h
[src/mame/machine]snes.c snes7110.c snesrtc.c snessdd1.c
[src/mess/machine]snescart.c

src/mame/machine/snes7110.c
r7667r7668
763763}
764764
765765static void spc7110_mmio_write(running_machine *machine, UINT32 addr, UINT8 data);
766static UINT8 spc7110_mmio_read(running_machine *machine, UINT32 addr);
766static UINT8 spc7110_mmio_read(const address_space *space, UINT32 addr);
767767static void spc7110_update_time(running_machine *machine, UINT8 offset);
768768
769769enum RTC_State
r7667r7668
10561056   }
10571057}
10581058
1059static UINT8 spc7110_mmio_read(running_machine *machine, UINT32 addr)
1059static UINT8 spc7110_mmio_read(const address_space *space, UINT32 addr)
10601060{
1061   running_machine *machine = space->machine;
10611062   UINT8 *ROM = memory_region(machine, "cart");
10621063
10631064   addr &= 0xffff;
r7667r7668
12391240      }
12401241   }
12411242
1242   return 0xff;
1243   return snes_open_bus_r(space, 0);
12431244}
12441245
12451246static void spc7110_mmio_write(running_machine *machine, UINT32 addr, UINT8 data)
r7667r7668
16281629   }
16291630}
16301631
1631static UINT8 spc7110_bank7_read(running_machine *machine, UINT32 offset)
1632static UINT8 spc7110_bank7_read(const address_space *space, UINT32 offset)
16321633{
1633   UINT8 *ROM = memory_region(machine, "cart");
1634   UINT8 *ROM = memory_region(space->machine, "cart");
16341635   UINT32 addr = offset & 0x0fffff;
16351636
16361637   switch (offset & 0xf00000)
r7667r7668
16441645   default:
16451646      break;
16461647   }
1647   return 0xff;
1648   return snes_open_bus_r(space, 0);
16481649}
src/mame/machine/snessdd1.c
r7667r7668
590590         return (snes_sdd1.mmc[3] >> 20) & 7;
591591   }
592592
593   return 0xff;
593   return snes_open_bus_r(space, 0);
594594}
595595
596596static void sdd1_mmio_write(const address_space *space, UINT32 addr, UINT8 data)
src/mame/machine/snesrtc.c
r7667r7668
109109   return (sum + 1) % 7; // 1900-01-01 was a Monday
110110}
111111
112static UINT8 srtc_read( running_machine *machine, UINT16 addr )
112static UINT8 srtc_read( const address_space *space, UINT16 addr )
113113{
114114   addr &= 0xffff;
115115
r7667r7668
122122
123123      if (rtc_state.index < 0)
124124      {
125         srtc_update_time(machine);
125         srtc_update_time(space->machine);
126126         rtc_state.index++;
127127         return 0x0f;
128128      }
r7667r7668
137137      }
138138   }
139139
140   return 0xff;
140   return snes_open_bus_r(space, 0);
141141}
142142
143143static void srtc_write( running_machine *machine, UINT16 addr, UINT8 data )
src/mame/machine/snes.c
r7667r7668
3838static void snes_dma(const address_space *space, UINT8 channels);
3939static void snes_hdma_init(const address_space *space);
4040static void snes_hdma(const address_space *space);
41static READ8_HANDLER(snes_open_bus_r);
4142
4243struct snes_cart_info snes_cart;
4344
r7667r7668
606607   {
607608      if (offset == 0x2800 || offset == 0x2801)
608609      {
609         return srtc_read(space->machine, offset);
610         return srtc_read(space, offset);
610611      }
611612   }
612613   else if (snes_has_addon_chip == HAS_SDD1)
r7667r7668
625626      UINT16 limit = (snes_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
626627      if (offset >= 0x4800 && offset <= limit)
627628      {
628         return spc7110_mmio_read(space->machine, offset);
629         return spc7110_mmio_read(space, offset);
629630      }
630631   }
631632
r7667r7668
16031604/* 0x000000 - 0x2fffff */
16041605READ8_HANDLER( snes_r_bank1 )
16051606{
1607   snes_state *state = (snes_state *)space->machine->driver_data;
16061608   UINT8 value = 0xff;
16071609   UINT16 address = offset & 0xffff;
16081610
r7667r7668
16121614      value = snes_r_io(space, address);
16131615   else if (address < 0x8000)
16141616   {
1615      if (snes_has_addon_chip == HAS_SUPERFX)
1616         value = snes_ram[0xf00000 + (address & 0x1fff)];   // here it should be 0xe00000 but there are mirroring issues
1617      if (snes_has_addon_chip == HAS_SUPERFX && state->superfx !=NULL)
1618      {
1619         if (superfx_access_ram(state->superfx))
1620            value = snes_ram[0xf00000 + (offset & 0x1fff)];   // here it should be 0xe00000 but there are mirroring issues
1621         else
1622            value = snes_open_bus_r(space, 0);
1623      }
16171624      else if (snes_has_addon_chip == HAS_OBC1)
16181625         value = obc1_read(space, offset);
16191626      else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000))
r7667r7668
16281635      else
16291636      {
16301637         logerror("snes_r_bank1: Unmapped external chip read: %04x\n", address);
1631         value = 0xff;                                 /* Reserved */
1638         value = snes_open_bus_r(space, 0);                        /* Reserved */
16321639      }
16331640   }
16341641   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
r7667r7668
16461653/* 0x300000 - 0x3fffff */
16471654READ8_HANDLER( snes_r_bank2 )
16481655{
1656   snes_state *state = (snes_state *)space->machine->driver_data;
16491657   UINT8 value = 0xff;
16501658   UINT16 address = offset & 0xffff;
16511659
r7667r7668
16551663      value = snes_r_io(space, address);
16561664   else if (address < 0x8000)                              /* SRAM for mode_21, Reserved othewise */
16571665   {
1658      if (snes_has_addon_chip == HAS_SUPERFX)
1659         value = snes_ram[0xf00000 + (address & 0x1fff)];   // here it should be 0xe00000 but there are mirroring issues
1666      if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
1667      {
1668         if (superfx_access_ram(state->superfx))
1669            value = snes_ram[0xf00000 + (offset & 0x1fff)];   // here it should be 0xe00000 but there are mirroring issues
1670         else
1671            value = snes_open_bus_r(space, 0);
1672      }
16601673      else if (snes_has_addon_chip == HAS_OBC1)
16611674         value = obc1_read (space, offset);
16621675      else if (snes_has_addon_chip == HAS_CX4)
r7667r7668
16751688      else
16761689      {
16771690         logerror( "snes_r_bank2: Unmapped external chip read: %04x\n", address );
1678         value = 0xff;
1691         value = snes_open_bus_r(space, 0);
16791692      }
16801693   }
16811694   /* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */
r7667r7668
16961709/* 0x400000 - 0x5fffff */
16971710READ8_HANDLER( snes_r_bank3 )
16981711{
1712   snes_state *state = (snes_state *)space->machine->driver_data;
16991713   UINT8 value = 0xff;
17001714   UINT16 address = offset & 0xffff;
17011715
1702   if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC))
1716   if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
17031717   {
1718      if (superfx_access_rom(state->superfx))
1719         value = snes_ram[0x400000 + offset];
1720      else
1721      {
1722         static const UINT8 sfx_data[16] = {
1723            0x00, 0x01, 0x00, 0x01, 0x04, 0x01, 0x00, 0x01,
1724            0x00, 0x01, 0x08, 0x01, 0x00, 0x01, 0x0c, 0x01,
1725         };
1726         return sfx_data[offset & 0x0f];
1727      }
1728   }
1729   else if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC))
1730   {
17041731      if (offset >= 0x100000 && offset < 0x110000)
1705         value = spc7110_mmio_read(space->machine, 0x4800);
1732         value = spc7110_mmio_read(space, 0x4800);
17061733   }
17071734   else if ((snes_cart.mode & 5) && !(snes_has_addon_chip == HAS_SUPERFX))   /* Mode 20 & 22 */
17081735   {
17091736      if ((address < 0x8000) && (snes_cart.mode == SNES_MODE_20))
1710         value = 0xff;                     /* Reserved */
1737         value = snes_open_bus_r(space, 0);                     /* Reserved */
17111738      else
17121739         value = snes_ram[0x400000 + offset];
17131740   }
r7667r7668
17201747/* 0x600000 - 0x6fffff */
17211748READ8_HANDLER( snes_r_bank4 )
17221749{
1750   snes_state *state = (snes_state *)space->machine->driver_data;
17231751   UINT8 value = 0xff;
17241752   UINT16 address = offset & 0xffff;
17251753
1726   if (snes_has_addon_chip == HAS_SUPERFX)
1727      value = snes_ram[0xe00000 + offset];
1754   if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
1755   {
1756      if (superfx_access_ram(state->superfx))
1757         value = snes_ram[0xe00000 + offset];
1758      else
1759         value = snes_open_bus_r(space, 0);
1760   }
17281761   else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000)
17291762      value = st010_read(address);
17301763   else if (snes_cart.mode & 5)                     /* Mode 20 & 22 */
r7667r7668
17371770      else
17381771      {
17391772         logerror("snes_r_bank4: Unmapped external chip read: %04x\n", address);
1740         value = 0xff;                     /* Reserved */
1773         value = snes_open_bus_r(space, 0);                     /* Reserved */
17411774      }
17421775   }
17431776   else if (snes_cart.mode & 0x0a)               /* Mode 21 & 25 */
r7667r7668
17491782/* 0x700000 - 0x7dffff */
17501783READ8_HANDLER( snes_r_bank5 )
17511784{
1785   snes_state *state = (snes_state *)space->machine->driver_data;
17521786   UINT8 value;
17531787   UINT16 address = offset & 0xffff;
17541788
1755   if (snes_has_addon_chip == HAS_SUPERFX)
1756      value = snes_ram[0xf00000 + offset];
1789   if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
1790   {
1791      if (superfx_access_ram(state->superfx))
1792         value = snes_ram[0xf00000 + offset];
1793      else
1794         value = snes_open_bus_r(space, 0);
1795   }
17571796   else if ((snes_cart.mode & 5) && (address < 0x8000))      /* Mode 20 & 22 */
17581797   {
17591798      if (snes_cart.sram > 0)
r7667r7668
17641803      else
17651804      {
17661805         logerror("snes_r_bank5: Unmapped external chip read: %04x\n", address);
1767         value = 0xff;                        /* Reserved */
1806         value = snes_open_bus_r(space, 0);                        /* Reserved */
17681807      }
17691808   }
17701809   else
r7667r7668
18001839         else                  /* Area 0x6000-0x8000 with offset < 0x300000 is reserved */
18011840         {
18021841            logerror("snes_r_bank6: Unmapped external chip read: %04x\n", address);
1803            value = 0xff;
1842            value = snes_open_bus_r(space, 0);
18041843         }
18051844      }
18061845   }
r7667r7668
18211860/* 0xc00000 - 0xffffff */
18221861READ8_HANDLER( snes_r_bank7 )
18231862{
1863   snes_state *state = (snes_state *)space->machine->driver_data;
18241864   UINT8 value = 0;
18251865   UINT16 address = offset & 0xffff;
18261866
1827   if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) && offset >= 0x100000)
1828      value = spc7110_bank7_read(space->machine, offset);
1867   if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
1868   {
1869      if (offset < 0x200000)   // ROM
1870      {
1871         if (superfx_access_rom(state->superfx))
1872            value = snes_ram[0xc00000 + offset];
1873         else
1874         {
1875            static const UINT8 sfx_data[16] = {
1876               0x00, 0x01, 0x00, 0x01, 0x04, 0x01, 0x00, 0x01,
1877               0x00, 0x01, 0x08, 0x01, 0x00, 0x01, 0x0c, 0x01,
1878            };
1879            return sfx_data[offset & 0x0f];
1880         }
1881      }
1882      else   // RAM
1883      {
1884         offset -= 0x200000;
1885         if (superfx_access_ram(state->superfx))
1886            value = snes_ram[0xe00000 + offset];
1887         else
1888            value = snes_open_bus_r(space, 0);
1889      }
1890   }
1891   else if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) && offset >= 0x100000)
1892      value = spc7110_bank7_read(space, offset);
18291893   else if (snes_has_addon_chip == HAS_SDD1)
18301894      value = sdd1_read(space->machine, offset);
18311895   else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000)
r7667r7668
18561920   else if (address < 0x8000)
18571921   {
18581922      if (snes_has_addon_chip == HAS_SUPERFX)
1859         snes_ram[0xf00000 + (address & 0x1fff)] = data;   // here it should 0xe00000 but there are mirroring issues
1923         snes_ram[0xf00000 + (offset & 0x1fff)] = data;   // here it should be 0xe00000 but there are mirroring issues
18601924      else if (snes_has_addon_chip == HAS_OBC1)
18611925         obc1_write(space, offset, data);
18621926      else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000))
r7667r7668
18981962   else if (address < 0x8000)                  /* SRAM for mode_21, Reserved othewise */
18991963   {
19001964      if (snes_has_addon_chip == HAS_SUPERFX)
1901         snes_ram[0xf00000 + (address & 0x1fff)] = data;   // here it should be 0xe00000 but there are mirroring issues
1965         snes_ram[0xf00000 + (offset & 0x1fff)] = data;   // here it should be 0xe00000 but there are mirroring issues
19021966      else if (snes_has_addon_chip == HAS_OBC1)
19031967         obc1_write(space, offset, data);
19041968      else if (snes_has_addon_chip == HAS_CX4)
r7667r7668
20322096   if (snes_has_addon_chip == HAS_SUPERFX)
20332097   {
20342098      if (offset >= 0x200000)
2035         snes_ram[0xc00000 + offset] = data;      // SFX RAM
2099      {
2100         offset -= 0x200000;
2101         snes_ram[0xe00000 + offset] = data;      // SFX RAM
2102      }
20362103      else
20372104         logerror("Attempt to write to ROM address: %X\n", offset + 0xc00000);
20382105   }
r7667r7668
28302897READ8_HANDLER( superfx_r_bank3 )
28312898{
28322899   /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES
2833   has only access to 0x600000-0x7d00000 (because there is WRAM after that), hence we directly use the mirror
2900   has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror
28342901   as the place where to write & read SFX RAM. SNES handlers have been setup accordingly. */
28352902   //printf("superfx_r_bank3: %08x = %02x\n", offset, snes_ram[0xe00000 + offset]);
28362903   return snes_ram[0xe00000 + offset];
r7667r7668
28502917
28512918WRITE8_HANDLER( superfx_w_bank3 )
28522919{
2853   /* IMPORTANT: SFX RAM sits in 0x600000-0x7f00000, and it's mirrored in 0xe00000-0xff00000. However, SNES
2854   has only access to 0x600000-0x7d00000 (because there is WRAM after that), hence we directly use the mirror
2920   /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES
2921   has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror
28552922   as the place where to write & read SFX RAM. SNES handlers have been setup accordingly. */
28562923   //printf("superfx_w_bank3: %08x = %02x\n", offset, data);
28572924   snes_ram[0xe00000 + offset] = data;
src/emu/cpu/superfx/superfx.h
r7667r7668
9999UINT8 superfx_mmio_read(running_device *cpu, UINT32 addr);
100100void superfx_mmio_write(running_device *cpu, UINT32 addr, UINT8 data);
101101void superfx_add_clocks(running_device *cpu, INT32 clocks);
102int superfx_access_ram(running_device *cpu);
103int superfx_access_rom(running_device *cpu);
102104
103105#endif /* __SUPERFX_H__ */
src/emu/cpu/superfx/superfx.c
r7667r7668
472472
473473/*****************************************************************************/
474474
475/* reads to SuperFX RAM only happen if this returns 1 */
476int superfx_access_ram(running_device *cpu)
477{
478   superfx_state *cpustate = get_safe_token(cpu);
479
480   if ((cpustate->sfr & SUPERFX_SFR_G) && (cpustate->scmr & SUPERFX_SCMR_RAN))
481      return 0;
482
483   return 1;
484}
485
486/* reads to SuperFX ROM only happen if this returns 1 */
487int superfx_access_rom(running_device *cpu)
488{
489   superfx_state *cpustate = get_safe_token(cpu);
490
491   if ((cpustate->sfr & SUPERFX_SFR_G) && (cpustate->scmr & SUPERFX_SCMR_RON))
492      return 0;
493
494   return 1;
495}
496
475497UINT8 superfx_mmio_read(running_device *cpu, UINT32 addr)
476498{
477499   superfx_state *cpustate = get_safe_token(cpu);
src/mess/machine/snescart.c
r7667r7668
625625         break;
626626   }
627627
628   /* Find the amount of sram */
629   snes_cart.sram = snes_r_bank1(space, 0x00ffd8);
630   if (snes_cart.sram > 0)
631   {
632      snes_cart.sram = ((1 << (snes_cart.sram + 3)) / 8);
633      if (snes_cart.sram > snes_cart.sram_max)
634         snes_cart.sram = snes_cart.sram_max;
635   }
636
637628   /* Find the type of cart and detect special chips */
638629   /* Info mostly taken from http://snesemu.black-ship.net/misc/-from%20nsrt.edgeemu.com-chipinfo.htm */
639630   switch (snes_r_bank1(space, 0x00ffd6))
r7667r7668
752743            break;
753744   }
754745
746   /* Find the amount of cart ram (even if we call it sram...) */
747   if ((snes_has_addon_chip != HAS_SUPERFX))
748      snes_cart.sram = snes_r_bank1(space, 0x00ffd8);
749   else
750      snes_cart.sram = (snes_r_bank1(space, 0x00ffbd) & 0x07);
751
752   if (snes_cart.sram > 0)
753   {
754      snes_cart.sram = (1024 << snes_cart.sram);
755      if (snes_cart.sram > snes_cart.sram_max)
756         snes_cart.sram = snes_cart.sram_max;
757   }
758
755759   /* Log snes_cart information */
756760   {
757761      char title[21], rom_id[4], company_id[2];

Previous 15994 Revisions Next


© 1998-2018 The MESS Team