FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
EmulatorJS/index.html at main · allancoding/EmulatorJS · GitHub
allancoding
/
EmulatorJS
Public
forked from
EmulatorJS/EmulatorJS
Notifications
You must be signed in to change notification settings
Fork
1
Star
4
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
EmulatorJS
/
index.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
445 lines (395 loc) · 17.2 KB
Breadcrumbs
EmulatorJS
/
index.html
Copy path
File metadata and controls
445 lines (395 loc) · 17.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
<!DOCTYPE html
>
<
html
lang
="
en
"
>
<
head
>
<
meta
charset
="
utf-8
"
>
<
title
>
EmulatorJS
</
title
>
<
link
rel
="
icon
"
href
="
docs/favicon.ico
"
sizes
="
16x16 32x32 48x48 64x64
"
type
="
image/vnd.microsoft.icon
"
>
<
meta
name
="
viewport
"
content
="
width = device-width, initial-scale = 1
"
>
<
style
>
body
,
html
{
height
:
100
%
;
background-color
:
black;
color
:
white;
}
body
{
margin
:
0
;
overflow
:
hidden;
}
body
,
#
box
,
#
top
{
display
:
flex;
align-items
:
center;
justify-content
:
center;
flex-direction
:
column;
}
#
box
{
color
:
#
aaa
;
height
:
20
em
;
width
:
30
em
;
max-width
:
80
%
;
max-height
:
80
%
;
background-color
:
#
333
;
border-radius
:
0.4
em
;
border
:
2
px
solid
#
555
;
position
:
relative;
flex-direction
:
column;
transition-duration
:
0.2
s
;
overflow
:
hidden;
font-family
:
monospace;
font-weight
:
bold;
font-size
:
20
px
;
margin
:
5
px
;
text-align
:
center;
padding
:
10
px
;
}
#
box
:
hover
,
#
box
[
drag
] {
border-color
:
#
1AAFFF
;
color
:
#
ddd
}
#
advanced
{
color
:
#
aaa
;
text-align
:
left;
width
:
30
em
;
max-width
:
80
%
;
background-color
:
#
333
;
border-radius
:
0.4
em
;
border
:
2
px
solid
#
555
;
position
:
relative;
flex-direction
:
column;
transition-duration
:
0.2
s
;
overflow
:
hidden;
font-family
:
monospace;
font-weight
:
bold;
font-size
:
20
px
;
margin
:
5
px
;
padding
:
10
px
;
}
#
advancedOptionsBox
{
margin-top
:
10
px
;
font-size
:
14
px
;
margin-left
:
20
px
;
}
.
advancedOptionsBoxRow
{
margin-top
:
10
px
;
}
#
input
{
cursor
:
pointer;
position
:
absolute;
left
:
0
;
top
:
0
;
width
:
100
%
;
height
:
100
%
;
opacity
:
0
;
}
#
display
{
width
:
100
%
;
height
:
100
%
}
select
,
button
{
padding
:
0.6
em
0.4
em
;
margin
:
0.5
em
;
width
:
15
em
;
max-width
:
100
%
;
font-family
:
monospace;
font-weight
:
bold;
font-size
:
16
px
;
background-color
:
#
444
;
color
:
#
aaa
;
border-radius
:
0.4
em
;
border
:
1
px
solid
#
555
;
cursor
:
pointer;
transition-duration
:
0.2
s
}
select
:
hover
,
button
:
hover
{
background-color
:
#
666
;
color
:
#
ddd
}
.
logo
{
width
:
130
px
;
height
:
130
px
;
filter
:
drop-shadow
(
0
0
8
px
white);
}
#
top
{
margin
:
5
px
;
}
</
style
>
</
head
>
<
body
>
<
div
id
="
top
"
>
<
h1
>
EmulatorJS Demo
</
h1
>
<
img
src
="
docs/Logo-light.png
"
alt
="
Logo
"
class
="
logo
"
>
<
br
>
</
div
>
<
div
id
="
box
"
>
<
input
type
="
file
"
id
="
input
"
title
="
Upload
"
/>
Drag ROM file or click here
</
div
>
<
div
id
="
advanced
"
>
<
div
id
="
advancedToggleBox
"
>
<
input
type
="
checkbox
"
id
="
advancedToggle
"
/>
<
label
for
="
advancedToggle
"
>
Show Advanced Options
</
label
>
</
div
>
<
div
id
="
advancedOptionsBox
"
>
<
div
class
="
advancedOptionsBoxRow
"
>
<
input
type
="
file
"
id
="
inputAdvanced
"
title
="
BIOS
"
/>
<
label
for
="
inputAdvanced
"
>
Upload BIOS file (if required)
</
label
>
</
div
>
<
div
class
="
advancedOptionsBoxRow
"
>
<
input
type
="
checkbox
"
id
="
debugToggle
"
/>
<
label
for
="
debugToggle
"
>
Enable Debug Mode
</
label
>
</
div
>
<
div
id
="
advancedOptionsBoxThreads
"
class
="
advancedOptionsBoxRow
"
>
<
input
type
="
checkbox
"
id
="
threadsToggle
"
/>
<
label
for
="
threadsToggle
"
>
Enable Threads
</
label
>
</
div
>
<
div
id
="
advancedOptionsCache
"
class
="
advancedOptionsBoxRow
"
>
<
input
type
="
checkbox
"
id
="
cacheToggle
"
checked
="
checked
"
/>
<
label
for
="
cacheToggle
"
>
Enable Cache
</
label
>
</
div
>
<
div
class
="
advancedOptionsBoxRow
"
>
<
span
>
Browser mode:
</
span
>
<
input
type
="
radio
"
id
="
browserModeAuto
"
name
="
browserMode
"
value
="
auto
"
>
<
label
for
="
browserModeAuto
"
>
Auto
</
label
>
<
input
type
="
radio
"
id
="
browserModeDesktop
"
name
="
browserMode
"
value
="
desktop
"
>
<
label
for
="
browserModeDesktop
"
>
Desktop
</
label
>
<
input
type
="
radio
"
id
="
browserModeMobile
"
name
="
browserMode
"
value
="
mobile
"
>
<
label
for
="
browserModeMobile
"
>
Mobile
</
label
>
</
div
>
</
div
>
</
div
>
<
script
>
let
enableDebug
=
false
;
let
enableThreads
=
false
;
let
browserMode
;
const
biosFileInput
=
document
.
getElementById
(
"inputAdvanced"
)
;
const
advancedToggle
=
document
.
getElementById
(
"advancedToggle"
)
;
const
advanced
=
document
.
getElementById
(
"advanced"
)
;
const
advancedOptionsBox
=
document
.
getElementById
(
"advancedOptionsBox"
)
;
advancedOptionsBox
.
style
.
display
=
"none"
;
advancedToggle
.
addEventListener
(
"change"
,
(
event
)
=>
{
if
(
event
.
target
.
checked
)
{
advancedOptionsBox
.
style
.
display
=
"block"
;
}
else
{
advancedOptionsBox
.
style
.
display
=
"none"
;
}
}
)
;
const
queryString
=
window
.
location
.
search
;
const
urlParams
=
new
URLSearchParams
(
queryString
)
;
const
debugToggle
=
document
.
getElementById
(
"debugToggle"
)
;
debugToggle
.
addEventListener
(
"change"
,
(
event
)
=>
{
enableDebug
=
event
.
target
.
checked
;
console
.
log
(
`Debug is
${
enableDebug
?
"enabled"
:
"disabled"
}
`
)
;
}
)
;
const
cacheToggle
=
document
.
getElementById
(
"cacheToggle"
)
;
window
.
EJS_cacheConfig
=
{
enabled
:
true
,
cacheMaxSizeMB
:
4096
,
// 4096 MB = 4 GB
cacheMaxAgeMins
:
7200
// 7200 minutes = 5 days
}
;
cacheToggle
.
addEventListener
(
"change"
,
(
event
)
=>
{
const
cacheEnabled
=
event
.
target
.
checked
;
console
.
log
(
`Cache is
${
cacheEnabled
?
"enabled"
:
"disabled"
}
`
)
;
window
.
EJS_cacheConfig
.
enabled
=
cacheEnabled
;
}
)
;
const
threadsToggleAvailable
=
document
.
getElementById
(
"advancedOptionsBoxThreads"
)
;
const
threadsToggle
=
document
.
getElementById
(
"threadsToggle"
)
;
threadsToggle
.
addEventListener
(
"change"
,
(
event
)
=>
{
enableThreads
=
event
.
target
.
checked
;
console
.
log
(
`Threads are
${
enableThreads
?
"enabled"
:
"disabled"
}
`
)
;
}
)
;
if
(
parseInt
(
urlParams
.
get
(
"debug"
)
)
===
1
||
urlParams
.
get
(
"debug"
)
===
"true"
)
{
enableDebug
=
true
;
debugToggle
.
checked
=
true
;
console
.
log
(
"Debug is enabled"
)
;
}
else
{
debugToggle
.
checked
=
false
;
console
.
log
(
"Debug is disabled"
)
;
}
if
(
window
.
SharedArrayBuffer
)
{
threadsToggleAvailable
.
style
.
display
=
"block"
;
if
(
parseInt
(
urlParams
.
get
(
"threads"
)
)
===
1
||
urlParams
.
get
(
"threads"
)
===
"true"
)
{
enableThreads
=
true
;
threadsToggle
.
checked
=
true
;
console
.
log
(
"Threads are enabled"
)
;
}
else
{
threadsToggle
.
checked
=
false
;
console
.
log
(
"Threads are disabled"
)
;
}
}
else
{
threadsToggleAvailable
.
style
.
display
=
"none"
;
console
.
warn
(
"Threads are disabled as SharedArrayBuffer is not available. Threads requires two headers to be set when sending you html page. See https://stackoverflow.com/a/68630724"
)
;
}
const
browserModeAuto
=
document
.
getElementById
(
"browserModeAuto"
)
;
browserModeAuto
.
addEventListener
(
"change"
,
(
event
)
=>
{
if
(
event
.
target
.
checked
)
{
browserMode
=
undefined
;
console
.
log
(
"Browser mode set to auto"
)
;
}
}
)
;
const
browserModeDesktop
=
document
.
getElementById
(
"browserModeDesktop"
)
;
browserModeDesktop
.
addEventListener
(
"change"
,
(
event
)
=>
{
if
(
event
.
target
.
checked
)
{
browserMode
=
"desktop"
;
console
.
log
(
"Browser mode set to desktop"
)
;
}
}
)
;
const
browserModeMobile
=
document
.
getElementById
(
"browserModeMobile"
)
;
browserModeMobile
.
addEventListener
(
"change"
,
(
event
)
=>
{
if
(
event
.
target
.
checked
)
{
browserMode
=
"mobile"
;
console
.
log
(
"Browser mode set to mobile"
)
;
}
}
)
;
if
(
urlParams
.
get
(
"browserMode"
)
)
{
browserMode
=
urlParams
.
get
(
"browserMode"
)
;
switch
(
browserMode
)
{
case
1
:
case
"1"
:
case
"mobile"
:
browserModeMobile
.
checked
=
true
;
break
;
case
2
:
case
"2"
:
case
"desktop"
:
browserModeDesktop
.
checked
=
true
;
break
;
default
:
browserModeAuto
.
checked
=
true
;
break
;
}
}
else
{
browserModeAuto
.
checked
=
true
;
}
if
(
urlParams
.
get
(
"rom"
)
)
{
console
.
log
(
`Loading ROM from URL: roms/
${
urlParams
.
get
(
"rom"
)
}
`
)
;
run
(
false
,
urlParams
.
get
(
"rom"
)
)
;
}
async
function
run
(
upload
,
file
)
{
const
url
=
upload
?
input
.
files
[
0
]
:
`roms/
${
file
}
`
;
const
parts
=
upload
?
input
.
files
[
0
]
.
name
.
split
(
"."
)
:
file
.
split
(
"."
)
;
const
biosUrl
=
biosFileInput
.
files
.
length
>
0
?
biosFileInput
.
files
[
0
]
:
""
;
const
core
=
await
(
async
(
ext
)
=>
{
if
(
[
"fds"
,
"nes"
,
"unif"
,
"unf"
]
.
includes
(
ext
)
)
return
"nes"
if
(
[
"smc"
,
"fig"
,
"sfc"
,
"gd3"
,
"gd7"
,
"dx2"
,
"bsx"
,
"swc"
]
.
includes
(
ext
)
)
return
"snes"
if
(
[
"z64"
,
"n64"
]
.
includes
(
ext
)
)
return
"n64"
if
(
[
"pce"
]
.
includes
(
ext
)
)
return
"pce"
if
(
[
"ngp"
,
"ngc"
]
.
includes
(
ext
)
)
return
"ngp"
if
(
[
"ws"
,
"wsc"
]
.
includes
(
ext
)
)
return
"ws"
if
(
[
"col"
,
"cv"
]
.
includes
(
ext
)
)
return
"coleco"
if
(
[
"d64"
]
.
includes
(
ext
)
)
return
"vice_x64sc"
if
(
[
"md"
,
"sg"
,
"smd"
,
"gen"
]
.
includes
(
ext
)
)
return
"segaMD"
if
(
[
"nds"
,
"gba"
,
"gb"
,
"z64"
,
"n64"
]
.
includes
(
ext
)
)
return
ext
if
(
[
"3ds"
,
"cci"
,
"cia"
,
"cxi"
,
"app"
]
.
includes
(
ext
)
)
return
"3ds"
return
await
new
Promise
(
resolve
=>
{
var
coreValues
=
{
"Nintendo 64"
:
"n64"
,
"Nintendo Game Boy"
:
"gb"
,
"Nintendo Game Boy Advance"
:
"gba"
,
"Nintendo DS"
:
"nds"
,
"Nintendo Entertainment System"
:
"nes"
,
"Super Nintendo Entertainment System"
:
"snes"
,
"PlayStation"
:
"psx"
,
"Virtual Boy"
:
"vb"
,
"Sega Mega Drive"
:
"segaMD"
,
"Sega Master System"
:
"segaMS"
,
"Sega CD"
:
"segaCD"
,
"Atari Lynx"
:
"lynx"
,
"Sega 32X"
:
"sega32x"
,
"Atari Jaguar"
:
"jaguar"
,
"Sega Game Gear"
:
"segaGG"
,
"Sega Saturn"
:
"segaSaturn"
,
"Atari 7800"
:
"atari7800"
,
"Atari 2600"
:
"atari2600"
,
"Arcade"
:
"arcade"
,
"NEC TurboGrafx-16/SuperGrafx/PC Engine"
:
"pce"
,
"NEC PC-FX"
:
"pcfx"
,
"SNK NeoGeo Pocket (Color)"
:
"ngp"
,
"Bandai WonderSwan (Color)"
:
"ws"
,
"ColecoVision"
:
"coleco"
,
"Commodore 64"
:
"vice_x64sc"
,
"Commodore 128"
:
"vice_x128"
,
"Commodore VIC20"
:
"vice_xvic"
,
"Commodore Plus/4"
:
"vice_xplus4"
,
"Commodore PET"
:
"vice_xpet"
,
"Amiga"
:
"puae"
}
if
(
enableThreads
)
{
coreValues
[
"DOSBOX-PURE"
]
=
"dosbox_pure"
;
coreValues
[
"PlayStation Portable"
]
=
"ppsspp"
;
coreValues
[
"Nintendo 3DS"
]
=
"3ds"
;
}
for
(
let
core
in
coreValues
)
{
if
(
core
.
toLowerCase
(
)
===
ext
)
{
resolve
(
core
)
}
}
const
cores
=
Object
.
keys
(
coreValues
)
.
sort
(
)
.
reduce
(
(
obj
,
key
)
=>
{
obj
[
key
]
=
coreValues
[
key
]
;
return
obj
;
}
,
{
}
)
;
const
button
=
document
.
createElement
(
"button"
)
const
select
=
document
.
createElement
(
"select"
)
for
(
const
type
in
cores
)
{
const
option
=
document
.
createElement
(
"option"
)
option
.
value
=
cores
[
type
]
option
.
textContent
=
type
select
.
appendChild
(
option
)
}
button
.
onclick
=
(
)
=>
resolve
(
select
[
select
.
selectedIndex
]
.
value
)
button
.
textContent
=
"Load game"
box
.
innerHTML
=
""
box
.
appendChild
(
select
)
box
.
appendChild
(
button
)
}
)
}
)
(
parts
.
pop
(
)
)
const
div
=
document
.
createElement
(
"div"
)
const
sub
=
document
.
createElement
(
"div"
)
const
script
=
document
.
createElement
(
"script"
)
sub
.
id
=
"game"
div
.
id
=
"display"
const
top
=
document
.
getElementById
(
"top"
)
;
top
.
remove
(
)
;
box
.
remove
(
)
;
div
.
appendChild
(
sub
)
;
advanced
.
remove
(
)
;
document
.
body
.
appendChild
(
div
)
window
.
EJS_player
=
"#game"
;
window
.
EJS_gameName
=
parts
.
shift
(
)
;
window
.
EJS_biosUrl
=
biosUrl
;
window
.
EJS_gameUrl
=
url
;
window
.
EJS_core
=
core
;
window
.
EJS_pathtodata
=
"data/"
;
window
.
EJS_startOnLoaded
=
true
;
window
.
EJS_DEBUG_XX
=
enableDebug
;
window
.
EJS_threads
=
enableThreads
;
if
(
browserMode
)
{
window
.
EJS_browserMode
=
browserMode
;
}
window
.
EJS_askBeforeExit
=
false
;
window
.
EJS_onExit
=
(
)
=>
{
alert
(
"The emulator has exited. This callback can be used to do any cleanup or show a message to the user."
)
;
}
;
script
.
src
=
"data/loader.js"
;
document
.
body
.
appendChild
(
script
)
;
}
input
.
onchange
=
async
(
)
=>
{
run
(
true
)
;
}
box
.
ondragover
=
(
)
=>
box
.
setAttribute
(
"drag"
,
true
)
;
box
.
ondragleave
=
(
)
=>
box
.
removeAttribute
(
"drag"
)
;
</
script
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL