summaryrefslogtreecommitdiff
path: root/emu/emu.c
diff options
context:
space:
mode:
Diffstat (limited to 'emu/emu.c')
-rw-r--r--emu/emu.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/emu/emu.c b/emu/emu.c
index 2723880..95bc5cb 100644
--- a/emu/emu.c
+++ b/emu/emu.c
@@ -23,9 +23,11 @@ int main( int argc, char *argv[] )
{
struct gengetopt_args_info args_info;
emul_t emul;
- cpu_6502_t cpu;
- memory_t memory;
+ bus_t bus;
+ memory_t rom;
+ memory_t ram;
seg7_t seg7;
+ cpu_6502_t cpu;
if( parse_options_and_arguments( argc, argv, &args_info ) != 0 ) {
exit( EXIT_FAILURE );
@@ -36,12 +38,19 @@ int main( int argc, char *argv[] )
exit( EXIT_SUCCESS );
}
- seg7_init( &seg7 );
-
- memory_init( &memory, &seg7 );
- memory_load( &memory, ROM_START, ROM_SIZE, args_info.rom_arg );
+ bus_init( &bus );
+
+ memory_init( &rom, MEMORY_ROM, ROM_START, ROM_SIZE );
+ memory_load( &rom, args_info.rom_arg );
+ bus_register( &bus, &rom.base, ROM_START, ROM_END );
+
+ memory_init( &ram, MEMORY_RAM, RAM_START, RAM_SIZE );
+ bus_register( &bus, &ram.base, RAM_START, RAM_END );
+
+ seg7_init( &seg7, VIA_START );
+ bus_register( &bus, &seg7.base, VIA_START, VIA_END );
- cpu_6502_init( &cpu, &memory );
+ cpu_6502_init( &cpu, &bus );
if( args_info.debug_given ) {
if( args_info.print_cpu_given ) {
cpu.debug_flags |= DEBUG_STATUS;
@@ -58,7 +67,7 @@ int main( int argc, char *argv[] )
}
cpu_6502_reset( &cpu );
- emul_init( &emul, &cpu, &memory, args_info.width_arg, args_info.height_arg );
+ emul_init( &emul, &cpu, &bus, 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" );
@@ -70,6 +79,7 @@ int main( int argc, char *argv[] )
emul_run( &emul, args_info.steps_arg );
+ bus_deinit( &bus );
emul_free( &emul );
exit( EXIT_SUCCESS );
}