Flipping background tiles?

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

Moderator: Moderators

tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Flipping background tiles?

Post by tepples »

And on the NES, it's the other way around: you can flip sprites but not background tiles. You can flip sprites because the OAM is on a separate bus, but you can't flip background because there isn't enough space in the attribute table to store a flip attribute.

AMIGrAve: Could you attach a mock-up of the picture that you're trying to display on the NES?
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Flipping background tiles?

Post by rainwarrior »

tepples wrote:there isn't enough space in the attribute table to store a flip attribute.
Well, there is 32 unused bits interleaved with the last row. Could have stored a flip bit per column there. ;)
User avatar
AMIGrAve
Posts: 6
Joined: Fri Nov 13, 2015 2:43 am

Re: Flipping background tiles?

Post by AMIGrAve »

tepples wrote:AMIGrAve: Could you attach a mock-up of the picture that you're trying to display on the NES?
Sure, it will be a perspective grid that will looks a bit like this:

Image
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Flipping background tiles?

Post by tepples »

Yes, mappers would allow splitting that into top and bottom halves and serving each from a separate bank of CHR ROM.
User avatar
AMIGrAve
Posts: 6
Joined: Fri Nov 13, 2015 2:43 am

Re: Flipping background tiles?

Post by AMIGrAve »

tepples wrote:Yes, mappers would allow splitting that into top and bottom halves and serving each from a separate bank of CHR ROM.
Thanks!

And for triggering the event at mid frame in order to do the bank switching, is it preferable to use the sprite 0 or do you advise a particular mapper that allows to trigger an IRQ or something at a given scanline ?
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Flipping background tiles?

Post by tokumaru »

If you'll already be using a mapper with decent CHR bankswitching, better use one that also has scanline IRQs. To split the screen with sprite 0 you need to wait for the hit in a loop, which wastes CPU time. IRQs on the other hand can interrupt the program when the desired scanline is reached, regardless of what it's doing, and after the split the program resumes as if nothing had happened.
User avatar
AMIGrAve
Posts: 6
Joined: Fri Nov 13, 2015 2:43 am

Re: Flipping background tiles?

Post by AMIGrAve »

tokumaru wrote:If you'll already be using a mapper with decent CHR bankswitching, better use one that also has scanline IRQs. To split the screen with sprite 0 you need to wait for the hit in a loop, which wastes CPU time. IRQs on the other hand can interrupt the program when the desired scanline is reached, regardless of what it's doing, and after the split the program resumes as if nothing had happened.
Thanks!
I just found the list of mappers with support for scanline IRQs maintained by rainwarrior on the nesdev wiki. Cool!
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Flipping background tiles?

Post by rainwarrior »

I just maintained the category page itself a little. I should not be credited for maintaining the list, a lot of other people did the real work on that one.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Flipping background tiles?

Post by tokumaru »

The MMC3 is probably the best choice in this case. It has reasonably fine CHR bankswitching (2KB for one pattern table and 1KB for the other) and a decent scanline counter. It's also very common and there are implementations of it for homebrew games. The only downside is that since the scanline counter functions by counting pattern table accesses, you can't use sprite tiles from both pattern tables when in 8x16 mode, because that confuses the counter. Sprites must come from one pattern table, and backgrounds from the other.
User avatar
Lazycow
Posts: 105
Joined: Tue Jun 11, 2013 1:04 pm
Location: Germany
Contact:

Re: Flipping background tiles?

Post by Lazycow »

tokumaru wrote:It's also very common and there are implementations of it for homebrew games.
I'm not sure if I understand, do you mean that are chips available that do the job of a MMC3 without the need of grabbing these chips out of other carts?
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Flipping background tiles?

Post by tokumaru »

Yes. INL has all new hardware for many mappers, including the MMC3.
Post Reply