initial spaghetti code

This commit is contained in:
kaylee 2023-12-15 19:43:36 +00:00
commit b0b062a2b0
110 changed files with 8500 additions and 0 deletions

1
WORKING_SETUP.json Executable file

File diff suppressed because one or more lines are too long

BIN
build/.DS_Store vendored Executable file

Binary file not shown.

BIN
build/._.DS_Store Executable file

Binary file not shown.

66
build/alu/full/index.html Executable file
View File

@ -0,0 +1,66 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="../" />
<title>Build an ALU</title>
<script type="text/javascript" src="../js/page.js"></script>
<link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>
<body>
<h1>Time to put it all together</h1>
<p>Now we've built the constituent parts, it's now time to put everything together into our ALU chip.</p>
<p>The ALU has two outputs: the 8-bit result of the operation that was performed, and a 4-bit <a href="https://en.wikipedia.org/wiki/FLAGS_register">"flags"</a> value which contains information about the calculation.</p>
<img src="../img/flags_diagram.png" alt="flags" />
<p>You should set the flags according to the following logic:</p>
<div style="width:100%;display: flex; justify-content: center;margin-top:-20px;">
<table>
<thead><tr><td>Flag</td><td>Logic</td></thead>
<tbody>
<tr><td><a href="https://en.wikipedia.org/wiki/Overflow_flag#:~:text=The%20overflow%20flag%20is,operands%20are%20the%20same).">Overflow</a></td><td>1 if the <b>addition</b> of two numbers with the same <a href="https://en.wikipedia.org/wiki/Sign_bit">sign bit</a> produces a result with a different sign, or if the <b>subtraction</b> of two numbers with different signs produces a result with the same sign as the number being subtracted.<br>0 otherwise.</td></tr>
<tr><td><a href="https://en.wikipedia.org/wiki/Carry_flag">Carry / Borrow</a></td><td>1 if an <b>addition</b> or <b>subtraction</b> operation results in a carry / borrow.<br>0 otherwise.</td></tr>
<tr><td><a href="https://en.wikipedia.org/wiki/Negative_flag">Negative flag</a></td><td>1 if the <b>sign bit</b> (most significant bit) of the result is 1.<br>0 otherwise.</td></tr>
<tr><td><a href="https://en.wikipedia.org/wiki/Zero_flag">Zero flag</a></td><td>1 if <b>every</b> bit of the result is 0. <br>0 otherwise.</td></tr>
</tbody>
</table>
</div>
<p>The ALU has three inputs: the first and second 8-bit operands, and a 4-bit "opcode" which selects the operation to be performed.<br> This processor's ALU will use the following opcodes:</p>
<div style="width:100%;display: flex; justify-content: center;margin-top:-20px;">
<!--<ol data-bin=1>
<li>add</li>
<li>subtract</li>
<li>add with carry</li>
<li>left shift</li>
<li>logical NAND</li>
<li data-before="1XX">logical XOR</li>
</ol>
-->
<table class="c1c">
<thead><tr><td>Opcode</td><td>Operation</td><td>Explaiation</td></tr></thead>
<tbody>
<tr><td>0000</td><td>add </td><td>Adds the second operand to the first, setting the carry in to 0.</td></tr>
<tr><td>0001</td><td>subtract (sub)</td><td>Subtracts the second operand from the first, setting the carry in to 0.</td></tr>
<tr><td>0010</td><td>add with carry<br>(adc)</td><td>Adds the second operand to the first, setting the carry in to the value of the carry flag.</td></tr>
<tr><td>0011</td><td>subtract with borrow<br>(subb)</td><td>Subtracts the second operand from the first, setting the carry in to the value of the carry flag.</td></tr>
<tr><td>0100</td><td>nand</td><td>Each bit of the output is the result of NANDing together the respective bits of each operand.</td></tr>
<tr><td>0101</td><td>xor</td><td>Each bit of the output is the result of XORing together the respective bits of each operand.</td></tr>
<tr><td>0110</td><td>shift left<br>(sll)</td><td>Each bit of operand 1 is shifted to the left by the number of places specified by operand 2.</td></tr>
<tr><td>0111</td><td>shift right<br>(srl)</td><td>Each bit of operand 1 is shifted to the right by the number of places specified by operand 2.</td></tr>
<tr><td>1XXX</td><td>move<br>(mov)</td><td>Operand 2 is passed straight through to the result. No operation is performed.</td></tr>
</tbody>
</table>
</div>
<p><i>This is the most complicated part of the process</i>, and it's OK if you don't quite understand everything yet. You can use the green links to get more information about certain words, and now might be a good time to ask your tutor for help if you are truly stuck.</p>
<h3><a href="/cpu/build/editor/?item=alu" data-newtab=1>Start building</a></h3>
<!--<ol>
<li><a href="1/" data-newtab=1>construct <b>2:1 mux</b></a></li>
<li><a href="2/" data-newtab=1>assemble <b>16:8 mux</b></a></li>
</ol>
-->
<p>
Once you are finished, you can <a href="/cpu/">return to the CPU</a>.
</p>
</body>
</html>

42
build/alu/index.html Executable file
View File

@ -0,0 +1,42 @@
<!doctype html>
<html>
<head>
<title>Build an ALU</title>
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<script type="text/javascript" src="../js/page.js"></script>
</head>
<body>
<h1>Build an ALU!</h1>
<p>The ALU is the chip that's responsible for performing all the calculations this processor can do. It's far too complex to build all in one go, however, so we have to break it down into component parts.</p>
<p>
Below is a list of all the parts that we need to make. They have to be done in order, because each one builds on the one before! Make sure you have a <a data-newtab=1 href="../multiplexer">multiplexer</a> built first, because we will need this!
</p>
<h3>Addition</h3>
<ol>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu1">half adder</a></li>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu2">full adder</a></li>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu3">8-bit ripple carry adder</a></li>
</ol>
<h3>Subtraction</h3>
<ol start=4>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu4">8-bit inverter</a></li>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu5">subtract unit</a></li>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu6">add / subtract unit</a></li>
</ol>
<h3>Logic</h3>
<ol start=7>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu7">nand/xor gate</a></li>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu8">8-bit nand/xor unit</a></li>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu9">left/right shift bit</a></li>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu10">shift n bits unit</a></li>
<li><a data-newtab=1 href="/cpu/build/editor/?item=alu11">logic unit</a></li>
</ol>
<h3>Final boss</h3>
<ol start=12>
<li><a href="full/">full ALU</a></li>
</ol>
<p>
Once you are finished, you can <a href="/cpu/">return to the CPU</a>.
</p>
</body>
</html>

BIN
build/css/._ibm.woff Executable file

Binary file not shown.

BIN
build/css/ibm.woff Executable file

Binary file not shown.

104
build/css/style.css Executable file
View File

@ -0,0 +1,104 @@
html {
background-color: #3A0000;
display: flex;
justify-content: center;
}
body {
margin-top: 15px;
line-height: 1;
padding: 30px;
font-family: sans-serif;
background-color: white;
box-shadow: rgb(142 47 47) 15px 15px;
margin-bottom:20px;
}
* {
margin-top: 5px;
margin-bottom: 5px;
font-family: "IBM VGA";
}
a {
border-bottom: 1px;
--fgcolor: blue;
color: var(--fgcolor);
}
img {
display: block;
margin: 0 auto;
max-width: 600px;
}
a:hover {
background-color: var(--fgcolor);
color: white;
}
a[href*="//"] {
border-bottom: 1px double;
--fgcolor: green;
target-name: new;
target-new: tab;
}
h1,ul,ol {
margin-top: 13px;
margin-bottom: 13px;
}
ol[data-bin="1"]{
list-style: none;
padding-left:0;
margin-left: 0;
padding-right:0;
margin-right: 0;
}
ol[data-bin="1"] li {
padding-left: 1rem;
text-indent: -0.7rem;
}
li:before {
font-weight: bolder;
color: red;
content: attr(data-before);
padding-right:10px;
}
p {
margin-bottom: 15px;
}
table{
margin: 25px;
width: 50%;
min-width: 500px;
border-collapse: collapse;
}
thead tr {
background-color: black;
color: white;
border-bottom: 1px solid;
}
td {
padding: 5px;
}
tbody tr:not(:last-child){
border-bottom: 1px solid;
}
tbody td:not(:first-child) {
border-left: 1px solid;
}
table.c1c td:first-child {
text-align: center;
}
table.c1c tbody td:first-child {
color: red;
}
@media screen and (max-width:600px) {
body { width: 100%; }
img { width: 100%; }
}
@media screen and (min-width:600px) {
body { width: 40%; min-width:600px; max-width:960px; }
}
@font-face {
font-family: 'IBM VGA';
src: url('../css/ibm.woff');
font-weight: normal;
font-style: normal;
}

BIN
build/editor/.DS_Store vendored Executable file

Binary file not shown.

BIN
build/editor/._.DS_Store Executable file

Binary file not shown.

15
build/editor/css/style.css Executable file
View File

@ -0,0 +1,15 @@
html, body {
width:100%;
height: 100%;
margin: 0;
overflow: hidden;
}
body {
display: flex;
align-items: center;
justify-content: center;
background-color:black;
}
canvas {
background-color:#36393E;
}

BIN
build/editor/img/.DS_Store vendored Executable file

Binary file not shown.

BIN
build/editor/img/._.DS_Store Executable file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

BIN
build/editor/img/gates/._and.png Executable file

Binary file not shown.

BIN
build/editor/img/gates/._nand.png Executable file

Binary file not shown.

BIN
build/editor/img/gates/._nor.png Executable file

Binary file not shown.

BIN
build/editor/img/gates/._not.png Executable file

Binary file not shown.

BIN
build/editor/img/gates/._or.png Executable file

Binary file not shown.

BIN
build/editor/img/gates/._xnor.png Executable file

Binary file not shown.

BIN
build/editor/img/gates/._xor.png Executable file

Binary file not shown.

BIN
build/editor/img/gates/and.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
build/editor/img/gates/nand.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
build/editor/img/gates/nor.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
build/editor/img/gates/not.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
build/editor/img/gates/or.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
build/editor/img/gates/xnor.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
build/editor/img/gates/xor.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

22
build/editor/index.php Executable file
View File

@ -0,0 +1,22 @@
<html>
<head>
<title>Component editior</title>
<?php
if($_GET['item']){
echo("\n<script src='js/items/".$_GET['item'].".js'></script>\n");
}
if(!isset($_GET['edit'])) { echo("<script>var editDisabled = 1;</script>\n"); }
?>
<script type="text/javascript" src="js/chips.js"></script>
<script type="text/javascript" src="js/md5.js"></script>
<script type="text/javascript" src="js/components.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="/cpu/css/stylesheet.css" />
</head>
<body>
<canvas id="logicsim">
</canvas>
</body>
</html>

187
build/editor/js/bk/chips.js Executable file
View File

@ -0,0 +1,187 @@
chips = {
"nand": {
image: "img/gates/nand.png",
inputs: 2,
pins : [0,0,0],
subComponents : [],
wires : []
},
"not": {
image: "img/gates/not.png",
inputs: 1,
pins: [0,0],
subComponents: ["nand"],
wires: [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 0, pin: 1 }
}
]
},
"and": {
image: "img/gates/and.png",
inputs: 2,
pins : [0,0,0],
subComponents : ["nand", "nand"],
wires : [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 },
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 0 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 1 }
},
{
source: { component: 2, pin: 2 },
destination: { component: 0, pin: 2 }
}
]
},
"or": {
image: "img/gates/or.png",
inputs: 2,
pins: [0,0,0],
subComponents : ["nand","nand","nand"],
wires : [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 },
},
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 2, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 2, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 3, pin: 0 }
},
{
source: { component: 2, pin: 2 },
destination: { component: 3, pin: 1 }
},
{
source: { component: 3, pin: 2 },
destination: { component: 0, pin: 2 }
}
]
},
"xor": {
image: "img/gates/xor.png",
inputs:2,
pins: [0,0,0],
subComponents: ["nand","nand","nand", "nand"],
wires : [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 0, pin: 0 },
destination: { component: 2, pin: 0 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 3, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 3, pin: 1 }
},
{
source: { component: 2, pin: 2 },
destination: { component: 4, pin: 0 }
},
{
source: { component: 3, pin: 2 },
destination: { component: 4, pin: 1 }
},
{
source: { component: 4, pin: 2 },
destination: { component: 0, pin: 2 }
}
]
},
"nor": {
inputs:2,
image: "img/gates/nor.png",
pins: [0,0,0],
subComponents: ["or","not"],
wires: [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 0 },
},
{
source: { component: 2, pin: 1 },
destination: { component: 0, pin: 2 }
}
]
},
"xnor": {
image: "img/gates/nor.png",
pins: [0,0,0],
subComponents: ["xor","not"],
wires: [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 0 },
},
{
source: { component: 2, pin: 1 },
destination: { component: 0, pin: 2 }
}
]
}
}

205
build/editor/js/bk/components.js Executable file
View File

@ -0,0 +1,205 @@
class Component {
type;
image;
inputs=0;
pins = [];
subComponents = [this];
zIndex = [];
wires = [];
position = { x: 0, y: 0 };
constructor(name){
this.type = name;
if (!(name in chips)) {
return;
}
var chip = JSON.parse(JSON.stringify(chips[name]));
this.image = chip.image;
this.pins = chip.pins;
this.wires = chip.wires;
this.inputs = chip.inputs;
chip.subComponents.forEach((sc,i)=>{
this.subComponents.push(new Component(sc));
this.zIndex.push(this.subComponents[i]);
});
this.process();
}
process(){
if (this.type=="nand"){
this.pins[2] = (this.pins[0] && this.pins[1])?0:1;
} else {
this.subComponents.forEach(s=>{if(s != this) {s.process()}});
this.wires.forEach(w=>{
this.subComponents[w.destination.component].pins[w.destination.pin] = this.subComponents[w.source.component].pins[w.source.pin]
});
}
return this.pins;
}
addComponent(name){
var nc = new Component(name);
this.subComponents.push(nc);
this.zIndex.unshift(nc);
}
removeComponent(index){
this.zIndex = this.zIndex.filter(zEntry=> this.getProperIndex(zEntry) !== index);
this.wires.forEach(w=>{
if(w.source.component == index)
this.subComponents[w.destination.component].pins[w.destination.pin] = 0;
});
this.wires = this.wires.filter(w=>w.source.component != index && w.destination.component != index).map(w => { if(w.destination.component>index){w.destination.component-=1};if(w.source.component>index){w.source.component-=1}; return w });
this.subComponents.splice(index,1);
console.log("hi");
console.log(this.subComponents);
}
sendToFront(index){
this.zIndex=this.zIndex.filter(zEntry=>this.getProperIndex(zEntry)!==index);
this.zIndex.push(this.subComponents[index]);
}
getProperIndex(zEntry){
return this.subComponents.indexOf(zEntry);
}
connect(source,destination,wid){
var sourceIsInput,destinationIsOutput;
sourceIsInput=destinationIsOutput=0;
if (source.pin < this.subComponents[source.component].inputs)
sourceIsInput = true;
if (destination.pin >= this.subComponents[destination.component].inputs)
destinationIsOutput = true;
source = {component:source.component, pin:source.pin};
destination={component:destination.component,pin:destination.pin};
if(source.component == 0){ // if the source is the chip itself
if(destination.component == 0){ // should be direct connection between input and output pins
if(!(sourceIsInput&&destinationIsOutput)){ // if not,
if((!sourceIsInput&&!destinationIsOutput)){ // is it backwards?
var tmp=source;
source=destination;
destination=tmp;
} else { // no, so it's wrong
console.log("1");
return false;
}
} else {
// connection between chip and component - both should be inputs or both should be outputs
if(!((sourceIsInput&&!destinationIsOutput)||(!sourceIsInput && destinationIsOutput))){
// if not, we know something must be wrong. there is no reason ever for an output pin on a component to go to an input pin or vice versa.
console.log("2");
return false;
} else if(!sourceIsInput&&!destinationIsOutput) {
}
}
}
} else {
if(destination.component == 0){
//connection between component and chip! both inputs or both outputs
if(!((sourceIsInput&&!destinationIsOutput)||(!sourceIsInput && destinationIsOutput))){
console.log("3");
return false;
}
} else { // connection between two components. source must be an output and destination must be input. cannot be same type.
//if same type
if(!((sourceIsInput&&destinationIsOutput)||(!sourceIsInput&&!destinationIsOutput))){
console.log("4");
return false;
}
if(sourceIsInput&&destinationIsOutput){ // if that happened its mixed up
var tmp = source;
tmp=destination;
destination=tmp;
}
}
}
/*
var sourceShouldBeInput,destinationShouldBeOutput,sourceIsInput, destinationIsOutput;
sourceShouldBeInput = destinationShouldBeOutput = sourceIsInput = destinationIsOutput = false;
if (source.pin < this.subComponents[source.component].inputs)
sourceIsInput = true;
if (destination.pin >= this.subComponents[destination.component].inputs)
destinationIsOutput = true;
if(source.component==0)
sourceShouldBeInput=true;
if(destination.component==0)
destinationShouldBeOutput=true;
if(sourceIsInput&&!sourceShouldBeInput){
if(destinationIsOutput&&!destinationShouldBeOutput){
var tmp = source;
source = destination;
destination = tmp;
} else {
if(
console.log("no bc source is input xor destination is output");
console.log({sourceIsInput,sourceShouldBeInput,destinationIsOutput,destinationShouldBeOutput});
return false;
}
} else if(destinationIsOutput&&!destinationShouldBeOutput) {
console.log("no bc destination is output");
console.log({sourceIsInput,sourceShouldBeInput,destinationIsOutput,destinationShouldBeOutput});
return false;
}
if(!sourceIsInput&&sourceShouldBeInput){
if(!destinationIsOutput&&destinationShouldBeOutput){
var tmp=source;
source=destination;
destination=tmp;
} else {
console.log({sourceIsInput,sourceShouldBeInput,destinationIsOutput,destinationShouldBeOutput});
console.log("no bc source is output xor destination is input");
return false;
}
} else if(!destinationIsOutput&&destinationShouldBeOutput) {
console.log("no bc destination is input");
console.log({sourceIsInput,sourceShouldBeInput,destinationIsOutput,destinationShouldBeOutput});
return false;
}
console.log({sourceIsInput,sourceShouldBeInput,destinationIsOutput,destinationShouldBeOutput});
/*
if (sourceIsInput && destinationIsOutput) {
if (source.component==0||destination.component==0)
return false;
var tmp = source;
source=destination;
destination = tmp;
} else if (sourceIsInput || destinationIsOutput) {
if (!((sourceIsInput && source.component==0)||(destinationIsOutput && destination.component==0)))
return false;
} else {
if(source.component==0||destination.component==0){
var tmp=source;
source=destination;
destination=tmp;
}
}
*/
this.wires = this.wires.filter(w=>JSON.stringify(w.destination)!=JSON.stringify(destination));
this.wires.push({ source: source, destination: destination, wireId:wid });
return true;
}
disconnect(source,destination){
this.wires = this.wires.filter(w=>JSON.stringify(w)!=JSON.stringify({source:source,destination:destination}));
}
addPin(isInput){
if(isInput){
this.inputs++;
this.pins.unshift(0);
this.wires.forEach(w=>{ if(w.source.component==0){w.source.pin+=1} });
} else {
this.pins.push(0);
}
}
removePin(i){;
this.wires = this.wires.filter(w=>!((w.source.component==0 && w.source.pin == pin)||(w.destination.component==0 && w.destination.pin == pin)));
if(i<this.inputs){
this.pins.shift();
this.wires.forEach(w=>{ if(w.source.component==0){w.source.pin-=1}});
} else {
this.pins.pop();
}
}
}

229
build/editor/js/bk/index.js Executable file
View File

@ -0,0 +1,229 @@
var canvas, ctx
var selectedItem
var mouseisdown
var chip = new Component("main");
var pinImages = [];
var wireVisuals = [];
var wireBeingDrawn = [];
images = {};
var x;
document.addEventListener("DOMContentLoaded", function(event){
canvas = document.getElementById('logicsim');
canvas.addEventListener("mousedown",selectItem);
canvas.addEventListener("mouseup", function(){mouseisdown=false});
canvas.addEventListener("mousemove",mousemove);
document.addEventListener("keydown",checkKey);
ctx = canvas.getContext('2d');
preloadAssets();
requestAnimationFrame(drawCanvas);
x=setInterval(function(){chip.process()},1);
});
function getMousePos(c,e){
var rect = c.getBoundingClientRect();
return {
x: e.clientX - rect.left,
y: e.clientY - rect.top
}
}
function checkKey(e){
e=e||window.event;
if(e.keyCode==27){
selectedPin={component:-1,pin:-1};
wireBeingDrawn=[];
}
}
function isInside(c,point){
return ( point.x > c.position.x && point.x < c.position.x + images[c.type].width) &&
( point.y > c.position.y && point.y < c.position.y + images[c.type].height);
}
function isInsidePin(p,point){
return Math.sqrt(Math.pow((p.position.x-point.x),2)+Math.pow((p.position.y-point.y),2)) < p.radius;
}
var clickpos;
var nWireAttempts=0;
var selectedPin = {component:-1,pin:-1};
var hoveredPin = {component:-1,pin:-1,type:-1};
function selectItem(e){
pos = getMousePos(canvas, e)
if(hoveredPin.component>=0){
if(hoveredPin.type==1){
chip.pins[hoveredPin.pin]=1-chip.pins[hoveredPin.pin];
} else {
if(wireBeingDrawn.length>0){
if(chip.connect(selectedPin, hoveredPin, nWireAttempts)){
wireBeingDrawn[wireBeingDrawn.length-1]={component:hoveredPin.component,pin:hoveredPin.pin};
wireVisuals.push({wireId:nWireAttempts,path:wireBeingDrawn.slice()});
wireBeingDrawn=[];
selectedPin={component:-1,pin:-1};
nWireAttempts+=1;
} else {
console.log("noooo");
}
} else {
wireBeingDrawn.push({component:hoveredPin.component,pin:hoveredPin.pin});
wireBeingDrawn.push({x:pos.x,y:pos.y});
selectedPin = {component:hoveredPin.component,pin:hoveredPin.pin};
}
}
} else {
if(wireBeingDrawn.length>0){
wireBeingDrawn[wireBeingDrawn.length-1]={x:pos.x,y:pos.y};
wireBeingDrawn.push({x:pos.x,y:pos.y})//slice());
}
}
chip.zIndex.forEach(function(c,i){
if (isInside(c, pos) && ctx.getImageData(pos.x,pos.y,1,1).data[3]) {
mouseisdown = true;
clickpos = pos;
chip.sendToFront(chip.getProperIndex(c));
// DELETE THIS LATER //
return;
}
});
}
var pos;
function mousemove(e){
pos = getMousePos(canvas,e);
if(wireBeingDrawn.length>0){
wireBeingDrawn[wireBeingDrawn.length-1]={x:pos.x,y:pos.y};
}
if(mouseisdown){
last = chip.zIndex.length-1;
chip.zIndex[last].position.x -= (clickpos.x - pos.x);
chip.zIndex[last].position.y -= (clickpos.y - pos.y);
clickpos = pos;
}
if(!pinImages.some(pi=>{
if(isInsidePin(pi,pos)){
hoveredPin = {component:pi.component,pin:pi.pin,type:pi.type}
return true;
}
})){
hoveredPin={component:-1,pin:-1};
}
}
function preloadAssets(){
Object.entries(chips).forEach(function(c){
if (!(c[1].image in images)){
images[c[0]] = new Image();
images[c[0]].src = c[1].image;
}
});
}
function makeArr(startValue, stopValue, cardinality) {
var arr = [];
var step = (stopValue - startValue) / (cardinality - 1);
for (var i = 0; i < cardinality; i++) {
arr.push(startValue + (step * i));
}
return arr;
}
function drawCircle(x,y,radius,colour){
ctx.beginPath();
ctx.arc(Math.floor(x),Math.floor(y),radius,0,2*Math.PI,false);
ctx.fillStyle=colour;
ctx.fill();
}
function drawLine(origin,destination,width,colour){
ctx.beginPath();
ctx.moveTo(origin.x,origin.y);
ctx.lineTo(destination.x,destination.y);
ctx.strokeStyle=colour;
ctx.lineWidth=width;
ctx.stroke();
}
function drawCanvas() {
pI = [];
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.canvas.width = 600;
ctx.canvas.height = 600;
ctx.fillStyle="lightgray";
ctx.fillRect(0,0,20,canvas.height);
//components.slice().reverse().forEach(function(c){
for(var i=0;i<wireBeingDrawn.length-1;i++){
if(i==0)
p1=pinImages.find(p=>p.component==wireBeingDrawn[0].component && p.pin==wireBeingDrawn[0].pin && p.type==0).position;
else
p1=wireBeingDrawn[i];
//if(i==wireBeingDrawn.length-2)
// p2=pinImages.find(p=>p.component==wireBeingDrawn[i+1].component&&p.pin==wireBeingDrawn[i+1].pin&&p.type==0).position;
//else
p2=wireBeingDrawn[i+1]
drawLine(p1,p2,3,["black","red"][chip.subComponents[wireBeingDrawn[0].component].pins[wireBeingDrawn[0].pin]]);
}
wireVisuals=wireVisuals.filter(wv=> {return chip.wires.findIndex(w=>w.wireId==wv.wireId)>=0});
wireVisuals.forEach(wv=>{
for(var i=0;i<wv.path.length-1;i++){
if(i==0)
p1=pinImages.find(p=>p.component==wv.path[0].component && p.pin==wv.path[0].pin && p.type==0).position;
else
p1=wv.path[i];
if(i==wv.path.length-2)
p2=pinImages.find(p=>p.component==wv.path[i+1].component&&p.pin==wv.path[i+1].pin&&p.type==0).position;
else
p2=wv.path[i+1];
drawLine(p1,p2,3,["black","red"][chip.subComponents[wv.path[0].component].pins[wv.path[0].pin]]);
}
});
chip.pins.forEach((p,i)=>{
if(i<chip.inputs){
centerX=10;
otherpins = chip.inputs;
pindex=i;
} else {
centerX = canvas.width - 10;
otherpins = chip.pins.length - chip.inputs;
pindex = i - chip.inputs;
}
ys = makeArr(0-(20/otherpins),0+canvas.height+(20/otherpins),otherpins+2);
ys.shift();
ys.pop();
centerY = ys[pindex];
pI.push({component:0,pin:i,position:{x:centerX,y:centerY},radius:10,type:1});
secondaryX=(i<chip.inputs?centerX+20:centerX-20);
pI.push({component:0,pin:i,position:{x:secondaryX,y:centerY},radius:5,type:0});
//ctx.beginPath();
//ctx.arc(Math.floor(centerX), Math.floor(centerY), 10, 0, 2*Math.PI, false);
(hoveredPin.component==0&&hoveredPin.pin==i&&hoveredPin.type==0) ? offset=2 : offset=0;
fillStyle1=["black","red","grey","pink"][chip.pins[i]+offset];
fillStyle2=(i<chip.inputs?["black","red","grey","pink"]:["black","red","black","red"])[chip.pins[i]+((hoveredPin.component==0&&hoveredPin.pin==i&&hoveredPin.type==1)?2:0)];
//ctx.fill();
drawLine({x:centerX,y:centerY},{x:secondaryX,y:centerY},1,["black","red"][chip.pins[i]]);
drawCircle(centerX,centerY,10,fillStyle2);
drawCircle(secondaryX,centerY,5,fillStyle1);
})
chip.zIndex.forEach(c=>{
img = images[c.type];
ctx.drawImage(img,c.position.x,c.position.y);
c.pins.forEach((p,i)=>{
//trueCenterY = (c.position.y+(c.position.y + c.height))/2
centerX = c.position.x+img.width+5;
otherpins = c.pins.length - c.inputs;
pindex = i - c.inputs;
if(i<c.inputs){
centerX = c.position.x-5;
if(["xor","nor","or"].includes(c.type)){
centerX += 9;
}
otherpins = c.inputs;
pindex=i;
}
ys = makeArr(c.position.y-(20/otherpins),c.position.y+img.height+(20/otherpins),otherpins+2);
ys.shift();
ys.pop();
centerY = ys[pindex];
pI.push({component:chip.subComponents.indexOf(c),pin:i,position:{x:centerX,y:centerY},radius:10,type:0});
ctx.beginPath();
ctx.arc(Math.floor(centerX), Math.floor(centerY), 5, 0, 2*Math.PI, false);
(hoveredPin.component==chip.subComponents.indexOf(c)&&hoveredPin.pin==i) ? offset=2 : offset=0;
ctx.fillStyle=["black","red","grey","pink"][c.pins[i]+offset];
ctx.fill();
});
});
pinImages=pI;
requestAnimationFrame(drawCanvas);
}

188
build/editor/js/chips.js Executable file
View File

@ -0,0 +1,188 @@
chips = {
"nand": {
image: "img/gates/nand.png",
inputs: 2,
pins : [0,0,0],
subComponents : [],
wires : []
},
"not": {
image: "img/gates/not.png",
inputs: 1,
pins: [0,0],
subComponents: ["nand"],
wires: [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 0, pin: 1 }
}
]
},
"and": {
image: "img/gates/and.png",
inputs: 2,
pins : [0,0,0],
subComponents : ["nand", "nand"],
wires : [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 },
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 0 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 1 }
},
{
source: { component: 2, pin: 2 },
destination: { component: 0, pin: 2 }
}
]
},
"or": {
image: "img/gates/or.png",
inputs: 2,
pins: [0,0,0],
subComponents : ["nand","nand","nand"],
wires : [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 },
},
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 2, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 2, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 3, pin: 0 }
},
{
source: { component: 2, pin: 2 },
destination: { component: 3, pin: 1 }
},
{
source: { component: 3, pin: 2 },
destination: { component: 0, pin: 2 }
}
]
},
"xor": {
image: "img/gates/xor.png",
inputs:2,
pins: [0,0,0],
subComponents: ["nand","nand","nand", "nand"],
wires : [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 0, pin: 0 },
destination: { component: 2, pin: 0 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 3, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 3, pin: 1 }
},
{
source: { component: 2, pin: 2 },
destination: { component: 4, pin: 0 }
},
{
source: { component: 3, pin: 2 },
destination: { component: 4, pin: 1 }
},
{
source: { component: 4, pin: 2 },
destination: { component: 0, pin: 2 }
}
]
},
"nor": {
inputs:2,
image: "img/gates/nor.png",
pins: [0,0,0],
subComponents: ["or","not"],
wires: [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 0 },
},
{
source: { component: 2, pin: 1 },
destination: { component: 0, pin: 2 }
}
]
},
"xnor": {
inputs:2,
image: "img/gates/xnor.png",
pins: [0,0,0],
subComponents: ["xor","not"],
wires: [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 0 },
},
{
source: { component: 2, pin: 1 },
destination: { component: 0, pin: 2 }
}
]
}
}

188
build/editor/js/chips_old.js Executable file
View File

@ -0,0 +1,188 @@
chips = {
"nand": {
image: "img/gates/nand.png",
inputs: 2,
pins : [0,0,0],
subComponents : [],
wires : []
},
"not": {
image: "img/gates/not.png",
inputs: 1,
pins: [0,0],
subComponents: ["nand"],
wires: [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 0, pin: 1 }
}
]
},
"and": {
image: "img/gates/and.png",
inputs: 2,
pins : [0,0,0],
subComponents : ["nand", "nand"],
wires : [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 },
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 0 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 1 }
},
{
source: { component: 2, pin: 2 },
destination: { component: 0, pin: 2 }
}
]
},
"or": {
image: "img/gates/or.png",
inputs: 2,
pins: [0,0,0],
subComponents : ["nand","nand","nand"],
wires : [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 },
},
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 2, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 2, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 3, pin: 0 }
},
{
source: { component: 2, pin: 2 },
destination: { component: 3, pin: 1 }
},
{
source: { component: 3, pin: 2 },
destination: { component: 0, pin: 2 }
}
]
},
"xor": {
image: "img/gates/xor.png",
inputs:2,
pins: [0,0,0],
subComponents: ["nand","nand","nand", "nand"],
wires : [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 0, pin: 0 },
destination: { component: 2, pin: 0 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 3, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 3, pin: 1 }
},
{
source: { component: 2, pin: 2 },
destination: { component: 4, pin: 0 }
},
{
source: { component: 3, pin: 2 },
destination: { component: 4, pin: 1 }
},
{
source: { component: 4, pin: 2 },
destination: { component: 0, pin: 2 }
}
]
},
"nor": {
inputs:2,
image: "img/gates/nor.png",
pins: [0,0,0],
subComponents: ["or","not"],
wires: [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 0 },
},
{
source: { component: 2, pin: 1 },
destination: { component: 0, pin: 2 }
}
]
},
"xnor": {
inputs:2,
image: "img/gates/xnor.png",
pins: [0,0,0],
subComponents: ["xor","not"],
wires: [
{
source: { component: 0, pin: 0 },
destination: { component: 1, pin: 0 }
},
{
source: { component: 0, pin: 1 },
destination: { component: 1, pin: 1 }
},
{
source: { component: 1, pin: 2 },
destination: { component: 2, pin: 0 },
},
{
source: { component: 2, pin: 1 },
destination: { component: 0, pin: 2 }
}
]
}
}

177
build/editor/js/components.js Executable file
View File

@ -0,0 +1,177 @@
class Component {
type;
image;
inputs=0;
pins = [];
subComponents = [this];
zIndex = [];
wires = [];
position = { x: 0, y: 0 };
groups = [];
tooltips=[];
getJSONandName(name){
var niceStructure={type:name,image:this.image,groups:this.groups,inputs:this.inputs,tooltips:this.tooltips,pins:new Array(this.pins.length).fill(0),subComponents:[],positions:[],wires:this.wires};
this.subComponents.forEach(c=>{
if (c!==this){
niceStructure.subComponents.push(c.type);
niceStructure.positions.push(c.position);
}
});
return JSON.stringify(niceStructure);
}
constructor(name,direct=false,djson=""){
this.type = name;
if (!(name in chips) && !direct) {
return;
}
var chip;
if(!direct){
chip = JSON.parse(JSON.stringify(chips[name]));
} else {
chip = JSON.parse(djson);
}
this.image = chip.image;
this.groups = [1,2,3]//chip.groups || [];
this.pins = chip.pins;
this.wires = chip.wires;
this.inputs = chip.inputs;
this.tooltips = chip.tooltips;
chip.subComponents.forEach((sc,i)=>{
this.subComponents.push(new Component(sc));
this.zIndex.push(this.subComponents[i+1]);
if(chip.type=="main"){
this.subComponents[i+1].position = chip.positions[i];
}
});
this.process();
}
process(){
//var startTime = performance.now()
if (this.type=="nand"){
this.pins[2] = (this.pins[0] && this.pins[1])?0:1;
} else {
this.subComponents.forEach(s=>{if(s != this) {s.process()}});
this.wires.forEach(w=>{
this.subComponents[w.destination.component].pins[w.destination.pin] = this.subComponents[w.source.component].pins[w.source.pin]
});
}
//var endTime = performance.now()
//if(this.type=="main")
// console.log(`Updating ${this.type} took ${endTime - startTime} milliseconds`)
return this.pins;
}
addComponent(name){
var nc = new Component(name);
this.subComponents.push(nc);
this.zIndex.unshift(nc);
}
removeComponent(index){
this.zIndex = this.zIndex.filter(zEntry=> this.getProperIndex(zEntry) !== index);
this.wires.forEach(w=>{
if(w.source.component == index)
this.subComponents[w.destination.component].pins[w.destination.pin] = 0;
});
this.wires = this.wires.filter(w=>w.source.component != index && w.destination.component != index).map(w => { if(w.destination.component>index){w.destination.component-=1};if(w.source.component>index){w.source.component-=1}; return w });
this.subComponents.splice(index,1);
console.log("hi");
console.log(this.subComponents);
}
sendToFront(index){
this.zIndex=this.zIndex.filter(zEntry=>this.getProperIndex(zEntry)!==index);
this.zIndex.push(this.subComponents[index]);
}
getProperIndex(zEntry){
return this.subComponents.indexOf(zEntry);
}
connect(source,destination,wid){
var sourceIsInput,destinationIsOutput;
sourceIsInput=destinationIsOutput=0;
if (source.pin < this.subComponents[source.component].inputs)
sourceIsInput = true;
if (destination.pin >= this.subComponents[destination.component].inputs)
destinationIsOutput = true;
source = {component:source.component, pin:source.pin};
destination={component:destination.component,pin:destination.pin};
if(sourceIsInput){
if(source.component == 0){
if((destinationIsOutput&&destination.component!=0)||(!destinationIsOutput && destination.component==0)){
console.log(1);
return false;
}
} else {
if(destinationIsOutput && destination.component==0){
console.log({n:2,c:source.component});
return false;
} else if (destinationIsOutput||destination.component==0){
console.log("swap");
var tmp = source;
source=destination;
destination = tmp;
} else if(!destinationIsOutput&&destination.component==0) {
} else {
console.log(3);
return false;
}
}
} else {
if(source.component==0){
if((destinationIsOutput&&destination.component!=0)||(!destinationIsOutput&&destination.component==0)){
console.log("swap");
var tmp=source;
source=destination;
destination=tmp;
} else {
console.log(4);
return false;
}
} else {
if(destinationIsOutput&&destination.component!=0){
console.log(5);
return false;
/*
} else if (!destinationIsOutput){
console.log("swap");
var tmp=source;
source=destination;
destination=tmp;
*/
} else if(destination.component==0&&!destinationIsOutput){
console.log(6);
return false;
}
}
}
this.wires = this.wires.filter(w=>JSON.stringify(w.destination)!=JSON.stringify(destination));
this.wires.push({ source: source, destination: destination, wireId:wid });
return true;
}
disconnect(source,destination){
this.wires = this.wires.filter(w=>JSON.stringify(w)!=JSON.stringify({source:source,destination:destination}));
}
addPin(isInput){
if(isInput){
this.inputs++;
this.pins.unshift(0);
this.wires.forEach(w=>{ if(w.destination.component==0){w.destination.pin+=1} });
} else {
this.pins.push(0);
}
}
removePin(i){;
this.wires = this.wires.filter(w=>!((w.source.component==0 && w.source.pin == pin)||(w.destination.component==0 && w.destination.pin == pin)));
if(i<this.inputs){
this.pins.shift();
this.wires.forEach(w=>{ if(w.source.component==0){w.source.pin-=1}});
} else {
this.pins.pop();
}
}
}

425
build/editor/js/index.js Executable file
View File

@ -0,0 +1,425 @@
var canvas, ctx
var selectedItem
var mouseisdown
var chip = new Component("main");
var pinImages = [];
var wireVisuals = [];
var wireBeingDrawn = [];
images = {};
var chipoffset=0;
var numUpdates = 0;
var x;
document.addEventListener("DOMContentLoaded", function(event){
canvas = document.getElementById('logicsim');
canvas.addEventListener("mousedown",selectItem);
canvas.addEventListener("mouseup", function(){mouseisdown=false});
canvas.addEventListener("mousemove",mousemove);
document.addEventListener("keydown",checkKey);
document.addEventListener("keyup",function(e){shifted=e.shiftKey});
ctx = canvas.getContext('2d');
preloadAssets();
requestAnimationFrame(drawCanvas);
//x=setInterval(function(){var st = performance.now(); chip.process(console.log(performance.now()-st))},1.1);
y=0
x=setInterval(function(){chip.process();numUpdates+=1},0.3);
storedChips = localStorage.getItem('chips');
if(storedChips) chips = JSON.parse(storedChips);
});
function getMousePos(c,e){
var rect = c.getBoundingClientRect();
return {
x: e.clientX - rect.left,
y: e.clientY - rect.top
}
}
function checkKey(e){
e=e||window.event;
if(e.keyCode==27){
selectedPin={component:-1,pin:-1};
wireBeingDrawn=[];
} else if(e.key=="n"){
var name = prompt('name new chip or cancel');
if (name.length){
chips[name]=JSON.parse(chip.getJSONandName(name));
localStorage.setItem('chips',JSON.stringify(chips));
chip = new Component();
close();
}
} else if(e.keyCode==8 || e.keyCode==46){if(selectedItem>=0){chip.removeComponent(selectedItem);
wireVisuals.forEach(wv=>{
wv.path.forEach(p=>{if(p.component>selectedItem){p.component-=1}});
});}} else if (e.keyCode==37) {
chipoffset+=10;
} else if (e.keyCode==39) { chipoffset-=10};
shifted=e.shiftKey;
}
function isInside(c,point){
return ( point.x > c.position.x && point.x < c.position.x + images[c.type].width) &&
( point.y > c.position.y && point.y < c.position.y + images[c.type].height);
}
function isInsidePin(p,point){
return Math.sqrt(Math.pow((p.position.x-point.x),2)+Math.pow((p.position.y-point.y),2)) < p.radius;
}
var clickpos;
var shifted = 0;
var nWireAttempts=0;
var selectedPin = {component:-1,pin:-1};
var hoveredPin = {component:-1,pin:-1,type:-1};
function selectItem(e){
pos = getMousePos(canvas, e)
if(pos.y>canvas.height-60){
chipMenu.forEach(cm=>{
if((pos.x>cm.topLeft.x && pos.x < (cm.topLeft.x+cm.width))&&(pos.y>cm.topLeft.y&&pos.y<(cm.topLeft.y+40))){
console.log(cm.type);
chip.addComponent(cm.type);
//.position = {x:pos.x,y:pos.y}
} else {
}
});
return;
}
if(hoveredPin.component>=0){
if(hoveredPin.type==1){
if(hoveredPin.pin<chip.inputs)
chip.pins[hoveredPin.pin]=1-chip.pins[hoveredPin.pin];
} else {
if(wireBeingDrawn.length>0){
if(chip.connect(selectedPin, hoveredPin, nWireAttempts)){
wireBeingDrawn[wireBeingDrawn.length-1]={component:hoveredPin.component,pin:hoveredPin.pin,shift:shifted,offset:wireBeingDrawn[1].offset};
wireVisuals.push({wireId:nWireAttempts,path:wireBeingDrawn.slice()});
wireBeingDrawn=[];
selectedPin={component:-1,pin:-1};
nWireAttempts+=1;
} else {
console.log("noooo");
}
} else {
inp = chip.subComponents[hoveredPin.component].inputs;
defaultOffset = 10;
if(hoveredPin.component == 0 && hoveredPin.pin < inp){
o = 7*hoveredPin.pin;
rev = 1
} else if(hoveredPin.component == 0) {
o = 7*(hoveredPin.pin-inp);
rev = -1
} else if (hoveredPin.component>0 && hoveredPin.pin < inp) {
o = 7*hoveredPin.pin;
rev = -1
} else {
o = 7*(hoveredPin.pin-inp)
rev = 1
}
wireBeingDrawn.push({component:hoveredPin.component,pin:hoveredPin.pin,shift:shifted,rev:rev});
wireBeingDrawn.push({x:pos.x,y:pos.y,shift:shifted,offset:o});
selectedPin = {component:hoveredPin.component,pin:hoveredPin.pin};
}
}
} else if(pos.x<20){
if(typeof editDisabled == 'undefined')
chip.addPin(1);
//wireVisuals.forEach(wv=>{if(wv.path[0].component==0){wv.path[wv.path.length-1].pin+=1;}});
return true;
} else if(pos.x>canvas.width-20){
if(typeof editDisabled == 'undefined')
chip.addPin();
return true;
} else {
if(wireBeingDrawn.length>0){
wireBeingDrawn[wireBeingDrawn.length-1]={x:pos.x,y:pos.y,shift:shifted,offset:wireBeingDrawn[1].offset};
wireBeingDrawn.push({x:pos.x,y:pos.y,shift:shifted,offset:wireBeingDrawn[1].offset})//slice());
}
}
selectedItem=-1;
chip.zIndex.forEach(function(c,i){
if (isInside(c, pos) && ctx.getImageData(pos.x,pos.y,1,1).data[3]) {
mouseisdown = true;
clickpos = pos;
chip.sendToFront(chip.getProperIndex(c));
selectedItem = chip.getProperIndex(c);
console.log(selectedItem);
// DELETE THIS LATER //
return;
}
});
}
var pos;
function mousemove(e){
pos = getMousePos(canvas,e);
if(wireBeingDrawn.length>0){
o = wireBeingDrawn[wireBeingDrawn.length-1].offset;
wireBeingDrawn[wireBeingDrawn.length-1]={x:pos.x,y:pos.y,shift:shifted,offset:o};
}
if(mouseisdown){
last = chip.zIndex.length-1;
chip.zIndex[last].position.x -= (clickpos.x - pos.x);
chip.zIndex[last].position.y -= (clickpos.y - pos.y);
clickpos = pos;
}
if(!pinImages.some(pi=>{
if(isInsidePin(pi,pos)){
hoveredPin = {component:pi.component,pin:pi.pin,type:pi.type}
return true;
}
})){
hoveredPin={component:-1,pin:-1};
}
}
function preloadAssets(){
Object.entries(chips).forEach(function(c){
if (!(c[1].image in images)){
images[c[0]] = new Image();
images[c[0]].src = c[1].image;
}
});
if(typeof loadChip == 'function'){
loadChip();
}
}
function makeArr(startValue, stopValue, cardinality) {
var arr = [];
var step = (stopValue - startValue) / (cardinality - 1);
for (var i = 0; i < cardinality; i++) {
arr.push(startValue + (step * i));
}
return arr;
}
function drawCircle(x,y,radius,colour){
ctx.beginPath();
ctx.arc(Math.floor(x),Math.floor(y),radius,0,2*Math.PI,false);
ctx.fillStyle=colour;
ctx.fill();
}
function drawLine(origin,destination,width,colour,taxi,offset,rev){
if(!taxi||destination.shift){
ctx.beginPath();
ctx.moveTo(origin.x,origin.y);
ctx.lineTo(destination.x,destination.y);
ctx.strokeStyle=colour;
ctx.lineWidth=width;
ctx.stroke();
} else {
ctx.beginPath();
ctx.moveTo(origin.x,origin.y);
if(destination.y>origin.y){
offset = offset*-rev;
} else {
offset = offset * rev;
}
multip = 0.4;
if(rev<0) {
multip = 1-multip;
}
ctx.lineTo(origin.x+(destination.x-origin.x)*multip+offset,origin.y);
ctx.lineTo(origin.x+(destination.x-origin.x)*multip+offset,destination.y);
ctx.lineTo(destination.x,destination.y);
ctx.strokeStyle=colour;
ctx.lineWidth=width;
ctx.stroke();
}
}
chipMenu = [];
tt = null;
class Tooltip {
constructor(x,y,message,persist=false){
this.x=x;
this.y=y;
this.message=message;
this.persist=persist;
}
draw(offset){
//ctx.fillStyle='pink';
//ctx.fillRect(0,0,canvas.width,canvas.height);
//return;
ctx.fillStyle="rgba(0,0,0,0.65)";
ctx.font="20px vcr_osd_monoregular";
ctx.textBaseline="bottom";
ctx.textAlign="left";
var width=ctx.measureText(this.message).width+6;
offset=0
ctx.fillRect(this.x<canvas.width/2?this.x:this.x-width,this.y-25-(26*offset),width,25);
ctx.fillStyle="white";
ctx.fillText(this.message,this.x<canvas.width/2?(this.x+3):(this.x-width+3),this.y-(26*offset));
}
}
function drawTooltip(message){
if(!message) return
if(!tt){
tt = new Tooltip(pos.x,pos.y,message);
}
}
function drawCanvas() {
//console.log(`Processed ${numUpdates} times`);
numUpdates=0;
// loadChip();
pI = [];
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.canvas.width = window.innerWidth;
ctx.canvas.height = window.innerHeight;
ctx.fillStyle="darkgray";
ctx.fillRect(0,0,20,canvas.height-60);
ctx.fillRect(canvas.width-20,0,canvas.width,canvas.height-60);
ctx.fillStyle="#303030";
ctx.fillRect(0,canvas.height-60,canvas.width,canvas.height);
var cm=[];
var curX = 5;
Object.entries(chips).forEach(chip=>{
ctx.font = "20px vcr_osd_monoregular"
ctx.fillStyle="#1A3060";
width=ctx.measureText(chip[0]).width+8;
ctx.fillRect(curX+chipoffset,canvas.height-50,width,40);
ctx.fillStyle="white";
ctx.fillText(chip[0],curX+chipoffset+4,canvas.height-25);
cm.push({type:chip[0],topLeft:{x: curX+chipoffset, y: canvas.height-50},width:width});
curX+=width+5;
});
chipMenu=cm;
//components.slice().reverse().forEach(function(c){
for(var i=0;i<wireBeingDrawn.length-1;i++){
if(i==0)
p1=pinImages.find(p=>p.component==wireBeingDrawn[0].component && p.pin==wireBeingDrawn[0].pin && p.type==0).position;
else
p1=wireBeingDrawn[i];
//if(i==wireBeingDrawn.length-2)
// p2=pinImages.find(p=>p.component==wireBeingDrawn[i+1].component&&p.pin==wireBeingDrawn[i+1].pin&&p.type==0).position;
//else
p2=wireBeingDrawn[i+1]
o=0.5;
if(wireBeingDrawn[i+1].offset != undefined){
o=wireBeingDrawn[i+1].offset;
}
drawLine(p1,p2,3,["lightgray","red"][chip.subComponents[wireBeingDrawn[0].component].pins[wireBeingDrawn[0].pin]],true,o,wireBeingDrawn[0].rev);
}
wireVisuals=wireVisuals.filter(wv=> {return chip.wires.findIndex(w=>w.wireId==wv.wireId)>=0});
wireVisuals.forEach(wv=>{
for(var i=0;i<wv.path.length-1;i++){
if(i==0)
p1=pinImages.find(p=>p.component==wv.path[0].component && p.pin==wv.path[0].pin && p.type==0).position;
else
p1=wv.path[i];
if(i==wv.path.length-2)
p2=pinImages.find(p=>p.component==wv.path[i+1].component&&p.pin==wv.path[i+1].pin&&p.type==0).position;
else
p2=wv.path[i+1];
drawLine(p1,p2,3,["lightgray","red"][chip.subComponents[wv.path[0].component].pins[wv.path[0].pin]],true,wv.path[1].offset,wv.path[0].rev);
}
});
currentGroup=-1;
groupn=1;
chip.pins.forEach((p,i)=>{
if(i<chip.inputs){
centerX=10;
otherpins = chip.inputs;
pindex=i;
} else {
centerX = canvas.width - 10;
otherpins = chip.pins.length - chip.inputs;
pindex = i - chip.inputs;
}
ys = makeArr(0-(20/otherpins),0+(canvas.height-60)+(20/otherpins),otherpins+2);
ys.shift();
ys.pop();
centerY = ys[pindex];
//ctx.beginPath();
//ctx.arc(Math.floor(centerX), Math.floor(centerY), 10, 0, 2*Math.PI, false)
(hoveredPin.component==0&&hoveredPin.pin==i&&hoveredPin.type==0) ? offset=2 : offset=0;
newGroup = -1;
chip.groups.forEach((group,n)=>{
if(group.includes(i)) newGroup = n;
});
if(newGroup>-1 && newGroup==currentGroup) {
centerY -=20*groupn;
groupn++;
} else {groupn=1};
pI.push({component:0,pin:i,position:{x:centerX,y:centerY},radius:7,type:1});
secondaryX=(i<chip.inputs?centerX+20:centerX-20);
pI.push({component:0,pin:i,position:{x:secondaryX,y:centerY},radius:5,type:0});
fillStyle1=["black","red","grey","pink"][chip.pins[i]+offset];
fillStyle2=(i<chip.inputs?["black","red","grey","pink"]:["black","red","black","red"])[chip.pins[i]+((hoveredPin.component==0&&hoveredPin.pin==i&&hoveredPin.type==1)?2:0)];
//ctx.fill();
drawLine({x:centerX,y:centerY},{x:secondaryX,y:centerY},1,["black","red"][chip.pins[i]],false);
drawCircle(centerX,centerY,10,fillStyle2);
drawCircle(secondaryX,centerY,5,fillStyle1);
if(newGroup>-1){
ctx.fillStyle="white";
old=[ctx.textAlign, ctx.textBaseline];
ctx.textAlign="center";
ctx.textBaseline="middle";
ctx.font='11px monospace'
if(!chip.no)
ctx.fillText(Math.pow(2,groupn-1), centerX, centerY);
else if(!chip.no.includes(i)) ctx.fillText(Math.pow(2,groupn-1), centerX, centerY);
ctx.textAlign=old[0];
ctx.textBaseline=old[1];
}
currentGroup=newGroup;
})
chip.zIndex.forEach(c=>{
img = images[c.type];
if(img!==undefined&&img.dummy!=1)
ctx.drawImage(img,c.position.x,c.position.y);
else {
ctx.font = "20px vcr_osd_monoregular"
ctx.fillStyle="#1A3060";
h = parseInt(md5(c.type).substring(1,10),16);
poss_colors = ["white","red","lightblue","pink","yellow","lightgreen","orange","violet"];
ctx.fillStyle = poss_colors[h%poss_colors.length];
width = ctx.measureText(c.type).width + 30;
if (c.inputs>c.pins.length/2){
height = c.inputs * 15
} else {
height = (c.pins.length-c.inputs)*15;
}
ctx.fillRect(c.position.x,c.position.y,width,height);
ctx.fillStyle="black";
ctx.fillText(c.type,c.position.x+15,c.position.y+(height/2)+4);
img = {width,height,dummy:1};
images[c.type]=img;
}
c.pins.forEach((p,i)=>{
//trueCenterY = (c.position.y+(c.position.y + c.height))/2
centerX = c.position.x+img.width+5;
otherpins = c.pins.length - c.inputs;
pindex = i - c.inputs;
if(i<c.inputs){
centerX = c.position.x-5;
if(["xor","nor","or"].includes(c.type)){
centerX += 9;
}
otherpins = c.inputs;
pindex=i;
}
ys = makeArr(c.position.y-(20/otherpins),c.position.y+img.height+(20/otherpins),otherpins+2);
ys.shift();
ys.pop();
centerY = ys[pindex];
pI.push({component:chip.subComponents.indexOf(c),pin:i,position:{x:centerX,y:centerY},radius:10,type:0});
ctx.beginPath();
ctx.arc(Math.floor(centerX), Math.floor(centerY), 5, 0, 2*Math.PI, false);
(hoveredPin.component==chip.subComponents.indexOf(c)&&hoveredPin.pin==i) ? offset=2 : offset=0;
ctx.fillStyle=["black","red","grey","pink"][c.pins[i]+offset];
ctx.fill();
});
});
pinImages=pI;
tt = null;
if(hoveredPin.component>=0){
try{
drawTooltip(chip.subComponents[hoveredPin.component].tooltips[hoveredPin.pin]);
} catch(ex){console.log(ex)}
} else {
}
if(tt) tt.draw();
requestAnimationFrame(drawCanvas);
}

View File

@ -0,0 +1,10 @@
function loadChip(){
setTimeout(function(){
chip = new Component("main", true, '{"type":"main","groups":[[0,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]],"inputs":21,"tooltips":["operand 0","operand 0","operand 0","operand 0","operand 0","operand 0","operand 0","operand 0","operand 1","operand 1","operand 1","operand 1","operand 1","operand 1","operand 1","operand 1","opcode","opcode","opcode","opcode","carry/borrow in","result","result","result","result","result","result","result","result","overflow flag","negative flag","carry/borrow flag","zero flag"],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":["ALU"],"positions":[{"x":467,"y":673}],"wires":[{"source":{"component":1,"pin":32},"destination":{"component":0,"pin":32},"wireId":0},{"source":{"component":1,"pin":31},"destination":{"component":0,"pin":31},"wireId":1},{"source":{"component":1,"pin":30},"destination":{"component":0,"pin":30},"wireId":2},{"source":{"component":1,"pin":29},"destination":{"component":0,"pin":29},"wireId":3},{"source":{"component":1,"pin":28},"destination":{"component":0,"pin":28},"wireId":4},{"source":{"component":1,"pin":27},"destination":{"component":0,"pin":27},"wireId":5},{"source":{"component":1,"pin":26},"destination":{"component":0,"pin":26},"wireId":6},{"source":{"component":1,"pin":25},"destination":{"component":0,"pin":25},"wireId":7},{"source":{"component":1,"pin":24},"destination":{"component":0,"pin":24},"wireId":8},{"source":{"component":1,"pin":23},"destination":{"component":0,"pin":23},"wireId":9},{"source":{"component":1,"pin":22},"destination":{"component":0,"pin":22},"wireId":10},{"source":{"component":1,"pin":21},"destination":{"component":0,"pin":21},"wireId":11},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":12},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1},"wireId":13},{"source":{"component":0,"pin":2},"destination":{"component":1,"pin":2},"wireId":15},{"source":{"component":0,"pin":3},"destination":{"component":1,"pin":3},"wireId":16},{"source":{"component":0,"pin":4},"destination":{"component":1,"pin":4},"wireId":17},{"source":{"component":0,"pin":5},"destination":{"component":1,"pin":5},"wireId":18},{"source":{"component":0,"pin":6},"destination":{"component":1,"pin":6},"wireId":19},{"source":{"component":0,"pin":7},"destination":{"component":1,"pin":7},"wireId":20},{"source":{"component":0,"pin":8},"destination":{"component":1,"pin":8},"wireId":21},{"source":{"component":0,"pin":9},"destination":{"component":1,"pin":9},"wireId":22},{"source":{"component":0,"pin":10},"destination":{"component":1,"pin":10},"wireId":23},{"source":{"component":0,"pin":11},"destination":{"component":1,"pin":11},"wireId":24},{"source":{"component":0,"pin":12},"destination":{"component":1,"pin":12},"wireId":25},{"source":{"component":0,"pin":13},"destination":{"component":1,"pin":13},"wireId":26},{"source":{"component":0,"pin":14},"destination":{"component":1,"pin":14},"wireId":27},{"source":{"component":0,"pin":15},"destination":{"component":1,"pin":15},"wireId":28},{"source":{"component":0,"pin":16},"destination":{"component":1,"pin":16},"wireId":29},{"source":{"component":0,"pin":17},"destination":{"component":1,"pin":17},"wireId":30},{"source":{"component":0,"pin":18},"destination":{"component":1,"pin":18},"wireId":31},{"source":{"component":0,"pin":19},"destination":{"component":1,"pin":19},"wireId":32},{"source":{"component":0,"pin":20},"destination":{"component":1,"pin":20},"wireId":33}]}');
chip.groups = []
chip.tooltips = ["A","B","nand/xor?","output"];
},1000)
setTimeout(function(){
wireVisuals = JSON.parse('[{"wireId":0,"path":[{"component":1,"pin":32,"shift":false,"rev":1},{"component":0,"pin":32,"shift":false,"offset":77}]},{"wireId":1,"path":[{"component":1,"pin":31,"shift":false,"rev":1},{"component":0,"pin":31,"shift":false,"offset":70}]},{"wireId":2,"path":[{"component":1,"pin":30,"shift":false,"rev":1},{"component":0,"pin":30,"shift":false,"offset":63}]},{"wireId":3,"path":[{"component":1,"pin":29,"shift":false,"rev":1},{"component":0,"pin":29,"shift":false,"offset":56}]},{"wireId":4,"path":[{"component":1,"pin":28,"shift":false,"rev":1},{"component":0,"pin":28,"shift":false,"offset":49}]},{"wireId":5,"path":[{"component":1,"pin":27,"shift":false,"rev":1},{"component":0,"pin":27,"shift":false,"offset":42}]},{"wireId":6,"path":[{"component":1,"pin":26,"shift":false,"rev":1},{"component":0,"pin":26,"shift":false,"offset":35}]},{"wireId":7,"path":[{"component":1,"pin":25,"shift":false,"rev":1},{"component":0,"pin":25,"shift":false,"offset":28}]},{"wireId":8,"path":[{"component":1,"pin":24,"shift":false,"rev":1},{"component":0,"pin":24,"shift":false,"offset":21}]},{"wireId":9,"path":[{"component":1,"pin":23,"shift":false,"rev":1},{"component":0,"pin":23,"shift":false,"offset":14}]},{"wireId":10,"path":[{"component":1,"pin":22,"shift":false,"rev":1},{"component":0,"pin":22,"shift":false,"offset":7}]},{"wireId":11,"path":[{"component":1,"pin":21,"shift":false,"rev":1},{"component":0,"pin":21,"shift":false,"offset":0}]},{"wireId":12,"path":[{"component":0,"pin":0,"shift":false,"rev":1},{"component":1,"pin":0,"shift":false,"offset":0}]},{"wireId":13,"path":[{"component":0,"pin":1,"shift":false,"rev":1},{"component":1,"pin":1,"shift":false,"offset":7}]},{"wireId":15,"path":[{"component":0,"pin":2,"shift":false,"rev":1},{"component":1,"pin":2,"shift":false,"offset":14}]},{"wireId":16,"path":[{"component":0,"pin":3,"shift":false,"rev":1},{"component":1,"pin":3,"shift":false,"offset":21}]},{"wireId":17,"path":[{"component":0,"pin":4,"shift":false,"rev":1},{"component":1,"pin":4,"shift":false,"offset":28}]},{"wireId":18,"path":[{"component":0,"pin":5,"shift":false,"rev":1},{"component":1,"pin":5,"shift":false,"offset":35}]},{"wireId":19,"path":[{"component":0,"pin":6,"shift":false,"rev":1},{"component":1,"pin":6,"shift":false,"offset":42}]},{"wireId":20,"path":[{"component":0,"pin":7,"shift":false,"rev":1},{"component":1,"pin":7,"shift":false,"offset":49}]},{"wireId":21,"path":[{"component":0,"pin":8,"shift":false,"rev":1},{"component":1,"pin":8,"shift":false,"offset":56}]},{"wireId":22,"path":[{"component":0,"pin":9,"shift":false,"rev":1},{"component":1,"pin":9,"shift":false,"offset":63}]},{"wireId":23,"path":[{"component":0,"pin":10,"shift":false,"rev":1},{"component":1,"pin":10,"shift":false,"offset":70}]},{"wireId":24,"path":[{"component":0,"pin":11,"shift":false,"rev":1},{"component":1,"pin":11,"shift":false,"offset":77}]},{"wireId":25,"path":[{"component":0,"pin":12,"shift":false,"rev":1},{"component":1,"pin":12,"shift":false,"offset":84}]},{"wireId":26,"path":[{"component":0,"pin":13,"shift":false,"rev":1},{"component":1,"pin":13,"shift":false,"offset":91}]},{"wireId":27,"path":[{"component":0,"pin":14,"shift":false,"rev":1},{"component":1,"pin":14,"shift":false,"offset":98}]},{"wireId":28,"path":[{"component":0,"pin":15,"shift":false,"rev":1},{"component":1,"pin":15,"shift":false,"offset":105}]},{"wireId":29,"path":[{"component":0,"pin":16,"shift":false,"rev":1},{"component":1,"pin":16,"shift":false,"offset":112}]},{"wireId":30,"path":[{"component":0,"pin":17,"shift":false,"rev":1},{"component":1,"pin":17,"shift":false,"offset":119}]},{"wireId":31,"path":[{"component":0,"pin":18,"shift":false,"rev":1},{"component":1,"pin":18,"shift":false,"offset":126}]},{"wireId":32,"path":[{"component":0,"pin":19,"shift":false,"rev":1},{"component":1,"pin":19,"shift":false,"offset":133}]},{"wireId":33,"path":[{"component":0,"pin":20,"shift":false,"rev":1},{"component":1,"pin":20,"shift":false,"offset":140}]}]');
},2000);
}

View File

@ -0,0 +1,10 @@
function loadChip(){
setTimeout(function(){
chip = new Component("main", true, '{"type":"main","groups":[[0,1,2,3,4,5,6,7],[8,9,10,11,12,13,14,15],[16],[17,18,19,20,21,22,23,24]],"inputs":17,"tooltips":["A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B","select","output","output","output","output","output","output","output","output"],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":["16:8 mux"],"positions":[{"x":690,"y":308}],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":0},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1},"wireId":1},{"source":{"component":0,"pin":2},"destination":{"component":1,"pin":2},"wireId":2},{"source":{"component":0,"pin":3},"destination":{"component":1,"pin":3},"wireId":3},{"source":{"component":0,"pin":4},"destination":{"component":1,"pin":4},"wireId":4},{"source":{"component":0,"pin":5},"destination":{"component":1,"pin":5},"wireId":5},{"source":{"component":0,"pin":6},"destination":{"component":1,"pin":6},"wireId":6},{"source":{"component":0,"pin":7},"destination":{"component":1,"pin":7},"wireId":7},{"source":{"component":0,"pin":8},"destination":{"component":1,"pin":8},"wireId":8},{"source":{"component":0,"pin":9},"destination":{"component":1,"pin":9},"wireId":9},{"source":{"component":0,"pin":10},"destination":{"component":1,"pin":10},"wireId":10},{"source":{"component":0,"pin":11},"destination":{"component":1,"pin":11},"wireId":11},{"source":{"component":0,"pin":12},"destination":{"component":1,"pin":12},"wireId":12},{"source":{"component":0,"pin":13},"destination":{"component":1,"pin":13},"wireId":13},{"source":{"component":0,"pin":14},"destination":{"component":1,"pin":14},"wireId":14},{"source":{"component":0,"pin":15},"destination":{"component":1,"pin":15},"wireId":15},{"source":{"component":0,"pin":16},"destination":{"component":1,"pin":16},"wireId":16},{"source":{"component":1,"pin":17},"destination":{"component":0,"pin":17},"wireId":17},{"source":{"component":1,"pin":18},"destination":{"component":0,"pin":18},"wireId":18},{"source":{"component":1,"pin":19},"destination":{"component":0,"pin":19},"wireId":19},{"source":{"component":1,"pin":20},"destination":{"component":0,"pin":20},"wireId":20},{"source":{"component":1,"pin":21},"destination":{"component":0,"pin":21},"wireId":21},{"source":{"component":1,"pin":22},"destination":{"component":0,"pin":22},"wireId":22},{"source":{"component":1,"pin":23},"destination":{"component":0,"pin":23},"wireId":23},{"source":{"component":1,"pin":24},"destination":{"component":0,"pin":24},"wireId":24}]}');
chip.groups = []
chip.tooltips = ["A","B","nand/xor?","output"];
},1000)
setTimeout(function(){
wireVisuals = JSON.parse('[{"wireId":0,"path":[{"component":0,"pin":0,"shift":false,"rev":1},{"component":1,"pin":0,"shift":false,"offset":0}]},{"wireId":1,"path":[{"component":0,"pin":1,"shift":false,"rev":1},{"component":1,"pin":1,"shift":false,"offset":7}]},{"wireId":2,"path":[{"component":0,"pin":2,"shift":false,"rev":1},{"component":1,"pin":2,"shift":false,"offset":14}]},{"wireId":3,"path":[{"component":0,"pin":3,"shift":false,"rev":1},{"component":1,"pin":3,"shift":false,"offset":21}]},{"wireId":4,"path":[{"component":0,"pin":4,"shift":false,"rev":1},{"component":1,"pin":4,"shift":false,"offset":28}]},{"wireId":5,"path":[{"component":0,"pin":5,"shift":false,"rev":1},{"component":1,"pin":5,"shift":false,"offset":35}]},{"wireId":6,"path":[{"component":0,"pin":6,"shift":false,"rev":1},{"component":1,"pin":6,"shift":false,"offset":42}]},{"wireId":7,"path":[{"component":0,"pin":7,"shift":false,"rev":1},{"component":1,"pin":7,"shift":false,"offset":49}]},{"wireId":8,"path":[{"component":0,"pin":8,"shift":false,"rev":1},{"component":1,"pin":8,"shift":false,"offset":56}]},{"wireId":9,"path":[{"component":0,"pin":9,"shift":false,"rev":1},{"component":1,"pin":9,"shift":false,"offset":63}]},{"wireId":10,"path":[{"component":0,"pin":10,"shift":false,"rev":1},{"component":1,"pin":10,"shift":false,"offset":70}]},{"wireId":11,"path":[{"component":0,"pin":11,"shift":false,"rev":1},{"component":1,"pin":11,"shift":false,"offset":77}]},{"wireId":12,"path":[{"component":0,"pin":12,"shift":false,"rev":1},{"component":1,"pin":12,"shift":false,"offset":84}]},{"wireId":13,"path":[{"component":0,"pin":13,"shift":false,"rev":1},{"component":1,"pin":13,"shift":false,"offset":91}]},{"wireId":14,"path":[{"component":0,"pin":14,"shift":false,"rev":1},{"component":1,"pin":14,"shift":false,"offset":98}]},{"wireId":15,"path":[{"component":0,"pin":15,"shift":false,"rev":1},{"component":1,"pin":15,"shift":false,"offset":105}]},{"wireId":16,"path":[{"component":0,"pin":16,"shift":false,"rev":1},{"component":1,"pin":16,"shift":false,"offset":112}]},{"wireId":17,"path":[{"component":1,"pin":17,"shift":true,"rev":1},{"component":0,"pin":17,"shift":true,"offset":0}]},{"wireId":18,"path":[{"component":1,"pin":18,"shift":true,"rev":1},{"component":0,"pin":18,"shift":true,"offset":7}]},{"wireId":19,"path":[{"component":1,"pin":19,"shift":false,"rev":1},{"component":0,"pin":19,"shift":false,"offset":14}]},{"wireId":20,"path":[{"component":1,"pin":20,"shift":false,"rev":1},{"component":0,"pin":20,"shift":false,"offset":21}]},{"wireId":21,"path":[{"component":1,"pin":21,"shift":false,"rev":1},{"component":0,"pin":21,"shift":false,"offset":28}]},{"wireId":22,"path":[{"component":1,"pin":22,"shift":false,"rev":1},{"component":0,"pin":22,"shift":false,"offset":35}]},{"wireId":23,"path":[{"component":1,"pin":23,"shift":false,"rev":1},{"component":0,"pin":23,"shift":false,"offset":42}]},{"wireId":24,"path":[{"component":1,"pin":24,"shift":false,"rev":1},{"component":0,"pin":24,"shift":false,"offset":49}]}]');
},2000);
}

6
build/editor/js/items/alu.js Executable file
View File

@ -0,0 +1,6 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":21,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,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]];
chip.no=[29,30,31,32];
chip.tooltips = ["operand 0","operand 0","operand 0","operand 0","operand 0","operand 0","operand 0","operand 0","operand 1","operand 1","operand 1","operand 1","operand 1","operand 1","operand 1","operand 1","opcode","opcode","opcode","opcode","carry/borrow in","result","result","result","result","result","result","result","result","overflow flag","negative flag","carry/borrow flag","zero flag"];
}

5
build/editor/js/items/alu1.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":2,"tooltips":[],"pins":[0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0],[1],[2],[3]]
chip.tooltips = ["A","B","sum", "carry"]
}

5
build/editor/js/items/alu10.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":12,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,1,2,3,4,5,6,7],[8,9,10],[12,13,14,15,16,17,18,19]];
chip.tooltips = ["input","input","input","input","input","input","input","input","shift by","shift by","shift by","left/right?","output","output","output","output","output","output","output","output"];
}

5
build/editor/js/items/alu11.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":18,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,1,2,3,4,5,6,7],[8,9,10,11,12,13,14,15],[18,19,20,21,22,23,24,25]];
chip.tooltips = ["A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B","operation select - nand/xor or shift", "operation select - nand/left or xor/right","result","result","result","result","result","result","result","result"];
}

5
build/editor/js/items/alu2.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":3,"tooltips":[],"pins":[0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0],[1],[2],[3],[4]];
chip.tooltips = ["A","B","carry in", "sum", "carry out"];
}

5
build/editor/js/items/alu3.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":17,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,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]];
chip.tooltips = ["A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B","carry in","sum","sum","sum","sum","sum","sum","sum","sum","carry out"];
}

5
build/editor/js/items/alu4.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":8,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,1,2,3,4,5,6,7],[8,9,10,11,12,13,14,15]];
chip.tooltips = ["input","input","input","input","input","input","input","input","output","output","output","output","output","output","output","output"];
}

5
build/editor/js/items/alu5.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":17,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,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]];
chip.tooltips = ["A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B","borrow in","difference","difference","difference","difference","difference","difference","difference","difference","borrow out"];
}

5
build/editor/js/items/alu6.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":18,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,1,2,3,4,5,6,7],[8,9,10,11,12,13,14,15],[16],[18,19,20,21,22,23,24,25],[26]];
chip.tooltips = ["A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B","carry/borrow in","operation select","result","result","result","result","result","result","result","result","carry/borrow out"];
}

5
build/editor/js/items/alu7.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":3,"tooltips":[],"pins":[0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [];
chip.tooltips = ["A","B","nand/xor?","output"];
}

View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":16,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,1,2,3,4,5,6,7],[8,9,10,11,12,13,14,15]];
chip.tooltips = ["A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B","output"];
}

5
build/editor/js/items/alu8.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":17,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,1,2,3,4,5,6,7],[8,9,10,11,12,13,14,15],[17,18,19,20,21,22,23,24]];
chip.tooltips = ["A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B","nand/nor?","output","output","output","output","output","output","output","output"];
}

5
build/editor/js/items/alu9.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":9,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,1,2,3,4,5,6,7],[9,10,11,12,13,14,15,16]];
chip.tooltips = ["input","input","input","input","input","input","input","input","left/right?","output","output","output","output","output","output","output","output"];
}

0
build/editor/js/items/md5.js Executable file
View File

5
build/editor/js/items/mux1.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":3,"tooltips":[],"pins":[0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[2]]
chip.tooltips = ["A","B","select", "output"]
}

5
build/editor/js/items/mux2.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":17,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[0,1,2,3,4,5,6,7],[8,9,10,11,12,13,14,15], [16], [17,18,19,20,21,22,23,24]]
chip.tooltips = ["A","A","A","A","A","A","A","A","B","B","B","B","B","B","B","B","select","output","output","output","output","output","output","output", "output"]
}

5
build/editor/js/items/mux3.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":2,"tooltips":[],"pins":[0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[1]]
chip.tooltips = ["input","select","output A", "output B"]
}

5
build/editor/js/items/mux4.js Executable file
View File

@ -0,0 +1,5 @@
function loadChip(){
chip=new Component('main',true,'{"type":"main","inputs":4,"tooltips":[],"pins":[0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
chip.groups = [[1,2,3]]
chip.tooltips = ["input","select","select","select","output A", "output B", "output C", "output D", "output E", "output F", "output G", "output H"]
}

View File

@ -0,0 +1,6 @@
function loadChip(){
chip = new Component("main",true,'{"type":"main","inputs":3,"pins":[0,0,0,0],"subComponents":["and","not","or","and"],"positions":[{"x":255,"y":136},{"x":126,"y":364},{"x":536,"y":179},{"x":291,"y":240}],"wires":[{"source":{"component":0,"pin":2},"destination":{"component":2,"pin":0},"wireId":0},{"source":{"component":2,"pin":1},"destination":{"component":1,"pin":1},"wireId":1},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":2},{"source":{"component":1,"pin":2},"destination":{"component":3,"pin":0},"wireId":3},{"source":{"component":0,"pin":1},"destination":{"component":4,"pin":0},"wireId":4},{"source":{"component":0,"pin":2},"destination":{"component":4,"pin":1},"wireId":5},{"source":{"component":4,"pin":2},"destination":{"component":3,"pin":1},"wireId":6},{"source":{"component":3,"pin":2},"destination":{"component":0,"pin":3},"wireId":7}]}');
setTimeout(function(){ wireVisuals = JSON.parse(
'[{"wireId":0,"path":[{"component":0,"pin":2,"shift":0,"rev":1},{"component":2,"pin":0,"shift":0,"offset":14}]},{"wireId":1,"path":[{"component":2,"pin":1,"shift":0,"rev":1},{"component":1,"pin":1,"shift":0,"offset":0}]},{"wireId":2,"path":[{"component":0,"pin":0,"shift":0,"rev":1},{"component":1,"pin":0,"shift":0,"offset":0}]},{"wireId":3,"path":[{"component":1,"pin":2,"shift":0,"rev":1},{"component":3,"pin":0,"shift":0,"offset":0}]},{"wireId":4,"path":[{"component":0,"pin":1,"shift":0,"rev":1},{"component":4,"pin":0,"shift":0,"offset":7}]},{"wireId":5,"path":[{"component":0,"pin":2,"shift":0,"rev":1},{"component":4,"pin":1,"shift":0,"offset":14}]},{"wireId":6,"path":[{"component":4,"pin":2,"shift":0,"rev":1},{"component":3,"pin":1,"shift":0,"offset":0}]},{"wireId":7,"path":[{"component":3,"pin":2,"shift":0,"rev":1},{"component":0,"pin":3,"shift":0,"offset":0}]}]');
},50);
}

View File

@ -0,0 +1,7 @@
function loadChip(){
chips=JSON.parse('{"nand":{"image":"img/gates/nand.png","inputs":2,"pins":[0,0,0],"subComponents":[],"wires":[]},"not":{"image":"img/gates/not.png","inputs":1,"pins":[0,0],"subComponents":["nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":0,"pin":1}}]},"and":{"image":"img/gates/and.png","inputs":2,"pins":[0,0,0],"subComponents":["nand","nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":1}},{"source":{"component":2,"pin":2},"destination":{"component":0,"pin":2}}]},"or":{"image":"img/gates/or.png","inputs":2,"pins":[0,0,0],"subComponents":["nand","nand","nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":1}},{"source":{"component":0,"pin":1},"destination":{"component":2,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":2,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":3,"pin":0}},{"source":{"component":2,"pin":2},"destination":{"component":3,"pin":1}},{"source":{"component":3,"pin":2},"destination":{"component":0,"pin":2}}]},"xor":{"image":"img/gates/xor.png","inputs":2,"pins":[0,0,0],"subComponents":["nand","nand","nand","nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":0,"pin":0},"destination":{"component":2,"pin":0}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":3,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":3,"pin":1}},{"source":{"component":2,"pin":2},"destination":{"component":4,"pin":0}},{"source":{"component":3,"pin":2},"destination":{"component":4,"pin":1}},{"source":{"component":4,"pin":2},"destination":{"component":0,"pin":2}}]},"nor":{"inputs":2,"image":"img/gates/nor.png","pins":[0,0,0],"subComponents":["or","not"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0}},{"source":{"component":2,"pin":1},"destination":{"component":0,"pin":2}}]},"xnor":{"inputs":2,"image":"img/gates/xnor.png","pins":[0,0,0],"subComponents":["xor","not"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0}},{"source":{"component":2,"pin":1},"destination":{"component":0,"pin":2}}]},"2-1 mux":{"type":"2-1 mux","inputs":3,"pins":[0,0,0,0],"subComponents":["and","not","or","and"],"positions":[{"x":255,"y":136},{"x":126,"y":364},{"x":536,"y":179},{"x":291,"y":240}],"wires":[{"source":{"component":0,"pin":2},"destination":{"component":2,"pin":0},"wireId":0},{"source":{"component":2,"pin":1},"destination":{"component":1,"pin":1},"wireId":1},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":2},{"source":{"component":1,"pin":2},"destination":{"component":3,"pin":0},"wireId":3},{"source":{"component":0,"pin":1},"destination":{"component":4,"pin":0},"wireId":4},{"source":{"component":0,"pin":2},"destination":{"component":4,"pin":1},"wireId":5},{"source":{"component":4,"pin":2},"destination":{"component":3,"pin":1},"wireId":6},{"source":{"component":3,"pin":2},"destination":{"component":0,"pin":3},"wireId":7}]}}');
chip = new Component("main",true,'{"type":"main","inputs":9,"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":["2-1 mux","2-1 mux","2-1 mux","2-1 mux"],"positions":[{"x":259,"y":17},{"x":438,"y":112},{"x":590,"y":194},{"x":610,"y":296}],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":0},{"source":{"component":0,"pin":8},"destination":{"component":1,"pin":2},"wireId":2},{"source":{"component":0,"pin":4},"destination":{"component":1,"pin":1},"wireId":3},{"source":{"component":0,"pin":1},"destination":{"component":2,"pin":0},"wireId":4},{"source":{"component":0,"pin":5},"destination":{"component":2,"pin":1},"wireId":5},{"source":{"component":1,"pin":3},"destination":{"component":0,"pin":9},"wireId":6},{"source":{"component":2,"pin":3},"destination":{"component":0,"pin":10},"wireId":7},{"source":{"component":3,"pin":3},"destination":{"component":0,"pin":11},"wireId":8},{"source":{"component":0,"pin":8},"destination":{"component":2,"pin":2},"wireId":9},{"source":{"component":0,"pin":2},"destination":{"component":3,"pin":0},"wireId":10},{"source":{"component":0,"pin":6},"destination":{"component":3,"pin":1},"wireId":11},{"source":{"component":0,"pin":8},"destination":{"component":3,"pin":2},"wireId":12},{"source":{"component":0,"pin":3},"destination":{"component":4,"pin":0},"wireId":13},{"source":{"component":0,"pin":7},"destination":{"component":4,"pin":1},"wireId":14},{"source":{"component":0,"pin":8},"destination":{"component":4,"pin":2},"wireId":15},{"source":{"component":4,"pin":3},"destination":{"component":0,"pin":12},"wireId":16}]}');
setTimeout(function(){ wireVisuals = JSON.parse(
'[{"wireId":0,"path":[{"component":0,"pin":0,"shift":false,"rev":1},{"component":1,"pin":0,"shift":false,"offset":0}]},{"wireId":2,"path":[{"component":1,"pin":2,"shift":false,"rev":-1},{"component":0,"pin":8,"shift":false,"offset":14}]},{"wireId":3,"path":[{"component":0,"pin":4,"shift":false,"rev":1},{"component":1,"pin":1,"shift":false,"offset":28}]},{"wireId":4,"path":[{"component":0,"pin":1,"shift":false,"rev":1},{"component":2,"pin":0,"shift":false,"offset":7}]},{"wireId":5,"path":[{"component":0,"pin":5,"shift":false,"rev":1},{"component":2,"pin":1,"shift":false,"offset":35}]},{"wireId":6,"path":[{"component":1,"pin":3,"shift":false,"rev":1},{"component":0,"pin":9,"shift":false,"offset":0}]},{"wireId":7,"path":[{"component":2,"pin":3,"shift":false,"rev":1},{"component":0,"pin":10,"shift":false,"offset":0}]},{"wireId":8,"path":[{"component":3,"pin":3,"shift":false,"rev":1},{"component":0,"pin":11,"shift":false,"offset":0}]},{"wireId":9,"path":[{"component":2,"pin":2,"shift":false,"rev":-1},{"component":0,"pin":8,"shift":false,"offset":14}]},{"wireId":10,"path":[{"component":3,"pin":0,"shift":false,"rev":-1},{"component":0,"pin":2,"shift":false,"offset":0}]},{"wireId":11,"path":[{"component":0,"pin":6,"shift":false,"rev":1},{"component":3,"pin":1,"shift":false,"offset":42}]},{"wireId":12,"path":[{"component":3,"pin":2,"shift":false,"rev":-1},{"component":0,"pin":8,"shift":false,"offset":14}]},{"wireId":13,"path":[{"component":0,"pin":3,"shift":false,"rev":1},{"component":4,"pin":0,"shift":false,"offset":21}]},{"wireId":14,"path":[{"component":0,"pin":7,"shift":false,"rev":1},{"component":4,"pin":1,"shift":false,"offset":49}]},{"wireId":15,"path":[{"component":4,"pin":2,"shift":false,"rev":-1},{"component":0,"pin":8,"shift":false,"offset":14}]},{"wireId":16,"path":[{"component":4,"pin":3,"shift":false,"rev":1},{"component":0,"pin":12,"shift":false,"offset":0}]}]');
},50);
}

File diff suppressed because one or more lines are too long

7
build/editor/js/layouts/alu.js Executable file

File diff suppressed because one or more lines are too long

6
build/editor/js/layouts/and.js Executable file
View File

@ -0,0 +1,6 @@
function loadChip(){
chip = new Component("main",true,'{"type":"main","inputs":2,"pins":[0,0,0],"subComponents":["and"],"positions":[{"x":300,"y":178}],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":0},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1},"wireId":1},{"source":{"component":1,"pin":2},"destination":{"component":0,"pin":2},"wireId":2}]}');
setTimeout(function(){ wireVisuals = JSON.parse(
'[{"wireId":0,"path":[{"component":1,"pin":0,"shift":false,"rev":-1},{"component":0,"pin":0,"shift":false,"offset":0}]},{"wireId":1,"path":[{"component":0,"pin":1,"shift":false,"rev":1},{"component":1,"pin":1,"shift":false,"offset":7}]},{"wireId":2,"path":[{"component":1,"pin":2,"shift":false,"rev":1},{"component":0,"pin":2,"shift":false,"offset":0}]}]');
},50);
}

View File

@ -0,0 +1,6 @@
function loadChip(){
chip = new Component("main",true,'{"type":"main","inputs":6,"pins":[0,0,0,0,0,0,0,0,0,0,0],"subComponents":["not","and","xor","and","not","or","not"],"positions":[{"x":124,"y":232},{"x":272,"y":291},{"x":276,"y":163},{"x":689,"y":126},{"x":458,"y":354},{"x":405,"y":22},{"x":878,"y":82}],"wires":[{"source":{"component":0,"pin":2},"destination":{"component":1,"pin":0},"wireId":1},{"source":{"component":1,"pin":1},"destination":{"component":2,"pin":0},"wireId":7},{"source":{"component":2,"pin":2},"destination":{"component":0,"pin":10},"wireId":8},{"source":{"component":0,"pin":4},"destination":{"component":2,"pin":1},"wireId":9},{"source":{"component":1,"pin":1},"destination":{"component":3,"pin":1},"wireId":10},{"source":{"component":0,"pin":1},"destination":{"component":3,"pin":0},"wireId":11},{"source":{"component":3,"pin":2},"destination":{"component":0,"pin":9},"wireId":12},{"source":{"component":0,"pin":0},"destination":{"component":4,"pin":0},"wireId":13},{"source":{"component":0,"pin":5},"destination":{"component":5,"pin":0},"wireId":14},{"source":{"component":5,"pin":1},"destination":{"component":4,"pin":1},"wireId":15},{"source":{"component":4,"pin":2},"destination":{"component":0,"pin":8},"wireId":16},{"source":{"component":0,"pin":5},"destination":{"component":6,"pin":1},"wireId":17},{"source":{"component":0,"pin":3},"destination":{"component":6,"pin":0},"wireId":18},{"source":{"component":6,"pin":2},"destination":{"component":0,"pin":6},"wireId":19},{"source":{"component":4,"pin":2},"destination":{"component":7,"pin":0},"wireId":20},{"source":{"component":7,"pin":1},"destination":{"component":0,"pin":7},"wireId":21}]}');
setTimeout(function(){ wireVisuals = JSON.parse(
'[{"wireId":1,"path":[{"component":0,"pin":2,"shift":false,"rev":1},{"component":1,"pin":0,"shift":false,"offset":14}]},{"wireId":7,"path":[{"component":1,"pin":1,"shift":false,"rev":1},{"component":2,"pin":0,"shift":false,"offset":0}]},{"wireId":8,"path":[{"component":2,"pin":2,"shift":false,"rev":1},{"component":0,"pin":10,"shift":false,"offset":0}]},{"wireId":9,"path":[{"component":0,"pin":4,"shift":false,"rev":1},{"component":2,"pin":1,"shift":false,"offset":28}]},{"wireId":10,"path":[{"component":1,"pin":1,"shift":false,"rev":1},{"component":3,"pin":1,"shift":false,"offset":0}]},{"wireId":11,"path":[{"component":0,"pin":1,"shift":false,"rev":1},{"component":3,"pin":0,"shift":false,"offset":7}]},{"wireId":12,"path":[{"component":3,"pin":2,"shift":false,"rev":1},{"component":0,"pin":9,"shift":false,"offset":0}]},{"wireId":13,"path":[{"component":0,"pin":0,"shift":false,"rev":1},{"component":4,"pin":0,"shift":false,"offset":0}]},{"wireId":14,"path":[{"component":0,"pin":5,"shift":false,"rev":1},{"component":5,"pin":0,"shift":false,"offset":35}]},{"wireId":15,"path":[{"component":5,"pin":1,"shift":false,"rev":1},{"component":4,"pin":1,"shift":false,"offset":0}]},{"wireId":16,"path":[{"component":4,"pin":2,"shift":false,"rev":1},{"component":0,"pin":8,"shift":false,"offset":0}]},{"wireId":17,"path":[{"component":0,"pin":5,"shift":false,"rev":1},{"component":6,"pin":1,"shift":false,"offset":35}]},{"wireId":18,"path":[{"component":0,"pin":3,"shift":false,"rev":1},{"component":6,"pin":0,"shift":false,"offset":21}]},{"wireId":19,"path":[{"component":6,"pin":2,"shift":false,"rev":1},{"component":0,"pin":6,"shift":false,"offset":0}]},{"wireId":20,"path":[{"component":4,"pin":2,"shift":false,"rev":1},{"component":7,"pin":0,"shift":false,"offset":0}]},{"wireId":21,"path":[{"component":7,"pin":1,"shift":false,"rev":1},{"component":0,"pin":7,"shift":false,"offset":0}]}]');
},50);
}

View File

@ -0,0 +1,6 @@
function loadChip(){
chip = new Component("main",true,'{"type":"main","inputs":2,"pins":[0,0,0,0],"subComponents":[],"positions":[],"wires":[]}');
setTimeout(function(){ wireVisuals = JSON.parse(
'[]');
},50);
}

View File

@ -0,0 +1,8 @@
function loadChip(){
chips = JSON.parse('{"nand":{"image":"img/gates/nand.png","inputs":2,"pins":[0,0,0],"subComponents":[],"wires":[]},"not":{"image":"img/gates/not.png","inputs":1,"pins":[0,0],"subComponents":["nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":0,"pin":1}}]},"and":{"image":"img/gates/and.png","inputs":2,"pins":[0,0,0],"subComponents":["nand","nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":1}},{"source":{"component":2,"pin":2},"destination":{"component":0,"pin":2}}]},"or":{"image":"img/gates/or.png","inputs":2,"pins":[0,0,0],"subComponents":["nand","nand","nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":1}},{"source":{"component":0,"pin":1},"destination":{"component":2,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":2,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":3,"pin":0}},{"source":{"component":2,"pin":2},"destination":{"component":3,"pin":1}},{"source":{"component":3,"pin":2},"destination":{"component":0,"pin":2}}]},"xor":{"image":"img/gates/xor.png","inputs":2,"pins":[0,0,0],"subComponents":["nand","nand","nand","nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":0,"pin":0},"destination":{"component":2,"pin":0}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":3,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":3,"pin":1}},{"source":{"component":2,"pin":2},"destination":{"component":4,"pin":0}},{"source":{"component":3,"pin":2},"destination":{"component":4,"pin":1}},{"source":{"component":4,"pin":2},"destination":{"component":0,"pin":2}}]},"nor":{"inputs":2,"image":"img/gates/nor.png","pins":[0,0,0],"subComponents":["or","not"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0}},{"source":{"component":2,"pin":1},"destination":{"component":0,"pin":2}}]},"xnor":{"inputs":2,"image":"img/gates/xnor.png","pins":[0,0,0],"subComponents":["xor","not"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0}},{"source":{"component":2,"pin":1},"destination":{"component":0,"pin":2}}]},"half adder":{"type":"half adder","inputs":2,"pins":[0,0,0,0],"subComponents":["and","xor"],"positions":[{"x":413,"y":299},{"x":293,"y":132}],"wires":[{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1},"wireId":0},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":1},{"source":{"component":1,"pin":2},"destination":{"component":0,"pin":3},"wireId":2},{"source":{"component":0,"pin":1},"destination":{"component":2,"pin":1},"wireId":3},{"source":{"component":0,"pin":0},"destination":{"component":2,"pin":0},"wireId":4},{"source":{"component":2,"pin":2},"destination":{"component":0,"pin":2},"wireId":5}]}}');
chip = new Component("main",true,'{"type":"main","inputs":3,"pins":[0,0,0,0,0],"subComponents":["half adder","half adder","or"],"positions":[{"x":110,"y":127},{"x":403,"y":212},{"x":827,"y":287}],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":6},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1},"wireId":7},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0},"wireId":8},{"source":{"component":0,"pin":2},"destination":{"component":2,"pin":1},"wireId":9},{"source":{"component":2,"pin":2},"destination":{"component":0,"pin":3},"wireId":10},{"source":{"component":1,"pin":3},"destination":{"component":3,"pin":1},"wireId":12},{"source":{"component":2,"pin":3},"destination":{"component":3,"pin":0},"wireId":13},{"source":{"component":3,"pin":2},"destination":{"component":0,"pin":4},"wireId":14}]}');
setTimeout(function(){ wireVisuals = JSON.parse(
'[{"wireId":6,"path":[{"component":0,"pin":0,"shift":false,"rev":1},{"component":1,"pin":0,"shift":false,"offset":0}]},{"wireId":7,"path":[{"component":0,"pin":1,"shift":false,"rev":1},{"component":1,"pin":1,"shift":false,"offset":7}]},{"wireId":8,"path":[{"component":1,"pin":2,"shift":false,"rev":1},{"component":2,"pin":0,"shift":false,"offset":0}]},{"wireId":9,"path":[{"component":0,"pin":2,"shift":false,"rev":1},{"component":2,"pin":1,"shift":false,"offset":14}]},{"wireId":10,"path":[{"component":2,"pin":2,"shift":false,"rev":1},{"component":0,"pin":3,"shift":false,"offset":0}]},{"wireId":12,"path":[{"component":1,"pin":3,"shift":false,"rev":1},{"x":468.085227265954,"y":342.81534092128277,"shift":false,"offset":7},{"component":3,"pin":1,"shift":false,"offset":7}]},{"wireId":13,"path":[{"component":3,"pin":0,"shift":false,"rev":-1},{"component":2,"pin":3,"shift":false,"offset":0}]},{"wireId":14,"path":[{"component":3,"pin":2,"shift":false,"rev":1},{"component":0,"pin":4,"shift":false,"offset":0}]}]' );
},50);
}

6
build/editor/js/layouts/not.js Executable file
View File

@ -0,0 +1,6 @@
function loadChip(){
chip = new Component("main",true,'{"type":"main","inputs":1,"pins":[0,0],"subComponents":["not"],"positions":[{"x":300,"y":178}],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":0},{"source":{"component":1,"pin":1},"destination":{"component":0,"pin":1},"wireId":1}]}');
setTimeout(function(){ wireVisuals = JSON.parse(
'[{"wireId":0,"path":[{"component":1,"pin":0,"shift":false,"rev":-1},{"component":0,"pin":0,"shift":false,"offset":0}]},{"wireId":1,"path":[{"component":1,"pin":1,"shift":false,"rev":1},{"component":0,"pin":1,"shift":false,"offset":0}]}]');
},50);
}

6
build/editor/js/layouts/or.js Executable file
View File

@ -0,0 +1,6 @@
function loadChip(){
chip = new Component("main",true,'{"type":"main","inputs":2,"pins":[0,0,0],"subComponents":["or"],"positions":[{"x":300,"y":178}],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":0},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1},"wireId":1},{"source":{"component":1,"pin":2},"destination":{"component":0,"pin":2},"wireId":2}]}');
setTimeout(function(){ wireVisuals = JSON.parse(
'[{"wireId":0,"path":[{"component":1,"pin":0,"shift":false,"rev":-1},{"component":0,"pin":0,"shift":false,"offset":0}]},{"wireId":1,"path":[{"component":0,"pin":1,"shift":false,"rev":1},{"component":1,"pin":1,"shift":false,"offset":7}]},{"wireId":2,"path":[{"component":1,"pin":2,"shift":false,"rev":1},{"component":0,"pin":2,"shift":false,"offset":0}]}]');
},50);
}

7
build/editor/js/layouts/rca.js Executable file
View File

@ -0,0 +1,7 @@
function loadChip(){
chips = JSON.parse('{"nand":{"image":"img/gates/nand.png","inputs":2,"pins":[0,0,0],"subComponents":[],"wires":[]},"not":{"image":"img/gates/not.png","inputs":1,"pins":[0,0],"subComponents":["nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":0,"pin":1}}]},"and":{"image":"img/gates/and.png","inputs":2,"pins":[0,0,0],"subComponents":["nand","nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":1}},{"source":{"component":2,"pin":2},"destination":{"component":0,"pin":2}}]},"or":{"image":"img/gates/or.png","inputs":2,"pins":[0,0,0],"subComponents":["nand","nand","nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":1}},{"source":{"component":0,"pin":1},"destination":{"component":2,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":2,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":3,"pin":0}},{"source":{"component":2,"pin":2},"destination":{"component":3,"pin":1}},{"source":{"component":3,"pin":2},"destination":{"component":0,"pin":2}}]},"xor":{"image":"img/gates/xor.png","inputs":2,"pins":[0,0,0],"subComponents":["nand","nand","nand","nand"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":0,"pin":0},"destination":{"component":2,"pin":0}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":3,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":3,"pin":1}},{"source":{"component":2,"pin":2},"destination":{"component":4,"pin":0}},{"source":{"component":3,"pin":2},"destination":{"component":4,"pin":1}},{"source":{"component":4,"pin":2},"destination":{"component":0,"pin":2}}]},"nor":{"inputs":2,"image":"img/gates/nor.png","pins":[0,0,0],"subComponents":["or","not"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0}},{"source":{"component":2,"pin":1},"destination":{"component":0,"pin":2}}]},"xnor":{"inputs":2,"image":"img/gates/xnor.png","pins":[0,0,0],"subComponents":["xor","not"],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0}},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1}},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0}},{"source":{"component":2,"pin":1},"destination":{"component":0,"pin":2}}]},"half adder":{"type":"half adder","inputs":2,"pins":[0,0,0,0],"subComponents":["and","xor"],"positions":[{"x":413,"y":299},{"x":293,"y":132}],"wires":[{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1},"wireId":0},{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":1},{"source":{"component":1,"pin":2},"destination":{"component":0,"pin":3},"wireId":2},{"source":{"component":0,"pin":1},"destination":{"component":2,"pin":1},"wireId":3},{"source":{"component":0,"pin":0},"destination":{"component":2,"pin":0},"wireId":4},{"source":{"component":2,"pin":2},"destination":{"component":0,"pin":2},"wireId":5}]},"full adder":{"type":"full adder","inputs":3,"pins":[0,0,0,0,0],"subComponents":["half adder","half adder","or"],"positions":[{"x":110,"y":127},{"x":403,"y":212},{"x":827,"y":287}],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":6},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1},"wireId":7},{"source":{"component":1,"pin":2},"destination":{"component":2,"pin":0},"wireId":8},{"source":{"component":0,"pin":2},"destination":{"component":2,"pin":1},"wireId":9},{"source":{"component":2,"pin":2},"destination":{"component":0,"pin":3},"wireId":10},{"source":{"component":1,"pin":3},"destination":{"component":3,"pin":1},"wireId":12},{"source":{"component":2,"pin":3},"destination":{"component":3,"pin":0},"wireId":13},{"source":{"component":3,"pin":2},"destination":{"component":0,"pin":4},"wireId":14}]}}');
chip = new Component("main",true,'{"type":"main","inputs":9,"pins":[0,0,0,0,0,0,0,0,0,0,0,0,0,0],"subComponents":["full adder","full adder","full adder","full adder"],"positions":[{"x":157,"y":30},{"x":364,"y":150},{"x":546,"y":224},{"x":734,"y":300}],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":11},{"source":{"component":0,"pin":4},"destination":{"component":1,"pin":1},"wireId":12},{"source":{"component":0,"pin":8},"destination":{"component":1,"pin":2},"wireId":13},{"source":{"component":0,"pin":1},"destination":{"component":2,"pin":0},"wireId":18},{"source":{"component":1,"pin":4},"destination":{"component":2,"pin":2},"wireId":20},{"source":{"component":0,"pin":5},"destination":{"component":2,"pin":1},"wireId":21},{"source":{"component":1,"pin":3},"destination":{"component":0,"pin":9},"wireId":22},{"source":{"component":2,"pin":3},"destination":{"component":0,"pin":10},"wireId":25},{"source":{"component":2,"pin":4},"destination":{"component":3,"pin":2},"wireId":26},{"source":{"component":0,"pin":2},"destination":{"component":3,"pin":0},"wireId":27},{"source":{"component":0,"pin":6},"destination":{"component":3,"pin":1},"wireId":28},{"source":{"component":3,"pin":3},"destination":{"component":0,"pin":11},"wireId":29},{"source":{"component":3,"pin":4},"destination":{"component":4,"pin":2},"wireId":30},{"source":{"component":0,"pin":7},"destination":{"component":4,"pin":1},"wireId":31},{"source":{"component":0,"pin":3},"destination":{"component":4,"pin":0},"wireId":32},{"source":{"component":4,"pin":3},"destination":{"component":0,"pin":12},"wireId":33},{"source":{"component":4,"pin":4},"destination":{"component":0,"pin":13},"wireId":34}]}');
setTimeout(function(){ wireVisuals = JSON.parse(
'[{"wireId":11,"path":[{"component":0,"pin":0,"shift":false,"rev":1},{"component":1,"pin":0,"shift":false,"offset":0}]},{"wireId":12,"path":[{"component":0,"pin":4,"shift":false,"rev":1},{"component":1,"pin":1,"shift":false,"offset":28}]},{"wireId":13,"path":[{"component":0,"pin":8,"shift":false,"rev":1},{"component":1,"pin":2,"shift":false,"offset":56}]},{"wireId":18,"path":[{"component":2,"pin":0,"shift":false,"rev":-1},{"component":0,"pin":1,"shift":false,"offset":0}]},{"wireId":20,"path":[{"component":1,"pin":4,"shift":false,"rev":1},{"component":2,"pin":2,"shift":false,"offset":7}]},{"wireId":21,"path":[{"component":2,"pin":1,"shift":false,"rev":-1},{"component":0,"pin":5,"shift":false,"offset":7}]},{"wireId":22,"path":[{"component":1,"pin":3,"shift":false,"rev":1},{"component":0,"pin":9,"shift":false,"offset":0}]},{"wireId":25,"path":[{"component":2,"pin":3,"shift":false,"rev":1},{"component":0,"pin":10,"shift":false,"offset":0}]},{"wireId":26,"path":[{"component":2,"pin":4,"shift":false,"rev":1},{"component":3,"pin":2,"shift":false,"offset":7}]},{"wireId":27,"path":[{"component":0,"pin":2,"shift":false,"rev":1},{"component":3,"pin":0,"shift":false,"offset":14}]},{"wireId":28,"path":[{"component":0,"pin":6,"shift":false,"rev":1},{"component":3,"pin":1,"shift":false,"offset":42}]},{"wireId":29,"path":[{"component":3,"pin":3,"shift":false,"rev":1},{"component":0,"pin":11,"shift":false,"offset":0}]},{"wireId":30,"path":[{"component":3,"pin":4,"shift":false,"rev":1},{"component":4,"pin":2,"shift":false,"offset":7}]},{"wireId":31,"path":[{"component":0,"pin":7,"shift":false,"rev":1},{"component":4,"pin":1,"shift":false,"offset":49}]},{"wireId":32,"path":[{"component":0,"pin":3,"shift":false,"rev":1},{"component":4,"pin":0,"shift":false,"offset":21}]},{"wireId":33,"path":[{"component":4,"pin":3,"shift":false,"rev":1},{"component":0,"pin":12,"shift":false,"offset":0}]},{"wireId":34,"path":[{"component":4,"pin":4,"shift":false,"rev":1},{"component":0,"pin":13,"shift":false,"offset":7}]}]');
},50);
}

7
build/editor/js/layouts/sub.js Executable file

File diff suppressed because one or more lines are too long

6
build/editor/js/layouts/xor.js Executable file
View File

@ -0,0 +1,6 @@
function loadChip(){
chip = new Component("main",true,'{"type":"main","inputs":2,"pins":[0,0,0],"subComponents":["xor"],"positions":[{"x":300,"y":178}],"wires":[{"source":{"component":0,"pin":0},"destination":{"component":1,"pin":0},"wireId":0},{"source":{"component":0,"pin":1},"destination":{"component":1,"pin":1},"wireId":1},{"source":{"component":1,"pin":2},"destination":{"component":0,"pin":2},"wireId":2}]}');
setTimeout(function(){ wireVisuals = JSON.parse(
'[{"wireId":0,"path":[{"component":1,"pin":0,"shift":false,"rev":-1},{"component":0,"pin":0,"shift":false,"offset":0}]},{"wireId":1,"path":[{"component":0,"pin":1,"shift":false,"rev":1},{"component":1,"pin":1,"shift":false,"offset":7}]},{"wireId":2,"path":[{"component":1,"pin":2,"shift":false,"rev":1},{"component":0,"pin":2,"shift":false,"offset":0}]}]');
},50);
}

171
build/editor/js/md5.js Executable file
View File

@ -0,0 +1,171 @@
function md5 ( str ) {
var RotateLeft = function(lValue, iShiftBits) {
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
};
var AddUnsigned = function(lX,lY) {
var lX4,lY4,lX8,lY8,lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
lX4 = (lX & 0x40000000);
lY4 = (lY & 0x40000000);
lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
if (lX4 & lY4) {
return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
}
if (lX4 | lY4) {
if (lResult & 0x40000000) {
return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
} else {
return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
}
} else {
return (lResult ^ lX8 ^ lY8);
}
};
var F = function(x,y,z) { return (x & y) | ((~x) & z); };
var G = function(x,y,z) { return (x & z) | (y & (~z)); };
var H = function(x,y,z) { return (x ^ y ^ z); };
var I = function(x,y,z) { return (y ^ (x | (~z))); };
var FF = function(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
var GG = function(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
var HH = function(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
var II = function(a,b,c,d,x,s,ac) {
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
return AddUnsigned(RotateLeft(a, s), b);
};
var ConvertToWordArray = function(str) {
var lWordCount;
var lMessageLength = str.length;
var lNumberOfWords_temp1=lMessageLength + 8;
var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
var lWordArray=Array(lNumberOfWords-1);
var lBytePosition = 0;
var lByteCount = 0;
while ( lByteCount < lMessageLength ) {
lWordCount = (lByteCount-(lByteCount % 4))/4;
lBytePosition = (lByteCount % 4)*8;
lWordArray[lWordCount] = (lWordArray[lWordCount] | (str.charCodeAt(lByteCount)<<lBytePosition));
lByteCount++;
}
lWordCount = (lByteCount-(lByteCount % 4))/4;
lBytePosition = (lByteCount % 4)*8;
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
lWordArray[lNumberOfWords-2] = lMessageLength<<3;
lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
return lWordArray;
};
var WordToHex = function(lValue) {
var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
for (lCount = 0;lCount<=3;lCount++) {
lByte = (lValue>>>(lCount*8)) & 255;
WordToHexValue_temp = "0" + lByte.toString(16);
WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
}
return WordToHexValue;
};
var x=Array();
var k,AA,BB,CC,DD,a,b,c,d;
var S11=7, S12=12, S13=17, S14=22;
var S21=5, S22=9 , S23=14, S24=20;
var S31=4, S32=11, S33=16, S34=23;
var S41=6, S42=10, S43=15, S44=21;
x = ConvertToWordArray(str);
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
for (k=0;k<x.length;k+=16) {
AA=a; BB=b; CC=c; DD=d;
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
a=AddUnsigned(a,AA);
b=AddUnsigned(b,BB);
c=AddUnsigned(c,CC);
d=AddUnsigned(d,DD);
}
var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
return temp.toLowerCase();
}

3
build/editor/js/test.c Executable file
View File

@ -0,0 +1,3 @@
// this is a haiku
#include<stdio.h>
printf("hello world");

BIN
build/img/._flags_diagram.png Executable file

Binary file not shown.

BIN
build/img/._flags_diagram.psd Executable file

Binary file not shown.

BIN
build/img/flags_diagram.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
build/img/flags_diagram.psd Executable file

Binary file not shown.

20
build/js/page.js Executable file
View File

@ -0,0 +1,20 @@
window.addEventListener('load',e=>{
for(var c = document.getElementsByTagName("a"), a = 0;a < c.length;a++) {
var b = c[a];
((b.getAttribute("href") && b.hostname !== location.hostname) || (b.getAttribute("data-newtab")==true)) && (b.target = "_blank")
}
for(var c=document.getElementsByTagName("ol"), a=0; a<c.length;a++) {
var b = c[a];
if(b.getAttribute("data-bin")){
Array.from(b.children).forEach((child,i)=>{
if(!child.getAttribute("data-before"))
child.setAttribute("data-before", pad(i.toString(2), Math.log2(b.children.length)));
});
}
}
});
function pad(num, size) {
var s = "000000000" + num;
return s.substr(s.length-size);
}

28
build/multiplexer/index.html Executable file
View File

@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<title>Build a multiplexer</title>
<link rel="stylesheet" type="text/css" href="../css/style.css" />
<script type="text/javascript" src="../js/page.js"></script>
</head>
<body>
<h1>Build a multiplexer!</h1>
<p>
The multiplexer chip used in this CPU is a <b>16:8</b> mux - this means it can select between <i>two</i> <b>8-bit</b> inputs.</p><p>
Don't worry, this is an extremely simple chip to construct. To start with, you must build from logic gates a <b>2:1</b> mux which can switch between two individual bits. Then you can use 8 of these <b>2:1</b> muxes to build this chip.
</p>
<!--<p>
You will also need a <i>demultiplexer</i> for later use. This chip, instead of choosing between inputs, takes a fixed input and instead selects between multiple <i>outputs</i>.
</p>-->
<h3>Start building</h3>
<ol>
<li><a data-newtab=1 href="/cpu/build/editor/?item=mux1">construct <b>2:1 mux</b></a></li>
<li><a data-newtab=1 href="/cpu/build/editor/?item=mux2">assemble <b>16:8 mux</b></a></li>
<!--<li><a data-newtab=1 href="/cpu/build/editor/?item=mux3">construct <b>1:2 <i>demux</i></b></a></li>
<li><a data-newtab=1 href="/cpu/build/editor/?item=mux4">assemble <b>1:8 <i>demux</i></b></a></li>-->
</ol>
<p>
Once you are finished, you can <a href="/cpu/">return to the CPU</a>.
</p>
</body>
</html>

23
build/registers/index.html Executable file
View File

@ -0,0 +1,23 @@
<!doctype html>
<html>
<head>
<title>Build a multiplexer</title>
<link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>
<body>
<h1>Build a multiplexer!</h1>
<p>
The multiplexer chip used in this CPU is a <b>16:8</b> mux - this means it can select between <i>two</i> <b>8-bit</b> inputs.
<br>
Don't worry, this is an extremely simple chip to construct. To start with, you must build from logic gates a <b>2:1</b> mux which can switch between two individual bits. Then you can use 8 of these <b>2:1</b> muxes to build this chip.
</p>
<h3>Start building</h3>
<ol>
<li><a href="1/">construct <b>2:1 mux</a></b></li>
<li><a href="2/">assemble <b>16:8 mux</a></b></li>
</ol>
<p>
Once you are finished, you can <a href="/cpu/">return to the CPU</a>.
</p>
</body>
</html>

3
cheat/index.html Executable file
View File

@ -0,0 +1,3 @@
<script>
fetch('/cpu/WORKING_SETUP.json').then(res=>res.text()).then(data=>{localStorage.setItem('chipsbackup',localStorage.getItem('chips'));localStorage.setItem('chips',data)}).then(alert('loaded pre-made components! taking you back')).then(window.location.href='/cpu/');
</script>

5
css/generator_config.txt Executable file
View File

@ -0,0 +1,5 @@
# Font Squirrel Font-face Generator Configuration File
# Upload this file to the generator to recreate the settings
# you used to create these fonts.
{"mode":"optimal","formats":["woff","woff2"],"tt_instructor":"default","fix_gasp":"xy","fix_vertical_metrics":"Y","metrics_ascent":"","metrics_descent":"","metrics_linegap":"","add_spaces":"Y","add_hyphens":"Y","fallback":"none","fallback_custom":"100","options_subset":"basic","subset_custom":"","subset_custom_range":"","subset_ot_features_list":"","css_stylesheet":"stylesheet.css","filename_suffix":"-webfont","emsquare":"2048","spacing_adjustment":"0"}

View File

@ -0,0 +1,129 @@
/*Notes about grid:
Columns: 12
Grid Width: 825px
Column Width: 55px
Gutter Width: 15px
-------------------------------*/
.section {margin-bottom: 18px;
}
.section:after {content: ".";display: block;height: 0;clear: both;visibility: hidden;}
.section {*zoom: 1;}
.section .firstcolumn,
.section .firstcol {margin-left: 0;}
/* Border on left hand side of a column. */
.border {
padding-left: 7px;
margin-left: 7px;
border-left: 1px solid #eee;
}
/* Border with more whitespace, spans one column. */
.colborder {
padding-left: 42px;
margin-left: 42px;
border-left: 1px solid #eee;
}
/* The Grid Classes */
.grid1, .grid1_2cols, .grid1_3cols, .grid1_4cols, .grid2, .grid2_3cols, .grid2_4cols, .grid3, .grid3_2cols, .grid3_4cols, .grid4, .grid4_3cols, .grid5, .grid5_2cols, .grid5_3cols, .grid5_4cols, .grid6, .grid6_4cols, .grid7, .grid7_2cols, .grid7_3cols, .grid7_4cols, .grid8, .grid8_3cols, .grid9, .grid9_2cols, .grid9_4cols, .grid10, .grid10_3cols, .grid10_4cols, .grid11, .grid11_2cols, .grid11_3cols, .grid11_4cols, .grid12
{margin-left: 15px;float: left;display: inline; overflow: hidden;}
.width1, .grid1, .span-1 {width: 55px;}
.width1_2cols,.grid1_2cols {width: 20px;}
.width1_3cols,.grid1_3cols {width: 8px;}
.width1_4cols,.grid1_4cols {width: 2px;}
.input_width1 {width: 49px;}
.width2, .grid2, .span-2 {width: 125px;}
.width2_3cols,.grid2_3cols {width: 31px;}
.width2_4cols,.grid2_4cols {width: 20px;}
.input_width2 {width: 119px;}
.width3, .grid3, .span-3 {width: 195px;}
.width3_2cols,.grid3_2cols {width: 90px;}
.width3_4cols,.grid3_4cols {width: 37px;}
.input_width3 {width: 189px;}
.width4, .grid4, .span-4 {width: 265px;}
.width4_3cols,.grid4_3cols {width: 78px;}
.input_width4 {width: 259px;}
.width5, .grid5, .span-5 {width: 335px;}
.width5_2cols,.grid5_2cols {width: 160px;}
.width5_3cols,.grid5_3cols {width: 101px;}
.width5_4cols,.grid5_4cols {width: 72px;}
.input_width5 {width: 329px;}
.width6, .grid6, .span-6 {width: 405px;}
.width6_4cols,.grid6_4cols {width: 90px;}
.input_width6 {width: 399px;}
.width7, .grid7, .span-7 {width: 475px;}
.width7_2cols,.grid7_2cols {width: 230px;}
.width7_3cols,.grid7_3cols {width: 148px;}
.width7_4cols,.grid7_4cols {width: 107px;}
.input_width7 {width: 469px;}
.width8, .grid8, .span-8 {width: 545px;}
.width8_3cols,.grid8_3cols {width: 171px;}
.input_width8 {width: 539px;}
.width9, .grid9, .span-9 {width: 615px;}
.width9_2cols,.grid9_2cols {width: 300px;}
.width9_4cols,.grid9_4cols {width: 142px;}
.input_width9 {width: 609px;}
.width10, .grid10, .span-10 {width: 685px;}
.width10_3cols,.grid10_3cols {width: 218px;}
.width10_4cols,.grid10_4cols {width: 160px;}
.input_width10 {width: 679px;}
.width11, .grid11, .span-11 {width: 755px;}
.width11_2cols,.grid11_2cols {width: 370px;}
.width11_3cols,.grid11_3cols {width: 241px;}
.width11_4cols,.grid11_4cols {width: 177px;}
.input_width11 {width: 749px;}
.width12, .grid12, .span-12 {width: 825px;}
.input_width12 {width: 819px;}
/* Subdivided grid spaces */
.emptycols_left1, .prepend-1 {padding-left: 70px;}
.emptycols_right1, .append-1 {padding-right: 70px;}
.emptycols_left2, .prepend-2 {padding-left: 140px;}
.emptycols_right2, .append-2 {padding-right: 140px;}
.emptycols_left3, .prepend-3 {padding-left: 210px;}
.emptycols_right3, .append-3 {padding-right: 210px;}
.emptycols_left4, .prepend-4 {padding-left: 280px;}
.emptycols_right4, .append-4 {padding-right: 280px;}
.emptycols_left5, .prepend-5 {padding-left: 350px;}
.emptycols_right5, .append-5 {padding-right: 350px;}
.emptycols_left6, .prepend-6 {padding-left: 420px;}
.emptycols_right6, .append-6 {padding-right: 420px;}
.emptycols_left7, .prepend-7 {padding-left: 490px;}
.emptycols_right7, .append-7 {padding-right: 490px;}
.emptycols_left8, .prepend-8 {padding-left: 560px;}
.emptycols_right8, .append-8 {padding-right: 560px;}
.emptycols_left9, .prepend-9 {padding-left: 630px;}
.emptycols_right9, .append-9 {padding-right: 630px;}
.emptycols_left10, .prepend-10 {padding-left: 700px;}
.emptycols_right10, .append-10 {padding-right: 700px;}
.emptycols_left11, .prepend-11 {padding-left: 770px;}
.emptycols_right11, .append-11 {padding-right: 770px;}
.pull-1 {margin-left: -70px;}
.push-1 {margin-right: -70px;margin-left: 18px;float: right;}
.pull-2 {margin-left: -140px;}
.push-2 {margin-right: -140px;margin-left: 18px;float: right;}
.pull-3 {margin-left: -210px;}
.push-3 {margin-right: -210px;margin-left: 18px;float: right;}
.pull-4 {margin-left: -280px;}
.push-4 {margin-right: -280px;margin-left: 18px;float: right;}

View File

@ -0,0 +1,396 @@
@import url('grid_12-825-55-15.css');
/*
CSS Reset by Eric Meyer - Released under Public Domain
http://meyerweb.com/eric/tools/css/reset/
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend, table,
caption, tbody, tfoot, thead, tr, th, td
{margin: 0;padding: 0;border: 0;outline: 0;
font-size: 100%;vertical-align: baseline;
background: transparent;}
body {line-height: 1;}
ol, ul {list-style: none;}
blockquote, q {quotes: none;}
blockquote:before, blockquote:after,
q:before, q:after {content: ''; content: none;}
:focus {outline: 0;}
ins {text-decoration: none;}
del {text-decoration: line-through;}
table {border-collapse: collapse;border-spacing: 0;}
body {
color: #000;
background-color: #dcdcdc;
}
a {
text-decoration: none;
color: #1883ba;
}
h1{
font-size: 32px;
font-weight: normal;
font-style: normal;
margin-bottom: 18px;
}
h2{
font-size: 18px;
}
#container {
width: 865px;
margin: 0px auto;
}
#header {
padding: 20px;
font-size: 36px;
background-color: #000;
color: #fff;
}
#header span {
color: #666;
}
#main_content {
background-color: #fff;
padding: 60px 20px 20px;
}
#footer p {
margin: 0;
padding-top: 10px;
padding-bottom: 50px;
color: #333;
font: 10px Arial, sans-serif;
}
.tabs {
width: 100%;
height: 31px;
background-color: #444;
}
.tabs li {
float: left;
margin: 0;
overflow: hidden;
background-color: #444;
}
.tabs li a {
display: block;
color: #fff;
text-decoration: none;
font: bold 11px/11px 'Arial';
text-transform: uppercase;
padding: 10px 15px;
border-right: 1px solid #fff;
}
.tabs li a:hover {
background-color: #00b3ff;
}
.tabs li.active a {
color: #000;
background-color: #fff;
}
div.huge {
font-size: 300px;
line-height: 1em;
padding: 0;
letter-spacing: -.02em;
overflow: hidden;
}
div.glyph_range {
font-size: 72px;
line-height: 1.1em;
}
.size10{ font-size: 10px; }
.size11{ font-size: 11px; }
.size12{ font-size: 12px; }
.size13{ font-size: 13px; }
.size14{ font-size: 14px; }
.size16{ font-size: 16px; }
.size18{ font-size: 18px; }
.size20{ font-size: 20px; }
.size24{ font-size: 24px; }
.size30{ font-size: 30px; }
.size36{ font-size: 36px; }
.size48{ font-size: 48px; }
.size60{ font-size: 60px; }
.size72{ font-size: 72px; }
.size90{ font-size: 90px; }
.psample_row1 { height: 120px;}
.psample_row1 { height: 120px;}
.psample_row2 { height: 160px;}
.psample_row3 { height: 160px;}
.psample_row4 { height: 160px;}
.psample {
overflow: hidden;
position: relative;
}
.psample p {
line-height: 1.3em;
display: block;
overflow: hidden;
margin: 0;
}
.psample span {
margin-right: .5em;
}
.white_blend {
width: 100%;
height: 61px;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVkAAAA9CAYAAAAH4BojAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAO1JREFUeNrs3TsKgFAMRUE/eer+NxztxMYuEWQG3ECKwwUF58ycAKixOAGAyAKILAAiCyCyACILgMgCiCyAyAIgsgAiCyCyAIgsgMgCiCwAIgsgsgAiC4DIAogsACIL0CWuZ3UGgLrIhjMA1EV2OAOAJQtgyQLwjOzmDAAiCyCyAIgsQFtkd2cAEFkAkQVAZAHaIns4A4AlC2DJAiCyACILILIAiCzAV5H1dQGAJQsgsgCILIDIAvwisl58AViyAJYsACILILIAIgvAe2T9EhxAZAFEFgCRBeiL7HAGgLrIhjMAWLIAliwAt1OAAQDwygTBulLIlQAAAABJRU5ErkJggg==);
position: absolute;
bottom: 0;
}
.black_blend {
width: 100%;
height: 61px;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVkAAAA9CAYAAAAH4BojAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPJJREFUeNrs3TEKhTAQRVGjibr/9QoxhY2N3Ywo50A28IrLwP9g6b1PAMSYTQAgsgAiC4DIAogsgMgCILIAIgsgsgCILIDIAogsACILILIAIguAyAKILIDIAiCyACILgMgCZCnjLWYAiFGvB0BQZJsZAFyyAC5ZAO6RXc0AILIAIguAyAKkRXYzA4DIAogsACILkBbZ3QwALlkAlywAIgsgsgAiC4DIArwVWf8uAHDJAogsACILILIAv4isH74AXLIALlkARBZAZAFEFoDnyPokOIDIAogsACILkBfZZgaAuMhWMwC4ZAE+p4x3mAEgxinAAJ+XBbPWGkwAAAAAAElFTkSuQmCC);
position: absolute;
bottom: 0;
}
.fullreverse {
background: #000 !important;
color: #fff !important;
margin-left: -20px;
padding-left: 20px;
margin-right: -20px;
padding-right: 20px;
padding: 20px;
margin-bottom:0;
}
.sample_table td {
padding-top: 3px;
padding-bottom:5px;
padding-left: 5px;
vertical-align: middle;
line-height: 1.2em;
}
.sample_table td:first-child {
background-color: #eee;
text-align: right;
padding-right: 5px;
padding-left: 0;
padding: 5px;
font: 11px/12px "Courier New", Courier, mono;
}
code {
white-space: pre;
background-color: #eee;
display: block;
padding: 10px;
margin-bottom: 18px;
overflow: auto;
}
.bottom,.last {margin-bottom:0 !important; padding-bottom:0 !important;}
.box {
padding: 18px;
margin-bottom: 18px;
background: #eee;
}
.reverse,.reversed { background: #000 !important;color: #fff !important; border: none !important;}
#bodycomparison {
position: relative;
overflow: hidden;
font-size: 72px;
height: 90px;
white-space: nowrap;
}
#bodycomparison div{
font-size: 72px;
line-height: 90px;
display: inline;
margin: 0 15px 0 0;
padding: 0;
}
#bodycomparison div span{
font: 10px Arial;
position: absolute;
left: 0;
}
#xheight {
float: none;
position: absolute;
color: #d9f3ff;
font-size: 72px;
line-height: 90px;
}
.fontbody {
position: relative;
}
.arialbody{
font-family: Arial;
position: relative;
}
.verdanabody{
font-family: Verdana;
position: relative;
}
.georgiabody{
font-family: Georgia;
position: relative;
}
/* @group Layout page
*/
#layout h1 {
font-size: 36px;
line-height: 42px;
font-weight: normal;
font-style: normal;
}
#layout h2 {
font-size: 24px;
line-height: 23px;
font-weight: normal;
font-style: normal;
}
#layout h3 {
font-size: 22px;
line-height: 1.4em;
margin-top: 1em;
font-weight: normal;
font-style: normal;
}
#layout p.byline {
font-size: 12px;
margin-top: 18px;
line-height: 12px;
margin-bottom: 0;
}
#layout p {
font-size: 14px;
line-height: 21px;
margin-bottom: .5em;
}
#layout p.large{
font-size: 18px;
line-height: 26px;
}
#layout .sidebar p{
font-size: 12px;
line-height: 1.4em;
}
#layout p.caption {
font-size: 10px;
margin-top: -16px;
margin-bottom: 18px;
}
/* @end */
/* @group Glyphs */
#glyph_chart div{
background-color: #d9f3ff;
color: black;
float: left;
font-size: 36px;
height: 1.2em;
line-height: 1.2em;
margin-bottom: 1px;
margin-right: 1px;
text-align: center;
width: 1.2em;
position: relative;
padding: .6em .2em .2em;
}
#glyph_chart div p {
position: absolute;
left: 0;
top: 0;
display: block;
text-align: center;
font: bold 9px Arial, sans-serif;
background-color: #3a768f;
width: 100%;
color: #fff;
padding: 2px 0;
}
#glyphs h1 {
font-family: Arial, sans-serif;
}
/* @end */
/* @group Installing */
#installing {
font: 13px Arial, sans-serif;
}
#installing p,
#glyphs p{
line-height: 1.2em;
margin-bottom: 18px;
font: 13px Arial, sans-serif;
}
#installing h3{
font-size: 15px;
margin-top: 18px;
}
/* @end */
#rendering h1 {
font-family: Arial, sans-serif;
}
.render_table td {
font: 11px "Courier New", Courier, mono;
vertical-align: middle;
}

87
css/style.css Executable file
View File

@ -0,0 +1,87 @@
* {
margin:0;
}
body,html{
color:#5be55b;
background-color:#191a1d;
width:100vw;
height:100vh;
display: flex;
flex-direction:column;
flex-wrap:wrap;
align-content:flex-start;
font-family:vcr_osd_monoregular;
}
canvas {
width:75vw;
height:100vh;
background-color:#36393E;
}
.center_holder{
margin-left:-10px;
margin-right:-10px;
width:100%;
display:flex;
justify-content:center;
}
.right_holder{
width:100%;
display: flex;
justify-content:right;
}
#compile{
margin-top:5px;
margin-right:25px;
}
#program{
width:90%;
height:20vh;
}
#sidebar{
padding-left:10px;
padding-top:10px;
padding-right:10px;
padding-bottom:10px;
width:25vw;
height:100vh;
}
#memory{
margin-top:5px;
/*font-size:13px;
line-height:15px;
*/
font-size: 0.65vw;
line-height:0.7vw;
color:#AAA;
}
#memory .written {
color: #FFF;
}
#memory tr td {
border-left: 1px solid #AAA;
border-bottom: 1px solid #AAA;
}
.label {
color: #5be55b;
border-left: none !important;
}
textarea::before{
background-color:grey;
display:block;
content:'';
position:absolute;
height:20vh;
width:90%;
}
textarea {
color: white;
background-color: grey;
background: url(http://i.imgur.com/2cOaJ.png);
background-attachment: local;
background-repeat: no-repeat;
padding-left: 35px;
padding-top: 10px;
font-size:13px;
line-height:16px;
border-color:#ccc;
}

12
css/stylesheet.css Executable file
View File

@ -0,0 +1,12 @@
/*! Generated by Font Squirrel (https://www.fontsquirrel.com) on February 20, 2022 */
@font-face {
font-family: 'vcr_osd_monoregular';
src: url('vcr_osd_mono_1.001-webfont.woff2') format('woff2'),
url('vcr_osd_mono_1.001-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}

602
css/vcr_osd_mono_1.001-demo.html Executable file
View File

@ -0,0 +1,602 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
(function($){$.fn.easyTabs=function(option){var param=jQuery.extend({fadeSpeed:"fast",defaultContent:1,activeClass:'active'},option);$(this).each(function(){var thisId="#"+this.id;if(param.defaultContent==''){param.defaultContent=1;}
if(typeof param.defaultContent=="number")
{var defaultTab=$(thisId+" .tabs li:eq("+(param.defaultContent-1)+") a").attr('href').substr(1);}else{var defaultTab=param.defaultContent;}
$(thisId+" .tabs li a").each(function(){var tabToHide=$(this).attr('href').substr(1);$("#"+tabToHide).addClass('easytabs-tab-content');});hideAll();changeContent(defaultTab);function hideAll(){$(thisId+" .easytabs-tab-content").hide();}
function changeContent(tabId){hideAll();$(thisId+" .tabs li").removeClass(param.activeClass);$(thisId+" .tabs li a[href=#"+tabId+"]").closest('li').addClass(param.activeClass);if(param.fadeSpeed!="none")
{$(thisId+" #"+tabId).fadeIn(param.fadeSpeed);}else{$(thisId+" #"+tabId).show();}}
$(thisId+" .tabs li").click(function(){var tabId=$(this).find('a').attr('href').substr(1);changeContent(tabId);return false;});});}})(jQuery);
</script>
<link rel="stylesheet" href="specimen_files/specimen_stylesheet.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" />
<style type="text/css">
body{
font-family: 'vcr_osd_monoregular';
}
</style>
<title>VCR OSD Mono Regular Specimen</title>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#container').easyTabs({defaultContent:1});
});
</script>
</head>
<body>
<div id="container">
<div id="header">
VCR OSD Mono Regular </div>
<ul class="tabs">
<li><a href="#specimen">Specimen</a></li>
<li><a href="#layout">Sample Layout</a></li>
<li><a href="#glyphs">Glyphs &amp; Languages</a></li>
<li><a href="#installing">Installing Webfonts</a></li>
</ul>
<div id="main_content">
<div id="specimen">
<div class="section">
<div class="grid12 firstcol">
<div class="huge">AaBb</div>
</div>
</div>
<div class="section">
<div class="glyph_range">A&#x200B;B&#x200b;C&#x200b;D&#x200b;E&#x200b;F&#x200b;G&#x200b;H&#x200b;I&#x200b;J&#x200b;K&#x200b;L&#x200b;M&#x200b;N&#x200b;O&#x200b;P&#x200b;Q&#x200b;R&#x200b;S&#x200b;T&#x200b;U&#x200b;V&#x200b;W&#x200b;X&#x200b;Y&#x200b;Z&#x200b;a&#x200b;b&#x200b;c&#x200b;d&#x200b;e&#x200b;f&#x200b;g&#x200b;h&#x200b;i&#x200b;j&#x200b;k&#x200b;l&#x200b;m&#x200b;n&#x200b;o&#x200b;p&#x200b;q&#x200b;r&#x200b;s&#x200b;t&#x200b;u&#x200b;v&#x200b;w&#x200b;x&#x200b;y&#x200b;z&#x200b;1&#x200b;2&#x200b;3&#x200b;4&#x200b;5&#x200b;6&#x200b;7&#x200b;8&#x200b;9&#x200b;0&#x200b;&amp;&#x200b;.&#x200b;,&#x200b;?&#x200b;!&#x200b;&#64;&#x200b;(&#x200b;)&#x200b;#&#x200b;$&#x200b;%&#x200b;*&#x200b;+&#x200b;-&#x200b;=&#x200b;:&#x200b;;</div>
</div>
<div class="section">
<div class="grid12 firstcol">
<table class="sample_table">
<tr><td>10</td><td class="size10">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>11</td><td class="size11">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>12</td><td class="size12">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>13</td><td class="size13">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>14</td><td class="size14">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>16</td><td class="size16">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>18</td><td class="size18">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>20</td><td class="size20">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>24</td><td class="size24">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>30</td><td class="size30">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>36</td><td class="size36">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>48</td><td class="size48">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>60</td><td class="size60">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>72</td><td class="size72">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
<tr><td>90</td><td class="size90">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</td></tr>
</table>
</div>
</div>
<div class="section" id="bodycomparison">
<div id="xheight">
<div class="fontbody">&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;&#x25FC;body</div><div class="arialbody">body</div><div class="verdanabody">body</div><div class="georgiabody">body</div></div>
<div class="fontbody" style="z-index:1">
body<span>VCR OSD Mono Regular</span>
</div>
<div class="arialbody" style="z-index:1">
body<span>Arial</span>
</div>
<div class="verdanabody" style="z-index:1">
body<span>Verdana</span>
</div>
<div class="georgiabody" style="z-index:1">
body<span>Georgia</span>
</div>
</div>
<div class="section psample psample_row1" id="">
<div class="grid2 firstcol">
<p class="size10"><span>10.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size11"><span>11.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size12"><span>12.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size13"><span>13.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row2" id="">
<div class="grid3 firstcol">
<p class="size14"><span>14.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size16"><span>16.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid5">
<p class="size18"><span>18.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row3" id="">
<div class="grid5 firstcol">
<p class="size20"><span>20.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid7">
<p class="size24"><span>24.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row4" id="">
<div class="grid12 firstcol">
<p class="size30"><span>30.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="white_blend"></div>
</div>
<div class="section psample psample_row1 fullreverse">
<div class="grid2 firstcol">
<p class="size10"><span>10.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size11"><span>11.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid3">
<p class="size12"><span>12.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size13"><span>13.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
<div class="section psample psample_row2 fullreverse">
<div class="grid3 firstcol">
<p class="size14"><span>14.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid4">
<p class="size16"><span>16.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid5">
<p class="size18"><span>18.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
<div class="section psample fullreverse psample_row3" id="">
<div class="grid5 firstcol">
<p class="size20"><span>20.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="grid7">
<p class="size24"><span>24.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
<div class="section psample fullreverse psample_row4" id="" style="border-bottom: 20px #000 solid;">
<div class="grid12 firstcol">
<p class="size30"><span>30.</span>Aenean lacinia bibendum nulla sed consectetur. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae elit libero, a pharetra augue.</p>
</div>
<div class="black_blend"></div>
</div>
</div>
<div id="layout">
<div class="section">
<div class="grid12 firstcol">
<h1>Lorem Ipsum Dolor</h1>
<h2>Etiam porta sem malesuada magna mollis euismod</h2>
<p class="byline">By <a href="#link">Aenean Lacinia</a></p>
</div>
</div>
<div class="section">
<div class="grid8 firstcol">
<p class="large">Donec sed odio dui. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. </p>
<h3>Pellentesque ornare sem</h3>
<p>Maecenas sed diam eget risus varius blandit sit amet non magna. Maecenas faucibus mollis interdum. Donec ullamcorper nulla non metus auctor fringilla. Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam id dolor id nibh ultricies vehicula ut id elit. </p>
<p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. </p>
<p>Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Aenean lacinia bibendum nulla sed consectetur. </p>
<p>Nullam quis risus eget urna mollis ornare vel eu leo. Nullam quis risus eget urna mollis ornare vel eu leo. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec ullamcorper nulla non metus auctor fringilla. </p>
<h3>Cras mattis consectetur</h3>
<p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Cras mattis consectetur purus sit amet fermentum. </p>
<p>Nullam id dolor id nibh ultricies vehicula ut id elit. Nullam quis risus eget urna mollis ornare vel eu leo. Cras mattis consectetur purus sit amet fermentum.</p>
</div>
<div class="grid4 sidebar">
<div class="box reverse">
<p class="last">Nullam quis risus eget urna mollis ornare vel eu leo. Donec ullamcorper nulla non metus auctor fringilla. Cras mattis consectetur purus sit amet fermentum. Sed posuere consectetur est at lobortis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p>
</div>
<p class="caption">Maecenas sed diam eget risus varius.</p>
<p>Vestibulum id ligula porta felis euismod semper. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Sed posuere consectetur est at lobortis. Maecenas sed diam eget risus varius blandit sit amet non magna. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. </p>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean lacinia bibendum nulla sed consectetur. Nullam quis risus eget urna mollis ornare vel eu leo. </p>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec ullamcorper nulla non metus auctor fringilla. Maecenas faucibus mollis interdum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. </p>
</div>
</div>
</div>
<div id="glyphs">
<div class="section">
<div class="grid12 firstcol">
<h1>Language Support</h1>
<p>The subset of VCR OSD Mono Regular in this kit supports the following languages:<br />
Albanian, Basque, Breton, Chamorro, Danish, English, Faroese, Finnish, Frisian, Galician, German, Icelandic, Italian, Malagasy, Norwegian, Portuguese, Spanish, Alsatian, Aragonese, Arapaho, Arrernte, Asturian, Aymara, Bislama, Cebuano, Corsican, Fijian, French_creole, Genoese, Gilbertese, Greenlandic, Haitian_creole, Hiligaynon, Hmong, Hopi, Ibanag, Iloko_ilokano, Indonesian, Interglossa_glosa, Interlingua, Irish_gaelic, Jerriais, Lojban, Lombard, Luxembourgeois, Manx, Mohawk, Norfolk_pitcairnese, Occitan, Oromo, Pangasinan, Papiamento, Piedmontese, Potawatomi, Rhaeto-romance, Romansh, Rotokas, Sami_lule, Sardinian, Scots_gaelic, Seychelles_creole, Shona, Sicilian, Somali, Southern_ndebele, Swahili, Swati_swazi, Tagalog_filipino_pilipino, Tetum, Tok_pisin, Uyghur_latinized, Volapuk, Walloon, Warlpiri, Xhosa, Yapese, Zulu, Latinbasic, Ubasic, Demo </p>
<h1>Glyph Chart</h1>
<p>The subset of VCR OSD Mono Regular in this kit includes all the glyphs listed below. Unicode entities are included above each glyph to help you insert individual characters into your layout.</p>
<div id="glyph_chart">
<div><p>&amp;#29;</p>&#29;</div>
<div><p>&amp;#13;</p>&#13;</div>
<div><p>&amp;#29;</p>&#29;</div>
<div><p>&amp;#32;</p>&#32;</div>
<div><p>&amp;#33;</p>&#33;</div>
<div><p>&amp;#34;</p>&#34;</div>
<div><p>&amp;#35;</p>&#35;</div>
<div><p>&amp;#36;</p>&#36;</div>
<div><p>&amp;#37;</p>&#37;</div>
<div><p>&amp;#38;</p>&#38;</div>
<div><p>&amp;#39;</p>&#39;</div>
<div><p>&amp;#40;</p>&#40;</div>
<div><p>&amp;#41;</p>&#41;</div>
<div><p>&amp;#42;</p>&#42;</div>
<div><p>&amp;#43;</p>&#43;</div>
<div><p>&amp;#44;</p>&#44;</div>
<div><p>&amp;#45;</p>&#45;</div>
<div><p>&amp;#46;</p>&#46;</div>
<div><p>&amp;#47;</p>&#47;</div>
<div><p>&amp;#48;</p>&#48;</div>
<div><p>&amp;#49;</p>&#49;</div>
<div><p>&amp;#50;</p>&#50;</div>
<div><p>&amp;#51;</p>&#51;</div>
<div><p>&amp;#52;</p>&#52;</div>
<div><p>&amp;#53;</p>&#53;</div>
<div><p>&amp;#54;</p>&#54;</div>
<div><p>&amp;#55;</p>&#55;</div>
<div><p>&amp;#56;</p>&#56;</div>
<div><p>&amp;#57;</p>&#57;</div>
<div><p>&amp;#58;</p>&#58;</div>
<div><p>&amp;#59;</p>&#59;</div>
<div><p>&amp;#60;</p>&#60;</div>
<div><p>&amp;#61;</p>&#61;</div>
<div><p>&amp;#62;</p>&#62;</div>
<div><p>&amp;#63;</p>&#63;</div>
<div><p>&amp;#64;</p>&#64;</div>
<div><p>&amp;#65;</p>&#65;</div>
<div><p>&amp;#66;</p>&#66;</div>
<div><p>&amp;#67;</p>&#67;</div>
<div><p>&amp;#68;</p>&#68;</div>
<div><p>&amp;#69;</p>&#69;</div>
<div><p>&amp;#70;</p>&#70;</div>
<div><p>&amp;#71;</p>&#71;</div>
<div><p>&amp;#72;</p>&#72;</div>
<div><p>&amp;#73;</p>&#73;</div>
<div><p>&amp;#74;</p>&#74;</div>
<div><p>&amp;#75;</p>&#75;</div>
<div><p>&amp;#76;</p>&#76;</div>
<div><p>&amp;#77;</p>&#77;</div>
<div><p>&amp;#78;</p>&#78;</div>
<div><p>&amp;#79;</p>&#79;</div>
<div><p>&amp;#80;</p>&#80;</div>
<div><p>&amp;#81;</p>&#81;</div>
<div><p>&amp;#82;</p>&#82;</div>
<div><p>&amp;#83;</p>&#83;</div>
<div><p>&amp;#84;</p>&#84;</div>
<div><p>&amp;#85;</p>&#85;</div>
<div><p>&amp;#86;</p>&#86;</div>
<div><p>&amp;#87;</p>&#87;</div>
<div><p>&amp;#88;</p>&#88;</div>
<div><p>&amp;#89;</p>&#89;</div>
<div><p>&amp;#90;</p>&#90;</div>
<div><p>&amp;#91;</p>&#91;</div>
<div><p>&amp;#92;</p>&#92;</div>
<div><p>&amp;#93;</p>&#93;</div>
<div><p>&amp;#94;</p>&#94;</div>
<div><p>&amp;#95;</p>&#95;</div>
<div><p>&amp;#96;</p>&#96;</div>
<div><p>&amp;#97;</p>&#97;</div>
<div><p>&amp;#98;</p>&#98;</div>
<div><p>&amp;#99;</p>&#99;</div>
<div><p>&amp;#100;</p>&#100;</div>
<div><p>&amp;#101;</p>&#101;</div>
<div><p>&amp;#102;</p>&#102;</div>
<div><p>&amp;#103;</p>&#103;</div>
<div><p>&amp;#104;</p>&#104;</div>
<div><p>&amp;#105;</p>&#105;</div>
<div><p>&amp;#106;</p>&#106;</div>
<div><p>&amp;#107;</p>&#107;</div>
<div><p>&amp;#108;</p>&#108;</div>
<div><p>&amp;#109;</p>&#109;</div>
<div><p>&amp;#110;</p>&#110;</div>
<div><p>&amp;#111;</p>&#111;</div>
<div><p>&amp;#112;</p>&#112;</div>
<div><p>&amp;#113;</p>&#113;</div>
<div><p>&amp;#114;</p>&#114;</div>
<div><p>&amp;#115;</p>&#115;</div>
<div><p>&amp;#116;</p>&#116;</div>
<div><p>&amp;#117;</p>&#117;</div>
<div><p>&amp;#118;</p>&#118;</div>
<div><p>&amp;#119;</p>&#119;</div>
<div><p>&amp;#120;</p>&#120;</div>
<div><p>&amp;#121;</p>&#121;</div>
<div><p>&amp;#122;</p>&#122;</div>
<div><p>&amp;#123;</p>&#123;</div>
<div><p>&amp;#124;</p>&#124;</div>
<div><p>&amp;#125;</p>&#125;</div>
<div><p>&amp;#126;</p>&#126;</div>
<div><p>&amp;#160;</p>&#160;</div>
<div><p>&amp;#161;</p>&#161;</div>
<div><p>&amp;#162;</p>&#162;</div>
<div><p>&amp;#163;</p>&#163;</div>
<div><p>&amp;#165;</p>&#165;</div>
<div><p>&amp;#166;</p>&#166;</div>
<div><p>&amp;#168;</p>&#168;</div>
<div><p>&amp;#169;</p>&#169;</div>
<div><p>&amp;#170;</p>&#170;</div>
<div><p>&amp;#171;</p>&#171;</div>
<div><p>&amp;#173;</p>&#173;</div>
<div><p>&amp;#174;</p>&#174;</div>
<div><p>&amp;#176;</p>&#176;</div>
<div><p>&amp;#178;</p>&#178;</div>
<div><p>&amp;#179;</p>&#179;</div>
<div><p>&amp;#180;</p>&#180;</div>
<div><p>&amp;#185;</p>&#185;</div>
<div><p>&amp;#186;</p>&#186;</div>
<div><p>&amp;#187;</p>&#187;</div>
<div><p>&amp;#188;</p>&#188;</div>
<div><p>&amp;#189;</p>&#189;</div>
<div><p>&amp;#190;</p>&#190;</div>
<div><p>&amp;#191;</p>&#191;</div>
<div><p>&amp;#192;</p>&#192;</div>
<div><p>&amp;#193;</p>&#193;</div>
<div><p>&amp;#194;</p>&#194;</div>
<div><p>&amp;#195;</p>&#195;</div>
<div><p>&amp;#196;</p>&#196;</div>
<div><p>&amp;#197;</p>&#197;</div>
<div><p>&amp;#198;</p>&#198;</div>
<div><p>&amp;#199;</p>&#199;</div>
<div><p>&amp;#200;</p>&#200;</div>
<div><p>&amp;#201;</p>&#201;</div>
<div><p>&amp;#202;</p>&#202;</div>
<div><p>&amp;#203;</p>&#203;</div>
<div><p>&amp;#204;</p>&#204;</div>
<div><p>&amp;#205;</p>&#205;</div>
<div><p>&amp;#206;</p>&#206;</div>
<div><p>&amp;#207;</p>&#207;</div>
<div><p>&amp;#208;</p>&#208;</div>
<div><p>&amp;#209;</p>&#209;</div>
<div><p>&amp;#210;</p>&#210;</div>
<div><p>&amp;#211;</p>&#211;</div>
<div><p>&amp;#212;</p>&#212;</div>
<div><p>&amp;#213;</p>&#213;</div>
<div><p>&amp;#214;</p>&#214;</div>
<div><p>&amp;#216;</p>&#216;</div>
<div><p>&amp;#217;</p>&#217;</div>
<div><p>&amp;#218;</p>&#218;</div>
<div><p>&amp;#219;</p>&#219;</div>
<div><p>&amp;#220;</p>&#220;</div>
<div><p>&amp;#221;</p>&#221;</div>
<div><p>&amp;#222;</p>&#222;</div>
<div><p>&amp;#223;</p>&#223;</div>
<div><p>&amp;#224;</p>&#224;</div>
<div><p>&amp;#225;</p>&#225;</div>
<div><p>&amp;#226;</p>&#226;</div>
<div><p>&amp;#227;</p>&#227;</div>
<div><p>&amp;#228;</p>&#228;</div>
<div><p>&amp;#229;</p>&#229;</div>
<div><p>&amp;#230;</p>&#230;</div>
<div><p>&amp;#231;</p>&#231;</div>
<div><p>&amp;#232;</p>&#232;</div>
<div><p>&amp;#233;</p>&#233;</div>
<div><p>&amp;#234;</p>&#234;</div>
<div><p>&amp;#235;</p>&#235;</div>
<div><p>&amp;#236;</p>&#236;</div>
<div><p>&amp;#237;</p>&#237;</div>
<div><p>&amp;#238;</p>&#238;</div>
<div><p>&amp;#239;</p>&#239;</div>
<div><p>&amp;#240;</p>&#240;</div>
<div><p>&amp;#241;</p>&#241;</div>
<div><p>&amp;#242;</p>&#242;</div>
<div><p>&amp;#243;</p>&#243;</div>
<div><p>&amp;#244;</p>&#244;</div>
<div><p>&amp;#245;</p>&#245;</div>
<div><p>&amp;#246;</p>&#246;</div>
<div><p>&amp;#248;</p>&#248;</div>
<div><p>&amp;#249;</p>&#249;</div>
<div><p>&amp;#250;</p>&#250;</div>
<div><p>&amp;#251;</p>&#251;</div>
<div><p>&amp;#252;</p>&#252;</div>
<div><p>&amp;#253;</p>&#253;</div>
<div><p>&amp;#254;</p>&#254;</div>
<div><p>&amp;#255;</p>&#255;</div>
<div><p>&amp;#8192;</p>&#8192;</div>
<div><p>&amp;#8193;</p>&#8193;</div>
<div><p>&amp;#8194;</p>&#8194;</div>
<div><p>&amp;#8195;</p>&#8195;</div>
<div><p>&amp;#8196;</p>&#8196;</div>
<div><p>&amp;#8197;</p>&#8197;</div>
<div><p>&amp;#8198;</p>&#8198;</div>
<div><p>&amp;#8199;</p>&#8199;</div>
<div><p>&amp;#8200;</p>&#8200;</div>
<div><p>&amp;#8201;</p>&#8201;</div>
<div><p>&amp;#8202;</p>&#8202;</div>
<div><p>&amp;#8208;</p>&#8208;</div>
<div><p>&amp;#8209;</p>&#8209;</div>
<div><p>&amp;#8210;</p>&#8210;</div>
<div><p>&amp;#8211;</p>&#8211;</div>
<div><p>&amp;#8212;</p>&#8212;</div>
<div><p>&amp;#8216;</p>&#8216;</div>
<div><p>&amp;#8217;</p>&#8217;</div>
<div><p>&amp;#8220;</p>&#8220;</div>
<div><p>&amp;#8221;</p>&#8221;</div>
<div><p>&amp;#8226;</p>&#8226;</div>
<div><p>&amp;#8230;</p>&#8230;</div>
<div><p>&amp;#8239;</p>&#8239;</div>
<div><p>&amp;#8249;</p>&#8249;</div>
<div><p>&amp;#8250;</p>&#8250;</div>
<div><p>&amp;#8287;</p>&#8287;</div>
<div><p>&amp;#8364;</p>&#8364;</div>
<div><p>&amp;#8482;</p>&#8482;</div>
<div><p>&amp;#9724;</p>&#9724;</div>
</div>
</div>
</div>
</div>
<div id="specs">
</div>
<div id="installing">
<div class="section">
<div class="grid7 firstcol">
<h1>Installing Webfonts</h1>
<p>Webfonts are supported by all major browser platforms but not all in the same way. There are currently four different font formats that must be included in order to target all browsers. This includes TTF, WOFF, EOT and SVG.</p>
<h2>1. Upload your webfonts</h2>
<p>You must upload your webfont kit to your website. They should be in or near the same directory as your CSS files.</p>
<h2>2. Include the webfont stylesheet</h2>
<p>A special CSS @font-face declaration helps the various browsers select the appropriate font it needs without causing you a bunch of headaches. Learn more about this syntax by reading the <a href="https://www.fontspring.com/blog/further-hardening-of-the-bulletproof-syntax">Fontspring blog post</a> about it. The code for it is as follows:</p>
<code>
@font-face{
font-family: 'MyWebFont';
src: url('WebFont.eot');
src: url('WebFont.eot?#iefix') format('embedded-opentype'),
url('WebFont.woff') format('woff'),
url('WebFont.ttf') format('truetype'),
url('WebFont.svg#webfont') format('svg');
}
</code>
<p>We've already gone ahead and generated the code for you. All you have to do is link to the stylesheet in your HTML, like this:</p>
<code>&lt;link rel=&quot;stylesheet&quot; href=&quot;stylesheet.css&quot; type=&quot;text/css&quot; charset=&quot;utf-8&quot; /&gt;</code>
<h2>3. Modify your own stylesheet</h2>
<p>To take advantage of your new fonts, you must tell your stylesheet to use them. Look at the original @font-face declaration above and find the property called "font-family." The name linked there will be what you use to reference the font. Prepend that webfont name to the font stack in the "font-family" property, inside the selector you want to change. For example:</p>
<code>p { font-family: 'WebFont', Arial, sans-serif; }</code>
<h2>4. Test</h2>
<p>Getting webfonts to work cross-browser <em>can</em> be tricky. Use the information in the sidebar to help you if you find that fonts aren't loading in a particular browser.</p>
</div>
<div class="grid5 sidebar">
<div class="box">
<h2>Troubleshooting<br />Font-Face Problems</h2>
<p>Having trouble getting your webfonts to load in your new website? Here are some tips to sort out what might be the problem.</p>
<h3>Fonts not showing in any browser</h3>
<p>This sounds like you need to work on the plumbing. You either did not upload the fonts to the correct directory, or you did not link the fonts properly in the CSS. If you've confirmed that all this is correct and you still have a problem, take a look at your .htaccess file and see if requests are getting intercepted.</p>
<h3>Fonts not loading in iPhone or iPad</h3>
<p>The most common problem here is that you are serving the fonts from an IIS server. IIS refuses to serve files that have unknown MIME types. If that is the case, you must set the MIME type for SVG to "image/svg+xml" in the server settings. Follow these instructions from Microsoft if you need help.</p>
<h3>Fonts not loading in Firefox</h3>
<p>The primary reason for this failure? You are still using a version Firefox older than 3.5. So upgrade already! If that isn't it, then you are very likely serving fonts from a different domain. Firefox requires that all font assets be served from the same domain. Lastly it is possible that you need to add WOFF to your list of MIME types (if you are serving via IIS.)</p>
<h3>Fonts not loading in IE</h3>
<p>Are you looking at Internet Explorer on an actual Windows machine or are you cheating by using a service like Adobe BrowserLab? Many of these screenshot services do not render @font-face for IE. Best to test it on a real machine.</p>
<h3>Fonts not loading in IE9</h3>
<p>IE9, like Firefox, requires that fonts be served from the same domain as the website. Make sure that is the case.</p>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<p>&copy;2010-2017 Font Squirrel. All rights reserved.</p>
</div>
</div>
</body>
</html>

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
img/pencil.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
img/question.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

97
index.html Executable file
View File

@ -0,0 +1,97 @@
<!doctype html>
<html style="overflow:hidden;">
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
<title>CPU sim</title>
<script src="js/opcodes.js"></script>
<script src="js/index.js"></script>
<script src="js/assembler.js"></script>
</head>
<body>
<iframe id="ALUframe" src="/cpu/build/editor/?item=CPU_ALU" style="display:none"></iframe>
<iframe id="MUX1frame" src="/cpu/build/editor/?item=CPU_MUX" style="display:none"></iframe>
<iframe id="MUX2frame" src="/cpu/build/editor/?item=CPU_MUX" style="display:none"></iframe>
<canvas id="sim">
</canvas>
<div id="sidebar">
<h2 id="runLabel">Run</h2>
<br>
<div class="center_holder">
<button disabled>&lt; step back</button>
&nbsp;
<button id="play" onclick="tick=true; clockTick(1200); runLabel.innerHTML='Run <i>(running)</i>'">Run</button>
&nbsp;
<button onclick="tick=false; runLabel.innerHTML='Run <i>(stopped)</i>'" id="stop">Stop</button>
&nbsp;
<button id="forward" onclick="clockTick(1200,true)">&gt; step forward</button>
&nbsp;
<button id="reset" onclick="resetAll();runLabel.innerHTML='Run';clearInterval(clockTimer)">Reset</button>
</div>
<h2>Program</h2>
<br>
<div class="center_holder">
<textarea spellcheck=false id="program"></textarea>
</div>
<div id="label_error" style="color:red" class="hidden">Invalid assembly code.</div>
<div class="right_holder">
<button id="compile" onclick="runLabel.innerHTML='Run';compile()">Load Program</button>
</div>
<br>
<hr>
<br>
<h2>Input</h2>
<div class="center_holder">
<input id="input" style="width:90%;margin-top:10px;"></input>
</div>
<h2>Output</h2>
<div class="center_holder">
<style>
input:disabled {
background: white;
color: black;
}
</style>
<input disabled id="output" style="width:90%;margin-top:10px;"></input>
</div>
<br>
<input type="checkbox" checked id="ascii" />ASCII?</input>
<br><br>
<br>
<hr>
<br>
<h2>Memory</h2>
<div class="center_holder">
<style>
.nonzero { color: white; }
.hidden {visibility:hidden;}
</style>
<table id="memory">
<tr class='label'><td class='label'>&nbsp;&nbsp;&nbsp;</td><td>x00</td><td>x01</td><td>x02</td><td>x03</td><td>x04</td><td>x05</td><td>x06</td><td>x07</td><td>x08</td><td>x09</td><td>x0A</td><td>x0B</td><td>x0C</td><td>x0D</td><td>x0E</td><td>x0F</td></tr>
<tr><td class='label'>x00</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>x10</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>x20</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>x30</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>x40</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>x50</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>x60</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>x70</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>x80</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>x90</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>xA0</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>xB0</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>xC0</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>xD0</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>xE0</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
<tr><td class='label'>xF0</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td><td>000</td>
</table>
</div>
<div class='center_holder' style="margin-top:5px;">
page&nbsp;<span id="label_mempage">000</span>&nbsp;of 255</div>
<div class='center_holder' style="margin-top:5px;"><span style="cursor:pointer;" onclick="prevMemPage()">&lt;-</span> &nbsp; <span style="cursor:pointer;" onclick="nextMemPage()">-&gt;</span></div>
</div>
<!-- make wget download these -->
<div style="display: none"><a href="cheat/">1</a><a href="uncheat/">2</a><a href="build/multiplexer/">3</a><a href="build/alu/">4</a></div>
</body>
</html>

294
js/assembler copy.js Executable file
View File

@ -0,0 +1,294 @@
Array.prototype.findIndexes=function(where) {
return this.reduce((a, e, i) => (where(e, i) ? a.concat(i) : a), []);
}
class assembler {
labels = [];
labelAddresses = [];
address = 0;
curLine = 0;
offset = 0; // account for any instructions the assembler needs to add
upper8(address){
return address>>8;
}
lower8(address){
return address&0x00FF;
}
intByte(n){
n=n.replace("#","");
var invert = false;
if(n[0]=="~") { invert=true; n=n.slice(1)};
var b = 0;
if(n.match(/^0b/)){
b = parseInt(n.slice(2),2);
} else {
b = parseInt(n);
}
if(isNaN(b)) {
throw 'Invalid number';
} else if(b>255 || b <-128){
throw 'Number will not fit in a byte!';
}
if(b<0){
// apply 2's complement to negative value
var r= ~Math.abs(b)+1;
} else {
var r= b;
};
return invert ? ((~r>>>0)&0xFF) : r;
}
encodeInstruction(line){
var bytes = [0,0];
var instruction = instructions.opcodes.find(oc=>oc.mnemonic==line[0].toLowerCase());
if(instruction.mnemonic=="bflag"||instruction.mnemonic=="bnoflag") {
var flag = instructions.flags.indexOf(line[1]);
if(flag>=0){
// evil stupid dumb
line[1] = line[1].replace(instructions.flags[flag],instructions.registers[flag]);
} else throw 'Invalid flag.';
}
if(!instruction) throw 'Unknown opcode';
var patterns = instructions.arg_patterns[instruction.patterns];
var mode = -1;
if(patterns[0].pattern.length!=line.length-1){
throw 'Wrong number of operands';
} else if(patterns.length==1){
mode = patterns[0].mode;
} else {
patterns.forEach(pattern=>{
var fit=0;
for(var i=0;i<pattern.pattern.length;i++){
if(line[i+1].match(pattern.pattern[i])){
fit++;
}
}
if(fit==pattern.pattern.length){
mode=pattern.mode;
}
})
}
if(mode==-1) { console.log(line); throw 'Ill-formatted instruction' };
// first byte - opcode, addressing mode, destination register
var destreg = instructions.registers.indexOf(line[1])
bytes[0] = (instruction.opcode << 4) + (mode << 3) + Math.max(destreg,0);
if(mode==0){
// register address in first 3 bits, the rest is 0
bytes[1]=instructions.registers.indexOf(line[2])<<5;
} else {
// immediate data (remove #)
bytes[1]=this.intByte(line[line.length-1].replace("#",""));
}
bytes[1]=Math.max(bytes[1],0);
//console.log(bytes);
return bytes;
}
processInstructions(instructions){
var bytecode=[];
var dataPage=0;
var instPage=0;
var instAddr=0;
console.log({labels:this.labels});
instructions.forEach((instruction,i)=>{
var l;
var mnemonic = instruction[0].toLowerCase();
this.curLine = i;
var offset=0;
// dealing with pseudo instructions
if(mnemonic==".data"){
return;
/*
} else if(mnemonic=="hlt"){ // halt: jump to same instruction
if(this.upper8(instAddr)!=instPage){
instPage=this.upper8(instAddr);
bytecode=bytecode.concat(this.encodeInstruction(["mov","ibank","#"+instPage]));
offset=2;
}
bytecode = bytecode.concat(this.encodeInstruction(["jmp","#"+this.lower8(instAddr+offset)]));
} else if(mnemonic=="nop"){ // nop: jump to next instruction
if(this.upper8(instAddr+2)!=instPage){
offset=2;
instPage=this.upper8(instAddr);
bytecode=bytecode.concat(this.encodeInstruction(["mov","ibank","#"+instPage]));
}
bytecode = bytecode.concat(this.encodeInstruction(["jmp","#"+this.lower8(instAddr+2+offset)]));
*/
// now process labels
} else if(mnemonic=="jsr"||mnemonic=="jmp"){
instruction[1] = instruction[1].replace("SKIP",'#'+(instAddr+4+offset));
l = this.labelAddresses.find(la=>instruction[1].includes(la.label));
if(l){ // we must replace
instruction[1] = instruction[1].replace(l.label, "#"+this.lower8(l.address));
if(this.upper8(l.address)!=instPage){
instPage=this.upper8(l.address);
bytecode=bytecode.concat(this.encodeInstruction(["mov","ip","#"+instPage]));
offset=2;
}
}
console.log(instruction);
bytecode=bytecode.concat(this.encodeInstruction(instruction));
} else if(mnemonic=="stb"||mnemonic=="ldb"||mnemonic=="mov"||mnemonic=="bflag"||mnemonic=="bnoflag"){
// QUICK AND DIRTY: WILL BREAK UNDER CERTAIN CONDITIONS
instruction[2] = instruction[2].replace("SKIP",'#'+(instAddr+4+offset));
l = this.labelAddresses.find(la=>instruction[2].includes(la.label));
if(l){ // we must replace
instruction[2] = instruction[2].replace(l.label, "#"+this.lower8(l.address));
if(this.upper8(l.address)!=dataPage){
dataPage=this.upper8(l.address);
bytecode=bytecode.concat(this.encodeInstruction(["mov","dp","#"+dataPage]));
offset=2;
}
}
bytecode=bytecode.concat(this.encodeInstruction(instruction));
} else bytecode=bytecode.concat(this.encodeInstruction(instruction));
console.log({i:i, l:this.labels});
l = this.labels.findIndex(la=>la.line==i);
if(l>-1){
this.labelAddresses.push({label: this.labels[l].label, address: instAddr});
}
instAddr += 2 + offset;
});
return bytecode;
}
assemble(code) {
// try
var tokens = this.tokenize(code).filter(line=>line.length>0 &&line[0]!='');
console.log(tokens);
var withPseudo = this.processAndOr(tokens);
var delabeled = this.processLabels(withPseudo);
var data = this.processData(delabeled);
var bytecode = this.processInstructions(delabeled);
var pad = data.bytes.length>0?Array(data.start - bytecode.length).fill(0):[];
console.log({tokens,withPseudo,delabeled,data,bytecode})
return bytecode.concat(pad).concat(data.bytes);
// catch
}
processAndOr(tokenLines) {
var processed=[];
tokenLines.forEach(line=>{
if(line.length<2){
processed.push(line)
}
else if(line[0].toLowerCase()=="and") {
line[0] = "nand";
processed.push(line); // NAND a, b
processed.push(['nand',line[1],line[1]]); // NAND a, a
} else if(line[1].toLowerCase()=="and") {
line[1] = "nand";
processed.push(line); // ibid
processed.push(['nand',line[2],line[2]]);
} else if(line[0].toLowerCase()=="or") {
processed.push(['nand',line[1],line[1]]); // NAND a, a
if(line[2].toLowerCase().match(instructions.match.reg)){
processed.push(['nand',line[2],line[2]]); // NAND b, b
processed.push(['nand',line[1],line[2]]); // NAND a, b
processed.push(['nand',line[2],line[2]]); // NAND b, b
} else if(line[2].toLowerCase().match(instructions.match.imm8)) {
//int imm8 = intByte(this.intByte(line[2]); // NAND b, b
processed.push(['nand',line[1],"~"+line[2]]);//line[2]]); // NAND a, b
} else if(line[2].toLowerCase().match(instructions.match.label)) {
processed.push(['nand',line[1],"~"+line[2]]);// NAND a, ~b
} else throw("error converting and");
} else if(line[1].toLowerCase()=="or"){
processed.push(['nand',line[2],line[2]]); // NAND a, a
if(line[3].toLowerCase().match(/(ip|dp|sp|r[0-3])/)){
processed.push(['nand',line[3],line[3]]); // NAND b, b
processed.push(['nand',line[2],line[3]]); // NAND a, b
processed.push(['nand',line[3],line[3]]); // NAND b, b
} else if(line[3].toLowerCase().match(instructions.match.imm8)) {
imm8 = ~this.intByte(line[3]); // NAND b, b
processed.push(['nand',line[2],line[3]]); // NAND a, b
} else if(line[3].toLowerCase().match(instructions.match.label)) {
processed.push(['nand',line[2],"~"+line[3]]);// NAND a, ~b
} else throw("error converting and");
} else {
processed.push(line);
}
});
return processed;
}
processLabels(tokenLines) {
var processed = [];
// first pass: extract labels
for(var i=0;i<tokenLines.length;i++){
var curLine = tokenLines[i];
if(curLine[0].match(/^[A-z0-9]+:$/)){
// if this line is just a label, we want to remove it
// and have the label point to the next line
// regardless, this label will point to the next line added
// to the processed array
var lineNum = processed.length;
if(curLine.length > 1 && curLine[1]!=''){
// first token was label; next token will be opcode or data
processed.push(curLine.slice(1));
}
this.labels.push({ label: curLine[0].split(/:.*/)[0], line: lineNum });
//processed.push(curLine.slice(1));
} else processed.push(curLine);
}
return processed;
}
processData(tokenLines) {
// we want to find out where the end of the instructions will be
// however, we don't know how many the assembler will insert to deal with pages
// i can't be bothered doing this properly so let's just add an extra two bytes
// for every instruction that accesses memory
// get number of instructions that deal with memory
var dataInstructions = tokenLines.findIndexes(line=>line[0].toLowerCase().match('^.data$'));
var numMem = tokenLines.filter(line => line[0].toLowerCase().match(/(ldb|stb|jsr|jmp|bflag|bnoflag)/)).length;
var start = ( (tokenLines.length - dataInstructions.length) + numMem )* 2;
var curAddr = 0;
var bytes = [];
dataInstructions.forEach(i=>{
this.curLine = i;
var thisLabel = this.labels.find(l => l.line== i);
if(thisLabel){
this.labelAddresses.push({ label: thisLabel.label, address: curAddr+start });
}
tokenLines[i].slice(1).forEach(token=>{
// if string
if(token.match(/^".*"$/)) {
token.slice(1).slice(0,-1).replace(/[^\x00-\x7F]/g, "").split('').forEach(character=>{
bytes.push(character.charCodeAt(0));
curAddr += 1;
});
} else {
bytes.push(this.intByte(token));
curAddr += 1;
}
});
})
return { start, bytes };
}
tokenize(code) {
var tokenLines = [];
// split code into lines - strings enclosed in quotes can span multiple lines
// nb this breaks for escaped quotes but who cares
var lines = code.split(/(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*)\r?\n(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/);
lines.forEach(line=>{
// split on wgutespace or comma, unless quoted
var tokens = line.split(/(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*)[ ,]+(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/);
// remove comments preceded by ;
var hitSemicolon=false
var tokenLine=[];
tokens.forEach(token=>{
//console.log(token);
if(token[0]==";"||hitSemicolon){
hitSemicolon=true;
} else {
tokenLine.push(token);
//console.log(tokenLine);
}
})
tokenLines.push(tokenLine);
})
return tokenLines;
}
}

294
js/assembler.js Executable file
View File

@ -0,0 +1,294 @@
Array.prototype.findIndexes=function(where) {
return this.reduce((a, e, i) => (where(e, i) ? a.concat(i) : a), []);
}
class assembler {
labels = [];
labelAddresses = [];
address = 0;
curLine = 0;
offset = 0; // account for any instructions the assembler needs to add
upper8(address){
return address>>8;
}
lower8(address){
return address&0x00FF;
}
intByte(n){
n=n.replace("#","");
var invert = false;
if(n[0]=="~") { invert=true; n=n.slice(1)};
var b = 0;
if(n.match(/^0b/)){
b = parseInt(n.slice(2),2);
} else {
b = parseInt(n);
}
if(isNaN(b)) {
throw 'Invalid number';
} else if(b>255 || b <-128){
throw 'Number will not fit in a byte!';
}
if(b<0){
// apply 2's complement to negative value
var r= ~Math.abs(b)+1;
} else {
var r= b;
};
return invert ? ((~r>>>0)&0xFF) : r;
}
encodeInstruction(line){
var bytes = [0,0];
var instruction = instructions.opcodes.find(oc=>oc.mnemonic==line[0].toLowerCase());
if(instruction.mnemonic=="bflag"||instruction.mnemonic=="bnoflag") {
var flag = instructions.flags.indexOf(line[1]);
if(flag>=0){
// evil stupid dumb
line[1] = line[1].replace(instructions.flags[flag],instructions.registers[flag]);
} else throw 'Invalid flag.';
}
if(!instruction) throw 'Unknown opcode';
var patterns = instructions.arg_patterns[instruction.patterns];
var mode = -1;
if(patterns[0].pattern.length!=line.length-1){
throw 'Wrong number of operands';
} else if(patterns.length==1){
mode = patterns[0].mode;
} else {
patterns.forEach(pattern=>{
var fit=0;
for(var i=0;i<pattern.pattern.length;i++){
if(line[i+1].match(pattern.pattern[i])){
fit++;
}
}
if(fit==pattern.pattern.length){
mode=pattern.mode;
}
})
}
if(mode==-1) { console.log(line); throw 'Ill-formatted instruction' };
// first byte - opcode, addressing mode, destination register
var destreg = instructions.registers.indexOf(line[1])
bytes[0] = (instruction.opcode << 4) + (mode << 3) + Math.max(destreg,0);
if(mode==0){
// register address in first 3 bits, the rest is 0
bytes[1]=instructions.registers.indexOf(line[2])<<5;
} else {
// immediate data (remove #)
bytes[1]=this.intByte(line[line.length-1].replace("#",""));
}
bytes[1]=Math.max(bytes[1],0);
//console.log(bytes);
return bytes;
}
processInstructions(instructions){
var bytecode=[];
var dataPage=0;
var instPage=0;
var instAddr=0;
console.log({labels:this.labels});
instructions.forEach((instruction,i)=>{
var l;
var mnemonic = instruction[0].toLowerCase();
this.curLine = i;
var offset=0;
// dealing with pseudo instructions
if(mnemonic==".data"){
return;
/*
} else if(mnemonic=="hlt"){ // halt: jump to same instruction
if(this.upper8(instAddr)!=instPage){
instPage=this.upper8(instAddr);
bytecode=bytecode.concat(this.encodeInstruction(["mov","ibank","#"+instPage]));
offset=2;
}
bytecode = bytecode.concat(this.encodeInstruction(["jmp","#"+this.lower8(instAddr+offset)]));
} else if(mnemonic=="nop"){ // nop: jump to next instruction
if(this.upper8(instAddr+2)!=instPage){
offset=2;
instPage=this.upper8(instAddr);
bytecode=bytecode.concat(this.encodeInstruction(["mov","ibank","#"+instPage]));
}
bytecode = bytecode.concat(this.encodeInstruction(["jmp","#"+this.lower8(instAddr+2+offset)]));
*/
// now process labels
} else if(mnemonic=="jsr"||mnemonic=="jmp"){
instruction[1] = instruction[1].replace("SKIP",'#'+(instAddr+4+offset));
l = this.labelAddresses.find(la=>instruction[1].includes(la.label));
if(l){ // we must replace
instruction[1] = instruction[1].replace(l.label, "#"+this.lower8(l.address));
if(this.upper8(l.address)!=instPage){
instPage=this.upper8(l.address);
bytecode=bytecode.concat(this.encodeInstruction(["mov","ip","#"+instPage]));
offset=2;
}
}
console.log(instruction);
bytecode=bytecode.concat(this.encodeInstruction(instruction));
} else if(mnemonic=="stb"||mnemonic=="ldb"||mnemonic=="mov"||mnemonic=="bflag"||mnemonic=="bnoflag"){
// QUICK AND DIRTY: WILL BREAK UNDER CERTAIN CONDITIONS
instruction[2] = instruction[2].replace("SKIP",'#'+(instAddr+4+offset));
l = this.labelAddresses.find(la=>instruction[2].includes(la.label));
if(l){ // we must replace
instruction[2] = instruction[2].replace(l.label, "#"+this.lower8(l.address));
if(this.upper8(l.address)!=dataPage){
dataPage=this.upper8(l.address);
bytecode=bytecode.concat(this.encodeInstruction(["mov","dp","#"+dataPage]));
offset=2;
}
}
bytecode=bytecode.concat(this.encodeInstruction(instruction));
} else bytecode=bytecode.concat(this.encodeInstruction(instruction));
console.log({i:i, l:this.labels});
l = this.labels.findIndex(la=>la.line==i);
if(l>-1){
this.labelAddresses.push({label: this.labels[l].label, address: instAddr});
}
instAddr += 2 + offset;
});
return bytecode;
}
assemble(code) {
// try
var tokens = this.tokenize(code).filter(line=>line.length>0 &&line[0]!='');
console.log(tokens);
var withPseudo = this.processAndOr(tokens);
var delabeled = this.processLabels(withPseudo);
var data = this.processData(delabeled);
var bytecode = this.processInstructions(delabeled);
var pad = data.bytes.length>0?Array(data.start - bytecode.length).fill(0):[];
console.log({tokens,withPseudo,delabeled,data,bytecode})
return bytecode.concat(pad).concat(data.bytes);
// catch
}
processAndOr(tokenLines) {
var processed=[];
tokenLines.forEach(line=>{
if(line.length<2){
processed.push(line)
}
else if(line[0].toLowerCase()=="and") {
line[0] = "nand";
processed.push(line); // NAND a, b
processed.push(['nand',line[1],line[1]]); // NAND a, a
} else if(line[1].toLowerCase()=="and") {
line[1] = "nand";
processed.push(line); // ibid
processed.push(['nand',line[2],line[2]]);
} else if(line[0].toLowerCase()=="or") {
processed.push(['nand',line[1],line[1]]); // NAND a, a
if(line[2].toLowerCase().match(instructions.match.reg)){
processed.push(['nand',line[2],line[2]]); // NAND b, b
processed.push(['nand',line[1],line[2]]); // NAND a, b
processed.push(['nand',line[2],line[2]]); // NAND b, b
} else if(line[2].toLowerCase().match(instructions.match.imm8)) {
//int imm8 = intByte(this.intByte(line[2]); // NAND b, b
processed.push(['nand',line[1],"~"+line[2]]);//line[2]]); // NAND a, b
} else if(line[2].toLowerCase().match(instructions.match.label)) {
processed.push(['nand',line[1],"~"+line[2]]);// NAND a, ~b
} else throw("error converting and");
} else if(line[1].toLowerCase()=="or"){
processed.push(['nand',line[2],line[2]]); // NAND a, a
if(line[3].toLowerCase().match(/(ip|dp|sp|r[0-3])/)){
processed.push(['nand',line[3],line[3]]); // NAND b, b
processed.push(['nand',line[2],line[3]]); // NAND a, b
processed.push(['nand',line[3],line[3]]); // NAND b, b
} else if(line[3].toLowerCase().match(instructions.match.imm8)) {
imm8 = ~this.intByte(line[3]); // NAND b, b
processed.push(['nand',line[2],line[3]]); // NAND a, b
} else if(line[3].toLowerCase().match(instructions.match.label)) {
processed.push(['nand',line[2],"~"+line[3]]);// NAND a, ~b
} else throw("error converting and");
} else {
processed.push(line);
}
});
return processed;
}
processLabels(tokenLines) {
var processed = [];
// first pass: extract labels
for(var i=0;i<tokenLines.length;i++){
var curLine = tokenLines[i];
if(curLine[0].match(/^[A-z0-9]+:$/)){
// if this line is just a label, we want to remove it
// and have the label point to the next line
// regardless, this label will point to the next line added
// to the processed array
var lineNum = processed.length;
if(curLine.length > 1 && curLine[1]!=''){
// first token was label; next token will be opcode or data
processed.push(curLine.slice(1));
}
this.labels.push({ label: curLine[0].split(/:.*/)[0], line: lineNum });
//processed.push(curLine.slice(1));
} else processed.push(curLine);
}
return processed;
}
processData(tokenLines) {
// we want to find out where the end of the instructions will be
// however, we don't know how many the assembler will insert to deal with pages
// i can't be bothered doing this properly so let's just add an extra two bytes
// for every instruction that accesses memory
// get number of instructions that deal with memory
var dataInstructions = tokenLines.findIndexes(line=>line[0].toLowerCase().match('^.data$'));
var numMem = tokenLines.filter(line => line[0].toLowerCase().match(/(ldb|stb|jsr|jmp|bflag|bnoflag)/)).length;
var start = ( (tokenLines.length - dataInstructions.length) + numMem )* 2;
var curAddr = 0;
var bytes = [];
dataInstructions.forEach(i=>{
this.curLine = i;
var thisLabel = this.labels.find(l => l.line== i);
if(thisLabel){
this.labelAddresses.push({ label: thisLabel.label, address: curAddr+start });
}
tokenLines[i].slice(1).forEach(token=>{
// if string
if(token.match(/^".*"$/)) {
token.slice(1).slice(0,-1).replace(/[^\x00-\x7F]/g, "").split('').forEach(character=>{
bytes.push(character.charCodeAt(0));
curAddr += 1;
});
} else {
bytes.push(this.intByte(token));
curAddr += 1;
}
});
})
return { start, bytes };
}
tokenize(code) {
var tokenLines = [];
// split code into lines - strings enclosed in quotes can span multiple lines
// nb this breaks for escaped quotes but who cares
var lines = code.split(/(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*)\r?\n(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/);
lines.forEach(line=>{
// split on wgutespace or comma, unless quoted
var tokens = line.split(/(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*)[ ,]+(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/);
// remove comments preceded by ;
var hitSemicolon=false
var tokenLine=[];
tokens.forEach(token=>{
//console.log(token);
if(token[0]==";"||hitSemicolon){
hitSemicolon=true;
} else {
tokenLine.push(token);
//console.log(tokenLine);
}
})
tokenLines.push(tokenLine);
})
return tokenLines;
}
}

1129
js/index.js Executable file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More