var memory = Array(); var code = [0xa9, 0x00, 0x20, 0x10, 0x00, 0x4c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8, 0x88, 0xe6, 0x40, 0x38, 0x69, 0x02, 0x60]; var cycle = 0; var trace = Array(); var running = false; function go(n){ for(var i=0;i>=1; } recalcNodeList(recalcs); } function mRead(a){ if(memory[a]==undefined) return 0; else return memory[a]; } function mWrite(a, d){memory[a]=d;} function clkNodes(){ var res = Array(); res.push(943); for(var i in nodes[943].gates){ var t = transistors[nodes[943].gates[i]]; if(t.c1==npwr) res.push(t.c2); if(t.c2==npwr) res.push(t.c1); } hiliteNode(res); } function runChip(){ var start = document.getElementById('start'); var stop = document.getElementById('stop'); start.style.visibility = 'hidden'; stop.style.visibility = 'visible'; running = true; } function stopChip(){ var start = document.getElementById('start'); var stop = document.getElementById('stop'); start.style.visibility = 'visible'; stop.style.visibility = 'hidden'; running = false; } function resetChip(){ stopChip(); initChip(); } function stepForward(){ stopChip(); step(); } function stepBack(){ if(cycle==0) return; showState(trace[--cycle].chip); setMem(trace[cycle].mem); var clk = isNodeHigh(nodenames['clk0']); if(!clk) writeDataBus(mRead(readAddressBus())); chipStatus(); } function chipStatus(){ var pc = readAddressBus(); setStatus('PC:', hexWord(pc), 'D:', hexByte(readDataBus()), 'SP:',hexByte(readSP()), 'cycle:', cycle, '
', 'A:', hexByte(readA()), 'X:', hexByte(readX()), 'Y:', hexByte(readY()), 'P:', hexByte(readP()) ); selectCell(pc); } function getMem(){ var res = Array(); for(var i=0;i<0x200;i++) res.push(mRead(i)); return res; } function setMem(arr){ for(var i=0;i<0x200;i++){mWrite(i, arr[i]); setCellValue(i, arr[i]);} } function hexWord(n){return (0x10000+n).toString(16).substring(1)} function hexByte(n){return (0x100+n).toString(16).substring(1)}