-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
199 lines (162 loc) · 6.44 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
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
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style/main.css">
<link rel="stylesheet" type="text/css" href="Kickstarter/css/kickstart.css">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-85196039-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div id="Container">
<span id="Author">Jason Shin</span>
<div id="CenterContainer">
</div>
<div id="DebugPanel"></div>
<div id="Menu">
<button class="green loadGames">Load Games</button>
<button class="orange pause">Pause</button>
<button class="orange resume">Resume</button>
</div>
<div>
<div class="col_8 column">
<h4>First update 17/07/2013</h4>
<p>This project was started for fun, also I wanted to experience on building a simple emulator so I can move on and
develop SNES emulator</p>
<p>There are few unknown bugs haven't been resolved yet, which are causing few games to be unplayable but many games are
working fine. I suspect this bug is related to V[x] register values but I cannot confirm this yet.</p>
<p>Feedbacks are always welcome and I would appreciate them all as I want to improve this program =D..<br>
Send them all at <a href="mailto:[email protected]">[email protected]</a>
</p>
</div>
</div>
</div>
<script src="Kickstarter/js/kickstart.js"></script>
<script src="Logger.js"></script>
<script src="MySound.js"></script>
<script src="Graphics.js"></script>
<script src="CPU.js"></script>
<script src="Chip8.js"></script>
<script src="Input.js"></script>
<script>
//INIT AND GUI PROGRAMS
(function () {
"use strict";
var container, chip8;
var gameList = [
["Stable", "Tetris"],
["Stable", "Invaders"],
["Stable", "Missile"],
["Stable", "Blitz"],
["Stable", "Breakout"],
["Stable", "Hidden"],
["Stable", "Puzzle"],
["Stable", "Vers"],
["Stable", "Maze"],
["Stable", "Brix"],
["Stable", "Pong"],
["Stable", "Pong2"],
["Stable", "Wall"],
["Unstable", "TicTac"],
["Unstable", "Connect4"],
["Unstable", "VBrix"],
["Unstable", "Tank"],
["Unstable", "Wipeoff"],
["Unstable", "15Puzzle"]
];
var menuHeader = "Welcome to JSON-Chip8 1.0 - Select a game to play";
function addButtonEvents() {
var menu = document.getElementById("Menu");
var buttons = menu.getElementsByTagName("button");
addEvent(buttons, "click", handleMenu);
}
function addGameListEvents() {
var gameContainer = document.getElementById("GameList");
var myGames = gameContainer.getElementsByTagName("tbody")[0].getElementsByClassName("gameItem");
addEvent(myGames, "click", handleGame);
}
function addEvent(nodeList, event, callback) {
for (var i = 0; i < nodeList.length; i++) {
nodeList[i].addEventListener(event, callback, false);
}
}
function handleMenu(event) {
//reset chip8 when menu is visible
var curClass = this.getAttribute("class");
if (curClass.indexOf("loadGames") !== -1) {
resetChip();
loadGameList();
} else if (curClass.indexOf("loadRandom") !== -1) {
console.log("load random");
} else if (curClass.indexOf("pause") !== -1) {
if (chip8 != undefined) {
chip8.stopLoop();
}
}
else if (curClass.indexOf("resume") !== -1) {
if (chip8 != undefined) {
chip8.emulateCycle();
}
}
}
function loadGameList() {
resetContainer();
container.style.overflowY = "scroll";
var html = "<div>"+menuHeader+"</div><br>";
html += " <table id='GameList' cellpadding='0' cellspacing='0'>";
html += "<thead>" +
"<tr class='alt first last'>" +
"<th>stability</th>" +
"<th>Name</th>" +
"</tr>" +
"</thead>"
html + "<tbody id='GameListBody'>";
for (var row = 0; row < gameList.length; row++) {
var stability = gameList[row][0];
var name = gameList[row][1];
var stableIMG;
if (stability.toLowerCase() === "unstable") {
stableIMG = ""
}
html += "<tr class='gameItem'>" +
"<th class='gameStability'><img class='stabilityImage' src='Image/" + (stability.toLowerCase() === "unstable" ? "unstable.png" : "stable.png") + "' alt='stability'>" + gameList[row][0] + "</th>" +
"<th class='gameName'>" + gameList[row][1] + "</th>" +
"</tr>";
}
html += "</tbody>";
html += "</html>";
container.innerHTML = html;
addGameListEvents();
}
function handleGame(event) {
resetContainer();
container.innerHTML = "<canvas id='MainCanvas'></canvas>";
chip8 = new CHIP_8();
var ganmeNameNode = this.getElementsByClassName("gameName")[0];
var gameName = ganmeNameNode.textContent || ganmeNameNode.innerText;
chip8.start(gameName.toUpperCase());
container.style.overflowY = "";
}
function resetContainer() {
container.innerHTML = "";
}
function resetChip() {
if (chip8 != undefined) {
chip8.reset();
}
}
(function() {
container = document.getElementById("CenterContainer");
addButtonEvents();
loadGameList();
})();
})();
</script>
</body>
</html>