diff options
author | 2015-11-08 12:56:12 +0100 | |
---|---|---|
committer | 2015-11-08 12:56:12 +0100 | |
commit | 7c19aac60e12d6f5ea301bdb34d7826a01e0b06f (patch) | |
tree | f310d86aa2c6bfc19d115307dedde4eb0cd52dad /src/lib/formats/nes_dsk.cpp | |
parent | a57b46ae933badd7441ce1644711dbb851e2b504 (diff) |
Rename *.c -> *.cpp in our source (nw)
Diffstat (limited to 'src/lib/formats/nes_dsk.cpp')
-rw-r--r-- | src/lib/formats/nes_dsk.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/lib/formats/nes_dsk.cpp b/src/lib/formats/nes_dsk.cpp new file mode 100644 index 00000000000..5fc263a5f26 --- /dev/null +++ b/src/lib/formats/nes_dsk.cpp @@ -0,0 +1,75 @@ +// license:BSD-3-Clause +// copyright-holders:Miodrag Milanovic +/********************************************************************* + + formats/nes_dsk.c + + NES disk images + +*********************************************************************/ + + +#include <string.h> +#include <assert.h> + +#include "formats/nes_dsk.h" +#include "formats/basicdsk.h" + + + +/***************************************************************************** + NES floppy core functions +*****************************************************************************/ + + +static FLOPPY_IDENTIFY( nes_dsk_identify ) +{ + UINT64 size; + UINT8 header[3]; + + *vote = 0; + + /* get first 3 bytes */ + floppy_image_read(floppy, &header, 0, sizeof(header)); + + /* first check the size of the image */ + size = floppy_image_size(floppy); + + if ((size == 65516) || (size == 131016) || (size == 262016)) + { + /* the image has an header, hence check the first sector for the magic string */ + if (!memcmp(header, "FDS", 3)) + *vote = 100; + } + + if ((size == 65500) || (size == 131000) || (size == 262000)) + { + /* the image has no header, hence let's trust the extension and load the file */ + *vote = 100; + } + + return FLOPPY_ERROR_SUCCESS; +} + + +static FLOPPY_CONSTRUCT( nes_dsk_construct ) +{ + return FLOPPY_ERROR_SUCCESS; +} + + +/***************************************************************************** + NES floppy options +*****************************************************************************/ + +LEGACY_FLOPPY_OPTIONS_START( nes_only ) + LEGACY_FLOPPY_OPTION( + fds_dsk, + "fds", + "NES floppy disk image", + nes_dsk_identify, + nes_dsk_construct, + NULL, + NULL + ) +LEGACY_FLOPPY_OPTIONS_END0 |