Best practise to avoid scanline limitations

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Best practise to avoid scanline limitations

Post by tokumaru »

-Basti- wrote:The coordinates are correct, since I used them in my sprite-based version.
Don't forget that sprite coordinates are in pixel units while tile coordinates are in tile units. Since each tile is 8x8 pixels:

Code: Select all

TileX = PixelX >> 3
TileY = PixelY >> 3
na_th_an
Posts: 558
Joined: Mon May 27, 2013 9:40 am

Re: Best practise to avoid scanline limitations

Post by na_th_an »

-Basti- wrote:Thanks, that worked for me :) I have to add, that you need to initialize the update-list with NT_UPD_EOF, before the first game-loop, instead you will only see a flickering screen.
You don't, if you do things right. I mean, that flickering screen is because you are calling ppu_wait_nmi with an un-terminated update-list. The section in the NMI code which deals with update lists just interprets the update buffer array until it finds the value NT_UPD_EOF (which is a number). Most likely, the NMI code is sending everything in RAM to the VRAM so things end in a very awful crash.

So most likely you are enabling the update list too early. Maybe there's a ppu_wait_nmi before the first loop.

In my example, you are not calling ppu_wait_nmi until NT_UPD_EOF has been written to the update buffer, so there's no need to initialize anything. NT_UPD_EOF is written when it's going to be needed: during the execution of ppu_wait_nmi.

Always make sure you enable the update buffer right before your loop, and that you write NT_UPD_EOF to it right before your ppu_wait_nmi call, and you won't have problems.

What you did is most likely a patch because you have stuff around you are not completely in control. It may float your boat and save your day, but my advice is that you should address the problem, find the real cause, get things properly in control, and remove all patches.
User avatar
-Basti-
Posts: 40
Joined: Sun Sep 26, 2010 10:29 pm

Re: Best practise to avoid scanline limitations

Post by -Basti- »

tokumaru wrote:
-Basti- wrote:The coordinates are correct, since I used them in my sprite-based version.
Don't forget that sprite coordinates are in pixel units while tile coordinates are in tile units. Since each tile is 8x8 pixels:

Code: Select all

TileX = PixelX >> 3
TileY = PixelY >> 3
That was the problem. Thanks for the hint :)
Post Reply