diff --git a/presets/nes/musicdemo.asm b/presets/nes/musicdemo.asm index 979fc2b8..e94271a0 100644 --- a/presets/nes/musicdemo.asm +++ b/presets/nes/musicdemo.asm @@ -3,16 +3,18 @@ ;;;;; VARIABLES - seg.u RAM - org $0 + seg.u RAM + org $0 -FT_BASE_ADR = $0300 ;page in the RAM used for FT2 variables, should be $xx00 -FT_TEMP = $00 ;3 bytes in zeropage used by the library as a scratchpad -FT_DPCM_OFF = $c000 ;$c000..$ffc0, 64-byte steps +; Famitracker constants +FT_TEMP ds 3 ;3 bytes in zeropage used by the library as a scratchpad + +FT_BASE_ADR = $0300 ;page in the RAM used for FT2 variables, should be $xx00 +FT_DPCM_OFF = DMCSamples ;$c000..$ffc0, 64-byte steps FT_SFX_STREAMS = 4 ;number of sound effects played at once, 1..4 -;FT_DPCM_ENABLE = 1 ;undefine to exclude all DMC code +FT_DPCM_ENABLE = 1 ;undefine to exclude all DMC code ;FT_SFX_ENABLE = 1 ;undefine to exclude all sound effects code -;FT_THREAD = 1 ;undefine if you are calling sound effects from the same thread as the sound update call +;FT_THREAD = 1 ;undefine if you are calling sound effects from the same thread as the sound update call FT_PAL_SUPPORT = 1 ;undefine to exclude PAL support FT_NTSC_SUPPORT = 1 ;undefine to exclude NTSC support @@ -28,15 +30,22 @@ Start: jsr ClearRAM ; clear RAM jsr WaitSync ; wait for VSYNC (and PPU warmup) - lda #$3f ; $3F -> A register - ldy #$00 ; $00 -> Y register - sta PPU_ADDR ; write high byte first - sty PPU_ADDR ; $3F00 -> PPU address - lda #$1c ; $1C = light blue color - sta PPU_DATA ; $1C -> PPU data + PPU_SETADDR $3f00 ; background color + PPU_SETVALUE $01 + PPU_SETADDR $3f01 ; first palette color + PPU_SETVALUE $38 + PPU_SETADDR $0000 ; first byte of tileset + PPU_SETVALUE $18 ; dash + PPU_SETVALUE $18 ; dash + PPU_SETVALUE $18 ; dash + PPU_SETVALUE $18 ; dash + PPU_SETVALUE $18 ; dash + PPU_SETVALUE $18 ; dash + PPU_SETVALUE $18 ; dash + PPU_SETVALUE $18 ; dash lda #CTRL_NMI sta PPU_CTRL ; enable NMI - lda #MASK_COLOR + lda #MASK_BG sta PPU_MASK ; enable rendering ldx # - set 16-bit PPU address + + MAC PPU_SETADDR + lda #>{1} + ldy #<{1} + sta PPU_ADDR + sty PPU_ADDR + ENDM + +;;;;; PPU_SETVALUE - feed 8-bit value to PPU + + MAC PPU_SETVALUE + lda #{1} + sta PPU_DATA + ENDM + +;;;;; SAVE_REGS - save flags/A/X/Y registers + + MAC SAVE_REGS + php + pha + txa + pha + tya + pha + ENDM + +;;;;; SAVE_REGS - restore Y/X/A/flags registers + + MAC RESTORE_REGS + pla + tay + pla + tax + pla + plp + ENDM diff --git a/src/platform/nes.js b/src/platform/nes.js index 733e5dac..e2ee983e 100644 --- a/src/platform/nes.js +++ b/src/platform/nes.js @@ -226,7 +226,8 @@ var JSNESPlatform = function(mainElement) { s += (status & 0x80) ? "VBLANK " : "- "; s += (status & 0x40) ? "SPRITE0HIT " : "- "; s += "\n"; - s += "BgColor " + ['black','blue','green','red'][ppu.f_color] + "\n"; + if (ppu.f_color) + s += " Tint " + ((ppu.f_color&1)?"RED ":"") + ((ppu.f_color&2)?"BLUE ":"") + ((ppu.f_color&4)?"GREEN ":"") + "\n"; if (ppu.f_spVisibility) { s += "SprSize " + (ppu.f_spriteSize ? "8x16" : "8x8") + "\n"; s += "SprBase $" + (ppu.f_spPatternTable ? "1000" : "0000") + "\n";