mirror of
https://github.com/holub/mame
synced 2025-04-24 01:11:11 +03:00
floppy: Harmless intermediate commit that could help Micko (nw)
This commit is contained in:
parent
41a817b9dc
commit
6752a99aea
@ -12,12 +12,17 @@
|
||||
|
||||
// device type definition
|
||||
const device_type FLOPPY_CONNECTOR = &device_creator<floppy_connector>;
|
||||
const device_type FLOPPY_3_SSDD = &device_creator<floppy_3_ssdd>;
|
||||
const device_type FLOPPY_3_DSDD = &device_creator<floppy_3_dsdd>;
|
||||
const device_type FLOPPY_35_DD = &device_creator<floppy_35_dd>;
|
||||
const device_type FLOPPY_35_DD_NOSD = &device_creator<floppy_35_dd_nosd>;
|
||||
const device_type FLOPPY_35_HD = &device_creator<floppy_35_hd>;
|
||||
const device_type FLOPPY_35_ED = &device_creator<floppy_35_ed>;
|
||||
const device_type FLOPPY_525_SSDD = &device_creator<floppy_525_ssdd>;
|
||||
const device_type FLOPPY_525_DD = &device_creator<floppy_525_dd>;
|
||||
const device_type FLOPPY_525_QD = &device_creator<floppy_525_qd>;
|
||||
const device_type FLOPPY_525_HD = &device_creator<floppy_525_hd>;
|
||||
const device_type FLOPPY_8_SSSD = &device_creator<floppy_8_sssd>;
|
||||
|
||||
floppy_connector::floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
device_t(mconfig, FLOPPY_CONNECTOR, "Floppy drive connector abstraction", tag, owner, clock),
|
||||
@ -175,8 +180,6 @@ void floppy_image_device::device_start()
|
||||
|
||||
/* motor off */
|
||||
mon = 1;
|
||||
/* set write protect on */
|
||||
wpt = 0;
|
||||
|
||||
cyl = 0;
|
||||
ss = 1;
|
||||
@ -344,7 +347,7 @@ void floppy_image_device::index_resync()
|
||||
}
|
||||
}
|
||||
|
||||
int floppy_image_device::ready_r()
|
||||
bool floppy_image_device::ready_r()
|
||||
{
|
||||
if (exists())
|
||||
{
|
||||
@ -412,7 +415,7 @@ UINT32 floppy_image_device::find_position(attotime &base, attotime when)
|
||||
revc++;
|
||||
}
|
||||
|
||||
return (delta*(rpm/300)).as_ticks(1000000000);
|
||||
return (delta*rpm/300).as_ticks(1000000000);
|
||||
}
|
||||
|
||||
attotime floppy_image_device::get_next_transition(attotime from_when)
|
||||
@ -441,8 +444,8 @@ attotime floppy_image_device::get_next_transition(attotime from_when)
|
||||
else
|
||||
next_position = 200000000 + (buf[1] & floppy_image::TIME_MASK);
|
||||
|
||||
|
||||
return base + attotime::from_nsec(next_position*(300/rpm));
|
||||
// logerror("Floppy: cuspos=%d nextpos=%d\n", position, next_position);
|
||||
return base + attotime::from_nsec(UINT64(next_position)*300/rpm);
|
||||
}
|
||||
|
||||
void floppy_image_device::write_flux(attotime start, attotime end, int transition_count, const attotime *transitions)
|
||||
@ -760,6 +763,53 @@ void ui_menu_control_floppy_image::handle()
|
||||
}
|
||||
}
|
||||
|
||||
floppy_3_ssdd::floppy_3_ssdd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
floppy_image_device(mconfig, FLOPPY_3_SSDD, "3\" double sided floppy drive", tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
floppy_3_ssdd::~floppy_3_ssdd()
|
||||
{
|
||||
}
|
||||
|
||||
void floppy_3_ssdd::setup_characteristics()
|
||||
{
|
||||
form_factor = floppy_image::FF_3;
|
||||
tracks = 42;
|
||||
sides = 2;
|
||||
set_rpm(300);
|
||||
}
|
||||
|
||||
void floppy_3_ssdd::handled_variants(UINT32 *variants, int &var_count) const
|
||||
{
|
||||
var_count = 0;
|
||||
variants[var_count++] = floppy_image::SSDD;
|
||||
}
|
||||
|
||||
floppy_3_dsdd::floppy_3_dsdd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
floppy_image_device(mconfig, FLOPPY_3_DSDD, "3\" single sided floppy drive", tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
floppy_3_dsdd::~floppy_3_dsdd()
|
||||
{
|
||||
}
|
||||
|
||||
void floppy_3_dsdd::setup_characteristics()
|
||||
{
|
||||
form_factor = floppy_image::FF_3;
|
||||
tracks = 42;
|
||||
sides = 1;
|
||||
set_rpm(300);
|
||||
}
|
||||
|
||||
void floppy_3_dsdd::handled_variants(UINT32 *variants, int &var_count) const
|
||||
{
|
||||
var_count = 0;
|
||||
variants[var_count++] = floppy_image::SSDD;
|
||||
variants[var_count++] = floppy_image::DSDD;
|
||||
}
|
||||
|
||||
floppy_35_dd::floppy_35_dd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
floppy_image_device(mconfig, FLOPPY_35_DD, "3.5\" double density floppy drive", tag, owner, clock)
|
||||
{
|
||||
@ -862,6 +912,30 @@ void floppy_35_ed::handled_variants(UINT32 *variants, int &var_count) const
|
||||
variants[var_count++] = floppy_image::DSED;
|
||||
}
|
||||
|
||||
floppy_525_ssdd::floppy_525_ssdd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
floppy_image_device(mconfig, FLOPPY_525_SSDD, "5.25\" single-sided double density floppy drive", tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
floppy_525_ssdd::~floppy_525_ssdd()
|
||||
{
|
||||
}
|
||||
|
||||
void floppy_525_ssdd::setup_characteristics()
|
||||
{
|
||||
form_factor = floppy_image::FF_525;
|
||||
tracks = 42;
|
||||
sides = 1;
|
||||
set_rpm(300);
|
||||
}
|
||||
|
||||
void floppy_525_ssdd::handled_variants(UINT32 *variants, int &var_count) const
|
||||
{
|
||||
var_count = 0;
|
||||
variants[var_count++] = floppy_image::SSSD;
|
||||
variants[var_count++] = floppy_image::SSDD;
|
||||
}
|
||||
|
||||
floppy_525_dd::floppy_525_dd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
floppy_image_device(mconfig, FLOPPY_525_DD, "5.25\" double density floppy drive", tag, owner, clock)
|
||||
{
|
||||
@ -884,6 +958,34 @@ void floppy_525_dd::handled_variants(UINT32 *variants, int &var_count) const
|
||||
var_count = 0;
|
||||
variants[var_count++] = floppy_image::SSSD;
|
||||
variants[var_count++] = floppy_image::SSDD;
|
||||
variants[var_count++] = floppy_image::DSDD;
|
||||
}
|
||||
|
||||
floppy_525_qd::floppy_525_qd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
floppy_image_device(mconfig, FLOPPY_525_QD, "5.25\" quad density floppy drive", tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
floppy_525_qd::~floppy_525_qd()
|
||||
{
|
||||
}
|
||||
|
||||
void floppy_525_qd::setup_characteristics()
|
||||
{
|
||||
form_factor = floppy_image::FF_525;
|
||||
tracks = 84;
|
||||
sides = 2;
|
||||
set_rpm(300);
|
||||
}
|
||||
|
||||
void floppy_525_qd::handled_variants(UINT32 *variants, int &var_count) const
|
||||
{
|
||||
var_count = 0;
|
||||
variants[var_count++] = floppy_image::SSSD;
|
||||
variants[var_count++] = floppy_image::SSDD;
|
||||
variants[var_count++] = floppy_image::SSQD;
|
||||
variants[var_count++] = floppy_image::DSDD;
|
||||
variants[var_count++] = floppy_image::DSQD;
|
||||
}
|
||||
|
||||
floppy_525_hd::floppy_525_hd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
@ -898,9 +1000,9 @@ floppy_525_hd::~floppy_525_hd()
|
||||
void floppy_525_hd::setup_characteristics()
|
||||
{
|
||||
form_factor = floppy_image::FF_525;
|
||||
tracks = 82;
|
||||
tracks = 84;
|
||||
sides = 2;
|
||||
set_rpm(300);
|
||||
set_rpm(360);
|
||||
}
|
||||
|
||||
void floppy_525_hd::handled_variants(UINT32 *variants, int &var_count) const
|
||||
@ -908,7 +1010,31 @@ void floppy_525_hd::handled_variants(UINT32 *variants, int &var_count) const
|
||||
var_count = 0;
|
||||
variants[var_count++] = floppy_image::SSSD;
|
||||
variants[var_count++] = floppy_image::SSDD;
|
||||
variants[var_count++] = floppy_image::SSQD;
|
||||
variants[var_count++] = floppy_image::DSDD;
|
||||
variants[var_count++] = floppy_image::DSQD;
|
||||
variants[var_count++] = floppy_image::DSHD;
|
||||
|
||||
}
|
||||
|
||||
floppy_8_sssd::floppy_8_sssd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
floppy_image_device(mconfig, FLOPPY_8_SSSD, "8\" single density floppy drive", tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
floppy_8_sssd::~floppy_8_sssd()
|
||||
{
|
||||
}
|
||||
|
||||
void floppy_8_sssd::setup_characteristics()
|
||||
{
|
||||
form_factor = floppy_image::FF_8;
|
||||
tracks = 77;
|
||||
sides = 1;
|
||||
set_rpm(300);
|
||||
}
|
||||
|
||||
void floppy_8_sssd::handled_variants(UINT32 *variants, int &var_count) const
|
||||
{
|
||||
var_count = 0;
|
||||
variants[var_count++] = floppy_image::SSSD;
|
||||
}
|
||||
|
@ -66,13 +66,14 @@ public:
|
||||
UINT32 get_len() { return image->get_track_size(cyl, ss ^ 1); }
|
||||
|
||||
void mon_w(int state);
|
||||
int ready_r();
|
||||
bool ready_r();
|
||||
double get_pos();
|
||||
|
||||
int wpt_r() { return wpt; }
|
||||
bool wpt_r() { return output_format == 0; }
|
||||
int dskchg_r() { return dskchg; }
|
||||
bool trk00_r() { return cyl != 0; }
|
||||
int idx_r() { return idx; }
|
||||
bool ss_r() { return ss; }
|
||||
|
||||
void stp_w(int state);
|
||||
void dir_w(int state) { dir = state; }
|
||||
@ -160,6 +161,28 @@ protected:
|
||||
virtual void hook_load(astring filename, bool softlist);
|
||||
};
|
||||
|
||||
class floppy_3_ssdd : public floppy_image_device {
|
||||
public:
|
||||
floppy_3_ssdd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~floppy_3_ssdd();
|
||||
virtual void handled_variants(UINT32 *variants, int &var_count) const;
|
||||
virtual void device_config_complete() { m_shortname = "floppy_3_ssdd"; }
|
||||
virtual const char *image_interface() const { return "floppy_3"; }
|
||||
protected:
|
||||
virtual void setup_characteristics();
|
||||
};
|
||||
|
||||
class floppy_3_dsdd : public floppy_image_device {
|
||||
public:
|
||||
floppy_3_dsdd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~floppy_3_dsdd();
|
||||
virtual void handled_variants(UINT32 *variants, int &var_count) const;
|
||||
virtual void device_config_complete() { m_shortname = "floppy_3_dsdd"; }
|
||||
virtual const char *image_interface() const { return "floppy_3"; }
|
||||
protected:
|
||||
virtual void setup_characteristics();
|
||||
};
|
||||
|
||||
class floppy_35_dd : public floppy_image_device {
|
||||
public:
|
||||
floppy_35_dd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
@ -204,6 +227,17 @@ protected:
|
||||
virtual void setup_characteristics();
|
||||
};
|
||||
|
||||
class floppy_525_ssdd : public floppy_image_device {
|
||||
public:
|
||||
floppy_525_ssdd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~floppy_525_ssdd();
|
||||
virtual void handled_variants(UINT32 *variants, int &var_count) const;
|
||||
virtual void device_config_complete() { m_shortname = "floppy_525_ssdd"; }
|
||||
virtual const char *image_interface() const { return "floppy_5_25"; }
|
||||
protected:
|
||||
virtual void setup_characteristics();
|
||||
};
|
||||
|
||||
class floppy_525_dd : public floppy_image_device {
|
||||
public:
|
||||
floppy_525_dd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
@ -215,6 +249,16 @@ protected:
|
||||
virtual void setup_characteristics();
|
||||
};
|
||||
|
||||
class floppy_525_qd : public floppy_image_device {
|
||||
public:
|
||||
floppy_525_qd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~floppy_525_qd();
|
||||
virtual void handled_variants(UINT32 *variants, int &var_count) const;
|
||||
virtual void device_config_complete() { m_shortname = "floppy_525_qd"; }
|
||||
virtual const char *image_interface() const { return "floppy_5_25"; }
|
||||
protected:
|
||||
virtual void setup_characteristics();
|
||||
};
|
||||
|
||||
class floppy_525_hd : public floppy_image_device {
|
||||
public:
|
||||
@ -227,6 +271,17 @@ protected:
|
||||
virtual void setup_characteristics();
|
||||
};
|
||||
|
||||
class floppy_8_sssd : public floppy_image_device {
|
||||
public:
|
||||
floppy_8_sssd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~floppy_8_sssd();
|
||||
virtual void handled_variants(UINT32 *variants, int &var_count) const;
|
||||
virtual void device_config_complete() { m_shortname = "floppy_8_sssd"; }
|
||||
virtual const char *image_interface() const { return "floppy_8"; }
|
||||
protected:
|
||||
virtual void setup_characteristics();
|
||||
};
|
||||
|
||||
class floppy_connector: public device_t,
|
||||
public device_slot_interface
|
||||
{
|
||||
@ -248,11 +303,16 @@ private:
|
||||
|
||||
// device type definition
|
||||
extern const device_type FLOPPY_CONNECTOR;
|
||||
extern const device_type FLOPPY_3_SSDD;
|
||||
extern const device_type FLOPPY_3_DSDD;
|
||||
extern const device_type FLOPPY_35_DD;
|
||||
extern const device_type FLOPPY_35_DD_NOSD;
|
||||
extern const device_type FLOPPY_35_HD;
|
||||
extern const device_type FLOPPY_35_ED;
|
||||
extern const device_type FLOPPY_525_SSDD;
|
||||
extern const device_type FLOPPY_525_DD;
|
||||
extern const device_type FLOPPY_525_QD;
|
||||
extern const device_type FLOPPY_525_HD;
|
||||
extern const device_type FLOPPY_8_SSSD;
|
||||
|
||||
#endif /* FLOPPY_H */
|
||||
|
@ -376,3 +376,220 @@ FLOPPY_CONSTRUCT(d88_dsk_construct)
|
||||
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
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/d88_dsk.h
|
||||
|
||||
D88 disk images
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "d88_dsk.h"
|
||||
|
||||
d88_format::d88_format()
|
||||
{
|
||||
}
|
||||
|
||||
const char *d88_format::name() const
|
||||
{
|
||||
return "d88";
|
||||
}
|
||||
|
||||
const char *d88_format::description() const
|
||||
{
|
||||
return "D88 disk image";
|
||||
}
|
||||
|
||||
const char *d88_format::extensions() const
|
||||
{
|
||||
return "d77,d88,1dd";
|
||||
}
|
||||
|
||||
int d88_format::identify(io_generic *io, UINT32 form_factor)
|
||||
{
|
||||
int size = io_generic_size(io);
|
||||
UINT8 h[32];
|
||||
|
||||
io_generic_read(io, h, 0, 32);
|
||||
if((LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x1c)) == size) &&
|
||||
(h[0x1b] == 0x00 || h[0x1b] == 0x10 || h[0x1b] == 0x20 || h[0x1b] == 0x30 || h[0x1b] == 0x40))
|
||||
return 100;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool d88_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
|
||||
{
|
||||
UINT8 h[32];
|
||||
|
||||
io_generic_read(io, h, 0, 32);
|
||||
|
||||
int cell_count = 0;
|
||||
int track_count = 0;
|
||||
int head_count = 0;
|
||||
switch(h[0x1b]) {
|
||||
case 0x00:
|
||||
cell_count = 100000;
|
||||
track_count = 42;
|
||||
head_count = 2;
|
||||
image->set_variant(floppy_image::DSDD);
|
||||
break;
|
||||
|
||||
case 0x10:
|
||||
cell_count = 100000;
|
||||
track_count = 82;
|
||||
head_count = 2;
|
||||
image->set_variant(floppy_image::DSQD);
|
||||
break;
|
||||
|
||||
case 0x20:
|
||||
cell_count = form_factor == floppy_image::FF_35 ? 200000 : 166666;
|
||||
track_count = 82;
|
||||
head_count = 2;
|
||||
image->set_variant(floppy_image::DSHD);
|
||||
break;
|
||||
|
||||
case 0x30:
|
||||
cell_count = 100000;
|
||||
track_count = 42;
|
||||
head_count = 1;
|
||||
image->set_variant(floppy_image::SSDD);
|
||||
break;
|
||||
|
||||
case 0x40:
|
||||
cell_count = 100000;
|
||||
track_count = 82;
|
||||
head_count = 1;
|
||||
image->set_variant(floppy_image::SSQD);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!head_count)
|
||||
return false;
|
||||
|
||||
UINT32 track_pos[164];
|
||||
io_generic_read(io, track_pos, 32, 164*4);
|
||||
|
||||
for(int track=0; track < track_count; track++)
|
||||
for(int head=0; head < head_count; head++) {
|
||||
int pos = LITTLE_ENDIANIZE_INT32(track_pos[track * head_count + head]);
|
||||
if(!pos)
|
||||
continue;
|
||||
|
||||
UINT32 track_data[210000];
|
||||
UINT8 sect_data[65536];
|
||||
int tpos = 0;
|
||||
|
||||
// gap 4a , IAM and gap 1
|
||||
for(int i=0; i<80; i++) mfm_w(track_data, tpos, 8, 0x4e);
|
||||
for(int i=0; i<12; i++) mfm_w(track_data, tpos, 8, 0x00);
|
||||
for(int i=0; i< 3; i++) raw_w(track_data, tpos, 16, 0x5224);
|
||||
mfm_w(track_data, tpos, 8, 0xfc);
|
||||
for(int i=0; i<50; i++) mfm_w(track_data, tpos, 8, 0x4e);
|
||||
|
||||
// Updated after reading the first header
|
||||
int sector_count = 1;
|
||||
int gap3 = 84;
|
||||
for(int i=0; i<sector_count; i++) {
|
||||
UINT8 hs[16];
|
||||
io_generic_read(io, hs, pos, 16);
|
||||
UINT16 size = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+14));
|
||||
io_generic_read(io, sect_data, pos+16, size);
|
||||
pos += 16+size;
|
||||
|
||||
if(i == 0) {
|
||||
sector_count = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+4));
|
||||
if(size < 512)
|
||||
gap3 = form_factor == floppy_image::FF_35 ? 54 : 50;
|
||||
else
|
||||
gap3 = form_factor == floppy_image::FF_35 ? 84 : 80;
|
||||
}
|
||||
|
||||
int cpos;
|
||||
UINT16 crc;
|
||||
// sync and IDAM and gap 2
|
||||
for(int j=0; j<12; j++) mfm_w(track_data, tpos, 8, 0x00);
|
||||
cpos = tpos;
|
||||
for(int j=0; j< 3; j++) raw_w(track_data, tpos, 16, 0x4489);
|
||||
mfm_w(track_data, tpos, 8, 0xfe);
|
||||
mfm_w(track_data, tpos, 8, hs[0]);
|
||||
mfm_w(track_data, tpos, 8, hs[1]);
|
||||
mfm_w(track_data, tpos, 8, hs[2]);
|
||||
mfm_w(track_data, tpos, 8, hs[3]);
|
||||
crc = calc_crc_ccitt(track_data, cpos, tpos);
|
||||
mfm_w(track_data, tpos, 16, crc);
|
||||
for(int j=0; j<22; j++) mfm_w(track_data, tpos, 8, 0x4e);
|
||||
|
||||
// sync, DAM, data and gap 3
|
||||
for(int j=0; j<12; j++) mfm_w(track_data, tpos, 8, 0x00);
|
||||
cpos = tpos;
|
||||
for(int j=0; j< 3; j++) raw_w(track_data, tpos, 16, 0x4489);
|
||||
mfm_w(track_data, tpos, 8, 0xfb);
|
||||
for(int j=0; j<size; j++) mfm_w(track_data, tpos, 8, sect_data[j]);
|
||||
crc = calc_crc_ccitt(track_data, cpos, tpos);
|
||||
mfm_w(track_data, tpos, 16, crc);
|
||||
for(int j=0; j<gap3; j++) mfm_w(track_data, tpos, 8, 0x4e);
|
||||
}
|
||||
|
||||
// Gap 4b
|
||||
|
||||
if(tpos > cell_count)
|
||||
throw emu_fatalerror("d88_format: Incorrect layout on track %d head %d, expected_size=%d, current_size=%d", track, head, cell_count, tpos);
|
||||
while(tpos < cell_count-15) mfm_w(track_data, tpos, 8, 0x4e);
|
||||
raw_w(track_data, tpos, cell_count-tpos, 0x9254 >> (16+tpos-cell_count));
|
||||
|
||||
generate_track_from_levels(track, head, track_data, cell_count, 0, image);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool d88_format::save(io_generic *io, floppy_image *image)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool d88_format::supports_save() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const floppy_format_type FLOPPY_D88_FORMAT = &floppy_image_format_creator<d88_format>;
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*********************************************************************
|
||||
|
||||
formats/d88_dsk.h
|
||||
|
||||
D88 disk images
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef D88_DSK_H
|
||||
#define D88_DSK_H
|
||||
|
||||
#include "flopimg.h"
|
||||
|
||||
|
||||
class d88_format : public floppy_image_format_t
|
||||
{
|
||||
public:
|
||||
d88_format();
|
||||
|
||||
virtual int identify(io_generic *io, UINT32 form_factor);
|
||||
virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
|
||||
virtual bool save(io_generic *io, 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_D88_FORMAT;
|
||||
|
||||
#endif /* D88_DSK_H */
|
@ -608,15 +608,19 @@ public:
|
||||
//! Form factors
|
||||
enum {
|
||||
FF_UNKNOWN = 0x00000000, //!< Unknown, useful when converting
|
||||
FF_3 = 0x20202033, //!< "3 " 3 inch disk
|
||||
FF_35 = 0x20203533, //!< "35 " 3.5 inch disk
|
||||
FF_525 = 0x20353235, //!< "525 " 5.25 inch disk
|
||||
FF_8 = 0x20202038, //!< "8 " 8 inch disk
|
||||
};
|
||||
|
||||
//! Variants
|
||||
enum {
|
||||
SSSD = 0x44535353, //!< "SSSD", Single-sided single-density
|
||||
SSDD = 0x44445353, //!< "DSSD", Double-sided single-density
|
||||
DSDD = 0x44445344, //!< "DSDD", Double-sided double-density (720K)
|
||||
SSDD = 0x44445353, //!< "SSDD", Single-sided double-density
|
||||
SSQD = 0x44515353, //!< "SSQD", Single-sided quad-density
|
||||
DSDD = 0x44445344, //!< "DSDD", Double-sided double-density (720K in 3.5, 360K in 5.25)
|
||||
DSQD = 0x44515344, //!< "DSQD", Double-sided quad-density (720K in 5.25, means DD+80 tracks)
|
||||
DSHD = 0x44485344, //!< "DSHD", Double-sided high-density (1440K)
|
||||
DSED = 0x44455344, //!< "DSED", Double-sided extra-density (2880K)
|
||||
};
|
||||
|
@ -0,0 +1,194 @@
|
||||
/***************************************************************************
|
||||
|
||||
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/upd765_dsk.h
|
||||
|
||||
helper for simple upd765-formatted disk images
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "formats/upd765_dsk.h"
|
||||
|
||||
upd765_format::upd765_format(const format *_formats)
|
||||
{
|
||||
formats = _formats;
|
||||
}
|
||||
|
||||
int upd765_format::find_size(io_generic *io, UINT32 form_factor)
|
||||
{
|
||||
int size = io_generic_size(io);
|
||||
for(int i=0; formats[i].form_factor; i++) {
|
||||
if(form_factor != floppy_image::FF_UNKNOWN && form_factor != formats[i].form_factor)
|
||||
continue;
|
||||
|
||||
int format_size;
|
||||
if(formats[i].sector_base_size)
|
||||
format_size = formats[i].sector_base_size * formats[i].sector_count;
|
||||
else {
|
||||
format_size = 0;
|
||||
for(int j=0; j != formats[i].sector_count; j++)
|
||||
format_size += formats[i].per_sector_size[j];
|
||||
}
|
||||
|
||||
format_size *= formats[i].track_count * formats[i].head_count;
|
||||
|
||||
if(size == format_size)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int upd765_format::identify(io_generic *io, UINT32 form_factor)
|
||||
{
|
||||
int type = find_size(io, form_factor);
|
||||
|
||||
if(type != -1)
|
||||
return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool upd765_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
|
||||
{
|
||||
int type = find_size(io, form_factor);
|
||||
if(type == -1)
|
||||
return false;
|
||||
|
||||
const format &f = formats[type];
|
||||
|
||||
floppy_image_format_t::desc_e desc[] = {
|
||||
/* 00 */ { MFM, 0x4e, f.gap_4a },
|
||||
/* 01 */ { MFM, 0x00, 12 },
|
||||
/* 02 */ { RAW, 0x5224, 3 },
|
||||
/* 03 */ { MFM, 0xfc, 1 },
|
||||
/* 04 */ { MFM, 0x4e, f.gap_1 },
|
||||
/* 05 */ { SECTOR_LOOP_START, 0, f.sector_count-1 },
|
||||
/* 06 */ { MFM, 0x00, 12 },
|
||||
/* 07 */ { CRC_CCITT_START, 1 },
|
||||
/* 08 */ { RAW, 0x4489, 3 },
|
||||
/* 09 */ { MFM, 0xfe, 1 },
|
||||
/* 10 */ { TRACK_ID },
|
||||
/* 11 */ { HEAD_ID },
|
||||
/* 12 */ { SECTOR_ID },
|
||||
/* 13 */ { SIZE_ID },
|
||||
/* 14 */ { CRC_END, 1 },
|
||||
/* 15 */ { CRC, 1 },
|
||||
/* 16 */ { MFM, 0x4e, f.gap_2 },
|
||||
/* 17 */ { MFM, 0x00, 12 },
|
||||
/* 18 */ { CRC_CCITT_START, 2 },
|
||||
/* 19 */ { RAW, 0x4489, 3 },
|
||||
/* 20 */ { MFM, 0xfb, 1 },
|
||||
/* 21 */ { SECTOR_DATA, -1 },
|
||||
/* 22 */ { CRC_END, 2 },
|
||||
/* 23 */ { CRC, 2 },
|
||||
/* 24 */ { MFM, 0x4e, f.gap_3 },
|
||||
/* 25 */ { SECTOR_LOOP_END },
|
||||
/* 26 */ { MFM, 0x4e, 0 },
|
||||
/* 27 */ { RAWBITS, 0x9254, 0 },
|
||||
/* 28 */ { END }
|
||||
};
|
||||
|
||||
int current_size = (f.gap_4a+12+3+1+f.gap_1)*16;
|
||||
if(f.sector_base_size)
|
||||
current_size += f.sector_base_size * f.sector_count * 16;
|
||||
else {
|
||||
for(int j=0; j != f.sector_count; j++)
|
||||
current_size += f.per_sector_size[j] * 16;
|
||||
}
|
||||
current_size += (12+3+1+4+2+f.gap_2+12+3+1+2+f.gap_3) * f.sector_count * 16;
|
||||
|
||||
int total_size = 200000000/f.cell_size;
|
||||
int remaining_size = total_size - current_size;
|
||||
if(remaining_size < 0)
|
||||
throw emu_fatalerror("upd765_format: Incorrect track layout, max_size=%d, current_size=%d", total_size, current_size);
|
||||
|
||||
// Fixup the end gap
|
||||
desc[26].p2 = remaining_size / 16;
|
||||
desc[27].p2 = remaining_size & 15;
|
||||
desc[27].p1 >>= 16-(remaining_size & 15);
|
||||
|
||||
int track_size;
|
||||
if(f.sector_base_size)
|
||||
track_size = f.sector_base_size * f.sector_count;
|
||||
else {
|
||||
track_size = 0;
|
||||
for(int i=0; i != f.sector_count; i++)
|
||||
track_size += f.per_sector_size[i];
|
||||
}
|
||||
|
||||
UINT8 sectdata[40*512];
|
||||
desc_s sectors[40];
|
||||
if(f.sector_base_id == -1) {
|
||||
for(int i=0; i<f.sector_count; i++) {
|
||||
int cur_offset = 0;
|
||||
for(int j=0; j<f.sector_count; j++)
|
||||
if(f.per_sector_id[j] < f.per_sector_id[i])
|
||||
cur_offset += f.sector_base_size ? f.sector_base_size : f.per_sector_size[j];
|
||||
sectors[i].data = sectdata + cur_offset;
|
||||
sectors[i].size = f.sector_base_size ? f.sector_base_size : f.per_sector_size[i];
|
||||
sectors[i].sector_id = f.per_sector_id[i];
|
||||
}
|
||||
} else {
|
||||
int cur_offset = 0;
|
||||
for(int i=0; i<f.sector_count; i++) {
|
||||
sectors[i].data = sectdata + cur_offset;
|
||||
sectors[i].size = f.sector_base_size ? f.sector_base_size : f.per_sector_size[i];
|
||||
cur_offset += sectors[i].size;
|
||||
sectors[i].sector_id = i + f.sector_base_id;
|
||||
}
|
||||
}
|
||||
|
||||
for(int track=0; track < f.track_count; track++)
|
||||
for(int head=0; head < f.head_count; head++) {
|
||||
io_generic_read(io, sectdata, (track*f.head_count + head)*track_size, track_size);
|
||||
generate_track(desc, track, head, sectors, f.sector_count, total_size, image);
|
||||
}
|
||||
|
||||
image->set_variant(f.variant);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool upd765_format::save(io_generic *io, floppy_image *image)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool upd765_format::supports_save() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*********************************************************************
|
||||
|
||||
formats/upd765_dsk.h
|
||||
|
||||
helper for simple upd765-formatted disk images
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef UPD765_DSK_H
|
||||
#define UPD765_DSK_H
|
||||
|
||||
#include "flopimg.h"
|
||||
|
||||
class upd765_format : public floppy_image_format_t
|
||||
{
|
||||
public:
|
||||
struct format {
|
||||
UINT32 form_factor; // See floppy_image for possible values
|
||||
UINT32 variant; // See floppy_image for possible values
|
||||
|
||||
int cell_size; // See floppy_image_format_t for details
|
||||
int sector_count;
|
||||
int track_count;
|
||||
int head_count;
|
||||
int sector_base_size;
|
||||
int per_sector_size[40]; // if sector_base_size is 0
|
||||
int sector_base_id; // 0 or 1 usually, -1 if there's interleave
|
||||
int per_sector_id[40]; // if sector_base_id is -1. If both per are used, then sector per_sector_id[i] has size per_sector_size[i]
|
||||
int gap_4a; // Usually 80 - number of 4e between index and IAM sync
|
||||
int gap_1; // Usually 50 - number of 4e between IAM and first IDAM sync
|
||||
int gap_2; // 22 for <=1.44Mb, 41 for 2.88Mb - number of 4e between sector header and data sync
|
||||
int gap_3; // Usually 84 - number of 4e between sector crc and next IDAM
|
||||
};
|
||||
|
||||
// End the array with {}
|
||||
upd765_format(const format *formats);
|
||||
|
||||
virtual int identify(io_generic *io, UINT32 form_factor);
|
||||
virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
|
||||
virtual bool save(io_generic *io, floppy_image *image);
|
||||
virtual bool supports_save() const;
|
||||
|
||||
private:
|
||||
const format *formats;
|
||||
int find_size(io_generic *io, UINT32 form_factor);
|
||||
};
|
||||
|
||||
#endif /* UPD765_DSK_H */
|
@ -0,0 +1,77 @@
|
||||
/***************************************************************************
|
||||
|
||||
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/xdf_dsk.c
|
||||
|
||||
x68k bare-bones formats
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "formats/xdf_dsk.h"
|
||||
|
||||
xdf_format::xdf_format() : upd765_format(formats)
|
||||
{
|
||||
}
|
||||
|
||||
const char *xdf_format::name() const
|
||||
{
|
||||
return "xdf";
|
||||
}
|
||||
|
||||
const char *xdf_format::description() const
|
||||
{
|
||||
return "XDF disk image";
|
||||
}
|
||||
|
||||
const char *xdf_format::extensions() const
|
||||
{
|
||||
return "xdf,hdm,2hd";
|
||||
}
|
||||
|
||||
// Unverified gap sizes
|
||||
const xdf_format::format xdf_format::formats[] = {
|
||||
{
|
||||
floppy_image::FF_525, floppy_image::DSHD,
|
||||
1200, // 1us, 360rpm
|
||||
8, 77, 2,
|
||||
1024, {},
|
||||
1, {},
|
||||
80, 50, 22, 84
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
const floppy_format_type FLOPPY_XDF_FORMAT = &floppy_image_format_creator<xdf_format>;
|
@ -0,0 +1,28 @@
|
||||
/*********************************************************************
|
||||
|
||||
formats/xdf_dsk.h
|
||||
|
||||
x68k bare-bones formats
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef XDF_DSK_H_
|
||||
#define XDF_DSK_H_
|
||||
|
||||
#include "upd765_dsk.h"
|
||||
|
||||
class xdf_format : public upd765_format {
|
||||
public:
|
||||
xdf_format();
|
||||
|
||||
virtual const char *name() const;
|
||||
virtual const char *description() const;
|
||||
virtual const char *extensions() const;
|
||||
|
||||
private:
|
||||
static const format formats[];
|
||||
};
|
||||
|
||||
extern const floppy_format_type FLOPPY_XDF_FORMAT;
|
||||
|
||||
#endif
|
@ -161,6 +161,7 @@ FORMATSOBJS = \
|
||||
$(LIBOBJ)/formats/tvc_cas.o \
|
||||
$(LIBOBJ)/formats/tzx_cas.o \
|
||||
$(LIBOBJ)/formats/uef_cas.o \
|
||||
$(LIBOBJ)/formats/upd765_dsk.o \
|
||||
$(LIBOBJ)/formats/vg5k_cas.o \
|
||||
$(LIBOBJ)/formats/vt_cas.o \
|
||||
$(LIBOBJ)/formats/vt_dsk.o \
|
||||
@ -168,6 +169,7 @@ FORMATSOBJS = \
|
||||
$(LIBOBJ)/formats/wavfile.o \
|
||||
$(LIBOBJ)/formats/x07_cas.o \
|
||||
$(LIBOBJ)/formats/x1_tap.o \
|
||||
$(LIBOBJ)/formats/xdf_dsk.o \
|
||||
$(LIBOBJ)/formats/z80ne_dsk.o \
|
||||
$(LIBOBJ)/formats/zx81_p.o \
|
||||
$(LIBOBJ)/formats/hxcmfm_dsk.o \
|
||||
|
Loading…
Reference in New Issue
Block a user