๐Ÿ“ฆ ajeetdsouza / chip8

๐Ÿ“„ util.js ยท 45 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45const ROMS = [
    "15PUZZLE",
    "BCTEST",
    "BLINKY",
    "BLITZ",
    "BRIX",
    "CONNECT4",
    "GUESS",
    "HIDDEN",
    "IBM",
    "INVADERS",
    "KALEID",
    "MAZE",
    "MERLIN",
    "MISSILE",
    "PONG",
    "PONG2",
    "PUZZLE",
    "SYZYGY",
    "TANK",
    "TETRIS",
    "TICTAC",
    "UFO",
    "VBRIX",
    "VERS",
    "WIPEOFF"
];

const loadRom = () => {
    const romSelector = document.getElementById("rom-selector");
    const romName = romSelector.options[romSelector.selectedIndex].value;
    Module.ccall('load_rom', null, ['string'], [`roms/${romName}.ch8`])
};

const listRom = () => {
    const romSelector = document.getElementById('rom-selector');
    romSelector.innerHTML = "";
    ROMS.forEach(romName => {
        const option = document.createElement('option');
        option.value = romName;
        option.innerHTML = romName;
        romSelector.appendChild(option);
    });
};