diff --git a/src/c.zig b/src/c.zig index be9aa38..397cb59 100644 --- a/src/c.zig +++ b/src/c.zig @@ -15,7 +15,12 @@ pub const c = @cImport({ // need to mix cz.foo and c.bar). pub const pccore_init = c.pccore_init; pub const pccore_term = c.pccore_term; -pub const pccore_reset = c.pccore_reset; +// Wrapper (src/np2_glue.c) that runs the core reset and then re-applies the +// Sound Mixer volumes — the core pccore_reset() resets the chips to their +// power-on volume and never restores np2cfg.vol_*. Route all callers through +// it so mixer settings survive every reset (incl. the initial one). +pub extern fn usa_pccore_reset() void; +pub const pccore_reset = usa_pccore_reset; pub extern fn usa_pccore_exec(draw: c_int) void; pub inline fn pccore_exec(draw: bool) void { usa_pccore_exec(if (draw) 1 else 0); diff --git a/src/np2_glue.c b/src/np2_glue.c index ea6f64b..155f601 100644 --- a/src/np2_glue.c +++ b/src/np2_glue.c @@ -427,8 +427,9 @@ void usa_mouse_btn_up(int left) { } // Reset with HELP key held (for BIOS system setup menu) +void usa_pccore_reset(void); // defined below; re-applies the Sound Mixer after reset void usa_reset_with_help(void) { - pccore_reset(); + usa_pccore_reset(); keystat_keydown(0x3f); } @@ -674,6 +675,18 @@ void usa_sound_apply_volumes(void) { fmboard_updatevolume(); } +// pccore_reset() resets every sound chip back to its power-on volume, +// dropping the FMGEN linear volumes / cs4231 scaling that the basic +// sound_init() path never establishes — so the Sound Mixer settings end up +// ignored after a reset (including the initial reset at startup). Wrap the +// core reset and re-apply the full np2cfg.vol_* mixer afterwards, matching +// the live slider-edit path. Done here in the glue layer so NP2kai's core +// stays unpatched. All reset call sites route through this wrapper. +void usa_pccore_reset(void) { + pccore_reset(); + fmboard_updatevolume(); +} + void usa_pal_makelcdpal(void) { pal_makelcdpal(); } void usa_pal_makeskiptable(void) { pal_makeskiptable(); } void usa_gdc_restorekacmode(void) { gdc_restorekacmode(); }