added a reset function

This commit is contained in:
Preston Skupinski 2011-07-11 19:04:51 -04:00
parent 5ada2b1daa
commit 4a9456f83f
2 changed files with 17 additions and 2 deletions

17
cpu.js
View File

@ -251,7 +251,8 @@ function CPU_65816() {
this.execute = function(raw_hex, has_header) {
this.mmu.load_rom(raw_hex);
this.r.pc = 0x8000;
// Skip the header(the first 512 bytes) if there is one present for now.
if(has_header) {
this.r.pc += 4096;
}
@ -366,6 +367,15 @@ function CPU_65816() {
executing = false;
}
};
this.reset = function() {
this.waiting = false;
this.stopped = false;
this.interrupt = this.INTERRUPT.NO_INTERRUPT;
this.r = { a:0, b:0, x:0, y:0, d:0, s:0xff, pc:0, dbr:0, k:0 };
this.p = { e:1, c:0, z:0, i:0, d:0, x:0, m:0, v:0, n:0 };
this.mmu.reset();
};
}
var MMU = {
@ -373,6 +383,11 @@ var MMU = {
memory: { 0: {} },
memory_mapped_io_devices: {},
reset: function() {
this.memory ={ 0: {} };
this.memory_mapped_io_devices = {};
},
add_memory_mapped_io_device: function(write_callback, read_callback, bank,
location) {
if(typeof this.memory_mapped_io_devices[bank] === 'undefined') {

View File

@ -13,7 +13,7 @@ $(document).ready(function() {
updateFields();
});
$("#reset").click(function() {
cpu = new CPU_65816();
cpu.reset();
$("#hex").val("");
updateFields();
});