diff --git a/presets/nes/apu.h b/presets/nes/apu.h index 3dc38bfd..2d3110e2 100644 --- a/presets/nes/apu.h +++ b/presets/nes/apu.h @@ -40,9 +40,12 @@ APU.pulse[channel].len_period_high = (((period)>>8)&7);\ 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); +#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)\ APU.pulse[channel].ramp = 0x80 | (period<<4) | (up?8:0) | shift; diff --git a/presets/nes/shoot2.c b/presets/nes/shoot2.c index bcb22e7f..d106bdc1 100644 --- a/presets/nes/shoot2.c +++ b/presets/nes/shoot2.c @@ -626,9 +626,9 @@ void set_sounds() { byte enable = ENABLE_PULSE0|ENABLE_PULSE1|ENABLE_NOISE; // missile fire sound 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 { - APU_PULSE_CONTROL(0, DUTY_50, 1); + APU_PULSE_SET_VOLUME(0, DUTY_50, 0); } // enemy explosion sound if (player_exploding && player_exploding < 8) { @@ -643,6 +643,7 @@ void set_sounds() { byte y = a->y >> 8; APU_TRIANGLE_SUSTAIN(0x100 | y); enable |= ENABLE_TRIANGLE; + break; } } APU_ENABLE(enable); diff --git a/presets/nes/siegegame.c b/presets/nes/siegegame.c index bca8ced7..a4690371 100644 --- a/presets/nes/siegegame.c +++ b/presets/nes/siegegame.c @@ -26,7 +26,7 @@ byte getchar(byte x, byte y) { word addr = NTADR_A(x,y); byte rd; // wait for VBLANK to start - ppu_wait_frame(); + ppu_wait_nmi(); // set vram address and read byte vram_adr(addr); vram_read(&rd, 1); @@ -116,8 +116,8 @@ void init_game() { memset(players, 0, sizeof(players)); players[0].head_attr = '1'; players[1].head_attr = '2'; - players[0].tail_attr = '#'; - players[1].tail_attr = '*'; + players[0].tail_attr = 0x06; + players[1].tail_attr = 0x07; frames_per_move = START_SPEED; } @@ -167,7 +167,7 @@ byte ai_try_dir(Player* p, dir_t dir, byte shift) { dir &= 3; x = p->x + (DIR_X[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; return 1; } 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"}*/ const unsigned char Palette_Table[16]={ - 0x02, - 0x31,0x31,0x31,0x00, - 0x34,0x34,0x34,0x00, - 0x39,0x39,0x39,0x00, + 0x00, + 0x01,0x28,0x31,0x00, + 0x04,0x24,0x34,0x00, + 0x09,0x29,0x39,0x00, + 0x06,0x26,0x36 }; // put 8x8 grid of palette entries into the PPU @@ -266,7 +267,7 @@ void setup_attrib_table() { void setup_palette() { int i; // 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); } diff --git a/src/platform/nes.ts b/src/platform/nes.ts index 5370b1ac..44cae22f 100644 --- a/src/platform/nes.ts +++ b/src/platform/nes.ts @@ -9,12 +9,7 @@ import { SampleAudio } from "../audio"; declare var jsnes : any; const JSNES_PRESETS = [ - {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:'hello.c', name:'Text'}, + {id:'hello.c', name:'Hello World'}, {id:'scroll.c', name:'Scrolling'}, {id:'vrambuffer.c', name:'VRAM Buffer'}, {id:'sprites.c', name:'Sprites'}, @@ -32,9 +27,14 @@ const JSNES_PRESETS = [ {id:'shoot2.c', name:'Solarian Game'}, {id:'climber.c', name:'Platform Game'}, {id:'fami.c', name:'Famitone Demo'}, - {id:'musicdemo.asm', name:'Famitone Demo (ASM)'}, {id:'bankswitch.c', name:'Bank Switching'}, {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:'xyscroll.asm', name:'XY Split Scrolling (ASM)'}, ]; diff --git a/src/ui.ts b/src/ui.ts index b880f594..3c617547 100644 --- a/src/ui.ts +++ b/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) { // TODO: support spaces var filename = prompt("Create New File", "newfile" + platform.getDefaultExtension()); if (filename && filename.trim().length > 0) { - if (filename.indexOf(" ") >= 0) { - alert("No spaces, please."); - return; - } + if (!checkEnteredFilename(filename)) return; if (filename.indexOf(".") < 0) { filename += platform.getDefaultExtension(); } @@ -526,6 +531,7 @@ function _renameFile(e) { var newfn = prompt("Rename '" + fn + "' to?", fn); var data = current_project.getFile(wnd.getPath()); if (newfn && data && newfn.startsWith("local/")) { + if (!checkEnteredFilename(newfn)) return; store.removeItem(fn, () => { store.setItem(newfn, data, () => { alert("Renamed " + fn + " to " + newfn); @@ -1028,6 +1034,7 @@ function addFileToProject(type, ext, linefn) { if (wnd && wnd.insertText) { var filename = prompt("Add "+type+" File to Project", "filename"+ext); if (filename && filename.trim().length > 0) { + if (!checkEnteredFilename(filename)) return; var path = "local/" + filename; var newline = "\n" + linefn(filename) + "\n"; current_project.loadFiles([path], (err, result) => {