diff --git a/Makefile b/Makefile index 5ba2c64..4fcc1ec 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ OBJS=perfect6502.o -#OBJS+=runtime.o runtime_init.o plugin.o console.o emu.o -OBJS+=measure.o -CFLAGS=-Wall -O3 +#OBJS+=cbmbasic.o runtime.o runtime_init.o plugin.o console.o emu.o +#OBJS+=measure.o +OBJS+=broken_transistors.o runtime.o runtime_init.o plugin.o console.o emu.o +CFLAGS=-Wall -O3 -DBROKEN_TRANSISTORS CC=clang all: cbmbasic diff --git a/broken_transistors.c b/broken_transistors.c index 772b908..8a5a880 100644 --- a/broken_transistors.c +++ b/broken_transistors.c @@ -1,3 +1,15 @@ +#include +#include +#include "perfect6502.h" + +extern void init_monitor(); + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int BOOL; + +#define YES 1 +#define NO 0 #define MAX_CYCLES 33000 BOOL log_rw[MAX_CYCLES]; @@ -6,8 +18,10 @@ uint8_t log_db[MAX_CYCLES]; int main() { - setupNodesAndTransistors(); - for (int run = -1; run < transistors; run ++) { + initAndResetChip(); +printf("%d\n", transistors); + int stransistors = transistors; + for (int run = -1; run < stransistors; run ++) { #if 0 /* skip a few runs! */ if (run == 0) @@ -26,12 +40,12 @@ main() for (int c = 0; c < MAX_CYCLES; c++) { step(); if (run == -1) { - log_rw[c] = isNodeHigh(rw); + log_rw[c] = cycle & 1; log_ab[c] = readAddressBus(); log_db[c] = readDataBus(); } else { - if (log_rw[c] != isNodeHigh(rw)) { - printf("FAIL, RW %d instead of %d @ %d\n", isNodeHigh(rw), log_rw[c], c); + if (log_rw[c] != (cycle & 1)) { + printf("FAIL, RW %d instead of %d @ %d\n", cycle & 1, log_rw[c], c); fail = YES; break; } diff --git a/cbmbasic.c b/cbmbasic.c new file mode 100644 index 0000000..c47167e --- /dev/null +++ b/cbmbasic.c @@ -0,0 +1,23 @@ +#include "perfect6502.h" + +int +main() +{ + int clk = 0; + + initAndResetChip(); + + /* set up memory for user program */ + init_monitor(); + + /* emulate the 6502! */ + for (;;) { + step(); + clk = !clk; + if (clk) + handle_monitor(); + + //chipStatus(); + //if (!(cycle % 1000)) printf("%d\n", cycle); + }; +} diff --git a/perfect6502.c b/perfect6502.c index acb8202..6b6b6b8 100644 --- a/perfect6502.c +++ b/perfect6502.c @@ -34,6 +34,8 @@ #include #include +#include "perfect6502.h" + typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int BOOL; @@ -428,7 +430,7 @@ getGroupValue() } #ifdef BROKEN_TRANSISTORS -transnum_t broken_transistor = (transnum_t)-1; +unsigned int broken_transistor = (unsigned int)-1; #endif void @@ -719,7 +721,7 @@ step() * ************************************************************/ -count_t transistors; +unsigned int transistors; void setupNodesAndTransistors() @@ -820,7 +822,6 @@ void handle_monitor(); #ifdef TEST #elif defined(BROKEN_TRANSISTORS) -#include "broken_transistors.c" #elif defined(COMPARE) #include "compare.c" #else diff --git a/perfect6502.h b/perfect6502.h index f79cb8f..070acf0 100644 --- a/perfect6502.h +++ b/perfect6502.h @@ -15,4 +15,8 @@ extern unsigned char readIR(); extern unsigned char memory[65536]; extern unsigned int cycle; +extern unsigned int transistors; +#ifdef BROKEN_TRANSISTORS +extern unsigned int broken_transistor; +#endif diff --git a/runtime_init.c b/runtime_init.c index 05f93b1..4882e94 100644 --- a/runtime_init.c +++ b/runtime_init.c @@ -96,24 +96,3 @@ handle_monitor() } } -int -main() -{ - int clk = 0; - - initAndResetChip(); - - /* set up memory for user program */ - init_monitor(); - - /* emulate the 6502! */ - for (;;) { - step(); - clk = !clk; - if (clk) - handle_monitor(); - - //chipStatus(); - //if (!(cycle % 1000)) printf("%d\n", cycle); - }; -}