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

The class containing all the registers of the PPU. More...

#include <PPU.hpp>

Inheritance diagram for ComSquare::PPU::PPU:
Collaboration diagram for ComSquare::PPU::PPU:

Public Member Functions

 PPU (Renderer::IRenderer &renderer)
 
 PPU (const PPU &)=delete
 
 ~PPU () override=default
 
PPUoperator= (const PPU &)=delete
 
uint8_t read (uint24_t addr) override
 Read data from the component. More...
 
void write (uint24_t addr, uint8_t data) override
 Write data to this component. More...
 
std::string getName () const override
 Get the name of this accessor (used for debug purpose) More...
 
Component getComponent () const override
 Get the component of this accessor (used for debug purpose) More...
 
uint24_t getSize () const override
 Get the size of the data. This size can be lower than the mapped data. More...
 
virtual void update (unsigned cycles)
 Update the PPU of n cycles. More...
 
uint16_t getVramAddress () const
 Give the Vram Address with the right Address remapping. More...
 
std::string getValueName (uint24_t addr) const override
 Give the name of the Address register (used for debug) More...
 
uint16_t cgramRead (uint16_t addr)
 Allow others components to read the CGRAM. More...
 
int getBPP (int bgNumber) const
 get the bpp depending of the bgNumber and the Bgmode More...
 
Vector2< int > getCharacterSize (int bgNumber) const
 Give the correct character size depending of the bgMode. More...
 
uint16_t getTileMapStartAddress (int bgNumber) const
 Give the address where the tilemap starts. More...
 
uint16_t getTilesetAddress (int bgNumber) const
 Give the address to find the correct tileset for a given x and y. More...
 
Vector2< bool > getBackgroundMirroring (int bgNumber) const
 Tells if the tilemap is expanded for the x and y directions. More...
 
void renderMainAndSubScreen ()
 Render the Main and sub screen correctly. More...
 
template<int levelLow, int levelHigh>
void addToMainSubScreen (Background &bg)
 Add a bg to the sub and/or main screen. More...
 
int getBgMode () const
 Get the current background Mode. More...
 
void updateVramReadBuffer ()
 update the Vram buffer More...
 
Vector2< int > getBgScroll (int bgNumber) const
 update the Vram buffer More...
 
const RegistersgetWriteRegisters () const
 Allow to look the value of each write register (used by Register debugger) More...
 
- Public Member Functions inherited from ComSquare::Memory::AMemory
uint24_t getRelativeAddress (uint24_t addr) const override
 Translate an absolute address to a relative address. More...
 
void setMemoryRegion (uint24_t start, uint24_t end)
 Change starting and ending points of this mapped memory. More...
 
bool hasMemoryAt (uint24_t addr) const override
 Return true if this component has mapped the address. More...
 
 ~AMemory () override=default
 A default destructor. More...
 
- Public Member Functions inherited from ComSquare::Memory::IMemory
virtual ~IMemory ()=default
 A virtual default destructor. More...
 

Public Attributes

Ram::Ram vram
 Rams. More...
 
Ram::Ram oamram
 
Ram::Ram cgram
 

Private Attributes

Registers _registers {}
 Init ppuRegisters. More...
 
Renderer::IRenderer_renderer
 
Background _backgrounds [4]
 Backgrounds buffers. More...
 
std::array< std::array< uint32_t, 1024 >, 1024 > _mainScreen
 Main Screen buffer. More...
 
std::array< std::array< uint8_t, 1024 >, 1024 > _mainScreenLevelMap
 
std::array< std::array< uint8_t, 1024 >, 1024 > _subScreenLevelMap
 Sub Screen buffer. More...
 
std::array< std::array< uint32_t, 1024 >, 1024 > _subScreen
 
std::array< std::array< uint32_t, 1024 >, 1024 > _screen
 Final Screen buffer. More...
 
uint16_t _vramReadBuffer = 0
 Used for vram read registers (0x2139 - 0x213A) More...
 
struct Utils::PpuState _ppuState
 Struct that contain all necessary vars for the use of the registers. More...
 

Additional Inherited Members

- Protected Attributes inherited from ComSquare::Memory::AMemory
uint24_t _start = 0
 The starting address mapped to this component. More...
 
uint24_t _end = 0
 The last continuous address mapped to this components. For shadows, see the MemoryShadow class. More...
 

Detailed Description

The class containing all the registers of the PPU.

Constructor & Destructor Documentation

◆ PPU() [1/2]

ComSquare::PPU::PPU::PPU ( Renderer::IRenderer renderer)
explicit

◆ PPU() [2/2]

ComSquare::PPU::PPU::PPU ( const PPU )
delete

◆ ~PPU()

ComSquare::PPU::PPU::~PPU ( )
overridedefault

Member Function Documentation

◆ addToMainSubScreen()

template<int levelLow, int levelHigh>
void ComSquare::PPU::PPU::addToMainSubScreen ( Background bg)
inline

Add a bg to the sub and/or main screen.

◆ cgramRead()

uint16_t ComSquare::PPU::PPU::cgramRead ( uint16_t  addr)

Allow others components to read the CGRAM.

◆ getBackgroundMirroring()

Vector2< bool > ComSquare::PPU::PPU::getBackgroundMirroring ( int  bgNumber) const

Tells if the tilemap is expanded for the x and y directions.

◆ getBgMode()

int ComSquare::PPU::PPU::getBgMode ( ) const

Get the current background Mode.

◆ getBgScroll()

Vector2< int > ComSquare::PPU::PPU::getBgScroll ( int  bgNumber) const

update the Vram buffer

◆ getBPP()

int ComSquare::PPU::PPU::getBPP ( int  bgNumber) const

get the bpp depending of the bgNumber and the Bgmode

◆ getCharacterSize()

Vector2< int > ComSquare::PPU::PPU::getCharacterSize ( int  bgNumber) const

Give the correct character size depending of the bgMode.

◆ getComponent()

Component ComSquare::PPU::PPU::getComponent ( ) const
overridevirtual

Get the component of this accessor (used for debug purpose)

Implements ComSquare::Memory::IMemory.

◆ getName()

std::string ComSquare::PPU::PPU::getName ( ) const
overridevirtual

Get the name of this accessor (used for debug purpose)

Implements ComSquare::Memory::IMemory.

◆ getSize()

uint24_t ComSquare::PPU::PPU::getSize ( ) const
overridevirtual

Get the size of the data. This size can be lower than the mapped data.

Returns
The number of bytes inside this memory.

Implements ComSquare::Memory::IMemory.

◆ getTileMapStartAddress()

uint16_t ComSquare::PPU::PPU::getTileMapStartAddress ( int  bgNumber) const

Give the address where the tilemap starts.

◆ getTilesetAddress()

uint16_t ComSquare::PPU::PPU::getTilesetAddress ( int  bgNumber) const

Give the address to find the correct tileset for a given x and y.

◆ getValueName()

std::string ComSquare::PPU::PPU::getValueName ( uint24_t  addr) const
overridevirtual

Give the name of the Address register (used for debug)

Implements ComSquare::Memory::IMemory.

◆ getVramAddress()

uint16_t ComSquare::PPU::PPU::getVramAddress ( ) const

Give the Vram Address with the right Address remapping.

◆ getWriteRegisters()

const Registers & ComSquare::PPU::PPU::getWriteRegisters ( ) const

Allow to look the value of each write register (used by Register debugger)

◆ operator=()

PPU& ComSquare::PPU::PPU::operator= ( const PPU )
delete

◆ read()

uint8_t ComSquare::PPU::PPU::read ( uint24_t  addr)
overridevirtual

Read data from the component.

Parameters
addrThe local address to read from (0x0 should refer to the first byte of this component).
Exceptions
Thisfunction should thrown an InvalidAddress for address that are not mapped to the component.
Returns
Return the data at the address given as parameter.

Implements ComSquare::Memory::IMemory.

◆ renderMainAndSubScreen()

void ComSquare::PPU::PPU::renderMainAndSubScreen ( )

Render the Main and sub screen correctly.

◆ update()

void ComSquare::PPU::PPU::update ( unsigned  cycles)
virtual

Update the PPU of n cycles.

Parameters
Thenumber of cycles to update.

◆ updateVramReadBuffer()

void ComSquare::PPU::PPU::updateVramReadBuffer ( )

update the Vram buffer

◆ write()

void ComSquare::PPU::PPU::write ( uint24_t  addr,
uint8_t  data 
)
overridevirtual

Write data to this component.

Parameters
addrThe local address to write data (0x0 should refer to the first byte of this component).
dataThe new data to write.
Exceptions
Thisfunction should thrown an InvalidAddress for address that are not mapped to the component.

Implements ComSquare::Memory::IMemory.

Member Data Documentation

◆ _backgrounds

Background ComSquare::PPU::PPU::_backgrounds[4]
private

Backgrounds buffers.

◆ _mainScreen

std::array<std::array<uint32_t, 1024>, 1024> ComSquare::PPU::PPU::_mainScreen
private

Main Screen buffer.

◆ _mainScreenLevelMap

std::array<std::array<uint8_t, 1024>, 1024> ComSquare::PPU::PPU::_mainScreenLevelMap
private

◆ _ppuState

struct Utils::PpuState ComSquare::PPU::PPU::_ppuState
private

Struct that contain all necessary vars for the use of the registers.

◆ _registers

Registers ComSquare::PPU::PPU::_registers {}
private

Init ppuRegisters.

◆ _renderer

Renderer::IRenderer& ComSquare::PPU::PPU::_renderer
private

◆ _screen

std::array<std::array<uint32_t, 1024>, 1024> ComSquare::PPU::PPU::_screen
private

Final Screen buffer.

◆ _subScreen

std::array<std::array<uint32_t, 1024>, 1024> ComSquare::PPU::PPU::_subScreen
private

◆ _subScreenLevelMap

std::array<std::array<uint8_t, 1024>, 1024> ComSquare::PPU::PPU::_subScreenLevelMap
private

Sub Screen buffer.

◆ _vramReadBuffer

uint16_t ComSquare::PPU::PPU::_vramReadBuffer = 0
private

Used for vram read registers (0x2139 - 0x213A)

◆ cgram

Ram::Ram ComSquare::PPU::PPU::cgram

◆ oamram

Ram::Ram ComSquare::PPU::PPU::oamram

◆ vram

Ram::Ram ComSquare::PPU::PPU::vram

Rams.


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