diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2020-11-26 19:55:02 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2020-11-26 19:55:02 +0100 |
commit | 3d77f3f5ad41e931117425f58c74f49c9503bf7b (patch) | |
tree | 8165c8f10a1b3b3cec27cfb283ee218e7af3a519 /emu/6502.c | |
parent | 394c9fbb6cc243e46b32aa9e7221b0e6cadd4c13 (diff) | |
download | 6502-3d77f3f5ad41e931117425f58c74f49c9503bf7b.tar.gz 6502-3d77f3f5ad41e931117425f58c74f49c9503bf7b.tar.bz2 |
more work on emulator, mainly debug and 7seg stuff
Diffstat (limited to 'emu/6502.c')
-rw-r--r-- | emu/6502.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -11,7 +11,7 @@ static const uint16_t SP_base = 0x100; void cpu_6502_init( cpu_6502_t *cpu, struct memory_t *memory ) { cpu->memory = memory; - cpu->debug = false; + cpu->debug_flags = 0; } uint16_t cpu_6502_read_word( cpu_6502_t *cpu, uint16_t addr ) @@ -78,8 +78,14 @@ 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 ) { - for( int i = 0; i < steps; i++ ) { - cpu_6502_step( cpu ); + if( steps != -1 ) { + for( int i = 0; i < steps; i++ ) { + cpu_6502_step( cpu ); + } + } else { + while( true ) { + cpu_6502_step( cpu ); + } } } @@ -184,9 +190,13 @@ void cpu_6502_step( cpu_6502_t *cpu ) opcode = cpu_6502_read_byte( cpu, cpu->PC ); cpu->PC++; - if( cpu->debug ) { + if( cpu->debug_flags & DEBUG_STATUS ) { cpu_6502_print_state( cpu, opcode ); + } + if( cpu->debug_flags & DEBUG_STACK ) { cpu_6502_print_stack( cpu ); + } + if( cpu->debug_flags & DEBUG_ZERO_PAGE ) { cpu_6502_print_zerop_page( cpu ); } @@ -236,7 +246,7 @@ void cpu_6502_step( cpu_6502_t *cpu ) case STX_ABS: operand16 = cpu_6502_read_word( cpu, cpu->PC ); cpu->PC += 2; - cpu_6502_write_word( cpu, operand16, cpu->X ); + cpu_6502_write_byte( cpu, operand16, cpu->X ); break; case DEY_IMPL: |