summaryrefslogtreecommitdiff
path: root/emu/bus.h
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2020-11-27 20:04:18 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2020-11-27 20:04:18 +0100
commitf829f6893d94ed52044bf007bc447526c9d5e653 (patch)
treec1c98d8b9240b4507719aa8b78eb3ee03dd64ab5 /emu/bus.h
parent3d77f3f5ad41e931117425f58c74f49c9503bf7b (diff)
download6502-f829f6893d94ed52044bf007bc447526c9d5e653.tar.gz
6502-f829f6893d94ed52044bf007bc447526c9d5e653.tar.bz2
emulator uses a bus now in the cpu, ROM, RAM and VIA (7-seg) are devices connected to the bus
Diffstat (limited to 'emu/bus.h')
-rw-r--r--emu/bus.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/emu/bus.h b/emu/bus.h
new file mode 100644
index 0000000..baa2fe2
--- /dev/null
+++ b/emu/bus.h
@@ -0,0 +1,28 @@
+#ifndef BUS_H
+#define BUS_H
+
+#include "device.h"
+
+enum {
+ MAX_NOF_DEVICES = 5
+};
+
+typedef struct registered_device_t {
+ device_t *device;
+ uint16_t from;
+ uint16_t to;
+} registered_device_t;
+
+typedef struct bus_t {
+ device_t base;
+ int nof_devices;
+ registered_device_t devices[MAX_NOF_DEVICES];
+} bus_t;
+
+void bus_init( bus_t *bus );
+void bus_register( bus_t *bus, device_t *device, uint16_t from, uint16_t to );
+uint8_t bus_read( void *obj, uint16_t addr );
+void bus_write( void *obj, uint16_t addr, uint8_t data );
+void bus_deinit( void *obj );
+
+#endif