From aff63a211e9b1e397adb9dce726d8153beb96dcd Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Wed, 30 Dec 2020 16:55:06 +0100 Subject: - 7seg is a subdevice of the VIA 6522 now, registering to a small sub-bus --- emu/bus.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'emu/bus.c') diff --git a/emu/bus.c b/emu/bus.c index 68ec972..33617c7 100644 --- a/emu/bus.c +++ b/emu/bus.c @@ -6,7 +6,9 @@ static device_vtable_t const bus_vtable = { bus_read, bus_write, - device_draw, +#ifdef WITH_GUI + bus_draw, +#endif bus_deinit }; @@ -55,13 +57,26 @@ void bus_write( void *obj, uint16_t addr, uint8_t data ) for( int i = 0; i < bus->nof_devices; i++ ) { registered_device_t *reg = &bus->devices[i]; if( reg->from <= addr && addr <= reg->to ) { - return reg->device->vtable->write( reg->device, addr, data ); + reg->device->vtable->write( reg->device, addr, data ); + return; } } - fprintf( stderr, "ERROR: illegal bus access writing from address %04X\n", addr ); + fprintf( stderr, "ERROR: illegal bus access writing to address %04X\n", addr ); } +#ifdef WITH_GUI +void bus_draw( void *obj, SDL_Renderer *renderer ) +{ + bus_t *bus = (bus_t *)obj; + + for( int i = 0; i < bus->nof_devices; i++ ) { + device_t *device = bus->devices[i].device; + device->vtable->draw( device, renderer ); + } +} +#endif + void bus_deinit( void *obj ) { bus_t *bus = (bus_t *)obj; -- cgit v1.2.3-54-g00ecf