You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.9 KiB
84 lines
2.9 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<!--
|
|
This is free and unencumbered software released into the public domain.
|
|
|
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
distribute this software, either in source code form or as a compiled
|
|
binary, for any purpose, commercial or non-commercial, and by any
|
|
means.
|
|
|
|
In jurisdictions that recognize copyright laws, the author or authors
|
|
of this software dedicate any and all copyright interest in the
|
|
software to the public domain. We make this dedication for the benefit
|
|
of the public at large and to the detriment of our heirs and
|
|
successors. We intend this dedication to be an overt act of
|
|
relinquishment in perpetuity of all present and future rights to this
|
|
software under copyright law.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
For more information, please refer to <https://unlicense.org>
|
|
-->
|
|
|
|
<title>BIOS Shrinker</title>
|
|
</head>
|
|
<body>
|
|
<label for="file-input">Select BIOS dumper save file:</label>
|
|
<input id="file-input" type="file" onchange="shrinkBios(this.files[0])">
|
|
|
|
<script src="https://geraintluff.github.io/sha256/sha256.min.js"></script>
|
|
<script>
|
|
const gbaSha = "fd2547724b505f487e6dcb29ec2ecff3af35a841a77ab2e85fd87350abd36570";
|
|
const dsSha = "782eb3894237ec6aa411b78ffee19078bacf10413856d33cda10b44fd9c2856b";
|
|
|
|
function shrinkBios(file) {
|
|
// Check that the file is 32 KiB
|
|
if(file.size != 32 << 10)
|
|
return alert("Error! This is not a correct GBA BIOS dumper save.");
|
|
|
|
// Read the file
|
|
var reader = new FileReader();
|
|
reader.readAsArrayBuffer(file);
|
|
reader.onload = function() {
|
|
var array = new Uint8Array(this.result);
|
|
|
|
// Trim to 16 KiB
|
|
array = array.subarray(0, 16 << 10);
|
|
|
|
// Check hash
|
|
var bStr = "";
|
|
for(i in array)
|
|
bStr += String.fromCharCode(array[i]);
|
|
var sha = sha256(bStr);
|
|
|
|
if(sha == gbaSha || sha == dsSha) {
|
|
// Download trimmed file
|
|
var blob = new Blob([array], {type: "application/octet-stream"});
|
|
var a = document.createElement("a");
|
|
var url = window.URL.createObjectURL(blob);
|
|
a.href = url;
|
|
a.download = "bios.bin";
|
|
a.click();
|
|
window.URL.revokeObjectURL(url);
|
|
|
|
alert("Done! Checksum matches as a correct BIOS dump from a " + (sha == gbaSha ? "GBA" : "DS") + ".\n\nSHA-256: " + sha);
|
|
} else {
|
|
alert("Error! Trimmed BIOS checksum does not match a valid GBA BIOS checksum.\n\nSHA-256: " + sha);
|
|
}
|
|
};
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|