general fixing (indent unused functions etc)

This commit is contained in:
Clément Le Bihan
2021-06-23 00:24:28 +02:00
parent a4333e22cb
commit e7ee90c652
9 changed files with 169 additions and 324 deletions
+123 -118
View File
@@ -125,124 +125,129 @@ set(CMAKE_AUTOUIC ON)
# make app # make app
add_executable(ComSquare add_executable(ComSquare
sources/main.cpp sources/main.cpp
sources/SNES.cpp sources/SNES.cpp
sources/SNES.hpp sources/SNES.hpp
sources/Memory/MemoryBus.cpp sources/Memory/MemoryBus.cpp
sources/Memory/MemoryBus.hpp sources/Memory/MemoryBus.hpp
sources/Memory/AMemory.hpp sources/Memory/AMemory.hpp
sources/Memory/AMemory.cpp sources/Memory/AMemory.cpp
sources/PPU/PPU.cpp sources/PPU/PPU.cpp
sources/PPU/PPU.hpp sources/PPU/PPU.hpp
sources/CPU/CPU.cpp sources/CPU/CPU.cpp
sources/CPU/CPU.hpp sources/CPU/CPU.hpp
sources/Cartridge/Cartridge.cpp sources/Cartridge/Cartridge.cpp
sources/Cartridge/Cartridge.hpp sources/Cartridge/Cartridge.hpp
sources/Exceptions/NotImplementedException.hpp sources/Exceptions/NotImplementedException.hpp
sources/APU/APU.hpp sources/APU/APU.hpp
sources/APU/APU.cpp sources/APU/APU.cpp
sources/Exceptions/InvalidAddress.hpp sources/Exceptions/InvalidAddress.hpp
sources/Exceptions/InvalidRom.hpp sources/Exceptions/InvalidRom.hpp
sources/Models/Int24.hpp sources/Models/Int24.hpp
sources/Models/Int24.hpp sources/Models/Int24.hpp
sources/Ram/Ram.cpp sources/Ram/Ram.cpp
sources/Ram/Ram.hpp sources/Ram/Ram.hpp
sources/Memory/MemoryShadow.cpp sources/Memory/MemoryShadow.cpp
sources/Memory/MemoryShadow.hpp sources/Memory/MemoryShadow.hpp
sources/Memory/ARectangleMemory.cpp sources/Memory/ARectangleMemory.cpp
sources/Memory/ARectangleMemory.hpp sources/Memory/ARectangleMemory.hpp
sources/APU/DSP/DSP.cpp sources/APU/DSP/DSP.cpp
sources/APU/DSP/DSP.hpp sources/APU/DSP/DSP.hpp
sources/Renderer/IRenderer.hpp sources/Renderer/IRenderer.hpp
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.cpp
sources/Memory/RectangleShadow.hpp sources/Memory/RectangleShadow.hpp
sources/Exceptions/InvalidOpcode.hpp sources/Exceptions/InvalidOpcode.hpp
sources/CPU/Instructions/Interrupts.cpp sources/CPU/Instructions/Interrupts.cpp
sources/CPU/Instructions/MathematicalOperations.cpp sources/CPU/Instructions/MathematicalOperations.cpp
sources/APU/Instructions/Standbys.cpp sources/APU/Instructions/Standbys.cpp
sources/APU/Instructions/ProgramStatusWord.cpp sources/APU/Instructions/ProgramStatusWord.cpp
sources/APU/Instructions/Bit.cpp sources/APU/Instructions/Bit.cpp
sources/CPU/Instructions/MathematicalOperations.cpp sources/CPU/Instructions/MathematicalOperations.cpp
sources/CPU/Instructions/MemoryInstructions.cpp sources/CPU/Instructions/MemoryInstructions.cpp
sources/CPU/Instructions/InternalInstruction.cpp sources/CPU/Instructions/InternalInstruction.cpp
sources/Ram/ExtendedRam.cpp sources/Ram/ExtendedRam.cpp
sources/Ram/ExtendedRam.hpp sources/Ram/ExtendedRam.hpp
sources/Debugger/CPU/CPUDebug.cpp sources/Debugger/CPU/CPUDebug.cpp
sources/Debugger/CPU/CPUDebug.hpp sources/Debugger/CPU/CPUDebug.hpp
sources/Renderer/QtRenderer/QtSFML.cpp sources/Renderer/QtRenderer/QtSFML.cpp
sources/Renderer/QtRenderer/QtSFML.hpp sources/Renderer/QtRenderer/QtSFML.hpp
sources/Renderer/QtRenderer/QtWidgetSFML.cpp sources/Renderer/QtRenderer/QtWidgetSFML.cpp
sources/Renderer/QtRenderer/QtWidgetSFML.hpp sources/Renderer/QtRenderer/QtWidgetSFML.hpp
ui/cpuView.ui ui/cpuView.ui
ui/ramView.ui ui/ramView.ui
ui/cartridgeView.ui ui/cartridgeView.ui
ui/apuView.ui ui/apuView.ui
ui/busView.ui ui/busView.ui
resources/appResources.qrc resources/appResources.qrc
sources/Utility/Utility.hpp sources/Utility/Utility.hpp
sources/Debugger/MemoryViewer.cpp sources/Debugger/MemoryViewer.cpp
sources/Debugger/MemoryViewer.hpp sources/Debugger/MemoryViewer.hpp
sources/Utility/Utility.cpp sources/Utility/Utility.cpp
sources/Debugger/HeaderViewer.cpp sources/Debugger/HeaderViewer.cpp
sources/Debugger/HeaderViewer.hpp sources/Debugger/HeaderViewer.hpp
sources/CPU/Instructions/BitsInstructions.cpp sources/CPU/Instructions/BitsInstructions.cpp
sources/Debugger/HeaderViewer.cpp sources/Debugger/HeaderViewer.cpp
sources/Debugger/HeaderViewer.hpp sources/Debugger/HeaderViewer.hpp
sources/Debugger/APUDebug.hpp sources/Debugger/APUDebug.hpp
sources/Debugger/APUDebug.cpp sources/Debugger/APUDebug.cpp
sources/APU/Instructions/Stack.cpp sources/APU/Instructions/Stack.cpp
sources/APU/Instructions/Subroutine.cpp sources/APU/Instructions/Subroutine.cpp
sources/APU/Instructions/ProgramFlow.cpp sources/APU/Instructions/ProgramFlow.cpp
sources/APU/Operand.cpp sources/APU/Operand.cpp
sources/APU/Instructions/DecimalCompensation.cpp sources/APU/Instructions/DecimalCompensation.cpp
sources/APU/Instructions/MultiplicationDivision.cpp sources/APU/Instructions/MultiplicationDivision.cpp
sources/APU/Instructions/16bitArithmetic.cpp sources/APU/Instructions/16bitArithmetic.cpp
sources/APU/Instructions/16bitDataTransmission.cpp sources/APU/Instructions/16bitDataTransmission.cpp
sources/APU/Instructions/8bitShiftRotation.cpp sources/APU/Instructions/8bitShiftRotation.cpp
sources/APU/Instructions/8bitIncrementDecrement.cpp sources/APU/Instructions/8bitIncrementDecrement.cpp
sources/APU/Instructions/8bitLogical.cpp sources/APU/Instructions/8bitLogical.cpp
sources/APU/Instructions/8bitArithmetic.cpp sources/APU/Instructions/8bitArithmetic.cpp
sources/APU/Instructions/8bitDataTransmission.cpp sources/APU/Instructions/8bitDataTransmission.cpp
sources/APU/IPL/IPL.hpp sources/APU/IPL/IPL.hpp
sources/APU/IPL/IPL.cpp sources/APU/IPL/IPL.cpp
sources/CPU/Instructions/TransferRegisters.cpp sources/CPU/Instructions/TransferRegisters.cpp
sources/CPU/AddressingModes.cpp sources/CPU/AddressingModes.cpp
sources/Debugger/MemoryBusDebug.cpp sources/Debugger/MemoryBusDebug.cpp
sources/Debugger/MemoryBusDebug.hpp sources/Debugger/MemoryBusDebug.hpp
sources/Debugger/ClosableWindow.hpp sources/Debugger/ClosableWindow.hpp
sources/Models/Components.hpp sources/Models/Components.hpp
sources/CPU/Instruction.hpp sources/CPU/Instruction.hpp
sources/Exceptions/DebuggableError.hpp sources/Exceptions/DebuggableError.hpp
sources/Debugger/CPU/Disassembly.cpp sources/Debugger/CPU/Disassembly.cpp
sources/Models/Components.hpp sources/Models/Components.hpp
sources/Debugger/CGramDebug.cpp sources/Debugger/CGramDebug.cpp
sources/Debugger/CGramDebug.hpp sources/Debugger/CGramDebug.hpp
sources/Models/Vector2.hpp sources/Models/Vector2.hpp
sources/PPU/Background.cpp sources/PPU/Background.cpp
sources/PPU/Background.hpp sources/PPU/Background.hpp
sources/CPU/DMA/DMA.cpp sources/CPU/DMA/DMA.cpp
sources/CPU/DMA/DMA.hpp sources/CPU/DMA/DMA.hpp
ui/registersView.ui ui/registersView.ui
sources/Debugger/RegisterViewer.cpp sources/Debugger/RegisterViewer.cpp
sources/Debugger/RegisterViewer.hpp sources/Debugger/RegisterViewer.hpp
sources/Memory/IMemory.hpp sources/Memory/IMemory.hpp
sources/APU/DSP/Voice.cpp sources/APU/DSP/Voice.cpp
sources/APU/DSP/Echo.cpp sources/APU/DSP/Echo.cpp
sources/APU/DSP/Gauss.cpp sources/APU/DSP/Gauss.cpp
sources/APU/DSP/Envelope.cpp sources/APU/DSP/Envelope.cpp
sources/APU/DSP/Timer.cpp sources/APU/DSP/Timer.cpp
sources/APU/DSP/BRR.cpp sources/APU/DSP/BRR.cpp
sources/PPU/PPUUtils.cpp sources/PPU/PPUUtils.cpp
ui/tileView.ui ui/tileView.ui
sources/Renderer/QtRenderer/QtRenderSfml.cpp sources/Debugger/TileViewer/TileViewer.cpp
sources/Renderer/QtRenderer/QtRenderSfml.hpp sources/Debugger/TileViewer/TileViewer.hpp
sources/Debugger/TileViewer/TileViewer.cpp sources/Debugger/TileViewer/RAMTileRenderer.cpp
sources/Debugger/TileViewer/TileViewer.hpp sources/Debugger/TileViewer/RAMTileRenderer.hpp
sources/Debugger/TileViewer/RAMTileRenderer.cpp sources/Debugger/TileViewer/RAMTileRenderer.hpp sources/PPU/Tile.hpp sources/Renderer/QtRenderer/QtSfmlTileRenderer.cpp sources/Renderer/QtRenderer/QtSfmlTileRenderer.hpp sources/PPU/TileRenderer.cpp sources/PPU/TileRenderer.hpp) sources/PPU/Tile.hpp
sources/Renderer/QtRenderer/QtSfmlTileRenderer.cpp
sources/Renderer/QtRenderer/QtSfmlTileRenderer.hpp
sources/PPU/TileRenderer.cpp
sources/PPU/TileRenderer.hpp
)
include_directories(ComSquare sources) include_directories(ComSquare sources)
+13 -13
View File
@@ -25,10 +25,10 @@ namespace ComSquare::Debugger
_snes(snes), _snes(snes),
_ui(), _ui(),
_ppu(ppu), _ppu(ppu),
_tileRenderer() _ramTileRenderer()
{ {
this->_tileRenderer.setRam(ppu.vram); this->_ramTileRenderer.setRam(ppu.vram);
this->_tileRenderer.setCgram(ppu.cgram); this->_ramTileRenderer.setCgram(ppu.cgram);
this->_window->setContextMenuPolicy(Qt::NoContextMenu); this->_window->setContextMenuPolicy(Qt::NoContextMenu);
this->_window->setAttribute(Qt::WA_QuitOnClose, false); this->_window->setAttribute(Qt::WA_QuitOnClose, false);
this->_window->setAttribute(Qt::WA_DeleteOnClose); this->_window->setAttribute(Qt::WA_DeleteOnClose);
@@ -69,7 +69,7 @@ namespace ComSquare::Debugger
void TileViewer::setPaletteIndex(int paletteIndex) void TileViewer::setPaletteIndex(int paletteIndex)
{ {
this->_tileRenderer.setPaletteIndex(paletteIndex); this->_ramTileRenderer.setPaletteIndex(paletteIndex);
this->internalUpdate(); this->internalUpdate();
} }
@@ -92,46 +92,46 @@ namespace ComSquare::Debugger
this->_ui.PaletteIndex->setMaximum(63); this->_ui.PaletteIndex->setMaximum(63);
break; break;
} }
this->_tileRenderer.setBpp(bpp); this->_ramTileRenderer.setBpp(bpp);
this->internalUpdate(); this->internalUpdate();
} }
void TileViewer::setNbColumns(int nbColumns) void TileViewer::setNbColumns(int nbColumns)
{ {
this->_tileRenderer.setNbColumns(nbColumns); this->_ramTileRenderer.setNbColumns(nbColumns);
this->internalUpdate(); this->internalUpdate();
} }
void TileViewer::setRenderSize(int size) void TileViewer::setRenderSize(int size)
{ {
this->_tileRenderer.setRenderSize(size); this->_ramTileRenderer.setRenderSize(size);
this->internalUpdate(); this->internalUpdate();
} }
int TileViewer::getBpp() const int TileViewer::getBpp() const
{ {
return this->_tileRenderer.getBpp(); return this->_ramTileRenderer.getBpp();
} }
int TileViewer::getPaletteIndex() const int TileViewer::getPaletteIndex() const
{ {
return this->_tileRenderer.getPaletteIndex(); return this->_ramTileRenderer.getPaletteIndex();
} }
int TileViewer::getNbColumns() const int TileViewer::getNbColumns() const
{ {
return this->_tileRenderer.getNbColumns(); return this->_ramTileRenderer.getNbColumns();
} }
void TileViewer::internalUpdate() void TileViewer::internalUpdate()
{ {
this->_tileRenderer.render(); this->_ramTileRenderer.render();
this->_sfWidget->buffer = this->_tileRenderer.buffer; this->_sfWidget->buffer = this->_ramTileRenderer.buffer;
} }
void TileViewer::setRamOffset(int offset) void TileViewer::setRamOffset(int offset)
{ {
this->_tileRenderer.setRamOffset(offset); this->_ramTileRenderer.setRamOffset(offset);
this->internalUpdate(); this->internalUpdate();
} }
+7 -4
View File
@@ -36,18 +36,21 @@ namespace ComSquare::Debugger
ComSquare::PPU::PPU &_ppu; ComSquare::PPU::PPU &_ppu;
//! @brief the window //! @brief the window
std::unique_ptr<Renderer::QtSFMLTileRenderer> _sfWidget; std::unique_ptr<Renderer::QtSFMLTileRenderer> _sfWidget;
//! @brief The tile renderer //! @brief The ram tile renderer
RAMTileRenderer _tileRenderer; RAMTileRenderer _ramTileRenderer;
//! @brief Change the bpp from the index given by the ui (QT combo box) //! @brief Change the bpp from the index given by the ui (QT combo box)
void _bppChangeUIHandler(int index); void _bppChangeUIHandler(int index);
public: public:
//! @brief Called when the window is closed. Turn off the debugger. //! @brief Called when the window is closed. Turn off the debugger.
void disableViewer(); void disableViewer();
public: //! @brief ctor
explicit TileViewer(SNES &snes, ComSquare::PPU::PPU &ppu); explicit TileViewer(SNES &snes, ComSquare::PPU::PPU &ppu);
//! @brief copy ctor
TileViewer(const TileViewer &) = delete; TileViewer(const TileViewer &) = delete;
//! @brief dtor
~TileViewer() override = default;
//! @brief assignment operator
TileViewer &operator=(const TileViewer &) = delete; TileViewer &operator=(const TileViewer &) = delete;
~TileViewer() = default;
//! @brief Read data at the CGRAM address send it to the debugger. //! @brief Read data at the CGRAM address send it to the debugger.
//! @param addr The address to read from. //! @param addr The address to read from.
+7 -78
View File
@@ -41,7 +41,7 @@ namespace ComSquare::PPU
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (!(i == 1 && this->_tileMapsConfig.x == 1) && !(i > 1 && this->_tileMapsConfig.y == 1)) { if (!(i == 1 && this->_tileMapsConfig.x == 1) && !(i > 1 && this->_tileMapsConfig.y == 1)) {
drawBasicTileMap(vramAddress, offset); _drawBasicTileMap(vramAddress, offset);
} }
vramAddress += TileMapByteSize; vramAddress += TileMapByteSize;
offset.x += NbCharacterWidth * this->_characterNbPixels.x; offset.x += NbCharacterWidth * this->_characterNbPixels.x;
@@ -52,7 +52,7 @@ namespace ComSquare::PPU
} }
} }
void Background::drawBgTile(uint16_t data, Vector2<int> pos) void Background::_drawBgTile(uint16_t data, Vector2<int> pos)
{ {
union TileMapData tileData; union TileMapData tileData;
@@ -67,8 +67,8 @@ namespace ComSquare::PPU
// Y vertical // Y vertical
this->_tileRenderer.setPaletteIndex(tileData.palette); this->_tileRenderer.setPaletteIndex(tileData.palette);
for (int i = 0; i < this->_characterNbPixels.y; i += 8) { for (int i = 0; i < this->_characterNbPixels.y; i += Tile::NbPixelsHeight) {
for (int j = 0; j < this->_characterNbPixels.x; j += 8) { for (int j = 0; j < this->_characterNbPixels.x; j += Tile::NbPixelsWidth) {
graphicAddress = this->_tilesetAddress + graphicAddress = this->_tilesetAddress +
((tileData.posY + tileOffset.y) * NbTilePerRow * this->_bpp * Tile::BaseByteSize) + ((tileData.posY + tileOffset.y) * NbTilePerRow * this->_bpp * Tile::BaseByteSize) +
((tileData.posX + tileOffset.x) * this->_bpp * Tile::BaseByteSize); ((tileData.posX + tileOffset.x) * this->_bpp * Tile::BaseByteSize);
@@ -95,74 +95,7 @@ namespace ComSquare::PPU
} }
} }
std::vector<uint16_t> Background::getPalette(int nbPalette) void Background::_drawBasicTileMap(uint16_t baseAddress, Vector2<int> offset)
{
uint8_t nbColors = std::pow(2, this->_bpp);
uint16_t addr = nbPalette * this->_bpp * this->_bpp * 2; // 2 because it's 2 addr for 1 color
std::vector<uint16_t> palette(nbColors);
switch (this->_ppu.getBgMode()) {
case 0:
addr += (this->_bgNumber - 1) * (4 * 8) * 2;
break;
default:
break;
}
for (int i = 0; i < nbColors; i++) {
palette[i] = this->_cgram->read(addr);
palette[i] += this->_cgram->read(addr + 1) << 8U;
addr += 2;
}
return palette;
}
uint8_t Background::getPixelReferenceFromTile(uint16_t tileAddress, uint8_t pixelIndex)
{
uint8_t row = pixelIndex / this->_characterNbPixels.x;
uint8_t column = pixelIndex % this->_characterNbPixels.y;
if (row >= Tile::NbPixelsHeight) {
tileAddress += 0x80 * this->_bpp;
row -= Tile::NbPixelsHeight;
}
if (column >= Tile::NbPixelsWidth) {
tileAddress += 0x8 * this->_bpp;
column -= Tile::NbPixelsWidth;
}
// TODO might not work with 8 bpp must check
tileAddress += 2 * row;
return this->getPixelReferenceFromTileRow(tileAddress, column);
}
uint8_t Background::getPixelReferenceFromTileRow(uint16_t tileRowAddress, uint8_t pixelIndex)
{
uint8_t highByte = this->_vram->read(tileRowAddress % VRAMSIZE);
uint8_t lowByte = this->_vram->read((tileRowAddress + 1) % VRAMSIZE);
uint8_t secondHighByte;
uint8_t secondLowByte;
uint16_t result = 0;
uint8_t shift = Tile::NbPixelsWidth - 1U - pixelIndex;
switch (this->_bpp) {
case 8:
return highByte;
case 4:
secondHighByte = this->_vram->read((tileRowAddress + 16) % VRAMSIZE);
secondLowByte = this->_vram->read((tileRowAddress + 17) % VRAMSIZE);
result = ((secondHighByte & (1U << shift)) | ((secondLowByte & (1U << shift)) << 1U));
result = (shift - 2 >= 0) ? result >> (shift - 2) : result << ((shift - 2) * -1);
FALLTHROUGH
case 2:
result += ((highByte & (1U << shift)) | ((lowByte & (1U << shift)) << 1U)) >> shift;
default:
break;
}
return result;
}
void Background::drawBasicTileMap(uint16_t baseAddress, Vector2<int> offset)
{ {
uint16_t tileMapValue = 0; uint16_t tileMapValue = 0;
Vector2<int> pos(0, 0); Vector2<int> pos(0, 0);
@@ -172,7 +105,8 @@ namespace ComSquare::PPU
// TODO function to read 2 bytes (LSB order or bits reversed) // TODO function to read 2 bytes (LSB order or bits reversed)
tileMapValue = this->_vram->read(vramAddress); tileMapValue = this->_vram->read(vramAddress);
tileMapValue += this->_vram->read(vramAddress + 1) << 8U; tileMapValue += this->_vram->read(vramAddress + 1) << 8U;
drawBgTile(tileMapValue, {(pos.x * this->_characterNbPixels.x) + offset.x, (pos.y * this->_characterNbPixels.y) + offset.y}); _drawBgTile(tileMapValue, {(pos.x * this->_characterNbPixels.x) + offset.x,
(pos.y * this->_characterNbPixels.y) + offset.y});
vramAddress += 2; vramAddress += 2;
if (pos.x % 31 == 0 && pos.x) { if (pos.x % 31 == 0 && pos.x) {
pos.y++; pos.y++;
@@ -212,11 +146,6 @@ namespace ComSquare::PPU
this->_tileMapsConfig = tileMaps; this->_tileMapsConfig = tileMaps;
} }
void Background::setBgNumber(int bgNumber)
{
this->_bgNumber = bgNumber;
}
int Background::getBgNumber() const int Background::getBgNumber() const
{ {
return this->_bgNumber; return this->_bgNumber;
+3 -19
View File
@@ -58,25 +58,11 @@ namespace ComSquare::PPU
//! @brief The access to cgram //! @brief The access to cgram
std::shared_ptr<Ram::Ram> _cgram; std::shared_ptr<Ram::Ram> _cgram;
//! @brief Draw a tile on the screen at x y pos //! @brief Draw a tile on the screen at x y pos
void drawBgTile(uint16_t data, Vector2<int> pos); void _drawBgTile(uint16_t data, Vector2<int> pos);
//! @brief Get a palette from the number of the palette
//! @param nbPalette The palette number (0 - 7)
//! @return The array of color of the palette
std::vector<uint16_t> getPalette(int nbPalette);
//! @brief Get the color reference of a pixel from the address of the row
//! @param tileRowAddress The address of the line of pixel
//! @param pixelIndex The index of the pixel (0 - 7)
//! @return The color Reference
uint8_t getPixelReferenceFromTileRow(uint16_t tileRowAddress, uint8_t pixelIndex);
//! @brief Get the color pixel reference from the tile address
//! @param tileAddress The starting address of the tile
//! @param pixelIndex The index of the pixel (0 - 255)
//! @return The color reference
uint8_t getPixelReferenceFromTile(uint16_t tileAddress, uint8_t pixelIndex);
//! @brief draw a tileMap 32x32 starting at baseAddress //! @brief draw a tileMap 32x32 starting at baseAddress
//! @param baseAddress The starting address of the tileMap //! @param baseAddress The starting address of the tileMap
//! @param offset The rendering offeset in pixels //! @param offset The rendering offeset in pixels
void drawBasicTileMap(uint16_t baseAddress, Vector2<int> offset); void _drawBasicTileMap(uint16_t baseAddress, Vector2<int> offset);
public: public:
//! @brief The size of the background (x, y) //! @brief The size of the background (x, y)
Vector2<unsigned> backgroundSize; Vector2<unsigned> backgroundSize;
@@ -99,9 +85,7 @@ namespace ComSquare::PPU
//! @brief setter for private variable _tileMaps //! @brief setter for private variable _tileMaps
//! @param tileMaps The tileMaps to set //! @param tileMaps The tileMaps to set
void setTilemaps(Vector2<int> tileMaps); void setTilemaps(Vector2<int> tileMaps);
//! @brief set the Background number
//! @param bgNumber the new Background Number
void setBgNumber(int bgNumber);
//! @brief Get the BackGround Number //! @brief Get the BackGround Number
//! @return the current Background number //! @return the current Background number
int getBgNumber() const; int getBgNumber() const;
+7 -7
View File
@@ -44,7 +44,7 @@ namespace ComSquare::PPU
this->cgram->write(67, 0x7F); this->cgram->write(67, 0x7F);
//tiles //tiles
int vram_test[] = { /* int vram_test[] = {
00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, 03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
@@ -75,17 +75,17 @@ namespace ComSquare::PPU
00,0x03,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x0c,0x00,0x18,0x00,0xf0,0x00,0xe0, 00,0x03,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x0c,0x00,0x18,0x00,0xf0,0x00,0xe0,
00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00,0xe0,0x00,0xf0,0x00,0xf8,0x00,0xfc,0x00, 00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00,0xe0,0x00,0xf0,0x00,0xf8,0x00,0xfc,0x00,
00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x07,0x00,0x0f,00,0x1f,00,0x3f,00, -1 00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x07,0x00,0x0f,00,0x1f,00,0x3f,00, -1
}; };*/
/*int *cgram_test = get_dump_cgram(); int *cgram_test = get_dump_cgram();
for (int i = 0; cgram_test[i] != -1; i++) { for (int i = 0; cgram_test[i] != -1; i++) {
this->cgram->write(i, cgram_test[i]); this->cgram->write(i, cgram_test[i]);
} }
int *vram_test = get_dump_vram(); */ int *vram_test = get_dump_vram();
for (int i = 0; vram_test[i] != -1; i++) { for (int i = 0; vram_test[i] != -1; i++) {
this->vram->write(i, vram_test[i]); this->vram->write(i, vram_test[i]);
} }
int vram_test_2[] = {8, 00, 02, 00, 0x0A, 00, 02, 00, 0x0A, 00, 00, 00, 00, 00, 00, -1}; /* int vram_test_2[] = {8, 00, 02, 00, 0x0A, 00, 02, 00, 0x0A, 00, 00, 00, 00, 00, 00, -1};
for (int i = 0; vram_test_2[i] != -1; i++) { for (int i = 0; vram_test_2[i] != -1; i++) {
this->vram->write(i + 0x8000, vram_test_2[i]); this->vram->write(i + 0x8000, vram_test_2[i]);
} }
@@ -144,8 +144,8 @@ namespace ComSquare::PPU
//this->_registers._bgofs[3].raw = 0x03DF; //this->_registers._bgofs[3].raw = 0x03DF;
this->_registers._t[0].enableWindowDisplayBg1 = true; this->_registers._t[0].enableWindowDisplayBg1 = true;
this->_registers._t[0].enableWindowDisplayBg2 = true; this->_registers._t[0].enableWindowDisplayBg2 = true;
*/
/*
//registers aladin //registers aladin
this->_registers._bgmode.bgMode = 1; this->_registers._bgmode.bgMode = 1;
@@ -199,7 +199,7 @@ namespace ComSquare::PPU
this->_registers._t[0].enableWindowDisplayBg1 = true; this->_registers._t[0].enableWindowDisplayBg1 = true;
this->_registers._t[0].enableWindowDisplayBg2 = true; this->_registers._t[0].enableWindowDisplayBg2 = true;
this->_registers._t[0].enableWindowDisplayBg3 = true; this->_registers._t[0].enableWindowDisplayBg3 = true;
*/
} }
+9 -2
View File
@@ -35,12 +35,19 @@ namespace ComSquare::PPU
int getBpp() const; int getBpp() const;
//! @brief Get the index of the current palette used //! @brief Get the index of the current palette used
int getPaletteIndex() const; int getPaletteIndex() const;
//! @brief Gives the reference of pixel using the tileAddress and the pixelIndex //! @brief Get the color pixel reference from the tile address and pixelIndex
//! @param tileAddress The starting address of the tile
//! @param pixelIndex The index of the pixel (0 - 255)
//! @return The color reference
//! @note This function is wrapper of getPixelReferenceFromTileRow //! @note This function is wrapper of getPixelReferenceFromTileRow
uint8_t getPixelReferenceFromTile(uint16_t tileAddress, uint8_t pixelIndex); uint8_t getPixelReferenceFromTile(uint16_t tileAddress, uint8_t pixelIndex);
//! @brief get the pixel color reference to use in the selected palette //! @brief Get the color reference of a pixel from the address of the row
//! @param tileRowAddress The address of the line of pixel
//! @param pixelIndex The index of the pixel (0 - 7)
//! @return The color Reference
uint8_t getPixelReferenceFromTileRow(uint16_t tileRowAddress, uint8_t pixelIndex); uint8_t getPixelReferenceFromTileRow(uint16_t tileRowAddress, uint8_t pixelIndex);
//! @brief Gives the actual selected palette with all of it's colors //! @brief Gives the actual selected palette with all of it's colors
//! @return The array of color of the palette
//! @warning Values are CGRAM colors use PPU::getRealColor function to get the actual real color //! @warning Values are CGRAM colors use PPU::getRealColor function to get the actual real color
std::vector<uint16_t> getPalette(int nbPalette); std::vector<uint16_t> getPalette(int nbPalette);
//! @brief read the 2bpp value for a pixel (used multple times for 4bpp and 8bpp) //! @brief read the 2bpp value for a pixel (used multple times for 4bpp and 8bpp)
@@ -1,28 +0,0 @@
//
// Created by cbihan on 18/05/2021.
//
#include "QtRenderSfml.hpp"
#include <iostream>
namespace ComSquare::Renderer
{/*
QtRenderSFML::QtRenderSFML(ComSquare::SNES &snes, QWidget *parent, const QPoint &position, const QSize &size, int frameRate)
: QtWidgetSFML(parent, position, size, frameRate),
_snes(snes)
{
}
void QtRenderSFML::_onUpdate()
{
try {
this->_snes.update();
} catch (const DebuggableError &e) {
std::cout << "Invalid rom's instruction: " << e.what() << std::endl;
this->_snes.enableCPUDebuggingWithError(e);
} catch (std::exception &e) {
std::cerr << "An error occurred: " << e.what() << std::endl;
QApplication::quit();
}
}*/
}
@@ -1,55 +0,0 @@
//
// Created by cbihan on 18/05/2021.
//
#pragma once
#include <QtWidgets/QWidget>
#include <SFML/Graphics/RenderWindow.hpp>
#include <QtCore/QTimer>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QGridLayout>
#include "../IRenderer.hpp"
#include "../SFRenderer.hpp"
#include "QtWidgetSFML.hpp"
#include "QtSFML.hpp"
namespace ComSquare::Renderer
{
class QtRenderSFML : public QtWidgetSFML
{
private:
//! @brief The main window that the app reside on.
//QMainWindow _window;
QWidget _window;
//! @brief The SFML widget.
std::unique_ptr<QtFullSFML> _sfWidget = nullptr;
public:
void setParentWidget(QWidget &widget);
//! @brief Use this function to create the window.
//! @param maxFPS The number of FPS you aim to run on.
void createWindow(SNES &snes, int maxFPS) override;
//! @brief Add a pixel to the buffer to the coordinates x, y with the color rgba.
//! @param X horizontal index.
//! @param Y vertical index.
//! @param rgba The color of the pixel.
void putPixel(unsigned y, unsigned x, uint32_t rgba) override;
//! @brief This function doesn't do anything because QT internally handle drawing to the screen.
void drawScreen() override;
//! @brief Playing all samples from buffer
//! @param samples Buffer containing samples
//! @param sampleCount number of samples inside buffer
void playAudio(std::span<int16_t> samples, uint64_t sampleCount) override;
//! @brief Set a new name to the window, if there is already a name it will be overwrite.
//! @param newWindowName new title for the window.
void setWindowName(std::string &newWindowName) override;
//! @brief Constructor that return a SFML renderer inside a QT window.
//! @param height _height of the window.
//! @param width _width of the window.
QtRenderSFML(SNES &snes, QWidget* parent, const QPoint& position, const QSize& size, int frameRate = 0);
QtRenderSFML(const QtRenderSFML &) = delete;
QtRenderSFML &operator=(const QtRenderSFML &) = delete;
~QtRenderSFML() override = default;
};
}