mirror of
https://github.com/Luca1991/NDSFactory.git
synced 2026-02-04 05:36:15 +01:00
Better project organization
This commit is contained in:
7
ui/tabs/fatpatching/fatpatchingtabfunctions.cpp
Normal file
7
ui/tabs/fatpatching/fatpatchingtabfunctions.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "./../../mainwindow.h"
|
||||
|
||||
|
||||
bool MainWindow::patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath)
|
||||
{
|
||||
return ndsFactory.patchFat(loadPath, shiftSize, savePath);
|
||||
}
|
||||
49
ui/tabs/fatpatching/fatpatchingtabsignals.cpp
Normal file
49
ui/tabs/fatpatching/fatpatchingtabsignals.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include "./../../mainwindow.h"
|
||||
#include "./../../ui_mainwindow.h"
|
||||
|
||||
|
||||
void MainWindow::on_fatPatchingLoadFatBtn_clicked()
|
||||
{
|
||||
QString fatPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Fat",
|
||||
QDir::currentPath(),
|
||||
"NDS Fat (*.bin)");
|
||||
|
||||
if( !fatPath.isNull() )
|
||||
{
|
||||
ui->fatPatchingFatPathEdt->setText(fatPath.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_fatPatchingPatchFatBtn_clicked()
|
||||
{
|
||||
uint32_t positionDiff = 0;
|
||||
uint32_t originalPos = ui->fatPatchingOriginalFatFilesAddrEdt->text().toUInt(nullptr, 16);
|
||||
uint32_t newPos = ui->fatPatchingNewFatFilesAddrEdt->text().toUInt(nullptr, 16);
|
||||
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS FAT",
|
||||
"fat.bin",
|
||||
"Binary (*.bin)");
|
||||
|
||||
if(dirPath.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (originalPos < newPos)
|
||||
{
|
||||
positionDiff = newPos-originalPos;
|
||||
} else {
|
||||
positionDiff = originalPos-newPos;
|
||||
}
|
||||
|
||||
patchFat(ui->fatPatchingFatPathEdt->text().toStdString(), positionDiff, dirPath.toStdString())
|
||||
? QMessageBox::information(this, tr("NDS Factory"), tr("FAT patching completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error patching FAT!"));
|
||||
|
||||
}
|
||||
368
ui/tabs/packer/packertabfunctions.cpp
Normal file
368
ui/tabs/packer/packertabfunctions.cpp
Normal file
@@ -0,0 +1,368 @@
|
||||
#include <QDir>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include "./../../mainwindow.h"
|
||||
#include "./../../ui_mainwindow.h"
|
||||
|
||||
|
||||
void MainWindow::populatePackerSectionHeader(NDSHeader *ndsHeader)
|
||||
{
|
||||
ui->packerGameTitleEdt->setText(QString::fromUtf8(ndsHeader->GameTitle, 0xC));
|
||||
ui->packerGameCodeEdt->setText(QString::fromUtf8(ndsHeader->GameCode, 0x4));
|
||||
ui->packerMakerCodeEdt->setText(QString::fromUtf8(reinterpret_cast<char*>(ndsHeader->MakerCode), 0x2));
|
||||
ui->packerUnitCodeEdt->setText(QString::number(ndsHeader->UnitCode, 16));
|
||||
|
||||
ui->packerDeviceCodeEdt->setText(QString::number(ndsHeader->DeviceType, 16));
|
||||
ui->packerCardSizeEdt->setText(QString::number(ndsHeader->DeviceSize, 16));
|
||||
ui->packerCardInfoEdt->setText(QString::number(ndsHeader->RomVersion, 16));
|
||||
ui->packerFlagsEdt->setText(QString::number(ndsHeader->Flags, 16));
|
||||
|
||||
ui->packerARM9RomAddrEdt->setText(QString::number(ndsHeader->Arm9RomAddr, 16));
|
||||
ui->packerARM9EntryAddrEdt->setText(QString::number(ndsHeader->Arm9EntryAddr, 16));
|
||||
ui->packerARM9RamAddrEdt->setText(QString::number(ndsHeader->Arm9RamAddr, 16));
|
||||
ui->packerARM9SizeEdt->setText(QString::number(ndsHeader->Arm9Size, 16));
|
||||
|
||||
ui->packerARM7RomAddrEdt->setText(QString::number(ndsHeader->Arm7RomAddr, 16));
|
||||
ui->packerARM7EntryAddrEdt->setText(QString::number(ndsHeader->Arm7EntryAddr, 16));
|
||||
ui->packerARM7RamAddrEdt->setText(QString::number(ndsHeader->Arm7RamAddr, 16));
|
||||
ui->packerARM7SizeEdt->setText(QString::number(ndsHeader->Arm7Size, 16));
|
||||
|
||||
ui->packerFilenameTableAddrEdt->setText(QString::number(ndsHeader->FilenameTableAddr, 16));
|
||||
ui->packerFilenameTableSizeEdt->setText(QString::number(ndsHeader->FilenameSize, 16));
|
||||
ui->packerFATAddrEdt->setText(QString::number(ndsHeader->FATAddr, 16));
|
||||
ui->packerFATSizeEdt->setText(QString::number(ndsHeader->FATSize, 16));
|
||||
|
||||
ui->packerARM9OverlayAddrEdt->setText(QString::number(ndsHeader->Arm9OverlayAddr, 16));
|
||||
ui->packerARM9OverlaySizeEdt->setText(QString::number(ndsHeader->Arm9OverlaySize, 16));
|
||||
ui->packerARM7OverlayAddrEdt->setText(QString::number(ndsHeader->Arm7OverlayAddr, 16));
|
||||
ui->packerARM7OverlaySizeEdt->setText(QString::number(ndsHeader->Arm7OverlaySize, 16));
|
||||
|
||||
ui->packerPortNCEdt->setText(QString::number(ndsHeader->NormalCommandsSettings, 16));
|
||||
ui->packerPortKCEdt->setText(QString::number(ndsHeader->Key1CommandsSettings, 16));
|
||||
ui->packerIconTitleEdt->setText(QString::number(ndsHeader->IconTitleAddr, 16));
|
||||
ui->packerSecureAreaCRC16Edt->setText(QString::number(ndsHeader->SecureAreaCRC16, 16));
|
||||
|
||||
ui->packerSecureAreaTimeoutEdt->setText(QString::number(ndsHeader->SecureAreaLoadingTimeout, 16));
|
||||
ui->packerARM9AURamAddrEdt->setText(QString::number(ndsHeader->ARM9AutoLoadListRamAddr, 16));
|
||||
ui->packerARM7AURamAddrEdt->setText(QString::number(ndsHeader->ARM7AutoLoadListRamAddr, 16));
|
||||
ui->packerSecureAreaDisableEdt->setText(QString::number(ndsHeader->SecureAreaDisable, 16));
|
||||
|
||||
ui->packerUsedRomSizeEdt->setText(QString::number(ndsHeader->RomSize, 16));
|
||||
ui->packerHeaderSizeEdt->setText(QString::number(ndsHeader->HeaderSize, 16));
|
||||
ui->packerNintendoLogoEdt->setText(QByteArray::fromRawData(reinterpret_cast<char*>(ndsHeader->NintendoLogo), 0x9C).toHex());
|
||||
ui->packerNintendoLogoCRCEdt->setText(QString::number(ndsHeader->NintendoLogoCRC, 16));
|
||||
|
||||
ui->packerHeaderCRCEdt->setText(QString::number(ndsHeader->HeaderCRC16, 16));
|
||||
ui->packerDebugRomAddrEdt->setText(QString::number(ndsHeader->DebugRomAddr, 16));
|
||||
ui->packerDebugSizeEdt->setText(QString::number(ndsHeader->DebugSize, 16));
|
||||
ui->packerDebugRamAddrEdt->setText(QString::number(ndsHeader->DebugRamAddr, 16));
|
||||
}
|
||||
|
||||
void MainWindow::generateHeader(NDSHeader* pRomHeader)
|
||||
{
|
||||
std::copy_n(ui->packerGameTitleEdt->text().toLatin1().data(), 0xc, std::begin(pRomHeader->GameTitle));
|
||||
std::copy_n(ui->packerGameCodeEdt->text().toStdString().data(), 0x4, std::begin(pRomHeader->GameCode));
|
||||
std::copy_n(ui->packerMakerCodeEdt->text().toStdString().data(), 0x2, std::begin(pRomHeader->MakerCode));
|
||||
pRomHeader->UnitCode = static_cast<unsigned char>(ui->packerUnitCodeEdt->text().toUInt(nullptr, 16));
|
||||
|
||||
pRomHeader->DeviceType = static_cast<unsigned char>(ui->packerDeviceCodeEdt->text().toUInt(nullptr, 16));
|
||||
pRomHeader->DeviceSize = static_cast<unsigned char>(ui->packerCardSizeEdt->text().toUInt(nullptr, 16));
|
||||
|
||||
std::fill(std::begin(pRomHeader->Reserved1), std::end(pRomHeader->Reserved1), 0);
|
||||
|
||||
pRomHeader->RomVersion = static_cast<unsigned char>(ui->packerCardInfoEdt->text().toUInt(nullptr, 16));
|
||||
pRomHeader->Flags = static_cast<unsigned char>(ui->packerFlagsEdt->text().toUInt(nullptr, 16));
|
||||
|
||||
pRomHeader->Arm9RomAddr = ui->packerARM9RomAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->Arm9EntryAddr = ui->packerARM9EntryAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->Arm9RamAddr = ui->packerARM9RamAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->Arm9Size = ui->packerARM9SizeEdt->text().toUInt(nullptr, 16);
|
||||
|
||||
pRomHeader->Arm7RomAddr = ui->packerARM7RomAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->Arm7EntryAddr = ui->packerARM7EntryAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->Arm7RamAddr = ui->packerARM7RamAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->Arm7Size = ui->packerARM7SizeEdt->text().toUInt(nullptr, 16);
|
||||
|
||||
pRomHeader->FilenameTableAddr = ui->packerFilenameTableAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->FilenameSize = ui->packerFilenameTableSizeEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->FATAddr = ui->packerFATAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->FATSize = ui->packerFATSizeEdt->text().toUInt(nullptr, 16);
|
||||
|
||||
pRomHeader->Arm9OverlayAddr = ui->packerARM9OverlayAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->Arm9OverlaySize = ui->packerARM9OverlaySizeEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->Arm7OverlayAddr = ui->packerARM7OverlayAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->Arm7OverlaySize = ui->packerARM7OverlaySizeEdt->text().toUInt(nullptr, 16);
|
||||
|
||||
pRomHeader->NormalCommandsSettings = ui->packerPortNCEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->Key1CommandsSettings = ui->packerPortKCEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->IconTitleAddr = ui->packerIconTitleEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->SecureAreaCRC16 = ui->packerSecureAreaCRC16Edt->text().toUShort(nullptr, 16);
|
||||
|
||||
pRomHeader->SecureAreaLoadingTimeout = ui->packerSecureAreaTimeoutEdt->text().toUShort(nullptr, 16);
|
||||
pRomHeader->ARM9AutoLoadListRamAddr = ui->packerARM9AURamAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->ARM7AutoLoadListRamAddr = ui->packerARM7AURamAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->SecureAreaDisable = ui->packerSecureAreaDisableEdt->text().toULong(nullptr, 16);
|
||||
|
||||
pRomHeader->RomSize = ui->packerUsedRomSizeEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->HeaderSize = ui->packerHeaderSizeEdt->text().toUInt(nullptr, 16);
|
||||
|
||||
std::fill(std::begin(pRomHeader->Reserved2), std::end(pRomHeader->Reserved2), 0);
|
||||
std::copy_n(std::begin(QByteArray::fromHex(ui->packerNintendoLogoEdt->text().toUtf8())), 0x9C, std::begin(pRomHeader->NintendoLogo));
|
||||
pRomHeader->NintendoLogoCRC = ui->packerNintendoLogoCRCEdt->text().toUShort(nullptr, 16);
|
||||
|
||||
pRomHeader->HeaderCRC16 = ui->packerHeaderCRCEdt->text().toUShort(nullptr, 16);
|
||||
pRomHeader->DebugRomAddr = ui->packerDebugRomAddrEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->DebugSize = ui->packerDebugSizeEdt->text().toUInt(nullptr, 16);
|
||||
pRomHeader->DebugRamAddr = ui->packerDebugRamAddrEdt->text().toUInt(nullptr, 16);
|
||||
|
||||
std::fill(std::begin(pRomHeader->Reserved3), std::end(pRomHeader->Reserved3), 0);
|
||||
std::fill(std::begin(pRomHeader->Reserved4), std::end(pRomHeader->Reserved4), 0);
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::writeHeader(const std::string& savePath)
|
||||
{
|
||||
std::vector<char> romHeader(sizeof(NDSHeader));
|
||||
NDSHeader* pRomHeader = reinterpret_cast<NDSHeader*>(romHeader.data());
|
||||
|
||||
generateHeader(pRomHeader);
|
||||
|
||||
return ndsFactory.writeBytesToFile(romHeader, savePath, 0, sizeof(NDSHeader));;
|
||||
}
|
||||
|
||||
void MainWindow::calcHeaderCrc16()
|
||||
{
|
||||
std::vector<char> romHeader(sizeof(NDSHeader));
|
||||
NDSHeader* pRomHeader = reinterpret_cast<NDSHeader*>(romHeader.data());
|
||||
|
||||
generateHeader(pRomHeader);
|
||||
|
||||
ui->packerHeaderCRCEdt->setText(QString::number(ndsFactory.calcHeaderCrc16(romHeader), 16));
|
||||
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm9Bin(const std::string& savePath, bool isArm9FooterPresent)
|
||||
{
|
||||
uint32_t size = ui->packerARM9SizeEdt->text().toUInt(nullptr, 16);
|
||||
if (isArm9FooterPresent)
|
||||
size += Arm9FooterSize;
|
||||
return ndsFactory.writeSectionToFile(
|
||||
ui->loadedArm9BinPathEdt->text().toStdString(),
|
||||
savePath,
|
||||
ui->packerARM9RomAddrEdt->text().toUInt(nullptr, 16),
|
||||
size);
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm7Bin(const std::string& savePath)
|
||||
{
|
||||
return ndsFactory.writeSectionToFile(
|
||||
ui->loadedArm7BinPathEdt->text().toStdString(),
|
||||
savePath,
|
||||
ui->packerARM7RomAddrEdt->text().toUInt(nullptr, 16),
|
||||
ui->packerARM7SizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::writeFnt(const std::string& savePath)
|
||||
{
|
||||
return ndsFactory.writeSectionToFile(
|
||||
ui->loadedFntPathEdt->text().toStdString(),
|
||||
savePath,
|
||||
ui->packerFilenameTableAddrEdt->text().toUInt(nullptr, 16),
|
||||
ui->packerFilenameTableSizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::writeFat(const std::string& savePath)
|
||||
{
|
||||
return ndsFactory.writeSectionToFile(
|
||||
ui->loadedFatPathEdt->text().toStdString(),
|
||||
savePath,
|
||||
ui->packerFATAddrEdt->text().toUInt(nullptr, 16),
|
||||
ui->packerFATSizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm9Overlay(const std::string& savePath)
|
||||
{
|
||||
return ndsFactory.writeSectionToFile(
|
||||
ui->loadedArm9OverlayPathEdt->text().toStdString(),
|
||||
savePath,
|
||||
ui->packerARM9OverlayAddrEdt->text().toUInt(nullptr, 16),
|
||||
ui->packerARM9OverlaySizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm9OverlayFiles(const std::string& savePath)
|
||||
{
|
||||
return false; // TODO: implement me!
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm7Overlay(const std::string& savePath)
|
||||
{
|
||||
return ndsFactory.writeSectionToFile(
|
||||
ui->loadedArm7OverlayPathEdt->text().toStdString(),
|
||||
savePath,
|
||||
ui->packerARM7OverlayAddrEdt->text().toUInt(nullptr, 16),
|
||||
ui->packerARM7OverlaySizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm7OverlayFiles(const std::string& savePath)
|
||||
{
|
||||
return false; // TODO: implement me!
|
||||
}
|
||||
|
||||
bool MainWindow::writeIconTitle(const std::string& savePath)
|
||||
{
|
||||
return ndsFactory.writeSectionToFile(
|
||||
ui->loadedIconTitlePathEdt->text().toStdString(),
|
||||
savePath,
|
||||
ui->packerIconTitleEdt->text().toUInt(nullptr, 16),
|
||||
IconTitleSize);
|
||||
}
|
||||
|
||||
bool MainWindow::writeFatFiles(const std::string& savePath)
|
||||
{
|
||||
uint32_t startAddr = ui->packerIconTitleEdt->text().toUInt(nullptr, 16) + IconTitleSize;
|
||||
uint32_t size = ui->packerUsedRomSizeEdt->text().toUInt(nullptr, 16) - startAddr;
|
||||
|
||||
return ndsFactory.writeSectionToFile(
|
||||
ui->loadedFatFilesPathEdt->text().toStdString(),
|
||||
savePath,
|
||||
startAddr,
|
||||
size);
|
||||
}
|
||||
|
||||
bool MainWindow::writeHeaderPadding(char paddingType, const std::string& savePath)
|
||||
{
|
||||
uint32_t startAddr = sizeof(NDSHeader);
|
||||
uint32_t size = ui->packerARM9RomAddrEdt->text().toUInt(nullptr, 16) - startAddr;
|
||||
|
||||
return ndsFactory.writePaddingToFile(
|
||||
paddingType,
|
||||
savePath,
|
||||
startAddr,
|
||||
size);
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm9BinPadding(char paddingType, const std::string& savePath, bool isFooterPresent)
|
||||
{ // FIXME check ARM9 Overlay
|
||||
uint32_t startAddr = ui->packerARM9RomAddrEdt->text().toUInt(nullptr, 16) + ui->packerARM9SizeEdt->text().toUInt(nullptr, 16);
|
||||
uint32_t size = ui->packerARM7RomAddrEdt->text().toUInt(nullptr, 16) - startAddr;
|
||||
|
||||
if (isFooterPresent)
|
||||
size -= Arm9FooterSize;
|
||||
|
||||
return ndsFactory.writePaddingToFile(
|
||||
paddingType,
|
||||
savePath,
|
||||
startAddr,
|
||||
size);
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm7BinPadding(char paddingType, const std::string& savePath)
|
||||
{ // FIXME check ARM7 Overlay
|
||||
uint32_t startAddr = ui->packerARM7RomAddrEdt->text().toUInt(nullptr, 16) + ui->packerARM7SizeEdt->text().toUInt(nullptr, 16);
|
||||
uint32_t size = ui->packerFilenameTableAddrEdt->text().toUInt(nullptr, 16) - startAddr;
|
||||
|
||||
return ndsFactory.writePaddingToFile(
|
||||
paddingType,
|
||||
savePath,
|
||||
startAddr,
|
||||
size);
|
||||
}
|
||||
|
||||
bool MainWindow::writeFntPadding(char paddingType, const std::string& savePath)
|
||||
{
|
||||
uint32_t startAddr = ui->packerFilenameTableAddrEdt->text().toUInt(nullptr, 16) + ui->packerFilenameTableSizeEdt->text().toUInt(nullptr, 16);
|
||||
uint32_t size = ui->packerFATAddrEdt->text().toUInt(nullptr, 16) - startAddr;
|
||||
|
||||
return ndsFactory.writePaddingToFile(
|
||||
paddingType,
|
||||
savePath,
|
||||
startAddr,
|
||||
size);
|
||||
}
|
||||
|
||||
bool MainWindow::writeFatPadding(char paddingType, const std::string& savePath)
|
||||
{
|
||||
uint32_t startAddr = ui->packerFATAddrEdt->text().toUInt(nullptr, 16) + ui->packerFATSizeEdt->text().toUInt(nullptr, 16);
|
||||
uint32_t size = ui->packerIconTitleEdt->text().toUInt(nullptr, 16) - startAddr;
|
||||
|
||||
return ndsFactory.writePaddingToFile(
|
||||
paddingType,
|
||||
savePath,
|
||||
startAddr,
|
||||
size);
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm9OverlayPadding(char paddingType, const std::string& savePath)
|
||||
{ // FIXME TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm9OverlayFilesPadding(char paddingType, const std::string& savePath)
|
||||
{ // FIXME TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::writeArm7OverlayPadding(char paddingType, const std::string& savePath)
|
||||
{ // FIXME TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::writeArm7OverlayFilesPadding(char paddingType, const std::string& savePath)
|
||||
{ // FIXME TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::writeRomPadding(const std::string& savePath)
|
||||
{
|
||||
uint32_t startAddr = ui->packerUsedRomSizeEdt->text().toUInt(nullptr, 16);
|
||||
uint32_t size = static_cast<uint32_t>(ndsFactory.getCardSizeInBytes(ui->packerCardSizeEdt->text().toInt())) - startAddr;
|
||||
|
||||
return ndsFactory.writePaddingToFile(
|
||||
static_cast<char>('\xff'),
|
||||
savePath,
|
||||
startAddr,
|
||||
size);
|
||||
}
|
||||
|
||||
bool MainWindow::writeEverything(const std::string& savePath)
|
||||
{
|
||||
bool res = true;
|
||||
char paddingType;
|
||||
bool isArm9FooterPresent = ndsFactory.checkArm9FooterPresence(ui->loadedArm9BinPathEdt->text().toStdString(),
|
||||
ui->packerARM9SizeEdt->text().toUInt(nullptr, 16));
|
||||
if (ui->packerPadType00RdBtn->isChecked())
|
||||
paddingType = static_cast<char>('\x00');
|
||||
else
|
||||
paddingType = static_cast<char>('\xff');
|
||||
|
||||
res &= writeHeader(savePath);
|
||||
res &= writeHeaderPadding(paddingType, savePath);
|
||||
res &= writeArm9Bin(savePath, isArm9FooterPresent);
|
||||
res &= writeArm9BinPadding(paddingType, savePath, isArm9FooterPresent);
|
||||
res &= writeArm7Bin(savePath);
|
||||
res &= writeArm7BinPadding(paddingType, savePath);
|
||||
res &= writeFnt(savePath);
|
||||
res &= writeFntPadding(paddingType, savePath);
|
||||
res &= writeFat(savePath);
|
||||
res &= writeFatPadding(paddingType, savePath);
|
||||
if(ui->packerARM9OverlayAddrEdt->text().toUInt(nullptr, 16) != 0) {
|
||||
res &= writeArm9Overlay(savePath);
|
||||
res &= writeArm9OverlayPadding(paddingType, savePath);
|
||||
res &= writeArm9OverlayFiles(savePath);
|
||||
res &= writeArm9OverlayFilesPadding(paddingType, savePath);
|
||||
}
|
||||
if(ui->packerARM7OverlayAddrEdt->text().toUInt(nullptr, 16) != 0) {
|
||||
res &= writeArm7Overlay(savePath);
|
||||
res &= writeArm7OverlayPadding(paddingType, savePath);
|
||||
res &= writeArm7OverlayFiles(savePath);
|
||||
res &= writeArm7OverlayFilesPadding(paddingType, savePath);
|
||||
}
|
||||
res &= writeIconTitle(savePath);
|
||||
res &= writeFatFiles(savePath);
|
||||
if(!ui->packerTrimRomsCbx->isChecked())
|
||||
{
|
||||
res &= writeRomPadding(savePath);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
191
ui/tabs/packer/packertabsignals.cpp
Normal file
191
ui/tabs/packer/packertabsignals.cpp
Normal file
@@ -0,0 +1,191 @@
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include "./../../mainwindow.h"
|
||||
#include "./../../ui_mainwindow.h"
|
||||
|
||||
|
||||
void MainWindow::on_packerLoadHeaderBtn_clicked()
|
||||
{
|
||||
std::vector<char> romHeader;
|
||||
NDSHeader *pNDSHeader;
|
||||
|
||||
QString headerPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Header",
|
||||
QDir::currentPath(),
|
||||
"NDS Header (*.bin)");
|
||||
|
||||
if(headerPath.isNull())
|
||||
{
|
||||
QMessageBox::critical(this, tr("NDS Factory"), tr("Unable to open file!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ndsFactory.loadRomHeader(headerPath.toStdString(), romHeader))
|
||||
{
|
||||
pNDSHeader = reinterpret_cast<NDSHeader*>(romHeader.data());
|
||||
populatePackerSectionHeader(pNDSHeader);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerLoadArm9BinBtn_clicked()
|
||||
{
|
||||
QString arm9BinPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Arm9Bin",
|
||||
QDir::currentPath(),
|
||||
"NDS Arm9Bin (*.bin)");
|
||||
|
||||
if(!arm9BinPath.isNull())
|
||||
{
|
||||
ui->loadedArm9BinPathEdt->setText(arm9BinPath.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerLoadArm7BinBtn_clicked()
|
||||
{
|
||||
QString arm7BinPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Arm7Bin",
|
||||
QDir::currentPath(),
|
||||
"NDS Arm7Bin (*.bin)");
|
||||
|
||||
if(!arm7BinPath.isNull())
|
||||
{
|
||||
ui->loadedArm7BinPathEdt->setText(arm7BinPath.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerLoadFntBtn_clicked()
|
||||
{
|
||||
QString fntPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Fnt",
|
||||
QDir::currentPath(),
|
||||
"NDS Fnt (*.bin)");
|
||||
|
||||
if(!fntPath.isNull())
|
||||
{
|
||||
ui->loadedFntPathEdt->setText(fntPath.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerLoadFatBtn_clicked()
|
||||
{
|
||||
QString fatPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Fat",
|
||||
QDir::currentPath(),
|
||||
"NDS Fat (*.bin)");
|
||||
|
||||
if(!fatPath.isNull())
|
||||
{
|
||||
ui->loadedFatPathEdt->setText(fatPath.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerLoadArm9OverlayBtn_clicked()
|
||||
{
|
||||
QString arm9OverlayPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Arm9Overlay",
|
||||
QDir::currentPath(),
|
||||
"NDS A9OVR (*.bin)");
|
||||
|
||||
if( !arm9OverlayPath.isNull() )
|
||||
{
|
||||
ui->loadedArm9OverlayPathEdt->setText(arm9OverlayPath.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerLoadArm9OverlayFilesBtn_clicked()
|
||||
{
|
||||
QString arm9OverlayFilesPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Arm9Overlay Data",
|
||||
QDir::currentPath(),
|
||||
"NDS A9OVR_DATA (*.bin)");
|
||||
|
||||
if(!arm9OverlayFilesPath.isNull())
|
||||
{
|
||||
ui->loadedArm9OverlayFilesPathEdt->setText(arm9OverlayFilesPath.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerLoadArm7OverlayBtn_clicked()
|
||||
{
|
||||
QString arm7OverlayPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Arm7Overlay",
|
||||
QDir::currentPath(),
|
||||
"NDS A7OVR (*.bin)");
|
||||
|
||||
if(!arm7OverlayPath.isNull())
|
||||
{
|
||||
ui->loadedArm7OverlayPathEdt->setText(arm7OverlayPath.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerLoadArm7OverlayFilesBtn_clicked()
|
||||
{
|
||||
QString arm7OverlayFilesPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Arm7Overlay Data",
|
||||
QDir::currentPath(),
|
||||
"NDS A7OVR_DATA (*.bin)");
|
||||
|
||||
if(!arm7OverlayFilesPath.isNull())
|
||||
{
|
||||
ui->loadedArm7OverlayFilesPathEdt->setText(arm7OverlayFilesPath.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerLoadIconTitleBtn_clicked()
|
||||
{
|
||||
QString iconTitlePath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS IconTitleLogo",
|
||||
QDir::currentPath(),
|
||||
"NDS ITL (*.bin)");
|
||||
|
||||
if(!iconTitlePath.isNull())
|
||||
{
|
||||
ui->loadedIconTitlePathEdt->setText(iconTitlePath.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerLoadFatFilesBtn_clicked()
|
||||
{
|
||||
QString fatFilesPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Fat Data",
|
||||
QDir::currentPath(),
|
||||
"NDS FAT_DATA (*.bin)");
|
||||
|
||||
if(!fatFilesPath.isNull())
|
||||
{
|
||||
ui->loadedFatFilesPathEdt->setText(fatFilesPath.toUtf8());
|
||||
ui->packerFatFilesAddrEdt->setText(QString::number((ui->packerIconTitleEdt->text().toUInt(nullptr, 16) + IconTitleSize), 16));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_packerBuildNDSRomBtn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Rom",
|
||||
"rom.nds",
|
||||
"NDS ROM (*.nds)");
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
writeEverything(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Creation completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the creation!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_packerCalcHeaderCrcBtn_clicked()
|
||||
{
|
||||
calcHeaderCrc16();
|
||||
}
|
||||
222
ui/tabs/unpacker/unpackertabfunctions.cpp
Normal file
222
ui/tabs/unpacker/unpackertabfunctions.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
#include <QDir>
|
||||
#include <stdlib.h>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include "./../../mainwindow.h"
|
||||
#include "./../../ui_mainwindow.h"
|
||||
|
||||
|
||||
void MainWindow::populateHeader(NDSHeader* ndsHeader)
|
||||
{
|
||||
|
||||
ui->unpackerGameTitleEdt->setText(QString::fromUtf8(ndsHeader->GameTitle, 0xC));
|
||||
ui->unpackerGameCodeEdt->setText(QString::fromUtf8(ndsHeader->GameCode, 0x4));
|
||||
ui->unpackerMakerCodeEdt->setText(QString::fromUtf8(reinterpret_cast<char*>(ndsHeader->MakerCode), 0x2));
|
||||
ui->unpackerUnitCodeEdt->setText(QString::number(ndsHeader->UnitCode, 16));
|
||||
|
||||
ui->unpackerDeviceCodeEdt->setText(QString::number(ndsHeader->DeviceType, 16));
|
||||
ui->unpackerCardSizeEdt->setText(QString::number(ndsHeader->DeviceSize, 16));
|
||||
ui->unpackerCardInfoEdt->setText(QString::number(ndsHeader->RomVersion, 16));
|
||||
ui->unpackerFlagsEdt->setText(QString::number(ndsHeader->Flags, 16));
|
||||
|
||||
ui->unpackerARM9RomAddrEdt->setText(QString::number(ndsHeader->Arm9RomAddr,16));
|
||||
ui->unpackerARM9EntryAddrEdt->setText(QString::number(ndsHeader->Arm9EntryAddr,16));
|
||||
ui->unpackerARM9RamAddrEdt->setText(QString::number(ndsHeader->Arm9RamAddr,16));
|
||||
ui->unpackerARM9SizeEdt->setText(QString::number(ndsHeader->Arm9Size,16));
|
||||
|
||||
ui->unpackerARM7RomAddrEdt->setText(QString::number(ndsHeader->Arm7RomAddr,16));
|
||||
ui->unpackerARM7EntryAddrEdt->setText(QString::number(ndsHeader->Arm7EntryAddr,16));
|
||||
ui->unpackerARM7RamAddrEdt->setText(QString::number(ndsHeader->Arm7RamAddr,16));
|
||||
ui->unpackerARM7SizeEdt->setText(QString::number(ndsHeader->Arm7Size,16));
|
||||
|
||||
ui->unpackerFilenameTableAddrEdt->setText(QString::number(ndsHeader->FilenameTableAddr,16));
|
||||
ui->unpackerFilenameTableSizeEdt->setText(QString::number(ndsHeader->FilenameSize,16));
|
||||
ui->unpackerFATAddrEdt->setText(QString::number(ndsHeader->FATAddr,16));
|
||||
ui->unpackerFATSizeEdt->setText(QString::number(ndsHeader->FATSize,16));
|
||||
|
||||
ui->unpackerARM9OverlayAddrEdt->setText(QString::number(ndsHeader->Arm9OverlayAddr,16));
|
||||
ui->unpackerARM9OverlaySizeEdt->setText(QString::number(ndsHeader->Arm9OverlaySize,16));
|
||||
ui->unpackerARM7OverlayAddrEdt->setText(QString::number(ndsHeader->Arm7OverlayAddr,16));
|
||||
ui->unpackerARM7OverlaySizeEdt->setText(QString::number(ndsHeader->Arm7OverlaySize,16));
|
||||
|
||||
ui->unpackerPortNCEdt->setText(QString::number(ndsHeader->NormalCommandsSettings,16));
|
||||
ui->unpackerPortKCEdt->setText(QString::number(ndsHeader->Key1CommandsSettings,16));
|
||||
ui->unpackerIconTitleEdt->setText(QString::number(ndsHeader->IconTitleAddr,16));
|
||||
ui->unpackerSecureAreaCRC16Edt->setText(QString::number(ndsHeader->SecureAreaCRC16,16));
|
||||
|
||||
ui->unpackerSecureAreaTimeoutEdt->setText(QString::number(ndsHeader->SecureAreaLoadingTimeout,16));
|
||||
ui->unpackerARM9AURamAddrEdt->setText(QString::number(ndsHeader->ARM9AutoLoadListRamAddr,16));
|
||||
ui->unpackerARM7AURamAddrEdt->setText(QString::number(ndsHeader->ARM7AutoLoadListRamAddr,16));
|
||||
ui->unpackerSecureAreaDisableEdt->setText(QString::number(ndsHeader->SecureAreaDisable,16));
|
||||
|
||||
ui->unpackerUsedRomSizeEdt->setText(QString::number(ndsHeader->RomSize,16));
|
||||
ui->unpackerHeaderSizeEdt->setText(QString::number(ndsHeader->HeaderSize,16));
|
||||
|
||||
ui->unpackerNintendoLogoEdt->setText(QByteArray::fromRawData(reinterpret_cast<char*>(ndsHeader->NintendoLogo), 0x9C).toHex());
|
||||
ui->unpackerNintendoLogoCRCEdt->setText(QString::number(ndsHeader->NintendoLogoCRC,16));
|
||||
|
||||
ui->unpackerHeaderCRCEdt->setText(QString::number(ndsHeader->HeaderCRC16,16));
|
||||
ui->unpackerDebugRomAddrEdt->setText(QString::number(ndsHeader->DebugRomAddr,16));
|
||||
ui->unpackerDebugSizeEdt->setText(QString::number(ndsHeader->DebugSize,16));
|
||||
ui->unpackerDebugRamAddrEdt->setText(QString::number(ndsHeader->DebugRamAddr,16));
|
||||
|
||||
ui->unpackerFatFilesOriginalAddrEdt->setText(QString::number((ndsHeader->IconTitleAddr+IconTitleSize),16));
|
||||
}
|
||||
|
||||
void MainWindow::enableExtractionButtons()
|
||||
{
|
||||
ui->unpackerExtractorGbx->setEnabled(true);
|
||||
ui->unpackerExtraGbx->setEnabled(true);
|
||||
if (ui->unpackerARM9OverlayAddrEdt->text().toUInt(nullptr, 16) == 0){
|
||||
ui->unpackerDumpArm9OverlayBtn->setEnabled(false);
|
||||
ui->unpackerDumpArm9OverlayFilesBtn->setEnabled(false);
|
||||
}
|
||||
if (ui->unpackerARM7OverlayAddrEdt->text().toUInt(nullptr, 16) == 0){
|
||||
ui->unpackerDumpArm7OverlayBtn->setEnabled(false);
|
||||
ui->unpackerDumpArm7OverlayFilesBtn->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::disableExtractionButtons()
|
||||
{
|
||||
ui->unpackerExtractorGbx->setEnabled(false);
|
||||
ui->unpackerExtraGbx->setEnabled(false);
|
||||
}
|
||||
|
||||
bool MainWindow::dumpHeader(const std::string& dirPath)
|
||||
{
|
||||
return ndsFactory.dumpDataFromFile(
|
||||
ui->loadedRomPath->text().toStdString(),
|
||||
dirPath,
|
||||
0,
|
||||
ui->unpackerHeaderSizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::dumpArm9Bin(const std::string& dirPath, bool dumpExtraBytes)
|
||||
{
|
||||
uint32_t size = ui->unpackerARM9SizeEdt->text().toUInt(nullptr, 16);
|
||||
if (dumpExtraBytes)
|
||||
size += 12;
|
||||
return ndsFactory.dumpDataFromFile(
|
||||
ui->loadedRomPath->text().toStdString(),
|
||||
dirPath,
|
||||
ui->unpackerARM9RomAddrEdt->text().toUInt(nullptr, 16),
|
||||
size);
|
||||
}
|
||||
|
||||
bool MainWindow::dumpArm7Bin(const std::string& dirPath)
|
||||
{
|
||||
return ndsFactory.dumpDataFromFile(
|
||||
ui->loadedRomPath->text().toStdString(),
|
||||
dirPath,
|
||||
ui->unpackerARM7RomAddrEdt->text().toUInt(nullptr, 16),
|
||||
ui->unpackerARM7SizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::dumpFnt(const std::string& dirPath)
|
||||
{
|
||||
return ndsFactory.dumpDataFromFile(
|
||||
ui->loadedRomPath->text().toStdString(),
|
||||
dirPath,
|
||||
ui->unpackerFilenameTableAddrEdt->text().toUInt(nullptr, 16),
|
||||
ui->unpackerFilenameTableSizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::dumpFat(const std::string& dirPath)
|
||||
{
|
||||
return ndsFactory.dumpDataFromFile(
|
||||
ui->loadedRomPath->text().toStdString(),
|
||||
dirPath,
|
||||
ui->unpackerFATAddrEdt->text().toUInt(nullptr, 16),
|
||||
ui->unpackerFATSizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::dumpArm9Overlay(const std::string& dirPath)
|
||||
{
|
||||
return ndsFactory.dumpDataFromFile(
|
||||
ui->loadedRomPath->text().toStdString(),
|
||||
dirPath,
|
||||
ui->unpackerARM9OverlayAddrEdt->text().toUInt(nullptr, 16),
|
||||
ui->unpackerARM9OverlaySizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::dumpArm9OverlayFiles(const std::string& dirPath)
|
||||
{
|
||||
return false; // TODO: implement me!
|
||||
}
|
||||
|
||||
bool MainWindow::dumpArm7Overlay(const std::string& dirPath)
|
||||
{
|
||||
return ndsFactory.dumpDataFromFile(
|
||||
ui->loadedRomPath->text().toStdString(),
|
||||
dirPath,
|
||||
ui->unpackerARM7OverlayAddrEdt->text().toUInt(nullptr, 16),
|
||||
ui->unpackerARM7OverlaySizeEdt->text().toUInt(nullptr, 16));
|
||||
}
|
||||
|
||||
bool MainWindow::dumpArm7OverlayFiles(const std::string& dirPath)
|
||||
{
|
||||
return false; // TODO: implement me!
|
||||
}
|
||||
|
||||
bool MainWindow::dumpIconTitle(const std::string& dirPath)
|
||||
{
|
||||
return ndsFactory.dumpDataFromFile(
|
||||
ui->loadedRomPath->text().toStdString(),
|
||||
dirPath,
|
||||
ui->unpackerIconTitleEdt->text().toUInt(nullptr, 16),
|
||||
0xA00);
|
||||
}
|
||||
|
||||
bool MainWindow::dumpFatFiles(const std::string& dirPath)
|
||||
{
|
||||
uint32_t startAddr = ui->unpackerIconTitleEdt->text().toUInt(nullptr, 16) + IconTitleSize;
|
||||
uint32_t size = ui->unpackerUsedRomSizeEdt->text().toUInt(nullptr, 16) - startAddr;
|
||||
|
||||
return ndsFactory.dumpDataFromFile(
|
||||
ui->loadedRomPath->text().toStdString(),
|
||||
dirPath,
|
||||
startAddr,
|
||||
size);
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::dumpEverything(QString dirPath)
|
||||
{
|
||||
|
||||
if(!dumpHeader(QDir::toNativeSeparators(dirPath+"/header.bin").toStdString()))
|
||||
return false;
|
||||
if(!dumpArm9Bin(QDir::toNativeSeparators(dirPath+"/arm9.bin").toStdString(), true))
|
||||
return false;
|
||||
if(!dumpArm7Bin(QDir::toNativeSeparators(dirPath+"/arm7.bin").toStdString()))
|
||||
return false;
|
||||
if(!dumpFnt(QDir::toNativeSeparators(dirPath+"/fnt.bin").toStdString()))
|
||||
return false;
|
||||
if(!dumpFat(QDir::toNativeSeparators(dirPath+"/fat.bin").toStdString()))
|
||||
return false;
|
||||
if(ui->unpackerARM9OverlayAddrEdt->text().toUInt(nullptr, 16) != 0) {
|
||||
if(!dumpArm9Overlay(QDir::toNativeSeparators(dirPath+"/a9ovr.bin").toStdString()))
|
||||
return false;
|
||||
if(!dumpArm9OverlayFiles(QDir::toNativeSeparators(dirPath+"/a9ovr_data.bin").toStdString()))
|
||||
return false;
|
||||
}
|
||||
if(ui->unpackerARM7OverlayAddrEdt->text().toUInt(nullptr, 16) != 0) {
|
||||
if(!dumpArm7Overlay(QDir::toNativeSeparators(dirPath+"/a7ovr.bin").toStdString()))
|
||||
return false;
|
||||
if(!dumpArm7OverlayFiles(QDir::toNativeSeparators(dirPath+"/a7ovr_data.bin").toStdString()))
|
||||
return false;
|
||||
}
|
||||
if(!dumpIconTitle(QDir::toNativeSeparators(dirPath+"/itl.bin").toStdString()))
|
||||
return false;
|
||||
if(!dumpFatFiles(QDir::toNativeSeparators(dirPath+"/fat_data.bin").toStdString()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::decodeFatFiles()
|
||||
{
|
||||
// TODO: implement me!
|
||||
return false;
|
||||
}
|
||||
209
ui/tabs/unpacker/unpackertabsignals.cpp
Normal file
209
ui/tabs/unpacker/unpackertabsignals.cpp
Normal file
@@ -0,0 +1,209 @@
|
||||
#include <QFileDialog>
|
||||
#include <vector>
|
||||
#include <QMessageBox>
|
||||
#include "./../../mainwindow.h"
|
||||
#include "./../../ui_mainwindow.h"
|
||||
|
||||
|
||||
void MainWindow::on_loadRomBtn_clicked()
|
||||
{
|
||||
std::vector<char> romHeader;
|
||||
NDSHeader *pNDSHeader;
|
||||
|
||||
QString romPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Rom",
|
||||
QDir::currentPath(),
|
||||
"NDS Rom (*.nds)");
|
||||
|
||||
if( !romPath.isNull() )
|
||||
{
|
||||
ui->loadedRomPath->setText(romPath.toUtf8());
|
||||
}
|
||||
|
||||
if (ndsFactory.loadRomHeader(ui->loadedRomPath->text().toStdString(), romHeader))
|
||||
{
|
||||
pNDSHeader = reinterpret_cast<NDSHeader*>(romHeader.data());
|
||||
populateHeader(pNDSHeader);
|
||||
enableExtractionButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
disableExtractionButtons();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpHeaderBtn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Header",
|
||||
"header.bin",
|
||||
"Binary (*.bin)");
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
dumpHeader(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpArm9Btn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS ARM9",
|
||||
"arm9.bin",
|
||||
"Binary (*.bin)");
|
||||
|
||||
QMessageBox::StandardButton dumpExtraBytes = QMessageBox::question(
|
||||
this,
|
||||
"NDS Factory",
|
||||
"Do you want to dump the extra 12 bytes? (click yes if you want a 1:1 arm9 dump)",
|
||||
QMessageBox::Yes|QMessageBox::No);
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
dumpArm9Bin(dirPath.toStdString(), dumpExtraBytes == QMessageBox::Yes ? true : false)
|
||||
? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpArm7Btn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS ARM7",
|
||||
"arm7.bin",
|
||||
"Binary (*.bin)");
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
dumpArm7Bin(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpFntBtn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS FNT",
|
||||
"fnt.bin",
|
||||
"Binary (*.bin)");
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
dumpFnt(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpFatBtn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS FAT",
|
||||
"fat.bin",
|
||||
"Binary (*.bin)");
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
dumpFat(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpArm9OverlayBtn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS ARM9 Overlay",
|
||||
"a9ovr.bin",
|
||||
"Binary (*.bin)");
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
dumpArm9Overlay(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpArm7OverlayBtn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS ARM7 Overlay",
|
||||
"a7ovr.bin",
|
||||
"Binary (*.bin)");
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
dumpArm7Overlay(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpIconTitleLogoBtn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS IconTitleLogo",
|
||||
"itl.bin",
|
||||
"Binary (*.bin)");
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
dumpIconTitle(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpFatFilesBtn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getSaveFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS FAT Files",
|
||||
"fat_data.bin",
|
||||
"Binary (*.bin)");
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
dumpFatFiles(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpArm9OverlayFilesBtn_clicked()
|
||||
{
|
||||
QMessageBox::warning(this, tr("NDS Factory"), tr("This function is currently not implemented!"));
|
||||
//dumpArm9OverlayFiles()
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpArm7OverlayFilesBtn_clicked()
|
||||
{
|
||||
QMessageBox::warning(this, tr("NDS Factory"), tr("This function is currently not implemented!"));
|
||||
//dumpArm7OverlayFiles()
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDumpEverythingBtn_clicked()
|
||||
{
|
||||
QString dirPath = QFileDialog::getExistingDirectory(
|
||||
this, tr("Select Directory"),
|
||||
"",
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if (!dirPath.isNull())
|
||||
{
|
||||
dumpEverything(dirPath) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_unpackerDecodeFatFilesBtn_clicked()
|
||||
{
|
||||
QMessageBox::warning(this, tr("NDS Factory"), tr("This function is currently not implemented!"));
|
||||
decodeFatFiles();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user