2022-04-08 12:48:37 +09:00
|
|
|
import { parseJSON } from '../codegen.js';
|
|
|
|
export const lskey = 'config/InstantRestart';
|
|
|
|
export const buttonValues = {
|
|
|
|
START: 0x1000,
|
|
|
|
Y: 0x0800,
|
|
|
|
X: 0x0400,
|
|
|
|
B: 0x0200,
|
|
|
|
A: 0x0100,
|
|
|
|
L: 0x0040,
|
|
|
|
R: 0x0020,
|
|
|
|
Z: 0x0010,
|
|
|
|
DU: 0x0008,
|
|
|
|
DD: 0x0004,
|
|
|
|
DR: 0x0002,
|
|
|
|
DL: 0x0001,
|
|
|
|
};
|
|
|
|
|
2022-04-25 21:28:43 +09:00
|
|
|
const baseCodes = {
|
|
|
|
GMSJ01: (b) => `
|
2022-04-28 04:26:00 +09:00
|
|
|
C20EAFA0 0000000A
|
2022-04-25 21:28:43 +09:00
|
|
|
3C608040 A0A30D50
|
2022-04-28 04:26:00 +09:00
|
|
|
2805${b} 40A20038
|
2022-04-25 21:28:43 +09:00
|
|
|
3C60817F 38A00001
|
|
|
|
98A300B3 98A30100
|
|
|
|
3C60803E 84A3600E
|
2022-04-28 04:26:00 +09:00
|
|
|
90A30004 38A00040
|
|
|
|
90A30000 3C60800E
|
2022-04-25 21:28:43 +09:00
|
|
|
6063B3F8 7C6803A6
|
|
|
|
4E800020 2C000002
|
|
|
|
60000000 00000000
|
|
|
|
`,
|
|
|
|
GMSJ0A: (b) => `
|
2022-04-28 04:26:00 +09:00
|
|
|
C227768C 0000000A
|
2022-04-25 21:28:43 +09:00
|
|
|
3C60803F A0A35428
|
2022-04-28 04:26:00 +09:00
|
|
|
2805${b} 40A20038
|
2022-04-25 21:28:43 +09:00
|
|
|
3C60817F 38A00001
|
|
|
|
98A300B3 98A30100
|
|
|
|
3C60803E 84A3A8EE
|
2022-04-28 04:26:00 +09:00
|
|
|
90A30004 38A00040
|
|
|
|
90A30000 3C608027
|
2022-04-25 21:28:43 +09:00
|
|
|
60637AE4 7C6803A6
|
|
|
|
4E800020 2C000002
|
|
|
|
60000000 00000000
|
2022-11-02 01:53:22 +09:00
|
|
|
`,
|
|
|
|
GMSE01: (b) => `
|
|
|
|
C22979E4 0000000A
|
|
|
|
3C608040 A0A34454
|
|
|
|
2805${b} 40A20038
|
|
|
|
3C60817F 38A00001
|
|
|
|
98A300B3 98A30100
|
|
|
|
3C60803F 84A3970E
|
|
|
|
90A30004 38A00040
|
|
|
|
90A30000 3C608029
|
|
|
|
60637E3C 7C6803A6
|
|
|
|
4E800020 2C000002
|
|
|
|
60000000 00000000
|
2022-04-25 21:28:43 +09:00
|
|
|
`,
|
|
|
|
};
|
|
|
|
const zCodes = {
|
|
|
|
GMSJ01: '040eb024 60000000',
|
|
|
|
GMSJ0A: '04277710 60000000',
|
2022-11-02 01:53:22 +09:00
|
|
|
GMSE01: '04297A68 60000000',
|
2022-04-25 21:28:43 +09:00
|
|
|
};
|
|
|
|
|
2022-04-08 12:48:37 +09:00
|
|
|
export const defaultConfig = {
|
2022-04-25 21:28:43 +09:00
|
|
|
button: buttonValues.Y | buttonValues.DU,
|
2022-04-08 12:48:37 +09:00
|
|
|
};
|
|
|
|
export function getConfig() {
|
|
|
|
return {
|
|
|
|
...defaultConfig,
|
|
|
|
...(parseJSON(localStorage.getItem(lskey)) ?? {}),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
export default function codegen(version) {
|
|
|
|
const { button } = getConfig();
|
2022-04-25 21:28:43 +09:00
|
|
|
const g = baseCodes[version];
|
|
|
|
if (g == null) return '';
|
|
|
|
let code = g(button.toString(16).padStart(4, '0'));
|
|
|
|
if (button & buttonValues.Z) {
|
|
|
|
code += zCodes[version];
|
2022-04-08 12:48:37 +09:00
|
|
|
}
|
|
|
|
return code.replace(/\s/g, '');
|
|
|
|
}
|