1
0
Fork 0
2019-nes-emulator/Source/NES.hpp

55 lines
824 B
C++

#pragma once
#include "Cartridge.hpp"
#include "CPU/CPU.hpp"
#include "Input.hpp"
#include "Platform.hpp"
#include "PPU/PPU.hpp"
#include <memory>
struct Color
{
Color()
: r(0), g(0), b(0), a(0)
{
}
Color(uint8_t r, uint8_t g, uint8_t b)
: r(r), g(g), b(b), a(255)
{}
uint8_t r, g, b, a;
uint32_t GetValue()
{
return (r << 24u) | (g << 16u) | (b << 8u) | a;
}
};
enum class BusSource
{
CPU,
PPU
};
class NES
{
public:
NES();
void InsertCartridge(char const* filename);
void Run();
void Write(BusSource source, uint16_t address, uint8_t value);
uint8_t Read(BusSource source, uint16_t address);
std::unique_ptr<CPU> cpu;
std::unique_ptr<PPU> ppu;
std::unique_ptr<Cartridge> cartridge;
std::unique_ptr<Platform> platform;
std::unique_ptr<Input> input;
bool nmi{};
Color palette[64];
};