Created
April 27, 2017 03:15
-
-
Save insipx/fc5b8239e8fabde9a4d28966477e60ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum voiceRegisters { | |
v_voll = 0x00, | |
v_volr = 0x01, | |
v_pitchl = 0x02, | |
v_pitchh = 0x03, | |
v_srcn = 0x04, | |
v_adsr0 = 0x05, | |
v_adsr1 = 0x06, | |
v_gain = 0x07, | |
v_envx = 0x08, | |
v_outx = 0x09, | |
} | |
//using this as a basis | |
fn update_voice_vol(addr: isize, state: &mut State) { | |
let mut l = state.regs[addr + voiceRegisters::v_voll]; | |
let mut r = state.regs[addr + voiceRegisters::v_volr]; | |
if l*r < state.surround_threshold { | |
//signs differ, so negate those that are negative | |
l ^= l >> 7; | |
r ^= r >> 7; | |
} | |
let &mut v:Voice = state.voices[addr >> 4]; | |
let enabled:isize = v.enabled; | |
v.volume[0] = l & enabled; | |
v.volume[1] = r & enabled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment