Previous 15994 Revisions Next

r7685 Saturday 3rd April, 2010 at 20:36:20 UTC by Fabio Priuli
[FAMICOM] Fixed fds format problems: Famicom Disk System is now back to the 0.135 status. Also, fixed a "free'd pointer which had never been allocated" issue (reported on MacOSX).
[src/mess/formats]nes_dsk.c
[src/mess/machine]nes.c

src/mess/machine/nes.c
r7684r7685
928928
929929static void nes_load_proc(running_device *image)
930930{
931   int header = 0;
931932   nes_fds.sides = 0;
932933
934   if (image_length(image) % 65500)
935      header = 0x10;
936
933937   image_fseek(image, 0, SEEK_END);
934   nes_fds.sides = (image_ftell(image) - 16) / 65500;
938   nes_fds.sides = (image_ftell(image) - header) / 65500;
935939   nes_fds.data = (UINT8*)image_malloc(image, nes_fds.sides * 65500);
936   image_fseek(image, 0x10, SEEK_SET);
940   
941   /* if there is an header, skip it */
942   image_fseek(image, header, SEEK_SET);
943
937944   image_fread(image, nes_fds.data, 65500 * nes_fds.sides);
938945   return;
939946}
r7684r7685
942949{
943950   /* TODO: should write out changes here as well */
944951   nes_fds.sides =  0;
945   image_freeptr(image,nes_fds.data);
946952}
947953
948DRIVER_INIT( famicom)
954DRIVER_INIT( famicom )
949955{
950956   /* clear some of the cart variables we don't use */
951957   nes.trainer = 0;
src/mess/formats/nes_dsk.c
r7684r7685
2424   UINT64 size;
2525   UINT8 header[3];
2626
27   *vote = 100;
27   *vote = 0;
2828
2929   /* get first 3 bytes */
3030   floppy_image_read(floppy, &header, 0, sizeof(header));
r7684r7685
3232   /* first check the size of the image */
3333   size = floppy_image_size(floppy);
3434
35   if ((size != 65516) && (size != 131016) && (size != 262016))
36      *vote = 0;
35   if ((size == 65516) || (size == 131016) || (size == 262016))
36   {
37      /* the image has an header, hence check the first sector for the magic string */
38      if (!memcmp(header, "FDS", 3))
39         *vote = 100;
40   }
3741
38   /* then check the first sector for the magic string */
39   if (memcmp(header, "FDS", 3))
40      *vote = 0;
41
42   if ((size == 65500) || (size == 131000) || (size == 262000))
43   {
44      /* the image has no header, hence let's trust the extension and load the file */
45      *vote = 100;
46   }
47   
4248   return FLOPPY_ERROR_SUCCESS;
4349}
4450

Previous 15994 Revisions Next


© 1998-2018 The MESS Team