30 lines
501 B
C++
30 lines
501 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <optional>
|
|
|
|
#include <memory/device.h>
|
|
|
|
class Bus : public Mem_device {
|
|
private:
|
|
struct MapEntry {
|
|
Range range;
|
|
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;
|
|
};
|