From 9a758781b587117db8775d256a035d75d547e13b Mon Sep 17 00:00:00 2001 From: edmccard Date: Fri, 6 Apr 2012 23:48:37 -0400 Subject: [PATCH] New cpu --- src/cpu6502.d | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/cpu6502.d diff --git a/src/cpu6502.d b/src/cpu6502.d new file mode 100644 index 0000000..85c79bc --- /dev/null +++ b/src/cpu6502.d @@ -0,0 +1,45 @@ +module cpu6502; + + +enum Strict : bool +{ + no, yes +} + +enum Cumulative : bool +{ + no, yes +} + + +class Cpu(bool cumulative) +{ + struct _Mem + { + // Reads a value from system memory. + ubyte delegate(ushort addr) read; + + // Writes a value to system memory. + void delegate(ushort addr, ubyte val) write; + } + _Mem memory; + + struct _Clock + { + static if (cumulative) + /* + * Updates the number of cycles executed. Called just + * prior to the final read/write action of each opcode. + */ + void delegate(int cycles) tick; + else + /* + * Increments the number of cycles executed. Called prior + * to each read/write action. + */ + void delegate() tick; + } + _Clock clock; + + ubyte A, X, Y, S, P; +}