From f6f467787afe3f751d6ba282e4a09f948c3eae60 Mon Sep 17 00:00:00 2001 From: BigEd Date: Sat, 25 Sep 2010 21:32:29 +0000 Subject: [PATCH] [dev]first (untidy) implementation of expert mode with tabular logging --- index.html | 6 ++++++ macros.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++-------- wires.css | 8 +++++++- wires.js | 10 ++++++++++ 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 6f2af7b..f09b358 100644 --- a/index.html +++ b/index.html @@ -65,11 +65,15 @@ Enter your own program into the array of RAM +
Expert: + +

x: 0
y: 0

+
Source code is available on GitHub: http://github.com/trebonian/visual6502
diff --git a/macros.js b/macros.js index 219db8b..3b12fbb 100644 --- a/macros.js +++ b/macros.js @@ -26,6 +26,7 @@ var code = [0xa9, 0x00, 0x20, 0x10, 0x00, 0x4c, 0x02, 0x00, 0xe8, 0x88, 0xe6, 0x40, 0x38, 0x69, 0x02, 0x60]; var cycle = 0; var trace = Array(); +var logstream = Array(); var running = false; function go(n){ @@ -103,10 +104,13 @@ function initChip(){ refresh(); cycle = 0; trace = Array(); + initLogbox(logThese); chipStatus(); if(ctrace)console.log('initChip done after', now()-start); } +var logThese=['sync','irq','nmi','ab','db','rw','pc','a','x','y','s']; + function step(){ trace[cycle]= {chip: stateString(), mem: getMem()}; halfStep(); @@ -175,6 +179,24 @@ function readBits(name, n){ return res; } +function hexBus(busname){ + var nodenamelist=[]; + // console.log('hexBus called: ' + busname); + for(i in nodenames){nodenamelist.push(i)}; + if(busname=='pc') + return hexBus('pch') + hexBus('pcl'); + var width=0; + for(var i in nodenamelist){ + if(nodenamelist[i].search("^"+busname+"[0-9]")==0) + width++; + } + if(width==0) + return isNodeHigh(nodenames[busname])?1:0; + if(width>16) + return -1; + return (0x10000+readBits(busname,width)).toString(16).slice(-width/4); +} + function writeDataBus(x){ var recalcs = Array(); for(var i=0;i<8;i++){ @@ -259,29 +281,48 @@ function chipStatus(){ ' Y:' + hexByte(readY()) + ' SP:' + hexByte(readSP()) + ' ' + readPstring(); + setStatus(machine1 + "
" + machine2); + if (loglevel>1) { + updateLogbox(logThese); + } + selectCell(ab); +} + +function initLogbox(names){ + logStream = []; + logStream.push("" + names.join("") + ""); +} + +function updateLogbox(names){ + var logbox=document.getElementById('logstream'); + var signals=[]; + + for(i in names){ + signals.push(hexBus(names[i])); + } + logStream.push("" + signals.join("") + ""); + + logbox.innerHTML = ""+logStream.join("")+""; + + var machine3 = - ' Sync:' + readBit('sync') + ' Sync:' + readBit('sync') + ' IRQ:' + readBit('irq') + ' NMI:' + readBit('nmi'); var machine4 = - ' IR:' + hexByte(255 - readBits('notir', 8)) + + ' IR:' + hexByte(readBits('ir', 8)) + ' TCstate:' + readBit('clock1') + readBit('clock2') + readBit('t2') + readBit('t3') + readBit('t4') + readBit('t5'); var machine5 = ' idl:' + hexByte(readBits('idl', 8)) + ' alu:' + hexByte(readBits('alu', 8)) + - ' idb:' +hexByte(readBits('idb',8)) + + ' idb:' + hexByte(readBits('idb',8)) + ' dor:' + hexByte(readBits('dor',8)); var machine6 = ' notRdy0:' + readBit('notRdy0') + ' fetch:' + readBit('fetch') + ' clearIR:' + readBit('clearIR') + ' D1x1:' + readBit('D1x1'); - setStatus(machine1 + "
" + machine2); - if (loglevel>2) { - console.log(machine1 + " " + machine2 + " " + machine3 + " " + machine4 + " " + machine5); - } - selectCell(ab); } function getMem(){ diff --git a/wires.css b/wires.css index 185b6df..8345762 100644 --- a/wires.css +++ b/wires.css @@ -79,6 +79,12 @@ img.navstop{ border: 0px; } +table.logstream { + font-family: monospace; + font-size: 12px; + border-spacing: 1px; +} + table.memtable { position: absolute; top: 78px; @@ -91,4 +97,4 @@ table.memtable { #title { font-size:30px; font-weight:bold; -} \ No newline at end of file +} diff --git a/wires.js b/wires.js index 6b32524..816a5e3 100644 --- a/wires.js +++ b/wires.js @@ -319,6 +319,16 @@ function findNodeNumber(x,y){ return (high<<8)+(mid<<4)+low; } +function updateExpertMode(on){ + if(on){ + document.getElementById('controlPanel').style.visibility = 'visible'; + loglevel=4; + } else { + document.getElementById('controlPanel').style.visibility = 'hidden'; + loglevel=0; + } +} + function updateShow(layer, on){ drawlayers[layer]=on; setupBackground();