io: add display unit

added rendering for modes 3,4,5
also changed how memory structuring works

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2024-06-22 04:16:12 +05:30
parent 54fc472399
commit 58a503d2c4
13 changed files with 652 additions and 275 deletions

View File

@@ -2,9 +2,8 @@
#include "header.hh"
#include "io/io.hh"
#include "memory.hh"
#include <memory>
#include <optional>
#include <span>
#include <vector>
namespace matar {
@@ -85,7 +84,7 @@ class Bus {
}
template<typename T>
std::optional<T> read(uint32_t address) const;
T read(uint32_t address) const;
template<typename T>
void write(uint32_t address, T value);
@@ -101,45 +100,11 @@ class Bus {
static constexpr decltype(cycle_map) init_cycle_count();
std::unique_ptr<IoDevices> io;
Memory<BIOS_SIZE> bios = {};
Memory<0x40000> board_wram = {};
Memory<0x80000> chip_wram = {};
Memory<> rom;
#define MEMORY_REGION(name, start) \
static constexpr uint32_t name##_START = start; \
static constexpr uint8_t name##_REGION = start >> 24 & 0xF;
#define DECL_MEMORY(name, ident, start, end) \
MEMORY_REGION(name, start) \
std::array<uint8_t, end - start + 1> ident = {};
MEMORY_REGION(BIOS, 0x00000000)
std::array<uint8_t, BIOS_SIZE> bios = {};
// board working RAM
DECL_MEMORY(BOARD_WRAM, board_wram, 0x02000000, 0x0203FFFF)
// chip working RAM
DECL_MEMORY(CHIP_WRAM, chip_wram, 0x03000000, 0x03007FFF)
// palette RAM
DECL_MEMORY(PALETTE_RAM, palette_ram, 0x05000000, 0x050003FF)
// video RAM
DECL_MEMORY(VRAM, vram, 0x06000000, 0x06017FFF)
// OAM OBJ attributes
DECL_MEMORY(OAM_OBJ_ATTR, oam_obj_attr, 0x07000000, 0x070003FF)
#undef DECL_MEMORY
MEMORY_REGION(ROM_0, 0x08000000)
MEMORY_REGION(ROM_1, 0x0A000000)
MEMORY_REGION(ROM_2, 0x0C000000)
MEMORY_REGION(IO, 0x04000000)
static constexpr uint32_t IO_END = 0x040003FE;
#undef MEMORY_REGION
std::vector<uint8_t> rom;
Header header;
void parse_header();
};