Skip to content

PSX3DS v0.2.6 — Real-3DS Audio Fix & Steady 60.0 FPS Lock

Choose a tag to compare

@codescv codescv released this 11 Nov 06:59
· 6 commits to main since this release

PSX3DS v0.2.6 — Real-Hardware Audio Fix (SysCore Priority 0x2F, Core 0 NDSP Backstop, 4x735 Full-Buffer FIFO Feeder) & Steady 60.0 FPS Frame Pacer

v0.2.6 resolves the two issues reported on real New 3DS hardware running World Soccer Jikkyou Winning Eleven 3 - Final Ver. (Japan) (SLPM_861.62 + SCPH5500.BIN) on v0.2.5: missing audio output ("另外没有声音") and 30–80 FPS framerate fluctuation ("帧数不稳定, 在30-80之间跳动. 希望能锁定最高60帧稳定运行").


English Release Notes

1. Fix Real-3DS Missing Audio (src/platform/3ds/threads_3ds.c, src/platform/3ds/audio_ndsp.c, src/platform/3ds/main_3ds.c, src/periph/spu.c)

  • SysCore (Core 1) SPU Worker Priority Ladder (0x2F):
    • Root Cause: In v0.2.4/v0.2.5, spu_core1_worker was spawned on Core 1 at main_prio + 1 (0x31), numerically lower priority than Horizon OS's 0x30 APT_SetAppCpuTimeLimit SysCore quota thread (or fell back to Core 0 at 0x30 where main() never yields), starving the audio worker 100% of the time while still displaying Core1 SPU: ASYNC on the HUD.
    • Fix: spu_core1_worker now launches on Core 1 at main_prio - 1 (0x2F) with a Core 1 retry ladder (0x2F -> 0x30 -> 0x31) and a sleeping-worker-safe Core 0 fallback (0x2F). Because the worker sleeps 500 us per step and parks 10 ms on APTHOOK_ONSUSPEND, 0x2F never blocks HOME Menu transitions. spu_core1_active now checks actual_core == 1 and logs spu_core=%d.
  • Dual-Core Trylock-Guarded NDSP Feeder & Core 0 Frame-End Backstop:
    • ctr_audio_step_core1(sys) is now guarded by an atomic trylock (g_step_lock) and pumped at the end of every emulated frame on Core 0 in addition to Core 1's 500 us worker. When Core 1 keeps up, Core 0 returns in < 1 us; if SysCore ever throttles Core 1, Core 0 seamlessly renders queued SpuCmd batches and feeds NDSP wavebufs.
  • 4x735 Full-Buffer FIFO NDSP Ring, 2-Buffer (33.3 ms) Re-Prime & Bounded Drift Resampler:
    • Root Cause: Previously, waking every 500 us popped partial 48..64-frame SPU batches into 735-frame NDSP wavebufs and padded the remaining 93.5%–100% with flat DC (g_last_l/g_last_r), locking NDSP into 50 ms of flat silence and inflating spu_underruns at 2 kHz.
    • Fix: Expanded NDSP ring to 4 x 735 stereo frames (66.7 ms), submitted via a strict FIFO cursor (g_wbuf_next) only when a full 735-frame buffer of real audio is ready. After cold start or a full NDSP drain, playback pre-primes 2 x 735 frames (33.33 ms, one full 30 Hz VSync(2) Even+Odd pair) so heavy ~22 ms 3D frames never underrun NDSP, counting exactly one atomic spu_underruns transition per genuine stream drain (0 underruns in we3_f2000/we3_f3100). Above high water, a gentle <= 1.1% linear resampler bounds latency under the 60.00 Hz lock.
  • Savestate Async SPU Regression Test (tests/unit/test_periph_spu.c):
    • Added test_spu_async_savestate_and_ring verifying that loading a sync (async_mode = false) savestate into an async (cfg.spu_async = true) 3DS system preserves async_mode == true and renders contiguous non-zero stereo audio across queued SpuCmd batches without drops.

2. Steady 60.0 FPS Wall-Clock Pacer & 32-Frame Rolling HUD Telemetry (src/gpu_hw/gpu_citro3d.c, src/platform/3ds/main_3ds.c, src/platform/3ds/ui_bottom.c)

  • Eliminate Extra VBlank Stalls on Empty VSync(2) Odd Frames:
    • hw_present now calls begin_frame(st, 0) instead of C3D_FRAME_SYNCDRAW when !st->in_frame, preventing empty Odd frames of 30 Hz VSync(2) games (~22 ms Even + ~6 ms Odd = ~28 ms < 33.33 ms) from stalling an extra hardware VBlank.
  • Drift-Free 60.00 Hz NTSC / 50.00 Hz PAL Deadline Pacer:
    • Added CtrFramePacer (16667 / 16667 / 16666 us = exact 50,000 us per 3 NTSC frames; 20,000 us PAL) with a 2-frame (33,334 us) catch-up window so 30 Hz VSync(2) Even+Odd pairs lock cleanly to 60.0 FPS while capping menus at 60.0 FPS (instead of running uncapped at 80+ FPS), without fast-forwarding after CD seeks or state loads.
  • 32-Frame Rolling HUD Average & Odd Redraw Cadence (15 frames = 4.0 Hz):
    • Replaced single-frame unpaced 1000000.0 / us_frame HUD readouts and the even-parity 16-frame redraw divisor (which aliased onto either heavy Even frames ~35 FPS or light Odd frames ~80 FPS) with a 32-frame rolling average of paced frame/CPU/GPU times, clamped cleanly at 60.0 FPS (16.67 ms) with an odd 15-frame idle redraw cadence.

中文更新说明 (v0.2.6)

  1. 彻底修复 New 3DS 实机无声音问题:
    • 修复 Core 1 (SysCore) SPU 音频线程饥饿:v0.2.4/v0.2.5 将 SPU 异步线程优先级设为 0x31(低于 Horizon OS 在 Core 1 上运行的 0x30 系统配额线程,或静默回退至主循环从不让出 CPU 的 Core 0),导致音频线程完全饥饿。现改为 0x2F(main_prio - 1)并配备优先级回退梯队与每帧末尾 Core 0 原子无锁(trylock)兜底泵送,确保任何情况下音频持续输出,且不影响 HOME 键挂起/退出。
    • 修复 NDSP 半满缓冲静音拼接与 FIFO 乱序:NDSP 环形缓冲扩容至 4 x 735 立体声采样帧(66.7 ms),严格按 FIFO 顺序仅在攒满 735 帧真实音频采样时提交(不再将未满缓冲区的 93%+ 填平为直流静音);启动或缓冲耗尽后自动预充 2 x 735 帧(33.3 ms,覆盖完整 30 Hz 奇偶帧周期),并通过 <= 1.1% 线性自适应重采样消除 60.00 Hz 锁帧下的长期音频延迟累积。
  2. 修复 30–80 帧跳动,稳定锁定最高 60.0 FPS:
    • 消除 30 Hz 游戏空奇帧额外垂直同步停顿:移除 hw_present 在无绘制奇帧上的 C3D_FRAME_SYNCDRAW,使《实况足球 3》比赛画面(偶帧 ~22 ms + 奇帧 ~6 ms = 28 ms < 33.33 ms)不再多等一次硬件 VBlank。
    • 零漂移 60.00 Hz(NTSC)/ 50.00 Hz(PAL)硬件时钟限帧器:带 2 帧(33.33 ms)追赶窗口,菜单与比赛最高稳定锁死 60.0 FPS(不再冲上 80+ FPS,也不会在光盘寻道后快进)。
    • HUD 32 帧滑动平均与奇分频(每 15 帧)刷新:消除旧版每 16 帧(偶数分频)采样奇偶帧导致的帧数显示跳变,稳定显示真实平滑帧率(最高钳位 60.0 FPS)。