2023-08-26 19:04:02 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <optional>
|
|
|
|
|
2023-08-30 22:34:45 +02:00
|
|
|
#include <memory/device.h>
|
2023-08-26 19:04:02 +02:00
|
|
|
|
|
|
|
class Bus : public Mem_device {
|
|
|
|
private:
|
|
|
|
struct MapEntry {
|
2023-08-30 13:02:20 +02:00
|
|
|
Range range;
|
2023-08-26 19:04:02 +02:00
|
|
|
Mem_device *dev;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::optional<MapEntry> find_entry(u16 addr);
|
|
|
|
|
|
|
|
public:
|
|
|
|
Bus();
|
|
|
|
|
|
|
|
void map_device(u16 start, u16 end, Mem_device* dev);
|
|
|
|
|
|
|
|
virtual void write8(u16 addr, u8 data);
|
|
|
|
virtual u8 read8(u16 addr);
|
|
|
|
|
|
|
|
virtual void write16(u16 addr, u16 data);
|
|
|
|
virtual u16 read16(u16 addr);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<MapEntry> map;
|
|
|
|
};
|