Fx3 wrote:
- Do you know if bit 8000h is affected when writting to 2005/6? Sometimes, I see ANDing with 0x7F00; others with 0xFF00. Who's right?
It doesn't matter, bit 15 has no significance.
tanoatnd wrote:
Now seems to work. (except RasterTest1.NES (which shows garbage when bars goes up on the screen),
Not familiar with that ROM, but stuff that does advanced raster effects probably relies on more precice timing.
As for your Popeye issue -- it might be that you might not be handling the NT wrapping properly.
When the coarse Y goes from 29->0, it toggles nametables, but it also goes from 31->0
without toggling the nametables. If Popeye is dong like a "negative scroll" thing to shake the screen, this might be the source of your problem.
Upon looping at your code again -- it seems like you did things very roundabout in order to get loopy_v to work with your scanline system. You actually made things much more complicated than they actually are. I actually noticed a bug, too -- you're using $2000 for 'tbl' initialization when you should use loopy_v (everything is loopy_v)
Here's some pseudo-code that might simplify the concept for you:
Code:
tbl = (loopy_v >> 10) & 3;
idx = (loopy_v & 0x03FF); // notice you don't need all the wacky scroll computations
tile_x_offset = loopy_x;
tile_y_offset = (loopy_v >> 12) & 7;
/* inside tile rendering loop */
if((idx & 0x001F) == 0x001F)
{
tbl ^= 1;
idx &= ~0x001F;
}
else
++idx;
/* at end of scanline */
if( (loopy_v & 0x7000) == 0x7000 ) // fine-Y scroll wrapped
{
loopy_v &= ~0x7000;
if( (loopy_v & 0x03E0) == 0x03A0 ) // 29->0
loopy_v ^= 0x0800 | 0x03A0; // NT wrap
else if( (loopy_v & 0x03E0) == 0x03E0 ) // 31->0
loopy_v ^= 0x03E0; // no NT wrap
else
loopy_v += 0x0020;
}
else
loopy_v += 0x1000; // fine Y increment
Notice that if you change loopy_v at runtime each scanline, you can handle the wrapping properly -- and also you don't need to offset by whatever scanline is being rendered (which is bad anyway because it won't work for games which turn the PPU on late)