Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 240 lines (215 sloc) 6.872 kb
aff68663 »
2012-04-04 Initial commit
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
6 <title>DCPU-16</title>
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
7 <style type="text/css">
5b9d7b0d »
2012-04-05 Styled to look a little like Notch's interface. (Tell me if this make…
8 @font-face { font-family: Commodore; src: url('Commodore.ttf'); }
9 body {
10 background: #bbb;
11 font-family: Commodore;
12 }
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
13 #container {
14 padding: 6px;
b92fb28b »
2012-04-05 Fixed graphical bugs
15 z-index: 1000;
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
16 }
17 #container a {
b92fb28b »
2012-04-05 Fixed graphical bugs
18 color: #444;
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
19 }
20 button {
5b9d7b0d »
2012-04-05 Styled to look a little like Notch's interface. (Tell me if this make…
21 border: 4px solid #000;
22 background: #222;
23 color: #fff;
24 font-size: 24px;
25 font-family: Commodore;
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
26 }
27 button:active {
28 background: #aaf;
29 }
5b9d7b0d »
2012-04-05 Styled to look a little like Notch's interface. (Tell me if this make…
30
31 textarea {
32 background: #222;
33 color: #fff;
34 border: 8px solid #000;
35 font-family: Commodore;
b92fb28b »
2012-04-05 Fixed graphical bugs
36 font-size: 12px;
5b9d7b0d »
2012-04-05 Styled to look a little like Notch's interface. (Tell me if this make…
37 }
38
39 #consoleContainer {
40 -webkit-perspective: 2200;
41 -moz-perspective: 2200;
42 }
43 .perspective {
44 -webkit-transform: rotateY(32deg);
45 -moz-transform: rotateY(32deg);
46 }
b92fb28b »
2012-04-05 Fixed graphical bugs
47 canvas {
48 z-index: -1;
49 }
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
50 </style>
0b0453f1 »
2012-04-04 Added code compilation
51 <script type="text/javascript" src="dcpu16.js"></script>
52 <script type="text/javascript">
53 function compile() {
54 try {
7ac2e350 »
2012-04-04 Added code cleaning
55 dcpu.compile(dcpu.clean(document.getElementById('editor').value));
fb41ca7f »
2012-04-04 Fixed browser compatibility issues
56 document.getElementById('debug').value = dcpu.getDump();
0b0453f1 »
2012-04-04 Added code compilation
57 } catch(e) {
fb41ca7f »
2012-04-04 Fixed browser compatibility issues
58 document.getElementById('debug').value = e;
0b0453f1 »
2012-04-04 Added code compilation
59 }
60 }
397e034c »
2012-04-04 Added analytics
61 function step() {
62 dcpu.step();
fb41ca7f »
2012-04-04 Fixed browser compatibility issues
63 document.getElementById('debug').value = dcpu.getDump();
397e034c »
2012-04-04 Added analytics
64 }
0b0453f1 »
2012-04-04 Added code compilation
65 function run() {
73391ab4 »
2012-04-04 Fixed runtime and compilation bugs, Notch's example program now works
66 dcpu.run(function() {
78a2d095 »
2012-04-05 Added debug toggle, execution speed is greatly increased when debug i…
67 if(document.getElementById('debugToggle').checked)
68 document.getElementById('debug').value = dcpu.getDump();
73391ab4 »
2012-04-04 Fixed runtime and compilation bugs, Notch's example program now works
69 });
78a2d095 »
2012-04-05 Added debug toggle, execution speed is greatly increased when debug i…
70 if(!document.getElementById('debugToggle').checked) document.getElementById('debug').value = 'Executing...';
397e034c »
2012-04-04 Added analytics
71 }
72 function stop() {
73 dcpu.stop();
fb41ca7f »
2012-04-04 Fixed browser compatibility issues
74 document.getElementById('debug').value = dcpu.getDump();
0b0453f1 »
2012-04-04 Added code compilation
75 }
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
76 function reset() {
77 dcpu.clear();
fb41ca7f »
2012-04-04 Fixed browser compatibility issues
78 document.getElementById('debug').value = dcpu.getDump();
868ac27f »
2012-04-04 Console is now cleared on Reset
79 document.getElementById('console').value = '';
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
80 }
05174ea8 »
2012-04-04 Added I/O operations (non-standard)
81 function sendInput() {
82 dcpu.input(document.getElementById('input').value);
83 document.getElementById('input').value = '';
84 }
3cb61383 »
2012-04-04 Added non-standard console print instruction
85
78a2d095 »
2012-04-05 Added debug toggle, execution speed is greatly increased when debug i…
86 dcpu.onOutput(function(screen, string) {
b485e610 »
2012-04-05 BRTEAKING: removed PRT, replaced with Notch's output system (write to…
87 string.replace('\n', '');
88 document.getElementById('console').value = string;
3cb61383 »
2012-04-04 Added non-standard console print instruction
89 });
78a2d095 »
2012-04-05 Added debug toggle, execution speed is greatly increased when debug i…
90 dcpu.onEnd(function() {
91 document.getElementById('debug').value = dcpu.getDump();
92 });
0b0453f1 »
2012-04-04 Added code compilation
93 </script>
397e034c »
2012-04-04 Added analytics
94 <script type="text/javascript">
95
96 var _gaq = _gaq || [];
97 _gaq.push(['_setAccount', 'UA-30599135-1']);
98 _gaq.push(['_trackPageview']);
99
100 (function() {
101 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
102 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
103 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
104 })();
105
106 </script>
aff68663 »
2012-04-04 Initial commit
107 </head>
108 <body>
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
109 <div id="container">
110 <a href="http://github.com/mappum/DCPU-16"><h1>DCPU-16 Emulator</h1></a>
b92fb28b »
2012-04-05 Fixed graphical bugs
111 <h2>V0.7 - By Mappum</h2>
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
112 <textarea id="editor" cols="60" rows="40">
b066e7ac »
2012-04-04 Fixed subroutines and various bugs
113 ; Try some basic stuff
114 SET A, 0x30 ; 7c01 0030
115 SET [0x1000], 0x20 ; 7de1 1000 0020
116 SUB A, [0x1000] ; 7803 1000
117 IFN A, 0x10 ; c00d
118 SET PC, crash ; 7dc1 001a [*]
119
120 ; Do a loopy thing
121 SET I, 10 ; a861
122 SET A, 0x2000 ; 7c01 2000
123 :loop SET [0x2000+I], [A] ; 2161 2000
124 SUB I, 1 ; 8463
125 IFN I, 0 ; 806d
126 SET PC, loop ; 7dc1 000d [*]
127
128 ; Call a subroutine
129 SET X, 0x4 ; 9031
130 JSR testsub ; 7c10 0018 [*]
d4c9e91e »
2012-04-05 Fixed JSR, and fixed demo to go to print subroutine before ending
131 SET PC, print ; 7dc1 001a [*]
b066e7ac »
2012-04-04 Fixed subroutines and various bugs
132
133 :testsub SHL X, 4 ; 9037
134 SET PC, POP ; 61c1
84875d56 »
2012-04-04 Fixed demo program
135
b485e610 »
2012-04-05 BRTEAKING: removed PRT, replaced with Notch's output system (write to…
136 ; "Hello, world!"
137 ; Set 0x8000 - 0x8180 to an ASCII value to output to console
d4c9e91e »
2012-04-05 Fixed JSR, and fixed demo to go to print subroutine before ending
138 :print
070caccb »
2012-04-05 Fixed demo code to use proper pointer notation
139 SET [0x8000], 72
140 SET [0x8001], 101
141 SET [0x8002], 108
142 SET [0x8003], 108
143 SET [0x8004], 111
144 SET [0x8005], 44
145 SET [0x8006], 32
146 SET [0x8007], 119
147 SET [0x8008], 111
148 SET [0x8009], 114
149 SET [0x800a], 108
150 SET [0x800b], 100
151 SET [0x800c], 33
3cb61383 »
2012-04-04 Added non-standard console print instruction
152
153 ; BRK (break) is also non-standard
154 BRK
84875d56 »
2012-04-04 Fixed demo program
155
156 ; Hang forever. X should now be 0x40 if everything went right.
157 :crash SET PC, crash ; 7dc1 001a [*]
b066e7ac »
2012-04-04 Fixed subroutines and various bugs
158 </textarea>
0b0453f1 »
2012-04-04 Added code compilation
159 <textarea id="debug" cols="45" rows="40" readonly="readonly"></textarea>
160 <div style="clear:both;">
161 <button onclick="compile()">Compile</button>
397e034c »
2012-04-04 Added analytics
162 <button onclick="step()">Step</button>
0b0453f1 »
2012-04-04 Added code compilation
163 <button onclick="run()">Run</button>
397e034c »
2012-04-04 Added analytics
164 <button onclick="stop()">Stop</button>
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
165 <button onclick="reset();">Reset</button>
78a2d095 »
2012-04-05 Added debug toggle, execution speed is greatly increased when debug i…
166 <label for="debugToggle">Debug:</label>
167 <input id="debugToggle" type="checkbox" checked="checked" />
aff68663 »
2012-04-04 Initial commit
168 </div>
3cb61383 »
2012-04-04 Added non-standard console print instruction
169 <hr />
5b9d7b0d »
2012-04-05 Styled to look a little like Notch's interface. (Tell me if this make…
170 <div id="consoleContainer">
3cb61383 »
2012-04-04 Added non-standard console print instruction
171 <h2>Console:</h2>
5b9d7b0d »
2012-04-05 Styled to look a little like Notch's interface. (Tell me if this make…
172 <textarea id="console" cols="30" rows="12" readonly="readonly" class="perspective"></textarea>
b485e610 »
2012-04-05 BRTEAKING: removed PRT, replaced with Notch's output system (write to…
173 <br />
174 <input id="input" type="text" style="width:200px; height:32px; vertical-align: bottom" />
175 <button id="submit" style="width:68px" onclick="sendInput()">>></button>
5b9d7b0d »
2012-04-05 Styled to look a little like Notch's interface. (Tell me if this make…
176 </div>
e7ef12e4 »
2012-04-04 (Kind of) improved the interface, added memory reset
177 </div>
5b9d7b0d »
2012-04-05 Styled to look a little like Notch's interface. (Tell me if this make…
178
179 <script type="text/javascript" src="lib/Three.js"></script>
180 <script type="text/javascript">
181 var scene, camera, renderer, cubes = [];
182
183 function init() {
184 scene = new THREE.Scene();
185 camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 10000);
186 camera.position.y = 150;
187 camera.position.z = 500;
188 scene.add(camera);
189
190 for(var i = 0; i < 40; i++) {
191 var color = (Math.random() * 60) + 100;
192 color |= color << 8;
193 color |= (color & 0xff) << 16;
194 materials = new THREE.MeshBasicMaterial({color: color});
195
196 var geom = new THREE.CubeGeometry(Math.random() * 200 + 100,
197 Math.random() * 200 + 100, Math.random() * 200 + 100);
198
199 var cube = new THREE.Mesh(geom, materials);
200 cube.doubleSided = true;
201
202 cube.position.x = Math.random() * window.innerWidth - window.innerWidth / 2;
203 cube.position.y = Math.random() * window.innerWidth - window.innerWidth / 2;
204 cube.position.z = Math.random() * -600 - 200;
205
5705cdc7 »
2012-04-05 Turned off cube animation
206 cube.rotation.x = Math.random() * 360;
207 cube.rotation.y = Math.random() * 360;
208 cube.rotation.z = Math.random() * 360;
5b9d7b0d »
2012-04-05 Styled to look a little like Notch's interface. (Tell me if this make…
209
210 scene.add(cube);
211 cubes.push(cube);
212 }
213
214 var light = new THREE.PointLight(0xffffff);
215 light.position.x = 500;
216 light.position.y = 550;
217 light.position.z = 500;
218 scene.add(light);
219
220 renderer = new THREE.CanvasRenderer();
221 renderer.setSize(window.innerWidth, window.innerHeight);
222
223 var el = renderer.domElement;
224 el.style.position = 'absolute';
225 el.style.left = 0;
226 el.style.top = 0;
227 el.style['z-index'] = -1;
228 document.body.appendChild(el);
229 }
230
52f38c19 »
2012-04-05 Turned off 3d background on mobile
231 if(navigator.platform.substr(0, 3) === 'Win'
232 || navigator.platform === 'Mac'
233 || navigator.platform === 'Linux') {
234 init();
5705cdc7 »
2012-04-05 Turned off cube animation
235 renderer.render(scene, camera);
52f38c19 »
2012-04-05 Turned off 3d background on mobile
236 }
5b9d7b0d »
2012-04-05 Styled to look a little like Notch's interface. (Tell me if this make…
237 </script>
aff68663 »
2012-04-04 Initial commit
238 </body>
239 </html>
Something went wrong with that request. Please try again.