diff --git a/wires.css b/expert.css similarity index 100% rename from wires.css rename to expert.css diff --git a/expert.html b/expert.html new file mode 100644 index 0000000..fee9d7e --- /dev/null +++ b/expert.html @@ -0,0 +1,103 @@ + + + +Visual 6502 in JavaScript + + + + + + + + + + + + + + + + + +FAQ  +Blog  +Links  + +
+
+
+
+Please wait, graphics initialising... + + + + +
+
+
+
+ +
+
+
+
Show: + (diffusion) + (grounded diffusion) + (powered diffusion) + (polysilicon) + (metal) + (protection) +
+
+ + + + Animate during simulation: + +   + Link to this location +
+
+
+
+ + +
+
+
+
+
+
+
+
+
+
+ + +
+
+ + + +
+
+

x: 0
y: 0

+
+
+
+
+ + diff --git a/expertWires.js b/expertWires.js new file mode 100644 index 0000000..d07ece7 --- /dev/null +++ b/expertWires.js @@ -0,0 +1,341 @@ +/* + 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 centerx=300, centery=300; +var zoom=1; +var dragMouseX, dragMouseY, moved; +var statbox; + +// Some constants for the graphics presentation +// the canvas is embedded in an 800x600 clipping div +// which gives rise to some of the 300 and 400 values in the code +// there are also some 600 values +// the 6502D chip coords are in the box (216,179) to (8983,9807) +// we have 4 canvases all the same size, now 2000 pixels square +// chip background - the layout +// overlay - a red/white transparency to show logic high or low +// hilite - to show the selected polygon +// hitbuffer - abusing color values to return which polygon is under a point +// we no longer use a scaling transform - we now scale the chip data at +// the point of drawing line segments +// if the canvas is any smaller than chip coordinates there will be +// rounding artifacts, and at high zoom there will be anti-aliasing on edges. +var grMaxZoom=12; +var grChipSize=10000; +var grCanvasSize=2000; +var grLineWidth=1; + +// 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)']; +var drawlayers = [true, true, true, true, true, true]; + +// some modes and parameters which can be passed in from the URL query +var moveHereFirst; +var expertMode=false +var animateChipLayout = true; +var chipLayoutIsVisible = true; +var userCode=[]; +var userResetLow; +var userResetHigh; +var userSteps; +var testprogram=[]; +var testprogramAddress; + +///////////////////////// +// +// Drawing Setup +// +///////////////////////// + +// try to present a meaningful page before starting expensive work +function setup(){ + statbox = document.getElementById('status'); + setStatus('loading 6502...'); + setTimeout(setup_part2, 0); +} + +function setup_part2(){ + frame = document.getElementById('frame'); + statbox = document.getElementById('status'); + setupParams(); + updateExpertMode(expertMode); + setupNodes(); + setupTransistors(); + if(chipLayoutIsVisible){ + // if user requests no chip layout, we can do no canvas operations at all + // which saves a lot of memory and allows us to run on small systems + updateChipLayoutVisibility(true); + } + window.onkeypress = function(e){handleKey(e);} + setStatus('resetting 6502...'); + setTimeout(setup_part3, 0); +} + +function setup_part3(){ + setupTable(); + setupNodeNameList(); + loadProgram(); + initChip(); + document.getElementById('stop').style.visibility = 'hidden'; + go(); +} + +function setupParams(){ + if(location.search=="") + return + var queryParts=location.search.slice(1).split('&'); + var panx; + var pany; + var zoom; + var userAddress; + for(var i=0;i0) + console.log('malformed parameters',params); + break; + } + var name=params[0]; + var value=params[1].replace(/\/$/,""); // chrome sometimes adds trailing slash + // be (relatively) forgiving in what we accept + // + // user interface mode control + if(name=="loglevel" && parseInt(value)!=NaN){ + updateLoglevel(value); + } else if(name=="expert" && value.indexOf("t")==0){ + updateExpertMode(true); + } else if(name=="graphics" && value.indexOf("f")==0){ + updateChipLayoutVisibility(false); + } else + // place the graphics window at a point of interest + if(name=="panx" && parseInt(value)!=NaN){ + panx=parseInt(value); + } else if(name=="pany" && parseInt(value)!=NaN){ + pany=parseInt(value); + } else if(name=="zoom" && parseInt(value)!=NaN){ + zoom=parseInt(value); + } else + // load a test program: Address, Data and Reset + if(name=="a" && parseInt(value,16)!=NaN){ + userAddress=parseInt(value,16); + } else if(name=="d" && value.match(/[0-9a-fA-F]*/)[0].length==value.length){ + for(var j=0;j>8)%256; + } else + // run a test program, and optionally check against a golden checksum + if(name=="steps" && parseInt(value)!=NaN){ + userSteps=parseInt(value); + running=true; + } else if(name=="checksum" && parseInt(value,16)!=NaN){ + goldenChecksum=(0x100000000+parseInt(value,16)).toString(16).slice(-8); + } else { + if(loglevel>0) + console.log('unrecognised parameters:',params); + break; + } + } + if(panx!=null && pany!=null && zoom!=null) + moveHereFirst=[panx,pany,zoom]; +} + +function updateChipLayoutAnimation(isOn){ + // simulation is much faster if we don't update the chip layout on every step + animateChipLayout=isOn; + document.getElementById('animateModeCheckbox').checked = animateChipLayout; +} + +///////////////////////// +// +// User Interface +// +///////////////////////// + +function handleKey(e){ + var c = e.charCode; + c = String.fromCharCode(c); + if('<>?npZzx'.indexOf(c)==-1) return; + if((c=='Z'||c=='x'||c=='<') && zoom>1) setZoom(zoom/1.2); + else if((c=='z'||c=='>') && zoom@import "wires.css"; + + @@ -29,30 +30,10 @@ function handleOnload() { - FAQ  Blog  Links  -
-

-This simulator uses HTML5 features only found on the latest versions of browsers and needs -lots of RAM. If you have trouble, please check compatibility. -
- -
-Hit '>' to zoom in, '<' to zoom out -
-Left-click and drag to scroll around -
-Enter your own program into the array of RAM -
-
-
@@ -111,36 +92,12 @@ Enter your own program into the array of RAM - Expert: - -

x: 0
y: 0

- - - - - diff --git a/kiosk.css b/kiosk.css new file mode 100644 index 0000000..185b6df --- /dev/null +++ b/kiosk.css @@ -0,0 +1,94 @@ +/* + 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 { + background: white; + color: black; +/* font-family: cursive;*/ + font-family :Verdana, Arial, Helvetica, Sans-Serif; + font-size: 12px; +} + +div.frame { + margin-left: 10px; + position: relative; + width: 1150px; + height: 600px; +} + +div.chip { + background: lightgray; + border: 2px solid gray; + position: absolute; + width: 800px; + height: 600px; + overflow: hidden; +} + +canvas.chip { + position: absolute; + width: 600px; + height: 600px; +} + +div.buttons{ + position: absolute; + top: -5px; + left: 820px; +} + +p.status { + position: absolute; + left: 820px; + top: 20px; + font-family: monospace; + font-size: 12px; +} + +img.navbutton{ + border: 0px; +} + +img.navplay{ + position: relative; + margin-right: 5px; + border: 0px; +} + +img.navstop{ + position: absolute; + border: 0px; +} + +table.memtable { + position: absolute; + top: 78px; + left: 820px; + font-family: monospace; + font-size: 12px; + border-spacing: 0px; +} + +#title { +font-size:30px; +font-weight:bold; +} \ No newline at end of file diff --git a/kiosk.html b/kiosk.html new file mode 100644 index 0000000..3fed961 --- /dev/null +++ b/kiosk.html @@ -0,0 +1,100 @@ + + + +Visual 6502 in JavaScript + + + + + + + + + + + + + + + + +
+The Visual 6502 + +
+FAQ  +Blog  +Links  +

+This simulator uses HTML5 features only found on the latest versions of browsers and needs +lots of RAM. If you have trouble, please check compatibility. +
+ +
+Hit '>' to zoom in, '<' to zoom out +
+Left-click and drag to scroll around +
+Enter your own program into the array of RAM +
+
+
+
+
+ + + + +
+
+
+ + +
+
+ + + +
+
+

x: 0
y: 0

+
+
+
+
+
+
+Source code is available on github visual6502. +Use the online emulator and assembler from 6502asm.com +and disassembler from e-tradition.net +
+For in-depth 6502 investigation and some more advanced features, try our Experimenter's (Beta) version. +
+
+ + + + + + diff --git a/kioskWires.js b/kioskWires.js new file mode 100644 index 0000000..14df22d --- /dev/null +++ b/kioskWires.js @@ -0,0 +1,198 @@ +/* + 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 centerx=300, centery=300; +var zoom=1; +var dragMouseX, dragMouseY, moved; +var statbox; +var userSteps; +var animateChipLayout = true; +var userCode=[]; +var userResetLow; +var userResetHigh; + +// Some constants for the graphics presentation +// the canvas is embedded in an 800x600 clipping div +// which gives rise to some of the 300 and 400 values in the code +// there are also some 600 values +// the 6502D chip coords are in the box (216,179) to (8983,9807) +// we have 4 canvases all the same size, now 2000 pixels square +// chip background - the layout +// overlay - a red/white transparency to show logic high or low +// hilite - to show the selected polygon +// hitbuffer - abusing color values to return which polygon is under a point +// we no longer use a scaling transform - we now scale the chip data at +// the point of drawing line segments +// if the canvas is any smaller than chip coordinates there will be +// rounding artifacts, and at high zoom there will be anti-aliasing on edges. +var grMaxZoom=12; +var grChipSize=10000; +var grCanvasSize=2000; +var grLineWidth=1; + +// 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)']; +var drawlayers = [true, true, true, true, true, true]; + +///////////////////////// +// +// Drawing Setup +// +///////////////////////// + +// try to present a meaningful page before starting expensive work +function setup(){ + statbox = document.getElementById('status'); + setStatus('loading 6502...'); + setTimeout(setup_part2, 0); +} + +function setup_part2(){ + frame = document.getElementById('frame'); + statbox = document.getElementById('status'); + setupNodes(); + setupTransistors(); + setupLayerVisibility(); + setupBackground(); + setupOverlay(); + setupHilite(); + setupHitBuffer(); + recenter(); + refresh(); + setupTable(); + window.onkeypress = function(e){handleKey(e);} + hilite.onmousedown = function(e){mouseDown(e);} + setStatus('resetting 6502...'); + setTimeout(setup_part3, 0); +} + +function setup_part3(){ + loadProgram(); + initChip(); + document.getElementById('stop').style.visibility = 'hidden'; + go(); +} + + +///////////////////////// +// +// User Interface +// +///////////////////////// + +function handleKey(e){ + var c = e.charCode; + c = String.fromCharCode(c); + if('<>?np'.indexOf(c)==-1) return; + if(c=='<' && zoom>1) setZoom(zoom/1.2); + else if(c=='>' && zoom','y:',cy); + else { + var s1='x: ' + cx + ' y: ' + cy; + var s2='node: ' + w + ' ' + nodeName(w); + setStatus(s1, s2); + } +} + +///////////////////////// +// +// Etc. +// +///////////////////////// + +function setChipStyle(props){ + for(var i in props){ + chipbg.style[i] = props[i]; + overlay.style[i] = props[i]; + hilite.style[i] = props[i]; + hitbuffer.style[i] = props[i]; + } +} + diff --git a/macros.js b/macros.js index d70e49c..0041fd7 100644 --- a/macros.js +++ b/macros.js @@ -403,6 +403,8 @@ function estimatedHz(){ function initLogbox(names){ var logbox=document.getElementById('logstream'); + if(logbox==null)return; + logStream = []; logStream.push("" + names.join("") + ""); logbox.innerHTML = ""+logStream.join("")+""; diff --git a/save.php b/save.php deleted file mode 100644 index e3c5737..0000000 --- a/save.php +++ /dev/null @@ -1,18 +0,0 @@ - - diff --git a/wires.js b/wires.js index 4ca0d25..f07fe1e 100644 --- a/wires.js +++ b/wires.js @@ -21,36 +21,6 @@ */ var frame, chipbg, overlay, hilite, hitbuffer, ctx; -var centerx=300, centery=300; -var zoom=1; -var dragMouseX, dragMouseY, moved; -var statbox; - -// Some constants for the graphics presentation -// the canvas is embedded in an 800x600 clipping div -// which gives rise to some of the 300 and 400 values in the code -// there are also some 600 values -// the 6502D chip coords are in the box (216,179) to (8983,9807) -// we have 4 canvases all the same size, now 2000 pixels square -// chip background - the layout -// overlay - a red/white transparency to show logic high or low -// hilite - to show the selected polygon -// hitbuffer - abusing color values to return which polygon is under a point -// we no longer use a scaling transform - we now scale the chip data at -// the point of drawing line segments -// if the canvas is any smaller than chip coordinates there will be -// rounding artifacts, and at high zoom there will be anti-aliasing on edges. -var grMaxZoom=12; -var grChipSize=10000; -var grCanvasSize=2000; -var grLineWidth=1; - -// 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)']; -var drawlayers = [true, true, true, true, true, true]; - var nodes = new Array(); var transistors = {}; var nodenamelist=[]; @@ -58,124 +28,6 @@ var nodenamelist=[]; var ngnd = nodenames['vss']; var npwr = nodenames['vcc']; -// some modes and parameters which can be passed in from the URL query -var moveHereFirst; -var expertMode=false -var animateChipLayout = true; -var chipLayoutIsVisible = true; -var userCode=[]; -var userResetLow; -var userResetHigh; -var userSteps; -var testprogram=[]; -var testprogramAddress; - -///////////////////////// -// -// Drawing Setup -// -///////////////////////// - -// try to present a meaningful page before starting expensive work -function setup(){ - statbox = document.getElementById('status'); - setStatus('loading 6502...'); - setTimeout(setup_part2, 0); -} - -function setup_part2(){ - frame = document.getElementById('frame'); - statbox = document.getElementById('status'); - setupParams(); - updateExpertMode(expertMode); - setupNodes(); - setupTransistors(); - if(chipLayoutIsVisible){ - // if user requests no chip layout, we can do no canvas operations at all - // which saves a lot of memory and allows us to run on small systems - updateChipLayoutVisibility(true); - } - window.onkeypress = function(e){handleKey(e);} - setStatus('resetting 6502...'); - setTimeout(setup_part3, 0); -} - -function setup_part3(){ - setupTable(); - setupNodeNameList(); - loadProgram(); - initChip(); - document.getElementById('stop').style.visibility = 'hidden'; - go(); -} - -function setupParams(){ - if(location.search=="") - return - var queryParts=location.search.slice(1).split('&'); - var panx; - var pany; - var zoom; - var userAddress; - for(var i=0;i0) - console.log('malformed parameters',params); - break; - } - var name=params[0]; - var value=params[1].replace(/\/$/,""); // chrome sometimes adds trailing slash - // be (relatively) forgiving in what we accept - // - // user interface mode control - if(name=="loglevel" && parseInt(value)!=NaN){ - updateLoglevel(value); - } else if(name=="expert" && value.indexOf("t")==0){ - updateExpertMode(true); - } else if(name=="graphics" && value.indexOf("f")==0){ - updateChipLayoutVisibility(false); - } else - // place the graphics window at a point of interest - if(name=="panx" && parseInt(value)!=NaN){ - panx=parseInt(value); - } else if(name=="pany" && parseInt(value)!=NaN){ - pany=parseInt(value); - } else if(name=="zoom" && parseInt(value)!=NaN){ - zoom=parseInt(value); - } else - // load a test program: Address, Data and Reset - if(name=="a" && parseInt(value,16)!=NaN){ - userAddress=parseInt(value,16); - } else if(name=="d" && value.match(/[0-9a-fA-F]*/)[0].length==value.length){ - for(var j=0;j>8)%256; - } else - // run a test program, and optionally check against a golden checksum - if(name=="steps" && parseInt(value)!=NaN){ - userSteps=parseInt(value); - running=true; - } else if(name=="checksum" && parseInt(value,16)!=NaN){ - goldenChecksum=(0x100000000+parseInt(value,16)).toString(16).slice(-8); - } else { - if(loglevel>0) - console.log('unrecognised parameters:',params); - break; - } - } - if(panx!=null && pany!=null && zoom!=null) - moveHereFirst=[panx,pany,zoom]; -} - -function updateChipLayoutAnimation(isOn){ - // simulation is much faster if we don't update the chip layout on every step - animateChipLayout=isOn; - document.getElementById('animateModeCheckbox').checked = animateChipLayout; -} - function setupNodes(){ for(var i in segdefs){ var seg = segdefs[i]; @@ -278,8 +130,6 @@ function hexdigit(n){return '0123456789ABCDEF'.charAt(n);} ///////////////////////// function refresh(){ - if(!chipLayoutIsVisible) - return; ctx.clearRect(0,0,grCanvasSize,grCanvasSize); for(i in nodes){ if(isNodeHigh(i)) overlayNode(nodes[i].segs); @@ -316,95 +166,6 @@ function drawSeg(ctx, seg){ ctx.lineTo(grScale(seg[0]+dx), grScale(grChipSize-seg[1])); } -///////////////////////// -// -// User Interface -// -///////////////////////// - -function handleKey(e){ - var c = e.charCode; - c = String.fromCharCode(c); - if('<>?npZzx'.indexOf(c)==-1) return; - if((c=='Z'||c=='x'||c=='<') && zoom>1) setZoom(zoom/1.2); - else if((c=='z'||c=='>') && zoom