/* Metasprites combine several hardware sprites to make a larger sprite. Our demo uses 4 hardware sprites in a 2x2 pattern, forming 16x16 pixel sprites. */ #include #include // include NESLIB header #include "neslib.h" // include CC65 NES Header (PPU) #include // link the pattern table into CHR ROM //#link "chr_generic.s" ///// METASPRITES #define TILE 0xd8 #define ATTR 0 // define a 2x2 metasprite const unsigned char metasprite[]={ 0, 0, TILE+0, ATTR, 0, 8, TILE+1, ATTR, 8, 0, TILE+2, ATTR, 8, 8, TILE+3, ATTR, 128}; /*{pal:"nes",layout:"nes"}*/ const char PALETTE[32] = { 0x03, // screen color 0x11,0x30,0x27,0x0, // background palette 0 0x1c,0x20,0x2c,0x0, // background palette 1 0x00,0x10,0x20,0x0, // background palette 2 0x06,0x16,0x26,0x0, // background palette 3 0x16,0x35,0x24,0x0, // sprite palette 0 0x00,0x37,0x25,0x0, // sprite palette 1 0x0d,0x2d,0x3a,0x0, // sprite palette 2 0x0d,0x27,0x2a // sprite palette 3 }; // setup PPU and tables void setup_graphics() { // clear sprites oam_clear(); // set palette colors pal_all(PALETTE); // turn on PPU ppu_on_all(); } // number of actors (4 h/w sprites each) #define NUM_ACTORS 16 // actor x/y positions byte actor_x[NUM_ACTORS]; byte actor_y[NUM_ACTORS]; // actor x/y deltas per frame (signed) sbyte actor_dx[NUM_ACTORS]; sbyte actor_dy[NUM_ACTORS]; // main program void main() { char i; char oam_id; setup_graphics(); // initialize actors with random values for (i=0; i