31 lines
535 B
C++
31 lines
535 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <optional>
|
|
|
|
#include <memory/device.h>
|
|
|
|
class Bus : public Mem_device {
|
|
private:
|
|
struct MapEntry {
|
|
Range range;
|
|
u16 offset;
|
|
Mem_device *dev;
|
|
};
|
|
|
|
std::optional<MapEntry> find_entry(u16 addr);
|
|
|
|
public:
|
|
Bus();
|
|
|
|
void map_device(u16 start, u16 end, Mem_device* dev, u16 offset = 0x0);
|
|
|
|
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;
|
|
};
|