From 3d77f3f5ad41e931117425f58c74f49c9503bf7b Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Thu, 26 Nov 2020 19:55:02 +0100 Subject: more work on emulator, mainly debug and 7seg stuff --- emu/emul.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'emu/emul.c') diff --git a/emu/emul.c b/emu/emul.c index 70a1144..930f112 100644 --- a/emu/emul.c +++ b/emu/emul.c @@ -3,11 +3,13 @@ #include #include -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 } -- cgit v1.2.3-54-g00ecf