From e7ee90c652a4b82f222c16a745673fcaca4d69d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Wed, 23 Jun 2021 00:24:28 +0200 Subject: [PATCH] general fixing (indent unused functions etc) --- CMakeLists.txt | 241 ++++++++++--------- sources/Debugger/TileViewer/TileViewer.cpp | 26 +- sources/Debugger/TileViewer/TileViewer.hpp | 11 +- sources/PPU/Background.cpp | 85 +------ sources/PPU/Background.hpp | 22 +- sources/PPU/PPU.cpp | 14 +- sources/PPU/TileRenderer.hpp | 11 +- sources/Renderer/QtRenderer/QtRenderSfml.cpp | 28 --- sources/Renderer/QtRenderer/QtRenderSfml.hpp | 55 ----- 9 files changed, 169 insertions(+), 324 deletions(-) delete mode 100644 sources/Renderer/QtRenderer/QtRenderSfml.cpp delete mode 100644 sources/Renderer/QtRenderer/QtRenderSfml.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 29b9efc..924bd4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,124 +125,129 @@ set(CMAKE_AUTOUIC ON) # make app add_executable(ComSquare - sources/main.cpp - sources/SNES.cpp - sources/SNES.hpp - sources/Memory/MemoryBus.cpp - sources/Memory/MemoryBus.hpp - sources/Memory/AMemory.hpp - sources/Memory/AMemory.cpp - sources/PPU/PPU.cpp - sources/PPU/PPU.hpp - sources/CPU/CPU.cpp - sources/CPU/CPU.hpp - sources/Cartridge/Cartridge.cpp - sources/Cartridge/Cartridge.hpp - sources/Exceptions/NotImplementedException.hpp - sources/APU/APU.hpp - sources/APU/APU.cpp - sources/Exceptions/InvalidAddress.hpp - sources/Exceptions/InvalidRom.hpp - sources/Models/Int24.hpp - sources/Models/Int24.hpp - sources/Ram/Ram.cpp - sources/Ram/Ram.hpp - sources/Memory/MemoryShadow.cpp - sources/Memory/MemoryShadow.hpp - sources/Memory/ARectangleMemory.cpp - sources/Memory/ARectangleMemory.hpp - sources/APU/DSP/DSP.cpp - sources/APU/DSP/DSP.hpp - sources/Renderer/IRenderer.hpp - sources/Renderer/SFRenderer.hpp - sources/Renderer/SFRenderer.cpp - sources/Exceptions/InvalidAction.hpp - sources/Cartridge/InterruptVectors.hpp - sources/Memory/RectangleShadow.cpp - sources/Memory/RectangleShadow.hpp - sources/Exceptions/InvalidOpcode.hpp - sources/CPU/Instructions/Interrupts.cpp - sources/CPU/Instructions/MathematicalOperations.cpp - sources/APU/Instructions/Standbys.cpp - sources/APU/Instructions/ProgramStatusWord.cpp - sources/APU/Instructions/Bit.cpp - sources/CPU/Instructions/MathematicalOperations.cpp - sources/CPU/Instructions/MemoryInstructions.cpp - sources/CPU/Instructions/InternalInstruction.cpp - sources/Ram/ExtendedRam.cpp - sources/Ram/ExtendedRam.hpp - sources/Debugger/CPU/CPUDebug.cpp - sources/Debugger/CPU/CPUDebug.hpp - sources/Renderer/QtRenderer/QtSFML.cpp - sources/Renderer/QtRenderer/QtSFML.hpp - sources/Renderer/QtRenderer/QtWidgetSFML.cpp - sources/Renderer/QtRenderer/QtWidgetSFML.hpp - ui/cpuView.ui - ui/ramView.ui - ui/cartridgeView.ui - ui/apuView.ui - ui/busView.ui - resources/appResources.qrc - sources/Utility/Utility.hpp - sources/Debugger/MemoryViewer.cpp - sources/Debugger/MemoryViewer.hpp - sources/Utility/Utility.cpp - sources/Debugger/HeaderViewer.cpp - sources/Debugger/HeaderViewer.hpp - sources/CPU/Instructions/BitsInstructions.cpp - sources/Debugger/HeaderViewer.cpp - sources/Debugger/HeaderViewer.hpp - sources/Debugger/APUDebug.hpp - sources/Debugger/APUDebug.cpp - sources/APU/Instructions/Stack.cpp - sources/APU/Instructions/Subroutine.cpp - sources/APU/Instructions/ProgramFlow.cpp - sources/APU/Operand.cpp - sources/APU/Instructions/DecimalCompensation.cpp - sources/APU/Instructions/MultiplicationDivision.cpp - sources/APU/Instructions/16bitArithmetic.cpp - sources/APU/Instructions/16bitDataTransmission.cpp - sources/APU/Instructions/8bitShiftRotation.cpp - sources/APU/Instructions/8bitIncrementDecrement.cpp - sources/APU/Instructions/8bitLogical.cpp - sources/APU/Instructions/8bitArithmetic.cpp - sources/APU/Instructions/8bitDataTransmission.cpp - sources/APU/IPL/IPL.hpp - sources/APU/IPL/IPL.cpp - sources/CPU/Instructions/TransferRegisters.cpp - sources/CPU/AddressingModes.cpp - sources/Debugger/MemoryBusDebug.cpp - sources/Debugger/MemoryBusDebug.hpp - sources/Debugger/ClosableWindow.hpp - sources/Models/Components.hpp - sources/CPU/Instruction.hpp - sources/Exceptions/DebuggableError.hpp - sources/Debugger/CPU/Disassembly.cpp - sources/Models/Components.hpp - sources/Debugger/CGramDebug.cpp - sources/Debugger/CGramDebug.hpp - sources/Models/Vector2.hpp - sources/PPU/Background.cpp - sources/PPU/Background.hpp - sources/CPU/DMA/DMA.cpp - sources/CPU/DMA/DMA.hpp - ui/registersView.ui - sources/Debugger/RegisterViewer.cpp - sources/Debugger/RegisterViewer.hpp - sources/Memory/IMemory.hpp - sources/APU/DSP/Voice.cpp - sources/APU/DSP/Echo.cpp - sources/APU/DSP/Gauss.cpp - sources/APU/DSP/Envelope.cpp - sources/APU/DSP/Timer.cpp - sources/APU/DSP/BRR.cpp - sources/PPU/PPUUtils.cpp - ui/tileView.ui - sources/Renderer/QtRenderer/QtRenderSfml.cpp - sources/Renderer/QtRenderer/QtRenderSfml.hpp - sources/Debugger/TileViewer/TileViewer.cpp - sources/Debugger/TileViewer/TileViewer.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/main.cpp + sources/SNES.cpp + sources/SNES.hpp + sources/Memory/MemoryBus.cpp + sources/Memory/MemoryBus.hpp + sources/Memory/AMemory.hpp + sources/Memory/AMemory.cpp + sources/PPU/PPU.cpp + sources/PPU/PPU.hpp + sources/CPU/CPU.cpp + sources/CPU/CPU.hpp + sources/Cartridge/Cartridge.cpp + sources/Cartridge/Cartridge.hpp + sources/Exceptions/NotImplementedException.hpp + sources/APU/APU.hpp + sources/APU/APU.cpp + sources/Exceptions/InvalidAddress.hpp + sources/Exceptions/InvalidRom.hpp + sources/Models/Int24.hpp + sources/Models/Int24.hpp + sources/Ram/Ram.cpp + sources/Ram/Ram.hpp + sources/Memory/MemoryShadow.cpp + sources/Memory/MemoryShadow.hpp + sources/Memory/ARectangleMemory.cpp + sources/Memory/ARectangleMemory.hpp + sources/APU/DSP/DSP.cpp + sources/APU/DSP/DSP.hpp + sources/Renderer/IRenderer.hpp + sources/Renderer/SFRenderer.hpp + sources/Renderer/SFRenderer.cpp + sources/Exceptions/InvalidAction.hpp + sources/Cartridge/InterruptVectors.hpp + sources/Memory/RectangleShadow.cpp + sources/Memory/RectangleShadow.hpp + sources/Exceptions/InvalidOpcode.hpp + sources/CPU/Instructions/Interrupts.cpp + sources/CPU/Instructions/MathematicalOperations.cpp + sources/APU/Instructions/Standbys.cpp + sources/APU/Instructions/ProgramStatusWord.cpp + sources/APU/Instructions/Bit.cpp + sources/CPU/Instructions/MathematicalOperations.cpp + sources/CPU/Instructions/MemoryInstructions.cpp + sources/CPU/Instructions/InternalInstruction.cpp + sources/Ram/ExtendedRam.cpp + sources/Ram/ExtendedRam.hpp + sources/Debugger/CPU/CPUDebug.cpp + sources/Debugger/CPU/CPUDebug.hpp + sources/Renderer/QtRenderer/QtSFML.cpp + sources/Renderer/QtRenderer/QtSFML.hpp + sources/Renderer/QtRenderer/QtWidgetSFML.cpp + sources/Renderer/QtRenderer/QtWidgetSFML.hpp + ui/cpuView.ui + ui/ramView.ui + ui/cartridgeView.ui + ui/apuView.ui + ui/busView.ui + resources/appResources.qrc + sources/Utility/Utility.hpp + sources/Debugger/MemoryViewer.cpp + sources/Debugger/MemoryViewer.hpp + sources/Utility/Utility.cpp + sources/Debugger/HeaderViewer.cpp + sources/Debugger/HeaderViewer.hpp + sources/CPU/Instructions/BitsInstructions.cpp + sources/Debugger/HeaderViewer.cpp + sources/Debugger/HeaderViewer.hpp + sources/Debugger/APUDebug.hpp + sources/Debugger/APUDebug.cpp + sources/APU/Instructions/Stack.cpp + sources/APU/Instructions/Subroutine.cpp + sources/APU/Instructions/ProgramFlow.cpp + sources/APU/Operand.cpp + sources/APU/Instructions/DecimalCompensation.cpp + sources/APU/Instructions/MultiplicationDivision.cpp + sources/APU/Instructions/16bitArithmetic.cpp + sources/APU/Instructions/16bitDataTransmission.cpp + sources/APU/Instructions/8bitShiftRotation.cpp + sources/APU/Instructions/8bitIncrementDecrement.cpp + sources/APU/Instructions/8bitLogical.cpp + sources/APU/Instructions/8bitArithmetic.cpp + sources/APU/Instructions/8bitDataTransmission.cpp + sources/APU/IPL/IPL.hpp + sources/APU/IPL/IPL.cpp + sources/CPU/Instructions/TransferRegisters.cpp + sources/CPU/AddressingModes.cpp + sources/Debugger/MemoryBusDebug.cpp + sources/Debugger/MemoryBusDebug.hpp + sources/Debugger/ClosableWindow.hpp + sources/Models/Components.hpp + sources/CPU/Instruction.hpp + sources/Exceptions/DebuggableError.hpp + sources/Debugger/CPU/Disassembly.cpp + sources/Models/Components.hpp + sources/Debugger/CGramDebug.cpp + sources/Debugger/CGramDebug.hpp + sources/Models/Vector2.hpp + sources/PPU/Background.cpp + sources/PPU/Background.hpp + sources/CPU/DMA/DMA.cpp + sources/CPU/DMA/DMA.hpp + ui/registersView.ui + sources/Debugger/RegisterViewer.cpp + sources/Debugger/RegisterViewer.hpp + sources/Memory/IMemory.hpp + sources/APU/DSP/Voice.cpp + sources/APU/DSP/Echo.cpp + sources/APU/DSP/Gauss.cpp + sources/APU/DSP/Envelope.cpp + sources/APU/DSP/Timer.cpp + sources/APU/DSP/BRR.cpp + sources/PPU/PPUUtils.cpp + ui/tileView.ui + sources/Debugger/TileViewer/TileViewer.cpp + sources/Debugger/TileViewer/TileViewer.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 + ) include_directories(ComSquare sources) diff --git a/sources/Debugger/TileViewer/TileViewer.cpp b/sources/Debugger/TileViewer/TileViewer.cpp index e74033b..2507892 100644 --- a/sources/Debugger/TileViewer/TileViewer.cpp +++ b/sources/Debugger/TileViewer/TileViewer.cpp @@ -25,10 +25,10 @@ namespace ComSquare::Debugger _snes(snes), _ui(), _ppu(ppu), - _tileRenderer() + _ramTileRenderer() { - this->_tileRenderer.setRam(ppu.vram); - this->_tileRenderer.setCgram(ppu.cgram); + this->_ramTileRenderer.setRam(ppu.vram); + this->_ramTileRenderer.setCgram(ppu.cgram); this->_window->setContextMenuPolicy(Qt::NoContextMenu); this->_window->setAttribute(Qt::WA_QuitOnClose, false); this->_window->setAttribute(Qt::WA_DeleteOnClose); @@ -69,7 +69,7 @@ namespace ComSquare::Debugger void TileViewer::setPaletteIndex(int paletteIndex) { - this->_tileRenderer.setPaletteIndex(paletteIndex); + this->_ramTileRenderer.setPaletteIndex(paletteIndex); this->internalUpdate(); } @@ -92,46 +92,46 @@ namespace ComSquare::Debugger this->_ui.PaletteIndex->setMaximum(63); break; } - this->_tileRenderer.setBpp(bpp); + this->_ramTileRenderer.setBpp(bpp); this->internalUpdate(); } void TileViewer::setNbColumns(int nbColumns) { - this->_tileRenderer.setNbColumns(nbColumns); + this->_ramTileRenderer.setNbColumns(nbColumns); this->internalUpdate(); } void TileViewer::setRenderSize(int size) { - this->_tileRenderer.setRenderSize(size); + this->_ramTileRenderer.setRenderSize(size); this->internalUpdate(); } int TileViewer::getBpp() const { - return this->_tileRenderer.getBpp(); + return this->_ramTileRenderer.getBpp(); } int TileViewer::getPaletteIndex() const { - return this->_tileRenderer.getPaletteIndex(); + return this->_ramTileRenderer.getPaletteIndex(); } int TileViewer::getNbColumns() const { - return this->_tileRenderer.getNbColumns(); + return this->_ramTileRenderer.getNbColumns(); } void TileViewer::internalUpdate() { - this->_tileRenderer.render(); - this->_sfWidget->buffer = this->_tileRenderer.buffer; + this->_ramTileRenderer.render(); + this->_sfWidget->buffer = this->_ramTileRenderer.buffer; } void TileViewer::setRamOffset(int offset) { - this->_tileRenderer.setRamOffset(offset); + this->_ramTileRenderer.setRamOffset(offset); this->internalUpdate(); } diff --git a/sources/Debugger/TileViewer/TileViewer.hpp b/sources/Debugger/TileViewer/TileViewer.hpp index f01fb86..1848899 100644 --- a/sources/Debugger/TileViewer/TileViewer.hpp +++ b/sources/Debugger/TileViewer/TileViewer.hpp @@ -36,18 +36,21 @@ namespace ComSquare::Debugger ComSquare::PPU::PPU &_ppu; //! @brief the window std::unique_ptr _sfWidget; - //! @brief The tile renderer - RAMTileRenderer _tileRenderer; + //! @brief The ram tile renderer + RAMTileRenderer _ramTileRenderer; //! @brief Change the bpp from the index given by the ui (QT combo box) void _bppChangeUIHandler(int index); public: //! @brief Called when the window is closed. Turn off the debugger. void disableViewer(); - public: + //! @brief ctor explicit TileViewer(SNES &snes, ComSquare::PPU::PPU &ppu); + //! @brief copy ctor TileViewer(const TileViewer &) = delete; + //! @brief dtor + ~TileViewer() override = default; + //! @brief assignment operator TileViewer &operator=(const TileViewer &) = delete; - ~TileViewer() = default; //! @brief Read data at the CGRAM address send it to the debugger. //! @param addr The address to read from. diff --git a/sources/PPU/Background.cpp b/sources/PPU/Background.cpp index 38320c0..8e20124 100644 --- a/sources/PPU/Background.cpp +++ b/sources/PPU/Background.cpp @@ -41,7 +41,7 @@ namespace ComSquare::PPU for (int i = 0; i < 4; i++) { if (!(i == 1 && this->_tileMapsConfig.x == 1) && !(i > 1 && this->_tileMapsConfig.y == 1)) { - drawBasicTileMap(vramAddress, offset); + _drawBasicTileMap(vramAddress, offset); } vramAddress += TileMapByteSize; offset.x += NbCharacterWidth * this->_characterNbPixels.x; @@ -52,7 +52,7 @@ namespace ComSquare::PPU } } - void Background::drawBgTile(uint16_t data, Vector2 pos) + void Background::_drawBgTile(uint16_t data, Vector2 pos) { union TileMapData tileData; @@ -67,8 +67,8 @@ namespace ComSquare::PPU // Y vertical this->_tileRenderer.setPaletteIndex(tileData.palette); - for (int i = 0; i < this->_characterNbPixels.y; i += 8) { - for (int j = 0; j < this->_characterNbPixels.x; j += 8) { + for (int i = 0; i < this->_characterNbPixels.y; i += Tile::NbPixelsHeight) { + for (int j = 0; j < this->_characterNbPixels.x; j += Tile::NbPixelsWidth) { graphicAddress = this->_tilesetAddress + ((tileData.posY + tileOffset.y) * NbTilePerRow * this->_bpp * Tile::BaseByteSize) + ((tileData.posX + tileOffset.x) * this->_bpp * Tile::BaseByteSize); @@ -95,74 +95,7 @@ namespace ComSquare::PPU } } - std::vector Background::getPalette(int nbPalette) - { - 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 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 offset) + void Background::_drawBasicTileMap(uint16_t baseAddress, Vector2 offset) { uint16_t tileMapValue = 0; Vector2 pos(0, 0); @@ -172,7 +105,8 @@ namespace ComSquare::PPU // TODO function to read 2 bytes (LSB order or bits reversed) tileMapValue = this->_vram->read(vramAddress); 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; if (pos.x % 31 == 0 && pos.x) { pos.y++; @@ -212,11 +146,6 @@ namespace ComSquare::PPU this->_tileMapsConfig = tileMaps; } - void Background::setBgNumber(int bgNumber) - { - this->_bgNumber = bgNumber; - } - int Background::getBgNumber() const { return this->_bgNumber; diff --git a/sources/PPU/Background.hpp b/sources/PPU/Background.hpp index 932fb13..abbc00e 100644 --- a/sources/PPU/Background.hpp +++ b/sources/PPU/Background.hpp @@ -58,25 +58,11 @@ namespace ComSquare::PPU //! @brief The access to cgram std::shared_ptr _cgram; //! @brief Draw a tile on the screen at x y pos - void drawBgTile(uint16_t data, Vector2 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 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); + void _drawBgTile(uint16_t data, Vector2 pos); //! @brief draw a tileMap 32x32 starting at baseAddress //! @param baseAddress The starting address of the tileMap //! @param offset The rendering offeset in pixels - void drawBasicTileMap(uint16_t baseAddress, Vector2 offset); + void _drawBasicTileMap(uint16_t baseAddress, Vector2 offset); public: //! @brief The size of the background (x, y) Vector2 backgroundSize; @@ -99,9 +85,7 @@ namespace ComSquare::PPU //! @brief setter for private variable _tileMaps //! @param tileMaps The tileMaps to set void setTilemaps(Vector2 tileMaps); - //! @brief set the Background number - //! @param bgNumber the new Background Number - void setBgNumber(int bgNumber); + //! @brief Get the BackGround Number //! @return the current Background number int getBgNumber() const; diff --git a/sources/PPU/PPU.cpp b/sources/PPU/PPU.cpp index a8fbe0a..3557ed1 100644 --- a/sources/PPU/PPU.cpp +++ b/sources/PPU/PPU.cpp @@ -44,7 +44,7 @@ namespace ComSquare::PPU this->cgram->write(67, 0x7F); //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, 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,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 - }; - /*int *cgram_test = get_dump_cgram(); + };*/ + int *cgram_test = get_dump_cgram(); for (int i = 0; cgram_test[i] != -1; 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++) { 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++) { this->vram->write(i + 0x8000, vram_test_2[i]); } @@ -144,8 +144,8 @@ namespace ComSquare::PPU //this->_registers._bgofs[3].raw = 0x03DF; this->_registers._t[0].enableWindowDisplayBg1 = true; this->_registers._t[0].enableWindowDisplayBg2 = true; +*/ -/* //registers aladin this->_registers._bgmode.bgMode = 1; @@ -199,7 +199,7 @@ namespace ComSquare::PPU this->_registers._t[0].enableWindowDisplayBg1 = true; this->_registers._t[0].enableWindowDisplayBg2 = true; this->_registers._t[0].enableWindowDisplayBg3 = true; - */ + } diff --git a/sources/PPU/TileRenderer.hpp b/sources/PPU/TileRenderer.hpp index 7e9a10d..e5808c5 100644 --- a/sources/PPU/TileRenderer.hpp +++ b/sources/PPU/TileRenderer.hpp @@ -35,12 +35,19 @@ namespace ComSquare::PPU int getBpp() const; //! @brief Get the index of the current palette used 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 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); //! @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 std::vector getPalette(int nbPalette); //! @brief read the 2bpp value for a pixel (used multple times for 4bpp and 8bpp) diff --git a/sources/Renderer/QtRenderer/QtRenderSfml.cpp b/sources/Renderer/QtRenderer/QtRenderSfml.cpp deleted file mode 100644 index 4b81096..0000000 --- a/sources/Renderer/QtRenderer/QtRenderSfml.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// -// Created by cbihan on 18/05/2021. -// - -#include "QtRenderSfml.hpp" -#include - -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(); - } - }*/ -} \ No newline at end of file diff --git a/sources/Renderer/QtRenderer/QtRenderSfml.hpp b/sources/Renderer/QtRenderer/QtRenderSfml.hpp deleted file mode 100644 index a02bfd5..0000000 --- a/sources/Renderer/QtRenderer/QtRenderSfml.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// -// Created by cbihan on 18/05/2021. -// - -#pragma once - -#include -#include -#include -#include -#include -#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 _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 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; - }; -}