Skip to content

Add subroutine to clear ppu nametables. Call during reset init after …#7

Open
Spacefreak18 wants to merge 1 commit intoNesHacker:mainfrom
Spacefreak18:nametable_init
Open

Add subroutine to clear ppu nametables. Call during reset init after …#7
Spacefreak18 wants to merge 1 commit intoNesHacker:mainfrom
Spacefreak18:nametable_init

Conversation

@Spacefreak18
Copy link

@Spacefreak18 Spacefreak18 commented Nov 25, 2023

This pull request addresses the issue of garbage appearing in the background when using the compiled ROM on real hardware with an Everdrive N8 Pro.

#6

It didn't take me long to put together that something must not be init to zero, and while that is fine on emulators, causes a problem on real hardware. In this demo, only part of the nametable is setup with background tiles, mainly just the ground. The rest is left uninitialized and will point to garbage tiles in the ROM.

You can read more about this behavior here.
https://forums.nesdev.org/viewtopic.php?t=18135

Some emulators such as mesen allow you change the default behavior of the emulator (initializing RAM to zeros) to the default behavior of a real console, leaving the RAM initialized with garbage rather than zeros thereby allowing you to replicate this behavior.

The fix here adds two subroutines I pulled from the NESHacker nes-pi repository for clearing the nametables, and i add them to the reset subroutine right after the cpu ram is initialized to zero.

Right now i left it only clearing nametable a and nametable c, this would have to change if you changed the mirroring. I could add another subroutine that clears all nametables as well, which will cover either mirroring setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant