forked from lrusso/Emulatrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Emulatrix_GameBoy.htm
executable file
·329 lines (305 loc) · 16.8 KB
/
Emulatrix_GameBoy.htm
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Emulatrix</title>
<link rel="stylesheet" href="Emulatrix.css">
</head>
<body>
<script>
var container_width;
var container_height;
function loadRomIntoVD()
{
// STARTS THE VIRTUAL FILE SYSTEM
startFileSystem();
// CREATES THE ROM FILE IN THE VIRTUAL DRIVE
var dataView=new Uint8Array(parent.ROMDATA);
FS.createDataFile("/","game.gb",dataView,true,false);
// CREATES THE FOLDERS IN THE VIRTUAL DRIVE IN ORDER TO SAVE THE CONFIG FILE
FS.createFolder("/home/web_user", "retroarch", true, true);
FS.createFolder("/home/web_user/retroarch", "userdata", true, true);
// SET THE VARIABLE FOR EMPTY VALUE IN THE CONFIG FILE. USING RETROARCH WEB IN MAC HAS A BUG THAT
// ANY NULL KEY IS FIRED AS THE COMMAND KEY. THAT'S WHY IS SCROLL_BACK INSTEAD OF NUL. THERE IS
// ANOTHER BUG IN MAC WITH THE COMMAND KEY, THAT IS FIRED AS THE TURBO BUTTON, NO MATTER THE CONFIG.
var emptyValue = "scroll_lock";
// CREATES THE VARIABLE FOR THE CONFIGURATION FILE
var config = "";
// SETS THE DEFAULT FOLDER WHEN BROWSING THE VIRTUAL DRIVE
config += "rgui_browser_directory = /\n";
// SETS THE KEY FOR THE START AND SELECT BUTTON
config += "input_player1_start = s\n";
config += "input_player1_start_btn = s\n";
config += "input_player1_select = a\n";
config += "input_player1_select_btn = a\n";
// SETS THE KEYS FOR THE BUTTONS A, B
config += "input_player1_a = x\n";
config += "input_player1_b = z\n";
// SETS THE KEYS FOR UNWANTED FUNCTIONS
config += "input_toggle_fast_forward = " + emptyValue + "\n";
config += "input_hold_fast_forward = " + emptyValue + "\n";
config += "input_toggle_slowmotion = " + emptyValue + "\n";
config += "input_hold_slowmotion = " + emptyValue + "\n";
config += "input_save_state = " + emptyValue + "\n";
config += "input_load_state = " + emptyValue + "\n";
config += "input_toggle_fullscreen = " + emptyValue + "\n";
config += "input_exit_emulator = " + emptyValue + "\n";
config += "input_state_slot_increase = " + emptyValue + "\n";
config += "input_state_slot_decrease = " + emptyValue + "\n";
config += "input_rewind = " + emptyValue + "\n";
config += "input_movie_record_toggle = " + emptyValue + "\n";
config += "input_pause_toggle = " + emptyValue + "\n";
config += "input_frame_advance = " + emptyValue + "\n";
config += "input_reset = " + emptyValue + "\n";
config += "input_shader_next = " + emptyValue + "\n";
config += "input_shader_prev = " + emptyValue + "\n";
config += "input_cheat_index_plus = " + emptyValue + "\n";
config += "input_cheat_index_minus = " + emptyValue + "\n";
config += "input_cheat_toggle = " + emptyValue + "\n";
config += "input_screenshot = " + emptyValue + "\n";
config += "input_audio_mute = " + emptyValue + "\n";
config += "input_osk_toggle = " + emptyValue + "\n";
config += "input_netplay_game_watch = " + emptyValue + "\n";
config += "input_enable_hotkey = " + emptyValue + "\n";
config += "input_volume_up = " + emptyValue + "\n";
config += "input_volume_down = " + emptyValue + "\n";
config += "input_overlay_next = " + emptyValue + "\n";
config += "input_disk_eject_toggle = " + emptyValue + "\n";
config += "input_disk_next = " + emptyValue + "\n";
config += "input_disk_prev = " + emptyValue + "\n";
config += "input_grab_mouse_toggle = " + emptyValue + "\n";
config += "input_game_focus_toggle = " + emptyValue + "\n";
config += "input_menu_toggle = " + emptyValue + "\n";
config += "input_recording_toggle = " + emptyValue + "\n";
config += "input_streaming_toggle = " + emptyValue + "\n";
// PLAYER 1
config += "input_player1_x = " + emptyValue + "\n";
config += "input_player1_y = " + emptyValue + "\n";
config += "input_player1_l = " + emptyValue + "\n";
config += "input_player1_l2 = " + emptyValue + "\n";
config += "input_player1_l3 = " + emptyValue + "\n";
config += "input_player1_r = " + emptyValue + "\n";
config += "input_player1_r2 = " + emptyValue + "\n";
config += "input_player1_r3 = " + emptyValue + "\n";
config += "input_player1_l_x_plus = " + emptyValue + "\n";
config += "input_player1_l_x_minus = " + emptyValue + "\n";
config += "input_player1_l_y_plus = " + emptyValue + "\n";
config += "input_player1_l_y_minus = " + emptyValue + "\n";
config += "input_player1_r_x_plus = " + emptyValue + "\n";
config += "input_player1_r_x_minus = " + emptyValue + "\n";
config += "input_player1_r_y_plus = " + emptyValue + "\n";
config += "input_player1_r_y_minus = " + emptyValue + "\n";
config += "input_player1_gun_trigger = " + emptyValue + "\n";
config += "input_player1_gun_offscreen_shot = " + emptyValue + "\n";
config += "input_player1_gun_aux_a = " + emptyValue + "\n";
config += "input_player1_gun_aux_b = " + emptyValue + "\n";
config += "input_player1_gun_aux_c = " + emptyValue + "\n";
config += "input_player1_gun_start = " + emptyValue + "\n";
config += "input_player1_gun_select = " + emptyValue + "\n";
config += "input_player1_gun_dpad_up = " + emptyValue + "\n";
config += "input_player1_gun_dpad_down = " + emptyValue + "\n";
config += "input_player1_gun_dpad_left = " + emptyValue + "\n";
config += "input_player1_gun_dpad_right = " + emptyValue + "\n";
config += "input_player1_turbo = " + emptyValue + "\n";
// PLAYER 2
config += "input_player2_up = " + emptyValue + "\n";
config += "input_player2_down = " + emptyValue + "\n";
config += "input_player2_left = " + emptyValue + "\n";
config += "input_player2_right = " + emptyValue + "\n";
config += "input_player2_start = " + emptyValue + "\n";
config += "input_player2_select = " + emptyValue + "\n";
config += "input_player2_a = " + emptyValue + "\n";
config += "input_player2_b = " + emptyValue + "\n";
config += "input_player2_x = " + emptyValue + "\n";
config += "input_player2_y = " + emptyValue + "\n";
config += "input_player2_l = " + emptyValue + "\n";
config += "input_player2_l2 = " + emptyValue + "\n";
config += "input_player2_l3 = " + emptyValue + "\n";
config += "input_player2_r = " + emptyValue + "\n";
config += "input_player2_r2 = " + emptyValue + "\n";
config += "input_player2_r3 = " + emptyValue + "\n";
config += "input_player2_l_x_plus = " + emptyValue + "\n";
config += "input_player2_l_x_minus = " + emptyValue + "\n";
config += "input_player2_l_y_plus = " + emptyValue + "\n";
config += "input_player2_l_y_minus = " + emptyValue + "\n";
config += "input_player2_r_x_plus = " + emptyValue + "\n";
config += "input_player2_r_x_minus = " + emptyValue + "\n";
config += "input_player2_r_y_plus = " + emptyValue + "\n";
config += "input_player2_r_y_minus = " + emptyValue + "\n";
config += "input_player2_gun_trigger = " + emptyValue + "\n";
config += "input_player2_gun_offscreen_shot = " + emptyValue + "\n";
config += "input_player2_gun_aux_a = " + emptyValue + "\n";
config += "input_player2_gun_aux_b = " + emptyValue + "\n";
config += "input_player2_gun_aux_c = " + emptyValue + "\n";
config += "input_player2_gun_start = " + emptyValue + "\n";
config += "input_player2_gun_select = " + emptyValue + "\n";
config += "input_player2_gun_dpad_up = " + emptyValue + "\n";
config += "input_player2_gun_dpad_down = " + emptyValue + "\n";
config += "input_player2_gun_dpad_left = " + emptyValue + "\n";
config += "input_player2_gun_dpad_right = " + emptyValue + "\n";
config += "input_player2_turbo = " + emptyValue + "\n";
// PLAYER 3
config += "input_player3_up = " + emptyValue + "\n";
config += "input_player3_down = " + emptyValue + "\n";
config += "input_player3_left = " + emptyValue + "\n";
config += "input_player3_right = " + emptyValue + "\n";
config += "input_player3_start = " + emptyValue + "\n";
config += "input_player3_select = " + emptyValue + "\n";
config += "input_player3_a = " + emptyValue + "\n";
config += "input_player3_b = " + emptyValue + "\n";
config += "input_player3_x = " + emptyValue + "\n";
config += "input_player3_y = " + emptyValue + "\n";
config += "input_player3_l = " + emptyValue + "\n";
config += "input_player3_l2 = " + emptyValue + "\n";
config += "input_player3_l3 = " + emptyValue + "\n";
config += "input_player3_r = " + emptyValue + "\n";
config += "input_player3_r2 = " + emptyValue + "\n";
config += "input_player3_r3 = " + emptyValue + "\n";
config += "input_player3_l_x_plus = " + emptyValue + "\n";
config += "input_player3_l_x_minus = " + emptyValue + "\n";
config += "input_player3_l_y_plus = " + emptyValue + "\n";
config += "input_player3_l_y_minus = " + emptyValue + "\n";
config += "input_player3_r_x_plus = " + emptyValue + "\n";
config += "input_player3_r_x_minus = " + emptyValue + "\n";
config += "input_player3_r_y_plus = " + emptyValue + "\n";
config += "input_player3_r_y_minus = " + emptyValue + "\n";
config += "input_player3_gun_trigger = " + emptyValue + "\n";
config += "input_player3_gun_offscreen_shot = " + emptyValue + "\n";
config += "input_player3_gun_aux_a = " + emptyValue + "\n";
config += "input_player3_gun_aux_b = " + emptyValue + "\n";
config += "input_player3_gun_aux_c = " + emptyValue + "\n";
config += "input_player3_gun_start = " + emptyValue + "\n";
config += "input_player3_gun_select = " + emptyValue + "\n";
config += "input_player3_gun_dpad_up = " + emptyValue + "\n";
config += "input_player3_gun_dpad_down = " + emptyValue + "\n";
config += "input_player3_gun_dpad_left = " + emptyValue + "\n";
config += "input_player3_gun_dpad_right = " + emptyValue + "\n";
config += "input_player3_turbo = " + emptyValue + "\n";
// PLAYER 4
config += "input_player4_up = " + emptyValue + "\n";
config += "input_player4_down = " + emptyValue + "\n";
config += "input_player4_left = " + emptyValue + "\n";
config += "input_player4_right = " + emptyValue + "\n";
config += "input_player4_start = " + emptyValue + "\n";
config += "input_player4_select = " + emptyValue + "\n";
config += "input_player4_a = " + emptyValue + "\n";
config += "input_player4_b = " + emptyValue + "\n";
config += "input_player4_x = " + emptyValue + "\n";
config += "input_player4_y = " + emptyValue + "\n";
config += "input_player4_l = " + emptyValue + "\n";
config += "input_player4_l2 = " + emptyValue + "\n";
config += "input_player4_l3 = " + emptyValue + "\n";
config += "input_player4_r = " + emptyValue + "\n";
config += "input_player4_r2 = " + emptyValue + "\n";
config += "input_player4_r3 = " + emptyValue + "\n";
config += "input_player4_l_x_plus = " + emptyValue + "\n";
config += "input_player4_l_x_minus = " + emptyValue + "\n";
config += "input_player4_l_y_plus = " + emptyValue + "\n";
config += "input_player4_l_y_minus = " + emptyValue + "\n";
config += "input_player4_r_x_plus = " + emptyValue + "\n";
config += "input_player4_r_x_minus = " + emptyValue + "\n";
config += "input_player4_r_y_plus = " + emptyValue + "\n";
config += "input_player4_r_y_minus = " + emptyValue + "\n";
config += "input_player4_gun_trigger = " + emptyValue + "\n";
config += "input_player4_gun_offscreen_shot = " + emptyValue + "\n";
config += "input_player4_gun_aux_a = " + emptyValue + "\n";
config += "input_player4_gun_aux_b = " + emptyValue + "\n";
config += "input_player4_gun_aux_c = " + emptyValue + "\n";
config += "input_player4_gun_start = " + emptyValue + "\n";
config += "input_player4_gun_select = " + emptyValue + "\n";
config += "input_player4_gun_dpad_up = " + emptyValue + "\n";
config += "input_player4_gun_dpad_down = " + emptyValue + "\n";
config += "input_player4_gun_dpad_left = " + emptyValue + "\n";
config += "input_player4_gun_dpad_right = " + emptyValue + "\n";
config += "input_player4_turbo = " + emptyValue + "\n";
// PLAYER 5
config += "input_player5_up = " + emptyValue + "\n";
config += "input_player5_down = " + emptyValue + "\n";
config += "input_player5_left = " + emptyValue + "\n";
config += "input_player5_right = " + emptyValue + "\n";
config += "input_player5_start = " + emptyValue + "\n";
config += "input_player5_select = " + emptyValue + "\n";
config += "input_player5_a = " + emptyValue + "\n";
config += "input_player5_b = " + emptyValue + "\n";
config += "input_player5_x = " + emptyValue + "\n";
config += "input_player5_y = " + emptyValue + "\n";
config += "input_player5_l = " + emptyValue + "\n";
config += "input_player5_l2 = " + emptyValue + "\n";
config += "input_player5_l3 = " + emptyValue + "\n";
config += "input_player5_r = " + emptyValue + "\n";
config += "input_player5_r2 = " + emptyValue + "\n";
config += "input_player5_r3 = " + emptyValue + "\n";
config += "input_player5_l_x_plus = " + emptyValue + "\n";
config += "input_player5_l_x_minus = " + emptyValue + "\n";
config += "input_player5_l_y_plus = " + emptyValue + "\n";
config += "input_player5_l_y_minus = " + emptyValue + "\n";
config += "input_player5_r_x_plus = " + emptyValue + "\n";
config += "input_player5_r_x_minus = " + emptyValue + "\n";
config += "input_player5_r_y_plus = " + emptyValue + "\n";
config += "input_player5_r_y_minus = " + emptyValue + "\n";
config += "input_player5_gun_trigger = " + emptyValue + "\n";
config += "input_player5_gun_offscreen_shot = " + emptyValue + "\n";
config += "input_player5_gun_aux_a = " + emptyValue + "\n";
config += "input_player5_gun_aux_b = " + emptyValue + "\n";
config += "input_player5_gun_aux_c = " + emptyValue + "\n";
config += "input_player5_gun_start = " + emptyValue + "\n";
config += "input_player5_gun_select = " + emptyValue + "\n";
config += "input_player5_gun_dpad_up = " + emptyValue + "\n";
config += "input_player5_gun_dpad_down = " + emptyValue + "\n";
config += "input_player5_gun_dpad_left = " + emptyValue + "\n";
config += "input_player5_gun_dpad_right = " + emptyValue + "\n";
config += "input_player5_turbo = " + emptyValue + "\n";
// SETS THE VIDEO CONFIGURATION
container_width = document.getElementById("container").offsetWidth;
container_height = document.getElementById("container").offsetHeight;
config += "video_vsync = true\n";
config += "video_scale = 1\n";
config += "video_window_x = " + container_width + "\n";
config += "video_window_y = " + container_height + "\n";
config += "aspect_ratio_index = 23\n";
config += "custom_viewport_width = " + container_width + "\n";
config += "custom_viewport_height = " + container_height + "\n";
config += "custom_viewport_x = 0\n";
config += "custom_viewport_y = 0\n";
// SETS THE AUDIO LATENCY
config += "audio_latency = 128\n";
// HIDES THE NOTIFICATION MESSAGES
config += "video_message_pos_x = -100\n";
config += "video_message_pos_y = -100\n";
config += "menu_enable_widgets = false\n";
// CREATES THE FILE WITH THE CONFIGURATION
FS.createDataFile("/home/web_user/retroarch/userdata", "retroarch.cfg", config, true, true);
// RUNS THE EMULATOR WITH THE SELECTED ROM
Module.callMain(["-v","/game.gb"]);
// RESIZES THE CANVAS
document.getElementById("canvas").width = container_width;
document.getElementById("canvas").height = container_height;
}
window.onload = function()
{
document.getElementById("container").style.display="block";
setTimeout(function(){loadRomIntoVD();},1000);
document.addEventListener("click", parent.goBackButtonResetIncrement, false);
document.addEventListener("dblclick", parent.goBackButtonResetIncrement, false);
document.addEventListener("mousemove", parent.goBackButtonResetIncrement, false);
}
window.onerror = function (msg, url, lineNo, columnNo, error)
{
// SOMETIMES THE LIBRETRO TAKES TOO MUCH TIME TO LOAD AND MAY THROUGH AN ERROR.
// THE CODE BELOW GIVES ANOTHER TRY TO RUN THE EMULATOR WITH THE SELECTED ROM.
setTimeout(function()
{
// RUNS THE EMULATOR WITH THE SELECTED ROM
Module.callMain(["-v","/game.gb"]);
// RESIZES THE CANVAS
document.getElementById("canvas").width = container_width;
document.getElementById("canvas").height = container_height;
}, 5000);
return true;
}
</script>
<div class="gui_pleasewait_title"><script>document.write(parent.STRING_STARTINGEMULATOR);</script></div><div class="pleasewait"><div class="lds-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>
<div id="container"><canvas id="canvas" oncontextmenu="event.preventDefault()"></canvas></div>
<script src="Emulatrix_GameBoy.js"></script>
</body>
</html>