pc98: Add its specific almost raw fdi disk format [O. Galibert]

This commit is contained in:
Olivier Galibert 2012-12-04 19:18:15 +00:00
parent ba39484252
commit 9857a8770e
4 changed files with 171 additions and 4 deletions

View File

@ -0,0 +1,128 @@
/***************************************************************************
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/pc98fdi_dsk.h
PC98FDI disk images
*********************************************************************/
#include "emu.h"
#include "pc98fdi_dsk.h"
pc98fdi_format::pc98fdi_format()
{
}
const char *pc98fdi_format::name() const
{
return "pc98-fdi";
}
const char *pc98fdi_format::description() const
{
return "PC98 FDI disk image";
}
const char *pc98fdi_format::extensions() const
{
return "fdi";
}
int pc98fdi_format::identify(io_generic *io, UINT32 form_factor)
{
int size = io_generic_size(io);
UINT8 h[32];
io_generic_read(io, h, 0, 32);
int hsize = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x8));
int psize = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0xc));
int ssize = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x10));
int scnt = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x14));
int sides = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x18));
int ntrk = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x1c));
if(size == hsize + psize && psize == ssize*scnt*sides*ntrk)
return 100;
return 0;
}
bool pc98fdi_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
{
UINT8 h[32];
io_generic_read(io, h, 0, 32);
int hsize = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x8));
int sector_size = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x10));
int sector_count = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x14));
int head_count = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x18));
int track_count = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x1c));
int cell_count = form_factor == floppy_image::FF_35 ? 200000 : 166666;
int ssize;
for(ssize=0; (128 << ssize) < sector_size; ssize++);
desc_pc_sector sects[256];
UINT8 sect_data[65536];
for(int track=0; track < track_count; track++)
for(int head=0; head < head_count; head++) {
io_generic_read(io, sect_data, hsize + sector_size*sector_count*(track*head_count + head), sector_size*sector_count);
for(int i=0; i<sector_count; i++) {
sects[i].track = track;
sects[i].head = head;
sects[i].sector = i+1;
sects[i].size = ssize;
sects[i].actual_size = sector_size;
sects[i].deleted = false;
sects[i].bad_crc = false;
sects[i].data = sect_data + i*sector_size;
}
build_pc_track_mfm(track, head, image, cell_count, sector_count, sects, calc_default_pc_gap3_size(form_factor, sector_size));
}
return true;
}
bool pc98fdi_format::supports_save() const
{
return false;
}
const floppy_format_type FLOPPY_PC98FDI_FORMAT = &floppy_image_format_creator<pc98fdi_format>;

View File

@ -0,0 +1,31 @@
/*********************************************************************
formats/pc98fdi_dsk.h
PC98FDI disk images
*********************************************************************/
#ifndef PC98FDI_DSK_H
#define PC98FDI_DSK_H
#include "flopimg.h"
class pc98fdi_format : public floppy_image_format_t
{
public:
pc98fdi_format();
virtual int identify(io_generic *io, UINT32 form_factor);
virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
virtual const char *name() const;
virtual const char *description() const;
virtual const char *extensions() const;
virtual bool supports_save() const;
};
extern const floppy_format_type FLOPPY_PC98FDI_FORMAT;
#endif /* PC98FDI_DSK_H */

View File

@ -153,6 +153,7 @@ FORMATSOBJS = \
$(LIBOBJ)/formats/p6001_cas.o \
$(LIBOBJ)/formats/pasti_dsk.o \
$(LIBOBJ)/formats/pc_dsk.o \
$(LIBOBJ)/formats/pc98fdi_dsk.o \
$(LIBOBJ)/formats/pmd_cas.o \
$(LIBOBJ)/formats/primoptp.o \
$(LIBOBJ)/formats/pyldin_dsk.o \

View File

@ -271,6 +271,7 @@
#include "machine/ram.h"
#include "formats/mfi_dsk.h"
#include "formats/d88_dsk.h"
#include "formats/pc98fdi_dsk.h"
#define UPD1990A_TAG "upd1990a"
#define UPD8251_TAG "upd8251"
@ -470,6 +471,8 @@ public:
DECLARE_WRITE8_MEMBER(pc9821_window_bank_w);
DECLARE_READ32_MEMBER(pc9821_timestamp_r);
DECLARE_FLOPPY_FORMATS( floppy_formats );
void fdc_2hd_irq(bool state);
void fdc_2hd_drq(bool state);
void fdc_2dd_irq(bool state);
@ -3089,6 +3092,10 @@ static const ym2203_interface pc98_ym2203_intf =
DEVCB_LINE(pc9801_sound_irq)
};
FLOPPY_FORMATS_MEMBER( pc9801_state::floppy_formats )
FLOPPY_PC98FDI_FORMAT
FLOPPY_FORMATS_END
static MACHINE_CONFIG_START( pc9801, pc9801_state )
MCFG_CPU_ADD("maincpu", I8086, 5000000) //unknown clock
MCFG_CPU_PROGRAM_MAP(pc9801_map)
@ -3111,10 +3118,10 @@ static MACHINE_CONFIG_START( pc9801, pc9801_state )
MCFG_UPD765A_ADD("upd765_2hd", false, true)
MCFG_UPD765A_ADD("upd765_2dd", false, true)
MCFG_FLOPPY_DRIVE_ADD("upd765_2hd:0", pc9801_floppies, "525hd", 0, floppy_image_device::default_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("upd765_2hd:1", pc9801_floppies, "525hd", 0, floppy_image_device::default_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("upd765_2dd:0", pc9801_floppies, "525hd", 0, floppy_image_device::default_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("upd765_2dd:1", pc9801_floppies, "525hd", 0, floppy_image_device::default_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("upd765_2hd:0", pc9801_floppies, "525hd", 0, pc9801_state::floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("upd765_2hd:1", pc9801_floppies, "525hd", 0, pc9801_state::floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("upd765_2dd:0", pc9801_floppies, "525hd", 0, pc9801_state::floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("upd765_2dd:1", pc9801_floppies, "525hd", 0, pc9801_state::floppy_formats)
MCFG_SOFTWARE_LIST_ADD("disk_list","pc98")