Browse Source

Renamed 6502 file to match exported class. Roughed out the class.

master
Bryan Miller 5 years ago
parent
commit
973c44e991
2 changed files with 55 additions and 11 deletions
  1. +0
    -11
      src/6502.js
  2. +55
    -0
      src/MOS6502.js

+ 0
- 11
src/6502.js View File

@@ -1,11 +0,0 @@
/*
* Emulate a basic 6502 (MOS) chip.
*/

// Registers
var PC = 0; // Program Counter (16 bit)
var IRQ = 0; // IRQ interrupt address code (16 bit)
var SR = 0; // Status Register (8 bit)
var XR = 0; // X Register (8 bit)
var YR = 0; // Y Register (8 bit)
var AR = 0; // Accumulator Register (8 bit)

+ 55
- 0
src/MOS6502.js View File

@@ -0,0 +1,55 @@
/*
* Emulate a basic 6502 (MOS) chip.
*/

var Memory = require('src/memory');

class MOS6502{
constructor(){
// Registers
this.__PC = 0; // Program Counter (16 bit)
this.__IRQ = 0; // IRQ interrupt address code (16 bit)
this.__SR = 0; // Status Register (8 bit)
this.__XR = 0; // X Register (8 bit)
this.__YR = 0; // Y Register (8 bit)
this.__AR = 0; // Accumulator Register (8 bit)

// Variables to watch for Interrupts.
this.__nmi = false;
this.__irq = false;

// Memory module or controller.
this.__mem = null; // Must be explicitly attached.

// Hold any created CLK instances.
this.__clkfn = null;
}

set NMI(n){
this.__nmi = (n === true);
}

set IRQ(q){
// TODO: Verify this.
// TODO: Do not set if the interrupt flag is off.
this.__irq = (q === true);
}

CLK(){
if (this.__clkfn === null){
this.__clkfn = (function(){
// TODO: All the work!!
}).bind(this);
}
return this.__clkfn;
}

Memory(mem){
if (!(mem instanceof Memory))
throw new ValueError("Expected Memory instance object.");
this.__mem = mem;
}
}


module.exports = MOS6502;

Loading…
Cancel
Save