bsnes/higan/gba/apu/wave.cpp

96 lines
2.1 KiB
C++
Raw Normal View History

auto APU::Wave::run() -> void {
if(period && --period == 0) {
period = 1 * (2048 - frequency);
Update to v103r01 release. byuu says: Changelog: - nall/dsp: improve one pole coefficient calculations [Fatbag] - higan/audio: reworked filters to support selection of either one pole (first-order) or biquad (second-order) filters - note: the design is not stable yet; so forks should not put too much effort into synchronizing with this change yet - fc: added first-order filters as per NESdev wiki (90hz lowpass + 440hz lowpass + 14khz highpass) - fc: created separate NTSC-J and NTSC-U regions - NESdev wiki says the Japanese Famicom uses a separate audio filtering strategy, but details are fuzzy - there's also cartridge audio output being disabled on NES units; and differences with controllers - this stuff will be supported in the future, just adding the support for it now - gba: corrected serious bugs in PSG wave channel emulation [Cydrak] - note that if there are still bugs here, it's my fault - md/psg,ym2612: added first-order low-pass 2840hz filter to match VA3-VA6 Mega Drives - md/psg: lowered volume relative to the YM2612 - using 0x1400; multiple people agreed it was the closest to the hardware recordings against a VA6 - ms,md/psg: don't serialize the volume levels array - md/vdp: Hblank bit acts the same during Vblank as outside of it (it isn't always set during Vblank) - md/vdp: return isPAL in bit 0 of control port reads - tomoko: change command-line option separator from : to | - [Editor's note: This change was present in the public v103, but it's in this changelog because it was made after the v103 WIP] - higan/all: change the 20hz high-pass filters from second-order three-pass to first-order one-pass - these filters are meant to remove DC bias, but I honestly can't hear a difference with or without them - so there's really no sense wasting CPU power with an extremely powerful filter here Things I did not do: - change icarus install rule - work on 8-bit Mega Drive SRAM - work on Famicom or Mega Drive region detection heuristics in icarus My long-term dream plan is to devise a special user-configurable filtering system where you can set relative volumes and create your own list of filters (any number of them in any order at any frequency), that way people can make the systems sound however they want. Right now, the sanest place to put this information is inside the $system.sys/manifest.bml files. But that's not very user friendly, and upgrading to new versions will lose these changes if you don't copy them over manually. Of course, cluttering the GUI with a fancy filter editor is probably supreme overkill for 99% of users, so maybe that's fine.
2017-06-26 01:41:58 +00:00
patternsample = pattern[patternbank << 5 | patternaddr++];
if(patternaddr == 0) patternbank ^= mode;
}
output = patternsample;
static uint multiplier[] = {0, 4, 2, 1, 3, 3, 3, 3};
output = (output * multiplier[volume]) / 4;
if(enable == false) output = 0;
}
auto APU::Wave::clocklength() -> void {
if(enable && counter) {
if(++length == 0) enable = false;
}
}
auto APU::Wave::read(uint addr) const -> uint8 {
switch(addr) {
case 0: return (mode << 5) | (bank << 6) | (dacenable << 7);
case 1: return 0;
case 2: return (volume << 5);
case 3: return 0;
case 4: return (counter << 6);
}
}
auto APU::Wave::write(uint addr, uint8 byte) -> void {
switch(addr) {
case 0: //NR30
mode = byte >> 5;
bank = byte >> 6;
dacenable = byte >> 7;
if(dacenable == false) enable = false;
break;
case 1: //NR31
length = byte >> 0;
break;
case 2: //NR32
volume = byte >> 5;
break;
case 3: //NR33
frequency = (frequency & 0xff00) | (byte << 0);
break;
case 4: //NR34
frequency = (frequency & 0x00ff) | (byte << 8);
counter = byte >> 6;
initialize = byte >> 7;
if(initialize) {
enable = dacenable;
period = 1 * (2048 - frequency);
patternaddr = 0;
patternbank = mode ? (uint1)0 : bank;
}
break;
}
}
auto APU::Wave::readram(uint addr) const -> uint8 {
uint8 byte = 0;
Update to v103r09 release. byuu says: Changelog: - gba/apu: fixed wave RAM nibble ordering (fixes audio in Castlevania, PocketNES) - emulator: restructured video information to just a single videoResolution() → VideoResolution function - returns "projected size" (between 160x144 and 320x240) - "internal buffer size" (up to 1280x480) - returns aspect correction multiplier that is to be applied to the width field - the value could be < 1.0 to handle systems with taller pixels; although higan doesn't emulate such a system - tomoko: all calculations for scaling and overscan masking are done by the GUI now - tomoko: aspect correction can be enabled in either windowed or fullscreen mode separately; moved to Video settings panel - tomoko: video scaling multipliers (against 320x240) can now me modified from the default (2,3,4) via the configuration file - use this as a really barebones way of supporting high DPI monitors; although the GUI elements won't scale nicely - if you set a value less than two, or greater than your resolution divided by 320x240, it's your own fault when things blow up. I'm not babysitting anyone with advanced config-file only options. - tomoko: added new adaptive windowed mode - when enabled, the window will shrink to eliminate any black borders when loading a game or changing video settings. The window will not reposition itself. - tomoko: added new adaptive fullscreen mode - when enabled, the integral scaling will be disabled for fullscreen mode, forcing the video to fill at least one direction of the video monitor completely. I expect we will be bikeshedding for the next month on how to describe the new video options, where they should appear in the GUI, changes people want, etc ... but suffice to say, I'm happy with the functionality, so I don't intend to make changes to -what- things do, but I will entertain better ways to name things.
2017-07-06 08:29:12 +00:00
byte |= pattern[!bank << 5 | addr << 1 | 0] << 4;
byte |= pattern[!bank << 5 | addr << 1 | 1] << 0;
return byte;
}
auto APU::Wave::writeram(uint addr, uint8 byte) -> void {
Update to v103r09 release. byuu says: Changelog: - gba/apu: fixed wave RAM nibble ordering (fixes audio in Castlevania, PocketNES) - emulator: restructured video information to just a single videoResolution() → VideoResolution function - returns "projected size" (between 160x144 and 320x240) - "internal buffer size" (up to 1280x480) - returns aspect correction multiplier that is to be applied to the width field - the value could be < 1.0 to handle systems with taller pixels; although higan doesn't emulate such a system - tomoko: all calculations for scaling and overscan masking are done by the GUI now - tomoko: aspect correction can be enabled in either windowed or fullscreen mode separately; moved to Video settings panel - tomoko: video scaling multipliers (against 320x240) can now me modified from the default (2,3,4) via the configuration file - use this as a really barebones way of supporting high DPI monitors; although the GUI elements won't scale nicely - if you set a value less than two, or greater than your resolution divided by 320x240, it's your own fault when things blow up. I'm not babysitting anyone with advanced config-file only options. - tomoko: added new adaptive windowed mode - when enabled, the window will shrink to eliminate any black borders when loading a game or changing video settings. The window will not reposition itself. - tomoko: added new adaptive fullscreen mode - when enabled, the integral scaling will be disabled for fullscreen mode, forcing the video to fill at least one direction of the video monitor completely. I expect we will be bikeshedding for the next month on how to describe the new video options, where they should appear in the GUI, changes people want, etc ... but suffice to say, I'm happy with the functionality, so I don't intend to make changes to -what- things do, but I will entertain better ways to name things.
2017-07-06 08:29:12 +00:00
pattern[!bank << 5 | addr << 1 | 0] = byte >> 4;
pattern[!bank << 5 | addr << 1 | 1] = byte >> 0;
}
auto APU::Wave::power() -> void {
mode = 0;
bank = 0;
dacenable = 0;
length = 0;
volume = 0;
frequency = 0;
counter = 0;
initialize = 0;
for(auto& sample : pattern) sample = 0;
enable = 0;
output = 0;
patternaddr = 0;
patternbank = 0;
patternsample = 0;
period = 0;
}