From e9d207fa840050257bdeb5f72159194ade8e52ca Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Wed, 20 Feb 2019 19:38:30 -0500 Subject: [PATCH] nes: update presets, famitone; show asm listing files --- doc/notes.txt | 6 +- presets/nes/demosounds.s | 70 ++ presets/nes/fami.c | 55 ++ presets/nes/famitone2.s | 1322 +++++++++++++++++++++++++++++ presets/nes/jroatch.c | 3 +- presets/nes/music_aftertherain.s | 1036 ++++++++++++++++++++++ presets/nes/music_dangerstreets.s | 869 +++++++++++++++++++ presets/nes/musicdemo.asm | 8 +- presets/nes/neslib.h | 5 + presets/nes/scrollrt.asm | 9 +- src/platform/nes.ts | 1 + src/project.ts | 6 +- src/ui.ts | 2 +- src/views.ts | 3 + src/worker/workermain.ts | 15 +- 15 files changed, 3387 insertions(+), 23 deletions(-) create mode 100644 presets/nes/demosounds.s create mode 100644 presets/nes/fami.c create mode 100644 presets/nes/famitone2.s create mode 100644 presets/nes/music_aftertherain.s create mode 100644 presets/nes/music_dangerstreets.s diff --git a/doc/notes.txt b/doc/notes.txt index aa004546..8511be5e 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -90,12 +90,12 @@ TODO: - HTTPS warning - Safari: scope doesn't show while CRT in use - recording video indicator -- verilog: support VGA/multisync monitor? - stego shareable images (http://pico-8.wikia.com/wiki/P8PNGFileFormat) - https://makecode.com/language? -- show .map file in listings? +- show .map file in listings? memory map view? - open ROM from URL? -- NES: breakpoint on illegal instruction +- NES: disassembly not aligned on PC +- NES: listing for .s files WEB WORKER FORMAT diff --git a/presets/nes/demosounds.s b/presets/nes/demosounds.s new file mode 100644 index 00000000..8bf87ff8 --- /dev/null +++ b/presets/nes/demosounds.s @@ -0,0 +1,70 @@ +;this file for FamiTone2 libary generated by nsf2data tool + + .export _demo_sounds +_demo_sounds: + .word @ntsc + .word @pal +@ntsc: + .word @sfx_ntsc_0 + .word @sfx_ntsc_1 + .word @sfx_ntsc_2 + .word @sfx_ntsc_3 +@pal: + .word @sfx_pal_0 + .word @sfx_pal_1 + .word @sfx_pal_2 + .word @sfx_pal_3 + +@sfx_ntsc_0: + .byte $80,$bf,$81,$56,$82,$03,$83,$bf,$84,$a6,$85,$02,$04,$81,$3a,$82 + .byte $02,$84,$c4,$85,$01,$04,$81,$ab,$82,$01,$84,$52,$04,$81,$1c,$84 + .byte $e1,$85,$00,$04,$81,$d5,$82,$00,$84,$a9,$04,$80,$b8,$81,$1c,$82 + .byte $01,$83,$b8,$84,$e1,$04,$81,$d5,$82,$00,$84,$a9,$04,$80,$30,$00 +@sfx_pal_0: + .byte $80,$bf,$81,$19,$82,$03,$83,$bf,$84,$75,$85,$02,$04,$81,$11,$82 + .byte $02,$84,$a4,$85,$01,$03,$81,$8c,$82,$01,$84,$3a,$03,$81,$08,$84 + .byte $d1,$85,$00,$04,$81,$c6,$82,$00,$84,$9d,$03,$80,$b8,$81,$08,$82 + .byte $01,$83,$b8,$84,$d1,$03,$81,$c6,$82,$00,$84,$9d,$04,$80,$30,$00 +@sfx_ntsc_1: + .byte $89,$3f,$8a,$0d,$01,$8a,$0b,$01,$8a,$09,$01,$8a,$07,$01,$8a,$05 + .byte $01,$8a,$03,$01,$89,$3e,$8a,$01,$01,$8a,$0f,$01,$8a,$0d,$01,$8a + .byte $0b,$01,$89,$3d,$8a,$09,$01,$8a,$07,$01,$8a,$05,$01,$8a,$03,$01 + .byte $89,$3c,$8a,$01,$01,$8a,$0f,$01,$8a,$0d,$01,$8a,$0b,$01,$89,$3b + .byte $8a,$09,$01,$8a,$07,$01,$8a,$05,$01,$8a,$03,$01,$89,$3a,$8a,$01 + .byte $01,$8a,$0f,$01,$8a,$0d,$01,$8a,$0b,$01,$89,$39,$8a,$09,$01,$8a + .byte $07,$01,$8a,$05,$01,$8a,$03,$01,$89,$38,$8a,$01,$01,$8a,$0f,$01 + .byte $8a,$0d,$01,$8a,$0b,$01,$89,$37,$8a,$09,$01,$8a,$07,$01,$8a,$05 + .byte $01,$8a,$03,$01,$89,$36,$8a,$01,$01,$8a,$0f,$01,$8a,$0d,$01,$8a + .byte $0b,$01,$89,$35,$8a,$09,$01,$8a,$07,$01,$8a,$05,$01,$8a,$03,$01 + .byte $89,$34,$8a,$01,$01,$8a,$0f,$01,$8a,$0d,$01,$8a,$0b,$01,$89,$33 + .byte $8a,$09,$01,$8a,$07,$01,$8a,$05,$01,$8a,$03,$01,$89,$32,$8a,$01 + .byte $01,$8a,$0f,$01,$8a,$0d,$01,$8a,$0b,$01,$89,$31,$8a,$09,$01,$8a + .byte $07,$01,$8a,$05,$01,$8a,$03,$01,$8a,$01,$01,$8a,$0f,$01,$8a,$0d + .byte $01,$00 +@sfx_pal_1: + .byte $89,$3f,$8a,$0d,$01,$8a,$0b,$01,$8a,$09,$01,$8a,$07,$01,$8a,$05 + .byte $01,$89,$3e,$8a,$03,$01,$8a,$01,$01,$8a,$0f,$01,$8a,$0d,$01,$89 + .byte $3d,$8a,$0b,$01,$8a,$09,$01,$8a,$07,$01,$8a,$05,$01,$89,$3c,$8a + .byte $03,$01,$8a,$01,$01,$8a,$0f,$01,$8a,$0d,$01,$89,$3b,$8a,$0b,$01 + .byte $8a,$09,$01,$8a,$07,$01,$8a,$05,$01,$89,$3a,$8a,$03,$01,$8a,$01 + .byte $01,$8a,$0f,$01,$8a,$0d,$01,$89,$39,$8a,$0b,$01,$8a,$09,$01,$8a + .byte $07,$01,$8a,$05,$01,$89,$38,$8a,$03,$01,$8a,$01,$01,$8a,$0f,$01 + .byte $8a,$0d,$01,$89,$37,$8a,$0b,$01,$8a,$09,$01,$8a,$07,$01,$8a,$05 + .byte $01,$89,$36,$8a,$03,$01,$8a,$01,$01,$8a,$0f,$01,$8a,$0d,$01,$89 + .byte $35,$8a,$0b,$01,$8a,$09,$01,$8a,$07,$01,$8a,$05,$01,$89,$34,$8a + .byte $03,$01,$8a,$01,$01,$8a,$0f,$01,$8a,$0d,$01,$89,$33,$8a,$0b,$01 + .byte $8a,$09,$01,$8a,$07,$01,$8a,$05,$01,$89,$32,$8a,$03,$01,$8a,$01 + .byte $01,$8a,$0f,$01,$8a,$0d,$01,$89,$31,$8a,$0b,$01,$8a,$09,$01,$8a + .byte $07,$01,$8a,$05,$01,$8a,$03,$01,$8a,$01,$01,$8a,$0f,$01,$00 +@sfx_ntsc_2: + .byte $80,$bf,$81,$d5,$82,$00,$02,$81,$6a,$02,$80,$b4,$04,$80,$b8,$81 + .byte $d5,$02,$81,$6a,$02,$80,$b2,$04,$00 +@sfx_pal_2: + .byte $80,$bf,$81,$c6,$82,$00,$02,$81,$62,$02,$80,$b4,$03,$80,$b8,$81 + .byte $c6,$02,$81,$62,$01,$80,$b2,$04,$00 +@sfx_ntsc_3: + .byte $86,$81,$87,$6a,$88,$00,$01,$87,$70,$01,$87,$6a,$01,$87,$70,$01 + .byte $87,$6a,$01,$00 +@sfx_pal_3: + .byte $86,$81,$87,$62,$88,$00,$01,$87,$68,$01,$87,$62,$01,$87,$68,$01 + .byte $87,$62,$01,$00 diff --git a/presets/nes/fami.c b/presets/nes/fami.c new file mode 100644 index 00000000..f7e2654f --- /dev/null +++ b/presets/nes/fami.c @@ -0,0 +1,55 @@ + +#include "neslib.h" + +//#link "jroatch.c" +extern unsigned char jroatch_chr[0x1000]; +#define TILESET jroatch_chr + +//#link "famitone2.s" +void __fastcall__ famitone_update(void); +//#link "music_aftertherain.s" +extern char after_the_rain_music_data[]; +//#link "music_dangerstreets.s" +extern char danger_streets_music_data[]; +//#link "demosounds.s" +extern char demo_sounds[]; + +void main(void) +{ + //copy tileset to RAM + vram_adr(0x0); + vram_write((unsigned char*)TILESET, sizeof(TILESET)); + pal_col(1,0x04); + pal_col(2,0x20); + pal_col(3,0x30); + vram_adr(NTADR_A(2,2)); + vram_write("FAMITONE2 DEMO", 14); + // initialize music system + //famitone_init(after_the_rain_music_data); + famitone_init(danger_streets_music_data); + sfx_init(demo_sounds); + // set music callback + nmi_set_callback(famitone_update); + // play music + music_play(0); + //enable rendering + ppu_on_all(); + // repeat forever + while(1) { + // poll controller 0 + char pad = pad_poll(0); + // play sounds when buttons pushed + if (pad & PAD_A) { + sfx_play(0,0); + } + if (pad & PAD_B) { + sfx_play(1,1); + } + if (pad & PAD_LEFT) { + sfx_play(2,2); + } + if (pad & PAD_RIGHT) { + sfx_play(3,3); + } + } +} diff --git a/presets/nes/famitone2.s b/presets/nes/famitone2.s new file mode 100644 index 00000000..f80e9f4f --- /dev/null +++ b/presets/nes/famitone2.s @@ -0,0 +1,1322 @@ + +;settings, uncomment or put them into your main program; the latter makes possible updates easier + +; 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 +; FT_SFX_STREAMS = 4 ;number of sound effects played at once, 1..4 + +; FT_DPCM_ENABLE ;undefine to exclude all DMC code +; FT_SFX_ENABLE ;undefine to exclude all sound effects code +; FT_THREAD ;undefine if you are calling sound effects from the same thread as the sound update call + +; FT_PAL_SUPPORT ;undefine to exclude PAL support +; FT_NTSC_SUPPORT ;undefine to exclude NTSC support + + .import popa + +FT_BASE_ADR =$0500 ;page in RAM, should be $xx00 +FT_DPCM_OFF =$c000 ;sample data start address + +.define FT_THREAD 1 ;undefine if you call sound effects in the same thread as sound update +.define FT_PAL_SUPPORT 1 ;undefine to exclude PAL support +.define FT_NTSC_SUPPORT 1 ;undefine to exclude NTSC support +.define FT_SFX_ENABLE 1 +.define FT_DPCM_ENABLE 0 +.define FT_SFX_STREAMS 4 + +.segment "ZEROPAGE" + +FT_TEMP: .res 3 + +.segment "CODE" + + .export _famitone_init,_famitone_update + .export _music_play,_music_stop,_music_pause +.if(FT_SFX_ENABLE) + .export _sfx_init + .export _sfx_play +.endif +.if(FT_DPCM_ENABLE) + .export _sample_play +.endif + +;void __fastcall__ famitone_init(void* music_data); + +_famitone_init=FamiToneInit + + + +;void __fastcall__ famitone_update(void); + +_famitone_update=FamiToneUpdate + + + +;void __fastcall__ music_play(unsigned char song); + +_music_play=FamiToneMusicPlay + + + +;void __fastcall__ music_stop(void); + +_music_stop=FamiToneMusicStop + + + +;void __fastcall__ music_pause(unsigned char pause); + +_music_pause=FamiToneMusicPause + + +.if(FT_SFX_ENABLE) +;void __fastcall__ sfx_init(void* sounds_data); +_sfx_init=FamiToneSfxInit + +;void __fastcall__ sfx_play(unsigned char sound,unsigned char channel); +_sfx_play: + + and #$03 + tax + lda @sfxPriority,x + tax + jsr popa + jmp FamiToneSfxPlay + +@sfxPriority: + + .byte FT_SFX_CH0,FT_SFX_CH1,FT_SFX_CH2,FT_SFX_CH3 +.endif + +.if(FT_DPCM_ENABLE) +;void __fastcall__ sample_play(unsigned char sample); +_sample_play=FamiToneSamplePlay +.endif + +;FamiTone2 v1.12 + + + +;internal defines +;FT_PITCH_FIX if either NTSC or PAL defined + .if(FT_PAL_SUPPORT && FT_NTSC_SUPPORT) +FT_PITCH_FIX = 1 + .else +FT_PITCH_FIX = 0 + .endif + +FT_DPCM_PTR = (FT_DPCM_OFF&$3fff)>>6 + + +;zero page variables + +FT_TEMP_PTR = FT_TEMP ;word +FT_TEMP_PTR_L = FT_TEMP_PTR+0 +FT_TEMP_PTR_H = FT_TEMP_PTR+1 +FT_TEMP_VAR1 = FT_TEMP+2 + + +;envelope structure offsets, 5 bytes per envelope, grouped by variable type + +FT_ENVELOPES_ALL = 3+3+3+2 ;3 for the pulse and triangle channels, 2 for the noise channel +FT_ENV_STRUCT_SIZE = 5 + +FT_ENV_VALUE = FT_BASE_ADR+0*FT_ENVELOPES_ALL +FT_ENV_REPEAT = FT_BASE_ADR+1*FT_ENVELOPES_ALL +FT_ENV_ADR_L = FT_BASE_ADR+2*FT_ENVELOPES_ALL +FT_ENV_ADR_H = FT_BASE_ADR+3*FT_ENVELOPES_ALL +FT_ENV_PTR = FT_BASE_ADR+4*FT_ENVELOPES_ALL + + +;channel structure offsets, 7 bytes per channel + +FT_CHANNELS_ALL = 5 +FT_CHN_STRUCT_SIZE = 9 + +FT_CHN_PTR_L = FT_BASE_ADR+0*FT_CHANNELS_ALL +FT_CHN_PTR_H = FT_BASE_ADR+1*FT_CHANNELS_ALL +FT_CHN_NOTE = FT_BASE_ADR+2*FT_CHANNELS_ALL +FT_CHN_INSTRUMENT = FT_BASE_ADR+3*FT_CHANNELS_ALL +FT_CHN_REPEAT = FT_BASE_ADR+4*FT_CHANNELS_ALL +FT_CHN_RETURN_L = FT_BASE_ADR+5*FT_CHANNELS_ALL +FT_CHN_RETURN_H = FT_BASE_ADR+6*FT_CHANNELS_ALL +FT_CHN_REF_LEN = FT_BASE_ADR+7*FT_CHANNELS_ALL +FT_CHN_DUTY = FT_BASE_ADR+8*FT_CHANNELS_ALL + + +;variables and aliases + +FT_ENVELOPES = FT_BASE_ADR +FT_CH1_ENVS = FT_ENVELOPES+0 +FT_CH2_ENVS = FT_ENVELOPES+3 +FT_CH3_ENVS = FT_ENVELOPES+6 +FT_CH4_ENVS = FT_ENVELOPES+9 + +FT_CHANNELS = FT_ENVELOPES+FT_ENVELOPES_ALL*FT_ENV_STRUCT_SIZE +FT_CH1_VARS = FT_CHANNELS+0 +FT_CH2_VARS = FT_CHANNELS+1 +FT_CH3_VARS = FT_CHANNELS+2 +FT_CH4_VARS = FT_CHANNELS+3 +FT_CH5_VARS = FT_CHANNELS+4 + + +FT_CH1_NOTE = FT_CH1_VARS+.lobyte(FT_CHN_NOTE) +FT_CH2_NOTE = FT_CH2_VARS+.lobyte(FT_CHN_NOTE) +FT_CH3_NOTE = FT_CH3_VARS+.lobyte(FT_CHN_NOTE) +FT_CH4_NOTE = FT_CH4_VARS+.lobyte(FT_CHN_NOTE) +FT_CH5_NOTE = FT_CH5_VARS+.lobyte(FT_CHN_NOTE) + +FT_CH1_INSTRUMENT = FT_CH1_VARS+.lobyte(FT_CHN_INSTRUMENT) +FT_CH2_INSTRUMENT = FT_CH2_VARS+.lobyte(FT_CHN_INSTRUMENT) +FT_CH3_INSTRUMENT = FT_CH3_VARS+.lobyte(FT_CHN_INSTRUMENT) +FT_CH4_INSTRUMENT = FT_CH4_VARS+.lobyte(FT_CHN_INSTRUMENT) +FT_CH5_INSTRUMENT = FT_CH5_VARS+.lobyte(FT_CHN_INSTRUMENT) + +FT_CH1_DUTY = FT_CH1_VARS+.lobyte(FT_CHN_DUTY) +FT_CH2_DUTY = FT_CH2_VARS+.lobyte(FT_CHN_DUTY) +FT_CH3_DUTY = FT_CH3_VARS+.lobyte(FT_CHN_DUTY) +FT_CH4_DUTY = FT_CH4_VARS+.lobyte(FT_CHN_DUTY) +FT_CH5_DUTY = FT_CH5_VARS+.lobyte(FT_CHN_DUTY) + +FT_CH1_VOLUME = FT_CH1_ENVS+.lobyte(FT_ENV_VALUE)+0 +FT_CH2_VOLUME = FT_CH2_ENVS+.lobyte(FT_ENV_VALUE)+0 +FT_CH3_VOLUME = FT_CH3_ENVS+.lobyte(FT_ENV_VALUE)+0 +FT_CH4_VOLUME = FT_CH4_ENVS+.lobyte(FT_ENV_VALUE)+0 + +FT_CH1_NOTE_OFF = FT_CH1_ENVS+.lobyte(FT_ENV_VALUE)+1 +FT_CH2_NOTE_OFF = FT_CH2_ENVS+.lobyte(FT_ENV_VALUE)+1 +FT_CH3_NOTE_OFF = FT_CH3_ENVS+.lobyte(FT_ENV_VALUE)+1 +FT_CH4_NOTE_OFF = FT_CH4_ENVS+.lobyte(FT_ENV_VALUE)+1 + +FT_CH1_PITCH_OFF = FT_CH1_ENVS+.lobyte(FT_ENV_VALUE)+2 +FT_CH2_PITCH_OFF = FT_CH2_ENVS+.lobyte(FT_ENV_VALUE)+2 +FT_CH3_PITCH_OFF = FT_CH3_ENVS+.lobyte(FT_ENV_VALUE)+2 + + +FT_VARS = FT_CHANNELS+FT_CHANNELS_ALL*FT_CHN_STRUCT_SIZE + +FT_PAL_ADJUST = FT_VARS+0 +FT_SONG_LIST_L = FT_VARS+1 +FT_SONG_LIST_H = FT_VARS+2 +FT_INSTRUMENT_L = FT_VARS+3 +FT_INSTRUMENT_H = FT_VARS+4 +FT_TEMPO_STEP_L = FT_VARS+5 +FT_TEMPO_STEP_H = FT_VARS+6 +FT_TEMPO_ACC_L = FT_VARS+7 +FT_TEMPO_ACC_H = FT_VARS+8 +FT_SONG_SPEED = FT_CH5_INSTRUMENT +FT_PULSE1_PREV = FT_CH3_DUTY +FT_PULSE2_PREV = FT_CH5_DUTY +FT_DPCM_LIST_L = FT_VARS+9 +FT_DPCM_LIST_H = FT_VARS+10 +FT_DPCM_EFFECT = FT_VARS+11 +FT_OUT_BUF = FT_VARS+12 ;11 bytes + + +;sound effect stream variables, 2 bytes and 15 bytes per stream +;when sound effects are disabled, this memory is not used + +FT_SFX_ADR_L = FT_VARS+23 +FT_SFX_ADR_H = FT_VARS+24 +FT_SFX_BASE_ADR = FT_VARS+25 + +FT_SFX_STRUCT_SIZE = 15 +FT_SFX_REPEAT = FT_SFX_BASE_ADR+0 +FT_SFX_PTR_L = FT_SFX_BASE_ADR+1 +FT_SFX_PTR_H = FT_SFX_BASE_ADR+2 +FT_SFX_OFF = FT_SFX_BASE_ADR+3 +FT_SFX_BUF = FT_SFX_BASE_ADR+4 ;11 bytes + + +;aliases for sound effect channels to use in user calls + +FT_SFX_CH0 = FT_SFX_STRUCT_SIZE*0 +FT_SFX_CH1 = FT_SFX_STRUCT_SIZE*1 +FT_SFX_CH2 = FT_SFX_STRUCT_SIZE*2 +FT_SFX_CH3 = FT_SFX_STRUCT_SIZE*3 + + +;aliases for the APU registers + +APU_PL1_VOL = $4000 +APU_PL1_SWEEP = $4001 +APU_PL1_LO = $4002 +APU_PL1_HI = $4003 +APU_PL2_VOL = $4004 +APU_PL2_SWEEP = $4005 +APU_PL2_LO = $4006 +APU_PL2_HI = $4007 +APU_TRI_LINEAR = $4008 +APU_TRI_LO = $400a +APU_TRI_HI = $400b +APU_NOISE_VOL = $400c +APU_NOISE_LO = $400e +APU_NOISE_HI = $400f +APU_DMC_FREQ = $4010 +APU_DMC_RAW = $4011 +APU_DMC_START = $4012 +APU_DMC_LEN = $4013 +APU_SND_CHN = $4015 + + +;aliases for the APU registers in the output buffer + + .if(!FT_SFX_ENABLE) ;if sound effects are disabled, write to the APU directly +FT_MR_PULSE1_V = APU_PL1_VOL +FT_MR_PULSE1_L = APU_PL1_LO +FT_MR_PULSE1_H = APU_PL1_HI +FT_MR_PULSE2_V = APU_PL2_VOL +FT_MR_PULSE2_L = APU_PL2_LO +FT_MR_PULSE2_H = APU_PL2_HI +FT_MR_TRI_V = APU_TRI_LINEAR +FT_MR_TRI_L = APU_TRI_LO +FT_MR_TRI_H = APU_TRI_HI +FT_MR_NOISE_V = APU_NOISE_VOL +FT_MR_NOISE_F = APU_NOISE_LO + .else ;otherwise write to the output buffer +FT_MR_PULSE1_V = FT_OUT_BUF +FT_MR_PULSE1_L = FT_OUT_BUF+1 +FT_MR_PULSE1_H = FT_OUT_BUF+2 +FT_MR_PULSE2_V = FT_OUT_BUF+3 +FT_MR_PULSE2_L = FT_OUT_BUF+4 +FT_MR_PULSE2_H = FT_OUT_BUF+5 +FT_MR_TRI_V = FT_OUT_BUF+6 +FT_MR_TRI_L = FT_OUT_BUF+7 +FT_MR_TRI_H = FT_OUT_BUF+8 +FT_MR_NOISE_V = FT_OUT_BUF+9 +FT_MR_NOISE_F = FT_OUT_BUF+10 + .endif + + + +;------------------------------------------------------------------------------ +; reset APU, initialize FamiTone +;------------------------------------------------------------------------------ + +FamiToneInit: + + sta FT_SONG_LIST_L ;store music data pointer for further use + stx FT_SONG_LIST_H + sta 0 + ldx #FT_SFX_CH0 + jsr _FT2SfxUpdate + .endif + .if FT_SFX_STREAMS>1 + ldx #FT_SFX_CH1 + jsr _FT2SfxUpdate + .endif + .if FT_SFX_STREAMS>2 + ldx #FT_SFX_CH2 + jsr _FT2SfxUpdate + .endif + .if FT_SFX_STREAMS>3 + ldx #FT_SFX_CH3 + jsr _FT2SfxUpdate + .endif + + + ;send data from the output buffer to the APU + + lda FT_OUT_BUF ;pulse 1 volume + sta APU_PL1_VOL + lda FT_OUT_BUF+1 ;pulse 1 period LSB + sta APU_PL1_LO + lda FT_OUT_BUF+2 ;pulse 1 period MSB, only applied when changed + cmp FT_PULSE1_PREV + beq @no_pulse1_upd + sta FT_PULSE1_PREV + sta APU_PL1_HI +@no_pulse1_upd: + + lda FT_OUT_BUF+3 ;pulse 2 volume + sta APU_PL2_VOL + lda FT_OUT_BUF+4 ;pulse 2 period LSB + sta APU_PL2_LO + lda FT_OUT_BUF+5 ;pulse 2 period MSB, only applied when changed + cmp FT_PULSE2_PREV + beq @no_pulse2_upd + sta FT_PULSE2_PREV + sta APU_PL2_HI +@no_pulse2_upd: + + lda FT_OUT_BUF+6 ;triangle volume (plays or not) + sta APU_TRI_LINEAR + lda FT_OUT_BUF+7 ;triangle period LSB + sta APU_TRI_LO + lda FT_OUT_BUF+8 ;triangle period MSB + sta APU_TRI_HI + + lda FT_OUT_BUF+9 ;noise volume + sta APU_NOISE_VOL + lda FT_OUT_BUF+10 ;noise period + sta APU_NOISE_LO + + .endif + + .if(FT_THREAD) + pla + sta FT_TEMP_PTR_H + pla + sta FT_TEMP_PTR_L + .endif + + rts + + +;internal routine, sets up envelopes of a channel according to current instrument +;in X envelope group offset, A instrument number + +_FT2SetInstrument: + asl a ;instrument number is pre multiplied by 4 + tay + lda FT_INSTRUMENT_H + adc #0 ;use carry to extend range for 64 instruments + sta { return new Views.ListingView(path); }); diff --git a/src/views.ts b/src/views.ts index 4df0d912..2da0f79b 100644 --- a/src/views.ts +++ b/src/views.ts @@ -534,6 +534,9 @@ export class ListingView extends DisassemblerView implements ProjectView { if (lst && lst.assemblyfile && lst.assemblyfile !== this.assemblyfile) { this.assemblyfile = lst.assemblyfile; } + else if (lst && lst.sourcefile && lst.sourcefile !== this.assemblyfile) { + this.assemblyfile = lst.sourcefile; + } } refresh(moveCursor: boolean) { diff --git a/src/worker/workermain.ts b/src/worker/workermain.ts index de87e0e8..192fc976 100644 --- a/src/worker/workermain.ts +++ b/src/worker/workermain.ts @@ -752,11 +752,11 @@ function parseCA65Listing(code, symbols, params, dbg) { var segLineMatch = /[.]segment\s+"(\w+)"/; //var dbgLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+[.]dbg\s+line,\s+\S+,\s+(\d+)/; var dbgLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+[.]dbg\s+line,\s+"(\w+[.]\w+)", (\d+)/; - var insnLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+([0-9A-F][0-9A-F ]*[0-9A-F])\s+/; + var insnLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+([0-9A-Fr ]*)\s*(.*)/; var lines = []; var linenum = 0; for (var line of code.split(re_crlf)) { - linenum++; + // TODO: not right when multiple .segment directives var segm = segLineMatch.exec(line); if (segm) { var segname = segm[1]; @@ -764,18 +764,19 @@ function parseCA65Listing(code, symbols, params, dbg) { segofs = parseInt(symbols[segsym] || params[segsym]) || 0; } if (dbg) { - var linem = dbgLineMatch.exec(line); - if (linem && linem[1]) { - var offset = parseInt(linem[1], 16); + var dbgm = dbgLineMatch.exec(line); + if (dbgm && dbgm[1]) { + var offset = parseInt(dbgm[1], 16); lines.push({ // TODO: sourcefile - line:parseInt(linem[5]), + line:parseInt(dbgm[5]), offset:offset + segofs, insns:null }); } } else { var linem = insnLineMatch.exec(line); + if (linem) linenum++; if (linem && linem[1]) { var offset = parseInt(linem[1], 16); var insns = linem[4].trim(); @@ -785,6 +786,8 @@ function parseCA65Listing(code, symbols, params, dbg) { offset:offset + segofs, insns:insns }); + // take back one to honor the long .byte line + if (linem[5].length == 0) linenum--; } } }