Skip to content

Commit

Permalink
Add v2 of REL Loader
Browse files Browse the repository at this point in the history
Also updated the original version to call CARDCheckAsync after mounting the memory card to check for possible errors and attempt to repair them.
  • Loading branch information
Zephiles committed Oct 15, 2023
1 parent 56b36dc commit b1928c4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ <h1>TTYD Savefile Hacker</h1>
<form id="uploadform">
<label for="fileupload">File</label>
<input type="file" id="fileupload" name="fileupload">
<label for="versionnumber">Which version?</label>
<select name="versionnumber" id="versionnumber">
<option>1</option>
<option selected>2</option>
</select>
<label for="filenumber">Which file?</label>
<select name="filenumber" id="filenumber">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option selected>4</option>
</select>
<input type="submit" value="Hack!" id="submit">
</form>
Expand Down
44 changes: 31 additions & 13 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var _a, _b;
var _a, _b, _c, _d, _e;
function readString(buffer, offs, length) {
var u = new Uint8Array(buffer);
var S = '';
Expand All @@ -21,23 +21,34 @@ var BinaryDataInit = (_a = {},
_a["G8ME01" /* US */] = "gI2asICEACBUhHAiOIRCYICtG5iApQCofYUiFH2JA6ZOgAQg",
_a);
var BinaryDataMain = (_b = {},
_b["G8MJ01" /* JP */] = "PGCAKWBjUnBIAAAFfIgCpjiEAChIAAEdgG2QsDiAAAGQgxJ4PGCABmBj28h8aQOmToAEIJQh/+B8CAKmkAEAJL+BAAh8fht4fJ8jeD+ggLA/gIApf6PreEgAAAV8iAKmOIT/pDigAzw9gIAmYYw9XH2IA6ZOgAAhf6PreDiAAzxIAADJk60ciDh9AzyQbRyMY4MiRGOkAMBIAACZY4xSdH2JA6Z/w/N4f+T7eLuBAAiAAQAkfAgDpjghACBOgAQgfH8beDxggTBgYzu0PICAsGCEAOBIAABdf+P7eEt5IWx8fxt4P8CAAGPDSIg8gICwOKADPEt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h8fxt4fJ4jeD+ggCljpWpUfKgDpk6AACFjo2sMfGgDpn/j+3h/xPN4ToAAIbuhAAiAAQAkfAgDpjghACBOgAAgP+CAADvAAAA/oAAPY71CQDhgAAA4gAAAOKAAAEgqq1ksA///QIIADDe9//9Bgf/kLAMAAECCAgg4YAAAgI0bmICEAAQ4oAAAOMAAAEgqsjFIAAGRLAMAAEGiABAsA//6QYIACEgAAdg4YAAAOIAAAEgqqdlIAAFtLAMAAECCAcA4gAAUSAABVXx9G3g4YAAAY+RMZH+l63hIKsElLAMAAECCAXw4gAQASAABMXx7G3h/o+t4f2TbeDigBAA4wCAAOOAAAEgqyKlIAAEZLAMAAECCATyA2wBAO4YB/1ecACyDWwJIgHsCRHwaG5Z8ABnWfADQUUGiABx/RNN4fKMA0H9FKDh/RRoUfITQUHzGIhSDOwIgfwbKFHwY4EBAoAAIf5jjeH9k23hIAACpfwTDeEgAAKl8ext4f6PreH9k23h/heN4OMAiADjgAABIKsghSAAAkSwDAABAggC0f5vSFH9j23h/hON4OKAAAUgpWnksAwABQIIAkHx6yhQ4YwAfVGMANICb/+g4hP/gOKMAQHwFIABBgQAsOKMAIJC7/+h8wyBQfJsaFJDEAAg/QIBCg1rwcIB6AARIKRgpkHoABJOfQUyTf0FQg9sANEgAAEg4YAAASAK00DhgAABIArT0LAMAAEyCACB9yAKmOGAAAEgqezUsA///QYL/9H3IA6ZOgAAgf2PbeEgpXxl/ZNt4S///wX+j63hIKsDBf6TreEv//7E4YAAASCqykSweAABBggAMf8gDpk6AACE4YAAASAax3HJlbAA=",
_e),
_b);
function decodeBinaryData(S) {
return Uint8Array.from(window.atob(S), function (c) { return c.charCodeAt(0); }).buffer;
}
function patch(view, fileNumber) {
function patch(view, versionNumber, fileNumber) {
var version = readString(view.buffer, 0x00, 0x06);
var validVersions = ["G8MJ01" /* JP */, "G8ME01" /* US */, "G8MP01" /* EU */];
if (!validVersions.includes(version))
return 2 /* WrongSaveFileGameID */;
var internalFilename = readString(view.buffer, 0x08, 0x11);
if (internalFilename !== 'mariost_save_file')
return 3 /* WrongSaveFileInternalName */;
if (versionNumber < 1 || versionNumber > 2)
return 4 /* InvalidVersionNumber */;
if (fileNumber < 1 || fileNumber > 4)
return 4 /* InvalidFileNumber */;
return 5 /* InvalidFileNumber */;
var offsetFile0 = ((fileNumber - 1) * 0x4000) + 0x2040;
var offsetFile1 = offsetFile0 + 0x10000;
function patchFilesU16(offset, value) {
Expand Down Expand Up @@ -75,7 +86,8 @@ function patch(view, fileNumber) {
// Make sure the selected file exists.
patchFilesU16(0x00, 0x00);
// Write the new file name.
patchFilesBytes(0x11C4, makeStrBytes('REL Loader\0'));
var newFileName = 'REL Loader v' + versionNumber + '\0';
patchFilesBytes(0x11C4, makeStrBytes(newFileName));
// Set the current follower ID.
if (version === "G8MJ01" /* JP */) {
patchFilesU32(0x11E8, 0x4F04);
Expand All @@ -92,10 +104,10 @@ function patch(view, fileNumber) {
}
// Write the main ASM function.
if (version === "G8MJ01" /* JP */) {
patchFilesBytes(0x2140, decodeBinaryData(BinaryDataMain[version]));
patchFilesBytes(0x2140, decodeBinaryData(BinaryDataMain[version][versionNumber]));
}
else {
patchFilesBytes(0x2260, decodeBinaryData(BinaryDataMain[version]));
patchFilesBytes(0x2260, decodeBinaryData(BinaryDataMain[version][versionNumber]));
}
var dataFieldSize = (version === "G8MJ01" /* JP */) ? 0x2140 : 0x2260;
var dataFieldSum = 0;
Expand Down Expand Up @@ -134,9 +146,13 @@ function displayResult(e) {
errorMessage.textContent = 'This save file has the wrong internal ID. Please make sure you are using a normal Paper Mario: The Thousand Year Door save file.';
return false;
}
else if (e === 4 /* InvalidFileNumber */) {
else if (e === 4 /* InvalidVersionNumber */) {
// should not happen
throw "whoops";
throw "Invalid version number.";
}
else if (e === 5 /* InvalidFileNumber */) {
// should not happen
throw "Invalid file number.";
}
}
function fileSubmitted() {
Expand All @@ -146,16 +162,18 @@ function fileSubmitted() {
if (!displayResult(1 /* NotSaveFile */))
return;
}
var versionNumberInput = document.querySelector('select#versionnumber');
var versionNumber = Number(versionNumberInput.selectedOptions[0].textContent);
var fileNumberInput = document.querySelector('select#filenumber');
var fileNumber = Number(fileNumberInput.selectedOptions[0].textContent);
var outputFilename = file.name.replace(/\..*$/, '') + "_REL_Loader.gci";
var reader = new FileReader();
reader.onload = function () {
var buffer = reader.result;
var view = new DataView(buffer);
var res = patch(view, fileNumber);
var res = patch(view, versionNumber, fileNumber);
if (!displayResult(res))
return;
var outputFilename = file.name.replace(/\..*$/, '') + "_REL_Loader_v" + versionNumber + ".gci";
downloadFile(outputFilename, buffer);
};
reader.readAsArrayBuffer(file);
Expand Down

0 comments on commit b1928c4

Please sign in to comment.