updated climber to use oam_meta_spr_pal(); updated neslib
This commit is contained in:
parent
d2b19df9c9
commit
5ded34e668
16
index.html
16
index.html
|
@ -51,11 +51,14 @@ body {
|
|||
<li class="dropdown dropdown-submenu">
|
||||
<a tabindex="-1" href="#">Sync</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="/login.html">Login to GitHub...</a></li>
|
||||
<hr>
|
||||
<li><a class="dropdown-item" href="#" id="item_github_import">Import Project from GitHub...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_github_connect">Publish Project on GitHub...</a></li>
|
||||
<hr>
|
||||
<li><a class="dropdown-item" href="#" id="item_github_connect">Pull Latest from Repository</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_github_connect">Push Changes to Repository...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_github_push">Push Changes to Repository...</a></li>
|
||||
<hr>
|
||||
<li><a class="dropdown-item" href="#" id="item_github_pull">Pull Latest from Repository</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown dropdown-submenu">
|
||||
|
@ -172,10 +175,14 @@ body {
|
|||
<img src="images/book_a2600.png"/>
|
||||
<b>Making Games For The Atari 2600</b>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item dropdown-link" target="_book_arcade" href="https://www.amazon.com/gp/product/1545484759/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1545484759&linkCode=as2&tag=pzp-20&linkId=b27709c022d2ebe639e90316d9f4fd5b">
|
||||
<img src="images/book_arcade.png"/>
|
||||
<b>Making 8-bit Arcade Games in C</b>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item dropdown-link" target="_book_verilog" href="https://www.amazon.com/gp/product/1728619440/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1728619440&linkCode=as2&tag=pzp-20">
|
||||
<img src="images/book_verilog.png"/>
|
||||
<b>Designing Video Game Hardware in Verilog</b>
|
||||
|
@ -399,10 +406,9 @@ $( ".dropdown-submenu" ).click(function(event) {
|
|||
</script>
|
||||
|
||||
<!-- firebase libs -->
|
||||
<script defer src="https://www.gstatic.com/firebasejs/5.10.1/firebase.js"></script>
|
||||
<script defer src="https://www.gstatic.com/firebasejs/5.11.1/firebase-app.js"></script>
|
||||
<script defer src="https://www.gstatic.com/firebasejs/5.11.1/firebase-auth.js"></script>
|
||||
<script defer src="config.js"></script>
|
||||
<script defer src="https://cdn.firebase.com/libs/firebaseui/3.6.0/firebaseui.js"></script>
|
||||
<link defer type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/3.6.0/firebaseui.css" />
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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<MAX_ACTORS; i++)
|
||||
oam_id = draw_actor(oam_id, i);
|
||||
draw_actor(i);
|
||||
// draw scoreboard
|
||||
oam_id = draw_scoreboard(oam_id);
|
||||
draw_scoreboard();
|
||||
// hide rest of actors
|
||||
oam_hide_rest(oam_id);
|
||||
oam_hide_rest(oam_off);
|
||||
}
|
||||
|
||||
byte is_ladder_close(byte actor_x, byte ladder_pos) {
|
||||
|
@ -696,6 +692,7 @@ void play_scene() {
|
|||
memset(actors, 0, sizeof(actors));
|
||||
actors[0].state = STANDING;
|
||||
actors[0].name = ACTOR_PLAYER;
|
||||
actors[0].pal = 3;
|
||||
actors[0].x = 64;
|
||||
actors[0].floor = 0;
|
||||
actors[0].yy = get_floor_yy(0);
|
||||
|
|
|
@ -328,5 +328,10 @@ typedef struct OAMSprite {
|
|||
|
||||
#define OAMBUF ((OAMSprite*) 0x200)
|
||||
|
||||
// OAM offset for spr_pal and spr_clip
|
||||
|
||||
extern byte oam_off;
|
||||
#pragma zpsym ("oam_off")
|
||||
|
||||
#endif /* neslib.h */
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ extern const byte climbr_title_rle[];
|
|||
|
||||
// link title screen palette and RLE nametable
|
||||
//#link "climbr_title.s"
|
||||
|
||||
void fade_in() {
|
||||
byte vb;
|
||||
for (vb=0; vb<=4; vb++) {
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue