mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-25 15:39:28 +00:00
setting the modification of getTilePixelReference
This commit is contained in:
+5
-2
@@ -100,7 +100,9 @@ add_executable(unit_tests
|
||||
tests/CPU/Math/testCMP.cpp
|
||||
sources/PPU/Background.cpp
|
||||
sources/PPU/Background.hpp
|
||||
sources/PPU/PPUUtils.cpp)
|
||||
sources/PPU/PPUUtils.cpp
|
||||
tests/PPU/testBackground.cpp
|
||||
)
|
||||
|
||||
# include criterion & coverage
|
||||
target_link_libraries(unit_tests criterion -lgcov)
|
||||
@@ -217,7 +219,8 @@ add_executable(ComSquare
|
||||
sources/Models/Vector2.hpp
|
||||
sources/PPU/Background.cpp
|
||||
sources/PPU/Background.hpp
|
||||
sources/PPU/PPUUtils.cpp)
|
||||
sources/PPU/PPUUtils.cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED)
|
||||
|
||||
|
||||
@@ -100,13 +100,15 @@ namespace ComSquare::PPU
|
||||
return palette;
|
||||
}
|
||||
|
||||
uint8_t Background::getTilePixelReference(uint16_t addr, int nb)
|
||||
uint8_t Background::getTilePixelReference(uint16_t addr, int index)
|
||||
{
|
||||
//line by line for each pixel of the line
|
||||
uint8_t highByte = this->_vram->read_internal(addr % VRAMSIZE);
|
||||
uint8_t lowByte = this->_vram->read_internal((addr + 1) % VRAMSIZE);
|
||||
uint8_t secondHightByte;
|
||||
uint8_t secondLowByte;
|
||||
uint8_t result = 0;
|
||||
uint8_t shift = (TILE_PIXEL_WIDTH - 1 - index);
|
||||
// C000
|
||||
|
||||
switch (this->_bpp) {
|
||||
@@ -115,9 +117,9 @@ namespace ComSquare::PPU
|
||||
case 4:
|
||||
secondHightByte = this->_vram->read_internal((addr + 32) % VRAMSIZE);
|
||||
secondLowByte = this->_vram->read_internal((addr + 33) % VRAMSIZE);
|
||||
result = ((secondHightByte & (1U << (7U - nb))) | ((secondLowByte & (1U << (7U - nb))) << 1U)) >> (7U - nb - 2);
|
||||
result = ((secondHightByte & (1U << (7U - index))) | ((secondLowByte & (1U << (7U - index))) << 1U)) >> (7U - index - 2);
|
||||
case 2:
|
||||
result += ((highByte & (1U << (7U - nb))) | ((lowByte & (1U << (7U - nb))) << 1U)) >> (7U - nb);
|
||||
result += ((highByte & (1U << (7U - index))) | ((lowByte & (1U << (7U - index))) << 1U)) >> (7U - index);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace ComSquare::PPU
|
||||
class Background {
|
||||
#define NB_CHARACTER_WIDTH 32
|
||||
#define NB_CHARACTER_HEIGHT 32
|
||||
#define TILE_PIXEL_WIDTH 8
|
||||
#define TILE_PIXEL_HEIGHT 8
|
||||
private:
|
||||
Vector2<int> _tileMaps;
|
||||
Vector2<int> _characterSize;
|
||||
@@ -36,8 +38,10 @@ namespace ComSquare::PPU
|
||||
void drawBgTile(uint16_t data, Vector2<int> pos);
|
||||
//! @brief Get a palette from the number of the palette (0 - 7)
|
||||
std::vector<uint16_t> getPalette(int nbPalette);
|
||||
//! @brief Get the color reference of a nb pixel tile
|
||||
uint8_t getTilePixelReference(uint16_t addr, int nb);
|
||||
//! @brief Get the color reference of a index pixel tile
|
||||
//! @param addr The address of the line of pixel
|
||||
//TODO support addr as the address of the start of the tile and index goes from 0 to 63 regardless of the bpp
|
||||
uint8_t getTilePixelReference(uint16_t addr, int index);
|
||||
//! @brief draw a tilemap 32x32 starting at baseAddress
|
||||
void drawBasicTileMap(uint16_t baseAddress, Vector2<int> offset);
|
||||
public:
|
||||
|
||||
+2
-2
@@ -129,7 +129,7 @@ namespace ComSquare::PPU
|
||||
|
||||
uint8_t PPU::read(uint24_t addr)
|
||||
{
|
||||
return 0;
|
||||
// return 0;
|
||||
switch (addr) {
|
||||
case ppuRegisters::mpyl:
|
||||
return this->_registers._mpy.mpyl;
|
||||
@@ -158,7 +158,7 @@ namespace ComSquare::PPU
|
||||
|
||||
void PPU::write(uint24_t addr, uint8_t data)
|
||||
{
|
||||
return;
|
||||
//return;
|
||||
switch (addr) {
|
||||
case ppuRegisters::inidisp:
|
||||
this->_registers._inidisp.raw = data;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Created by cbihan on 9/29/20.
|
||||
//
|
||||
|
||||
#include <criterion/criterion.h>
|
||||
#include <iostream>
|
||||
#include <bitset>
|
||||
#include "../tests.hpp"
|
||||
#include "../../sources/SNES.hpp"
|
||||
#include "../../sources/Memory/MemoryBus.hpp"
|
||||
#include "../../sources/PPU/PPU.hpp"
|
||||
|
||||
using namespace ComSquare;
|
||||
|
||||
Test(backgroundGetTilePixelReference, basicTest)
|
||||
{
|
||||
Init()
|
||||
snes._bus->write(0x2100, 0b11111111);
|
||||
cr_assert_eq(snes.ppu->_registers._inidisp.fblank, true);
|
||||
cr_assert_eq(snes.ppu->_registers._inidisp.brightness, 0xF);
|
||||
}
|
||||
Reference in New Issue
Block a user