Previous 15994 Revisions Next

r5796 Friday 18th September, 2009 at 21:20:35 UTC by Fabio Priuli
[SNES] slightly changed cart loading routine to allow emulation of S-DD1 bankswitches
[src/mame/machine]snessdd1.c
[src/mess/drivers]snes.c
[src/mess/machine]snescart.c

src/mame/machine/snessdd1.c
r5795r5796
537537
538538static void sdd1_init(running_machine* machine)
539539{
540   UINT8 i;
541
542   snes_sdd1.sdd1_enable = 0x00;
543   snes_sdd1.xfer_enable = 0x00;
544
545   snes_sdd1.mmc[0] = 0 << 20;
546   snes_sdd1.mmc[1] = 1 << 20;
547   snes_sdd1.mmc[2] = 2 << 20;
548   snes_sdd1.mmc[3] = 3 << 20;
549
550   for(i = 0; i < 8; i++)
551   {
552      snes_sdd1.dma[i].addr = 0;
553      snes_sdd1.dma[i].size = 0;
554   }
555
540556   snes_sdd1.sdd1emu = SDD1emu_ctor(machine);
557
558   snes_sdd1.buffer.ready = 0;
541559}
542560
543561static UINT8 sdd1_mmio_read(const address_space *space, UINT32 addr)
r5795r5796
631649
632650static UINT8 sdd1_read(running_machine* machine, UINT32 addr)
633651{
652   unsigned char *ROM;
653   ROM = memory_region(machine, "cart");
654
634655   //printf( "sdd1.read(%06x)\n", addr );
635656   if(snes_sdd1.sdd1_enable & snes_sdd1.xfer_enable)
636657   {
r5795r5796
677698   } // S-DD1 decompressor enabled
678699
679700   //printf( "returning a generic memory read from %06x\n", 0xc00000 + snes_sdd1.mmc[(addr >> 20) & 3] + (addr & 0x0fffff) );
680   return snes_ram[0xc00000 + snes_sdd1.mmc[(addr >> 20) & 3] + (addr & 0x0fffff)];
701   return ROM[snes_sdd1.mmc[(addr >> 20) & 3] + (addr & 0x0fffff)];
681702}
682703
683704static void sdd1_reset(running_machine *machine)
src/mess/machine/snescart.c
r5795r5796
343343   UINT8 header[512];
344344   UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000);
345345   UINT8 valid_mode20, valid_mode21, valid_mode25;
346   unsigned char *ROM;
347   int length;
346348
347349   memory_region_alloc(machine, "maincpu", 0x1000000, 0);
348350
r5795r5796
412414      snes_cart.sram_max = 0x20000;
413415   }
414416
417   /* Loading data */
418   {
419   ROM = memory_region(image->machine, "cart");
420   length = image_fread(image, ROM, image_length(image) - offset);
421   }
422
415423   /* FIXME: Insert crc check here */
416424
417425   /* How many blocks of data are available to be loaded? */
r5795r5796
439447         while (read_blocks < 64 && read_blocks < total_blocks)
440448         {
441449            /* Loading data */
442            image_fread(image, &snes_ram[0xc00000 + read_blocks * 0x10000], 0x10000);
450            memcpy(&snes_ram[0xc00000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x10000], 0x10000);
443451            /* Mirroring */
444452            memcpy(&snes_ram[0x008000 + read_blocks * 0x10000], &snes_ram[0xc08000 + read_blocks * 0x10000], 0x8000);
445453            memcpy(&snes_ram[0x400000 + read_blocks * 0x10000], &snes_ram[0xc00000 + read_blocks * 0x10000], 0x10000);
r5795r5796
474482         while (read_blocks < 64 && read_blocks < total_blocks)
475483         {
476484            /* Loading data */
477            image_fread(image, &snes_ram[0xc00000 + read_blocks * 0x10000], 0x10000);
485            memcpy(&snes_ram[0xc00000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x10000], 0x10000);
478486            /* Mirroring */
479487            memcpy( &snes_ram[0x808000 + read_blocks * 0x10000], &snes_ram[0xc08000 + read_blocks * 0x10000], 0x8000);
480488            read_blocks++;
r5795r5796
492500         while (read_blocks < 64  && read_blocks < (total_blocks - 64))
493501         {
494502            /* Loading data */
495            image_fread(image, &snes_ram[0x400000 + read_blocks * 0x10000], 0x10000);
503            memcpy(&snes_ram[0x400000 + read_blocks * 0x10000], &ROM[0x400000 + read_blocks * 0x10000], 0x10000);
496504            /* Mirroring */
497505            memcpy(&snes_ram[0x8000 + read_blocks * 0x10000], &snes_ram[0x408000 + read_blocks * 0x10000], 0x8000);
498506            read_blocks++;
r5795r5796
522530         while (read_blocks < 64 && read_blocks < total_blocks)
523531         {
524532            /* Loading data */
525            image_fread( image, &snes_ram[0x8000 + read_blocks * 0x10000], 0x8000);
533            memcpy(&snes_ram[0x008000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x8000], 0x8000);
526534            /* Mirroring */
527535            memcpy(&snes_ram[0x400000 + read_blocks * 0x10000], &snes_ram[0x8000 + read_blocks * 0x10000], 0x8000);
528536            memcpy(&snes_ram[0x408000 + read_blocks * 0x10000], &snes_ram[0x8000 + read_blocks * 0x10000], 0x8000);
r5795r5796
552560      /* LoROM carts load data in banks 0x00 to 0x7f at address 0x8000 (actually up to 0x7d, because 0x7e and
553561       * 0x7f are overwritten by WRAM). Each block is also mirrored in banks 0x80 to 0xff (up to 0xff for real)
554562       */
555         if((temp_buffer[0x007fd6] >= 0x13 && temp_buffer[0x007fd6] <= 0x15) || temp_buffer[0x007fd6] == 0xa)
563         /* SuperFX games needs a different loading routine */
564         if(((temp_buffer[0x007fd6] >= 0x13 && temp_buffer[0x007fd6] <= 0x15) || temp_buffer[0x007fd6] == 0x1a) && (temp_buffer[0x007fd5] == 0x20))
556565         {
557566            while (read_blocks < 64 && read_blocks < total_blocks)
558567            {
559568               /* Loading data primary: banks 0-3f from 8000-ffff*/
560               image_fread(image, &snes_ram[0x8000 + read_blocks * 0x10000], 0x8000);
569               memcpy(&snes_ram[0x008000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x8000], 0x8000);
561570               /* Mirroring at banks 80-bf from 8000-ffff */
562               memcpy(&snes_ram[0x808000 + (read_blocks * 0x10000)], &snes_ram[0x8000 + (read_blocks * 0x10000)], 0x8000);
571               memcpy(&snes_ram[0x808000 + read_blocks * 0x10000], &snes_ram[0x8000 + (read_blocks * 0x10000)], 0x8000);
563572               read_blocks++;
564573            }
565
566            image_fseek(image, offset, SEEK_SET);
567574            /* Loading data secondary, filling full 64k banks from 0x400000 to 600000 */
568            image_fread(image, &snes_ram[0x400000], total_blocks * 0x8000);
575            memcpy(&snes_ram[0x400000], &ROM[0x000000], total_blocks * 0x8000);
569576            /* mirror at c00000-e00000 */
570            memcpy( &snes_ram[0xc00000], &snes_ram[0x400000], total_blocks * 0x8000);
577            memcpy(&snes_ram[0xc00000], &snes_ram[0x400000], total_blocks * 0x8000);
571578         }
572579         else
573580         {
574581            while (read_blocks < 128 && read_blocks < total_blocks)
575582            {
576583               /* Loading data */
577               image_fread(image, &snes_ram[0x8000 + read_blocks * 0x10000], 0x8000);
584               memcpy(&snes_ram[0x008000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x8000], 0x8000);
578585               /* Mirroring */
579               memcpy(&snes_ram[0x808000 + (read_blocks * 0x10000)], &snes_ram[0x8000 + (read_blocks * 0x10000)], 0x8000);
586               memcpy(&snes_ram[0x808000 + read_blocks * 0x10000], &snes_ram[0x8000 + (read_blocks * 0x10000)], 0x8000);
580587               read_blocks++;
581588            }
582589            /* Filling banks up to 0x7f and their mirrors */
src/mess/drivers/snes.c
r5795r5796
3434#include "includes/snes.h"
3535#include "machine/snescart.h"
3636
37#define MAX_SNES_CART_SIZE 0x600000
3738
3839/*************************************
3940 *
r5795r5796
278279   ROM_REGION( 0x1000, "addons", 0 )      /* add-on chip ROMs (DSP, SFX, etc) */
279280   ROM_LOAD( "dsp1data.bin", 0x000000, 0x000800, CRC(4b02d66d) SHA1(1534f4403d2a0f68ba6e35186fe7595d33de34b1) )
280281   ROM_LOAD( "dsp3data.bin", 0x000800, 0x000800, CRC(4a1c5453) SHA1(2f69c652109938cde21df5eb89890bf090256dbb) )
282   ROM_REGION( MAX_SNES_CART_SIZE, "cart", ROMREGION_ERASE00 )
281283ROM_END
282284
283285ROM_START(snessfx)
r5795r5796
285287   ROM_LOAD( "spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
286288   ROM_REGION( 0x1000, "addons", 0 )      /* add-on chip ROMs (DSP, SFX, etc) */
287289   ROM_LOAD( "dsp1data.bin", 0x000000, 0x000800, CRC(4b02d66d) SHA1(1534f4403d2a0f68ba6e35186fe7595d33de34b1) )
290   ROM_REGION( MAX_SNES_CART_SIZE, "cart", ROMREGION_ERASE00 )
288291ROM_END
289292
290293ROM_START(snespal)
r5795r5796
293296   ROM_REGION( 0x1000, "addons", 0 )      /* add-on chip ROMs (DSP, SFX, etc) */
294297   ROM_LOAD( "dsp1data.bin", 0x000000, 0x000800, CRC(4b02d66d) SHA1(1534f4403d2a0f68ba6e35186fe7595d33de34b1) )
295298   ROM_LOAD( "dsp3data.bin", 0x000800, 0x000800, CRC(4a1c5453) SHA1(2f69c652109938cde21df5eb89890bf090256dbb) )
299   ROM_REGION( MAX_SNES_CART_SIZE, "cart", ROMREGION_ERASE00 )
296300ROM_END
297301
298302ROM_START(snespsfx)
r5795r5796
300304   ROM_LOAD( "spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
301305   ROM_REGION( 0x1000, "addons", 0 )      /* add-on chip ROMs (DSP, SFX, etc) */
302306   ROM_LOAD( "dsp1data.bin", 0x000000, 0x000800, CRC(4b02d66d) SHA1(1534f4403d2a0f68ba6e35186fe7595d33de34b1) )
307   ROM_REGION( MAX_SNES_CART_SIZE, "cart", ROMREGION_ERASE00 )
303308ROM_END
304309
305310ROM_START(sfcbox)
r5795r5796
315320   ROM_LOAD( "spc700.rom", 0x00, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
316321
317322   ROM_REGION( 0x1000, "addons", ROMREGION_ERASE00 )      /* add-on chip ROMs (DSP, SFX, etc) */
323   ROM_REGION( MAX_SNES_CART_SIZE, "cart", ROMREGION_ERASE00 )
318324ROM_END
319325
320326/***************************************************************************

Previous 15994 Revisions Next


© 1998-2018 The MESS Team