4#include "core/interconnect/bus.hpp"
5#include "core/bios/bios.hpp"
6#include "core/cpu/cpu.hpp"
7#include "core/memory/ram.hpp"
24 ram =
new RAM(2 * 1024 * 1024);
54 ss <<
"Unaligned read32_cpu: 0x" << std::hex << addr;
55 throw std::runtime_error(ss.str());
58 uint32_t addr_og = addr;
71 std::cout <<
"Unhandled Interrupt Control Read: Just returning 0" << std::endl;
78 ss <<
"Unmapped address for read32_cpu: 0x" << std::hex << addr_og;
79 throw std::runtime_error(ss.str());
106 std::stringstream ss;
107 ss <<
"Unaligned write32_cpu: 0x" << std::hex << addr;
108 throw std::runtime_error(ss.str());
111 uint32_t addr_og = addr;
119 if(data != 0x1f000000)
121 std::stringstream ss;
122 ss <<
"Bad Expansion 1 Base Address write: 0x" << std::hex << data;
123 throw std::runtime_error(ss.str());
127 if(data != 0x1f802000)
129 std::stringstream ss;
130 ss <<
"Bad Expansion 2 Base Address write: 0x" << std::hex << data;
131 throw std::runtime_error(ss.str());
135 std::stringstream ss;
136 ss <<
"Unhandled write to MEM_CTRL register: " << addr;
160 std::cout <<
"Ignoring write32 to Interrupt Register" << std::endl;
165 std::stringstream ss;
166 ss <<
"Unmapped address for write32_cpu: 0x" << std::hex << addr_og;
167 throw std::runtime_error(ss.str());
192 std::stringstream ss;
193 ss <<
"Unaligned read16_cpu: 0x" << std::hex << addr;
194 throw std::runtime_error(ss.str());
197 uint32_t addr_og = addr;
201 std::stringstream ss;
202 ss <<
"Unmapped address for read16_cpu: 0x" << std::hex << addr_og;
203 throw std::runtime_error(ss.str());
228 std::stringstream ss;
229 ss <<
"Unaligned write16_cpu: 0x" << std::hex << addr;
230 throw std::runtime_error(ss.str());
233 uint32_t addr_og = addr;
242 std::stringstream ss;
243 ss <<
"Unhandled write16 (" << data <<
") to SPU register: " << addr_og;
253 std::cout <<
"Ignoring write16 to Timer Register" << std::endl;
258 std::stringstream ss;
259 ss <<
"Unmapped address for write16_cpu: 0x" << std::hex << addr;
260 throw std::runtime_error(ss.str());
283 uint32_t addr_og = addr;
301 std::stringstream ss;
302 ss <<
"Unmapped address for read8_cpu: 0x" << std::hex << addr_og;
303 throw std::runtime_error(ss.str());
325 uint32_t addr_og = addr;
330 std::cout <<
"Ignoring write8 to Expansion 2" << std::endl;
339 std::stringstream ss;
340 ss <<
"Unmapped address for write8_cpu: 0x" << std::hex << addr_og;
341 throw std::runtime_error(ss.str());
Class to emulate the BIOS.
uint32_t read32_cpu(uint32_t offset)
Reads a 32-bit word from the BIOS.
Range mem_ctrl_range
Range of the Memory Control Registers.
RAM * ram
Pointer to the RAM object.
Range expansion1_range
Range of the Expansion 1.
Range ram_size_range
Range of the RAM Size Register.
CPU * cpu
Pointer to the CPU object.
uint16_t read16_cpu(uint32_t addr)
Reads a 16-bit word from the given address.
uint32_t read32_cpu(uint32_t addr)
Reads a 32-bit word from the given address.
Bus(std::string bios_path)
Construct a new Bus:: Bus object.
Range ram_range
Range of the RAM.
Range bios_range
Range of the BIOS.
Range timer_range
Range of the Timer Registers.
Range cache_ctrl_range
Range of the Cache Control Register.
BIOS * bios
Pointer to the BIOS object.
void write8_cpu(uint32_t addr, uint8_t data)
Writes a 8-bit word to the given address.
uint32_t region_mask(uint32_t addr)
Returns the region mask for a given address.
Range expansion2_range
Range of the Expansion 2.
void write32_cpu(uint32_t addr, uint32_t data)
Writes a 32-bit word to the given address.
void write16_cpu(uint32_t addr, uint16_t data)
Writes a 16-bit word to the given address.
Range interrupt_range
Range of the Interrupt Registers.
Range spu_range
Range of the SPU (Sound Processing Unit) Registers.
uint8_t read8_cpu(uint32_t addr)
Reads a 8-bit word from the given address.
Class to emulate the CPU.
void connectBus(Bus *bus)
Connects Bus to the CPU.
Class to emulate the RAM.
void write8_cpu(uint32_t offset, uint8_t data)
Writes a byte to the RAM.
void write32_cpu(uint32_t offset, uint32_t data)
Writes a 32-bit word to the RAM.
uint32_t read32_cpu(uint32_t offset)
Reads a 32-bit word from the RAM.
uint8_t read8_cpu(uint32_t offset)
Reads a byte from the RAM.
bool contains(uint32_t addr)
Checks if the given address is in the range.
uint32_t offset(uint32_t addr)
Gets the offset of the given address from the start of the range.