-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
136 lines (118 loc) · 2.8 KB
/
index.html
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style type="text/css">
* {
margin: 0;
padding: 0;
}
body {
text-align: center;
background: #333;
font-family: Arial;
}
#screen {
margin: 50px auto 0;
position: relative;
width: 640px;
}
#screen canvas {
background: #FFF;
}
#rom-loader:hover {
display: block !important;
}
#screen canvas:hover + #rom-loader {
display: block !important;
}
#rom-loader {
position: absolute;
top: 10px;
right: 10px;
}
#controls {
max-width: 640px;
background: #FFF;
margin: 50px auto 0;
padding: 15px 0;
}
#controls span {
padding: 0 15px;
white-space: nowrap;
}
#fps {
display: none;
position: fixed;
top: 0;
right: 0;
width: 80px;
height: 30px;
line-height: 30px;
background: #FFF;
border-radius: 0 0 0 10px;
}
#fps::before {
content: "FPS: ";
}
#rom-file {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
overflow: hidden;
padding: 0;
position: absolute !important;
white-space: nowrap;
width: 1px;
}
#rom-file + label {
background-color: #444;
padding: 10px;
color: #fff;
cursor: pointer;
display: inline-block;
padding-left: 2rem 4rem;
}
#rom-file:focus + label,
#rom-file + label:hover {
background-color: #222;
}
#rom-file:focus + label {
outline: 1px dotted #000;
}
</style>
</head>
<body>
<div id="screen">
<canvas width="640" height="576"></canvas>
<div id="rom-loader">
<input type="file" id="rom-file" />
<label for="rom-file" />Choose a ROM file</label>
</div>
</div>
<div id="controls">
<span><strong>D-pad:</strong> arrows</span>
<span><strong>B/A buttons:</strong> A/S</span>
<span><strong>Select:</strong> spacebar</span>
<span><strong>Start:</strong> enter</span>
</div>
<script type="module">
import Emulator from './emulator/Emulator.js';
const canvas = document.querySelector('canvas');
const emulator = new Emulator(canvas);
const fpsCounter = document.getElementById('fps');
const romLoader = document.getElementById('rom-loader');
romLoader.querySelector('input').addEventListener('input', (e) => {
romLoader.style.display = 'none';
fpsCounter.style.display = 'block';
emulator.load(e.target.files[0]);
emulator.boot();
});
</script>
<div id="fps"></div>
</body>
</html>