diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2020-12-10 19:50:39 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2020-12-10 19:50:39 +0100 |
commit | 1269d11d15f1014b7ac87fc2bb2c76367404e16c (patch) | |
tree | d8d4595811b279d2e7d5ccef32f55ba5cbcba585 /emu/6502.c | |
parent | 84e25eb07749636b48deb802d673f44841c55d91 (diff) | |
download | 6502-1269d11d15f1014b7ac87fc2bb2c76367404e16c.tar.gz 6502-1269d11d15f1014b7ac87fc2bb2c76367404e16c.tar.bz2 |
some more unit testing
Diffstat (limited to 'emu/6502.c')
-rw-r--r-- | emu/6502.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -2,7 +2,6 @@ #include "memory.h" #include <stdio.h> -#include <stdlib.h> static const uint16_t reset_vector = 0xFFFC; static const uint16_t ZP_base = 0x0; @@ -13,6 +12,7 @@ void cpu_6502_init( cpu_6502_t *cpu, bus_t *bus, bool initialize ) cpu->bus = bus; cpu->debug_flags = 0; cpu->steps = 0; + cpu->error_state = ERROR_STATE_OK; if( initialize ) { cpu->PC = 0x0000; @@ -88,11 +88,11 @@ void cpu_6502_write_word( cpu_6502_t *cpu, uint16_t addr, uint16_t data ) void cpu_6502_run( cpu_6502_t *cpu, int steps ) { if( steps != -1 ) { - for( int i = 0; i < steps; i++ ) { + for( int i = 1; i <= steps && cpu->error_state == ERROR_STATE_OK; i++ ) { cpu_6502_step( cpu ); } } else { - while( true ) { + while( cpu->error_state == ERROR_STATE_OK ) { cpu_6502_step( cpu ); } } @@ -429,7 +429,7 @@ void cpu_6502_step( cpu_6502_t *cpu ) default: fprintf( stderr, "ERROR: Illegal opcode %02X at PC %04X\n", opcode, cpu->PC ); - exit( EXIT_FAILURE ); + cpu->error_state |= ERROR_STATE_ILLEGAL_OPCODE; } cpu->steps++; |