mirror of
https://github.com/mon/BemaniPatcher.git
synced 2026-08-02 06:20:42 -07:00
Add Subtractive score for SDVX, class-ify patch styles
This commit is contained in:
+149
-55
@@ -3,8 +3,148 @@ mods = null;
|
|||||||
filename = null;
|
filename = null;
|
||||||
errorLog = "";
|
errorLog = "";
|
||||||
|
|
||||||
|
// Each unique kind of patch should have createUI, validatePatch, applyPatch,
|
||||||
|
// updateUI
|
||||||
|
|
||||||
|
StandardPatch = function(options) {
|
||||||
|
this.name = options.name;
|
||||||
|
this.shortname = options.shortname;
|
||||||
|
this.patches = options.patches;
|
||||||
|
};
|
||||||
|
|
||||||
|
StandardPatch.prototype.createUI = function(parent) {
|
||||||
|
var id = this.shortname;
|
||||||
|
var label = this.name;
|
||||||
|
parent.append('<div class="patch"><input type="checkbox" id="' + id + '"><label for="' + id + '">' + label + '</label></div>');
|
||||||
|
};
|
||||||
|
|
||||||
|
StandardPatch.prototype.updateUI = function(file) {
|
||||||
|
var id = this.shortname;
|
||||||
|
var elem = document.getElementById(id);
|
||||||
|
elem.checked = this.checkPatchBytes(file) == "on";
|
||||||
|
};
|
||||||
|
|
||||||
|
StandardPatch.prototype.validatePatch = function(file) {
|
||||||
|
var status = this.checkPatchBytes(file);
|
||||||
|
if(status == "on") {
|
||||||
|
console.log('"' + this.name + '"', "is enabled!");
|
||||||
|
} else if(status == "off") {
|
||||||
|
console.log('"' + this.name + '"', "is disabled!");
|
||||||
|
} else {
|
||||||
|
success = false;
|
||||||
|
return '"' + this.name + '" is neither on nor off! Have you got the right dll?';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
StandardPatch.prototype.applyPatch = function(file) {
|
||||||
|
id = this.shortname;
|
||||||
|
var enabled = document.getElementById(id).checked;
|
||||||
|
this.replaceAll(file, enabled);
|
||||||
|
return enabled ? this.shortname : "";
|
||||||
|
};
|
||||||
|
|
||||||
|
StandardPatch.prototype.replaceAll = function(file, featureOn) {
|
||||||
|
for(var i = 0; i < this.patches.length; i++) {
|
||||||
|
replace(file, this.patches[i].offset,
|
||||||
|
featureOn? this.patches[i].on : this.patches[i].off);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StandardPatch.prototype.checkPatchBytes = function(file) {
|
||||||
|
var patchStatus = "";
|
||||||
|
for(var i = 0; i < this.patches.length; i++) {
|
||||||
|
var patch = this.patches[i];
|
||||||
|
if(bytesMatch(file, patch.offset, patch.off)) {
|
||||||
|
if(patchStatus == "") {
|
||||||
|
patchStatus = "off";
|
||||||
|
} else if(patchStatus != "off"){
|
||||||
|
return "on/off mismatch within patch";
|
||||||
|
}
|
||||||
|
} else if(bytesMatch(file, patch.offset, patch.on)) {
|
||||||
|
if(patchStatus == "") {
|
||||||
|
patchStatus = "on";
|
||||||
|
} else if(patchStatus != "on"){
|
||||||
|
return "on/off mismatch within patch";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return "patch neither on nor off";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return patchStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Each unique kind of patch should have createUI, validatePatch, applyPatch,
|
||||||
|
// updateUI
|
||||||
|
|
||||||
|
// The DEFAULT state is always the 1st element in the patches array
|
||||||
|
UnionPatch = function(options) {
|
||||||
|
this.name = options.name;
|
||||||
|
this.shortname = options.shortname;
|
||||||
|
this.offset = options.offset;
|
||||||
|
this.patches = options.patches;
|
||||||
|
};
|
||||||
|
|
||||||
|
UnionPatch.prototype.createUI = function(parent) {
|
||||||
|
var container = $("<div>", {"class": "patch-union"});
|
||||||
|
container.append('<span class="patch-union-title">' + this.name + ':</span>');
|
||||||
|
for(var i = 0; i < this.patches.length; i++) {
|
||||||
|
var patch = this.patches[i];
|
||||||
|
var id = this.shortname + '-' + patch.shortname;
|
||||||
|
var label = patch.name;
|
||||||
|
container.append('<div class="patch"><input type="radio" id="' + id + '" name="' + this.shortname + '"><label for="' + id + '">' + label + '</label></div>');
|
||||||
|
}
|
||||||
|
parent.append(container);
|
||||||
|
};
|
||||||
|
|
||||||
|
UnionPatch.prototype.updateUI = function(file) {
|
||||||
|
for(var i = 0; i < this.patches.length; i++) {
|
||||||
|
if(bytesMatch(file, this.offset, this.patches[i].patch)) {
|
||||||
|
document.getElementById(this.shortname + '-' + this.patches[i].shortname).checked = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Default fallback
|
||||||
|
document.getElementById(this.shortname + '-' + this.patches[0].shortname).checked = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
UnionPatch.prototype.validatePatch = function(file) {
|
||||||
|
for(var i = 0; i < this.patches.length; i++) {
|
||||||
|
if(bytesMatch(file, this.offset, this.patches[i].patch)) {
|
||||||
|
console.log(this.name, "has", this.patches[i].name, "enabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '"' + this.name + '" doesn\'t have a valid patch! Have you got the right dll?';
|
||||||
|
};
|
||||||
|
|
||||||
|
UnionPatch.prototype.applyPatch = function(file) {
|
||||||
|
var patch = this.getSelected();
|
||||||
|
var name = this.shortname + patch.shortname;
|
||||||
|
replace(file, this.offset, patch.patch);
|
||||||
|
return patch.shortname == "default" ? "" : name;
|
||||||
|
};
|
||||||
|
|
||||||
|
UnionPatch.prototype.getSelected = function() {
|
||||||
|
for(var i = 0; i < this.patches.length; i++) {
|
||||||
|
if(document.getElementById(this.shortname + '-' + this.patches[i].shortname).checked) {
|
||||||
|
return this.patches[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
DllPatcher = function(fname, args) {
|
DllPatcher = function(fname, args) {
|
||||||
mods = args;
|
mods = [];
|
||||||
|
for(var i = 0; i < args.length; i++) {
|
||||||
|
mod = args[i];
|
||||||
|
if(mod.type) {
|
||||||
|
if(mod.type == "union") {
|
||||||
|
mods.push(new UnionPatch(mod));
|
||||||
|
}
|
||||||
|
} else { // standard patch
|
||||||
|
mods.push(new StandardPatch(mod));
|
||||||
|
}
|
||||||
|
}
|
||||||
filename = fname;
|
filename = fname;
|
||||||
loadPatchUI();
|
loadPatchUI();
|
||||||
};
|
};
|
||||||
@@ -33,11 +173,9 @@ saveDll = function() {
|
|||||||
var fname = filename;
|
var fname = filename;
|
||||||
|
|
||||||
for(var i = 0; i < mods.length; i++) {
|
for(var i = 0; i < mods.length; i++) {
|
||||||
id = mods[i].shortname;
|
var enabledStr = mods[i].applyPatch(dllFile);
|
||||||
var enabled = document.getElementById(id).checked;
|
if(enabledStr) {
|
||||||
replaceAll(dllFile, mods[i].patches, enabled);
|
fname += '-' + enabledStr;
|
||||||
if(enabled) {
|
|
||||||
fname += '-' + id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fname += '.dll';
|
fname += '.dll';
|
||||||
@@ -49,67 +187,29 @@ saveDll = function() {
|
|||||||
loadPatchUI = function() {
|
loadPatchUI = function() {
|
||||||
var patchDiv = $('#patches');
|
var patchDiv = $('#patches');
|
||||||
for(var i = 0; i < mods.length; i++) {
|
for(var i = 0; i < mods.length; i++) {
|
||||||
var id = mods[i].shortname;
|
mods[i].createUI(patchDiv);
|
||||||
var name = mods[i].name;
|
|
||||||
patchDiv.append('<div class="patch"><input type="checkbox" id="' + id + '"><label for="' + id + '">' + name + '</label></div>');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePatchUI = function() {
|
updatePatchUI = function() {
|
||||||
for(var i = 0; i < mods.length; i++) {
|
for(var i = 0; i < mods.length; i++) {
|
||||||
var id = mods[i].shortname;
|
mods[i].updateUI(dllFile);
|
||||||
var elem = document.getElementById(id);
|
|
||||||
elem.checked = checkPatchBytes(mods[i].patches) == "on";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildError = function(patchName, message) {
|
|
||||||
var msg = '"' + patchName + '" ' + message;
|
|
||||||
console.log(msg);
|
|
||||||
errorLog += msg + '<br/>';
|
|
||||||
}
|
|
||||||
|
|
||||||
validatePatches = function() {
|
validatePatches = function() {
|
||||||
errorLog = "";
|
errorLog = "";
|
||||||
success = true;
|
success = true;
|
||||||
for(var i = 0; i < mods.length; i++) {
|
for(var i = 0; i < mods.length; i++) {
|
||||||
var patch = mods[i];
|
var error = mods[i].validatePatch(dllFile);
|
||||||
var status = checkPatchBytes(patch.patches);
|
if(error) {
|
||||||
if(status == "on") {
|
errorLog += error + "<br/>";
|
||||||
console.log('"' + patch.name + '"', "is enabled!");
|
|
||||||
} else if(status == "off") {
|
|
||||||
console.log('"' + patch.name + '"', "is disabled!");
|
|
||||||
} else {
|
|
||||||
success = false;
|
success = false;
|
||||||
buildError(patch.name, "is neither on nor off! Have you got the right dll?");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkPatchBytes = function(patches) {
|
|
||||||
var patchStatus = "";
|
|
||||||
for(var i = 0; i < patches.length; i++) {
|
|
||||||
patch = patches[i];
|
|
||||||
if(bytesMatch(dllFile, patch.offset, patch.off)) {
|
|
||||||
if(patchStatus == "") {
|
|
||||||
patchStatus = "off";
|
|
||||||
} else if(patchStatus != "off"){
|
|
||||||
return "on/off mismatch within patch";
|
|
||||||
}
|
|
||||||
} else if(bytesMatch(dllFile, patch.offset, patch.on)) {
|
|
||||||
if(patchStatus == "") {
|
|
||||||
patchStatus = "on";
|
|
||||||
} else if(patchStatus != "on"){
|
|
||||||
return "on/off mismatch within patch";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return "patch neither on nor off";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return patchStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
bytesMatch = function(buffer, offset, bytes) {
|
bytesMatch = function(buffer, offset, bytes) {
|
||||||
for(var i = 0; i < bytes.length; i++) {
|
for(var i = 0; i < bytes.length; i++) {
|
||||||
if(buffer[offset+i] != bytes[i])
|
if(buffer[offset+i] != bytes[i])
|
||||||
@@ -118,12 +218,6 @@ bytesMatch = function(buffer, offset, bytes) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
replaceAll = function(buffer, patches, featureOn) {
|
|
||||||
for(var i = 0; i < patches.length; i++) {
|
|
||||||
replace(buffer, patches[i].offset, featureOn? patches[i].on : patches[i].off);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
replace = function(buffer, offset, bytes) {
|
replace = function(buffer, offset, bytes) {
|
||||||
for(var i = 0; i < bytes.length; i++) {
|
for(var i = 0; i < bytes.length; i++) {
|
||||||
buffer[offset+i] = bytes[i];
|
buffer[offset+i] = bytes[i];
|
||||||
|
|||||||
+28
-6
@@ -41,10 +41,15 @@
|
|||||||
on : [0xB8, 0x01, 0x00, 0x00, 0x00, 0x89, 0x83, 0x78, 0x0A, 0x00, 0x00, 0x90, 0x56, 0x57, 0x90, 0x90]}]
|
on : [0xB8, 0x01, 0x00, 0x00, 0x00, 0x89, 0x83, 0x78, 0x0A, 0x00, 0x00, 0x90, 0x56, 0x57, 0x90, 0x90]}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : "Score as overall percentage (Osu style % display)",
|
type : "union",
|
||||||
shortname : "percent",
|
name : "Score",
|
||||||
patches : [{offset : 0x1FBD9,
|
shortname : "score",
|
||||||
off : [0x8B, 0x85, 0x50, 0x01, 0x00, 0x00, 0x8B, 0x9D, 0x48, 0x01, 0x00, 0x00, 0x8B, 0x8D, 0x54, 0x01,
|
offset : 0x1FBD9,
|
||||||
|
patches : [
|
||||||
|
{
|
||||||
|
name : "Default (NEAR+CRITICAL add to score from 0)",
|
||||||
|
shortname : "default",
|
||||||
|
patch : [0x8B, 0x85, 0x50, 0x01, 0x00, 0x00, 0x8B, 0x9D, 0x48, 0x01, 0x00, 0x00, 0x8B, 0x8D, 0x54, 0x01,
|
||||||
0x00, 0x00, 0x8B, 0x95, 0x4C, 0x01, 0x00, 0x00, 0x56, 0x57, 0x3B, 0xC3, 0x75, 0x08, 0x3B, 0xCA,
|
0x00, 0x00, 0x8B, 0x95, 0x4C, 0x01, 0x00, 0x00, 0x56, 0x57, 0x3B, 0xC3, 0x75, 0x08, 0x3B, 0xCA,
|
||||||
0x0F, 0x84, 0x86, 0x00, 0x00, 0x00, 0x8B, 0xF8, 0x81, 0xC7, 0x7C, 0x9F, 0x02, 0x00, 0x8B, 0xF1,
|
0x0F, 0x84, 0x86, 0x00, 0x00, 0x00, 0x8B, 0xF8, 0x81, 0xC7, 0x7C, 0x9F, 0x02, 0x00, 0x8B, 0xF1,
|
||||||
0x83, 0xD6, 0x00, 0x3B, 0xD6, 0x7C, 0x1C, 0x7F, 0x04, 0x3B, 0xDF, 0x76, 0x16, 0x05, 0x26, 0x43,
|
0x83, 0xD6, 0x00, 0x3B, 0xD6, 0x7C, 0x1C, 0x7F, 0x04, 0x3B, 0xDF, 0x76, 0x16, 0x05, 0x26, 0x43,
|
||||||
@@ -52,15 +57,32 @@
|
|||||||
0x00, 0xEB, 0x59, 0x8B, 0xF8, 0x81, 0xC7, 0x26, 0x43, 0x00, 0x00, 0x8B, 0xF1, 0x83, 0xD6, 0x00,
|
0x00, 0xEB, 0x59, 0x8B, 0xF8, 0x81, 0xC7, 0x26, 0x43, 0x00, 0x00, 0x8B, 0xF1, 0x83, 0xD6, 0x00,
|
||||||
0x3B, 0xD6, 0x7C, 0x1C, 0x7F, 0x04, 0x3B, 0xDF, 0x76, 0x16, 0x05, 0x62, 0x16, 0x00, 0x00, 0x83,
|
0x3B, 0xD6, 0x7C, 0x1C, 0x7F, 0x04, 0x3B, 0xDF, 0x76, 0x16, 0x05, 0x62, 0x16, 0x00, 0x00, 0x83,
|
||||||
0xD1, 0x00, 0x89, 0x85, 0x50],
|
0xD1, 0x00, 0x89, 0x85, 0x50],
|
||||||
on : [0x56, 0x57, 0x52, 0x51, 0xBE, 0x90, 0x71, 0x7C, 0x18, 0x8B, 0x46, 0x54, 0x99, 0x6A, 0x00, 0x6A,
|
},
|
||||||
|
{
|
||||||
|
name : "Subtractive (NEAR+ERROR subtract score from 10,000,000)",
|
||||||
|
shortname : "subtract",
|
||||||
|
patch : [0x56, 0x57, 0x52, 0x51, 0xBE, 0x90, 0x71, 0x7C, 0x18, 0x8B, 0x46, 0x5C, 0x6A, 0x00, 0x99, 0x6A,
|
||||||
|
0x02, 0x52, 0x50, 0xE8, 0x3F, 0xC4, 0x21, 0x00, 0x8B, 0xC8, 0x8B, 0x46, 0x58, 0x8B, 0xFA, 0x99,
|
||||||
|
0x6A, 0x00, 0x01, 0xC1, 0x11, 0xD7, 0x68, 0x80, 0x96, 0x98, 0x00, 0x57, 0x51, 0xE8, 0x25, 0xC4,
|
||||||
|
0x21, 0x00, 0x8B, 0xFA, 0x8B, 0x56, 0x18, 0x8B, 0xC8, 0x8B, 0x82, 0x80, 0x2C, 0x00, 0x00, 0x01,
|
||||||
|
0xC0, 0x99, 0x52, 0x50, 0x57, 0x51, 0xE8, 0xAC, 0x36, 0x21, 0x00, 0xB9, 0x80, 0x96, 0x98, 0x00,
|
||||||
|
0xBF, 0x00, 0x00, 0x00, 0x00, 0x29, 0xC1, 0x19, 0xD7, 0x8B, 0xDF, 0x8B, 0xF9, 0x59, 0x5A, 0x8B,
|
||||||
|
0x45, 0x08, 0x8B, 0x40, 0x04]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : "Average (Osu style % display)",
|
||||||
|
shortname : "avg",
|
||||||
|
patch : [0x56, 0x57, 0x52, 0x51, 0xBE, 0x90, 0x71, 0x7C, 0x18, 0x8B, 0x46, 0x54, 0x99, 0x6A, 0x00, 0x6A,
|
||||||
0x02, 0x52, 0x50, 0xE8, 0x3F, 0xC4, 0x21, 0x00, 0x8B, 0xC8, 0x8B, 0xFA, 0x8B, 0x46, 0x58, 0x99,
|
0x02, 0x52, 0x50, 0xE8, 0x3F, 0xC4, 0x21, 0x00, 0x8B, 0xC8, 0x8B, 0xFA, 0x8B, 0x46, 0x58, 0x99,
|
||||||
0x01, 0xC1, 0x11, 0xD7, 0x6A, 0x00, 0x68, 0x80, 0x96, 0x98, 0x00, 0x57, 0x51, 0xE8, 0x25, 0xC4,
|
0x01, 0xC1, 0x11, 0xD7, 0x6A, 0x00, 0x68, 0x80, 0x96, 0x98, 0x00, 0x57, 0x51, 0xE8, 0x25, 0xC4,
|
||||||
0x21, 0x00, 0x8B, 0xFA, 0x8B, 0xC8, 0x8B, 0x46, 0x54, 0x8B, 0x56, 0x58, 0x01, 0xD0, 0x8B, 0x56,
|
0x21, 0x00, 0x8B, 0xFA, 0x8B, 0xC8, 0x8B, 0x46, 0x54, 0x8B, 0x56, 0x58, 0x01, 0xD0, 0x8B, 0x56,
|
||||||
0x5C, 0x01, 0xD0, 0x01, 0xC0, 0x99, 0x83, 0xF8, 0x00, 0x0F, 0x85, 0x0F, 0x00, 0x00, 0x00, 0xBF,
|
0x5C, 0x01, 0xD0, 0x01, 0xC0, 0x99, 0x83, 0xF8, 0x00, 0x0F, 0x85, 0x0F, 0x00, 0x00, 0x00, 0xBF,
|
||||||
0x00, 0x00, 0x00, 0x00, 0xBB, 0x00, 0x00, 0x00, 0x00, 0xE9, 0x0D, 0x00, 0x00, 0x00, 0x52, 0x50,
|
0x00, 0x00, 0x00, 0x00, 0xBB, 0x00, 0x00, 0x00, 0x00, 0xE9, 0x0D, 0x00, 0x00, 0x00, 0x52, 0x50,
|
||||||
0x57, 0x51, 0xE8, 0x90, 0x36, 0x21, 0x00, 0x8B, 0xF8, 0x8B, 0xDA, 0x59, 0x5A, 0x8B, 0x45, 0x08,
|
0x57, 0x51, 0xE8, 0x90, 0x36, 0x21, 0x00, 0x8B, 0xF8, 0x8B, 0xDA, 0x59, 0x5A, 0x8B, 0x45, 0x08,
|
||||||
0x8B, 0x40, 0x04, 0xEB, 0x49]}]
|
0x8B, 0x40, 0x04, 0xEB, 0x49]
|
||||||
},
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user