all ppu registers write (except write registers to vram cgram & oamram))

This commit is contained in:
Clément Le Bihan
2020-02-13 11:16:29 +01:00
parent 62a36d98b0
commit c5fa9906c1
3 changed files with 116 additions and 29 deletions
+17 -1
View File
@@ -142,6 +142,22 @@ namespace ComSquare::PPU
case ppuRegisters::ts:
this->_t[addr - ppuRegisters::tm].raw = data;
break;
case ppuRegisters::tmw:
case ppuRegisters::tsw:
this->_tw[addr - ppuRegisters::tmw].raw = data;
break;
case ppuRegisters::cgwsel:
this->_cgwsel.raw = data;
break;
case ppuRegisters::cgadsub:
this->_cgadsub.raw = data;
break;
case ppuRegisters::coldata:
this->_coldata.raw = data;
break;
case ppuRegisters::setini:
this->_setini.raw = data;
break;
//TODO adding the rest of the registers. oaf !
default:
throw InvalidAddress("PPU Internal Registers write", addr);
@@ -168,7 +184,7 @@ namespace ComSquare::PPU
{
(void)cycles;
int inc = getVramAddress();
uint32_t pixelTmp = 0xFFFFFFFF;
//uint32_t pixelTmp = 0xFFFFFFFF;
//pixelTmp |= this->_inidisp.brightness;
if (!this->_inidisp.fblank) {
for (int x = 0; x < 448; x++) {
+30 -27
View File
@@ -432,18 +432,18 @@ namespace ComSquare::PPU
};
uint8_t raw;
} _t[2];
//! @brief TMW Register (Window Mask Designation for the Main Screen)
//! @brief TMW - TSW Registers (Window Mask Designation for the Main/Sub Screen)
union {
struct {
uint8_t _: 3;
bool enableWindowMaskingObj: 1;
bool enableWindowMaskingBg4: 1;
bool enableWindowMaskingBg3: 1;
bool enableWindowMaskingBg2: 1;
bool enableWindowMaskingBg1: 1;
bool enableWindowMaskingBg2: 1;
bool enableWindowMaskingBg3: 1;
bool enableWindowMaskingBg4: 1;
bool enableWindowMaskingObj: 1;
uint8_t _: 3;
};
uint8_t raw;
} _tmw;
} _tw[2];
//! @brief TSW Register (Window Mask Designation for the Sub Screen)
union {
struct {
@@ -459,51 +459,54 @@ namespace ComSquare::PPU
//! @brief CGWSEL Register (Color Addition Select)
union {
struct {
uint8_t clipColorToBlackBeforeMath: 2;
uint8_t preventColorMath: 2;
uint8_t _: 2;
bool addSubscreen: 1;
bool directColorMode: 1;
bool addSubscreen: 1;
uint8_t _: 2;
uint8_t preventColorMath: 2;
uint8_t clipColorToBlackBeforeMath: 2;
};
uint8_t raw;
} _cgwsel;
//! @brief CGADSUB Register (Color Math designation)
union {
struct {
bool addSubtractSelect: 1;
bool halfColorMath: 1;
bool enableColorMathBackdrop: 1;
bool enableColorMathObj: 1;
bool enableColorMathBg4: 1;
bool enableColorMathBg3: 1;
bool enableColorMathBg2: 1;
bool enableColorMathBg1: 1;
bool enableColorMathBg2: 1;
bool enableColorMathBg3: 1;
bool enableColorMathBg4: 1;
bool enableColorMathObj: 1;
bool enableColorMathBackdrop: 1;
bool halfColorMath: 1;
bool addSubtractSelect: 1;
};
uint8_t raw;
} _cgadsub;
//! @brief COLDATA Register (Fixed Color Data)
union {
struct {
bool blue: 1;
bool green: 1;
bool red: 1;
uint8_t colorIntensity: 5;
bool red: 1;
bool green: 1;
bool blue: 1;
};
uint8_t raw;
} _coldata;
//! @brief SETINI Register (Screen Mode/Video Select)
union {
struct {
bool externalSync: 1;
bool mode7ExtBg: 1;
uint8_t _: 2;
bool enablePseudoHiresMode: 1;
bool overscanMode: 1;
bool objInterlace: 1;
bool screenInterlace: 1;
bool objInterlace: 1;
bool overscanMode: 1;
bool enablePseudoHiresMode: 1;
uint8_t _: 2;
bool mode7ExtBg: 1;
bool externalSync: 1;
};
uint8_t raw;
} _setini;
// <READ registers> not in priority
//! @brief MPYL - MPYM - MPYH Registers (Multiplication Result)
union {
struct {
+69 -1
View File
@@ -90,7 +90,7 @@ Test(PPU_write_2, cgadd_full_high_byte_null)
Test(PPU_write_2, cgdata_data_full)
{
auto pair = Init();
pair.first->write(0x2121, 0b11111111);
pair.first->write(0x2121, 0x0);
pair.first->write(0x2122, 0b11111111);
cr_assert_eq(pair.second.ppu->_cgdata.cgdatal, 0b11111111);
cr_assert_eq(pair.second.ppu->_isLowByte, false);
@@ -201,4 +201,72 @@ Test(PPU_write_2, ts_data_full)
cr_assert_eq(pair.second.ppu->_t[1].enableWindowDisplayBg3, true);
cr_assert_eq(pair.second.ppu->_t[1].enableWindowDisplayBg4, true);
cr_assert_eq(pair.second.ppu->_t[1].enableWindowDisplayObj, false);
}
Test(PPU_write_2, tmw_data_full)
{
auto pair = Init();
pair.first->write(0x212E, 0b10101110);
cr_assert_eq(pair.second.ppu->_tw[0].enableWindowMaskingBg1, false);
cr_assert_eq(pair.second.ppu->_tw[0].enableWindowMaskingBg2, true);
cr_assert_eq(pair.second.ppu->_tw[0].enableWindowMaskingBg3, true);
cr_assert_eq(pair.second.ppu->_tw[0].enableWindowMaskingBg4, true);
cr_assert_eq(pair.second.ppu->_tw[0].enableWindowMaskingObj, false);
}
Test(PPU_write_2, tsw_data_full)
{
auto pair = Init();
pair.first->write(0x212F, 0b10100011);
cr_assert_eq(pair.second.ppu->_tw[1].enableWindowMaskingBg1, true);
cr_assert_eq(pair.second.ppu->_tw[1].enableWindowMaskingBg2, true);
cr_assert_eq(pair.second.ppu->_tw[1].enableWindowMaskingBg3, false);
cr_assert_eq(pair.second.ppu->_tw[1].enableWindowMaskingBg4, false);
cr_assert_eq(pair.second.ppu->_tw[1].enableWindowMaskingObj, false);
}
Test(PPU_write_2, cgwsel_data_full)
{
auto pair = Init();
pair.first->write(0x2130, 0b10111001);
cr_assert_eq(pair.second.ppu->_cgwsel.clipColorToBlackBeforeMath, 0b10);
cr_assert_eq(pair.second.ppu->_cgwsel.preventColorMath, 0b11);
cr_assert_eq(pair.second.ppu->_cgwsel.addSubscreen, false);
cr_assert_eq(pair.second.ppu->_cgwsel.directColorMode, true);
}
Test(PPU_write_2, cgadsub_data_full)
{
auto pair = Init();
pair.first->write(0x2131, 0b10111001);
cr_assert_eq(pair.second.ppu->_cgadsub.addSubtractSelect, true);
cr_assert_eq(pair.second.ppu->_cgadsub.halfColorMath, false);
cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathBackdrop, true);
cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathObj, true);
cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathBg4, true);
cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathBg3, false);
cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathBg2, false);
cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathBg1, true);
}
Test(PPU_write_2, coldata_data_full)
{
auto pair = Init();
pair.first->write(0x2132, 0b10111001);
cr_assert_eq(pair.second.ppu->_coldata.blue, true);
cr_assert_eq(pair.second.ppu->_coldata.green, false);
cr_assert_eq(pair.second.ppu->_coldata.red, true);
cr_assert_eq(pair.second.ppu->_coldata.colorIntensity, 0b11001);
}
Test(PPU_write_2, setini_data_full)
{
auto pair = Init();
pair.first->write(0x2133, 0b10111001);
cr_assert_eq(pair.second.ppu->_setini.externalSync, true);
cr_assert_eq(pair.second.ppu->_setini.mode7ExtBg, false);
cr_assert_eq(pair.second.ppu->_setini.enablePseudoHiresMode, true);
cr_assert_eq(pair.second.ppu->_setini.overscanMode, false);
cr_assert_eq(pair.second.ppu->_setini.objInterlace, false);
cr_assert_eq(pair.second.ppu->_setini.screenInterlace, true);
}