PPU: Implemented second PPU status flag ($213F)

This commit is contained in:
Sour 2019-02-21 18:11:31 -05:00
parent 93b730b390
commit bcf41aca83
2 changed files with 21 additions and 2 deletions

View file

@ -524,6 +524,7 @@ void Ppu::LatchLocationValues()
{ {
_horizontalLocation = _cycle; _horizontalLocation = _cycle;
_verticalLocation = _scanline; _verticalLocation = _scanline;
_locationLatched = true;
} }
uint8_t Ppu::Read(uint16_t addr) uint8_t Ppu::Read(uint16_t addr)
@ -606,6 +607,7 @@ uint8_t Ppu::Read(uint16_t addr)
case 0x213E: case 0x213E:
//STAT77 - PPU Status Flag and Version
//TODO open bus on bit 4 //TODO open bus on bit 4
//"The high/low selector is reset to <20>elow<6F>f when $213f is read" //"The high/low selector is reset to <20>elow<6F>f when $213f is read"
@ -615,9 +617,26 @@ uint8_t Ppu::Read(uint16_t addr)
return ( return (
(_timeOver ? 0x80 : 0) | (_timeOver ? 0x80 : 0) |
(_rangeOver ? 0x40 : 0) | (_rangeOver ? 0x40 : 0) |
0x01 //PPU chip version 0x01 //PPU (5c77) chip version
); );
case 0x213F: {
//STAT78 - PPU Status Flag and Version
//TODO open bus on bit 5
uint8_t value = (
((_frameCount & 0x01) ? 0x80 : 0) |
(_locationLatched ? 0x40 : 0) |
//TODO (_isPal ? 0x10 : 0)
0x02 //PPU (5c78) chip version
);
if(_regs->GetIoPortOutput() & 0x80) {
_locationLatched = false;
}
return value;
}
default: default:
MessageManager::DisplayMessage("Debug", "Unimplemented register read: " + HexUtilities::ToHex(addr)); MessageManager::DisplayMessage("Debug", "Unimplemented register read: " + HexUtilities::ToHex(addr));
break; break;

View file

@ -113,9 +113,9 @@ private:
uint16_t _horizontalLocation = 0; uint16_t _horizontalLocation = 0;
bool _horizontalLocToggle = false; bool _horizontalLocToggle = false;
uint16_t _verticalLocation = 0; uint16_t _verticalLocation = 0;
bool _verticalLocationToggle = false; bool _verticalLocationToggle = false;
bool _locationLatched = false;
uint16_t _mode7MatrixA = 0; uint16_t _mode7MatrixA = 0;
uint16_t _mode7MatrixB = 0; uint16_t _mode7MatrixB = 0;