src/mess/machine/nes.c
| r7684 | r7685 | |
| 928 | 928 | |
| 929 | 929 | static void nes_load_proc(running_device *image) |
| 930 | 930 | { |
| 931 | int header = 0; |
| 931 | 932 | nes_fds.sides = 0; |
| 932 | 933 | |
| 934 | if (image_length(image) % 65500) |
| 935 | header = 0x10; |
| 936 | |
| 933 | 937 | image_fseek(image, 0, SEEK_END); |
| 934 | | nes_fds.sides = (image_ftell(image) - 16) / 65500; |
| 938 | nes_fds.sides = (image_ftell(image) - header) / 65500; |
| 935 | 939 | 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 | |
| 937 | 944 | image_fread(image, nes_fds.data, 65500 * nes_fds.sides); |
| 938 | 945 | return; |
| 939 | 946 | } |
| r7684 | r7685 | |
| 942 | 949 | { |
| 943 | 950 | /* TODO: should write out changes here as well */ |
| 944 | 951 | nes_fds.sides = 0; |
| 945 | | image_freeptr(image,nes_fds.data); |
| 946 | 952 | } |
| 947 | 953 | |
| 948 | | DRIVER_INIT( famicom) |
| 954 | DRIVER_INIT( famicom ) |
| 949 | 955 | { |
| 950 | 956 | /* clear some of the cart variables we don't use */ |
| 951 | 957 | nes.trainer = 0; |
src/mess/formats/nes_dsk.c
| r7684 | r7685 | |
| 24 | 24 | UINT64 size; |
| 25 | 25 | UINT8 header[3]; |
| 26 | 26 | |
| 27 | | *vote = 100; |
| 27 | *vote = 0; |
| 28 | 28 | |
| 29 | 29 | /* get first 3 bytes */ |
| 30 | 30 | floppy_image_read(floppy, &header, 0, sizeof(header)); |
| r7684 | r7685 | |
| 32 | 32 | /* first check the size of the image */ |
| 33 | 33 | size = floppy_image_size(floppy); |
| 34 | 34 | |
| 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 | } |
| 37 | 41 | |
| 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 | |
| 42 | 48 | return FLOPPY_ERROR_SUCCESS; |
| 43 | 49 | } |
| 44 | 50 | |