mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-22 14:12:35 +01:00
byuu says: Changelog: - higan now uses Natural<Size>/Integer<Size> for its internal types - Super Famicom emulation now uses uint24 instead of uint for bus addresses (it's a 24-bit bus) - cleaned up gb/apu MMIO writes - cleaned up sfc/coprocessor/msu1 MMIO writes - ~3% speed penalty I've wanted to do that 24-bit bus thing for so long, but have always been afraid of the speed impact. It's probably going to hurt balanced/performance once they compile again, but it wasn't significant enough to harm the accuracy core's frame rate, thankfully. Only lost one frame per second. The GBA core handlers are clearly going to take a lot more work. The bit-ranges will make it substantially easier to handle, though. Lots of 32-bit registers where certain values span multiple bytes, but we have to be able to read/write at byte-granularity.
72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
struct Memory {
|
|
virtual inline auto size() const -> uint;
|
|
virtual auto read(uint24 addr, uint8 data = 0) -> uint8 = 0;
|
|
virtual auto write(uint24 addr, uint8 data) -> void = 0;
|
|
};
|
|
|
|
struct StaticRAM : Memory {
|
|
inline StaticRAM(uint size);
|
|
inline ~StaticRAM();
|
|
|
|
inline auto data() -> uint8*;
|
|
inline auto size() const -> uint;
|
|
|
|
inline auto read(uint24 addr, uint8 data = 0) -> uint8;
|
|
inline auto write(uint24 addr, uint8 data) -> void;
|
|
inline auto operator[](uint24 addr) -> uint8&;
|
|
inline auto operator[](uint24 addr) const -> const uint8&;
|
|
|
|
private:
|
|
uint8* data_ = nullptr;
|
|
uint size_ = 0;
|
|
};
|
|
|
|
struct MappedRAM : Memory {
|
|
inline auto reset() -> void;
|
|
inline auto map(uint8*, uint) -> void;
|
|
inline auto copy(const stream& memory) -> void;
|
|
inline auto read(const stream& memory) -> void;
|
|
|
|
inline auto write_protect(bool status) -> void;
|
|
inline auto data() -> uint8*;
|
|
inline auto size() const -> uint;
|
|
|
|
inline auto read(uint24 addr, uint8 data = 0) -> uint8;
|
|
inline auto write(uint24 addr, uint8 data) -> void;
|
|
inline auto operator[](uint24 addr) const -> const uint8&;
|
|
|
|
private:
|
|
uint8* data_ = nullptr;
|
|
uint size_ = 0;
|
|
bool write_protect_ = false;
|
|
};
|
|
|
|
struct Bus {
|
|
alwaysinline static auto mirror(uint addr, uint size) -> uint;
|
|
alwaysinline static auto reduce(uint addr, uint mask) -> uint;
|
|
|
|
Bus();
|
|
~Bus();
|
|
|
|
alwaysinline auto read(uint24 addr, uint8 data) -> uint8;
|
|
alwaysinline auto write(uint24 addr, uint8 data) -> void;
|
|
|
|
auto reset() -> void;
|
|
auto map() -> void;
|
|
auto map(
|
|
const function<uint8 (uint24, uint8)>& reader,
|
|
const function<void (uint24, uint8)>& writer,
|
|
uint8 banklo, uint8 bankhi, uint16 addrlo, uint16 addrhi,
|
|
uint size = 0, uint base = 0, uint mask = 0
|
|
) -> void;
|
|
|
|
uint8* lookup = nullptr;
|
|
uint32* target = nullptr;
|
|
|
|
uint idcount = 0;
|
|
function<auto (uint24, uint8) -> uint8> reader[256];
|
|
function<auto (uint24, uint8) -> void> writer[256];
|
|
};
|
|
|
|
extern Bus bus;
|