Adding documentation

This commit is contained in:
AnonymusRaccoon
2020-01-27 19:02:49 +01:00
parent c1cfcf6881
commit ab71231fd8
4 changed files with 41 additions and 1 deletions
+1 -1
View File
@@ -36,4 +36,4 @@ add_executable(ComSquare
sources/PPU/Ppu.hpp
sources/APU/APU.hpp
sources/APU/APU.cpp
)
sources/Exceptions/InvalidAddress.hpp)
+16
View File
@@ -10,6 +10,7 @@
namespace ComSquare::Cartridge
{
//! @brief Exception thrown when someone tries to load an invalid rom.
class InvalidRomException : std::exception {
private:
std::string _msg;
@@ -18,14 +19,29 @@ namespace ComSquare::Cartridge
const char *what() const noexcept override { return this->_msg.c_str(); }
};
//! @brief Contains the rom's memory/instructions.
class Cartridge : IMemory {
private:
//! @brief The rom data (contains all the instructions).
unsigned char *_data;
//! @brief The size of the rom data.
size_t _size;
//! @brief Get the size of a rom from it's path.
//! @param romPath The path of the rom to get info from.
//! @return The size of the rom.
static size_t getRomSize(const std::string &romPath);
public:
//! @brief Load a rom from it's path.
explicit Cartridge(const std::string &romPath);
//! @brief Read from the rom.
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the rom's memory.
//! @throw InvalidAddress will be thrown if the address is less than 0 or more than the size of the rom's memory.
//! @return Return the data at the address.
uint8_t read(uint32_t addr) override;
//! @brief Write data to the rom.
//! @param addr The address to write to. The address 0x0 should refer to the first byte of the rom's memory.
//! @param data The data to write.
//! @throw InvalidAddress will be thrown if the address is less than 0 or more than the size of the rom's memory.
void write(uint32_t addr, uint8_t data) override;
};
}
+23
View File
@@ -0,0 +1,23 @@
//
// Created by anonymus-raccoon on 1/27/20.
//
#ifndef COMSQUARE_INVALIDADDRESS_HPP
#define COMSQUARE_INVALIDADDRESS_HPP
#include <exception>
#include <string>
namespace ComSquare
{
//! @brief Exception thrown when trying to read/write to an invalid address.
class InvalidAddress : std::exception {
private:
std::string _msg;
public:
explicit InvalidAddress(const std::string &msg) : _msg(msg) {}
const char *what() const noexcept override { return this->_msg.c_str(); }
};
}
#endif //COMSQUARE_INVALIDADDRESS_HPP
@@ -9,6 +9,7 @@
namespace ComSquare
{
//! @brief When this is thrown, it means that we should work more.
class NotImplementedException : std::exception {
public:
explicit NotImplementedException() = default;