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/emul.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/emul.c')
-rw-r--r-- | emu/emul.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -3,11 +3,13 @@ #include <stdio.h> #include <stdlib.h> -void emul_init( emul_t *emul, cpu_6502_t *cpu, memory_t *memory ) +void emul_init( emul_t *emul, cpu_6502_t *cpu, memory_t *memory, int width, int height ) { emul->cpu = cpu; emul->memory = memory; emul->gui = false; + emul->width = width; + emul->height = height; } void emul_start( emul_t *emul ) @@ -42,7 +44,7 @@ void emul_start( emul_t *emul ) emul->window = SDL_CreateWindow( "6502 emu", SDL_WINDOWPOS_UNDEFINED_DISPLAY( display ), SDL_WINDOWPOS_UNDEFINED_DISPLAY( display ), - 600, 250, 0 ); + emul->width, emul->height, 0 ); if( emul->window == NULL ) { fprintf( stderr, "ERROR: SDL_CreateWindow failed: %s\n", SDL_GetError( ) ); exit( EXIT_FAILURE ); @@ -69,7 +71,7 @@ void emul_start( emul_t *emul ) } } -void emul_run( emul_t *emul ) +void emul_run( emul_t *emul, int nof_steps ) { #ifdef WITH_GUI if( emul->gui ) { @@ -97,12 +99,17 @@ void emul_run( emul_t *emul ) if( delay > 0 ) { SDL_Delay( delay ); } + + if( nof_steps != -1 && emul->cpu->steps > nof_steps ) { + fprintf( stderr, "INFO: final number of steps reached (%d), terminating now\n", emul->cpu->steps ); + done = true; + } } } else { - cpu_6502_run( emul->cpu, 100 ); + cpu_6502_run( emul->cpu, nof_steps ); } #else - cpu_6502_run( emul->cpu, 100 ); + cpu_6502_run( emul->cpu, nof_steps ); #endif } |