04. Full background

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…

https://nesdoug.com/2017/04/22/nes-screen-tool-bmp-import/

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. We can’t do this with the screen on, so turn it off, then set a starting address, and call the rle function.

ppu_off();

vram_adr(NAMETABLE_A);

vram_unrle(Girl3);

ppu_on_all();

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.

04_fullBG

https://github.com/nesdoug/04_FullBG/blob/master/fullBG.c

https://github.com/nesdoug/04_FullBG

.

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.

https://github.com/nesdoug/05_Fade/blob/master/fade.c

https://github.com/nesdoug/05_Fade

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s