2024-09-01 15:52:46 +01:00
|
|
|
<!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;
|
2024-09-02 21:20:00 +01:00
|
|
|
color: #EEE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#emulator-screen{
|
|
|
|
border: 1px solid pink;
|
2024-09-01 15:52:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
2024-09-02 21:20:00 +01:00
|
|
|
|
|
|
|
<script src="./dist/revuelto8ts.js"></script>
|
2024-09-01 15:52:46 +01:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
2024-09-02 21:20:00 +01:00
|
|
|
<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);
|
2024-09-01 15:52:46 +01:00
|
|
|
});
|
|
|
|
|
2024-09-02 21:20:00 +01:00
|
|
|
const emulatorCanvas = document.getElementById('emulator-screen');
|
|
|
|
|
|
|
|
// Loop
|
|
|
|
while(true) {
|
|
|
|
emulator.emulateCycle();
|
|
|
|
|
|
|
|
emulator.drawGraphics();
|
|
|
|
emulator.drawToCanvas(emulatorCanvas, 4);
|
|
|
|
}
|
|
|
|
</script>
|
2024-09-01 15:52:46 +01:00
|
|
|
</body>
|
|
|
|
</html>
|