mirror of
https://github.com/trebonian/visual6502.git
synced 2025-07-13 01:24:11 +00:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
9477ea64b4 | |||
7ef9dc4c43 | |||
efddb36049 | |||
ef88fdeb90 | |||
470080015d | |||
dccef54f2e | |||
18fbd2eb36 | |||
bc901566e3 | |||
6276d019d7 | |||
69ab63e406 | |||
d032580201 | |||
0ecb753ec6 | |||
e2e88cfae1 | |||
1fd86334f7 | |||
bf2108b9d6 | |||
2d2d0ef9b6 | |||
3398a6f181 | |||
b6d4ffda6a | |||
6dd7e9c24e | |||
51b4d8d7a0 | |||
e01093def5 | |||
27f085b743 | |||
d3223a9478 | |||
f8931fce49 | |||
b9cbe765b2 |
4
.gitattributes
vendored
Normal file
4
.gitattributes
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
* text=auto
|
||||||
|
*.js text
|
||||||
|
*.css text
|
||||||
|
*.html text
|
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# emacs-style backup files
|
||||||
|
*~
|
||||||
|
# patch detritus
|
||||||
|
*.orig
|
||||||
|
*.rej
|
10
README
10
README
@ -0,0 +1,10 @@
|
|||||||
|
This is the javascript simulator from the visual5602.org project:
|
||||||
|
www.visual6502.org/JSSim
|
||||||
|
|
||||||
|
It includes a general purpose transistor-level simulator, layout browser,
|
||||||
|
and the data from a 6502 revD chip.
|
||||||
|
|
||||||
|
Note the various licenses and Copyright associated with each file.
|
||||||
|
|
||||||
|
Enjoy!
|
||||||
|
- The Visual 6502 Team
|
||||||
|
33
browsertrouble.html
Normal file
33
browsertrouble.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Visual 6502 in JavaScript</title>
|
||||||
|
<style type="text/css">@import "wires.css";</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<span id="title"><a href="http://visual6502.org">The Visual 6502</a></span>
|
||||||
|
<span id="plain">
|
||||||
|
<br />
|
||||||
|
<span id="title">Browser Trouble?</span>
|
||||||
|
<br />
|
||||||
|
<a href="http://www.visual6502.org/faq.html">FAQ</a>
|
||||||
|
<a href="http://blog.visual6502.org">Blog</a>
|
||||||
|
<a href="http://www.visual6502.org/links.html">Links</a> 
|
||||||
|
<p>
|
||||||
|
Our chip simulator makes heavy use of the latest version of HTML5 drawing technology.
|
||||||
|
<p>
|
||||||
|
It will only run on recent browsers and on a computer with sufficient memory (we recommend at least 2Gbytes.)
|
||||||
|
<p>
|
||||||
|
We've tested it on Chrome, Firefox, Safari and Opera. Unfortunately Internet Explorer isn't yet capable of running the graphics.
|
||||||
|
<p>
|
||||||
|
If you're using one of the above browsers and having trouble, please restart the browser.
|
||||||
|
<p>
|
||||||
|
If you have a problem report or you're able to help us with compatilibity, please get in touch - our contact details are on the main page.
|
||||||
|
<p>
|
||||||
|
In the meantime, here's a picture of what you're missing:
|
||||||
|
<p>
|
||||||
|
<a href="http://visual6502.org"><img src="images/jssim2.png" style="border:10px"></a>
|
||||||
|
</span>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -21,6 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var ctrace = false;
|
var ctrace = false;
|
||||||
|
var noGraphics = false;
|
||||||
|
var loglevel = 3;
|
||||||
var ridx = 0;
|
var ridx = 0;
|
||||||
|
|
||||||
function recalcNodeList(list){
|
function recalcNodeList(list){
|
||||||
@ -33,7 +35,7 @@ function recalcNodeList(list){
|
|||||||
list = recalclist;
|
list = recalclist;
|
||||||
recalclist = new Array();
|
recalclist = new Array();
|
||||||
}
|
}
|
||||||
console.log(n,'looping...');
|
if(ctrace) console.log(n,'looping...');
|
||||||
}
|
}
|
||||||
|
|
||||||
function recalcNode(node, recalclist){
|
function recalcNode(node, recalclist){
|
||||||
@ -129,7 +131,7 @@ function getNodeValue(group){
|
|||||||
if((n.state=='fl')&&(flstate==undefined)) flstate = 'fl';
|
if((n.state=='fl')&&(flstate==undefined)) flstate = 'fl';
|
||||||
if(n.state=='fh') flstate = 'fh';
|
if(n.state=='fh') flstate = 'fh';
|
||||||
}
|
}
|
||||||
if(flstate==undefined) console.log(group);
|
if(flstate==undefined && ctrace) console.log(group);
|
||||||
return flstate;
|
return flstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
images/jssim2.png
Executable file
BIN
images/jssim2.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 312 KiB |
68
index.html
68
index.html
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>6502</title>
|
<title>Visual 6502 in JavaScript</title>
|
||||||
<style type="text/css">@import "wires.css";</style>
|
<style type="text/css">@import "wires.css";</style>
|
||||||
<script src="segdefs.js"></script>
|
<script src="segdefs.js"></script>
|
||||||
<script src="transdefs.js"></script>
|
<script src="transdefs.js"></script>
|
||||||
@ -10,27 +10,75 @@
|
|||||||
<script src="chipsim.js"></script>
|
<script src="chipsim.js"></script>
|
||||||
<script src="memtable.js"></script>
|
<script src="memtable.js"></script>
|
||||||
<script src="macros.js"></script>
|
<script src="macros.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
function handleOnload() {
|
||||||
|
if((navigator.appName == 'Microsoft Internet Explorer') && (parseInt(navigator.appVersion,10)<9)){
|
||||||
|
document.getElementById('browsertrouble').innerHTML=
|
||||||
|
'<p>Sorry, '+navigator.appName+' not supported - showing you a picture instead!</p>';
|
||||||
|
document.getElementById('frame').innerHTML='<a href="browsertrouble.html"><img src="images/jssim2.png" style="border:10px"></a>';
|
||||||
|
}else{
|
||||||
|
setTimeout(setup,200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="setup();">
|
<body onload="handleOnload();">
|
||||||
<p class="title">The 6502</p>
|
<br />
|
||||||
|
<span id="title"><a href="http://visual6502.org">The Visual 6502</a></span>
|
||||||
|
<span id="plain">
|
||||||
|
<br />
|
||||||
|
<a href="http://www.visual6502.org/faq.html">FAQ</a>
|
||||||
|
<a href="http://blog.visual6502.org">Blog</a>
|
||||||
|
<a href="http://www.visual6502.org/links.html">Links</a> 
|
||||||
|
<br /><br />
|
||||||
|
This simulator uses HTML5 features only found on the latest versions of browsers and needs
|
||||||
|
lots of RAM. If you have trouble, please <a href="browsertrouble.html">check compatibility.</a>
|
||||||
|
<br />
|
||||||
|
<span id="browsertrouble"></span>
|
||||||
|
<br />
|
||||||
|
Hit '>' to zoom in, '<' to zoom out
|
||||||
|
<br />
|
||||||
|
Right-click to scroll around
|
||||||
|
<br />
|
||||||
|
Enter your own program into the array of RAM
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
</span>
|
||||||
<div class="frame" id="frame">
|
<div class="frame" id="frame">
|
||||||
<div class="chip">
|
<div class="chip" id="chip">
|
||||||
<canvas class="chip" id="chipbg"></canvas>
|
<canvas class="chip" id="chipbg"></canvas>
|
||||||
<canvas class="chip" id="overlay"></canvas>
|
<canvas class="chip" id="overlay"></canvas>
|
||||||
<canvas class="chip" id="hilite"></canvas>
|
<canvas class="chip" id="hilite"></canvas>
|
||||||
<canvas class="chip" id="hitbuffer"></canvas>
|
<canvas class="chip" id="hitbuffer"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<div class = "buttons">
|
<div class = "buttons">
|
||||||
<a href ="javascript:stopChip()"id="stop"><img class="navstop" src="images/stop.png"></a>
|
<div style="position:relative; float:left;">
|
||||||
<a href ="javascript:runChip()" id="start"><img class="navplay" src="images/play.png"></a>
|
<a href ="javascript:stopChip()"id="stop"><img class="navstop" src="images/stop.png"></a>
|
||||||
<a href ="javascript:resetChip()"><img class="navbutton" src="images/up.png"></a>
|
<a href ="javascript:runChip()" id="start"><img class="navplay" src="images/play.png"></a>
|
||||||
<a href ="javascript:stepBack()"><img class="navbutton" src="images/prev.png"></a>
|
</div>
|
||||||
<a href ="javascript:stepForward()"><img class="navbutton" src="images/next.png"></a>
|
<div style="float:left;">
|
||||||
|
<a href ="javascript:resetChip()"><img class="navbutton" src="images/up.png"></a>
|
||||||
|
<a href ="javascript:stepBack()"><img class="navbutton" src="images/prev.png"></a>
|
||||||
|
<a href ="javascript:stepForward()"><img class="navbutton" src="images/next.png"></a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="status" id="status">x: 0<br>y: 0</p>
|
<p class="status" id="status">x: 0<br>y: 0</p>
|
||||||
<table class="memtable" id="memtable"></table>
|
<table class="memtable" id="memtable"></table>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="updateShow"> Show:
|
||||||
|
<input type="checkbox" name="0" id="updateShow0" onchange="updateShow(this.name,this.checked)" />(metal)
|
||||||
|
<input type="checkbox" name="1" id="updateShow1" onchange="updateShow(this.name,this.checked)" />(switched diffusion)
|
||||||
|
<input type="checkbox" name="3" id="updateShow3" onchange="updateShow(this.name,this.checked)" />(grounded diffusion)
|
||||||
|
<input type="checkbox" name="4" id="updateShow4" onchange="updateShow(this.name,this.checked)" />(powered diffusion)
|
||||||
|
<input type="checkbox" name="5" id="updateShow5" onchange="updateShow(this.name,this.checked)" />(polysilicon)
|
||||||
|
<input type="checkbox" name="2" id="updateShow2" onchange="updateShow(this.name,this.checked)" />(diode)
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
In addition to this JavaScript project, see our <a href="../python6502.html">Python-based simulator</a> which may be easier to customize, verify, and apply to the study of long programs.<br />
|
||||||
|
<br />
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
124
macros.js
124
macros.js
@ -39,11 +39,55 @@ function go(n){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function steps(){
|
function steps(){
|
||||||
if(running) step();
|
if(running) {
|
||||||
setTimeout(steps, 200);
|
step();
|
||||||
|
setTimeout(steps, 0); // schedule the next poll
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testNMI(n){
|
||||||
|
initChip();
|
||||||
|
|
||||||
|
mWrite(0x0000, 0x38); // set carry
|
||||||
|
mWrite(0x0001, 0x4c); // jump to test code
|
||||||
|
mWrite(0x0002, 0x06);
|
||||||
|
mWrite(0x0003, 0x23);
|
||||||
|
|
||||||
|
mWrite(0x22ff, 0x38); // set carry
|
||||||
|
mWrite(0x2300, 0xea);
|
||||||
|
mWrite(0x2301, 0xea);
|
||||||
|
mWrite(0x2302, 0xea);
|
||||||
|
mWrite(0x2303, 0xea);
|
||||||
|
mWrite(0x2304, 0xb0); // branch carry set to self
|
||||||
|
mWrite(0x2305, 0xfe);
|
||||||
|
|
||||||
|
mWrite(0x2306, 0xb0); // branch carry set to self
|
||||||
|
mWrite(0x2307, 0x01);
|
||||||
|
mWrite(0x2308, 0x00); // brk should be skipped
|
||||||
|
mWrite(0x2309, 0xa9); // anything
|
||||||
|
mWrite(0x230a, 0xde); // anything
|
||||||
|
mWrite(0x230b, 0xb0); // branch back with page crossing
|
||||||
|
mWrite(0x230c, 0xf2);
|
||||||
|
|
||||||
|
mWrite(0xc018, 0x40); // nmi handler
|
||||||
|
|
||||||
|
mWrite(0xfffa, 0x18); // nmi vector
|
||||||
|
mWrite(0xfffb, 0xc0);
|
||||||
|
mWrite(0xfffc, 0x00); // reset vector
|
||||||
|
mWrite(0xfffd, 0x00);
|
||||||
|
|
||||||
|
for(var i=0;i<n;i++){step();}
|
||||||
|
setLow('nmi');
|
||||||
|
chipStatus();
|
||||||
|
for(var i=0;i<8;i++){step();}
|
||||||
|
setHigh('nmi');
|
||||||
|
chipStatus();
|
||||||
|
for(var i=0;i<16;i++){step();}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function initChip(){
|
function initChip(){
|
||||||
|
var start = now();
|
||||||
for(var nn in nodes) nodes[nn].state = 'fl';
|
for(var nn in nodes) nodes[nn].state = 'fl';
|
||||||
nodes[ngnd].state = 'gnd';
|
nodes[ngnd].state = 'gnd';
|
||||||
nodes[npwr].state = 'vcc';
|
nodes[npwr].state = 'vcc';
|
||||||
@ -55,11 +99,12 @@ function initChip(){
|
|||||||
recalcNodeList(allNodes());
|
recalcNodeList(allNodes());
|
||||||
for(var i=0;i<8;i++){setHigh('clk0'), setLow('clk0');}
|
for(var i=0;i<8;i++){setHigh('clk0'), setLow('clk0');}
|
||||||
setHigh('res');
|
setHigh('res');
|
||||||
for(var i=0;i<14;i++){step();}
|
for(var i=0;i<18;i++){resetStep();}
|
||||||
refresh();
|
refresh();
|
||||||
cycle = 0;
|
cycle = 0;
|
||||||
trace = Array();
|
trace = Array();
|
||||||
chipStatus();
|
chipStatus();
|
||||||
|
if(ctrace)console.log('initChip done after', now()-start);
|
||||||
}
|
}
|
||||||
|
|
||||||
function step(){
|
function step(){
|
||||||
@ -76,6 +121,12 @@ function halfStep(){
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetStep(){
|
||||||
|
var clk = isNodeHigh(nodenames['clk0']);
|
||||||
|
if (clk) {setLow('clk0'); handleBusRead(); }
|
||||||
|
else {setHigh('clk0'); handleBusWrite();}
|
||||||
|
}
|
||||||
|
|
||||||
function handleBusRead(){
|
function handleBusRead(){
|
||||||
if(isNodeHigh(nodenames['rw'])) writeDataBus(mRead(readAddressBus()));
|
if(isNodeHigh(nodenames['rw'])) writeDataBus(mRead(readAddressBus()));
|
||||||
}
|
}
|
||||||
@ -95,8 +146,26 @@ function readA(){return readBits('a', 8);}
|
|||||||
function readY(){return readBits('y', 8);}
|
function readY(){return readBits('y', 8);}
|
||||||
function readX(){return readBits('x', 8);}
|
function readX(){return readBits('x', 8);}
|
||||||
function readP(){return readBits('p', 8);}
|
function readP(){return readBits('p', 8);}
|
||||||
|
function readPstring(){
|
||||||
|
var result;
|
||||||
|
result = (isNodeHigh(nodenames['p7'])?'N':'n') +
|
||||||
|
(isNodeHigh(nodenames['p6'])?'V':'v') +
|
||||||
|
'-' +
|
||||||
|
(isNodeHigh(nodenames['p3'])?'B':'b') +
|
||||||
|
(isNodeHigh(nodenames['p3'])?'D':'d') +
|
||||||
|
(isNodeHigh(nodenames['p2'])?'I':'i') +
|
||||||
|
(isNodeHigh(nodenames['p1'])?'Z':'z') +
|
||||||
|
(isNodeHigh(nodenames['p0'])?'C':'c');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
function readSP(){return readBits('s', 8);}
|
function readSP(){return readBits('s', 8);}
|
||||||
|
function readPC(){return (readBits('pch', 8)<<8) + readBits('pcl', 8);}
|
||||||
|
function readPCL(){return readBits('pcl', 8);}
|
||||||
|
function readPCH(){return readBits('pch', 8);}
|
||||||
|
|
||||||
|
function readBit(name){
|
||||||
|
return isNodeHigh(nodenames[name])?1:0;
|
||||||
|
}
|
||||||
function readBits(name, n){
|
function readBits(name, n){
|
||||||
var res = 0;
|
var res = 0;
|
||||||
for(var i=0;i<n;i++){
|
for(var i=0;i<n;i++){
|
||||||
@ -144,6 +213,7 @@ function runChip(){
|
|||||||
start.style.visibility = 'hidden';
|
start.style.visibility = 'hidden';
|
||||||
stop.style.visibility = 'visible';
|
stop.style.visibility = 'visible';
|
||||||
running = true;
|
running = true;
|
||||||
|
steps();
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopChip(){
|
function stopChip(){
|
||||||
@ -156,7 +226,8 @@ function stopChip(){
|
|||||||
|
|
||||||
function resetChip(){
|
function resetChip(){
|
||||||
stopChip();
|
stopChip();
|
||||||
initChip();
|
setStatus('resetting 6502...');
|
||||||
|
setTimeout(initChip,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function stepForward(){
|
function stepForward(){
|
||||||
@ -174,17 +245,40 @@ function stepBack(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function chipStatus(){
|
function chipStatus(){
|
||||||
var pc = readAddressBus();
|
var ab = readAddressBus();
|
||||||
setStatus('PC:', hexWord(pc),
|
var machine1 =
|
||||||
'D:', hexByte(readDataBus()),
|
' halfcyc:' + cycle +
|
||||||
'SP:',hexByte(readSP()),
|
' phi0:' + readBit('clk0') +
|
||||||
'cycle:', cycle, '<br>',
|
' AB:' + hexWord(ab) +
|
||||||
'A:', hexByte(readA()),
|
' D:' + hexByte(readDataBus()) +
|
||||||
'X:', hexByte(readX()),
|
' RnW:' + readBit('rw');
|
||||||
'Y:', hexByte(readY()),
|
var machine2 =
|
||||||
'P:', hexByte(readP())
|
' PC:' + hexWord(readPC()) +
|
||||||
);
|
' A:' + hexByte(readA()) +
|
||||||
selectCell(pc);
|
' X:' + hexByte(readX()) +
|
||||||
|
' Y:' + hexByte(readY()) +
|
||||||
|
' SP:' + hexByte(readSP()) +
|
||||||
|
' ' + readPstring();
|
||||||
|
var machine3 =
|
||||||
|
' Sync:' + readBit('sync')
|
||||||
|
' IRQ:' + readBit('irq') +
|
||||||
|
' NMI:' + readBit('nmi');
|
||||||
|
var machine4 =
|
||||||
|
' IR:' + hexByte(255 - readBits('notir', 8)) +
|
||||||
|
' idl:' + hexByte(255 - readBits('idl', 8)) +
|
||||||
|
' alu:' + hexByte(255 - readBits('alu', 8)) +
|
||||||
|
' TCstate:' + readBit('clock1') + readBit('clock2') +
|
||||||
|
readBit('t2') + readBit('t3') + readBit('t4') + readBit('t5');
|
||||||
|
var machine5 =
|
||||||
|
' notRdy0:' + readBit('notRdy0') +
|
||||||
|
' fetch:' + readBit('fetch') +
|
||||||
|
' clearIR:' + readBit('clearIR') +
|
||||||
|
' D1x1:' + readBit('D1x1');
|
||||||
|
setStatus(machine1 + "<br>" + machine2);
|
||||||
|
if (loglevel>2 && ctrace) {
|
||||||
|
console.log(machine1 + " " + machine2 + " " + machine3 + " " + machine4 + " " + machine5);
|
||||||
|
}
|
||||||
|
selectCell(ab);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMem(){
|
function getMem(){
|
||||||
|
94
nodenames.js
94
nodenames.js
@ -29,6 +29,14 @@ db5: 175,
|
|||||||
db4: 1393,
|
db4: 1393,
|
||||||
db7: 1349,
|
db7: 1349,
|
||||||
db6: 1591,
|
db6: 1591,
|
||||||
|
idl0: 116,
|
||||||
|
idl1: 576,
|
||||||
|
idl2: 1485,
|
||||||
|
idl3: 1284,
|
||||||
|
idl4: 1516,
|
||||||
|
idl5: 498,
|
||||||
|
idl6: 1537,
|
||||||
|
idl7: 529,
|
||||||
a1: 1234,
|
a1: 1234,
|
||||||
ab1: 451,
|
ab1: 451,
|
||||||
ab2: 1340,
|
ab2: 1340,
|
||||||
@ -67,6 +75,14 @@ s7: 1435,
|
|||||||
s6: 1212,
|
s6: 1212,
|
||||||
s5: 1098,
|
s5: 1098,
|
||||||
s4: 1702,
|
s4: 1702,
|
||||||
|
nots0: 418,
|
||||||
|
nots1: 1064,
|
||||||
|
nots2: 752,
|
||||||
|
nots3: 828,
|
||||||
|
nots4: 1603,
|
||||||
|
nots5: 601,
|
||||||
|
nots6: 1029,
|
||||||
|
nots7: 181,
|
||||||
rw: 1156,
|
rw: 1156,
|
||||||
x2: 1,
|
x2: 1,
|
||||||
x3: 1648,
|
x3: 1648,
|
||||||
@ -113,5 +129,81 @@ y5: 615,
|
|||||||
y4: 989,
|
y4: 989,
|
||||||
y7: 843,
|
y7: 843,
|
||||||
y6: 115,
|
y6: 115,
|
||||||
cclk: 943
|
cclk: 943, // aka cp2
|
||||||
|
clock1: 156,
|
||||||
|
clock2: 1536,
|
||||||
|
notir7: 1320,
|
||||||
|
notir6: 895, // OK
|
||||||
|
notir5: 1394, // OK
|
||||||
|
notir4: 26,
|
||||||
|
notir3: 1125,
|
||||||
|
notir2: 1182,
|
||||||
|
notir1: 702,
|
||||||
|
notir0: 194,
|
||||||
|
t2: 971,
|
||||||
|
t3: 1567,
|
||||||
|
t4: 690,
|
||||||
|
t5: 909,
|
||||||
|
cp1: 710,
|
||||||
|
fetch: 879,
|
||||||
|
clearIR: 1077,
|
||||||
|
D1x1: 827,
|
||||||
|
notRdy0: 248,
|
||||||
|
alu0: 394,
|
||||||
|
alu1: 697,
|
||||||
|
alu2: 276,
|
||||||
|
alu3: 495,
|
||||||
|
alu4: 1490,
|
||||||
|
alu5: 893,
|
||||||
|
alu6: 68,
|
||||||
|
alu7: 1123,
|
||||||
|
adl0: 413,
|
||||||
|
adl1: 1282,
|
||||||
|
adl2: 1242,
|
||||||
|
adl3: 684,
|
||||||
|
adl4: 1437,
|
||||||
|
adl5: 1630,
|
||||||
|
adl6: 121,
|
||||||
|
adl7: 1299,
|
||||||
|
adh0: 407,
|
||||||
|
adh1: 52,
|
||||||
|
adh2: 1651,
|
||||||
|
adh3: 315,
|
||||||
|
adh4: 1160,
|
||||||
|
adh5: 483,
|
||||||
|
adh6: 13,
|
||||||
|
adh7: 1539,
|
||||||
|
sb0: 54,
|
||||||
|
sb1: 1150,
|
||||||
|
sb2: 1287,
|
||||||
|
sb3: 1188,
|
||||||
|
sb4: 1405,
|
||||||
|
sb5: 166,
|
||||||
|
sb6: 1336,
|
||||||
|
sb7: 1001,
|
||||||
|
idb0: 1108,
|
||||||
|
idb1: 991,
|
||||||
|
idb2: 1473,
|
||||||
|
idb3: 1302,
|
||||||
|
idb4: 892,
|
||||||
|
idb5: 1503,
|
||||||
|
idb6: 833,
|
||||||
|
idb7: 493,
|
||||||
|
dor0: 222,
|
||||||
|
dor1: 527,
|
||||||
|
dor2: 1288,
|
||||||
|
dor3: 823,
|
||||||
|
dor4: 873,
|
||||||
|
dor5: 1266,
|
||||||
|
dor6: 1418,
|
||||||
|
dor7: 158,
|
||||||
|
pd0: 758,
|
||||||
|
pd1: 361,
|
||||||
|
pd2: 955,
|
||||||
|
pd3: 894,
|
||||||
|
pd4: 369,
|
||||||
|
pd5: 829,
|
||||||
|
pd6: 1669,
|
||||||
|
pd7: 1690,
|
||||||
|
h1x1: 1042, // drive status byte onto databus
|
||||||
}
|
}
|
||||||
|
11
segdefs.js
11
segdefs.js
@ -1,3 +1,14 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2010 Greg James, Brian Silverman, Barry Silverman
|
||||||
|
|
||||||
|
The following is provided under terms of the Creative Commons
|
||||||
|
Attribution-NonCommercial-ShareAlike 3.0 Unported license:
|
||||||
|
http://creativecommons.org/licenses/by-nc-sa/3.0/
|
||||||
|
|
||||||
|
Specify the original author as Greg James and the following URL
|
||||||
|
for original source material: www.visual6502.org
|
||||||
|
*/
|
||||||
|
|
||||||
var segdefs = [
|
var segdefs = [
|
||||||
[ 0,'+',1,5391,8260,5391,8216,5357,8216,5357,8260],
|
[ 0,'+',1,5391,8260,5391,8216,5357,8216,5357,8260],
|
||||||
[ 0,'+',1,5391,7919,5391,7873,5356,7873,5356,7919],
|
[ 0,'+',1,5391,7919,5391,7873,5356,7873,5356,7919],
|
||||||
|
11
transdefs.js
11
transdefs.js
@ -1,3 +1,14 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2010 Greg James, Brian Silverman, Barry Silverman
|
||||||
|
|
||||||
|
The following is provided under terms of the Creative Commons
|
||||||
|
Attribution-NonCommercial-ShareAlike 3.0 Unported license:
|
||||||
|
http://creativecommons.org/licenses/by-nc-sa/3.0/
|
||||||
|
|
||||||
|
Specify the original author as Greg James and the following URL
|
||||||
|
for original source material: www.visual6502.org
|
||||||
|
*/
|
||||||
|
|
||||||
var transdefs = [
|
var transdefs = [
|
||||||
['t0', 357, 558, 217],
|
['t0', 357, 558, 217],
|
||||||
['t1', 1608, 657, 349],
|
['t1', 1608, 657, 349],
|
||||||
|
40
wires.css
40
wires.css
@ -1,8 +1,31 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: white;
|
background: white;
|
||||||
color: black;
|
color: black;
|
||||||
font-family: cursive;
|
/* font-family: cursive;*/
|
||||||
font-size: 30px;
|
font-family :Verdana, Arial, Helvetica, Sans-Serif;
|
||||||
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.frame {
|
div.frame {
|
||||||
@ -42,27 +65,30 @@ p.status {
|
|||||||
}
|
}
|
||||||
|
|
||||||
img.navbutton{
|
img.navbutton{
|
||||||
margin-left: -5px;
|
|
||||||
border: 0px;
|
border: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
img.navplay{
|
img.navplay{
|
||||||
margin-left: -5px;
|
position: relative;
|
||||||
|
margin-right: 5px;
|
||||||
border: 0px;
|
border: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
img.navstop{
|
img.navstop{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: -5px;
|
|
||||||
top: 9px;
|
|
||||||
border: 0px;
|
border: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.memtable {
|
table.memtable {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 63px;
|
top: 78px;
|
||||||
left: 820px;
|
left: 820px;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
border-spacing: 0px;
|
border-spacing: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#title {
|
||||||
|
font-size:30px;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
50
wires.js
50
wires.js
@ -26,8 +26,11 @@ var zoom=1;
|
|||||||
var dragMouseX, dragMouseY, moved;
|
var dragMouseX, dragMouseY, moved;
|
||||||
var statbox;
|
var statbox;
|
||||||
|
|
||||||
var colors = ['rgba(128,128,128,0.4)','#FFFF00','#FF00FF','#4DFF4D',
|
// Index of layerNames corresponds to index into drawLayers
|
||||||
|
var layernames = ['metal', 'switched diffusion', 'inputdiode', 'grounded diffusion', 'powered diffusion', 'polysilicon'];
|
||||||
|
var colors = ['rgba(128,128,192,0.4)','#FFFF00','#FF00FF','#4DFF4D',
|
||||||
'#FF4D4D','#801AC0','rgba(128,0,255,0.75)'];
|
'#FF4D4D','#801AC0','rgba(128,0,255,0.75)'];
|
||||||
|
var drawlayers = [true, true, true, true, true, true];
|
||||||
|
|
||||||
var nodes = new Array();
|
var nodes = new Array();
|
||||||
var transistors = {};
|
var transistors = {};
|
||||||
@ -42,11 +45,19 @@ var npwr = nodenames['vcc'];
|
|||||||
//
|
//
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
|
||||||
|
// try to present a meaningful page before starting expensive work
|
||||||
function setup(){
|
function setup(){
|
||||||
|
statbox = document.getElementById('status');
|
||||||
|
setStatus('loading 6502...');
|
||||||
|
setTimeout(setup_part2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup_part2(){
|
||||||
frame = document.getElementById('frame');
|
frame = document.getElementById('frame');
|
||||||
statbox = document.getElementById('status');
|
statbox = document.getElementById('status');
|
||||||
setupNodes();
|
setupNodes();
|
||||||
setupTransistors();
|
setupTransistors();
|
||||||
|
setupLayerVisibility();
|
||||||
setupBackground();
|
setupBackground();
|
||||||
setupOverlay();
|
setupOverlay();
|
||||||
setupHilite();
|
setupHilite();
|
||||||
@ -56,6 +67,11 @@ function setup(){
|
|||||||
setupTable();
|
setupTable();
|
||||||
window.onkeypress = function(e){handleKey(e);}
|
window.onkeypress = function(e){handleKey(e);}
|
||||||
hilite.onmousedown = function(e){mouseDown(e);}
|
hilite.onmousedown = function(e){mouseDown(e);}
|
||||||
|
setStatus('resetting 6502...');
|
||||||
|
setTimeout(setup_part3, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup_part3(){
|
||||||
initChip();
|
initChip();
|
||||||
document.getElementById('stop').style.visibility = 'hidden';
|
document.getElementById('stop').style.visibility = 'hidden';
|
||||||
go();
|
go();
|
||||||
@ -89,6 +105,14 @@ function setupTransistors(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupLayerVisibility(){
|
||||||
|
var x=document.getElementById('updateShow');
|
||||||
|
for (var i=0;i<x.childNodes.length;i++) {
|
||||||
|
if(x.childNodes[i].type='checkbox'){
|
||||||
|
x.childNodes[i].checked=drawlayers[x.childNodes[i].name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setupBackground(){
|
function setupBackground(){
|
||||||
chipbg = document.getElementById('chipbg');
|
chipbg = document.getElementById('chipbg');
|
||||||
@ -100,16 +124,16 @@ function setupBackground(){
|
|||||||
ctx.strokeStyle = 'rgba(255,255,255,0.5)';
|
ctx.strokeStyle = 'rgba(255,255,255,0.5)';
|
||||||
ctx.lineWidth = 4;
|
ctx.lineWidth = 4;
|
||||||
ctx.fillRect(0,0,10000,10000);
|
ctx.fillRect(0,0,10000,10000);
|
||||||
var start = now();
|
|
||||||
for(var i in segdefs){
|
for(var i in segdefs){
|
||||||
var seg = segdefs[i];
|
var seg = segdefs[i];
|
||||||
var c = seg[2];
|
var c = seg[2];
|
||||||
|
if (drawlayers[c]) {
|
||||||
ctx.fillStyle = colors[c];
|
ctx.fillStyle = colors[c];
|
||||||
drawSeg(ctx, segdefs[i].slice(3));
|
drawSeg(ctx, segdefs[i].slice(3));
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
if((c==0)||(c==6)) ctx.stroke();
|
if((c==0)||(c==6)) ctx.stroke();
|
||||||
}
|
}
|
||||||
// console.log('time to draw: ', now() - start, ' ms');
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupOverlay(){
|
function setupOverlay(){
|
||||||
@ -189,6 +213,7 @@ function hiliteNode(n){
|
|||||||
|
|
||||||
|
|
||||||
function drawSeg(ctx, seg){
|
function drawSeg(ctx, seg){
|
||||||
|
if(noGraphics) return;
|
||||||
var dx = 400;
|
var dx = 400;
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(seg[0]+dx, 10000-seg[1])
|
ctx.moveTo(seg[0]+dx, 10000-seg[1])
|
||||||
@ -288,6 +313,11 @@ function findNodeNumber(x,y){
|
|||||||
return (high<<8)+(mid<<4)+low;
|
return (high<<8)+(mid<<4)+low;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateShow(layer, on){
|
||||||
|
drawlayers[layer]=on;
|
||||||
|
setupBackground();
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
//
|
//
|
||||||
// Etc.
|
// Etc.
|
||||||
@ -305,21 +335,11 @@ function setChipStyle(props){
|
|||||||
|
|
||||||
|
|
||||||
function localx(el, gx){
|
function localx(el, gx){
|
||||||
var lx = gx+window.pageXOffset;
|
return gx-el.getBoundingClientRect().left;
|
||||||
while(el.offsetLeft!=undefined){
|
|
||||||
lx-=el.offsetLeft+el.clientLeft;
|
|
||||||
el = el.parentNode;
|
|
||||||
}
|
|
||||||
return lx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function localy(el, gy){
|
function localy(el, gy){
|
||||||
var ly = gy+window.pageYOffset;
|
return gy-el.getBoundingClientRect().top;
|
||||||
while(el.offsetTop!=undefined){
|
|
||||||
ly-=el.offsetTop+el.clientTop;
|
|
||||||
el = el.parentNode;
|
|
||||||
}
|
|
||||||
return ly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus(){
|
function setStatus(){
|
||||||
|
Reference in New Issue
Block a user