Writing a full screen as a RLE compressed file.
I wrote another blog page, a while back, about importing a BMP file into NES Screen Tool. Here…
I’m using the same graphics (Girl3.chr), and I’ve saved my NES Screen Tool (.nss) file as a compressed rle file, “Nametable/Save Nametable and Attributes/RLE packed as C header .h”. Now we can import it into the C code, and print it to the background.
A full nametable is 1024 bytes. You don’t want to leave nametables uncompressed… you would very quickly run out of space. The RLE version is 588 bytes. The game code needs to decompress this Girl3.h file.
We can’t do this with the screen on, so turn it off, then set a starting address, and call the rle function.
So far, I’ve forgotten to mention the palette. I had to change it to make it brown shades. I’m going to discuss this in more detail later. pal_bg() sets the palette for the BG.
Fade In / Fade Out
neslib makes it easy to change the brightness of the screen. You can do this with pal_bright(), using a value between 0 (black) and 8 (white). 4 = normal.
I borrowed a function from Shiru’s “Chase” game, and it’s very easy to use.
pal_fade_to(0,4); // fade from black to normal
pal_fade_to(4,0); // fade from normal to black
And if you run the fade.nes file, you see that it fades in and out in an infinite loop. Fading could be used for transitions, like from the title to the game, or from level to level.