Created
November 24, 2023 08:32
-
-
Save DNA64/96f7b05fcea5999512eac7614c176ee7 to your computer and use it in GitHub Desktop.
Hex Calculator for use with CE (Web Based)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hexadecimal Wizard by DNA64</title> | |
</head> | |
<h1>Hexadecimal Wizard by DNA64</h1> | |
<p>This simple web-based Hex tool will save you a lot of time when using Cheat Engine.<br> It will increment the user provided byte values by the difference between the current item quantity and desired. <br>If you don't know what this tool is for, it's not for you ;)<br> | |
<p> </p> | |
<label for="currentQuantity">Current item quantity:</label> | |
<input type="number" id="currentQuantity" min="1" maxlength="3" style="width: 40px;"><br> | |
<p><label for="desiredQuantity">Desired item quantity:</label> | |
<input type="number" id="desiredQuantity" min="1" maxlength="3" style="width: 40px;"><br><br> | |
<label for="byteAddress78">Byte 78:</label> | |
<input type="text" id="byteAddress78" maxlength="2" placeholder="Current Hexadecimal Value"><br> | |
<label for="byteAddress79">Byte 79:</label> | |
<input type="text" id="byteAddress79" maxlength="2" placeholder="Current Hexadecimal Value"><br> | |
<label for="byteAddress7A">Byte 7A:</label> | |
<input type="text" id="byteAddress7A" maxlength="2" placeholder="Current Hexadecimal Value"><br> | |
<label for="byteAddress7B">Byte 7B:</label> | |
<input type="text" id="byteAddress7B" maxlength="2" placeholder="Current Hexadecimal Value"><br> | |
<label for="byteAddress7C">Byte 7C:</label> | |
<input type="text" id="byteAddress7C" maxlength="2" placeholder="Current Hexadecimal Value"><br> | |
<label for="byteAddress7D">Byte 7D:</label> | |
<input type="text" id="byteAddress7D" maxlength="2" placeholder="Current Hexadecimal Value"><br> | |
<label for="byteAddress7E">Byte 7E:</label> | |
<input type="text" id="byteAddress7E" maxlength="2" placeholder="Current Hexadecimal Value"><br> | |
<label for="byteAddress7F">Byte 7F:</label> | |
<input type="text" id="byteAddress7F" maxlength="2" placeholder="Current Hexadecimal Value"><br><br> | |
<button onclick="calculateNewValues()">Calculate</button> | |
<button onclick="resetFields()">Reset Fields</button> | |
<p>Resulting Hexadecimal Values (It's a secret to everybody) :</p> | |
<textarea id="result" rows="1" cols="50" readonly></textarea> | |
<script> | |
function calculateNewValues() { | |
const currentQuantity = parseInt(document.getElementById("currentQuantity").value, 10); | |
const desiredQuantity = parseInt(document.getElementById("desiredQuantity").value, 10); | |
const byteAddresses = ['78', '79', '7A', '7B', '7C', '7D', '7E', '7F']; | |
const hexValues = byteAddresses.map(address => { | |
const inputValue = document.getElementById(`byteAddress${address}`).value.trim(); | |
return inputValue.length === 0 ? '00' : inputValue; | |
}); | |
const decimalValues = hexValues.map(hex => parseInt(hex, 16)); | |
const diff = desiredQuantity - currentQuantity; | |
for (let i = 0; i < decimalValues.length; i++) { | |
if (hexValues[i] !== '00' && (i === 0 || i === 4)) { | |
decimalValues[i] += diff; | |
if (decimalValues[i] > 255) { | |
const rollover = Math.floor(decimalValues[i] / 256); | |
decimalValues[i] %= 256; | |
decimalValues[i + 1] += rollover; | |
} | |
} | |
} | |
const result = decimalValues.map(value => value.toString(16).toUpperCase().padStart(2, '0')).join(' '); | |
document.addEventListener("DOMContentLoaded", function() { | |
var b64 = "VGhpcyB0b29sIHdhcyBjcmVhdGVkIGJ5IEROQTY0LiBQbGVhc2UgbGVhdmUgdGhpcyBtZXNzYWdlIGludGFjdCB3aGVuIHVzaW5nIG15IGNvZGUuIFRoYXQncyBhbGwgSSBhc2sgOik="; | |
console.log(atob(b64)); | |
}); | |
document.getElementById("result").value = result; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment