mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 14:15:11 +00:00
Setting the window's name to the game's name
This commit is contained in:
@@ -79,7 +79,7 @@ add_executable(ComSquare
|
|||||||
sources/Renderer/SFRenderer.hpp
|
sources/Renderer/SFRenderer.hpp
|
||||||
sources/Renderer/SFRenderer.cpp
|
sources/Renderer/SFRenderer.cpp
|
||||||
sources/Exceptions/InvalidAction.hpp
|
sources/Exceptions/InvalidAction.hpp
|
||||||
sources/Cartridge/InterruptVectors.hpp)
|
sources/Cartridge/InterruptVectors.hpp sources/Memory/RectangleShadow.cpp sources/Memory/RectangleShadow.hpp)
|
||||||
|
|
||||||
target_link_libraries(ComSquare
|
target_link_libraries(ComSquare
|
||||||
sfml-graphics
|
sfml-graphics
|
||||||
|
|||||||
5
main.cpp
5
main.cpp
@@ -17,11 +17,10 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Memory::MemoryBus bus;
|
Memory::MemoryBus bus;
|
||||||
SNES snes(std::make_shared<Memory::MemoryBus>(bus), argv[1]);
|
Renderer::SFRenderer renderer(600, 800, 60);
|
||||||
|
SNES snes(std::make_shared<Memory::MemoryBus>(bus), argv[1], renderer);
|
||||||
bus.mapComponents(snes);
|
bus.mapComponents(snes);
|
||||||
|
|
||||||
Renderer::SFRenderer renderer(600, 800, 60);
|
|
||||||
renderer.setWindowName("Fire Emblem : Three Houses");
|
|
||||||
while (!renderer.shouldExit) {
|
while (!renderer.shouldExit) {
|
||||||
renderer.getEvents();
|
renderer.getEvents();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ namespace ComSquare::Cartridge
|
|||||||
|
|
||||||
this->header = this->_mapHeader(headerAddress);
|
this->header = this->_mapHeader(headerAddress);
|
||||||
char name[22];
|
char name[22];
|
||||||
std::memcpy(name, &this->_data[headerAddress + 0xC0u], 21);
|
std::memcpy(name, &this->_data[headerAddress], 21);
|
||||||
name[21] = '\0';
|
name[21] = '\0';
|
||||||
this->header.gameName = std::string(name);
|
this->header.gameName = std::string(name);
|
||||||
if (headerAddress & 0x200u) {
|
if (headerAddress & 0x200u) {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace ComSquare::Cartridge
|
|||||||
//! @brief The size of the rom data.
|
//! @brief The size of the rom data.
|
||||||
size_t _size;
|
size_t _size;
|
||||||
//! @brief Sometime the rom's data has an offset for a SMC header. This value indicate the start of the real rom discarding this header.
|
//! @brief Sometime the rom's data has an offset for a SMC header. This value indicate the start of the real rom discarding this header.
|
||||||
uint16_t _romStart;
|
uint16_t _romStart = 0;
|
||||||
|
|
||||||
//! @brief Get the size of a rom from it's path.
|
//! @brief Get the size of a rom from it's path.
|
||||||
//! @param romPath The path of the rom to get info from.
|
//! @param romPath The path of the rom to get info from.
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "MemoryBus.hpp"
|
#include "MemoryBus.hpp"
|
||||||
#include "../SNES.hpp"
|
#include "../SNES.hpp"
|
||||||
#include "MemoryShadow.hpp"
|
#include "MemoryShadow.hpp"
|
||||||
|
#include "RectangleShadow.hpp"
|
||||||
|
|
||||||
namespace ComSquare::Memory
|
namespace ComSquare::Memory
|
||||||
{
|
{
|
||||||
@@ -83,6 +84,7 @@ namespace ComSquare::Memory
|
|||||||
if (console.cartridge->header.mappingMode & Cartridge::LoRom) {
|
if (console.cartridge->header.mappingMode & Cartridge::LoRom) {
|
||||||
console.cartridge->setMemoryRegion(0x80, 0xFF, 0x8000, 0xFFFF);
|
console.cartridge->setMemoryRegion(0x80, 0xFF, 0x8000, 0xFFFF);
|
||||||
this->_memoryAccessors.push_back(console.cartridge);
|
this->_memoryAccessors.push_back(console.cartridge);
|
||||||
|
this->_memoryAccessors.push_back(Memory::RectangleShadow::createShadow(console.cartridge, 0x0, 0x7D, 0x8000, 0xFFFF));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
31
sources/Memory/RectangleShadow.cpp
Normal file
31
sources/Memory/RectangleShadow.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// Created by anonymus-raccoon on 2/4/20.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "RectangleShadow.hpp"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace ComSquare::Memory
|
||||||
|
{
|
||||||
|
RectangleShadow::RectangleShadow(std::shared_ptr<IRectangleMemory> initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
|
||||||
|
: _initial(std::move(initial))
|
||||||
|
{
|
||||||
|
this->setMemoryRegion(startBank, endBank, startPage, endPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<IMemory> RectangleShadow::createShadow(std::shared_ptr<IRectangleMemory> initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
|
||||||
|
{
|
||||||
|
return static_cast<std::shared_ptr<IMemory>>(new RectangleShadow(std::move(initial), startBank, endBank, startPage, endPage));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t RectangleShadow::read_internal(uint24_t addr)
|
||||||
|
{
|
||||||
|
return this->_initial->read_internal(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RectangleShadow::write_internal(uint24_t addr, uint8_t data)
|
||||||
|
{
|
||||||
|
this->_initial->write_internal(addr, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
sources/Memory/RectangleShadow.hpp
Normal file
35
sources/Memory/RectangleShadow.hpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// Created by anonymus-raccoon on 2/4/20.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef COMSQUARE_RECTANGLESHADOW_HPP
|
||||||
|
#define COMSQUARE_RECTANGLESHADOW_HPP
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include "IRectangleMemory.hpp"
|
||||||
|
|
||||||
|
namespace ComSquare::Memory
|
||||||
|
{
|
||||||
|
class RectangleShadow : public IRectangleMemory {
|
||||||
|
private:
|
||||||
|
//! @brief Memory to shadow from.
|
||||||
|
std::shared_ptr<IRectangleMemory> _initial;
|
||||||
|
public:
|
||||||
|
//! @brief Create a shadow for the memory given as parameter.
|
||||||
|
explicit RectangleShadow(std::shared_ptr<IRectangleMemory> initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
|
||||||
|
|
||||||
|
static std::shared_ptr<IMemory> createShadow(std::shared_ptr<IRectangleMemory> initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
|
||||||
|
//! @brief Internal component read. Implement this as you would implement a basic IMemory's read.
|
||||||
|
//! @param addr The local address to read from. 0x0 refer to the first byte of your data and the address is in the component's space. That means that you can consider this address as continuous
|
||||||
|
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
|
||||||
|
//! @return Return the data at the address given as parameter.
|
||||||
|
uint8_t read_internal(uint24_t addr) override;
|
||||||
|
//! @brief Internal component write. Implement this as you would implement a basic IMemory's write.
|
||||||
|
//! @param addr The local address to write to. 0x0 refer to the first byte of your data and the address is in the component's space. That means that you can consider this address as continuous
|
||||||
|
//! @param data The new data to write.
|
||||||
|
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
|
||||||
|
void write_internal(uint24_t addr, uint8_t data) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //COMSQUARE_RECTANGLESHADOW_HPP
|
||||||
@@ -6,13 +6,15 @@
|
|||||||
|
|
||||||
namespace ComSquare
|
namespace ComSquare
|
||||||
{
|
{
|
||||||
SNES::SNES(const std::shared_ptr<Memory::MemoryBus> &bus, const std::string &romPath) :
|
SNES::SNES(const std::shared_ptr<Memory::MemoryBus> &bus, const std::string &romPath, Renderer::IRenderer &renderer) :
|
||||||
cpu(new CPU::CPU(bus)),
|
cpu(new CPU::CPU(bus)),
|
||||||
ppu(new PPU::PPU()),
|
ppu(new PPU::PPU()),
|
||||||
apu(new APU::APU()),
|
apu(new APU::APU()),
|
||||||
cartridge(new Cartridge::Cartridge(romPath)),
|
cartridge(new Cartridge::Cartridge(romPath)),
|
||||||
wram(new Ram::Ram(16384))
|
wram(new Ram::Ram(16384)),
|
||||||
|
sram(new Ram::Ram(this->cartridge->header.sramSize))
|
||||||
{
|
{
|
||||||
bus->mapComponents(*this);
|
bus->mapComponents(*this);
|
||||||
|
renderer.setWindowName(this->cartridge->header.gameName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,19 +11,27 @@
|
|||||||
#include "Ram/Ram.hpp"
|
#include "Ram/Ram.hpp"
|
||||||
#include "PPU/PPU.hpp"
|
#include "PPU/PPU.hpp"
|
||||||
#include "APU/APU.hpp"
|
#include "APU/APU.hpp"
|
||||||
|
#include "Renderer/IRenderer.hpp"
|
||||||
|
|
||||||
namespace ComSquare
|
namespace ComSquare
|
||||||
{
|
{
|
||||||
//! @brief Container of all the components of the SNES.
|
//! @brief Container of all the components of the SNES.
|
||||||
struct SNES {
|
struct SNES {
|
||||||
public:
|
public:
|
||||||
|
//! @brief Central Processing Unit of the SNES.
|
||||||
std::shared_ptr<CPU::CPU> cpu;
|
std::shared_ptr<CPU::CPU> cpu;
|
||||||
|
//! @brief Picture Processing Unit of the SNES
|
||||||
std::shared_ptr<PPU::PPU> ppu;
|
std::shared_ptr<PPU::PPU> ppu;
|
||||||
|
//! @brief Audio Processing Unit if the SNES
|
||||||
std::shared_ptr<APU::APU> apu;
|
std::shared_ptr<APU::APU> apu;
|
||||||
|
//! @brief Cartridge containing instructions (ROM).
|
||||||
std::shared_ptr<Cartridge::Cartridge> cartridge;
|
std::shared_ptr<Cartridge::Cartridge> cartridge;
|
||||||
|
//! @brief Work Ram shared by all the components.
|
||||||
std::shared_ptr<Ram::Ram> wram;
|
std::shared_ptr<Ram::Ram> wram;
|
||||||
|
//! @brief Save Ram residing inside the Cartridge in a real SNES.
|
||||||
|
std::shared_ptr<Ram::Ram> sram;
|
||||||
//! @brief Create all the components using a common memory bus for all of them.
|
//! @brief Create all the components using a common memory bus for all of them.
|
||||||
SNES(const std::shared_ptr<Memory::MemoryBus> &bus, const std::string &ramPath);
|
SNES(const std::shared_ptr<Memory::MemoryBus> &bus, const std::string &ramPath, Renderer::IRenderer &renderer);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user