diff --git a/index.html b/index.html index ff3b11f4..3cf738b6 100644 --- a/index.html +++ b/index.html @@ -51,11 +51,14 @@ body { +
  •   Making 8-bit Arcade Games in C +
  • +
  •   Designing Video Game Hardware in Verilog @@ -399,10 +406,9 @@ $( ".dropdown-submenu" ).click(function(event) { - + + - - diff --git a/presets/nes/chase/game.c b/presets/nes/chase/game.c index 97389517..fae09315 100644 --- a/presets/nes/chase/game.c +++ b/presets/nes/chase/game.c @@ -105,20 +105,20 @@ //palettes data //all the palettes are designed in NES Screen Tool, then copy/pasted here //with Palettes/Put C data to clipboard function - -const unsigned char palTitle[16]={ 0x0f,0x0f,0x0f,0x0f,0x0f,0x1c,0x2c,0x3c,0x0f,0x12,0x22,0x32,0x0f,0x14,0x24,0x34 }; - +/*{pal:"nes",layout:"nes"}*/ const unsigned char palGame1[16]={ 0x0f,0x11,0x32,0x30,0x0f,0x1c,0x2c,0x3c,0x0f,0x09,0x27,0x38,0x0f,0x11,0x21,0x31 }; - +/*{pal:"nes",layout:"nes"}*/ const unsigned char palGame2[16]={ 0x0f,0x11,0x32,0x30,0x0f,0x11,0x21,0x31,0x0f,0x07,0x27,0x38,0x0f,0x13,0x23,0x33 }; - +/*{pal:"nes",layout:"nes"}*/ const unsigned char palGame3[16]={ 0x0f,0x11,0x32,0x30,0x0f,0x15,0x25,0x35,0x0f,0x05,0x27,0x38,0x0f,0x13,0x23,0x33 }; - +/*{pal:"nes",layout:"nes"}*/ const unsigned char palGame4[16]={ 0x0f,0x11,0x32,0x30,0x0f,0x19,0x29,0x39,0x0f,0x0b,0x27,0x38,0x0f,0x17,0x27,0x37 }; - +/*{pal:"nes",layout:"nes"}*/ const unsigned char palGame5[16]={ 0x0f,0x11,0x32,0x30,0x0f,0x16,0x26,0x36,0x0f,0x07,0x27,0x38,0x0f,0x18,0x28,0x38 }; - +/*{pal:"nes",layout:"nes"}*/ const unsigned char palGameSpr[16]={ 0x0f,0x0f,0x29,0x30,0x0f,0x0f,0x26,0x30,0x0f,0x0f,0x24,0x30,0x0f,0x0f,0x21,0x30 }; +/*{pal:"nes",layout:"nes"}*/ +const unsigned char palTitle[16]={ 0x0f,0x0f,0x0f,0x0f,0x0f,0x1c,0x2c,0x3c,0x0f,0x12,0x22,0x32,0x0f,0x14,0x24,0x34 }; //metasprites diff --git a/presets/nes/chase/level1_nam.h b/presets/nes/chase/level1_nam.h index 83f0e865..b47299b3 100644 --- a/presets/nes/chase/level1_nam.h +++ b/presets/nes/chase/level1_nam.h @@ -1,22 +1,23 @@ -const unsigned char level1_nam[305]={ -0x01,0x00,0x01,0xfe,0x00,0x01,0x08,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40, -0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x00,0x01,0x0f,0x42,0x43,0x42,0x43,0x42,0x43, -0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x00,0x01,0x0f,0x40,0x41,0x10, -0x44,0x45,0x46,0x45,0x46,0x45,0x46,0x45,0x46,0x45,0x46,0x40,0x41,0x00,0x01,0x0f, -0x42,0x43,0x44,0x44,0x47,0x48,0x47,0x48,0x47,0x48,0x47,0x48,0x47,0x48,0x42,0x43, -0x00,0x01,0x0f,0x40,0x41,0x45,0x46,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x45, -0x46,0x40,0x41,0x00,0x01,0x0f,0x42,0x43,0x47,0x48,0x42,0x43,0x42,0x43,0x42,0x43, -0x42,0x43,0x47,0x48,0x42,0x43,0x00,0x01,0x0f,0x40,0x41,0x45,0x46,0x45,0x46,0x45, -0x46,0x45,0x46,0x45,0x46,0x45,0x46,0x40,0x41,0x00,0x01,0x0f,0x42,0x43,0x47,0x48, -0x47,0x48,0x47,0x48,0x47,0x48,0x47,0x48,0x47,0x48,0x42,0x43,0x00,0x01,0x0f,0x40, -0x41,0x45,0x46,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x45,0x46,0x40,0x41,0x00, -0x01,0x0f,0x42,0x43,0x47,0x48,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x47,0x48, -0x42,0x43,0x00,0x01,0x0f,0x40,0x41,0x45,0x46,0x45,0x46,0x45,0x46,0x45,0x46,0x45, -0x46,0x11,0x44,0x40,0x41,0x00,0x01,0x0f,0x42,0x43,0x47,0x48,0x47,0x48,0x47,0x48, -0x47,0x48,0x47,0x48,0x44,0x44,0x42,0x43,0x00,0x01,0x0f,0x40,0x41,0x40,0x41,0x40, -0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x00,0x01,0x0f,0x42,0x43, -0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x00,0x01, -0xfe,0x00,0x01,0x1a,0xbd,0xad,0xad,0x6d,0x00,0x01,0x03,0xb9,0xad,0xad,0x6e,0x00, -0x01,0x03,0xb9,0xad,0xad,0x6e,0x00,0x01,0x03,0x0d,0x01,0x03,0x00,0x01,0x11,0x01, -0x00 -}; +/*{w:32,h:30,bpp:8,comp:"rletag",map:"nesnt"}*/ +const unsigned char level1_nam[305]={ +0x01,0x00,0x01,0xfe,0x00,0x01,0x08,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40, +0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x00,0x01,0x0f,0x42,0x43,0x42,0x43,0x42,0x43, +0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x00,0x01,0x0f,0x40,0x41,0x10, +0x44,0x45,0x46,0x45,0x46,0x45,0x46,0x45,0x46,0x45,0x46,0x40,0x41,0x00,0x01,0x0f, +0x42,0x43,0x44,0x44,0x47,0x48,0x47,0x48,0x47,0x48,0x47,0x48,0x47,0x48,0x42,0x43, +0x00,0x01,0x0f,0x40,0x41,0x45,0x46,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x45, +0x46,0x40,0x41,0x00,0x01,0x0f,0x42,0x43,0x47,0x48,0x42,0x43,0x42,0x43,0x42,0x43, +0x42,0x43,0x47,0x48,0x42,0x43,0x00,0x01,0x0f,0x40,0x41,0x45,0x46,0x45,0x46,0x45, +0x46,0x45,0x46,0x45,0x46,0x45,0x46,0x40,0x41,0x00,0x01,0x0f,0x42,0x43,0x47,0x48, +0x47,0x48,0x47,0x48,0x47,0x48,0x47,0x48,0x47,0x48,0x42,0x43,0x00,0x01,0x0f,0x40, +0x41,0x45,0x46,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x45,0x46,0x40,0x41,0x00, +0x01,0x0f,0x42,0x43,0x47,0x48,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x47,0x48, +0x42,0x43,0x00,0x01,0x0f,0x40,0x41,0x45,0x46,0x45,0x46,0x45,0x46,0x45,0x46,0x45, +0x46,0x11,0x44,0x40,0x41,0x00,0x01,0x0f,0x42,0x43,0x47,0x48,0x47,0x48,0x47,0x48, +0x47,0x48,0x47,0x48,0x44,0x44,0x42,0x43,0x00,0x01,0x0f,0x40,0x41,0x40,0x41,0x40, +0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x40,0x41,0x00,0x01,0x0f,0x42,0x43, +0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x42,0x43,0x00,0x01, +0xfe,0x00,0x01,0x1a,0xbd,0xad,0xad,0x6d,0x00,0x01,0x03,0xb9,0xad,0xad,0x6e,0x00, +0x01,0x03,0xb9,0xad,0xad,0x6e,0x00,0x01,0x03,0x0d,0x01,0x03,0x00,0x01,0x11,0x01, +0x00 +}; diff --git a/presets/nes/climber.c b/presets/nes/climber.c index de14496b..1c99ca9f 100644 --- a/presets/nes/climber.c +++ b/presets/nes/climber.c @@ -36,7 +36,7 @@ typedef enum { SND_START, SND_HIT, SND_COIN, SND_JUMP } SFXIndex; #define COLS 30 // floor width in tiles #define ROWS 60 // total nametable height in tiles -#define MAX_FLOORS 24 // total # of floors in a stage +#define MAX_FLOORS 4 // total # of floors in a stage #define GAPSIZE 4 // gap size in tiles #define BOTTOM_FLOOR_Y 2 // offset for bottommost floor @@ -365,7 +365,8 @@ typedef struct Actor { byte x; // X position in pixels (8 bit) byte floor; // floor index byte state; // ActorState - int name:2; // ActorType + int name:2; // ActorType (2 bits) + int pal:2; // palette color (2 bits) int dir:1; // direction (0=right, 1=left) int onscreen:1; // is actor onscreen? union { @@ -394,11 +395,12 @@ void create_actors_on_floor(byte floor_index) { a->name = ACTOR_RESCUE; a->state = PACING; a->x = 0; + a->pal = 1; } } } -byte draw_actor(byte oam_id, byte i) { +void draw_actor(byte i) { struct Actor* a = &actors[i]; bool dir; const unsigned char* meta; @@ -406,13 +408,13 @@ byte draw_actor(byte oam_id, byte i) { int screen_y = SCREEN_Y_BOTTOM - a->yy + scroll_pixel_yy; if (screen_y > 192+8 || screen_y < -18) { a->onscreen = 0; - return oam_id; // offscreen vertically + return; // offscreen vertically } dir = a->dir; switch (a->state) { case INACTIVE: a->onscreen = 0; - return oam_id; // inactive, offscreen + return; // inactive, offscreen case STANDING: meta = dir ? playerLStand : playerRStand; break; @@ -435,37 +437,31 @@ byte draw_actor(byte oam_id, byte i) { // set sprite values x = a->x; y = screen_y; - oam_id = oam_meta_spr(x, y, oam_id, meta); + oam_meta_spr_pal(x, y, a->pal, meta); // is this actor 0? (player sprite) if (i == 0) { player_screen_y = y; // last screen Y position - // set special palette for the player's sprites - // directly in OAM buffer - OAMBUF[0].attr |= 3; - OAMBUF[1].attr |= 3; - OAMBUF[2].attr |= 3; - OAMBUF[3].attr |= 3; } a->onscreen = 1; - return oam_id; + return; } -byte draw_scoreboard(byte oam_id) { - oam_id = oam_spr(24+0, 24, '0'+(score >> 4), 2, oam_id); - oam_id = oam_spr(24+8, 24, '0'+(score & 0xf), 2, oam_id); - return oam_id; +void draw_scoreboard() { + oam_off = oam_spr(24+0, 24, '0'+(score >> 4), 2, oam_off); + oam_off = oam_spr(24+8, 24, '0'+(score & 0xf), 2, oam_off); } void refresh_sprites() { byte i; + // reset sprite index to 0 + oam_off = 0; // draw all actors - byte oam_id = 0; for (i=0; i