Import Full Background as RLE

Continuing with the neslib examples, I will import a full background (with rendering off) from a RLE compressed nametable.

Last time, I successfully imported a BMP into NES Screen Tool (the newest version, with ‘lossy’ on). I saved the .chr graphics file. Then, I exported the nametable as a compressed RLE with a .h extension.

(note, I had to remove 1 used tile from the .chr, because the RLE code won’t work with 256 unique tiles on screen. See, I made one of the tiles an X, and removed references to it on the nametable, then saved the RLE, and resaved the CHR)

Also, I cut and pasted the palette, from NES Screen Tool…palette/put to clipboard/C data. And, pasted into the .c file.

In the crt0.s file, I had to edit the CHR segment to include the “Girl2.chr” file. In the C code, I had to import the “Girl2.h” (our RLE compressed background data).

Step 1, set a nametable address to start from.

vram_adr(NAMETABLE_A);

Step 2, uncompress the BG data, by sending a pointer to the data to this function…

vram_unrle(Girl2);

(if you open the Girl2.h file, the array of chars is called ‘Girl2’).

And, then turn on rendering. (the scroll position is still set to the default, nametable #0, X and Y are 0,0).

ppu_on_all();

And, compile. Here’s what we have…

lesson23

I find that flat tones (Anime style) works well for NES images.

Here’s the source code…

http://dl.dropboxusercontent.com/s/1ozfna9ro09qz8n/lesson23.zip

 

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s