From c3a24f023848e6d688ce6d3c06f4a383f80f5934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Thu, 14 May 2020 18:21:21 +0200 Subject: [PATCH] fixing compilation --- CMakeLists.txt | 7 +++++-- sources/PPU/Background.cpp | 28 ++++++++++++++++++++++++++++ sources/PPU/Background.hpp | 22 ++++++++++++++++++++++ sources/PPU/Backgrounds.cpp | 1 + sources/PPU/PPU.cpp | 2 +- sources/PPU/PPU.hpp | 3 --- 6 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 sources/PPU/Background.cpp create mode 100644 sources/PPU/Background.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fbb74d9..0624057 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,8 @@ add_executable(unit_tests tests/CPU/Math/testOthersMath.cpp tests/testRectangleMemory.cpp tests/CPU/Math/testCMP.cpp -) + sources/PPU/Backgrounds.cpp + sources/PPU/Background.cpp sources/PPU/Background.hpp) # include criterion & coverage target_link_libraries(unit_tests criterion -lgcov) @@ -212,7 +213,9 @@ add_executable(ComSquare sources/Models/Components.hpp sources/Debugger/CGramDebug.cpp sources/Debugger/CGramDebug.hpp - sources/Models/Vector2.hpp sources/PPU/Backgrounds.cpp) + sources/Models/Vector2.hpp + sources/PPU/Backgrounds.cpp + sources/PPU/Background.cpp sources/PPU/Background.hpp) target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED) diff --git a/sources/PPU/Background.cpp b/sources/PPU/Background.cpp new file mode 100644 index 0000000..b4afa83 --- /dev/null +++ b/sources/PPU/Background.cpp @@ -0,0 +1,28 @@ +// +// Created by cbihan on 5/14/20. +// + +#include "Background.hpp" + +namespace PPU +{ + /*void PPU::renderBackground(int bgNumber, Vector2 characterSize, int bpp, bool priority) + { + int nbBgHeight = (this->_registers._bgsc[bgNumber - 1].tilemapVerticalMirroring) ? 2 : 1; + int nbBgWidth = (this->_registers._bgsc[bgNumber - 1].tilemapHorizontalMirroring) ? 2 : 1; + uint16_t vramAddress = this->_registers._bgsc[bgNumber - 1].tilemapAddress << 1U; + Vector2 offset(0, 0); + + for (int i = 0; i < 4; i++) { + if (!(i == 1 && nbBgWidth == 1) && !(i > 1 && nbBgHeight == 1)) { + drawBasicTileMap(vramAddress, bgNumber, bpp, characterSize, offset); + } + vramAddress+= 0x800; + offset.x += 32 * characterSize.x; + if (i == 2) { + offset.x = 0; + offset.y += 32 * characterSize.y; + } + } + }*/ +} \ No newline at end of file diff --git a/sources/PPU/Background.hpp b/sources/PPU/Background.hpp new file mode 100644 index 0000000..bee5559 --- /dev/null +++ b/sources/PPU/Background.hpp @@ -0,0 +1,22 @@ +// +// Created by cbihan on 5/14/20. +// + +#ifndef COMSQUARE_BACKGROUND_HPP +#define COMSQUARE_BACKGROUND_HPP + +#include +#include +#include "../Models/Vector2.hpp" + +class Background { + int width; + int height; + int bpp; + bool directColor; + bool highRes; + std::array, 1024> buffer; +}; + + +#endif //COMSQUARE_BACKGROUND_HPP diff --git a/sources/PPU/Backgrounds.cpp b/sources/PPU/Backgrounds.cpp index d498476..c7d01dc 100644 --- a/sources/PPU/Backgrounds.cpp +++ b/sources/PPU/Backgrounds.cpp @@ -15,6 +15,7 @@ namespace ComSquare::PPU { void PPU::renderBackground(int bgNumber, Vector2 characterSize, int bpp, bool priority) { + (void)priority; int nbBgHeight = (this->_registers._bgsc[bgNumber - 1].tilemapVerticalMirroring) ? 2 : 1; int nbBgWidth = (this->_registers._bgsc[bgNumber - 1].tilemapHorizontalMirroring) ? 2 : 1; uint16_t vramAddress = this->_registers._bgsc[bgNumber - 1].tilemapAddress << 1U; diff --git a/sources/PPU/PPU.cpp b/sources/PPU/PPU.cpp index 15263c4..c0a5661 100644 --- a/sources/PPU/PPU.cpp +++ b/sources/PPU/PPU.cpp @@ -260,7 +260,7 @@ namespace ComSquare::PPU this->_renderer.putPixel(x, y, pixelTmp); } } - renderBackground(1, {8, 8}, 4, false); + this->renderBackground(1, {8, 8}, 4, false); this->_renderer.drawScreen(); } diff --git a/sources/PPU/PPU.hpp b/sources/PPU/PPU.hpp index 13dee70..38aceaf 100644 --- a/sources/PPU/PPU.hpp +++ b/sources/PPU/PPU.hpp @@ -17,11 +17,8 @@ //#define max4BitTiles 2048 //#define max8BitTiles 1024 - - namespace ComSquare::PPU { - enum ppuRegisters { //! @brief INIDISP Register (F-blank and Brightness) inidisp = 0x00,