Skip to content

Commit 7e74ac2

Browse files
deploy: 757449a
1 parent e423df2 commit 7e74ac2

File tree

1 file changed

+46
-19
lines changed

1 file changed

+46
-19
lines changed

index.html

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,38 @@ <h1 class="retro-title">zc8</h1>
145145
window.enable_loadstore_quirk = Module.cwrap('enable_loadstore_quirk', 'void', 'bool');
146146
window.disable_audio = Module.cwrap('disable_audio', 'void', 'bool');
147147

148+
149+
function get_game_function(game) {
150+
if (game == "pong") {
151+
return load_pong;
152+
}
153+
else if (game == "breakout") {
154+
return load_breakout;
155+
}
156+
else if (game == "spaceinvaders") {
157+
return load_spaceinvaders;
158+
}
159+
else if (game == "blinky") {
160+
return load_blinky;
161+
}
162+
else if (game == "tank") {
163+
return load_tank;
164+
}
165+
else if (game == "astrododge") {
166+
return load_astrododge;
167+
}
168+
else if (game == "filter") {
169+
return load_filter
170+
}
171+
else if (game == "animalrace") {
172+
return load_animalrace;
173+
}
174+
else if (game == "tetris") {
175+
return load_tetris;
176+
}
177+
178+
}
179+
148180
document.getElementById('pong').onclick = () => {
149181
const select = document.getElementById('game-select').value = 'pong';
150182
load_pong();
@@ -162,51 +194,46 @@ <h1 class="retro-title">zc8</h1>
162194

163195
document.getElementById("game-select").addEventListener("change", function(event) {
164196
const value = event.target.value;
165-
if (value == "pong")
166-
load_pong();
167-
else if (value == "breakout")
168-
load_breakout();
169-
else if (value == "spaceinvaders") {
197+
198+
const game_function = get_game_function(value);
199+
200+
if (value == "spaceinvaders") {
170201
enable_shiftquirk(true);
171202
document.getElementById('shift-quirk-checkbox').checked = 'checked';
172-
load_spaceinvaders();
173203
}
174204
else if (value == "blinky") {
175205
enable_shiftquirk(true);
176206
enable_loadstore_quirk(true);
177207
document.getElementById('shift-quirk-checkbox').checked = 'checked';
178208
document.getElementById('loadstore-quirk-checkbox').checked = 'checked';
179-
load_blinky();
180-
}
181-
else if (value == "tank")
182-
load_tank();
183-
else if (value == "astrododge")
184-
load_astrododge();
185-
else if (value == "filter")
186-
load_filter();
187-
else if (value == "animalrace")
188-
load_animalrace();
189-
else if (value == "tetris")
190-
load_tetris();
191-
209+
}
210+
211+
game_function();
212+
192213
});
193214

194215
document.getElementById('shift-quirk-checkbox').addEventListener('change', (event) => {
216+
const value = document.getElementById("game-select").value;
195217
if (event.currentTarget.checked) {
196218
enable_shiftquirk(true);
197219
}
198220
else {
199221
enable_shiftquirk(false);
200222
}
223+
const game_function = get_game_function(value);
224+
game_function();
201225
});
202226

203227
document.getElementById('loadstore-quirk-checkbox').addEventListener('change', (event) => {
228+
const value = document.getElementById("game-select").value;
204229
if (event.currentTarget.checked) {
205230
enable_loadstore_quirk(true);
206231
}
207232
else {
208233
enable_loadstore_quirk(false);
209234
}
235+
const game_function = get_game_function(value);
236+
game_function();
210237
});
211238

212239

0 commit comments

Comments
 (0)