This commit is contained in:
hanabbi
2023-05-06 14:25:44 +09:00
parent 01f2ead573
commit 859ec00454
3 changed files with 24 additions and 17 deletions

View File

@@ -16,7 +16,7 @@
#pragma once
#define CUST_REV 4
#define CUST_REV 5
#include "oc_common.hpp"
#include "pcv/pcv_common.hpp"

2
pages/dist/main.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,5 @@
/* Config: Cust */
const CUST_REV_UV = 5;
const CUST_REV = 4;
enum CustPlatform {
@@ -404,6 +405,7 @@ class Cust {
storage: CustStorage = new CustStorage();
readonly magic = 0x54535543; // "CUST"
readonly magicLen = 4;
rev: number;
mapper : {[size: number]: { get: any, set: any }} = {
2: {
@@ -441,7 +443,10 @@ class Cust {
mapper.set(i.offset, i.value!);
});
CustTable.forEach(lambda);
AdvTable.forEach(lambda);
if (this.rev == CUST_REV_UV) {
AdvTable.forEach(lambda);
}
this.storage.save();
let a = document.createElement("a");
@@ -522,9 +527,9 @@ class Cust {
parse() {
let offset = this.beginOffset + this.magicLen;
let revLen = 4;
let rev = this.mapper[revLen].get(offset);
if (rev != CUST_REV) {
throw new Error(`Unsupported custRev, expected: ${CUST_REV}, got ${rev}`);
this.rev = this.mapper[revLen].get(offset);
if (this.rev != CUST_REV && this.rev != CUST_REV_UV) {
throw new Error(`Unsupported custRev, expected: ${CUST_REV} or ${CUST_REV_UV}, got ${this.rev}`);
}
offset += revLen;
document.getElementById("cust_rev")!.innerHTML = `Cust v${CUST_REV} is loaded.`;
@@ -540,17 +545,19 @@ class Cust {
offset += i.size;
i.validate();
});
AdvTable.forEach(i => {
i.offset = offset;
let mapper = this.mapper[i.size];
if (!mapper) {
i.getInputElement()?.focus();
throw new Error(`Unknown size at ${i}`);
}
i.value = mapper.get(offset);
offset += i.size;
i.validate();
});
if (this.rev == CUST_REV_UV) {
AdvTable.forEach(i => {
i.offset = offset;
let mapper = this.mapper[i.size];
if (!mapper) {
i.getInputElement()?.focus();
throw new Error(`Unknown size at ${i}`);
}
i.value = mapper.get(offset);
offset += i.size;
i.validate();
});
}
}
load(buffer: ArrayBuffer) {