mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-01-10 16:29:48 +00:00
nes preset updates
This commit is contained in:
parent
9108bb5e1c
commit
4ddc183f74
@ -13,64 +13,30 @@
|
|||||||
|
|
||||||
///// METASPRITES
|
///// METASPRITES
|
||||||
|
|
||||||
|
#define TILE 0xd8
|
||||||
|
#define ATTR 0
|
||||||
|
|
||||||
// define a 2x2 metasprite
|
// define a 2x2 metasprite
|
||||||
#define DEF_METASPRITE_2x2(name,code,pal)\
|
const unsigned char metasprite[]={
|
||||||
const unsigned char name[]={\
|
0, 0, TILE+0, ATTR,
|
||||||
0, 0, (code)+0, pal, \
|
0, 8, TILE+1, ATTR,
|
||||||
0, 8, (code)+1, pal, \
|
8, 0, TILE+2, ATTR,
|
||||||
8, 0, (code)+2, pal, \
|
8, 8, TILE+3, ATTR,
|
||||||
8, 8, (code)+3, pal, \
|
|
||||||
128};
|
128};
|
||||||
|
|
||||||
// define a 2x2 metasprite, flipped horizontally
|
|
||||||
#define DEF_METASPRITE_2x2_FLIP(name,code,pal)\
|
|
||||||
const unsigned char name[]={\
|
|
||||||
8, 0, (code)+0, (pal)|OAM_FLIP_H, \
|
|
||||||
8, 8, (code)+1, (pal)|OAM_FLIP_H, \
|
|
||||||
0, 0, (code)+2, (pal)|OAM_FLIP_H, \
|
|
||||||
0, 8, (code)+3, (pal)|OAM_FLIP_H, \
|
|
||||||
128};
|
|
||||||
|
|
||||||
DEF_METASPRITE_2x2(playerRStand, 0xd8, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRRun1, 0xdc, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRRun2, 0xe0, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRRun3, 0xe4, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRJump, 0xe8, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRClimb, 0xec, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRSad, 0xf0, 0);
|
|
||||||
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLStand, 0xd8, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLRun1, 0xdc, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLRun2, 0xe0, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLRun3, 0xe4, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLJump, 0xe8, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLClimb, 0xec, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLSad, 0xf0, 0);
|
|
||||||
|
|
||||||
DEF_METASPRITE_2x2(personToSave, 0xba, 1);
|
|
||||||
|
|
||||||
const unsigned char* const playerRunSeq[16] = {
|
|
||||||
playerLRun1, playerLRun2, playerLRun3,
|
|
||||||
playerLRun1, playerLRun2, playerLRun3,
|
|
||||||
playerLRun1, playerLRun2,
|
|
||||||
playerRRun1, playerRRun2, playerRRun3,
|
|
||||||
playerRRun1, playerRRun2, playerRRun3,
|
|
||||||
playerRRun1, playerRRun2,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*{pal:"nes",layout:"nes"}*/
|
/*{pal:"nes",layout:"nes"}*/
|
||||||
const char PALETTE[32] = {
|
const char PALETTE[32] = {
|
||||||
0x03, // background color
|
0x03, // screen color
|
||||||
|
|
||||||
0x25,0x30,0x27,0x00, // ladders and pickups
|
0x11,0x30,0x27,0x0, // background palette 0
|
||||||
0x1C,0x20,0x2C,0x00, // floor blocks
|
0x1c,0x20,0x2c,0x0, // background palette 1
|
||||||
0x00,0x10,0x20,0x00,
|
0x00,0x10,0x20,0x0, // background palette 2
|
||||||
0x06,0x16,0x26,0x00,
|
0x06,0x16,0x26,0x0, // background palette 3
|
||||||
|
|
||||||
0x16,0x35,0x24,0x00, // enemy sprites
|
0x16,0x35,0x24,0x0, // sprite palette 0
|
||||||
0x00,0x37,0x25,0x00, // rescue person
|
0x00,0x37,0x25,0x0, // sprite palette 1
|
||||||
0x0D,0x2D,0x1A,0x00,
|
0x0d,0x2d,0x3a,0x0, // sprite palette 2
|
||||||
0x0D,0x27,0x2A // player sprites
|
0x0d,0x27,0x2a // sprite palette 3
|
||||||
};
|
};
|
||||||
|
|
||||||
// setup PPU and tables
|
// setup PPU and tables
|
||||||
@ -87,11 +53,11 @@ void setup_graphics() {
|
|||||||
#define NUM_ACTORS 24
|
#define NUM_ACTORS 24
|
||||||
|
|
||||||
// actor x/y positions
|
// actor x/y positions
|
||||||
char actor_x[NUM_ACTORS];
|
byte actor_x[NUM_ACTORS];
|
||||||
char actor_y[NUM_ACTORS];
|
byte actor_y[NUM_ACTORS];
|
||||||
// actor x/y deltas per frame
|
// actor x/y deltas per frame (signed)
|
||||||
char actor_dx[NUM_ACTORS];
|
sbyte actor_dx[NUM_ACTORS];
|
||||||
char actor_dy[NUM_ACTORS];
|
sbyte actor_dy[NUM_ACTORS];
|
||||||
|
|
||||||
// main program
|
// main program
|
||||||
void main() {
|
void main() {
|
||||||
@ -117,7 +83,7 @@ void main() {
|
|||||||
// wrap around actor array
|
// wrap around actor array
|
||||||
if (i >= NUM_ACTORS)
|
if (i >= NUM_ACTORS)
|
||||||
i -= NUM_ACTORS;
|
i -= NUM_ACTORS;
|
||||||
oam_id = oam_meta_spr(actor_x[i], actor_y[i], oam_id, playerRunSeq[i&15]);
|
oam_id = oam_meta_spr(actor_x[i], actor_y[i], oam_id, metasprite);
|
||||||
actor_x[i] += actor_dx[i];
|
actor_x[i] += actor_dx[i];
|
||||||
actor_y[i] += actor_dy[i];
|
actor_y[i] += actor_dy[i];
|
||||||
++i;
|
++i;
|
||||||
|
@ -1,30 +1,20 @@
|
|||||||
|
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
// link the pattern table into CHR ROM
|
// link the pattern table into CHR ROM
|
||||||
//#link "chr_generic.s"
|
//#link "chr_generic.s"
|
||||||
|
|
||||||
// function to write a string into the name table
|
|
||||||
// adr = start address in name table
|
|
||||||
// str = pointer to string
|
|
||||||
void put_str(unsigned int adr, const char *str) {
|
|
||||||
vram_adr(adr); // set PPU read/write address
|
|
||||||
vram_write(str, strlen(str)); // write bytes to PPU
|
|
||||||
}
|
|
||||||
|
|
||||||
// main function, run after console reset
|
// main function, run after console reset
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// set palette colors
|
// set palette colors
|
||||||
pal_col(0,0x02);
|
pal_col(0,0x02); // set screen to dark blue
|
||||||
pal_col(1,0x14);
|
pal_col(1,0x14); // pink
|
||||||
pal_col(2,0x20);
|
pal_col(2,0x20); // grey
|
||||||
pal_col(3,0x30);
|
pal_col(3,0x30); // white
|
||||||
|
|
||||||
// write text to name table
|
// write text to name table
|
||||||
put_str(NTADR_A(2,2),"HELLO, WORLD!");
|
vram_adr(NTADR_A(2,2)); // set address
|
||||||
put_str(NTADR_A(2,4),"Hello, World!");
|
vram_write("HELLO, WORLD!", 13); // write bytes to video RAM
|
||||||
put_str(NTADR_A(2,6),"\x14 \x15 \x16 \x17 \x18 \x19");
|
|
||||||
|
|
||||||
// enable PPU rendering (turn on screen)
|
// enable PPU rendering (turn on screen)
|
||||||
ppu_on_all();
|
ppu_on_all();
|
||||||
|
@ -44,7 +44,7 @@ void new_building() {
|
|||||||
void update_nametable() {
|
void update_nametable() {
|
||||||
register word addr;
|
register word addr;
|
||||||
// a buffer drawn to the nametable vertically
|
// a buffer drawn to the nametable vertically
|
||||||
char buf[PLAYROWS];
|
char buf[32];
|
||||||
// divide x_scroll by 8
|
// divide x_scroll by 8
|
||||||
// to get nametable X position
|
// to get nametable X position
|
||||||
byte x = ((x_scroll >> 3)+32) & 63;
|
byte x = ((x_scroll >> 3)+32) & 63;
|
||||||
@ -61,7 +61,7 @@ void update_nametable() {
|
|||||||
// draw rest of building
|
// draw rest of building
|
||||||
memset(buf+PLAYROWS-bldg_height, bldg_char, bldg_height);
|
memset(buf+PLAYROWS-bldg_height, bldg_char, bldg_height);
|
||||||
// draw vertical slice in name table
|
// draw vertical slice in name table
|
||||||
vrambuf_put(addr ^ 0xc000, buf, sizeof(buf));
|
vrambuf_put(addr ^ 0xc000, buf, PLAYROWS);
|
||||||
// every 4 columns, update attribute table
|
// every 4 columns, update attribute table
|
||||||
if ((x & 3) == 1) {
|
if ((x & 3) == 1) {
|
||||||
// compute attribute table address
|
// compute attribute table address
|
||||||
@ -90,16 +90,13 @@ void scroll_demo() {
|
|||||||
if ((x_scroll & 7) == 0) {
|
if ((x_scroll & 7) == 0) {
|
||||||
update_nametable();
|
update_nametable();
|
||||||
}
|
}
|
||||||
// manually force vram update
|
// ensure VRAM buffer is cleared
|
||||||
// flush and clear VRAM buffer after NMI
|
|
||||||
ppu_wait_nmi();
|
ppu_wait_nmi();
|
||||||
flush_vram_update(updbuf);
|
|
||||||
vrambuf_clear();
|
vrambuf_clear();
|
||||||
// reset ppu address
|
// split at x_scroll
|
||||||
vram_adr(0x0);
|
split(x_scroll, 0);
|
||||||
// set scroll register
|
// increment x_scroll
|
||||||
// and increment x_scroll
|
++x_scroll;
|
||||||
split(x_scroll++, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,13 +139,14 @@ void main(void) {
|
|||||||
|
|
||||||
// set sprite 0
|
// set sprite 0
|
||||||
oam_clear();
|
oam_clear();
|
||||||
oam_spr(1, 30, 0xa0, 1, 0);
|
oam_spr(1, 30, 0xa0, 0, 0);
|
||||||
|
|
||||||
// clip left 8 pixels of screen
|
// clip left 8 pixels of screen
|
||||||
ppu_mask(MASK_SPR|MASK_BG);
|
ppu_mask(MASK_SPR|MASK_BG);
|
||||||
|
|
||||||
// clear vram buffer
|
// clear vram buffer
|
||||||
vrambuf_clear();
|
vrambuf_clear();
|
||||||
|
set_vram_update(updbuf);
|
||||||
|
|
||||||
// enable PPU rendering (turn on screen)
|
// enable PPU rendering (turn on screen)
|
||||||
ppu_on_all();
|
ppu_on_all();
|
||||||
|
@ -87,11 +87,11 @@ void setup_graphics() {
|
|||||||
#define NUM_ACTORS 16
|
#define NUM_ACTORS 16
|
||||||
|
|
||||||
// actor x/y positions
|
// actor x/y positions
|
||||||
char actor_x[NUM_ACTORS];
|
byte actor_x[NUM_ACTORS];
|
||||||
char actor_y[NUM_ACTORS];
|
byte actor_y[NUM_ACTORS];
|
||||||
// actor x/y deltas per frame
|
// actor x/y deltas per frame (signed)
|
||||||
char actor_dx[NUM_ACTORS];
|
sbyte actor_dx[NUM_ACTORS];
|
||||||
char actor_dy[NUM_ACTORS];
|
sbyte actor_dy[NUM_ACTORS];
|
||||||
|
|
||||||
// main program
|
// main program
|
||||||
void main() {
|
void main() {
|
||||||
@ -130,7 +130,10 @@ void main() {
|
|||||||
}
|
}
|
||||||
// draw and move all actors
|
// draw and move all actors
|
||||||
for (i=0; i<NUM_ACTORS; i++) {
|
for (i=0; i<NUM_ACTORS; i++) {
|
||||||
oam_id = oam_meta_spr(actor_x[i], actor_y[i], oam_id, playerRunSeq[i&15]);
|
byte runseq = actor_x[i] & 7;
|
||||||
|
if (actor_dx[i] >= 0)
|
||||||
|
runseq += 8;
|
||||||
|
oam_id = oam_meta_spr(actor_x[i], actor_y[i], oam_id, playerRunSeq[runseq]);
|
||||||
actor_x[i] += actor_dx[i];
|
actor_x[i] += actor_dx[i];
|
||||||
actor_y[i] += actor_dy[i];
|
actor_y[i] += actor_dy[i];
|
||||||
}
|
}
|
||||||
|
@ -13,64 +13,30 @@
|
|||||||
|
|
||||||
///// METASPRITES
|
///// METASPRITES
|
||||||
|
|
||||||
|
#define TILE 0xd8
|
||||||
|
#define ATTR 0
|
||||||
|
|
||||||
// define a 2x2 metasprite
|
// define a 2x2 metasprite
|
||||||
#define DEF_METASPRITE_2x2(name,code,pal)\
|
const unsigned char metasprite[]={
|
||||||
const unsigned char name[]={\
|
0, 0, TILE+0, ATTR,
|
||||||
0, 0, (code)+0, pal, \
|
0, 8, TILE+1, ATTR,
|
||||||
0, 8, (code)+1, pal, \
|
8, 0, TILE+2, ATTR,
|
||||||
8, 0, (code)+2, pal, \
|
8, 8, TILE+3, ATTR,
|
||||||
8, 8, (code)+3, pal, \
|
|
||||||
128};
|
128};
|
||||||
|
|
||||||
// define a 2x2 metasprite, flipped horizontally
|
|
||||||
#define DEF_METASPRITE_2x2_FLIP(name,code,pal)\
|
|
||||||
const unsigned char name[]={\
|
|
||||||
8, 0, (code)+0, (pal)|OAM_FLIP_H, \
|
|
||||||
8, 8, (code)+1, (pal)|OAM_FLIP_H, \
|
|
||||||
0, 0, (code)+2, (pal)|OAM_FLIP_H, \
|
|
||||||
0, 8, (code)+3, (pal)|OAM_FLIP_H, \
|
|
||||||
128};
|
|
||||||
|
|
||||||
DEF_METASPRITE_2x2(playerRStand, 0xd8, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRRun1, 0xdc, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRRun2, 0xe0, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRRun3, 0xe4, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRJump, 0xe8, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRClimb, 0xec, 0);
|
|
||||||
DEF_METASPRITE_2x2(playerRSad, 0xf0, 0);
|
|
||||||
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLStand, 0xd8, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLRun1, 0xdc, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLRun2, 0xe0, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLRun3, 0xe4, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLJump, 0xe8, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLClimb, 0xec, 0);
|
|
||||||
DEF_METASPRITE_2x2_FLIP(playerLSad, 0xf0, 0);
|
|
||||||
|
|
||||||
DEF_METASPRITE_2x2(personToSave, 0xba, 1);
|
|
||||||
|
|
||||||
const unsigned char* const playerRunSeq[16] = {
|
|
||||||
playerLRun1, playerLRun2, playerLRun3,
|
|
||||||
playerLRun1, playerLRun2, playerLRun3,
|
|
||||||
playerLRun1, playerLRun2,
|
|
||||||
playerRRun1, playerRRun2, playerRRun3,
|
|
||||||
playerRRun1, playerRRun2, playerRRun3,
|
|
||||||
playerRRun1, playerRRun2,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*{pal:"nes",layout:"nes"}*/
|
/*{pal:"nes",layout:"nes"}*/
|
||||||
const char PALETTE[32] = {
|
const char PALETTE[32] = {
|
||||||
0x03, // background color
|
0x03, // screen color
|
||||||
|
|
||||||
0x25,0x30,0x27,0x00, // ladders and pickups
|
0x11,0x30,0x27,0x0, // background palette 0
|
||||||
0x1C,0x20,0x2C,0x00, // floor blocks
|
0x1c,0x20,0x2c,0x0, // background palette 1
|
||||||
0x00,0x10,0x20,0x00,
|
0x00,0x10,0x20,0x0, // background palette 2
|
||||||
0x06,0x16,0x26,0x00,
|
0x06,0x16,0x26,0x0, // background palette 3
|
||||||
|
|
||||||
0x16,0x35,0x24,0x00, // enemy sprites
|
0x16,0x35,0x24,0x0, // sprite palette 0
|
||||||
0x00,0x37,0x25,0x00, // rescue person
|
0x00,0x37,0x25,0x0, // sprite palette 1
|
||||||
0x0D,0x2D,0x1A,0x00,
|
0x0d,0x2d,0x3a,0x0, // sprite palette 2
|
||||||
0x0D,0x27,0x2A // player sprites
|
0x0d,0x27,0x2a // sprite palette 3
|
||||||
};
|
};
|
||||||
|
|
||||||
// setup PPU and tables
|
// setup PPU and tables
|
||||||
@ -87,11 +53,11 @@ void setup_graphics() {
|
|||||||
#define NUM_ACTORS 16
|
#define NUM_ACTORS 16
|
||||||
|
|
||||||
// actor x/y positions
|
// actor x/y positions
|
||||||
char actor_x[NUM_ACTORS];
|
byte actor_x[NUM_ACTORS];
|
||||||
char actor_y[NUM_ACTORS];
|
byte actor_y[NUM_ACTORS];
|
||||||
// actor x/y deltas per frame
|
// actor x/y deltas per frame (signed)
|
||||||
char actor_dx[NUM_ACTORS];
|
sbyte actor_dx[NUM_ACTORS];
|
||||||
char actor_dy[NUM_ACTORS];
|
sbyte actor_dy[NUM_ACTORS];
|
||||||
|
|
||||||
// main program
|
// main program
|
||||||
void main() {
|
void main() {
|
||||||
@ -112,8 +78,7 @@ void main() {
|
|||||||
oam_id = 0;
|
oam_id = 0;
|
||||||
// draw and move all actors
|
// draw and move all actors
|
||||||
for (i=0; i<NUM_ACTORS; i++) {
|
for (i=0; i<NUM_ACTORS; i++) {
|
||||||
oam_id = oam_meta_spr(actor_x[i], actor_y[i], oam_id,
|
oam_id = oam_meta_spr(actor_x[i], actor_y[i], oam_id, metasprite);
|
||||||
playerRunSeq[i&15]);
|
|
||||||
actor_x[i] += actor_dx[i];
|
actor_x[i] += actor_dx[i];
|
||||||
actor_y[i] += actor_dy[i];
|
actor_y[i] += actor_dy[i];
|
||||||
}
|
}
|
||||||
|
@ -87,11 +87,11 @@ void setup_graphics() {
|
|||||||
#define NUM_ACTORS 16
|
#define NUM_ACTORS 16
|
||||||
|
|
||||||
// actor x/y positions
|
// actor x/y positions
|
||||||
char actor_x[NUM_ACTORS];
|
byte actor_x[NUM_ACTORS];
|
||||||
char actor_y[NUM_ACTORS];
|
byte actor_y[NUM_ACTORS];
|
||||||
// actor x/y deltas per frame
|
// actor x/y deltas per frame (signed)
|
||||||
char actor_dx[NUM_ACTORS];
|
sbyte actor_dx[NUM_ACTORS];
|
||||||
char actor_dy[NUM_ACTORS];
|
sbyte actor_dy[NUM_ACTORS];
|
||||||
|
|
||||||
// main program
|
// main program
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -22,22 +22,23 @@ void scroll_demo() {
|
|||||||
while (1) {
|
while (1) {
|
||||||
// wait for next frame
|
// wait for next frame
|
||||||
ppu_wait_frame();
|
ppu_wait_frame();
|
||||||
// set scroll register
|
|
||||||
scroll(x, y);
|
|
||||||
// update y variable
|
// update y variable
|
||||||
y += dy;
|
y += dy;
|
||||||
// change direction when hitting either edge of scroll area
|
// change direction when hitting either edge of scroll area
|
||||||
if (y >= 479) dy = -1;
|
if (y >= 479) dy = -1;
|
||||||
if (y == 0) dy = 1;
|
if (y == 0) dy = 1;
|
||||||
|
// set scroll register
|
||||||
|
scroll(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// main function, run after console reset
|
// main function, run after console reset
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// set palette colors
|
// set palette colors
|
||||||
pal_col(1,0x04);
|
pal_col(0,0x02); // set screen to dark blue
|
||||||
pal_col(2,0x20);
|
pal_col(1,0x14); // pink
|
||||||
pal_col(3,0x30);
|
pal_col(2,0x20); // grey
|
||||||
|
pal_col(3,0x30); // white
|
||||||
|
|
||||||
// write text to name table
|
// write text to name table
|
||||||
put_str(NTADR_A(2,0), "Nametable A, Line 0");
|
put_str(NTADR_A(2,0), "Nametable A, Line 0");
|
||||||
|
@ -5,25 +5,22 @@
|
|||||||
// include NESLIB header
|
// include NESLIB header
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
|
|
||||||
// include CC65 NES Header (PPU)
|
|
||||||
#include <nes.h>
|
|
||||||
|
|
||||||
// link the pattern table into CHR ROM
|
// link the pattern table into CHR ROM
|
||||||
//#link "chr_generic.s"
|
//#link "chr_generic.s"
|
||||||
|
|
||||||
/*{pal:"nes",layout:"nes"}*/
|
/*{pal:"nes",layout:"nes"}*/
|
||||||
const char PALETTE[32] = {
|
const char PALETTE[32] = {
|
||||||
0x03, // background color
|
0x03, // screen color
|
||||||
|
|
||||||
0x11,0x30,0x27,0x0, // ladders and pickups
|
0x11,0x30,0x27,0x0, // background palette 0
|
||||||
0x1c,0x20,0x2c,0x0, // floor blocks
|
0x1c,0x20,0x2c,0x0, // background palette 1
|
||||||
0x00,0x10,0x20,0x0,
|
0x00,0x10,0x20,0x0, // background palette 2
|
||||||
0x06,0x16,0x26,0x0,
|
0x06,0x16,0x26,0x0, // background palette 3
|
||||||
|
|
||||||
0x16,0x35,0x24,0x0, // enemy sprites
|
0x16,0x35,0x24,0x0, // sprite palette 0
|
||||||
0x00,0x37,0x25,0x0, // rescue person
|
0x00,0x37,0x25,0x0, // sprite palette 1
|
||||||
0x0d,0x2d,0x3a,0x0,
|
0x0d,0x2d,0x3a,0x0, // sprite palette 2
|
||||||
0x0d,0x27,0x2a // player sprites
|
0x0d,0x27,0x2a // sprite palette 3
|
||||||
};
|
};
|
||||||
|
|
||||||
// setup PPU and tables
|
// setup PPU and tables
|
||||||
@ -40,11 +37,11 @@ void setup_graphics() {
|
|||||||
#define NUM_ACTORS 64
|
#define NUM_ACTORS 64
|
||||||
|
|
||||||
// actor x/y positions
|
// actor x/y positions
|
||||||
char actor_x[NUM_ACTORS];
|
byte actor_x[NUM_ACTORS];
|
||||||
char actor_y[NUM_ACTORS];
|
byte actor_y[NUM_ACTORS];
|
||||||
// actor x/y deltas per frame
|
// actor x/y deltas per frame (signed)
|
||||||
char actor_dx[NUM_ACTORS];
|
sbyte actor_dx[NUM_ACTORS];
|
||||||
char actor_dy[NUM_ACTORS];
|
sbyte actor_dy[NUM_ACTORS];
|
||||||
|
|
||||||
// main program
|
// main program
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -19,14 +19,13 @@ void put_str(unsigned int adr, const char *str) {
|
|||||||
// function to scroll window up and down until end
|
// function to scroll window up and down until end
|
||||||
void scroll_demo() {
|
void scroll_demo() {
|
||||||
int x = 0; // x scroll position
|
int x = 0; // x scroll position
|
||||||
int y = 0; // y scroll position
|
int dx = 1; // x scroll direction
|
||||||
int dx = 1; // y scroll direction
|
|
||||||
// infinite loop
|
// infinite loop
|
||||||
while (1) {
|
while (1) {
|
||||||
// set scroll register
|
// set scroll register
|
||||||
// waits for NMI, which means no frame-skip?
|
// waits for NMI, which means no frame-skip?
|
||||||
split(x, 0);
|
split(x, 0);
|
||||||
// update y variable
|
// update x variable
|
||||||
x += dx;
|
x += dx;
|
||||||
// change direction when hitting either edge of scroll area
|
// change direction when hitting either edge of scroll area
|
||||||
if (x >= 479) dx = -1;
|
if (x >= 479) dx = -1;
|
||||||
@ -64,7 +63,7 @@ void main(void) {
|
|||||||
|
|
||||||
// set sprite 0
|
// set sprite 0
|
||||||
oam_clear();
|
oam_clear();
|
||||||
oam_spr(1, 30, 0xa0, 1, 0);
|
oam_spr(1, 30, 0xa0, 0, 0);
|
||||||
|
|
||||||
// enable PPU rendering (turn on screen)
|
// enable PPU rendering (turn on screen)
|
||||||
ppu_on_all();
|
ppu_on_all();
|
||||||
|
@ -24,26 +24,25 @@ void scroll_demo() {
|
|||||||
// write message to string array
|
// write message to string array
|
||||||
sprintf(str, "%6x %6d", y, y);
|
sprintf(str, "%6x %6d", y, y);
|
||||||
// write string array into VRAM buffer
|
// write string array into VRAM buffer
|
||||||
|
// if buffer is full this will wait for next frame
|
||||||
vrambuf_put(NTADR_A(2,y%30), str, 32);
|
vrambuf_put(NTADR_A(2,y%30), str, 32);
|
||||||
// wait for next frame
|
|
||||||
// and flush VRAM buffer
|
|
||||||
vrambuf_flush();
|
|
||||||
// set scroll (shadow) registers
|
|
||||||
scroll(x, y);
|
|
||||||
// update y variable
|
// update y variable
|
||||||
y += dy;
|
y += dy;
|
||||||
// change direction when hitting either edge of scroll area
|
// change direction when hitting either edge of scroll area
|
||||||
if (y >= 479) dy = -1;
|
if (y >= 479) dy = -1;
|
||||||
if (y == 0) dy = 1;
|
if (y == 0) dy = 1;
|
||||||
|
// set scroll (shadow) registers
|
||||||
|
scroll(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// main function, run after console reset
|
// main function, run after console reset
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// set palette colors
|
// set palette colors
|
||||||
pal_col(1,0x04);
|
pal_col(0,0x02); // set screen to dark blue
|
||||||
pal_col(2,0x20);
|
pal_col(1,0x14); // pink
|
||||||
pal_col(3,0x30);
|
pal_col(2,0x20); // grey
|
||||||
|
pal_col(3,0x30); // white
|
||||||
|
|
||||||
// clear vram buffer
|
// clear vram buffer
|
||||||
vrambuf_clear();
|
vrambuf_clear();
|
||||||
|
@ -21,7 +21,6 @@ const JSNES_PRESETS = [
|
|||||||
{id:'metasprites.c', name:'Metasprites'},
|
{id:'metasprites.c', name:'Metasprites'},
|
||||||
{id:'flicker.c', name:'Flickering Sprites'},
|
{id:'flicker.c', name:'Flickering Sprites'},
|
||||||
{id:'metacursor.c', name:'Controllers'},
|
{id:'metacursor.c', name:'Controllers'},
|
||||||
{id:'metatrigger.c', name:'Trigger Mode + Vbright'},
|
|
||||||
{id:'rletitle.c', name:'Title Screen RLE'},
|
{id:'rletitle.c', name:'Title Screen RLE'},
|
||||||
{id:'statusbar.c', name:'Split Status Bar'},
|
{id:'statusbar.c', name:'Split Status Bar'},
|
||||||
{id:'horizmask.c', name:'Offscreen Scrolling'},
|
{id:'horizmask.c', name:'Offscreen Scrolling'},
|
||||||
@ -114,6 +113,7 @@ class JSNESPlatform extends Base6502Platform implements Platform {
|
|||||||
},
|
},
|
||||||
//TODO: onBatteryRamWrite
|
//TODO: onBatteryRamWrite
|
||||||
});
|
});
|
||||||
|
//this.nes.ppu.showSpr0Hit = true;
|
||||||
//this.nes.ppu.clipToTvSize = false;
|
//this.nes.ppu.clipToTvSize = false;
|
||||||
this.nes.stop = () => {
|
this.nes.stop = () => {
|
||||||
// TODO: trigger breakpoint
|
// TODO: trigger breakpoint
|
||||||
|
Loading…
x
Reference in New Issue
Block a user