use read_word_long to clean up reading where the program counter should

point to when there is an interrupt
This commit is contained in:
Preston Skupinski 2012-01-05 21:02:57 -05:00
parent 12b352cfa5
commit 898c16637a

41
cpu.js
View File

@ -3827,62 +3827,41 @@ window.CPU_65816 = function() {
this.p.i = 1; this.p.i = 1;
this.r.k = 0; this.r.k = 0;
var low_byte, high_byte;
// Look for where to jump to for the interrupt. // Look for where to jump to for the interrupt.
if(this.p.e) { if(this.p.e) {
// NMI // NMI
if(this.interrupt===this.INTERRUPT.NMI) { if(this.interrupt===this.INTERRUPT.NMI) {
low_byte = this.mmu.read_byte_long(0xfffa, 0); this.r.pc = this.mmu.read_word_long(0xfffa, 0);
high_byte = this.mmu.read_byte_long(0xfffb, 0);
this.r.pc = (high_byte<<8)|low_byte;
// RESET // RESET
} else if(this.interrupt===this.INTERRUPT.RESET) { } else if(this.interrupt===this.INTERRUPT.RESET) {
low_byte = this.mmu.read_byte_long(0xfffc, 0); this.r.pc = this.mmu.read_word_long(0xfffc, 0);
high_byte = this.mmu.read_byte_long(0xfffd, 0);
this.r.pc = (high_byte<<8)|low_byte;
// ABORT // ABORT
} else if(this.interrupt===this.INTERRUPT.ABORT) { } else if(this.interrupt===this.INTERRUPT.ABORT) {
low_byte = this.mmu.read_byte_long(0xfff8, 0); this.r.pc = this.mmu.read_word_long(0xfff8, 0);
high_byte = this.mmu.read_byte_long(0xfff9, 0);
this.r.pc = (high_byte<<8)|low_byte;
// COP // COP
} else if(this.interrupt===this.INTERRUPT.COP) { } else if(this.interrupt===this.INTERRUPT.COP) {
low_byte = this.mmu.read_byte_long(0xfff4, 0); this.r.pc = this.mmu.read_word_long(0xfff4, 0);
high_byte = this.mmu.read_byte_long(0xfff5, 0);
this.r.pc = (high_byte<<8)|low_byte;
// IRQ or BRK // IRQ or BRK
} else if(this.interrupt===this.INTERRUPT.IRQ || } else if(this.interrupt===this.INTERRUPT.IRQ ||
this.interrupt===this.INTERRUPT.BRK) { this.interrupt===this.INTERRUPT.BRK) {
low_byte = this.mmu.read_byte_long(0xfffe, 0); this.r.pc = this.mmu.read_word_long(0xfffe, 0);
high_byte = this.mmu.read_byte_long(0xffff, 0);
this.r.pc = (high_byte<<8)|low_byte;
} }
} else { } else {
// NMI // NMI
if(this.interrupt===this.INTERRUPT.NMI) { if(this.interrupt===this.INTERRUPT.NMI) {
low_byte = this.mmu.read_byte_long(0xffea, 0); this.r.pc = this.mmu.read_word_long(0xffea, 0);
high_byte = this.mmu.read_byte_long(0xffeb, 0);
this.r.pc = (high_byte<<8)|low_byte;
// ABORT // ABORT
} else if(this.interrupt===this.INTERRUPT.ABORT) { } else if(this.interrupt===this.INTERRUPT.ABORT) {
low_byte = this.mmu.read_byte_long(0xffe8, 0); this.r.pc = this.mmu.read_word_long(0xffe8, 0);
high_byte = this.mmu.read_byte_long(0xffe9, 0);
this.r.pc = (high_byte<<8)|low_byte;
// COP // COP
} else if(this.interrupt===this.INTERRUPT.COP) { } else if(this.interrupt===this.INTERRUPT.COP) {
low_byte = this.mmu.read_byte_long(0xffe4, 0); this.r.pc = this.mmu.read_word_long(0xffe4, 0);
high_byte = this.mmu.read_byte_long(0xffe5, 0);
this.r.pc = (high_byte<<8)|low_byte;
// IRQ // IRQ
} else if(this.interrupt===this.INTERRUPT.IRQ) { } else if(this.interrupt===this.INTERRUPT.IRQ) {
low_byte = this.mmu.read_byte_long(0xffee, 0); this.r.pc = this.mmu.read_word_long(0xffee, 0);
high_byte = this.mmu.read_byte_long(0xffef, 0);
this.r.pc = (high_byte<<8)|low_byte;
// BRK // BRK
} else if(this.interrupt===this.INTERRUPT.BRK) { } else if(this.interrupt===this.INTERRUPT.BRK) {
low_byte = this.mmu.read_byte_long(0xffe6, 0); this.r.pc = this.mmu.read_word_long(0xffe6, 0);
high_byte = this.mmu.read_byte_long(0xffe7, 0);
this.r.pc = (high_byte<<8)|low_byte;
} }
} }