mirror of
https://github.com/holub/mame
synced 2025-04-16 13:34:55 +03:00
ap2_dsk: edd support [O. Galibert]
This commit is contained in:
parent
2d2afa9ed9
commit
f22371f389
@ -40,7 +40,7 @@ ROM_START( diskiing )
|
||||
ROM_END
|
||||
|
||||
FLOPPY_FORMATS_MEMBER( a2bus_diskiing_device::floppy_formats )
|
||||
FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT
|
||||
FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT, FLOPPY_EDD_FORMAT
|
||||
FLOPPY_FORMATS_END
|
||||
|
||||
//-------------------------------------------------
|
||||
|
@ -623,14 +623,14 @@ attotime floppy_image_device::get_next_transition(const attotime &from_when)
|
||||
if(!image || mon)
|
||||
return attotime::never;
|
||||
|
||||
int cells = image->get_track_size(cyl, ss);
|
||||
int cells = image->get_track_size(cyl, ss, subcyl);
|
||||
if(cells <= 1)
|
||||
return attotime::never;
|
||||
|
||||
attotime base;
|
||||
UINT32 position = find_position(base, from_when);
|
||||
|
||||
const UINT32 *buf = image->get_buffer(cyl, ss);
|
||||
const UINT32 *buf = image->get_buffer(cyl, ss, subcyl);
|
||||
int index = find_index(position, buf, cells);
|
||||
|
||||
if(index == -1)
|
||||
@ -661,16 +661,16 @@ void floppy_image_device::write_flux(const attotime &start, const attotime &end,
|
||||
for(int i=0; i != transition_count; i++)
|
||||
trans_pos[i] = find_position(base, transitions[i]);
|
||||
|
||||
int cells = image->get_track_size(cyl, ss);
|
||||
UINT32 *buf = image->get_buffer(cyl, ss);
|
||||
int cells = image->get_track_size(cyl, ss, subcyl);
|
||||
UINT32 *buf = image->get_buffer(cyl, ss, subcyl);
|
||||
|
||||
int index;
|
||||
if(cells)
|
||||
index = find_index(start_pos, buf, cells);
|
||||
else {
|
||||
index = 0;
|
||||
image->set_track_size(cyl, ss, 1);
|
||||
buf = image->get_buffer(cyl, ss);
|
||||
image->set_track_size(cyl, ss, 1, subcyl);
|
||||
buf = image->get_buffer(cyl, ss, subcyl);
|
||||
buf[cells++] = floppy_image::MG_N;
|
||||
}
|
||||
|
||||
@ -684,9 +684,9 @@ void floppy_image_device::write_flux(const attotime &start, const attotime &end,
|
||||
UINT32 pos = start_pos;
|
||||
int ti = 0;
|
||||
while(pos != end_pos) {
|
||||
if(image->get_track_size(cyl, ss) < cells+10) {
|
||||
image->set_track_size(cyl, ss, cells+200);
|
||||
buf = image->get_buffer(cyl, ss);
|
||||
if(image->get_track_size(cyl, ss, subcyl) < cells+10) {
|
||||
image->set_track_size(cyl, ss, cells+200, subcyl);
|
||||
buf = image->get_buffer(cyl, ss, subcyl);
|
||||
}
|
||||
UINT32 next_pos;
|
||||
if(ti != transition_count)
|
||||
@ -704,7 +704,7 @@ void floppy_image_device::write_flux(const attotime &start, const attotime &end,
|
||||
cur_mg = cur_mg == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A;
|
||||
}
|
||||
|
||||
image->set_track_size(cyl, ss, cells);
|
||||
image->set_track_size(cyl, ss, cells, subcyl);
|
||||
}
|
||||
|
||||
void floppy_image_device::write_zone(UINT32 *buf, int &cells, int &index, UINT32 spos, UINT32 epos, UINT32 mg)
|
||||
@ -812,7 +812,7 @@ void floppy_image_device::set_write_splice(const attotime &when)
|
||||
image_dirty = true;
|
||||
attotime base;
|
||||
int splice_pos = find_position(base, when);
|
||||
image->set_write_splice_position(cyl, ss, splice_pos);
|
||||
image->set_write_splice_position(cyl, ss, splice_pos, subcyl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1513,3 +1513,114 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
|
||||
}
|
||||
|
||||
const floppy_format_type FLOPPY_RWTS18_FORMAT = &floppy_image_format_creator<a2_rwts18_format>;
|
||||
|
||||
a2_edd_format::a2_edd_format() : floppy_image_format_t()
|
||||
{
|
||||
}
|
||||
|
||||
const char *a2_edd_format::name() const
|
||||
{
|
||||
return "a2_edd";
|
||||
}
|
||||
|
||||
const char *a2_edd_format::description() const
|
||||
{
|
||||
return "Apple II EDD Image";
|
||||
}
|
||||
|
||||
const char *a2_edd_format::extensions() const
|
||||
{
|
||||
return "edd";
|
||||
}
|
||||
|
||||
bool a2_edd_format::supports_save() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int a2_edd_format::identify(io_generic *io, UINT32 form_factor)
|
||||
{
|
||||
return io_generic_size(io) == 2244608 ? 50 : 0;
|
||||
}
|
||||
|
||||
UINT8 a2_edd_format::pick(const UINT8 *data, int pos)
|
||||
{
|
||||
return ((data[pos>>3] << 8) | data[(pos>>3)+1]) >> (8-(pos & 7));
|
||||
}
|
||||
|
||||
bool a2_edd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
|
||||
{
|
||||
UINT8 img[2244608];
|
||||
UINT8 nibble[16384], stream[16384];
|
||||
int npos[16384];
|
||||
io_generic_read(io, img, 0, 2244608);
|
||||
|
||||
for(int i=0; i<137; i++) {
|
||||
const UINT8 *trk = img + 16384*i;
|
||||
int pos = 0;
|
||||
int wpos = 0;
|
||||
while(pos < 16383*8) {
|
||||
UINT8 acc = pick(trk, pos);
|
||||
pos += 8;
|
||||
while(!(acc & 0x80) && pos < 16384*8) {
|
||||
acc <<= 1;
|
||||
if(trk[pos >> 3] & (0x80 >> (pos & 7)))
|
||||
acc |= 0x01;
|
||||
pos++;
|
||||
}
|
||||
if(acc & 0x80) {
|
||||
nibble[wpos] = acc;
|
||||
npos[wpos] = pos;
|
||||
wpos++;
|
||||
}
|
||||
}
|
||||
int nm = 0, nmj = 0, nmk = 0;
|
||||
for(int j=0; j<wpos-1; j++)
|
||||
for(int k=j+6200; k<wpos && k<j+6400; k++) {
|
||||
int m = 0;
|
||||
for(int l=0; k+l<wpos && nibble[j+l] == nibble[k+l]; l++)
|
||||
m++;
|
||||
if(m > nm) {
|
||||
nm = m;
|
||||
nmj = j;
|
||||
nmk = k;
|
||||
}
|
||||
}
|
||||
int delta = nmk - nmj;
|
||||
int spos = (wpos-delta)/2;
|
||||
int zpos = npos[spos];
|
||||
int epos = npos[spos+delta];
|
||||
int len = epos-zpos;
|
||||
int part1_size = zpos % len;
|
||||
int part1_bsize = part1_size >> 3;
|
||||
int part1_spos = epos-part1_size;
|
||||
int part2_offset = zpos - part1_size;
|
||||
int total_bsize = (len+7) >> 3;
|
||||
|
||||
for(int j=0; j<part1_bsize; j++)
|
||||
stream[j] = pick(trk, part1_spos + 8*j);
|
||||
stream[part1_bsize] =
|
||||
(pick(trk, part1_spos + 8*part1_bsize) & (0xff00 >> (part1_size & 7))) |
|
||||
(pick(trk, part2_offset + 8*part1_bsize) & (0x00ff >> (part1_size & 7)));
|
||||
for(int j=part1_bsize+1; j<total_bsize; j++)
|
||||
stream[j] = pick(trk, part2_offset + 8*j);
|
||||
|
||||
bool odd = false;
|
||||
for(int j=0; j<len; j++)
|
||||
if(stream[j>>3] & (0x80 >> (j & 7)))
|
||||
odd = !odd;
|
||||
|
||||
int splice_byte = spos;
|
||||
while(splice_byte < spos+delta && (npos[splice_byte+1] - npos[splice_byte] != 8 || npos[splice_byte+2] - npos[splice_byte+1] == 8 || npos[splice_byte+2] - npos[splice_byte+2] == 8))
|
||||
splice_byte++;
|
||||
int splice = (npos[splice_byte+2]-1) % len;
|
||||
if(odd)
|
||||
stream[splice >> 3] ^= 0x80 >> (splice & 7);
|
||||
|
||||
generate_track_from_bitstream(i >> 2, 0, stream, len, image, i & 3);
|
||||
image->set_write_splice_position(i >> 2, 0, UINT32(U64(200000000)*splice/len), i & 3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const floppy_format_type FLOPPY_EDD_FORMAT = &floppy_image_format_creator<a2_edd_format>;
|
||||
|
@ -80,4 +80,24 @@ private:
|
||||
|
||||
extern const floppy_format_type FLOPPY_RWTS18_FORMAT;
|
||||
|
||||
|
||||
class a2_edd_format : public floppy_image_format_t
|
||||
{
|
||||
public:
|
||||
a2_edd_format();
|
||||
|
||||
virtual int identify(io_generic *io, UINT32 form_factor);
|
||||
virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
|
||||
virtual bool supports_save() const;
|
||||
|
||||
virtual const char *name() const;
|
||||
virtual const char *description() const;
|
||||
virtual const char *extensions() const;
|
||||
|
||||
private:
|
||||
static UINT8 pick(const UINT8 *data, int pos);
|
||||
};
|
||||
|
||||
extern const floppy_format_type FLOPPY_EDD_FORMAT;
|
||||
|
||||
#endif /* AP2_DISK_H */
|
||||
|
@ -1647,11 +1647,11 @@ void floppy_image_format_t::normalize_times(UINT32 *buffer, int bitlen)
|
||||
}
|
||||
}
|
||||
|
||||
void floppy_image_format_t::generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image)
|
||||
void floppy_image_format_t::generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image, int subtrack)
|
||||
{
|
||||
// Maximal number of cells which happens when the buffer is all 1
|
||||
image->set_track_size(track, head, track_size+1);
|
||||
UINT32 *dest = image->get_buffer(track, head);
|
||||
image->set_track_size(track, head, track_size+1, subtrack);
|
||||
UINT32 *dest = image->get_buffer(track, head, subtrack);
|
||||
UINT32 *base = dest;
|
||||
|
||||
UINT32 cbit = floppy_image::MG_A;
|
||||
@ -1669,8 +1669,8 @@ void floppy_image_format_t::generate_track_from_bitstream(int track, int head, c
|
||||
|
||||
int size = dest - base;
|
||||
normalize_times(base, size);
|
||||
image->set_track_size(track, head, size);
|
||||
image->set_write_splice_position(track, head, 0);
|
||||
image->set_track_size(track, head, size, subtrack);
|
||||
image->set_write_splice_position(track, head, 0, subtrack);
|
||||
}
|
||||
|
||||
void floppy_image_format_t::generate_track_from_levels(int track, int head, UINT32 *trackbuf, int track_size, int splice_pos, floppy_image *image)
|
||||
@ -2166,9 +2166,9 @@ const floppy_image_format_t::desc_e floppy_image_format_t::amiga_22[] = {
|
||||
{ END }
|
||||
};
|
||||
|
||||
void floppy_image_format_t::generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image)
|
||||
void floppy_image_format_t::generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image, int subtrack)
|
||||
{
|
||||
int tsize = image->get_track_size(track, head);
|
||||
int tsize = image->get_track_size(track, head, subtrack);
|
||||
if(!tsize || tsize == 1) {
|
||||
// Unformatted track
|
||||
track_size = 200000000/cell_size;
|
||||
@ -2177,8 +2177,8 @@ void floppy_image_format_t::generate_bitstream_from_track(int track, int head, i
|
||||
}
|
||||
|
||||
// Start at the write splice
|
||||
const UINT32 *tbuf = image->get_buffer(track, head);
|
||||
UINT32 splice = image->get_write_splice_position(track, head);
|
||||
const UINT32 *tbuf = image->get_buffer(track, head, subtrack);
|
||||
UINT32 splice = image->get_write_splice_position(track, head, subtrack);
|
||||
int cur_pos = splice;
|
||||
int cur_entry = 0;
|
||||
while(cur_entry < tsize-1 && (tbuf[cur_entry+1] & floppy_image::TIME_MASK) < cur_pos)
|
||||
|
@ -381,7 +381,7 @@ protected:
|
||||
@param track_size in cells, not bytes.
|
||||
@param image
|
||||
*/
|
||||
void generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image);
|
||||
void generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image, int subtrack = 0);
|
||||
|
||||
//! @brief Generate a track from cell level values (0/1/W/D/N).
|
||||
|
||||
@ -477,7 +477,7 @@ protected:
|
||||
@endverbatim
|
||||
*/
|
||||
|
||||
void generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image);
|
||||
void generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image, int subtrack = 0);
|
||||
|
||||
//! Defines a standard sector for extracting.
|
||||
struct desc_xs {
|
||||
|
@ -41,7 +41,7 @@ static SLOT_INTERFACE_START( a3_floppies )
|
||||
SLOT_INTERFACE_END
|
||||
|
||||
FLOPPY_FORMATS_MEMBER( apple3_state::floppy_formats )
|
||||
FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT
|
||||
FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT, FLOPPY_EDD_FORMAT
|
||||
FLOPPY_FORMATS_END
|
||||
|
||||
static MACHINE_CONFIG_START( apple3, apple3_state )
|
||||
|
@ -70,6 +70,7 @@ static floppy_format_type floppy_formats[] = {
|
||||
FLOPPY_DC42_FORMAT,
|
||||
FLOPPY_A216S_FORMAT,
|
||||
FLOPPY_RWTS18_FORMAT,
|
||||
FLOPPY_EDD_FORMAT,
|
||||
|
||||
FLOPPY_ORIC_DSK_FORMAT,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user