Chipvuelto8/index.html
2024-09-02 22:20:00 +02:00

55 lines
1.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chip 8 emulator Test</title>
<style>
body {
background-color: #000;
color: #EEE;
}
#emulator-screen{
border: 1px solid pink;
}
</style>
<script src="./dist/revuelto8ts.js"></script>
</head>
<body>
<h1>Chip 8 emulator</h1>
<!-- Original screen is 64x32 -->
<canvas id="emulator-screen" width="256" height="128"></canvas>
<script>
// Assuming your library exposes an Emulator class
console.log(Revuelto8ts);
console.log(Revuelto8ts.Chip8Emulator);
const emulator = new Revuelto8ts.Chip8Emulator();
// Load ROM (you'll need to implement this method in your emulator)
fetch('./roms/1-chip8-logo.ch8')
.then(response => response.arrayBuffer())
.then(buffer => {
//emulator.loadROM(new Uint8Array(buffer));
// Load and start
emulator.loadRom(buffer);
});
const emulatorCanvas = document.getElementById('emulator-screen');
// Loop
while(true) {
emulator.emulateCycle();
emulator.drawGraphics();
emulator.drawToCanvas(emulatorCanvas, 4);
}
</script>
</body>
</html>