Skip to content

Commit 16d4b2c

Browse files
committed
writing WIP
1 parent 7d76e22 commit 16d4b2c

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

ArduinoFloppyReader/ArduinoFloppyReader/GarduinoReaderWriter.cpp

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class MainWindow : public Gtk::ApplicationWindow
4646
Gtk::Label *partialCount = nullptr;
4747
builder->get_widget("partialCount", partialCount);
4848

49-
auto callback = [this, cylinderCount, sideLabel, goodCount, partialCount](const int currentTrack, const ArduinoFloppyReader::DiskSurface currentSide, const int retryCounter, const int sectorsFound, const int badSectorsFound) -> ArduinoFloppyReader::WriteResponse
49+
auto readerCallback = [this, cylinderCount, sideLabel, goodCount, partialCount](const int currentTrack, const ArduinoFloppyReader::DiskSurface currentSide, const int retryCounter, const int sectorsFound, const int badSectorsFound) -> ArduinoFloppyReader::WriteResponse
5050
{
5151
std::string side = (currentSide == ArduinoFloppyReader::DiskSurface::dsUpper ? "Upper" : "Lower");
5252
std::cout << "currentTrack: " << currentTrack << " side: " << side << "retryCount: " << retryCounter << std::endl;
@@ -89,7 +89,7 @@ class MainWindow : public Gtk::ApplicationWindow
8989
});
9090
Gtk::RadioButton *trackButton = nullptr;
9191
builder->get_widget("radio80", trackButton);
92-
copyButton->signal_clicked().connect([this, fileEntry, folderButton, typeSelector, trackButton, callback, portsCombo]()
92+
copyButton->signal_clicked().connect([this, fileEntry, folderButton, typeSelector, trackButton, readerCallback, portsCombo]()
9393
{
9494
Glib::ustring folder = folderButton->get_filename();
9595
Glib::ustring filename = folder + "/" + fileEntry->get_buffer()->get_text();
@@ -100,15 +100,48 @@ class MainWindow : public Gtk::ApplicationWindow
100100
ArduinoFloppyReader::ADFResult readerResult;
101101
if (typeSelector->get_active_text() == "ADF")
102102
{
103-
readerResult = writer.DiskToADF(std::wstring(filename.begin(), filename.end()), tracks80 ? 80 : 82, callback);
103+
readerResult = writer.DiskToADF(std::wstring(filename.begin(), filename.end()), tracks80 ? 80 : 82, readerCallback);
104104
}
105105
else
106106
{
107-
readerResult = writer.DiskToSCP(std::wstring(filename.begin(), filename.end()), tracks80 ? 80 : 82, 3, callback);
107+
readerResult = writer.DiskToSCP(std::wstring(filename.begin(), filename.end()), tracks80 ? 80 : 82, 3, readerCallback);
108108
}
109109
// Handle the result
110110
handleResult(writer, readerResult);
111111
});
112+
113+
auto writerCallback = [this](const int currentTrack, const ArduinoFloppyReader::DiskSurface currentSide, const bool isVerifyError) -> ArduinoFloppyReader::WriteResponse {
114+
std::string side = (currentSide == ArduinoFloppyReader::DiskSurface::dsUpper ? "Upper" : "Lower");
115+
std::cout << "writing: currentTrack: " << currentTrack << " side: " << side << std::endl;
116+
117+
// if (isVerifyError) {
118+
// switch (MessageBox(L"Verify error writing track.", L"Disk Write Error", MB_ABORTRETRYIGNORE)) {
119+
// case IDABORT: return ArduinoFloppyReader::WriteResponse::wrAbort;
120+
// case IDRETRY: return ArduinoFloppyReader::WriteResponse::wrRetry;
121+
// case IDIGNORE: return ArduinoFloppyReader::WriteResponse::wrSkipBadChecksums;
122+
// }
123+
// }
124+
// Just continue
125+
return ArduinoFloppyReader::WriteResponse::wrContinue;
126+
};
127+
Gtk::Entry *writeFileEntry = nullptr;
128+
builder->get_widget("writeFileEntry", writeFileEntry);
129+
Gtk::FileChooserButton *writeFolderSelector = nullptr;
130+
builder->get_widget("writeFolderSelector", writeFolderSelector);
131+
Gtk::Button *writeButton = nullptr;
132+
builder->get_widget("writeButton", writeButton);
133+
writeButton->signal_clicked().connect([this, writeFileEntry, writeFolderSelector, writerCallback, portsCombo]()
134+
{
135+
Glib::ustring folder = writeFolderSelector->get_filename();
136+
Glib::ustring filename = folder + "/" + writeFileEntry->get_buffer()->get_text();
137+
ArduinoFloppyReader::ADFWriter writer;
138+
Glib::ustring serial = portsCombo->get_active_text();
139+
writer.openDevice(std::wstring(serial.begin(), serial.end()));
140+
ArduinoFloppyReader::ADFResult readerResult;
141+
readerResult = writer.ADFToDisk(std::wstring(filename.begin(), filename.end()), false, false, writerCallback);
142+
// Handle the result
143+
handleResult(writer, readerResult);
144+
});
112145
}
113146

114147
virtual ~MainWindow() = default;
@@ -182,7 +215,7 @@ private
182215
}
183216
}
184217
}
185-
218+
186219
bool showQuestion(bool isQuestion, const std::string question)
187220
{
188221
Gtk::ButtonsType buttons = Gtk::BUTTONS_OK_CANCEL;

0 commit comments

Comments
 (0)