1
0
mirror of https://github.com/mist64/perfect6502.git synced 2024-10-01 13:55:46 +00:00
perfect6502/js/wires.js
2010-09-21 06:25:51 +00:00

87 lines
2.3 KiB
JavaScript

/*
Copyright (c) 2010 Brian Silverman, Barry Silverman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
var statbox;
var nodes = new Array();
var transistors = {};
var ngnd = nodenames['vss'];
var npwr = nodenames['vcc'];
/////////////////////////
//
// Drawing Setup
//
/////////////////////////
// try to present a meaningful page before starting expensive work
function setup(){
statbox = document.getElementById('status');
setupNodes();
setupTransistors();
setupTable();
initChip();
document.getElementById('stop').style.visibility = 'hidden';
go();
}
function setup_part2(){
}
function setupNodes(){
var w = 0;
for(var i in segdefs){
nodes[w++] = {pullup: segdefs[i],
state: 'fl', gates: new Array(), c1c2s: new Array()};
}
}
function setupTransistors(){
for(i in transdefs){
var tdef = transdefs[i];
var gate = tdef[0];
var c1 = tdef[1];
var c2 = tdef[2];
var trans = {name: i, on: false, gate: gate, c1: c1, c2: c2};
nodes[gate].gates.push(i);
nodes[c1].c1c2s.push(i);
nodes[c2].c1c2s.push(i);
transistors[i] = trans;
}
}
/////////////////////////
//
// Etc.
//
/////////////////////////
function setStatus(){
var res = '';
for(var i=0;i<arguments.length;i++) res=res+arguments[i]+' ';
statbox.innerHTML = res;
}
function now(){return new Date().getTime();}