summaryrefslogtreecommitdiff
path: root/emu/emul.c
diff options
context:
space:
mode:
Diffstat (limited to 'emu/emul.c')
-rw-r--r--emu/emul.c17
1 files changed, 12 insertions, 5 deletions
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 <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
}