@@ -298,27 +298,31 @@ void MainWindow::build_operations_menu(QVBoxLayout* target_layout) {
298
298
this ->button_read_cartridge = new QPushButton (" Read P2000T Cartridge" );
299
299
this ->button_flash_rom = new QPushButton (" Write ROM" );
300
300
this ->button_flash_bank = new QPushButton (" Write ROM to bank" );
301
+ this ->button_scan_slots = new QPushButton (" Scan slots" );
301
302
302
303
layout->addWidget (this ->button_identify_chip );
303
304
layout->addWidget (this ->button_read_rom );
304
305
layout->addWidget (this ->button_read_cartridge );
305
306
layout->addWidget (this ->button_flash_rom );
306
307
layout->addWidget (this ->button_flash_bank );
307
308
layout->addWidget (this ->button_erase_chip );
309
+ layout->addWidget (this ->button_scan_slots );
308
310
309
311
this ->button_identify_chip ->setEnabled (false );
310
312
this ->button_erase_chip ->setEnabled (false );
311
313
this ->button_read_cartridge ->setEnabled (false );
312
314
this ->button_read_rom ->setEnabled (false );
313
315
this ->button_flash_rom ->setEnabled (false );
314
316
this ->button_flash_bank ->setEnabled (false );
317
+ this ->button_scan_slots ->setEnabled (false );
315
318
316
319
connect (this ->button_read_rom , SIGNAL (released ()), this , SLOT (read_rom ()));
317
320
connect (this ->button_read_cartridge , SIGNAL (released ()), this , SLOT (read_cartridge ()));
318
321
connect (this ->button_flash_rom , SIGNAL (released ()), this , SLOT (flash_rom ()));
319
322
connect (this ->button_identify_chip , SIGNAL (released ()), this , SLOT (read_chip_id ()));
320
323
connect (this ->button_flash_bank , SIGNAL (released ()), this , SLOT (flash_bank ()));
321
324
connect (this ->button_erase_chip , SIGNAL (released ()), this , SLOT (erase_chip ()));
325
+ connect (this ->button_scan_slots , SIGNAL (released ()), this , SLOT (scan_chip ()));
322
326
323
327
target_layout->addWidget (container);
324
328
this ->progress_bar_load = new QProgressBar ();
@@ -682,6 +686,36 @@ void MainWindow::slot_update_settings() {
682
686
this ->hex_widget ->viewport ()->repaint ();
683
687
}
684
688
689
+ /* *
690
+ * @brief Convenience function on completing a chip scan
691
+ */
692
+ void MainWindow::parse_chip_read_results () {
693
+ this ->progress_bar_load ->setValue (this ->progress_bar_load ->maximum ());
694
+
695
+ QByteArray data;
696
+ if (this ->readerthread ) {
697
+ data = this ->readerthread ->get_data ();
698
+ this ->readerthread .reset (); // delete object
699
+ } else if (this ->cartridgereaderthread ) {
700
+ data = this ->cartridgereaderthread ->get_data ();
701
+ this ->readerthread .reset (); // delete object
702
+ } else {
703
+ qDebug () << " This function should not have been called." ;
704
+ }
705
+
706
+ qDebug () << " Read " << data.size () << " bytes from chip." ;
707
+ this ->hex_widget ->set_data (data);
708
+
709
+ QByteArray hash = QCryptographicHash::hash (data, QCryptographicHash::Md5);
710
+ this ->label_data_descriptor ->setText (QString (" <b>%1</b> | Size: %2 kb | MD5: %3" )
711
+ .arg (" ROM data" )
712
+ .arg (data.size () / 1024 )
713
+ .arg (QString (hash.toHex ()))
714
+ );
715
+
716
+ statusBar ()->showMessage (QString (" Done reading chip in %1 seconds." ).arg (this ->timer1 .elapsed () / 1000 .f ));
717
+ }
718
+
685
719
/* *
686
720
* @brief Close the application
687
721
*/
@@ -804,6 +838,7 @@ void MainWindow::read_chip_id() {
804
838
this ->button_flash_rom ->setEnabled (true );
805
839
this ->button_flash_bank ->setEnabled (true );
806
840
this ->button_erase_chip ->setEnabled (true );
841
+ this ->button_scan_slots ->setEnabled (true );
807
842
} catch (const std::exception& e) {
808
843
QMessageBox msg_box;
809
844
msg_box.setIcon (QMessageBox::Warning);
@@ -892,30 +927,18 @@ void MainWindow::read_block_done(unsigned int block_id, unsigned int nr_blocks)
892
927
* @brief Signal that a read operation is finished
893
928
*/
894
929
void MainWindow::read_result_ready () {
895
- this ->progress_bar_load ->setValue (this ->progress_bar_load ->maximum ());
896
-
897
- QByteArray data;
898
- if (this ->readerthread ) {
899
- data = this ->readerthread ->get_data ();
900
- this ->readerthread .reset (); // delete object
901
- } else if (this ->cartridgereaderthread ) {
902
- data = this ->cartridgereaderthread ->get_data ();
903
- this ->readerthread .reset (); // delete object
904
- } else {
905
- qDebug () << " This function should not have been called." ;
906
- }
907
-
908
- qDebug () << " Read " << data.size () << " bytes from chip." ;
909
- this ->hex_widget ->set_data (data);
930
+ this ->parse_chip_read_results ();
931
+ }
910
932
911
- QByteArray hash = QCryptographicHash::hash (data, QCryptographicHash::Md5);
912
- this ->label_data_descriptor ->setText (QString (" <b>%1</b> | Size: %2 kb | MD5: %3" )
913
- .arg (" ROM data" )
914
- .arg (data.size () / 1024 )
915
- .arg (QString (hash.toHex ()).toUpper ())
916
- );
933
+ /*
934
+ * @brief Signal that a scan chip operation is finished
935
+ */
936
+ void MainWindow::scan_chip_result_ready () {
937
+ this ->parse_chip_read_results ();
917
938
918
- statusBar ()->showMessage (QString (" Done reading chip in %1 seconds." ).arg (this ->timer1 .elapsed () / 1000 .f ));
939
+ // at this point, the chip has been scanned and we can process the results
940
+ BankViewer bankviewer (this ->num_blocks / BLOCKSPERBANK, this ->hex_widget ->get_data (), this );
941
+ bankviewer.exec ();
919
942
}
920
943
921
944
/* ***************************************************************************
@@ -1035,6 +1058,30 @@ void MainWindow::erase_chip() {
1035
1058
QMessageBox::information (this , " Chip erased." , " Done erasing the chip. All bytes are set of 0xFF." );
1036
1059
}
1037
1060
1061
+ /* *
1062
+ * @brief MainWindow::Scan the ROMs on the chip
1063
+ */
1064
+ void MainWindow::scan_chip () {
1065
+ // ask where to store file
1066
+ statusBar ()->showMessage (" Reading from chip, please wait..." );
1067
+ this ->label_data_descriptor ->clear ();
1068
+
1069
+ // dispatch thread
1070
+ this ->timer1 .start ();
1071
+
1072
+ // disable all buttons so that the user cannot interrupt this task
1073
+ // this->disable_all_buttons();
1074
+
1075
+ // dispatch thread
1076
+ // this->operation = "Reading"; // message for statusbar
1077
+ this ->readerthread = std::make_unique<ReadThread>(this ->serial_interface );
1078
+ this ->readerthread ->set_serial_port (this ->combobox_serial_ports ->currentText ().toStdString ());
1079
+ connect (this ->readerthread .get (), SIGNAL (read_result_ready ()), this , SLOT (scan_chip_result_ready ()));
1080
+ connect (this ->readerthread .get (), SIGNAL (read_block_start (uint,uint)), this , SLOT (read_block_start (uint,uint)));
1081
+ connect (this ->readerthread .get (), SIGNAL (read_block_done (uint,uint)), this , SLOT (read_block_done (uint,uint)));
1082
+ this ->readerthread ->start ();
1083
+ }
1084
+
1038
1085
/* *
1039
1086
* @brief Slot to indicate that a sector is about to be written
1040
1087
*/
0 commit comments