mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-01 05:41:31 +00:00
nes presets; check spaces in filenames
This commit is contained in:
parent
865103f36a
commit
d8016ff718
|
@ -40,9 +40,12 @@
|
||||||
APU.pulse[channel].len_period_high = (((period)>>8)&7);\
|
APU.pulse[channel].len_period_high = (((period)>>8)&7);\
|
||||||
APU.pulse[channel].control = (duty) | (vol) | (PULSE_CONSTVOL|PULSE_ENVLOOP);
|
APU.pulse[channel].control = (duty) | (vol) | (PULSE_CONSTVOL|PULSE_ENVLOOP);
|
||||||
|
|
||||||
#define APU_PULSE_CONTROL(channel,duty,decay)\
|
#define APU_PULSE_SET_DECAY(channel,duty,decay)\
|
||||||
APU.pulse[channel].control = (duty) | (decay);
|
APU.pulse[channel].control = (duty) | (decay);
|
||||||
|
|
||||||
|
#define APU_PULSE_SET_VOLUME(channel,duty,vol)\
|
||||||
|
APU.pulse[channel].control = (duty) | (vol) | (PULSE_CONSTVOL|PULSE_ENVLOOP);
|
||||||
|
|
||||||
#define APU_PULSE_SWEEP(channel,period,shift,up)\
|
#define APU_PULSE_SWEEP(channel,period,shift,up)\
|
||||||
APU.pulse[channel].ramp = 0x80 | (period<<4) | (up?8:0) | shift;
|
APU.pulse[channel].ramp = 0x80 | (period<<4) | (up?8:0) | shift;
|
||||||
|
|
||||||
|
|
|
@ -626,9 +626,9 @@ void set_sounds() {
|
||||||
byte enable = ENABLE_PULSE0|ENABLE_PULSE1|ENABLE_NOISE;
|
byte enable = ENABLE_PULSE0|ENABLE_PULSE1|ENABLE_NOISE;
|
||||||
// missile fire sound
|
// missile fire sound
|
||||||
if (missiles[PLYRMISSILE].ypos != YOFFSCREEN) {
|
if (missiles[PLYRMISSILE].ypos != YOFFSCREEN) {
|
||||||
APU_PULSE_SUSTAIN(0, missiles[PLYRMISSILE].ypos ^ 0xff, DUTY_50, 6);
|
APU_PULSE_SUSTAIN(0, 255-missiles[PLYRMISSILE].ypos, DUTY_50, 6);
|
||||||
} else {
|
} else {
|
||||||
APU_PULSE_CONTROL(0, DUTY_50, 1);
|
APU_PULSE_SET_VOLUME(0, DUTY_50, 0);
|
||||||
}
|
}
|
||||||
// enemy explosion sound
|
// enemy explosion sound
|
||||||
if (player_exploding && player_exploding < 8) {
|
if (player_exploding && player_exploding < 8) {
|
||||||
|
@ -643,6 +643,7 @@ void set_sounds() {
|
||||||
byte y = a->y >> 8;
|
byte y = a->y >> 8;
|
||||||
APU_TRIANGLE_SUSTAIN(0x100 | y);
|
APU_TRIANGLE_SUSTAIN(0x100 | y);
|
||||||
enable |= ENABLE_TRIANGLE;
|
enable |= ENABLE_TRIANGLE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
APU_ENABLE(enable);
|
APU_ENABLE(enable);
|
||||||
|
|
|
@ -26,7 +26,7 @@ byte getchar(byte x, byte y) {
|
||||||
word addr = NTADR_A(x,y);
|
word addr = NTADR_A(x,y);
|
||||||
byte rd;
|
byte rd;
|
||||||
// wait for VBLANK to start
|
// wait for VBLANK to start
|
||||||
ppu_wait_frame();
|
ppu_wait_nmi();
|
||||||
// set vram address and read byte
|
// set vram address and read byte
|
||||||
vram_adr(addr);
|
vram_adr(addr);
|
||||||
vram_read(&rd, 1);
|
vram_read(&rd, 1);
|
||||||
|
@ -116,8 +116,8 @@ void init_game() {
|
||||||
memset(players, 0, sizeof(players));
|
memset(players, 0, sizeof(players));
|
||||||
players[0].head_attr = '1';
|
players[0].head_attr = '1';
|
||||||
players[1].head_attr = '2';
|
players[1].head_attr = '2';
|
||||||
players[0].tail_attr = '#';
|
players[0].tail_attr = 0x06;
|
||||||
players[1].tail_attr = '*';
|
players[1].tail_attr = 0x07;
|
||||||
frames_per_move = START_SPEED;
|
frames_per_move = START_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ byte ai_try_dir(Player* p, dir_t dir, byte shift) {
|
||||||
dir &= 3;
|
dir &= 3;
|
||||||
x = p->x + (DIR_X[dir] << shift);
|
x = p->x + (DIR_X[dir] << shift);
|
||||||
y = p->y + (DIR_Y[dir] << shift);
|
y = p->y + (DIR_Y[dir] << shift);
|
||||||
if (x < COLS && y < ROWS && getchar(x, y) == ' ') {
|
if (x < COLS && y < ROWS && getchar(x, y) == 0) {
|
||||||
p->dir = dir;
|
p->dir = dir;
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -251,10 +251,11 @@ AE(1,1,1,1),AE(1,1,1,1),AE(1,1,1,1),AE(1,1,1,1), AE(1,1,1,1),AE(1,1,1,1),AE(1,1,
|
||||||
|
|
||||||
/*{pal:"nes",layout:"nes"}*/
|
/*{pal:"nes",layout:"nes"}*/
|
||||||
const unsigned char Palette_Table[16]={
|
const unsigned char Palette_Table[16]={
|
||||||
0x02,
|
0x00,
|
||||||
0x31,0x31,0x31,0x00,
|
0x01,0x28,0x31,0x00,
|
||||||
0x34,0x34,0x34,0x00,
|
0x04,0x24,0x34,0x00,
|
||||||
0x39,0x39,0x39,0x00,
|
0x09,0x29,0x39,0x00,
|
||||||
|
0x06,0x26,0x36
|
||||||
};
|
};
|
||||||
|
|
||||||
// put 8x8 grid of palette entries into the PPU
|
// put 8x8 grid of palette entries into the PPU
|
||||||
|
@ -266,7 +267,7 @@ void setup_attrib_table() {
|
||||||
void setup_palette() {
|
void setup_palette() {
|
||||||
int i;
|
int i;
|
||||||
// only set palette entries 0-15 (background only)
|
// only set palette entries 0-15 (background only)
|
||||||
for (i=0; i<15; i++)
|
for (i=0; i<16; i++)
|
||||||
pal_col(i, Palette_Table[i] ^ attract);
|
pal_col(i, Palette_Table[i] ^ attract);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,7 @@ import { SampleAudio } from "../audio";
|
||||||
declare var jsnes : any;
|
declare var jsnes : any;
|
||||||
|
|
||||||
const JSNES_PRESETS = [
|
const JSNES_PRESETS = [
|
||||||
{id:'ex0.asm', name:'Initialization (ASM)'},
|
{id:'hello.c', name:'Hello World'},
|
||||||
{id:'ex1.asm', name:'Hello World (ASM)'},
|
|
||||||
{id:'ex2.asm', name:'Scrolling Demo (ASM)'},
|
|
||||||
{id:'ex3.asm', name:'Sprite Demo (ASM)'},
|
|
||||||
{id:'ex4.asm', name:'Controller Demo (ASM)'},
|
|
||||||
{id:'hello.c', name:'Text'},
|
|
||||||
{id:'scroll.c', name:'Scrolling'},
|
{id:'scroll.c', name:'Scrolling'},
|
||||||
{id:'vrambuffer.c', name:'VRAM Buffer'},
|
{id:'vrambuffer.c', name:'VRAM Buffer'},
|
||||||
{id:'sprites.c', name:'Sprites'},
|
{id:'sprites.c', name:'Sprites'},
|
||||||
|
@ -32,9 +27,14 @@ const JSNES_PRESETS = [
|
||||||
{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:'fami.c', name:'Famitone Demo'},
|
{id:'fami.c', name:'Famitone Demo'},
|
||||||
{id:'musicdemo.asm', name:'Famitone Demo (ASM)'},
|
|
||||||
{id:'bankswitch.c', name:'Bank Switching'},
|
{id:'bankswitch.c', name:'Bank Switching'},
|
||||||
{id:'irq.c', name:'IRQ Scanline Counter'},
|
{id:'irq.c', name:'IRQ Scanline Counter'},
|
||||||
|
{id:'ex0.asm', name:'Initialization (ASM)'},
|
||||||
|
{id:'ex1.asm', name:'Hello World (ASM)'},
|
||||||
|
{id:'ex2.asm', name:'Scrolling Demo (ASM)'},
|
||||||
|
{id:'ex3.asm', name:'Sprite Demo (ASM)'},
|
||||||
|
{id:'ex4.asm', name:'Controller Demo (ASM)'},
|
||||||
|
{id:'musicdemo.asm', name:'Famitone Demo (ASM)'},
|
||||||
{id:'scrollrt.asm', name:'Line-by-line Scrolling (ASM)'},
|
{id:'scrollrt.asm', name:'Line-by-line Scrolling (ASM)'},
|
||||||
{id:'xyscroll.asm', name:'XY Split Scrolling (ASM)'},
|
{id:'xyscroll.asm', name:'XY Split Scrolling (ASM)'},
|
||||||
];
|
];
|
||||||
|
|
15
src/ui.ts
15
src/ui.ts
|
@ -286,14 +286,19 @@ function getSkeletonFile(fileid:string, callback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkEnteredFilename(fn : string) : boolean {
|
||||||
|
if (fn.indexOf(" ") >= 0) {
|
||||||
|
alert("No spaces in filenames, please.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function _createNewFile(e) {
|
function _createNewFile(e) {
|
||||||
// TODO: support spaces
|
// TODO: support spaces
|
||||||
var filename = prompt("Create New File", "newfile" + platform.getDefaultExtension());
|
var filename = prompt("Create New File", "newfile" + platform.getDefaultExtension());
|
||||||
if (filename && filename.trim().length > 0) {
|
if (filename && filename.trim().length > 0) {
|
||||||
if (filename.indexOf(" ") >= 0) {
|
if (!checkEnteredFilename(filename)) return;
|
||||||
alert("No spaces, please.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (filename.indexOf(".") < 0) {
|
if (filename.indexOf(".") < 0) {
|
||||||
filename += platform.getDefaultExtension();
|
filename += platform.getDefaultExtension();
|
||||||
}
|
}
|
||||||
|
@ -526,6 +531,7 @@ function _renameFile(e) {
|
||||||
var newfn = prompt("Rename '" + fn + "' to?", fn);
|
var newfn = prompt("Rename '" + fn + "' to?", fn);
|
||||||
var data = current_project.getFile(wnd.getPath());
|
var data = current_project.getFile(wnd.getPath());
|
||||||
if (newfn && data && newfn.startsWith("local/")) {
|
if (newfn && data && newfn.startsWith("local/")) {
|
||||||
|
if (!checkEnteredFilename(newfn)) return;
|
||||||
store.removeItem(fn, () => {
|
store.removeItem(fn, () => {
|
||||||
store.setItem(newfn, data, () => {
|
store.setItem(newfn, data, () => {
|
||||||
alert("Renamed " + fn + " to " + newfn);
|
alert("Renamed " + fn + " to " + newfn);
|
||||||
|
@ -1028,6 +1034,7 @@ function addFileToProject(type, ext, linefn) {
|
||||||
if (wnd && wnd.insertText) {
|
if (wnd && wnd.insertText) {
|
||||||
var filename = prompt("Add "+type+" File to Project", "filename"+ext);
|
var filename = prompt("Add "+type+" File to Project", "filename"+ext);
|
||||||
if (filename && filename.trim().length > 0) {
|
if (filename && filename.trim().length > 0) {
|
||||||
|
if (!checkEnteredFilename(filename)) return;
|
||||||
var path = "local/" + filename;
|
var path = "local/" + filename;
|
||||||
var newline = "\n" + linefn(filename) + "\n";
|
var newline = "\n" + linefn(filename) + "\n";
|
||||||
current_project.loadFiles([path], (err, result) => {
|
current_project.loadFiles([path], (err, result) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user