From 8dd69b710edccf118975912d3785e8c4e7811b87 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Sat, 13 Apr 2024 13:42:37 +0200 Subject: [PATCH] move rom/ram/ports management from bus to emulator --- src/bus.c | 18 +++--------------- src/emulator.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/bus.c b/src/bus.c index c9b0aec..f2ae9d1 100644 --- a/src/bus.c +++ b/src/bus.c @@ -1,11 +1,9 @@ #include #include "types.h" -#include "rom.h" -#include "ram.h" -#include "ports.h" #include "hdw.h" #include "bus.h" +#include "ports.h" #define SEG_OF( adr ) ( ( adr ) >> 12 ) #define OFFSET_OF( adr ) ( ( adr ) & 0xFFF ) @@ -32,19 +30,9 @@ static address hdw_seg; word crc; -void bus_init( void ) -{ - rom_init(); - ram_init(); - ports_init(); - bus_reset(); -} +void bus_init( void ) { bus_reset(); } -void bus_exit( void ) -{ - rom_exit(); - ram_exit(); -} +void bus_exit( void ) {} static inline void update_crc( byte nibble ) { crc = ( crc >> 4 ) ^ ( ( ( crc ^ nibble ) & 0xF ) * 0x1081 ); } diff --git a/src/emulator.c b/src/emulator.c index 77fc418..a56a54a 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -11,6 +11,9 @@ #include "display.h" #include "gui.h" #include "emulator.h" +#include "rom.h" +#include "ram.h" +#include "ports.h" #define MAX_DELTA 4000 @@ -46,13 +49,21 @@ void emulator_init( void ) { static bool locked = false; + rom_init(); + ram_init(); + ports_init(); bus_init(); if ( !locked ) locked = true; } -void emulator_exit( void ) { bus_exit(); } +void emulator_exit( void ) +{ + rom_exit(); + ram_exit(); + bus_exit(); +} static inline void throttle( bool is_needed ) {