Skip to content

Commit

Permalink
added binary edit toggle for faster experimentation; fixed hex editor…
Browse files Browse the repository at this point in the history
… updating bug
  • Loading branch information
fudgepop01 committed Jun 21, 2020
1 parent fbdadeb commit 9a2e9f8
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 13 deletions.
13 changes: 7 additions & 6 deletions src/components/Hex.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
export let data;
export let params;
let editor;
let lastChange;
let dispatch = createEventDispatcher();
onMount(async () => {
Expand All @@ -30,16 +31,16 @@
description: param.description
})
}
dispatch('updateEditorFn', (data) => {
editor.acceptFile(new File([new Blob([data])], 'amiibodata'));
});
}, 100);
})
async function broadcastChange() {
dispatch('dataChanged', await editor.saveFile());
}
let binView = false;
const toggleBinView = () => {
lastChange = await editor.saveFile();
dispatch('dataChanged', lastChange);
}
</script>
Expand Down
13 changes: 12 additions & 1 deletion src/components/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@
return await card.init();
}
let updateEditorFn = (data) => {};
async function loadFile(method) {
let paths = await remote.dialog.showOpenDialog({
message: 'open amiibo bin'
});
if (method === 'encrypt') data = decrypt(await readFile(paths[0]), keys);
else data = await readFile(paths[0]);
updateEditorFn(data);
}
async function saveFile(method) {
Expand Down Expand Up @@ -120,6 +122,7 @@
data = await card.read();
data = decrypt(data, keys);
data[0xE3] |= 0b00000001;
updateEditorFn(data);
}
})
.modal('show');
Expand Down Expand Up @@ -150,6 +153,8 @@
targetCard = decrypt(targetCard, keys);
data.copy(targetCard, 0xE0, 0xE0, 0x1B5);
// uncomment this to be able to set the nickname:
// targetCard.write(newStr, 0x39, newStr.length * 2, 'utf16le');
sign(targetCard);
let encrypted = encrypt(targetCard, keys);
Expand Down Expand Up @@ -258,6 +263,7 @@
<div class="ui placeholder">
<div class="square image"></div>
</div>

<div class="io">
<div class="ui two mini buttons">
<button class="ui labeled icon button" on:click={() => loadFile('encrypt')}>
Expand Down Expand Up @@ -312,6 +318,11 @@
{#if page === 'overview'}
<Overview {data} {params} {abilities} on:load={setTimeout(() => window['$']('.ui.dropdown').dropdown(), 100)}/>
{:else if page === 'hex'}
<Hex on:dataChanged={(evt) => data = Buffer.from(evt.detail)} {data} {params}></Hex>
<Hex
on:dataChanged={(evt) => data = Buffer.from(evt.detail)}
on:updateEditorFn={(evt) => updateEditorFn = evt.detail}
{data}
{params}>
</Hex>
{/if}
</div>
82 changes: 76 additions & 6 deletions src/components/Overview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,78 @@
}
let thing = false;
function checkBoundsAndSet(evt, param) {
if (param.min <= evt.target.value && evt.target.value <= param.max) {
writeAdjustment(evt.target.value, param);
function checkBoundsAndSet(evt, param, isBin) {
let value;
if (isBin) {
value = parseInt(evt.target.value, 2);
if (param.min !== 0 && evt.target.value.startsWith('1')) {
value = param.min + parseInt(evt.target.value.substring(1), 2);
}
} else {
evt.target.value = (evt.target.value > 0) ? param.max : param.min;
writeAdjustment(evt.target.value, param);
value = evt.target.value;
}
if (param.min <= value && value <= param.max) {
writeAdjustment(value, param);
} else {
const v = (value > 0) ? param.max : param.min;
writeAdjustment(v, param);
}
thing = !thing;
}
function binEdit(evt, param) {
let selStart;
let selEnd;
switch (evt.key) {
case 'ArrowLeft':
case 'ArrowRight':
return;
case 'i':
evt.preventDefault();
selStart = evt.target.selectionStart;
selEnd = evt.target.selectionEnd;
let out = evt.target.value.substring(0, selStart);
for (const ch of evt.target.value.substring(selStart, selEnd)) {
out += (ch === '0') ? '1' : '0';
}
out += evt.target.value.substring(selEnd);
evt.target.value = out;
evt.target.setSelectionRange(selStart, selEnd);
checkBoundsAndSet(evt, param, true);
break;
case 'Backspace':
evt.preventDefault();
selStart = evt.target.selectionStart
evt.target.value =
evt.target.value.substring(0, selStart - 1)
+ '0'
+ evt.target.value.substring(selStart);
evt.target.setSelectionRange(selStart - 1, selStart - 1);
checkBoundsAndSet(evt, param, true);
break;
case '1':
case '0':
evt.preventDefault();
selStart = evt.target.selectionStart
evt.target.value =
evt.target.value.substring(0, selStart)
+ evt.key
+ evt.target.value.substring(selStart + 1);
evt.target.setSelectionRange(selStart + 1, selStart + 1);
checkBoundsAndSet(evt, param, true)
break;
default:
evt.preventDefault();
}
}
</script>

<style>
Expand Down Expand Up @@ -208,7 +270,15 @@
<!-- forces update when value is changed -->
<span style="display: none">{thing}</span>
{#if displayBin}
({(param.value !== undefined) ? (param.value >>> 0).toString(2).substr(-param.bitCount).padStart(param.bitCount, '0') : ''})
<br/>
<div class="ui transparent left icon input">
<input
value={(param.value >>> 0).toString(2).substr(-param.bitCount).padStart(param.bitCount, '0')}
on:keydown={(evt) => binEdit(evt, param)}
style="font-family: consolas;"
placeholder="value..."/>
<i class="angle double right icon"></i>
</div>
{/if}
{/if}
</div>
Expand Down
88 changes: 88 additions & 0 deletions static/amiibo/regions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,60 @@ aggression: u16
behavior
how aggressive the amiibo is (a value of 0 will prevent all attacks)

attack bit 1: bits
0x168b0
0x168b1
behavior
will occasionally make the AI attack - it is in an odd position compared to the rest

attack bit 2: bits
0x169b0
0x169b1
behavior
makes the AI attack on occasion

double-jump bit: bits
0x169b1
0x169b2
behavior
makes the AI frequently double-jump

attack bits 3: bits
0x169b2
0x169b8
behavior
controlls how often the AI attacks

edgeguard: u16
0x16A
0x16C
behavior
the chance of the amiibo jumping after the opponent to edgeguard

opposite-groundedness: bits
0x16Ab0
0x16Ab4
behavior
if the AI usually often jumps, increase this to lower that chance, and vice versa

edg b4-8: bits
0x16Ab4
0x16Ab8
behavior
TEMPORARY REGION FOR EXPERIMENTATION

edg b8-12: bits
0x16Bb0
0x16Bb4
behavior
TEMPORARY REGION FOR EXPERIMENTATION

edg b12-16: bits
0x16Bb4
0x16Bb8
behavior
TEMPORARY REGION FOR EXPERIMENTATION

anticipation: u16
0x16C
0x16E
Expand All @@ -103,6 +151,12 @@ grab: u8
moveset
the chance of the amiibo running the grab routine

parry skill: u8
0x178
0x179
behavior
the chance of the amiibo going for a parry

smashball collector: u16
0x17b
0x17d
Expand Down Expand Up @@ -157,6 +211,12 @@ down tilt: u8
moveset
the chance of the amiibo running the dTilt routine

hard punish fsmash: bits
0x18c b3
0x18c b4
moveset
tells the amiibo to punish shieldbreak / rest with fsmash

forward smash: u8
0x18d
0x18e
Expand Down Expand Up @@ -274,6 +334,34 @@ costume: u8
misc
the skin the amiibo has

unknown 1: u8
0x1A4
0x1A5
behavior
has something to do with attack patterns.
usually 0x08 or 0x09

unknown 2a: u8
0x1A5
0x1A6
behavior
has something to do with attack patterns.
usually 0xFC, 0xFD, or 0x00

unknown 2b: u8
0x1A6
0x1A7
behavior
has something to do with attack patterns.
usually 0xFC, 0xFD, or 0x00

unknown 2c: u8
0x1A7
0x1A8
behavior
has something to do with attack patterns.
usually 0xFC, 0xFD, or 0x00

custom moves: u8
0xff
0x100
Expand Down
Binary file added static/amiibo/sample_files/CAP_2
Binary file not shown.
Binary file added static/amiibo/sample_files/CAP_2_ENC
Binary file not shown.
Binary file added static/amiibo/sample_files/CAP_3
Binary file not shown.

0 comments on commit 9a2e9f8

Please sign in to comment.