1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-02 12:41:30 +00:00
8bitworkshop/presets/nes/neslib5.c
2018-07-29 15:57:51 -04:00

54 lines
2.3 KiB
C

//this example code unpacks a RLE'd nametable into the VRAM
//you can create the source data using NES Screen Tool
#include "neslib.h"
const unsigned char test[308]={
0x01,0x00,0x01,0xa3,0x10,0x01,0x04,0x00,0x10,0x01,0x04,0x00,0x10,0x01,0x04,0x00,
0x10,0x01,0x04,0x00,0x01,0x0a,0x10,0x00,0x01,0x02,0x10,0x00,0x01,0x04,0x10,0x00,
0x01,0x06,0x10,0x00,0x01,0x0c,0x10,0x00,0x01,0x02,0x10,0x01,0x02,0x00,0x01,0x02,
0x10,0x01,0x04,0x00,0x01,0x02,0x10,0x00,0x01,0x0c,0x10,0x00,0x01,0x02,0x10,0x00,
0x01,0x08,0x10,0x00,0x01,0x02,0x10,0x00,0x01,0x0c,0x10,0x00,0x01,0x02,0x10,0x01,
0x04,0x00,0x10,0x01,0x04,0x00,0x01,0x02,0x10,0x00,0x01,0x42,0x10,0x00,0x01,0x06,
0x10,0x01,0x04,0x00,0x10,0x00,0x01,0x04,0x10,0x01,0x04,0x00,0x10,0x00,0x01,0x04,
0x10,0x00,0x01,0x06,0x10,0x00,0x01,0x02,0x10,0x00,0x10,0x00,0x01,0x04,0x10,0x00,
0x01,0x06,0x10,0x01,0x04,0x00,0x01,0x06,0x10,0x00,0x01,0x02,0x10,0x00,0x10,0x00,
0x01,0x04,0x10,0x01,0x02,0x00,0x01,0x04,0x10,0x00,0x01,0x02,0x10,0x00,0x01,0x06,
0x10,0x01,0x03,0x00,0x00,0x10,0x00,0x01,0x04,0x10,0x00,0x01,0x06,0x10,0x00,0x01,
0x02,0x10,0x00,0x01,0x06,0x10,0x00,0x01,0x02,0x10,0x00,0x10,0x01,0x04,0x00,0x10,
0x01,0x04,0x00,0x01,0x02,0x10,0x01,0x04,0x00,0x01,0x46,0x10,0x00,0x01,0x02,0x10,
0x00,0x10,0x01,0x04,0x00,0x10,0x01,0x04,0x00,0x01,0x0e,0x10,0x10,0x00,0x10,0x10,
0x00,0x10,0x00,0x01,0x02,0x10,0x00,0x10,0x00,0x01,0x02,0x10,0x00,0x01,0x0e,0x10,
0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x01,0x02,0x10,0x00,0x10,0x00,0x01,0x02,0x10,
0x00,0x01,0x0e,0x10,0x00,0x01,0x02,0x10,0x00,0x10,0x01,0x04,0x00,0x10,0x01,0x04,
0x00,0x01,0x0e,0x10,0x00,0x01,0x02,0x10,0x00,0x10,0x00,0x01,0x02,0x10,0x00,0x10,
0x00,0x01,0xde,0x50,0x01,0x07,0x55,0x01,0x07,0xa5,0x01,0x07,0xaa,0x01,0x0f,0x0a,
0x01,0x07,0x01,0x00
};
const unsigned char palette[16]={ 0x0f,0x21,0x10,0x30,0x0f,0x14,0x21,0x31,0x0f,0x29,0x16,0x26,0x0f,0x09,0x19,0x29 }; //palette data
//#link "tileset1.c"
// tile set, two planes for 4 colors
extern unsigned char TILESET[8*256];
void main(void)
{
//rendering is disabled at the startup, and palette is all black
pal_bg(palette);//set background palette from an array
//copy tileset to RAM
vram_write((unsigned char*)TILESET, 0x0, sizeof(TILESET));
//unpack nametable into the VRAM
unrle_vram(test,0x2000);
//enable rendering
ppu_on_all();
while(1);//do nothing, infinite loop
}