Added specialist mx custom format handling (nw)

This commit is contained in:
Miodrag Milanovic 2012-12-13 12:56:38 +00:00
parent f356f30e6e
commit 0716e22259
4 changed files with 79 additions and 148 deletions

View File

@ -1,159 +1,74 @@
/***************************************************************************
Copyright Olivier Galibert
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
****************************************************************************/
/*********************************************************************
formats/smx_dsk.c
Specialist MX disk images
Specialist MX format
*********************************************************************/
#include <string.h>
#include "emu.h"
#include "formats/smx_dsk.h"
#include "smx_dsk.h"
#include "basicdsk.h"
static FLOPPY_IDENTIFY(smx_dsk_identify)
smx_format::smx_format() : wd177x_format(formats)
{
*vote = (floppy_image_size(floppy) == 819200) ? 100 : 0;
return FLOPPY_ERROR_SUCCESS;
}
static int smx_get_heads_per_disk(floppy_image_legacy *floppy)
const char *smx_format::name() const
{
return 2;
return "smx";
}
static int smx_get_tracks_per_disk(floppy_image_legacy *floppy)
const char *smx_format::description() const
{
return 80;
return "Specialist MX disk image";
}
static UINT64 smx_translate_offset(floppy_image_legacy *floppy,
int track, int head, int sector)
const char *smx_format::extensions() const
{
return (track * 1024 * 5 * 2) + (head * 1024 * 5) + 1024 * sector;
return "odi";
}
static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset)
// Unverified gap sizes
const smx_format::format smx_format::formats[] =
{
UINT64 offs;
/* translate the sector to a raw sector */
if (!sector_is_index)
{
sector -= 1;
}
/* check to see if we are out of range */
if ((head < 0) || (head >= 2) || (track < 0) || (track >= 80)
|| (sector < 0) || (sector >= 6))
return FLOPPY_ERROR_SEEKERROR;
{ // 720K 5.25 inch
floppy_image::FF_525, floppy_image::DSQD,
2000, 5, 80, 2, 1024, {}, 1, {}, 100, 22, 20
},
{}
};
offs = smx_translate_offset(floppy, track, head, sector);
if (offset)
*offset = offs;
return FLOPPY_ERROR_SUCCESS;
}
static floperr_t internal_smx_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
{
UINT64 offset;
floperr_t err;
err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
if (err)
return err;
floppy_image_read(floppy, buffer, offset, buflen);
return FLOPPY_ERROR_SUCCESS;
}
static floperr_t internal_smx_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam)
{
UINT64 offset;
floperr_t err;
err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
if (err)
return err;
floppy_image_write(floppy, buffer, offset, buflen);
return FLOPPY_ERROR_SUCCESS;
}
static floperr_t smx_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
{
return internal_smx_read_sector(floppy, head, track, sector, FALSE, buffer, buflen);
}
static floperr_t smx_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
{
return internal_smx_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam);
}
static floperr_t smx_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
{
return internal_smx_read_sector(floppy, head, track, sector, TRUE, buffer, buflen);
}
static floperr_t smx_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
{
return internal_smx_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam);
}
static floperr_t smx_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length)
{
floperr_t err;
err = get_offset(floppy, head, track, sector, FALSE, NULL);
if (err)
return err;
if (sector_length) {
*sector_length = 1024;
}
return FLOPPY_ERROR_SUCCESS;
}
static floperr_t smx_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags)
{
sector_index += 1;
if (cylinder)
*cylinder = track;
if (side)
*side = head;
if (sector)
*sector = sector_index;
if (flags)
/* TODO: read DAM or DDAM and determine flags */
*flags = 0;
return smx_get_sector_length(floppy, head, track, sector_index, sector_length);
}
static FLOPPY_CONSTRUCT(smx_dsk_construct)
{
struct FloppyCallbacks *callbacks;
callbacks = floppy_callbacks(floppy);
callbacks->read_sector = smx_read_sector;
callbacks->write_sector = smx_write_sector;
callbacks->read_indexed_sector = smx_read_indexed_sector;
callbacks->write_indexed_sector = smx_write_indexed_sector;
callbacks->get_sector_length = smx_get_sector_length;
callbacks->get_heads_per_disk = smx_get_heads_per_disk;
callbacks->get_tracks_per_disk = smx_get_tracks_per_disk;
callbacks->get_indexed_sector_info = smx_get_indexed_sector_info;
return FLOPPY_ERROR_SUCCESS;
}
/* ----------------------------------------------------------------------- */
LEGACY_FLOPPY_OPTIONS_START( specimx )
LEGACY_FLOPPY_OPTION( smx_dsk, "odi", "Specialist MX floppy disk image", smx_dsk_identify, smx_dsk_construct, NULL, NULL)
LEGACY_FLOPPY_OPTIONS_END
const floppy_format_type FLOPPY_SMX_FORMAT = &floppy_image_format_creator<smx_format>;

View File

@ -2,17 +2,27 @@
formats/smx_dsk.h
SVI318 disk images
Specialist MX disk images
*********************************************************************/
#ifndef SMX_DSK_H
#define SMX_DSK_H
#ifndef SMX_DSK_H_
#define SMX_DSK_H_
#include "flopimg.h"
#include "wd177x_dsk.h"
/**************************************************************************/
class smx_format : public wd177x_format {
public:
smx_format();
LEGACY_FLOPPY_OPTIONS_EXTERN(specimx);
virtual const char *name() const;
virtual const char *description() const;
virtual const char *extensions() const;
#endif /* SVI_DSK_H */
private:
static const format formats[];
};
extern const floppy_format_type FLOPPY_SMX_FORMAT;
#endif

View File

@ -379,6 +379,10 @@ static const cassette_interface special_cassette_interface =
NULL
};
FLOPPY_FORMATS_MEMBER( special_state::specimx_floppy_formats )
FLOPPY_SMX_FORMAT
FLOPPY_FORMATS_END
static SLOT_INTERFACE_START( specimx_floppies )
SLOT_INTERFACE( "525dd", FLOPPY_525_DD )
SLOT_INTERFACE_END
@ -446,8 +450,8 @@ static MACHINE_CONFIG_DERIVED( specimx, special )
/* Devices */
MCFG_FD1793x_ADD("fd1793", XTAL_8MHz / 8)
MCFG_FLOPPY_DRIVE_ADD("fd0", specimx_floppies, "525dd", 0, floppy_image_device::default_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("fd1", specimx_floppies, "525dd", 0, floppy_image_device::default_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("fd0", specimx_floppies, "525dd", 0, special_state::specimx_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("fd1", specimx_floppies, "525dd", 0, special_state::specimx_floppy_formats)
/* internal ram */
MCFG_RAM_ADD(RAM_TAG)
@ -485,8 +489,8 @@ static MACHINE_CONFIG_START( erik, special_state )
MCFG_I8255_ADD( "ppi8255", specialist_ppi8255_interface )
MCFG_FD1793x_ADD("fd1793", XTAL_8MHz / 8)
MCFG_FLOPPY_DRIVE_ADD("fd0", specimx_floppies, "525dd", 0, floppy_image_device::default_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("fd1", specimx_floppies, "525dd", 0, floppy_image_device::default_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("fd0", specimx_floppies, "525dd", 0, special_state::specimx_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("fd1", specimx_floppies, "525dd", 0, special_state::specimx_floppy_formats)
/* internal ram */
MCFG_RAM_ADD(RAM_TAG)

View File

@ -15,6 +15,7 @@
#include "machine/i8255.h"
#include "machine/pit8253.h"
#include "imagedev/cassette.h"
#include "formats/smx_dsk.h"
#include "formats/rk_cas.h"
#include "machine/wd_fdc.h"
#include "machine/ram.h"
@ -95,6 +96,7 @@ public:
TIMER_CALLBACK_MEMBER(special_reset);
TIMER_CALLBACK_MEMBER(setup_pit8253_gates);
void fdc_drq(bool state);
DECLARE_FLOPPY_FORMATS( specimx_floppy_formats );
};