mirror of
https://github.com/Luca1991/NDSFactory.git
synced 2026-02-04 05:36:15 +01:00
Implemented FAT rebuilding
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#ifndef REVISION_H
|
||||
#define REVISION_H
|
||||
|
||||
#define GIT_COMMIT_HASH "e2e53cb"
|
||||
#define GIT_COMMIT_HASH "f46e527"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -58,6 +58,9 @@ private slots:
|
||||
void on_fatExtractorLoadFatBtn_clicked();
|
||||
void on_fatExtractorLoadFntBtn_clicked();
|
||||
void on_fatExtractorExtractBtn_clicked();
|
||||
void on_fatBuilderOpenFatDataDirBtn_clicked();
|
||||
void on_fatBuilderLoadOriginalFatBtn_clicked();
|
||||
void on_fatBuilderBuildBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
@@ -109,4 +112,5 @@ private:
|
||||
bool extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath,
|
||||
const std::string& fntSectionPath, uint32_t originalFatDataAddr, const std::string& savePath, bool logFileIDs);
|
||||
bool patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath);
|
||||
bool buildFatData(const std::string& fatDataDirPath, const std::string& originalFatPath, uint32_t fatDataAddr, const std::string& savePath);
|
||||
};
|
||||
|
||||
@@ -702,7 +702,7 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="fatExtractorSaveFileIDsCbx">
|
||||
<property name="text">
|
||||
<string>Save file IDs to _file_IDs.txt (required for games that access files by their ID)</string>
|
||||
<string>Save file IDs to _file_IDs.txt (required for rebuilding FAT)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -736,6 +736,83 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_8">
|
||||
<property name="title">
|
||||
<string>FAT Builder</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_18">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_19">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Original fat.bin is required ONLY if the ROM has an overlay...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="fatBuilderFatDirPathEdt"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="fatBuilderOpenFatDataDirBtn">
|
||||
<property name="text">
|
||||
<string>Open FAT Data Directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="fatBuilderOriginalFatPathEdt"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="fatBuilderLoadOriginalFatBtn">
|
||||
<property name="text">
|
||||
<string>Load Original fat.bin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Fat Files (fat_data.bin) Addr:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="fatBuilderFatAddrEdt"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<item>
|
||||
<widget class="QPushButton" name="fatBuilderBuildBtn">
|
||||
<property name="text">
|
||||
<string>Build!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||
<item>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <filesystem>
|
||||
#include "./../../mainwindow.h"
|
||||
|
||||
|
||||
@@ -11,3 +12,9 @@ bool MainWindow::patchFat(const std::string& loadPath, uint32_t shiftSize, const
|
||||
{
|
||||
return ndsFactory.patchFat(loadPath, shiftSize, savePath);
|
||||
}
|
||||
|
||||
bool MainWindow::buildFatData(const std::string& fatDataDirPath, const std::string& originalFatPath, uint32_t fatDataAddr, const std::string& savePath)
|
||||
{
|
||||
if (!std::filesystem::exists(fatDataDirPath + "/_file_IDs.txt")) return false;
|
||||
return ndsFactory.buildFatData(fatDataDirPath, originalFatPath, fatDataAddr, savePath);
|
||||
}
|
||||
|
||||
@@ -106,3 +106,45 @@ void MainWindow::on_fatPatcherPatchFatBtn_clicked()
|
||||
|
||||
ui->fatPatcherPatchFatBtn->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_fatBuilderOpenFatDataDirBtn_clicked()
|
||||
{
|
||||
QString fatDirPat = QFileDialog::getExistingDirectory(
|
||||
this, tr("Select Directory"),
|
||||
"",
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if (!fatDirPat.isNull())
|
||||
ui->fatBuilderFatDirPathEdt->setText(fatDirPat.toUtf8());
|
||||
}
|
||||
|
||||
void MainWindow::on_fatBuilderLoadOriginalFatBtn_clicked()
|
||||
{
|
||||
QString fatPath = QFileDialog::getOpenFileName(
|
||||
Q_NULLPTR,
|
||||
"NDS Fat",
|
||||
"",
|
||||
"NDS Fat (*.bin)");
|
||||
|
||||
if (!fatPath.isNull())
|
||||
ui->fatBuilderOriginalFatPathEdt->setText(fatPath.toUtf8());
|
||||
}
|
||||
|
||||
void MainWindow::on_fatBuilderBuildBtn_clicked()
|
||||
{
|
||||
ui->fatBuilderOpenFatDataDirBtn->setEnabled(false);
|
||||
|
||||
QString dirPath = QFileDialog::getExistingDirectory(
|
||||
this, tr("Select Directory"),
|
||||
"",
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if (!dirPath.isNull())
|
||||
buildFatData(ui->fatBuilderFatDirPathEdt->text().toStdString(),
|
||||
ui->fatBuilderOriginalFatPathEdt->text().toStdString(),
|
||||
ui->fatBuilderFatAddrEdt->text().toUInt(nullptr, 16),
|
||||
dirPath.toStdString()) ? QMessageBox::information(this, tr("NDSFactory"), tr("fat_data.bin and fat.bin correctly built!"))
|
||||
: QMessageBox::critical(this, tr("NDSFactory"), tr("Error building FAT!"));
|
||||
|
||||
ui->fatBuilderOpenFatDataDirBtn->setEnabled(true);
|
||||
}
|
||||
@@ -148,7 +148,10 @@ bool MainWindow::writeArm9BinPadding(char paddingType, const std::string& savePa
|
||||
size = extractPackerHeaderTableData(NDSHeaderNames::ARM7RomAddress).toUInt(nullptr, 16) - startAddr;
|
||||
|
||||
if (isFooterPresent)
|
||||
{
|
||||
startAddr += Arm9FooterSize;
|
||||
size -= Arm9FooterSize;
|
||||
}
|
||||
|
||||
return ndsFactory.writePaddingToFile(
|
||||
paddingType,
|
||||
|
||||
Reference in New Issue
Block a user