Previous 15994 Revisions Next

r9900 Monday 3rd January, 2011 at 03:14:19 UTC by R. Belmont
SNES: Moved DSP to specific drivers like SuperFX at Kale's request. Use "snesdsp" and "snespdsp" for NTSC/PAL with DSP-1/2/3/4.
[src/mame/includes]snes.h
[src/mame/machine]snes.c
[src/mess]messdriv.c
[src/mess/drivers]snes.c

src/mame/machine/snes.c
r9899r9900
3636
3737struct snes_cart_info snes_cart;
3838
39// DSP accessors
40#define dsp_get_sr() state->upd7725->snesdsp_read(false)
41#define dsp_get_dr() state->upd7725->snesdsp_read(true)
42#define dsp_set_sr(data) state->upd7725->snesdsp_write(false, data)
43#define dsp_set_dr(data) state->upd7725->snesdsp_write(true, data)
44
3945// add-on chip emulators
4046#include "machine/snesobc1.c"
4147#include "machine/snescx4.c"
r9899r9900
278284   snes_ram[RDMPYH] = (c >> 8) & 0xff;
279285}
280286
281
282287/*************************************
283288
284    DSP I/O
285
286*************************************/
287static UINT8 dsp_get_sr(running_machine *machine)
288{
289   upd7725_device *upd7725 = machine->device<upd7725_device>("dsp");
290
291   return upd7725->snesdsp_read(false);
292}
293
294static UINT8 dsp_get_dr(running_machine *machine)
295{
296   upd7725_device *upd7725 = machine->device<upd7725_device>("dsp");
297
298   return upd7725->snesdsp_read(true);
299}
300
301static void dsp_set_sr(running_machine *machine, UINT8 data)
302{
303   upd7725_device *upd7725 = machine->device<upd7725_device>("dsp");
304
305   upd7725->snesdsp_write(false, data);
306}
307
308static void dsp_set_dr(running_machine *machine, UINT8 data)
309{
310   upd7725_device *upd7725 = machine->device<upd7725_device>("dsp");
311
312   upd7725->snesdsp_write(true, data);
313}
314
315/*************************************
316
317289    Input Handlers
318290
319291*************************************/
r9899r9900
968940      else if (state->has_addon_chip == HAS_OBC1)
969941         value = obc1_read(space, offset);
970942      else if ((state->cart[0].mode == SNES_MODE_21) && (state->has_addon_chip == HAS_DSP1) && (offset < 0x100000))
971         value = (address < 0x7000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
943         value = (address < 0x7000) ? dsp_get_dr() : dsp_get_sr();
972944      else if (state->has_addon_chip == HAS_CX4)
973945         value = CX4_read(address - 0x6000);
974946      else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
r9899r9900
983955      }
984956   }
985957   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
986      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
958      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
987959   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
988      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
960      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
989961   else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
990      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
962      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
991963   else
992964      value = snes_ram[offset];
993965
r9899r9900
10471019   }
10481020   /* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */
10491021   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1))
1050      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
1022      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
10511023   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2))
1052      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
1024      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
10531025   else if (state->has_addon_chip == HAS_DSP3)
1054      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
1026      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
10551027   else if (state->has_addon_chip == HAS_DSP4)
1056      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
1028      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
10571029   else
10581030      value = snes_ram[0x300000 + offset];
10591031
r9899r9900
11301102         value = snes_ram[0x600000 + offset];
11311103      /* some other dsp1 games use these banks 0x60 to 0x6f at address 0x0000 */
11321104      else if (state->has_addon_chip == HAS_DSP1)
1133         value = (address >= 0x4000) ? dsp_get_sr(space->machine) : dsp_get_dr(space->machine);
1105         value = (address >= 0x4000) ? dsp_get_sr() : dsp_get_dr();
11341106      else
11351107      {
11361108         logerror("(PC=%06x) snes_r_bank4: Unmapped external chip read: %04x\n",cpu_get_pc(space->cpu),address);
r9899r9900
12181190      }
12191191   }
12201192   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
1221      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
1193      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
12221194   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
1223      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
1195      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
12241196   else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
1225      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
1197      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
12261198   else if ((state->has_addon_chip == HAS_DSP4) && (offset >= 0x300000))
1227      value = (address < 0xc000) ? dsp_get_dr(space->machine) : dsp_get_sr(space->machine);
1199      value = (address < 0xc000) ? dsp_get_dr() : dsp_get_sr();
12281200   else
12291201      value = snes_ram[0x800000 + offset];
12301202
r9899r9900
13141286      else if (state->has_addon_chip == HAS_OBC1)
13151287         obc1_write(space, offset, data);
13161288      else if ((state->cart[0].mode == SNES_MODE_21) && (state->has_addon_chip == HAS_DSP1) && (offset < 0x100000))
1317         dsp_set_dr(space->machine, data);
1289         dsp_set_dr(data);
13181290      else if (state->has_addon_chip == HAS_CX4)
13191291         CX4_write(space->machine, address - 0x6000, data);
13201292      else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
r9899r9900
13261298         logerror("snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data);
13271299   }
13281300   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
1329      dsp_set_dr(space->machine, data);
1301      dsp_set_dr(data);
13301302   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
13311303   {
13321304      if (address < 0xc000)
1333         dsp_set_dr(space->machine, data);
1305         dsp_set_dr(data);
13341306      else
1335         dsp_set_sr(space->machine, data);
1307         dsp_set_sr(data);
13361308   }
13371309   else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
13381310      if (address < 0xc000)
1339         dsp_set_dr(space->machine, data);
1311         dsp_set_dr(data);
13401312      else
1341         dsp_set_sr(space->machine, data);
1313         dsp_set_sr(data);
13421314   else
13431315      logerror( "(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset );
13441316
r9899r9900
13871359   }
13881360   /* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */
13891361   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1))
1390      dsp_set_dr(space->machine, data);
1362      dsp_set_dr(data);
13911363   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2))
13921364   {
13931365      if (address < 0xc000)
1394         dsp_set_dr(space->machine, data);
1366         dsp_set_dr(data);
13951367      else
1396         dsp_set_sr(space->machine, data);
1368         dsp_set_sr(data);
13971369   }
1398   else if (state->has_addon_chip == HAS_DSP3)
1370   else if ((state->has_addon_chip == HAS_DSP3) || (state->has_addon_chip == HAS_DSP4))
13991371      if (address < 0xc000)
1400         dsp_set_dr(space->machine, data);
1372         dsp_set_dr(data);
14011373      else
1402         dsp_set_sr(space->machine, data);
1403   else if (state->has_addon_chip == HAS_DSP4)
1404      if (address < 0xc000)
1405         dsp_set_dr(space->machine, data);
1406      else
1407         dsp_set_sr(space->machine, data);
1374         dsp_set_sr(data);
14081375   else
14091376      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x300000);
14101377
r9899r9900
14291396      if (address >= 0x8000)
14301397         logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x600000);
14311398      else if (state->has_addon_chip == HAS_DSP1)
1432         dsp_set_dr(space->machine, data);
1399         dsp_set_dr(data);
14331400      else
14341401         logerror("snes_w_bank4: Attempt to write to reserved address: %X = %02x\n", offset + 0x600000, data);
14351402   }
r9899r9900
14981465      }
14991466   }
15001467   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
1501      dsp_set_dr(space->machine, data);
1468      dsp_set_dr(data);
15021469   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
15031470   {
15041471      if (address < 0xc000)
1505         dsp_set_dr(space->machine, data);
1472         dsp_set_dr(data);
15061473      else
1507         dsp_set_sr(space->machine, data);
1474         dsp_set_sr(data);
15081475   }
15091476   else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
15101477      if (address < 0xc000)
1511         dsp_set_dr(space->machine, data);
1478         dsp_set_dr(data);
15121479      else
1513         dsp_set_sr(space->machine, data);
1480         dsp_set_sr(data);
15141481   else if ((state->has_addon_chip == HAS_DSP4) && (offset >= 0x300000))
15151482      if (address < 0xc000)
1516         dsp_set_dr(space->machine, data);
1483         dsp_set_dr(data);
15171484      else
1518         dsp_set_sr(space->machine, data);
1485         dsp_set_sr(data);
15191486   else
15201487      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x800000);
15211488
r9899r9900
17081675   snes_ram[WRIO] = 0xff;
17091676   snes_ram[VMAIN] = 0x80;
17101677
1711   // assume no DSP and halt it...
1712   cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE);
1678   // see if there's a uPD7725 DSP in the machine config
1679   state->upd7725 = machine->device<upd7725_device>("dsp");
17131680
1681   // if we have a DSP, halt it for the moment
1682   if (state->upd7725)
1683   {
1684      cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE);
1685   }
1686
17141687   switch (state->has_addon_chip)
17151688   {
17161689      case HAS_DSP1:
17171690      case HAS_DSP2:
17181691      case HAS_DSP3:
17191692      case HAS_DSP4:
1720         // we do have a DSP, let 'er rip
1721         cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, CLEAR_LINE);
1693         // cartridge uses the DSP, let 'er rip
1694         if (state->upd7725)
1695         {
1696            cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, CLEAR_LINE);
1697         }
1698         else
1699         {
1700            logerror("SNES: Game uses a DSP, but the machine driver is missing the uPD7725!\n");
1701            state->has_addon_chip = HAS_NONE;   // prevent crash trying to access NULL device
1702         }                       
17221703         break;
17231704
17241705      case HAS_RTC:
src/mame/includes/snes.h
r9899r9900
66#include "streams.h"
77#include "cpu/spc700/spc700.h"
88#include "cpu/g65816/g65816.h"
9#include "cpu/upd7725/upd7725.h"
910#include "audio/snes_snd.h"
1011
1112/*
r9899r9900
469470   spc700_device *soundcpu;
470471   snes_sound_device *spc700;
471472   cpu_device *superfx;
473   upd7725_device *upd7725;
472474};
473475
474476/* Special chips, checked at init and used in memory handlers */
src/mess/messdriv.c
r9899r9900
7070   DRIVER( snespal )   /* Nintendo Super Nintendo PAL */
7171   DRIVER( snessfx )   /* Nintendo Super Nintendo NTSC w/SuperFX CPU*/
7272   DRIVER( snespsfx )  /* Nintendo Super Nintendo PAL w/SuperFX CPU */
73   DRIVER( snesdsp )   /* Nintendo Super Nintendo NTSC w/DSP-x CPU*/
74   DRIVER( snespdsp )  /* Nintendo Super Nintendo PAL w/DSP-x CPU */
7375   DRIVER( snesst )    /* Nintendo Super Nintendo NTSC w/Sufami Turbo base cart */
7476   DRIVER( snesbsx )   /* Nintendo Super Nintendo NTSC w/BS-X compatible cart  */
7577   DRIVER( n64 )       /* Nintendo N64   */
src/mess/drivers/snes.c
r9899r9900
703703   MCFG_CPU_ADD("soundcpu", SPC700, 1024000)   /* 1.024 MHz */
704704   MCFG_CPU_PROGRAM_MAP(spc_map)
705705
706   MCFG_CPU_ADD("dsp", UPD7725, 8000000)
707   MCFG_CPU_PROGRAM_MAP(dsp_prg_map)
708   MCFG_CPU_DATA_MAP(dsp_data_map)
709
710706   //MCFG_QUANTUM_TIME(HZ(48000))
711707   MCFG_QUANTUM_PERFECT_CPU("maincpu")
712708
r9899r9900
746742   MCFG_CPU_CONFIG(snes_superfx_config)
747743MACHINE_CONFIG_END
748744
745static MACHINE_CONFIG_DERIVED( snesdsp, snes )
746
747   MCFG_CPU_ADD("dsp", UPD7725, 8000000)
748   MCFG_CPU_PROGRAM_MAP(dsp_prg_map)
749   MCFG_CPU_DATA_MAP(dsp_data_map)
750MACHINE_CONFIG_END
751
749752static MACHINE_CONFIG_DERIVED( snespal, snes )
750753   MCFG_CPU_MODIFY( "maincpu" )
751754   MCFG_CPU_CLOCK( MCLK_PAL )
r9899r9900
761764   MCFG_CPU_CONFIG(snes_superfx_config)
762765MACHINE_CONFIG_END
763766
767static MACHINE_CONFIG_DERIVED( snespdsp, snespal )
768
769   MCFG_CPU_ADD("dsp", UPD7725, 8000000)
770   MCFG_CPU_PROGRAM_MAP(dsp_prg_map)
771   MCFG_CPU_DATA_MAP(dsp_data_map)
772MACHINE_CONFIG_END
773
764774static MACHINE_CONFIG_DERIVED( snesst, snes_base )
765775
766776   MCFG_MACHINE_START(snesst)
r9899r9900
786796   ROM_REGION( 0x100, "user5", 0 )      /* IPL ROM */
787797   ROM_LOAD( "spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
788798
799   ROM_REGION( 0x10000, "addons", ROMREGION_ERASE00 )      /* add-on chip ROMs (DSP, SFX, etc) */
800
801   ROM_REGION( MAX_SNES_CART_SIZE, "cart", ROMREGION_ERASE00 )
802   ROM_REGION( 0x2000, "dspprg", ROMREGION_ERASEFF)
803   ROM_REGION( 0x800, "dspdata", ROMREGION_ERASEFF)
804ROM_END
805
806ROM_START( snesdsp )
807   ROM_REGION( 0x1000000, "maincpu", ROMREGION_ERASE00 )
808
809   ROM_REGION( 0x100, "user5", 0 )      /* IPL ROM */
810   ROM_LOAD( "spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
811
789812   ROM_REGION( 0x10000, "addons", 0 )      /* add-on chip ROMs (DSP, SFX, etc) */
790813   ROM_LOAD( "dsp1b.bin", SNES_DSP1B_OFFSET, 0x002800, CRC(453557e0) SHA1(3a218b0e4572a8eba6d0121b17fdac9529609220) )
791814   ROM_LOAD( "dsp1.bin",  SNES_DSP1_OFFSET,  0x002800, CRC(2838f9f5) SHA1(0a03ccb1fd2bea91151c745a4d1f217ae784f889) )
r9899r9900
817840   ROM_REGION( 0x100, "user5", 0 )      /* IPL ROM */
818841   ROM_LOAD( "spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
819842
843   ROM_REGION( 0x10000, "addons", ROMREGION_ERASE00 )      /* add-on chip ROMs (DSP, SFX, etc) */
844
845   ROM_REGION( MAX_SNES_CART_SIZE, "cart", ROMREGION_ERASE00 )
846   ROM_REGION( 0x2000, "dspprg", ROMREGION_ERASEFF)
847   ROM_REGION( 0x800, "dspdata", ROMREGION_ERASEFF)
848ROM_END
849
850ROM_START( snespdsp )
851   ROM_REGION( 0x1000000, "maincpu", ROMREGION_ERASE00 )
852
853   ROM_REGION( 0x100, "user5", 0 )      /* IPL ROM */
854   ROM_LOAD( "spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
855
820856   ROM_REGION( 0x10000, "addons", 0 )      /* add-on chip ROMs (DSP, SFX, etc) */
821857   ROM_LOAD( "dsp1b.bin", SNES_DSP1B_OFFSET, 0x002800, CRC(453557e0) SHA1(3a218b0e4572a8eba6d0121b17fdac9529609220) )
822858   ROM_LOAD( "dsp1.bin",  SNES_DSP1_OFFSET,  0x002800, CRC(2838f9f5) SHA1(0a03ccb1fd2bea91151c745a4d1f217ae784f889) )
r9899r9900
893929// FIXME: the "hacked" drivers below, currently needed due to limitations in the core device design, should eventually be removed
894930
895931// These would require CPU to be added/removed depending on the cart which is loaded
932CONS( 1989, snesdsp,  snes,   0,      snesdsp,  snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC, w/DSP-x)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
933CONS( 1991, snespdsp, snes,   0,      snespdsp, snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System (PAL, w/DSP-x)",  GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
896934CONS( 1989, snessfx,  snes,   0,      snessfx,  snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC, w/SuperFX)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
897935CONS( 1991, snespsfx, snes,   0,      snespsfx, snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System (PAL, w/SuperFX)",  GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
898936//CONS( 1989, snessa1,  snes,   0,      snessa1,  snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC, w/SA-1)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team