Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FDS-N163 playback issues #330

Open
Gumball2415 opened this issue Jan 20, 2025 · 2 comments
Open

FDS-N163 playback issues #330

Gumball2415 opened this issue Jan 20, 2025 · 2 comments
Labels
bug Something isn't working nsf-driver sound engine used in NSF/assembly file export question Further information is requested

Comments

@Gumball2415
Copy link
Collaborator

Gumball2415 commented Jan 20, 2025

NSF export of this module crashes in Mesen2 @ commit 30ece8ec6271f09cffa440828a1c96e35fef837a
When assembled with .asm export and driver source, FDS automodulation isn't working.

details:

  • build: release x64 Dn-FT v0.5.1.1+ beta @ commit 4493431

attachments:

  • computer.dnm
  • computer.nsf (NSF2 export)
  • music.nsf (.asm export, compiled with driver v2.15)

investigation is needed.

@Gumball2415 Gumball2415 added bug Something isn't working nsf-driver sound engine used in NSF/assembly file export question Further information is requested labels Jan 20, 2025
@Gumball2415
Copy link
Collaborator Author

Gumball2415 commented Jan 24, 2025

the latter is caused by #331

@Gumball2415
Copy link
Collaborator Author

the former is caused by the memory region in $8000-DFFF becoming read-writeable by FDS. in some NSF players where they do not make this region read-writeable, the NSF works as expected, but when exported as NSF and played in Mesen, which makes the region read-writeable, the program crashes through a cascade of expansion audio register writes overwriting driver code.

example case using this NSF: computer.zip

the NSF is exported with a "glob" multichip configuration, enabling all expansion audio code. (USE_ALL)

VRC6 initialization writes $00 to $9003.

.if .defined(USE_VRC6)
lda #$00
sta $9003
.endif

N163 writes to $0E $C000 due to 5B being enabled. this prevents conflicts with 5B registers.

; Enable sound, copied from PPMCK and verified on a real Namco cart
; no sound without this!
.if .defined(USE_S5B) ;;; ;; ;
lda #$0E
sta $C000
.endif ; ;; ;;;

VRC7 init writes to $9010 and $9030, ending up with $3E and $00 in both registers respectively.

ft_init_vrc7:
lda #$00
sta var_ch_vrc7_PatchFlag
tax
: stx $9010
jsr ft_vrc7_delay2
sta $9030
jsr ft_vrc7_delay
inx
cpx #$3F
bne :-
ldx #$05
lda #$FF
: sta var_ch_vrc7_EffPatch, x
dex
bpl :-
rts

the former write corrupts this line to sta $3e20,x instead of sta $0420,x, which is where var_ch_PeriodCalcLo is compiled to.

ft_calc_period:
; Load period
lda var_ch_TimerPeriodLo, x
sta var_ch_PeriodCalcLo, x

there are also memory corruptions throughout the driver, though i am not sure where they are coming from.

in any case, overwriting data/code results in nondeterministic behavior and may even cause the program to crash.

#334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working nsf-driver sound engine used in NSF/assembly file export question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant