Skip to content

NES: FDS Accuracy Improvements#85

Draft
TakuikaNinja wants to merge 11 commits intonesdev-org:masterfrom
TakuikaNinja:FDS-Registers
Draft

NES: FDS Accuracy Improvements#85
TakuikaNinja wants to merge 11 commits intonesdev-org:masterfrom
TakuikaNinja:FDS-Registers

Conversation

@TakuikaNinja
Copy link
Copy Markdown

@TakuikaNinja TakuikaNinja commented May 5, 2026

This PR aims to improve the FDS accuracy based on ongoing research: https://www.nesdev.org/wiki/User:TakuikaNinja/FDS_Registers

I'm not as familiar with the audio side of things, so any help there would be appreciated.

Working

  • $4023.D0 only affects writable disk registers, forces certain values for $4025 and $4026
  • $4023.D1 only directly affects $4080 (volume envelope), $4085 (mod counter), and $4088 (mod table write), apply instant volume mute for now
  • External connector: Mask $4026 writes to 7 bits, and force bit 7 = 1 for $4033 reads (i.e. always return good battery/power status)
  • $4030 reads do not clear byte transfer flag/disk IRQs
  • Move byte transfer flag to $4030.D7 (eventually needed by Tonkachi Editor)
  • A more faithful modulation implementation, based on Implement nonlinear FDS DAC and updated FDS audio emulation SourMesen/Mesen2#33 (minus non-linear DAC)
  • $4090-$4097 reads (debug audio registers), which required the above implementation

Needs testing/fixing

  • Modulation issues in FDS-Audio-Registers
  • Modulation issues in Bio Miracle Bokutte Upa (e.g. the invincibility theme when grabbing a bell item, underground theme in 1-2)
  • Test for regressions in commercial games + NSFs, especially the modulation

Not addressing

  • Add remaining disk registers to register view
  • Register peeking
  • Actual audio reset state when $4023.D1 = 0 (research ongoing) + rename _soundRegEnabled to reflect its purpose
  • $4095 upper nybble
  • DRAM refresh watchdog ($4030.D1)
  • End of head behaviour ($4030.D6)
  • Byte transfer flag behaviour ($4030.D7)
  • Non-linear DAC + volume PWM + filtering (probably not worth the performance hit for a minuscule audio improvement)

Test programs

TakuikaNinja and others added 11 commits April 13, 2026 15:00
Passes latest FDS-Mirroring-Test
Disk registers behave closer to hardware in FDS-4023-Test
$4023.D0 = 0 forces output to $7F
Always return good battery status in $4033.D7
Modulation has unfortunately regressed
- Fix GetModIncrement()
- Optimise mod counter register display
- Add disable logic in UpdateCounter() for now
fixme: Modulation issues in FDS-Audio-Registers and Bio Miracle Bokutte Upa
Eventually needed by Tonkachi Editor, though it still fails to access disks for editing
Fixes modulation in FDS-Audio-Registers
Also remove redundant TickEnvelope definition
@TakuikaNinja
Copy link
Copy Markdown
Author

Turns out the PR I was referencing for the modulation had missed the fact that the mod accumulator is halted while $4087.D7 = 1. FDS-Audio-Registers sounds correct now.

Bio Miracle Bokutte Upa still sounds weird compared to recordings I found on TCRF, however, so I'll have to double check against my Twin Famicom. Maybe the mixing resistor swap will make it easier to discern! 😛

@TakuikaNinja
Copy link
Copy Markdown
Author

TakuikaNinja commented May 10, 2026

Scaling back the scope of this PR a bit - the remaining register view changes will go into a separate PR, and register peeking will have to wait until more accuracy improvements have been made.

Note: The audio debug registers ($4090-$4097) have already been added to the register viewer under an appropriate heading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant