Skip to content

Commit

Permalink
* added error check for invalid hex input, with conversion to 0xFF an…
Browse files Browse the repository at this point in the history
…d alert
  • Loading branch information
zoul0813 authored and Zeal8bit committed Oct 6, 2024
1 parent 350fe5a commit 250fa88
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions view/tabs/memdump.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ $("#dumpcontent").on("focusin focusout keyup keydown", ".membytes div[contentedi
return;
}

if(!/^[a-fA-F0-9]+$/.test(value)) {
// TODO: limit input to valid HEX values
}
// TODO: limit input to valid HEX values
// if(!/^[a-fA-F0-9]+$/.test(value)) {
// }

if(value.length > 2) {
evt.preventDefault();
Expand Down Expand Up @@ -199,6 +199,10 @@ $("#dumpcontent").on("focusin focusout keyup keydown", ".membytes div[contentedi
var current = $this.text().toLowerCase();
if(current != previous) {
var new_value = parseInt(current, 16);
if(Number.isNaN(new_value)) {
popout.error(`Invalid value: 0x${$(this).text().toUpperCase()}, converting to 0xFF`);
new_value = 0xFF;
}
zealcom.mem_write(addr, new_value);

var c = String.fromCharCode(new_value);
Expand Down

0 comments on commit 250fa88

Please sign in to comment.