-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59c4653
commit 1de3391
Showing
4 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,29 @@ | ||
const go = new Go() | ||
const form = document.querySelector("form#select-rom") | ||
|
||
WebAssembly | ||
.instantiateStreaming(fetch("chip8.wasm"), go.importObject) | ||
.then(result => go.run(result.instance)) | ||
form.addEventListener("submit", (e) => { | ||
e.preventDefault() | ||
|
||
const data = new FormData(form) | ||
|
||
const rom = data.get("rom") | ||
|
||
document.rom = rom | ||
|
||
form.remove() | ||
|
||
const go = new Go() | ||
|
||
WebAssembly | ||
.instantiateStreaming(fetch(`chip8.wasm`), go.importObject) | ||
.then(result => { | ||
go.run(result.instance) | ||
const canvas = document.getElementsByTagName("canvas")[0] | ||
|
||
canvas.addEventListener("keydown", (e) => { | ||
console.log(e.key) | ||
if (e.key == "Escape") { | ||
location.reload() | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters