ComSquare
IMemoryBus.hpp
Go to the documentation of this file.
1 //
2 // Created by Zoe Roux on 2021-07-04.
3 //
4 
5 
6 #pragma once
7 
8 #include <cinttypes>
9 #include <optional>
10 #include "IMemory.hpp"
11 
12 namespace ComSquare
13 {
14  class SNES;
15 
16  namespace Memory
17  {
19  class IMemoryBus
20  {
21  public:
23  virtual ~IMemoryBus() = default;
24 
29  virtual uint8_t read(uint24_t addr) = 0;
30 
34  virtual std::optional<uint8_t> peek(uint24_t addr) = 0;
35 
40  virtual uint8_t peek_v(uint24_t addr) = 0;
41 
45  virtual void write(uint24_t addr, uint8_t data) = 0;
46 
50  virtual IMemory *getAccessor(uint24_t addr) = 0;
51  };
52  }
53 }
ComSquare::Memory::IMemoryBus::getAccessor
virtual IMemory * getAccessor(uint24_t addr)=0
Helper function to get the components that is responsible of read/write at an address.
ComSquare::Memory::IMemoryBus::read
virtual uint8_t read(uint24_t addr)=0
Read data at a global address. This form allow read to be silenced.
uint24_t
unsigned uint24_t
Definition: Ints.hpp:10
ComSquare::Memory::IMemory
Common interface implemented by all components mapping memory.
Definition: IMemory.hpp:17
ComSquare::Memory::IMemoryBus::~IMemoryBus
virtual ~IMemoryBus()=default
A virtual default destructor.
ComSquare::Memory::IMemoryBus::peek_v
virtual uint8_t peek_v(uint24_t addr)=0
This as the same purpose as a read but it does not change the open bus and won't throw an exception.
ComSquare::Memory::IMemoryBus
The memory bus is the component responsible of mapping addresses to components address and transmitti...
Definition: IMemoryBus.hpp:19
ComSquare::Memory::IMemoryBus::write
virtual void write(uint24_t addr, uint8_t data)=0
Write a data to a global address.
ComSquare::Memory::IMemoryBus::peek
virtual std::optional< uint8_t > peek(uint24_t addr)=0
This as the same purpose as a read but it does not change the open bus and won't throw an exception.
IMemory.hpp
ComSquare
Definition: APU.cpp:12