Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix ppu scroll glitch bug #1788

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ares/fc/cpu/timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ auto CPU::read(n16 address) -> n8 {
}

auto CPU::write(n16 address, n8 data) -> void {
writeBus(address, io.openBus = data);
writeBus(address, data);
io.openBus = data;
step(rate());
}

Expand Down
10 changes: 9 additions & 1 deletion ares/fc/ppu/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ auto PPU::writeIO(n16 address, n8 data) -> void {

//PPUCTRL
case 0:
scroll.nametable = data.bit(0,1);
scroll.nametable = data.bit(0,1);
if (io.lx == 257 && rendering())
var.nametableX = cpu.io.openBus.bit(0);

io.vramIncrement = data.bit(2) ? 32 : 1;
io.spriteAddress = data.bit(3) ? 0x1000 : 0x0000;
io.bgAddress = data.bit(4) ? 0x1000 : 0x0000;
Expand Down Expand Up @@ -141,6 +144,9 @@ auto PPU::writeIO(n16 address, n8 data) -> void {
if(scroll.latch++ == 0) {
scroll.fineX = data.bit(0,2);
scroll.tileX = data.bit(3,7);

if (io.lx == 257 && rendering())
var.tileX = cpu.io.openBus.bit(3,7);
} else {
scroll.fineY = data.bit(0,2);
scroll.tileY = data.bit(3,7);
Expand All @@ -151,6 +157,8 @@ auto PPU::writeIO(n16 address, n8 data) -> void {
case 6:
if(scroll.latch++ == 0) {
scroll.addressHi = data.bit(0,5);
if (io.lx == 257 && rendering())
var.nametable = cpu.io.openBus.bit(2,3);
} else {
scroll.addressLo = data.bit(0,7);
scroll.transferDelay = 3;
Expand Down
Loading