Skip to content

Commit d23f1e0

Browse files
committed
Support decimal numbers in editor
1 parent f62edef commit d23f1e0

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

_css/editor.css

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
font-weight: bold;
3939
}
4040

41+
.e-decimal{
42+
color: #00BBDD;
43+
font-weight: bold;
44+
}
45+
4146
.e-valid-char{
4247
color: #AA00FF;
4348
font-weight: bold;

_css/periphery.css

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
Styles for periphery device related stuff.
33
*/
44

5-
#octalDisplay{
5+
#octalDisplay, #joystick{
66
width: 121px;
77
margin-top: 5px;
88
margin-left: 5px;
99
}
1010

11+
#octJoystick{
12+
display: inline-block;
13+
}
14+
1115
#octalDisplay .displayContainer{
1216
background-color: #000000;
1317
margin: 5px auto;
@@ -23,6 +27,10 @@
2327
background-image: url(../_media/sevensegment.png);
2428
}
2529

30+
#joystick .joystickContainer{
31+
margin: 5px 5px;
32+
}
33+
2634
#dotMatrix{
2735
width: 246px;
2836
margin-top: 5px;

_js/Assembler.js

+6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ var Assembler = new function(){
5959
if(lines[i][l].substring(0, 1) == "#"){
6060
lines[i][l] = binToOct(lines[i][l].substring(1, lines[i][l].length));
6161
}
62+
63+
// Values ending with . are decimal.
64+
// Translate them to octal
65+
if(lines[i][l].substring(lines[i][l].length-1, lines[i][l].length) == "."){
66+
lines[i][l] = decToOct(lines[i][l].substring(0, lines[i][l].length-1));
67+
}
6268

6369
// Remove emtpy entries
6470
if(lines[i][l] == ""){

_js/Editor.js

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ function Editor(
7979
}
8080
} else if(fragment.substring(0, 1) == "#"){ // Binary value
8181
code[c] = '<span class="e-binary" title="Octal: '+binToOct(fragment)+'">'+fragment+"</span>";
82+
} else if(fragment.substring(fragment.length-1, fragment.length) == "."){ // Decimal value
83+
code[c] = '<span class="e-decimal" title="Octal: '+binToOct(fragment)+'">'+fragment+"</span>";
8284
} else if(/^([0-7]*)$/.test(fragment) === true && fragment.length > 0){ // Octal value
8385
code[c] = '<span class="e-octal" title="Binary: '+octToBin(fragment)+'">'+fragment+"</span>";
8486
}

index.html

+18-2
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,29 @@ <h2>Memory</h2>
320320
<table id="ramtable" class="memtable">
321321
<tbody id="ramtbody"></tbody>
322322
</table>
323-
</div><br /><div id="octalDisplay" class="panel">
323+
</div><br /><div id="octJoystick"><div id="octalDisplay" class="panel">
324324
<h2 title="Device Address: 020">Oct Display</h2>
325325
<div class="displayContainer">
326326
<div class="displaySegment" id="displaySegment0"></div><div class="displaySegment" id="displaySegment1"></div><div class="displaySegment" id="displaySegment2"></div>
327327
</div>
328328
<span class="peripheryDocs" onclick="Control.showPopup('octalDisplayInfoPopup');">Docs</span>
329-
</div><div id="dotMatrix" class="panel">
329+
</div><br /><div id="joystick" class="panel">
330+
<h2 title="Device Address: 050">Joystick</h2>
331+
<div class="joystickContainer">
332+
<table>
333+
<tr>
334+
<td></td><td><button>^</button></td><td></td>
335+
</tr>
336+
<tr>
337+
<td><button>&lt;</button></td><td><button>o</button></td><td><button>&gt;</button></td>
338+
</tr>
339+
<tr>
340+
<td></td><td><button>v</button></td><td></td>
341+
</tr>
342+
</table>
343+
</div>
344+
<span class="peripheryDocs" onclick="Control.showPopup('dotMatrixInfoPopup');">Docs</span>
345+
</div></div><div id="dotMatrix" class="panel">
330346
<h2 title="Device Addresses: 030 - 034">Dot Matrix</h2>
331347
<div class="dotMatrixContainer">
332348
<canvas id="dotMatrixCanvas" height="160" width="160"></canvas>

0 commit comments

Comments
 (0)