Skip to content

Keep the ADPCM delta-N low byte when it is written first - #22

Merged
bubio merged 1 commit into
mainfrom
fix/adpcm-deltan-low-byte
Sep 21, 2026
Merged

bubio merged 1 commit into
mainfrom
fix/adpcm-deltan-low-byte

Conversation

@bubio

@bubio bubio commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • ADPCM delta-N (ext reg 0x09/0x0A) の 256 下限クランプをレジスタ自体に書き戻していたため、上位バイトが 0x00 の状態で下位を先に書くと下位バイトが消えていた(256 = 0x0100)。
  • fmgen と同じく、生のレジスタ値を保持し、下限は updateADPCMPlaybackDelta() の派生値にだけ適用するよう修正。
  • あたしのぱ・ぴ・ぷ・ぺ・ぽ は 0x09=0xDD → 0x0A=0x24 で 0x24DD のはずが 0x2400 になり、66 秒の ADPCM ストリームが 2.34% 遅く再生され、600Hz RTC で進むアニメが曲より先行していた(bubio/Bubilator88 側の報告)。

Test plan

  • YM2608ADPCMDeltaNTests を追加(書き込み順 2 通り、256 未満のペアの扱い)
  • swift test 全 PASS(928 tests)
  • BootTester で同デモの ADPCM 出力長が 67.259 s → 65.672 s(理論値 65.672 s)に一致
  • scripts/regression_compare.py 20/20 PASS

🤖 Generated with Claude Code

The 256 floor on delta-N was written back into the register pair. A low
byte written while the high byte was still 0x00 became 0x0100, which
drops the low byte. fmgen floors only the value it derives from the two
registers, so the floor now lives in updateADPCMPlaybackDelta() alone.

あたしのぱ・ぴ・ぷ・ぺ・ぽ writes 0x09=0xDD then 0x0A=0x24 once after reset
and got 0x2400 instead of 0x24DD, so its 66-second ADPCM stream played
2.3% slow and fell behind the RTC-paced animation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@bubio
bubio merged commit cbc3924 into main Sep 21, 2026
3 checks passed
@bubio
bubio deleted the fix/adpcm-deltan-low-byte branch September 21, 2026 03:56
@bubio bubio mentioned this pull request Sep 21, 2026
3 tasks done
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