Previous 15994 Revisions Next

r8152 Monday 24th May, 2010 at 14:24:20 UTC by Fabio Priuli
[FDS] Finally fixed RAM handling: most games now reach the title screen as they were doing back in 0.117 & 0.122 and many of them are playable again (a few still suffer of SRAM problems)
[docs]messnew.txt
[src/mess/includes]nes.h
[src/mess/machine]nes.c nes_ines.c

src/mess/includes/nes.h
r8151r8152
157157
158158   /***** FDS-floppy related *****/
159159
160   UINT8   *fds_data;
161160   UINT8   fds_sides;
162   UINT8   *fds_ram;
161   UINT8   *fds_data;   // here, we store a copy of the disk
162   UINT8   *fds_ram;   // here, we emulate the RAM adapter
163163
164164   /* Variables which can change */
165165   UINT8   fds_motor_on;
src/mess/machine/nes.c
r8151r8152
5959         state->slow_banking = 0;
6060         /* If we are loading a disk we have already filled state->fds_data and we don't want to overwrite it,
6161            if we are loading a cart image identified as mapper 20 (probably wrong mapper...) we need to alloc
62            memory for the bank 2 pointer */
62            memory for use in nes_fds_r/nes_fds_w. Same goes for allocation of fds_ram (used for bank2) */
6363         if (state->fds_data == NULL)
64            state->fds_data = auto_alloc_array(machine, UINT8, 0x8000);
64         {
65            UINT32 size = memory_region_length(machine, "maincpu") - 0x10000;
66            state->fds_data = auto_alloc_array_clear(machine, UINT8, size);
67            memcpy(state->fds_data, state->rom, size);   // copy in fds_data the cart PRG
68         }
69         if (state->fds_ram == NULL)
70            state->fds_ram = auto_alloc_array(machine, UINT8, 0x8000);
71
6572         memory_install_read8_handler(space, 0x4030, 0x403f, 0, 0, nes_fds_r);
6673         memory_install_read_bank(space, 0x6000, 0xdfff, 0, 0, "bank2");
6774         memory_install_read_bank(space, 0xe000, 0xffff, 0, 0, "bank1");
r8151r8152
7077         memory_install_write_bank(space, 0x6000, 0xdfff, 0, 0, "bank2");
7178
7279         memory_set_bankptr(machine, "bank1", &state->rom[0xe000]);
73         memory_set_bankptr(machine, "bank2", state->fds_data);
80         memory_set_bankptr(machine, "bank2", state->fds_ram);
7481         break;
7582      case 50:
7683         memory_install_write8_handler(space, 0x4020, 0x403f, 0, 0, nes_mapper50_add_w);
r8151r8152
496503
497504      if ((magic[0] == 'N') && (magic[1] == 'E') && (magic[2] == 'S'))   /* If header starts with 'NES' it is iNES */
498505      {
506         UINT32 prg_size;
507
499508         state->format = 1;   // we use this to select between mapper_reset / unif_reset
500509
501510         mapinfo = image_extrainfo(image);
r8151r8152
577586         memory_region_free(image->machine, "gfx1");
578587
579588         /* Allocate them again with the proper size */
580         memory_region_alloc(image->machine, "maincpu", 0x10000 + (state->prg_chunks + 1) * 0x4000, 0);
589         prg_size = (state->prg_chunks == 1) ? 2 * 0x4000 : state->prg_chunks * 0x4000;
590         memory_region_alloc(image->machine, "maincpu", 0x10000 + prg_size, 0);
581591         if (state->chr_chunks)
582592            memory_region_alloc(image->machine, "gfx1", state->chr_chunks * 0x2000, 0);
583593
r8151r8152
598608         {
599609            image_fread(image, &state->rom[0x14000], 0x4000);
600610            /* Mirror this bank into $8000 */
601            memcpy(&state->rom[0x10000], &state->rom [0x14000], 0x4000);
611            memcpy(&state->rom[0x10000], &state->rom[0x14000], 0x4000);
602612         }
603613         else
604614            image_fread(image, &state->rom[0x10000], 0x4000 * state->prg_chunks);
r8151r8152
635645         }
636646
637647#if SPLIT_CHR
648         if (state->chr_chunks > 0)
638649         {
639650            FILE *chrout;
640651            char outname[255];
r8151r8152
667678         char magic2[4];
668679         UINT8 buffer[4];
669680         UINT32 chunk_length = 0, read_length = 0x20;
670         UINT32 prg_start = 0, chr_start = 0;
681         UINT32 prg_start = 0, chr_start = 0, prg_size;
671682         int prg_left = 0, chr_left = 0;   // used to verify integrity of our unif image
672683         char unif_mapr[32];   // here we should store MAPR chunks
673684         UINT32 size = image_length(image);
r8151r8152
732743                  state->prg_chunks = unif_board->prgrom;
733744                  state->chr_chunks = unif_board->chrrom;
734745                  state->battery = unif_board->wram;   // we should implement WRAM banks...
735                  //                  state->hard_mirroring = unif_board->nt;
736                  //                      state->four_screen_vram = ;
746                  // state->hard_mirroring = unif_board->nt;
747                  // state->four_screen_vram = ;
737748
738749                  /* Free the regions that were allocated by the ROM loader */
739750                  memory_region_free(image->machine, "maincpu");
740751                  memory_region_free(image->machine, "gfx1");
741752
742753                  /* Allocate them again with the proper size */
743                  memory_region_alloc(image->machine, "maincpu", 0x10000 + (state->prg_chunks + 1) * 0x4000, 0);
754                  prg_size = (state->prg_chunks == 1) ? 2 * 0x4000 : state->prg_chunks * 0x4000;
755                  memory_region_alloc(image->machine, "maincpu", 0x10000 + prg_size, 0);
744756                  if (state->chr_chunks)
745757                     memory_region_alloc(image->machine, "gfx1", state->chr_chunks * 0x2000, 0);
746758
r8151r8152
918930            }
919931         } while (size > read_length);
920932
921         if (!mapr_chunk_found )
933         if (!mapr_chunk_found)
922934            fatalerror("UNIF should have a [MAPR] chunk to work. Check if your image has been corrupted");
923935
936#if SPLIT_PRG
937         {
938            FILE *prgout;
939            char outname[255];
940           
941            sprintf(outname, "%s.prg", image_filename(image));
942            prgout = fopen(outname, "wb");
943            if (prgout)
944            {
945               fwrite(&state->rom[0x10000], 1, 0x4000 * state->prg_chunks, prgout);
946               printf("Created PRG chunk\n");
947            }
948           
949            fclose(prgout);
950         }
951#endif
952         
953#if SPLIT_CHR
954         if (state->chr_chunks > 0)
955         {
956            FILE *chrout;
957            char outname[255];
958           
959            sprintf(outname, "%s.chr", image_filename(image));
960            chrout= fopen(outname, "wb");
961            if (chrout)
962            {
963               fwrite(state->vrom, 1, 0x2000 * state->chr_chunks, chrout);
964               printf("Created CHR chunk\n");
965            }
966            fclose(chrout);
967         }
968#endif
969         
924970         logerror("UNIF support is only very preliminary.\n");
925971      }
926972      else
r8151r8152
944990      // validate the xml fields
945991      if (!prg_size)
946992         fatalerror("No PRG entry for this software! Please check if the xml list got corrupted");
947      if (prg_size < 0x4000)
993      if (prg_size < 0x8000)
948994         fatalerror("PRG entry is too small! Please check if the xml list got corrupted");
949995
950996      if (chr_size)
r8151r8152
10061052   if (image_length(image) % 65500)
10071053      header = 0x10;
10081054
1009   image_fseek(image, 0, SEEK_END);
1010   state->fds_sides = (image_ftell(image) - header) / 65500;
1011   state->fds_data = (UINT8*)image_malloc(image, state->fds_sides * 65500);
1055   state->fds_sides = (image_length(image) - header) / 65500;
10121056
1057   if (state->fds_data == NULL)
1058      state->fds_data = (UINT8*)image_malloc(image, state->fds_sides * 65500);   // I don't think we can arrive here ever, probably it can be removed...
1059
10131060   /* if there is an header, skip it */
10141061   image_fseek(image, header, SEEK_SET);
10151062
r8151r8152
10431090   state->fds_sides = 0;
10441091   state->fds_data = NULL;
10451092
1093   state->fds_data = auto_alloc_array_clear(machine, UINT8, 65500 * 2);
1094   state->fds_ram = auto_alloc_array_clear(machine, UINT8, 0x8000);
1095   state_save_register_global_pointer(machine, state->fds_ram, 0x8000);
1096
10461097   floppy_install_load_proc(floppy_get_device(machine, 0), nes_load_proc);
10471098   floppy_install_unload_proc(floppy_get_device(machine, 0), nes_unload_proc);
10481099}
src/mess/machine/nes_ines.c
r8151r8152
19291929         {
19301930            /* If we've switched disks, report "no disk" for a few reads */
19311931            ret = 1;
1932            state->fds_count ++;
1932            state->fds_count++;
19331933            if (state->fds_count == 50)
19341934            {
19351935               state->fds_last_side = state->fds_current_side;
docs/messnew.txt
r8151r8152
10.138.1
10.138.1
22
33New System Drivers Supported:
44-----------------------------
r8151r8152
1919
2020System Driver Changes:
2121----------------------
22[GBA] Improved flash saving in games such as Sword of Mana [R. Belmont]
2322
23- [FAMICOM] Fixed long standing problems (present at least since MESS 0.122)
24  with disks not loading correctly. Many games are playable again. [Fabio Priuli]
2425
26- [GBA] Improved flash saving in games such as Sword of Mana [R. Belmont]
2527
28
29
2630Imgtool Changes:
2731----------------
2832(none)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team