summaryrefslogtreecommitdiff
path: root/emu/emu.c
diff options
context:
space:
mode:
Diffstat (limited to 'emu/emu.c')
-rw-r--r--emu/emu.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/emu/emu.c b/emu/emu.c
index 7c8f041..2723880 100644
--- a/emu/emu.c
+++ b/emu/emu.c
@@ -1,6 +1,7 @@
#include "emul.h"
#include "6502.h"
#include "memory.h"
+#include "7seg.h"
#include <stdlib.h>
@@ -24,6 +25,7 @@ int main( int argc, char *argv[] )
emul_t emul;
cpu_6502_t cpu;
memory_t memory;
+ seg7_t seg7;
if( parse_options_and_arguments( argc, argv, &args_info ) != 0 ) {
exit( EXIT_FAILURE );
@@ -33,19 +35,40 @@ int main( int argc, char *argv[] )
printf( "emu version: %s, Copyright (c) 2020, LGPLv3, Andreas Baumann <mail at andreasbaumann dot cc>\n", EMU_VERSION );
exit( EXIT_SUCCESS );
}
+
+ seg7_init( &seg7 );
+
+ memory_init( &memory, &seg7 );
+ memory_load( &memory, ROM_START, ROM_SIZE, args_info.rom_arg );
- memory_init( &memory );
- memory_load( &memory, ROM_START, ROM_SIZE, "./rom.bin" );
-
cpu_6502_init( &cpu, &memory );
- //cpu.debug = true;
+ if( args_info.debug_given ) {
+ if( args_info.print_cpu_given ) {
+ cpu.debug_flags |= DEBUG_STATUS;
+ }
+ if( args_info.print_zero_page_given ) {
+ cpu.debug_flags |= DEBUG_ZERO_PAGE;
+ }
+ if( args_info.print_stack_given ) {
+ cpu.debug_flags |= DEBUG_STACK;
+ }
+ if( args_info.print_7seg_given ) {
+ seg7.debug = true;
+ }
+ }
cpu_6502_reset( &cpu );
-
- emul_init( &emul, &cpu, &memory );
- emul.gui = true;
+
+ emul_init( &emul, &cpu, &memory, args_info.width_arg, args_info.height_arg );
+ if( args_info.gui_given ) {
+ if( args_info.debug_given ) {
+ fprintf( stderr, "ERROR: don't run debug and GUI together! Uses too many resources!\n" );
+ exit( EXIT_SUCCESS );
+ }
+ emul.gui = true;
+ }
emul_start( &emul );
- emul_run( &emul );
+ emul_run( &emul, args_info.steps_arg );
emul_free( &emul );
exit( EXIT_SUCCESS );