diff --git a/Core/Ppu.cpp b/Core/Ppu.cpp index bfadc34..c3005a3 100644 --- a/Core/Ppu.cpp +++ b/Core/Ppu.cpp @@ -529,6 +529,10 @@ void Ppu::LatchLocationValues() uint8_t Ppu::Read(uint16_t addr) { switch(addr) { + case 0x2134: return ((int16_t)_mode7MatrixA * ((int16_t)_mode7MatrixB >> 8)) & 0xFF; + case 0x2135: return (((int16_t)_mode7MatrixA * ((int16_t)_mode7MatrixB >> 8)) >> 8) & 0xFF; + case 0x2136: return (((int16_t)_mode7MatrixA * ((int16_t)_mode7MatrixB >> 8)) >> 16) & 0xFF; + case 0x2137: //SLHV - Software Latch for H/V Counter //Latch values on read, and return open bus @@ -753,6 +757,18 @@ void Ppu::Write(uint32_t addr, uint8_t value) } break; + case 0x211B: + //M7A - Mode 7 Matrix A (also used with $2134/6) + _mode7MatrixA = (value << 8) | _mode7Latch; + _mode7Latch = value; + break; + + case 0x211C: + //M7B - Mode 7 Matrix B (also used with $2134/6) + _mode7MatrixB = (value << 8) | _mode7Latch; + _mode7Latch = value; + break; + case 0x2121: //CGRAM Address(CGADD) _cgramAddress = value * 2; diff --git a/Core/Ppu.h b/Core/Ppu.h index 4cda177..b51dd21 100644 --- a/Core/Ppu.h +++ b/Core/Ppu.h @@ -117,6 +117,10 @@ private: uint16_t _verticalLocation = 0; bool _verticalLocationToggle = false; + uint16_t _mode7MatrixA = 0; + uint16_t _mode7MatrixB = 0; + uint8_t _mode7Latch = 0; + template void RenderBgColor();