Add a "Tools" menu that has a "Split" command that will save the in-memory ROM image into 4 separate files name <selected file name>_{1-4}, where the numbers correspond to the IC's on the socketed ROM SIMM.
This commit is contained in:
parent
ac7c3bd523
commit
a50c5e3f32
|
@ -5,10 +5,12 @@ RomPatcher::RomPatcher()
|
|||
openAction = new QAction(tr("&Open"), this);
|
||||
saveAction = new QAction(tr("&Save"), this);
|
||||
exitAction = new QAction(tr("&Exit"), this);
|
||||
splitAction = new QAction(tr("&Split"), this);
|
||||
|
||||
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
|
||||
connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));
|
||||
connect(exitAction, SIGNAL(triggered()), this, SLOT(quit()));
|
||||
connect(splitAction, SIGNAL(triggered()), this, SLOT(splitImage()));
|
||||
|
||||
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
fileMenu->addAction(openAction);
|
||||
|
@ -16,6 +18,9 @@ RomPatcher::RomPatcher()
|
|||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(exitAction);
|
||||
|
||||
toolsMenu = menuBar()->addMenu(tr("&Tools"));
|
||||
toolsMenu->addAction(splitAction);
|
||||
|
||||
int mywidth = 300;
|
||||
int myheight = 300;
|
||||
int yoffset = 25;
|
||||
|
@ -94,6 +99,35 @@ void RomPatcher::save()
|
|||
// save the RomCtx structure here
|
||||
applyMods();
|
||||
|
||||
QDataStream stream(&file);
|
||||
stream.writeRawData((char*)rom->data, (int)rom->datasize);
|
||||
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void RomPatcher::quit()
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void RomPatcher::updateChecksumUI()
|
||||
{
|
||||
uint32_t cksum;
|
||||
GetChecksum(rom, &cksum);
|
||||
checksum->setText(QString().sprintf("Checksum: %#x", cksum));
|
||||
}
|
||||
|
||||
void RomPatcher::applyMods()
|
||||
{
|
||||
if(applyRomdisk->isChecked()) {
|
||||
RomErr err = InstallRomdiskDrvr(rom);
|
||||
if(err != eSuccess) {
|
||||
fprintf(stderr, "Error applying romdisk drvr: %d %s\n", err, GetROMErrString(err));
|
||||
QMessageBox::critical(this, "Error", "Could not apply ROMdisk driver");
|
||||
}
|
||||
}
|
||||
|
||||
RomErr err = UpdateChecksum(rom);
|
||||
if(err != eSuccess) {
|
||||
fprintf(stderr, "Error updating checksum: %d %s\n", err, GetROMErrString(err));
|
||||
|
@ -124,35 +158,6 @@ void RomPatcher::save()
|
|||
}
|
||||
}
|
||||
|
||||
QDataStream stream(&file);
|
||||
stream.writeRawData((char*)rom->data, (int)rom->datasize);
|
||||
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void RomPatcher::quit()
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void RomPatcher::updateChecksumUI()
|
||||
{
|
||||
uint32_t cksum;
|
||||
GetChecksum(rom, &cksum);
|
||||
checksum->setText(QString().sprintf("Checksum: %#x", cksum));
|
||||
}
|
||||
|
||||
void RomPatcher::applyMods()
|
||||
{
|
||||
if(applyRomdisk->isChecked()) {
|
||||
printf("Romdisk checked, applying\n");
|
||||
RomErr err = InstallRomdiskDrvr(rom);
|
||||
if(err != eSuccess) {
|
||||
fprintf(stderr, "Error applying romdisk drvr: %d %s\n", err, GetROMErrString(err));
|
||||
}
|
||||
}
|
||||
|
||||
updateChecksumUI();
|
||||
}
|
||||
|
||||
|
@ -161,3 +166,47 @@ void RomPatcher::selectDiskImage()
|
|||
QString s = QFileDialog::getOpenFileName(this, "Select ROMdisk Image", "./", "All Files (*.*)");
|
||||
romdiskFile->setText(s);
|
||||
}
|
||||
|
||||
void RomPatcher::splitImage()
|
||||
{
|
||||
QString s = QFileDialog::getSaveFileName(this, "Select split image", "./", "All Files (*.*)");
|
||||
|
||||
applyMods();
|
||||
|
||||
int i;
|
||||
QFile *outfiles[4];
|
||||
QDataStream *outstreams[4];
|
||||
for(i = 0; i < 4; i++) {
|
||||
outfiles[i] = new QFile(s + "_" + (i+49));
|
||||
if(!outfiles[i]) {
|
||||
QMessageBox::critical(this, "Error", "Couldn't open file for splitting");
|
||||
return;
|
||||
|
||||
}
|
||||
if(!outfiles[i]->open(QIODevice::WriteOnly)) {
|
||||
QMessageBox::critical(this, "Error", "Couldn't open file for splitting");
|
||||
return;
|
||||
}
|
||||
|
||||
outstreams[i] = new QDataStream(outfiles[i]);
|
||||
if(!outstreams[i]) {
|
||||
QMessageBox::critical(this, "Error", "Couldn't open stream for splitting");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t bytecount = 0;
|
||||
do {
|
||||
for(i = 3; i>=0; i--, bytecount++) {
|
||||
outstreams[i]->writeRawData((char*)(rom->data+bytecount), 1);
|
||||
}
|
||||
}while(bytecount < rom->datasize);
|
||||
|
||||
for(i = 0; i < 4; i++) {
|
||||
outfiles[i]->close();
|
||||
delete outfiles[i];
|
||||
delete outstreams[i];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ private slots:
|
|||
void quit();
|
||||
void applyMods();
|
||||
void selectDiskImage();
|
||||
void splitImage();
|
||||
|
||||
private:
|
||||
void updateChecksumUI();
|
||||
|
@ -21,8 +22,10 @@ private:
|
|||
QAction *openAction;
|
||||
QAction *saveAction;
|
||||
QAction *exitAction;
|
||||
QAction *splitAction;
|
||||
|
||||
QMenu *fileMenu;
|
||||
QMenu *toolsMenu;
|
||||
|
||||
QLabel *checksum;
|
||||
QCheckBox *applyRomdisk;
|
||||
|
|
Loading…
Reference in New Issue