First row of background tiles is hidden

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
PaulSurzh
Posts: 3
Joined: Sun Jul 19, 2020 12:16 am

First row of background tiles is hidden

Post by PaulSurzh » Sun Jul 19, 2020 12:41 am

I'm currently just playing with emulators, and I created a simple test program, that shows which keys are pressed. Don't look at the roundabout way of handling input and the fact that CHR is written with asm (I'm using asm6 btw), that's not the point. The weird thing is that I have to write tiles from $2020 of PPU, i.e. from the second row. If I write them from the first row, then FCEUX nametable viewer still shows them, but they aren't shown on the screen. It's as if the first row is always above the area that the screen shows.

It's probably a dumb question, but I really cannot find information about this on the wiki.
Attachments
input_test.nes
(40.02 KiB) Downloaded 18 times
input_test.asm
(2.13 KiB) Downloaded 17 times

User avatar
Quietust
Posts: 1569
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: First row of background tiles is hidden

Post by Quietust » Sun Jul 19, 2020 6:16 am

The phenomenon you are experiencing is called overscan, and it is common for emulators to hide the top and bottom 8 scanlines to yield a 256x224 playfield, even to the point that many technical documents incorrectly claim this to be the NES's output resolution (rather than 256x240).

Incidentally, your test ROM has a rather significant problem - after reset, it's enabling rendering and then trying to clear all of VRAM (which is taking it about 305 scanlines). VRAM can only be safely written when the PPU is not rendering, which is only during the 20-scanline VBLANK window unless you disable rendering.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
dougeff
Posts: 2712
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: First row of background tiles is hidden

Post by dougeff » Sun Jul 19, 2020 7:09 am

My modern flat screen TV shows all 240 vertical lines. An older CRT TV cuts off 5-7 lines from the top and bottom, and even more at the corners.
nesdoug.com -- blog/tutorial on programming for the NES

PaulSurzh
Posts: 3
Joined: Sun Jul 19, 2020 12:16 am

Re: First row of background tiles is hidden

Post by PaulSurzh » Sun Jul 19, 2020 10:06 am

Thanks, Quietust, that's exactly what I was looking for and even more! By disabling rendering did you mean resetting bits 3 and 4 of PPUMASK? I do that now before clearing VRAM.
Attachments
input_test.nes
(40.02 KiB) Downloaded 17 times
input_test.asm
(2.2 KiB) Downloaded 17 times

Pokun
Posts: 1492
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: First row of background tiles is hidden

Post by Pokun » Wed Jul 22, 2020 1:00 pm

Yes when both background and sprites are disabled, rendering is considered to be off and you have access to VRAM. Your old program had a lot of garbage on the screen which is fixed now. Now you just need to move the controller input indicators to within the "title safe area" like it says on the wiki.

My modern LCD TV crops quite a bit of the screen while my older CRTs shows much more, so it's never guaranteed that the outer border is shown or not shown, and it's different on different TV sets. The title safe area has quite a margin and is probably shown on all TV sets though.

PaulSurzh
Posts: 3
Joined: Sun Jul 19, 2020 12:16 am

Re: First row of background tiles is hidden

Post by PaulSurzh » Wed Jul 22, 2020 2:54 pm

Thanks for the important info, I actually didn't look at the NesDev wiki overscan page, so I didn't know about the "title safe area".

I've actually already moved the indicators to the very center of the screen (just because it looks better, not because they were outside the safe area). I also added a lot of useless and probably annoying stuff (I am not trying to make anything useful, just playing with different features of PPU and APU to understand them better).
Attachments
input_test.nes
(40.02 KiB) Downloaded 13 times
input_test.asm
(5.26 KiB) Downloaded 11 times

Post Reply