From 49e265f5f83a1d68c46896c6d30a6c96bbeaa9b1 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Thu, 19 Mar 2015 16:47:25 +0000 Subject: [PATCH] Added save/restore support for the OPL3 waveform selection. --- bochs/iodev/sound/opl.cc | 17 +++++++++++++++-- bochs/iodev/sound/opl.h | 2 ++ bochs/iodev/sound/sb16.cc | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bochs/iodev/sound/opl.cc b/bochs/iodev/sound/opl.cc index da3faa499..cd5774a30 100644 --- a/bochs/iodev/sound/opl.cc +++ b/bochs/iodev/sound/opl.cc @@ -420,6 +420,7 @@ void change_waveform(Bitu regbase, op_type* op_pt) if (regbase>=ARC_SECONDSET) regbase -= (ARC_SECONDSET-22); // second set starts at 22 #endif // waveform selection + op_pt->cur_wvsel = wave_sel[regbase]; op_pt->cur_wmask = wavemask[wave_sel[regbase]]; op_pt->cur_wform = &wavtable[waveform[wave_sel[regbase]]]; // (might need to be adapted to waveform type here...) @@ -527,6 +528,7 @@ void adlib_init(Bit32u samplerate) op[i].tcount = 0; op[i].tinc = 0; op[i].toff = 0; + op[i].cur_wvsel = 0; op[i].cur_wmask = wavemask[0]; op[i].cur_wform = &wavtable[waveform[0]]; op[i].freq_high = 0; @@ -1553,8 +1555,7 @@ void adlib_register_state(bx_list_c *parent) new bx_shadow_num_c(opX, "op_state", &op[i].op_state); new bx_shadow_num_c(opX, "toff", &op[i].toff); new bx_shadow_num_c(opX, "freq_high", &op[i].freq_high); - // TODO: cur_wform - new bx_shadow_num_c(opX, "cur_wmask", &op[i].cur_wmask); + new bx_shadow_num_c(opX, "cur_wvsel", &op[i].cur_wvsel); new bx_shadow_num_c(opX, "act_state", &op[i].act_state); new bx_shadow_bool_c(opX, "sys_keep", &op[i].sus_keep); new bx_shadow_bool_c(opX, "vibrato", &op[i].vibrato); @@ -1575,4 +1576,16 @@ void adlib_register_state(bx_list_c *parent) } } +void adlib_after_restore_state() +{ + int i; + Bit8u wvsel; + + for (i = 0; i < MAXOPERATORS; i++) { + wvsel = op[i].cur_wvsel; + op[i].cur_wmask = wavemask[wvsel]; + op[i].cur_wform = &wavtable[waveform[wvsel]]; + } +} + #endif diff --git a/bochs/iodev/sound/opl.h b/bochs/iodev/sound/opl.h index afbec6bfe..ee119f274 100644 --- a/bochs/iodev/sound/opl.h +++ b/bochs/iodev/sound/opl.h @@ -141,6 +141,7 @@ typedef struct operator_struct { Bit32u op_state; // current state of operator (attack/decay/sustain/release/off) Bit32u toff; Bit32s freq_high; // highest three bits of the frequency, used for vibrato calculations + Bit8u cur_wvsel; // register value of selected waveform Bit16s* cur_wform; // start of selected waveform Bit32u cur_wmask; // mask for selected waveform Bit32u act_state; // activity state (regular, percussion) @@ -210,6 +211,7 @@ Bitu adlib_reg_read(Bitu port); void adlib_write_index(Bitu port, Bit8u val); void adlib_register_state(bx_list_c *parent); +void adlib_after_restore_state(); extern Bit16u opl_index; diff --git a/bochs/iodev/sound/sb16.cc b/bochs/iodev/sound/sb16.cc index 155d0a0f7..98acec201 100644 --- a/bochs/iodev/sound/sb16.cc +++ b/bochs/iodev/sound/sb16.cc @@ -526,6 +526,7 @@ void bx_sb16_c::register_state(void) void bx_sb16_c::after_restore_state(void) { set_irq_dma(); + adlib_after_restore_state(); } void bx_sb16_c::runtime_config_handler(void *this_ptr)