Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 14 additions & 1 deletion src/np2_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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(); }
Expand Down
Loading