mirror of
https://github.com/trebonian/visual6502.git
synced 2024-12-22 12:29:20 +00:00
[dev]user program can be defined in url, can run for chosen number of steps
This commit is contained in:
parent
c8aabd6baa
commit
f0536dc716
27
macros.js
27
macros.js
@ -29,20 +29,31 @@ var trace = Array();
|
||||
var logstream = Array();
|
||||
var running = false;
|
||||
|
||||
function go(n){
|
||||
function loadProgram(){
|
||||
if(userCode.length!=0)
|
||||
code=userCode;
|
||||
// default reset vector will be 0x0000 because undefined memory reads as zero
|
||||
if(userResetLow!=undefined)
|
||||
mWrite(0xfffc, userResetLow);
|
||||
if(userResetHigh!=undefined)
|
||||
mWrite(0xfffd, userResetHigh);
|
||||
for(var i=0;i<code.length;i++){
|
||||
mWrite(i, code[i]);
|
||||
if(i<0x200)
|
||||
setCellValue(i, code[i]);
|
||||
}
|
||||
mWrite(0xfffc, 0x00);
|
||||
mWrite(0xfffd, 0x00);
|
||||
steps();
|
||||
}
|
||||
|
||||
function steps(){
|
||||
function go(){
|
||||
if(userSteps!=undefined){
|
||||
if(--userSteps==0){
|
||||
running=false;
|
||||
userSteps=undefined;
|
||||
}
|
||||
}
|
||||
if(running) {
|
||||
step();
|
||||
setTimeout(steps, 0); // schedule the next poll
|
||||
setTimeout(go, 0); // schedule the next poll
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +110,7 @@ function initChip(){
|
||||
recalcNodeList(allNodes());
|
||||
for(var i=0;i<8;i++){setHigh('clk0'), setLow('clk0');}
|
||||
setHigh('res');
|
||||
for(var i=0;i<18;i++){halfStep();}
|
||||
for(var i=0;i<18;i++){halfStep();} // avoid updating graphics and trace buffer before user code
|
||||
refresh();
|
||||
cycle = 0;
|
||||
trace = Array();
|
||||
@ -284,7 +295,7 @@ function runChip(){
|
||||
start.style.visibility = 'hidden';
|
||||
stop.style.visibility = 'visible';
|
||||
running = true;
|
||||
steps();
|
||||
go();
|
||||
}
|
||||
|
||||
function stopChip(){
|
||||
|
@ -59,6 +59,8 @@ function cellKeydown(e){
|
||||
}
|
||||
|
||||
function setCellValue(n, val){
|
||||
if(val==undefined)
|
||||
val=0x00;
|
||||
val%=256;
|
||||
cellEl(n).val=val;
|
||||
cellEl(n).innerHTML=hexByte(val);
|
||||
|
17
wires.js
17
wires.js
@ -44,6 +44,10 @@ var moveHereFirst;
|
||||
var expertMode=false
|
||||
var animateChipLayout = true;
|
||||
var chipLayoutIsVisible = true;
|
||||
var userCode=[];
|
||||
var userResetLow;
|
||||
var userResetHigh;
|
||||
var userSteps;
|
||||
|
||||
/////////////////////////
|
||||
//
|
||||
@ -78,6 +82,7 @@ function setup_part2(){
|
||||
function setup_part3(){
|
||||
setupTable();
|
||||
setupNodeNameList();
|
||||
loadProgram();
|
||||
initChip();
|
||||
document.getElementById('stop').style.visibility = 'hidden';
|
||||
go();
|
||||
@ -90,6 +95,7 @@ function setupParams(){
|
||||
var panx;
|
||||
var pany;
|
||||
var zoom;
|
||||
var userAddress;
|
||||
for(var i=0;i<queryParts.length;i++){
|
||||
var params=queryParts[i].split("=");
|
||||
if(params.length!=2){
|
||||
@ -112,6 +118,17 @@ function setupParams(){
|
||||
pany=parseInt(value);
|
||||
} else if(name=="zoom" && parseInt(value)!=NaN){
|
||||
zoom=parseInt(value);
|
||||
} else if(name=="steps" && parseInt(value)!=NaN){
|
||||
userSteps=parseInt(value);
|
||||
running=true;
|
||||
} else 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<value.length;j+=2)
|
||||
userCode[userAddress++]=parseInt(value.slice(j,j+2),16);
|
||||
} else if(name=="r" && parseInt(value,16)!=NaN){
|
||||
userResetLow=parseInt(value,16)%256;
|
||||
userResetHigh=(parseInt(value,16)>>8)%256;
|
||||
} else {
|
||||
if(loglevel>0)
|
||||
console.log('unrecognised parameters:',params);
|
||||
|
Loading…
Reference in New Issue
Block a user