mirror of
https://github.com/TomHarte/CLK.git
synced 2024-10-17 02:24:55 +00:00
Implemented single density version of format track.
This commit is contained in:
parent
0da02d3902
commit
7b8bb0297a
@ -531,32 +531,32 @@ void i8272::posit_event(int event_type) {
|
|||||||
begin_writing();
|
begin_writing();
|
||||||
|
|
||||||
// Write start-of-track.
|
// Write start-of-track.
|
||||||
// TODO: single density.
|
if(get_is_double_density()) {
|
||||||
for(int c = 0; c < 80; c++) {
|
for(int c = 0; c < 80; c++) write_byte(0x4e);
|
||||||
write_byte(0x4e);
|
for(int c = 0; c < 12; c++) write_byte(0x00);
|
||||||
}
|
for(int c = 0; c < 3; c++) write_raw_short(Storage::Encodings::MFM::MFMIndexSync);
|
||||||
for(int c = 0; c < 12; c++) {
|
|
||||||
write_byte(0x00);
|
|
||||||
}
|
|
||||||
for(int c = 0; c < 3; c++) {
|
|
||||||
write_raw_short(Storage::Encodings::MFM::MFMIndexSync);
|
|
||||||
}
|
|
||||||
write_byte(Storage::Encodings::MFM::IndexAddressByte);
|
write_byte(Storage::Encodings::MFM::IndexAddressByte);
|
||||||
for(int c = 0; c < 50; c++) {
|
for(int c = 0; c < 50; c++) write_byte(0x4e);
|
||||||
write_byte(0x4e);
|
} else {
|
||||||
|
for(int c = 0; c < 40; c++) write_byte(0xff);
|
||||||
|
for(int c = 0; c < 6; c++) write_byte(0x00);
|
||||||
|
write_raw_short(Storage::Encodings::MFM::FMIndexAddressMark);
|
||||||
|
for(int c = 0; c < 26; c++) write_byte(0xff);
|
||||||
}
|
}
|
||||||
WAIT_FOR_EVENT(Event::DataWritten);
|
WAIT_FOR_EVENT(Event::DataWritten);
|
||||||
sector_ = 0;
|
sector_ = 0;
|
||||||
|
|
||||||
format_track_write_sector:
|
format_track_write_sector:
|
||||||
for(int c = 0; c < 12; c++) {
|
if(get_is_double_density()) {
|
||||||
write_byte(0x00);
|
for(int c = 0; c < 12; c++) write_byte(0x00);
|
||||||
}
|
for(int c = 0; c < 3; c++) write_raw_short(Storage::Encodings::MFM::MFMSync);
|
||||||
for(int c = 0; c < 3; c++) {
|
|
||||||
write_raw_short(Storage::Encodings::MFM::MFMSync);
|
|
||||||
}
|
|
||||||
get_crc_generator().set_value(Storage::Encodings::MFM::MFMPostSyncCRCValue);
|
get_crc_generator().set_value(Storage::Encodings::MFM::MFMPostSyncCRCValue);
|
||||||
write_byte(Storage::Encodings::MFM::IDAddressByte);
|
write_byte(Storage::Encodings::MFM::IDAddressByte);
|
||||||
|
} else {
|
||||||
|
for(int c = 0; c < 6; c++) write_byte(0x00);
|
||||||
|
get_crc_generator().reset();
|
||||||
|
write_raw_short(Storage::Encodings::MFM::FMIDAddressMark);
|
||||||
|
}
|
||||||
|
|
||||||
// Write the sector header, obtaining its contents
|
// Write the sector header, obtaining its contents
|
||||||
// from the processor.
|
// from the processor.
|
||||||
@ -578,36 +578,38 @@ void i8272::posit_event(int event_type) {
|
|||||||
write_crc();
|
write_crc();
|
||||||
|
|
||||||
// Write the sector body.
|
// Write the sector body.
|
||||||
for(int c = 0; c < 22; c++) {
|
if(get_is_double_density()) {
|
||||||
write_byte(0x4e);
|
for(int c = 0; c < 22; c++) write_byte(0x4e);
|
||||||
}
|
for(int c = 0; c < 12; c++) write_byte(0x00);
|
||||||
for(int c = 0; c < 12; c++) {
|
for(int c = 0; c < 3; c++) write_raw_short(Storage::Encodings::MFM::MFMSync);
|
||||||
write_byte(0x00);
|
|
||||||
}
|
|
||||||
for(int c = 0; c < 3; c++) {
|
|
||||||
write_raw_short(Storage::Encodings::MFM::MFMSync);
|
|
||||||
}
|
|
||||||
get_crc_generator().set_value(Storage::Encodings::MFM::MFMPostSyncCRCValue);
|
get_crc_generator().set_value(Storage::Encodings::MFM::MFMPostSyncCRCValue);
|
||||||
write_byte(Storage::Encodings::MFM::DataAddressByte);
|
write_byte(Storage::Encodings::MFM::DataAddressByte);
|
||||||
|
} else {
|
||||||
|
for(int c = 0; c < 11; c++) write_byte(0xff);
|
||||||
|
for(int c = 0; c < 6; c++) write_byte(0x00);
|
||||||
|
get_crc_generator().reset();
|
||||||
|
write_raw_short(Storage::Encodings::MFM::FMDataAddressMark);
|
||||||
|
}
|
||||||
for(int c = 0; c < (128 << command_[2]); c++) {
|
for(int c = 0; c < (128 << command_[2]); c++) {
|
||||||
write_byte(command_[5]);
|
write_byte(command_[5]);
|
||||||
}
|
}
|
||||||
write_crc();
|
write_crc();
|
||||||
|
|
||||||
// Write the prescribed gap.
|
// Write the prescribed gap.
|
||||||
for(int c = 0; c < command_[4]; c++) {
|
if(get_is_double_density()) {
|
||||||
write_byte(0x4e);
|
for(int c = 0; c < command_[4]; c++) write_byte(0x4e);
|
||||||
|
} else {
|
||||||
|
for(int c = 0; c < command_[4]; c++) write_byte(0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consider repeating.
|
// Consider repeating.
|
||||||
sector_++;
|
sector_++;
|
||||||
if(sector_ < command_[3]) {
|
if(sector_ < command_[3])
|
||||||
goto format_track_write_sector;
|
goto format_track_write_sector;
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, pad out to the index hole.
|
// Otherwise, pad out to the index hole.
|
||||||
format_track_pad:
|
format_track_pad:
|
||||||
write_byte(0x4e);
|
write_byte(get_is_double_density() ? 0x4e : 0xff);
|
||||||
WAIT_FOR_EVENT((int)Event::DataWritten | (int)Event::IndexHole);
|
WAIT_FOR_EVENT((int)Event::DataWritten | (int)Event::IndexHole);
|
||||||
if(event_type != (int)Event::IndexHole) goto format_track_pad;
|
if(event_type != (int)Event::IndexHole) goto format_track_pad;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user