mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-01 01:38:05 +00:00
fixing ppu x and y
This commit is contained in:
@@ -101,7 +101,7 @@ namespace ComSquare::PPU
|
||||
std::for_each(this->_tileBuffer.begin(), this->_tileBuffer.begin() + this->_characterNbPixels.y,
|
||||
[this, &pixelPosition](const auto &row) {
|
||||
std::move(row.begin(), row.begin() + this->_characterNbPixels.x,
|
||||
this->buffer[pixelPosition.y++].begin() + pixelPosition.x);
|
||||
this->buffer[pixelPosition.x++].begin() + pixelPosition.y);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -118,12 +118,12 @@ namespace ComSquare::PPU
|
||||
this->_drawTile(tileMapValue, {(offset.x * NbCharacterWidth) + pos.x,
|
||||
(offset.y * NbCharacterHeight) + pos.y});
|
||||
vramAddress += 2;
|
||||
if (pos.x % 31 == 0 && pos.x) {
|
||||
pos.y++;
|
||||
pos.x = 0;
|
||||
if (pos.y % 31 == 0 && pos.y) {
|
||||
pos.x++;
|
||||
pos.y = 0;
|
||||
}
|
||||
else {
|
||||
pos.x++;
|
||||
pos.y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <stdint-gcc.h>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include "../Models/Vector2.hpp"
|
||||
#include "TileRenderer.hpp"
|
||||
#include "../Ram/Ram.hpp"
|
||||
@@ -127,7 +128,7 @@ namespace ComSquare::PPU
|
||||
}
|
||||
pixelLevel = backgroundSrc.isPriorityPixel(i, j) ? levelHigh : levelLow;
|
||||
|
||||
if (pixelLevel > pixelDestinationLevelMap[i][j]) {
|
||||
if (pixelLevel >= pixelDestinationLevelMap[i][j]) {
|
||||
bufferDest[i][j] = pixel;
|
||||
pixelDestinationLevelMap[i][j] = pixelLevel;
|
||||
}
|
||||
@@ -136,6 +137,7 @@ namespace ComSquare::PPU
|
||||
j = 0;
|
||||
i++;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//! @brief ctor
|
||||
|
||||
+9
-13
@@ -23,20 +23,16 @@ namespace ComSquare::PPU
|
||||
_renderer(renderer),
|
||||
_backgrounds{
|
||||
Background(*this, 1, false),
|
||||
//Background(*this, 1, true),
|
||||
Background(*this, 2, false),
|
||||
//Background(*this, 2, true),
|
||||
Background(*this, 3, false),
|
||||
//Background(*this, 3, true),
|
||||
Background(*this, 4, false),
|
||||
//Background(*this, 4, true)
|
||||
},
|
||||
_mainScreen({{{0}}}),
|
||||
_subScreen({{{0}}})
|
||||
{
|
||||
this->_registers._isLowByte = true;
|
||||
|
||||
// Utils::Debug::populateEnvironment(*this, 1);
|
||||
Utils::Debug::populateEnvironment(*this, 1);
|
||||
}
|
||||
|
||||
uint8_t PPU::read(uint24_t addr)
|
||||
@@ -111,9 +107,9 @@ namespace ComSquare::PPU
|
||||
case PpuRegisters::bgmode:
|
||||
this->_registers._bgmode.raw = data;
|
||||
// update backgrounds
|
||||
for (int i = 0; i < 8; i++) {
|
||||
this->_backgrounds[i].setBpp(this->getBPP((i / 2) + 1));
|
||||
this->_backgrounds[i].setCharacterSize(this->getCharacterSize((i / 2) + 1));
|
||||
for (int i = 0; i < 4; i++) {
|
||||
this->_backgrounds[i].setBpp(this->getBPP(i + 1));
|
||||
this->_backgrounds[i].setCharacterSize(this->getCharacterSize(i + 1));
|
||||
}
|
||||
break;
|
||||
case PpuRegisters::mosaic:
|
||||
@@ -127,14 +123,14 @@ namespace ComSquare::PPU
|
||||
// update background tilemap address
|
||||
this->_backgrounds[addr - PpuRegisters::bg1sc].setTileMapStartAddress(
|
||||
this->getTileMapStartAddress(addr - PpuRegisters::bg1sc + 1));
|
||||
this->_backgrounds[addr - PpuRegisters::bg1sc + 1].setTileMapStartAddress(
|
||||
this->getTileMapStartAddress(addr - PpuRegisters::bg1sc + 1));
|
||||
//this->_backgrounds[addr - PpuRegisters::bg1sc + 1].setTileMapStartAddress(
|
||||
// this->getTileMapStartAddress(addr - PpuRegisters::bg1sc + 1));
|
||||
this->_backgrounds[addr - PpuRegisters::bg1sc].setTileMapMirroring(
|
||||
{static_cast<bool>(this->_registers._bgsc[addr - PpuRegisters::bg1sc].tilemapHorizontalMirroring),
|
||||
static_cast<bool>(this->_registers._bgsc[addr - PpuRegisters::bg1sc].tilemapVerticalMirroring)});
|
||||
this->_backgrounds[addr - PpuRegisters::bg1sc + 1].setTileMapMirroring(
|
||||
{static_cast<bool>(this->_registers._bgsc[addr - PpuRegisters::bg1sc].tilemapHorizontalMirroring),
|
||||
static_cast<bool>(this->_registers._bgsc[addr - PpuRegisters::bg1sc].tilemapVerticalMirroring)});
|
||||
//this->_backgrounds[addr - PpuRegisters::bg1sc + 1].setTileMapMirroring(
|
||||
// {static_cast<bool>(this->_registers._bgsc[addr - PpuRegisters::bg1sc].tilemapHorizontalMirroring),
|
||||
// static_cast<bool>(this->_registers._bgsc[addr - PpuRegisters::bg1sc].tilemapVerticalMirroring)});
|
||||
break;
|
||||
case PpuRegisters::bg12nba:
|
||||
case PpuRegisters::bg34nba:
|
||||
|
||||
+1
-5
@@ -33,13 +33,9 @@ namespace ComSquare::PPU
|
||||
//! @brief Enum to access more easily the ppu background array
|
||||
enum BgName {
|
||||
bg1NoPriority = 0,
|
||||
bg1Priority,
|
||||
bg2NoPriority = 1,
|
||||
bg2Priority,
|
||||
bg3NoPriority = 2,
|
||||
bg3Priority,
|
||||
bg4NoPriority = 3,
|
||||
bg4Priority
|
||||
bg4NoPriority = 3
|
||||
};
|
||||
|
||||
enum PpuRegisters {
|
||||
|
||||
Reference in New Issue
Block a user