Add latching to ppu
This commit is contained in:
@@ -590,7 +590,7 @@ void Ppu::HandleVblank() {
|
|||||||
frame_interlace = interlace; // set if we have a interlaced frame
|
frame_interlace = interlace; // set if we have a interlaced frame
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Ppu::Read(uint8_t adr) {
|
uint8_t Ppu::Read(uint8_t adr, bool latch) {
|
||||||
switch (adr) {
|
switch (adr) {
|
||||||
case 0x04:
|
case 0x04:
|
||||||
case 0x14:
|
case 0x14:
|
||||||
@@ -621,9 +621,9 @@ uint8_t Ppu::Read(uint8_t adr) {
|
|||||||
}
|
}
|
||||||
case 0x37: {
|
case 0x37: {
|
||||||
// TODO: only when ppulatch is set
|
// TODO: only when ppulatch is set
|
||||||
hCount = memory_.h_pos() / 4;
|
if (latch) {
|
||||||
vCount = memory_.v_pos();
|
LatchHV();
|
||||||
countersLatched = true;
|
}
|
||||||
return memory_.open_bus();
|
return memory_.open_bus();
|
||||||
}
|
}
|
||||||
case 0x38: {
|
case 0x38: {
|
||||||
@@ -711,9 +711,11 @@ uint8_t Ppu::Read(uint8_t adr) {
|
|||||||
val |= ppu2openBus & 0x20;
|
val |= ppu2openBus & 0x20;
|
||||||
val |= countersLatched << 6;
|
val |= countersLatched << 6;
|
||||||
val |= even_frame << 7;
|
val |= even_frame << 7;
|
||||||
countersLatched = false; // TODO: only when ppulatch is set
|
if (latch) {
|
||||||
|
countersLatched = false;
|
||||||
hCountSecond = false;
|
hCountSecond = false;
|
||||||
vCountSecond = false;
|
vCountSecond = false;
|
||||||
|
}
|
||||||
ppu2openBus = val;
|
ppu2openBus = val;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,6 +314,12 @@ class Ppu : public SharedRom {
|
|||||||
void RunLine(int line);
|
void RunLine(int line);
|
||||||
void HandlePixel(int x, int y);
|
void HandlePixel(int x, int y);
|
||||||
|
|
||||||
|
void LatchHV() {
|
||||||
|
hCount = memory_.h_pos() / 4;
|
||||||
|
vCount = memory_.v_pos();
|
||||||
|
countersLatched = true;
|
||||||
|
}
|
||||||
|
|
||||||
int GetPixel(int x, int y, bool sub, int* r, int* g, int* b);
|
int GetPixel(int x, int y, bool sub, int* r, int* g, int* b);
|
||||||
|
|
||||||
void EvaluateSprites(int line);
|
void EvaluateSprites(int line);
|
||||||
@@ -350,7 +356,7 @@ class Ppu : public SharedRom {
|
|||||||
uint16_t GetOffsetValue(int col, int row);
|
uint16_t GetOffsetValue(int col, int row);
|
||||||
int GetPixelForBgLayer(int x, int y, int layer, bool priority);
|
int GetPixelForBgLayer(int x, int y, int layer, bool priority);
|
||||||
|
|
||||||
uint8_t Read(uint8_t adr);
|
uint8_t Read(uint8_t adr, bool latch);
|
||||||
void Write(uint8_t adr, uint8_t val);
|
void Write(uint8_t adr, uint8_t val);
|
||||||
|
|
||||||
uint16_t GetVramRemap();
|
uint16_t GetVramRemap();
|
||||||
|
|||||||
Reference in New Issue
Block a user