diff --git a/CMakeLists.txt b/CMakeLists.txt index dd82dd5..37c6a15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ add_compile_options(-W -Wall -Wextra -Wshadow) # make unit tests add_executable(unit_tests tests/testCPU.cpp - sources/PPU/PPU.cpp - sources/PPU/PPU.hpp + tests/testMemoryBus.cpp + tests/communism.hpp sources/SNES.cpp sources/SNES.hpp sources/Memory/MemoryBus.cpp @@ -39,9 +39,14 @@ add_executable(unit_tests sources/Memory/IRectangleMemory.hpp sources/APU/DSP/DSP.cpp sources/APU/DSP/DSP.hpp + sources/Renderer/IRenderer.hpp + sources/Renderer/NoRenderer.hpp + sources/Renderer/NoRenderer.cpp + sources/Exceptions/InvalidAction.hpp + sources/Cartridge/InterruptVectors.hpp sources/Memory/RectangleShadow.cpp sources/Memory/RectangleShadow.hpp - sources/Renderer/NoRenderer.cpp sources/Renderer/NoRenderer.hpp) +) # include criterion & coverage target_link_libraries(unit_tests criterion -lgcov) diff --git a/docs/MemoryBus_8hpp_source.html b/docs/MemoryBus_8hpp_source.html index 3a5d131..9c1ab60 100644 --- a/docs/MemoryBus_8hpp_source.html +++ b/docs/MemoryBus_8hpp_source.html @@ -93,7 +93,7 @@ $(function() {
24 
28  std::shared_ptr<IMemory> getAccessor(uint24_t addr);
29 
-
31  uint8_t _openbus = 0;
+
31  uint8_t _openBus = 0;
32 
36  inline void _mirrorComponents(SNES &console, int i);
37 
@@ -117,7 +117,7 @@ $(function() {
uint24_t
unsigned uint24_t
Definition: Ints.hpp:8
ComSquare::Memory::MemoryBus::write
void write(uint24_t addr, uint8_t data)
Write a data to a global address.
Definition: MemoryBus.cpp:37
ComSquare::Memory::MemoryBus::getAccessor
std::shared_ptr< IMemory > getAccessor(uint24_t addr)
Helper function to get the components that is responsible of read/write at an address.
Definition: MemoryBus.cpp:13
-
ComSquare::Memory::MemoryBus::_openbus
uint8_t _openbus
The last value read via the memory bus.
Definition: MemoryBus.hpp:31
+
ComSquare::Memory::MemoryBus::_openBus
uint8_t _openBus
The last value read via the memory bus.
Definition: MemoryBus.hpp:31
ComSquare::Memory::MemoryBus::mapComponents
void mapComponents(SNES &console)
Map components to the address space using the currently loaded cartridge to set the right mapping mod...
Definition: MemoryBus.cpp:56
IMemory.hpp
ComSquare::Memory::MemoryBus::_mirrorComponents
void _mirrorComponents(SNES &console, int i)
WRam, CPU, PPU & ALU registers are mirrored to all banks of Q1 & Q3. This function is used for the mi...
Definition: MemoryBus.cpp:48
diff --git a/docs/classComSquare_1_1Memory_1_1MemoryBus-members.html b/docs/classComSquare_1_1Memory_1_1MemoryBus-members.html index 2e75524..375ba89 100644 --- a/docs/classComSquare_1_1Memory_1_1MemoryBus-members.html +++ b/docs/classComSquare_1_1Memory_1_1MemoryBus-members.html @@ -74,7 +74,7 @@ $(function() { - + diff --git a/docs/classComSquare_1_1Memory_1_1MemoryBus.html b/docs/classComSquare_1_1Memory_1_1MemoryBus.html index 70b3c38..85f72c9 100644 --- a/docs/classComSquare_1_1Memory_1_1MemoryBus.html +++ b/docs/classComSquare_1_1Memory_1_1MemoryBus.html @@ -114,7 +114,7 @@ Private Attributes - +
_memoryAccessorsComSquare::Memory::MemoryBusprivate
_mirrorComponents(SNES &console, int i)ComSquare::Memory::MemoryBusinlineprivate
_openbusComSquare::Memory::MemoryBusprivate
_openBusComSquare::Memory::MemoryBusprivate
getAccessor(uint24_t addr)ComSquare::Memory::MemoryBusprivate
mapComponents(SNES &console)ComSquare::Memory::MemoryBus
read(uint24_t addr)ComSquare::Memory::MemoryBus
std::vector< std::shared_ptr< IMemory > > _memoryAccessors
 The list of components registered inside the bus. Every components that can read/write to a public address should be in this vector. More...
 
uint8_t _openbus = 0
uint8_t _openBus = 0
 The last value read via the memory bus. More...
 
@@ -317,7 +317,7 @@ Private Attributes -

◆ _openbus

+

◆ _openBus

@@ -326,7 +326,7 @@ Private Attributes - +
uint8_t ComSquare::Memory::MemoryBus::_openbus = 0uint8_t ComSquare::Memory::MemoryBus::_openBus = 0
diff --git a/docs/functions.html b/docs/functions.html index 9778567..957526e 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -122,7 +122,7 @@ $(function() { , ComSquare::InvalidAddress , ComSquare::InvalidRomException -
  • _openbus +
  • _openBus : ComSquare::Memory::MemoryBus
  • _registers diff --git a/docs/functions_vars.html b/docs/functions_vars.html index 57a253f..d41ff3a 100644 --- a/docs/functions_vars.html +++ b/docs/functions_vars.html @@ -110,7 +110,7 @@ $(function() { , ComSquare::InvalidAddress , ComSquare::InvalidRomException
  • -
  • _openbus +
  • _openBus : ComSquare::Memory::MemoryBus
  • _registers diff --git a/docs/latex/classComSquare_1_1Memory_1_1MemoryBus.tex b/docs/latex/classComSquare_1_1Memory_1_1MemoryBus.tex index 6f9fa79..2a5de9e 100644 --- a/docs/latex/classComSquare_1_1Memory_1_1MemoryBus.tex +++ b/docs/latex/classComSquare_1_1Memory_1_1MemoryBus.tex @@ -146,9 +146,9 @@ Write a data to a global address. The list of components registered inside the bus. Every components that can read/write to a public address should be in this vector. \mbox{\Hypertarget{classComSquare_1_1Memory_1_1MemoryBus_ab55064b581ef9348bc47e0f277a0439d}\label{classComSquare_1_1Memory_1_1MemoryBus_ab55064b581ef9348bc47e0f277a0439d}} -\index{ComSquare::Memory::MemoryBus@{ComSquare::Memory::MemoryBus}!\_openbus@{\_openbus}} -\index{\_openbus@{\_openbus}!ComSquare::Memory::MemoryBus@{ComSquare::Memory::MemoryBus}} -\doxysubsubsection{\texorpdfstring{\_openbus}{\_openbus}} +\index{ComSquare::Memory::MemoryBus@{ComSquare::Memory::MemoryBus}!\_openBus@{\_openBus}} +\index{\_openBus@{\_openBus}!ComSquare::Memory::MemoryBus@{ComSquare::Memory::MemoryBus}} +\doxysubsubsection{\texorpdfstring{\_openBus}{\_openBus}} {\footnotesize\ttfamily uint8\+\_\+t Com\+Square\+::\+Memory\+::\+Memory\+Bus\+::\+\_\+openbus = 0\hspace{0.3cm}{\ttfamily [private]}} diff --git a/sources/Memory/MemoryBus.cpp b/sources/Memory/MemoryBus.cpp index 6a2ecf5..76e0298 100644 --- a/sources/Memory/MemoryBus.cpp +++ b/sources/Memory/MemoryBus.cpp @@ -28,10 +28,10 @@ namespace ComSquare::Memory if (!handler) { std::cout << "Unknown memory accessor for address " << std::hex << addr << ". Using open bus." << std::endl; - return this->_openbus; + return this->_openBus; } uint8_t data = handler->read(addr - handler->getStart()); - this->_openbus = data; + this->_openBus = data; return data; } diff --git a/sources/Memory/MemoryBus.hpp b/sources/Memory/MemoryBus.hpp index 83b2b5c..e2af811 100644 --- a/sources/Memory/MemoryBus.hpp +++ b/sources/Memory/MemoryBus.hpp @@ -28,9 +28,9 @@ namespace ComSquare std::shared_ptr getAccessor(uint24_t addr); //! @brief The last value read via the memory bus. - uint8_t _openbus = 0; + uint8_t _openBus = 0; - //! @brief WRam, CPU, PPU & ALU registers are mirrored to all banks of Q1 & Q3. This function is used for the mirroring. + //! @brief WRam, CPU, PPU & APU registers are mirrored to all banks of Q1 & Q3. This function is used for the mirroring. //! @param console All the components. //! @param i Base address for the mirrors. inline void _mirrorComponents(SNES &console, int i); diff --git a/tests/communism.hpp b/tests/communism.hpp new file mode 100644 index 0000000..f6fd1ea --- /dev/null +++ b/tests/communism.hpp @@ -0,0 +1,12 @@ +// +// Created by Melefp on 05/02/2020. +// + +#ifndef COMSQUARE_COMMUNISM_HPP +#define COMSQUARE_COMMUNISM_HPP + +#define private public +#define protected public +#define class struct + +#endif //COMSQUARE_COMMUNISM_HPP diff --git a/tests/testMemoryBus.cpp b/tests/testMemoryBus.cpp new file mode 100644 index 0000000..1a90ffe --- /dev/null +++ b/tests/testMemoryBus.cpp @@ -0,0 +1,55 @@ +// +// Created by Melefo on 05/02/2020. +// + +#include +#include "communism.hpp" +#include "../sources/Memory/MemoryBus.hpp" +#include "../sources/Memory/IMemory.hpp" +#include "../sources/SNES.hpp" +#include "../sources/Renderer/NoRenderer.hpp" + + +using namespace ComSquare; + +std::pair Init() +{ + Memory::MemoryBus bus; + Renderer::NoRenderer norenderer(0, 0, 0); + SNES snes(std::make_shared(bus), "", norenderer); + snes.cartridge->_size = 10; + snes.cartridge->_data = new uint8_t[snes.cartridge->_size]; + snes.cartridge->header.mappingMode = Cartridge::LoRom; + bus.mapComponents(snes); + return std::make_pair(bus, snes); +} + +Test(BusAccessor, GetRom) +{ + auto pair = Init(); + std::shared_ptr accessor = nullptr; + + accessor = pair.first.getAccessor(0xFFFFEF); + printf("%p %p", accessor.get(), pair.second.cartridge.get()); + cr_assert_eq(accessor.get(), pair.second.cartridge.get()); +} + +Test(BusWrite, ) +{ + +} + +Test(BusRead, ) +{ + +} + +Test(BusMapping, ) +{ + +} + +Test(BusMirror, ) +{ + +} \ No newline at end of file