ComSquare
Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ComSquare::Cartridge::Cartridge Class Reference

Contains the rom's memory/instructions. More...

#include <Cartridge.hpp>

Inheritance diagram for ComSquare::Cartridge::Cartridge:
Inheritance graph
Collaboration diagram for ComSquare::Cartridge::Cartridge:
Collaboration graph

Public Member Functions

 Cartridge (const std::string &romPath)
 Load a rom from it's path. More...
 
 ~Cartridge ()
 Destructor that free the cartridge data. More...
 
uint8_t read_internal (uint24_t addr) override
 Read from the rom. More...
 
void write_internal (uint24_t addr, uint8_t data) override
 Write data to the rom. More...
 

Public Attributes

Header header
 The header of the cartridge. More...
 

Private Member Functions

bool _loadHeader ()
 Set the public variable header by parsing the header in the ROM. More...
 
uint32_t _getHeaderAddress ()
 Get the address of the header. More...
 
Header _mapHeader (uint32_t headerAddress)
 Parse the memory to get a readable header. More...
 
- Private Member Functions inherited from ComSquare::Memory::IRectangleMemory
uint8_t read (uint24_t addr) override
 Read data from the component using the same method as the basic IMemory. More...
 
void write (uint24_t addr, uint8_t data) override
 Write data to this component using the same method as the basic IMemory. More...
 
bool hasMemoryAt (uint24_t addr) override
 Return true if this component has mapped the address. More...
 
uint24_t getStart () override
 Get the first address mapped to this component. More...
 
void setMemoryRegion (uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
 Change starting and ending points of this mapped memory. More...
 
- Private Member Functions inherited from ComSquare::Memory::IMemory
void setMemoryRegion (uint24_t start, uint24_t end)
 Change starting and ending points of this mapped memory. More...
 

Static Private Member Functions

static size_t getRomSize (const std::string &romPath)
 Get the size of a rom from it's path. More...
 

Private Attributes

uint8_t * _data
 The rom data (contains all the instructions). More...
 
size_t _size
 The size of the rom data. More...
 

Detailed Description

Contains the rom's memory/instructions.

Constructor & Destructor Documentation

◆ Cartridge()

ComSquare::Cartridge::Cartridge::Cartridge ( const std::string &  romPath)
explicit

Load a rom from it's path.

◆ ~Cartridge()

ComSquare::Cartridge::Cartridge::~Cartridge ( )

Destructor that free the cartridge data.

Member Function Documentation

◆ _getHeaderAddress()

uint32_t ComSquare::Cartridge::Cartridge::_getHeaderAddress ( )
private

Get the address of the header.

Returns
The address of this cartridge header.

◆ _loadHeader()

bool ComSquare::Cartridge::Cartridge::_loadHeader ( )
private

Set the public variable header by parsing the header in the ROM.

Returns
True if this cartridge has a SCM header, false otherwise.

◆ _mapHeader()

Header ComSquare::Cartridge::Cartridge::_mapHeader ( uint32_t  headerAddress)
private

Parse the memory to get a readable header.

Parameters
headerAddressThe address you want to parse.
Returns
A header struct representing the data at the memory address you passed.

◆ getRomSize()

size_t ComSquare::Cartridge::Cartridge::getRomSize ( const std::string &  romPath)
staticprivate

Get the size of a rom from it's path.

Parameters
romPathThe path of the rom to get info from.
Returns
The size of the rom.

◆ read_internal()

uint8_t ComSquare::Cartridge::Cartridge::read_internal ( uint24_t  addr)
overridevirtual

Read from the rom.

Parameters
addrThe address to read from. The address 0x0 should refer to the first byte of the rom's memory.
Exceptions
InvalidAddresswill be thrown if the address is more than the size of the rom's memory.
Returns
Return the data at the address.

Implements ComSquare::Memory::IRectangleMemory.

◆ write_internal()

void ComSquare::Cartridge::Cartridge::write_internal ( uint24_t  addr,
uint8_t  data 
)
overridevirtual

Write data to the rom.

Parameters
addrThe address to write to. The address 0x0 should refer to the first byte of the rom's memory.
dataThe data to write.
Exceptions
InvalidAddresswill be thrown if the address is more than the size of the rom's memory.

Implements ComSquare::Memory::IRectangleMemory.

Member Data Documentation

◆ _data

uint8_t* ComSquare::Cartridge::Cartridge::_data
private

The rom data (contains all the instructions).

◆ _size

size_t ComSquare::Cartridge::Cartridge::_size
private

The size of the rom data.

◆ header

Header ComSquare::Cartridge::Cartridge::header

The header of the cartridge.


The documentation for this class was generated from the following files: