mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-02 12:41:30 +00:00
minor tweaks
This commit is contained in:
parent
fe89e577ac
commit
517605d7da
|
@ -1,9 +1,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Setting the attribute table, which controls palette selection
|
Setting the attribute table, which controls palette selection
|
||||||
for the nametable. We copy it from an array in ROM to video RAM.
|
for the nametable. We copy it from an array in ROM to video RAM.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "neslib.h"
|
#include "neslib.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -11,16 +9,6 @@ for the nametable. We copy it from an array in ROM to video RAM.
|
||||||
// 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"}*/
|
|
||||||
const char PALETTE[16] = {
|
|
||||||
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 // background palette 3
|
|
||||||
};
|
|
||||||
|
|
||||||
// attribute table in PRG ROM
|
// attribute table in PRG ROM
|
||||||
const char ATTRIBUTE_TABLE[0x40] = {
|
const char ATTRIBUTE_TABLE[0x40] = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // rows 0-3
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // rows 0-3
|
||||||
|
@ -33,6 +21,16 @@ const char ATTRIBUTE_TABLE[0x40] = {
|
||||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f // rows 28-29
|
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f // rows 28-29
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*{pal:"nes",layout:"nes"}*/
|
||||||
|
const char PALETTE[16] = {
|
||||||
|
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 // background palette 3
|
||||||
|
};
|
||||||
|
|
||||||
// main function, run after console reset
|
// main function, run after console reset
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// set background palette colors
|
// set background palette colors
|
||||||
|
|
|
@ -59,7 +59,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[32];
|
char buf[PLAYROWS];
|
||||||
// divide x_scroll by 8
|
// divide x_scroll by 8
|
||||||
// to get nametable X position
|
// to get nametable X position
|
||||||
byte x = (x_scroll/8 + 32) & 63;
|
byte x = (x_scroll/8 + 32) & 63;
|
||||||
|
@ -68,9 +68,9 @@ void update_nametable() {
|
||||||
else
|
else
|
||||||
addr = NTADR_B(x&31, 4);
|
addr = NTADR_B(x&31, 4);
|
||||||
// clear empty space
|
// clear empty space
|
||||||
memset(buf, 0, PLAYROWS-bldg_height);
|
memset(buf, 0, sizeof(buf));
|
||||||
// draw a random star
|
// draw a random star
|
||||||
buf[rand8() & 31] = '.';
|
buf[rand8() & 15] = '.';
|
||||||
// draw roof
|
// draw roof
|
||||||
buf[PLAYROWS-bldg_height-1] = bldg_char & 3;
|
buf[PLAYROWS-bldg_height-1] = bldg_char & 3;
|
||||||
// draw rest of building
|
// draw rest of building
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A character-based surround-the-opponent game.
|
A character-based surround-the-opponent game.
|
||||||
Reads from nametable RAM to determine collisions, and also
|
Reads from nametable RAM to determine collisions, and also
|
||||||
to help the AI avoid walls.
|
to help the AI avoid walls.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <nes.h>
|
#include <nes.h>
|
||||||
|
@ -30,10 +28,11 @@ to help the AI avoid walls.
|
||||||
byte getchar(byte x, byte y) {
|
byte getchar(byte x, byte y) {
|
||||||
// compute VRAM read address
|
// compute VRAM read address
|
||||||
word addr = NTADR_A(x,y);
|
word addr = NTADR_A(x,y);
|
||||||
|
// result goes into rd
|
||||||
byte rd;
|
byte rd;
|
||||||
// wait for VBLANK to start
|
// wait for VBLANK to start
|
||||||
ppu_wait_nmi();
|
ppu_wait_nmi();
|
||||||
// set vram address and read byte
|
// set vram address and read byte into rd
|
||||||
vram_adr(addr);
|
vram_adr(addr);
|
||||||
vram_read(&rd, 1);
|
vram_read(&rd, 1);
|
||||||
// scroll registers are corrupt
|
// scroll registers are corrupt
|
||||||
|
|
|
@ -17,15 +17,15 @@ const JSNES_PRESETS = [
|
||||||
{id:'flicker.c', name:'Flickering Sprites'},
|
{id:'flicker.c', name:'Flickering Sprites'},
|
||||||
{id:'metacursor.c', name:'Controllers'},
|
{id:'metacursor.c', name:'Controllers'},
|
||||||
{id:'vrambuffer.c', name:'VRAM Buffer'},
|
{id:'vrambuffer.c', name:'VRAM Buffer'},
|
||||||
{id:'tint.c', name:'Color Emphasis'},
|
|
||||||
{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'},
|
||||||
{id:'monobitmap.c', name:'Monochrome Bitmap'},
|
{id:'siegegame.c', name:'Siege Game'},
|
||||||
|
{id:'tint.c', name:'Color Emphasis'},
|
||||||
|
{id:'rletitle.c', name:'Title Screen RLE'},
|
||||||
{id:'aputest.c', name:'Sound Tester'},
|
{id:'aputest.c', name:'Sound Tester'},
|
||||||
{id:'music.c', name:'Music Player'},
|
{id:'music.c', name:'Music Player'},
|
||||||
|
{id:'monobitmap.c', name:'Monochrome Bitmap'},
|
||||||
{id:'fami.c', name:'Famitone Demo'},
|
{id:'fami.c', name:'Famitone Demo'},
|
||||||
{id:'siegegame.c', name:'Siege Game'},
|
|
||||||
{id:'shoot2.c', name:'Solarian Game'},
|
{id:'shoot2.c', name:'Solarian Game'},
|
||||||
{id:'climber.c', name:'Platform Game'},
|
{id:'climber.c', name:'Platform Game'},
|
||||||
{id:'bankswitch.c', name:'Bank Switching'},
|
{id:'bankswitch.c', name:'Bank Switching'},
|
||||||
|
@ -114,7 +114,7 @@ class JSNESPlatform extends Base6502Platform implements Platform {
|
||||||
if (this.frameindex < 10)
|
if (this.frameindex < 10)
|
||||||
this.audio.feedSample(0, 1); // avoid popping at powerup
|
this.audio.feedSample(0, 1); // avoid popping at powerup
|
||||||
else
|
else
|
||||||
this.audio.feedSample(left+right, 1);
|
this.audio.feedSample((left+right)*0.5, 1);
|
||||||
},
|
},
|
||||||
onStatusUpdate: function(s) {
|
onStatusUpdate: function(s) {
|
||||||
console.log(s);
|
console.log(s);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user