How big can be the .chr file?

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

Moderator: Moderators

Post Reply
User avatar
kikutano
Posts: 100
Joined: Sat May 26, 2018 6:14 am
Location: Italy

How big can be the .chr file?

Post by kikutano » Sat Oct 06, 2018 2:38 am

Hello to everyone!
Another noob question about Nes Dev. I'm writing the frames for my animations on a .chr file so I need to know what's the max size of .chr to put my graphics into. So what's the size limit? What's the best way to put the entire graphics of the game into a chr ad read it?

Thanks! :)

User avatar
Kasumi
Posts: 1291
Joined: Wed Apr 02, 2008 2:09 pm

Re: How big can be the .chr file?

Post by Kasumi » Sat Oct 06, 2018 2:45 am

The size limit depends on the mapper. If you're using NROM, you get exactly 512 8x8 tiles for the whole game. (8KB.)

On MMC3, you can use 256 KB of CHR. This is 16384 total tiles. There are other mappers with different limitations.

But regardless of how many tiles you have total, the NES can only see 512 at once. 256 of which are usually allocated for sprites. So if all your sprite animations take up more than 256 tiles, you need to write some way to manage them all.

User avatar
kikutano
Posts: 100
Joined: Sat May 26, 2018 6:14 am
Location: Italy

Re: How big can be the .chr file?

Post by kikutano » Sat Oct 06, 2018 3:00 am

So I've to "unload" and "load" 512 tiles at time?

calima
Posts: 1021
Joined: Tue Oct 06, 2015 10:16 am

Re: How big can be the .chr file?

Post by calima » Sat Oct 06, 2018 3:12 am

Probably 256, as 512 might make for very complicated programming side.

User avatar
kikutano
Posts: 100
Joined: Sat May 26, 2018 6:14 am
Location: Italy

Re: How big can be the .chr file?

Post by kikutano » Sat Oct 06, 2018 3:13 am

I see, thanks! :) Maybe I will try to put everything on 40kb game :P .

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

Re: How big can be the .chr file?

Post by tokumaru » Sat Oct 06, 2018 5:13 am

kikutano wrote:So I've to "unload" and "load" 512 tiles at time?
It really depends on the mapper. CNROM, one of the simplest mappers out there, allows you to have 4 8KB pages in total, and you can only swap all 512 tiles at once.

On the other extreme there are mappers like the MMC3, which divides the pattern tables into slots of 1 and 2KB, so you can swap smaller chunks at a time.

There's yet another option for managing graphics, which's CHR-RAM. Using RAM for your tiles means the cartridge doesn't have a separate chip where CHR data is stored, instead it has a RAM chip. The CHR data is then stored in the PRG chip, in whatever format the programmer wants, even compressed, and has to be manually copied to the CHR-RAM chip at run time. In this case, you have total freedom to replace tiles as you wish, but unlike with CHR-ROM, the switch isn't instantaneous, each byte has to be explicitly transferred by the CPU, consuming processing time.

User avatar
Sumez
Posts: 909
Joined: Thu Sep 15, 2016 6:29 am
Location: Denmark (PAL)

Re: How big can be the .chr file?

Post by Sumez » Mon Oct 08, 2018 6:53 am

If you're planning on making graphics for a game, you should get your restrictions from whoever is programming it.
One thing is the innate limitations of the console as we can tell you about. But it really depends on the game design and how the engine is built. A lot of "business logic" stuff matters, like how palettes are distributed, which sprites are reserved for stuff like HUD/bullet/powerup/etc purposes, and how the game intends to dynamically load in new sprites/object types.

Post Reply