mirror of
https://github.com/vonmillhausen/sf2000.git
synced 2024-11-08 11:05:12 +01:00
806444d2a9
This was just supposed to be a new feature for the generic image tool (dithering support), but while working on that things kind of snowballed 😅
* Added dithering support to the generic image tool and the boot logo changer, when converting images to RGB565 format. This uses a Bayer 8x8 matrix, and the overall "strength" of the dither can be controlled - it defaults to what I feel is a sane value. Dithering can help reduce banding effects due to the low colour depth in RGB565.
* Made "fix" scaling mode more flexible in the generic image tool - now there's checkboxes beside the width and height dimensions - if you un-check one, the other dimension will be calculated automatically to keep the input's aspect ratio intact
* Improved downscaling quality in the generic image tool. While working on the dithering feature, I discovered the previous "gaussian resampling" downscaling method I was using introduced distortion in certain situations. I had a lot of fun playing around with possible replacements (I tried 10 new downscaling functions!), and finally settled on a hybrid function that mixes powers-of-two downscaling (with some custom mipmap style cross-blending) with Hermite interpolation. This new method is reasonably quick, gives clean results with no great distortion, and works well with alpha channels (doesn't introduce any dark fringing)
* Generic image tool now shows the dimensions of the output image
* Added a max width on the main tool page bodies, so that they don't get so wide on full-screen desktop browsers
* Fixed a few edge-case logic bugs here and there (e.g., when upscaling only a single dimensions with the generic image tool, or places where I thought I was copying objects, but was only creating references to them, etc.)
* Switched from using "var" declarations across all tool codebases to "let" or "const" instead
* Switched out the SVG alert icons to just use emoji instead
* Various other nips and tucks (fixed up my arbitrary 80-column comment wrapping on the tools that had previously just been eye-balled, fixed a few comment typos, etc.)
87 lines
4.1 KiB
HTML
87 lines
4.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Data Frog SF2000 BIOS CRC32 Patcher</title>
|
|
<meta name="viewport" content="width=device-width">
|
|
<link rel="stylesheet" href="tools.css">
|
|
</head>
|
|
<body>
|
|
<h1>Data Frog SF2000 BIOS CRC32 Patcher</h1>
|
|
<p>This tool will recalculate and patch the CRC32 check bits for a modified <code>bisrv.asd</code> BIOS file for the SF2000; only really useful if you've manually modified data outside of the "safe" areas covered by my other tools. If you haven't done your own hex editing of the BIOS, then this tool probably isn't for you! 🙂</p>
|
|
<p id="initialWarning"></p>
|
|
<hr>
|
|
<div id="steps">
|
|
<section id="bisrvSection">
|
|
<h2>Step 1: Select Your <code>bisrv.asd</code></h2>
|
|
<p>Select your <code>bisrv.asd</code> file. You should probably make a backup of the file first, just in case!</p>
|
|
<div id="bisrvMessages"></div>
|
|
<div class="controlContainer">
|
|
<label class="control">Open <code>bisrv.asd</code>: <input id="bisrvSelector" type="file" accept=".asd,application/octet-stream" onchange="bisrvLoad(event.target.files[0])"></label>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
<script src="tools.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
// Global variables...
|
|
let bisrvData; // Used to store the binary data from the bisrv.asd file
|
|
|
|
// Display our initial warning message
|
|
setMessage("warning", "initialWarning", "<strong><em>WARNING:</em></strong> This tool will just blindly modify bytes <code>0x18c</code> to <code>0x18f</code> of whatever input file you provide; correct usage of this tool is therefore up to you, not me! 🤣");
|
|
|
|
function bisrvLoad(file) {
|
|
// We've got a new file - clear any old error messages and any HTML after
|
|
// Step 1...
|
|
document.getElementById("bisrvMessages").innerHTML = "";
|
|
while(document.getElementById("bisrvSection").nextSibling) {
|
|
document.getElementById("bisrvSection").nextSibling.remove();
|
|
}
|
|
|
|
// Check to make sure the file is at least ~512-bytes-ish long (CRC32 for
|
|
// bisrv.asd is calculated for bytes 512 onwards)...
|
|
if (file.size < 520) {
|
|
setMessage("error", "bisrvMessages", "ERROR: Provided file is too small!");
|
|
return;
|
|
}
|
|
|
|
// If we're here then we should be good - read in our file and store its
|
|
// contents in bisrvData, then patch the CRC32 bytes...
|
|
const frBisrv = new FileReader();
|
|
frBisrv.readAsArrayBuffer(file);
|
|
frBisrv.onload = function(event) {
|
|
|
|
// Read the provided file's data into an array...
|
|
bisrvData = new Uint8Array(event.target.result);
|
|
|
|
// Patch the CRC32 bytes...
|
|
patchCRC32(bisrvData);
|
|
|
|
// And display Step 2...
|
|
stepTwo();
|
|
};
|
|
}
|
|
|
|
function stepTwo() {
|
|
// Start building our HTML...
|
|
let html = "<section id=\"downloadSection\"><h2>Step 2: Download Patched <code>bisrv.asd</code></h2><p>Click the download button for the patched <code>bisrv.asd</code> file; use it to replace the one in the <code>bios</code> folder on your SF2000's microSD card.</p><div id=\"downloadSectionMessages\"></div>";
|
|
|
|
// Add our download button...
|
|
html += "<div class=\"controlContainer\"><div class=\"control\"><input id=\"downloadButton\" type=\"button\" value=\"Download\"></div></div>";
|
|
|
|
// Finally, add a <hr> separator after the last step, and append the new step...
|
|
document.getElementById("steps").insertAdjacentHTML("beforeend", "<hr>");
|
|
document.getElementById("steps").insertAdjacentHTML("beforeend", html);
|
|
|
|
// Attach our event handler to our download button...
|
|
const dButton = document.getElementById("downloadButton");
|
|
dButton.addEventListener("click", function() {
|
|
downloadToBrowser(bisrvData, "application/octet-stream", "bisrv.asd");
|
|
});
|
|
}
|
|
</script>
|
|
<hr>
|
|
<p><a rel="license" href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>: public domain. Version 1.2, 20240514.1</p>
|
|
</body>
|
|
</html>
|