summaryrefslogtreecommitdiff
path: root/emu/emul.c
diff options
context:
space:
mode:
Diffstat (limited to 'emu/emul.c')
-rw-r--r--emu/emul.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/emu/emul.c b/emu/emul.c
index 602ce33..bf64d13 100644
--- a/emu/emul.c
+++ b/emu/emul.c
@@ -10,6 +10,7 @@ void emul_init( emul_t *emul, cpu_6502_t *cpu, bus_t *bus, int width, int height
emul->gui = false;
emul->width = width;
emul->height = height;
+ emul->debug = false;
}
void emul_start( emul_t *emul )
@@ -63,7 +64,7 @@ void emul_start( emul_t *emul )
emul->background_image = SDL_LoadBMP( "../other/breadboard.bmp" );
emul->background_texture = SDL_CreateTextureFromSurface( emul->renderer, emul->background_image );
SDL_RenderCopy( emul->renderer, emul->background_texture, NULL, NULL );
-
+
SDL_RenderPresent( emul->renderer );
#else
fprintf( stderr, "WARN: gui enabled and not compiled with WITH_GUI (SDL2)\n" );
@@ -83,6 +84,14 @@ void emul_run( emul_t *emul, int nof_steps )
SDL_PollEvent( &event );
switch( event.type ) {
+ case SDL_KEYDOWN:
+ switch( event.key.keysym.sym ) {
+ case SDLK_ESCAPE:
+ done = true;
+ break;
+ }
+ break;
+
case SDL_QUIT:
done = true;
break;
@@ -90,8 +99,17 @@ void emul_run( emul_t *emul, int nof_steps )
cpu_6502_run( emul->cpu, CPU_FREQUENCY / DISPLAY_FPS );
- cpu_6502_print_state( emul->cpu, 0 );
+ if( emul->debug ) {
+ cpu_6502_print_state( emul->cpu, 0 );
+ }
+
SDL_RenderCopy( emul->renderer, emul->background_texture, NULL, NULL );
+
+ for( int i = 0; i < emul->bus->nof_devices; i++ ) {
+ device_t *device = emul->bus->devices[i].device;
+ device->vtable->draw( device, emul->renderer );
+ }
+
SDL_RenderPresent( emul->renderer );
uint32_t frame_end = SDL_GetTicks( );