2015-11-16 08:38:05 +00:00
|
|
|
auto APU::Wave::run() -> void {
|
2012-04-06 04:29:50 +00:00
|
|
|
if(period && --period == 0) {
|
2013-12-10 12:12:54 +00:00
|
|
|
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++];
|
2012-04-06 04:29:50 +00:00
|
|
|
if(patternaddr == 0) patternbank ^= mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
output = patternsample;
|
2015-11-16 08:38:05 +00:00
|
|
|
static uint multiplier[] = {0, 4, 2, 1, 3, 3, 3, 3};
|
2012-04-07 08:17:49 +00:00
|
|
|
output = (output * multiplier[volume]) / 4;
|
2012-04-06 04:29:50 +00:00
|
|
|
if(enable == false) output = 0;
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto APU::Wave::clocklength() -> void {
|
2012-04-06 04:29:50 +00:00
|
|
|
if(enable && counter) {
|
|
|
|
if(++length == 0) enable = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto APU::Wave::read(uint addr) const -> uint8 {
|
2012-04-06 04:29:50 +00:00
|
|
|
switch(addr) {
|
|
|
|
case 0: return (mode << 5) | (bank << 6) | (dacenable << 7);
|
2015-11-14 00:52:51 +00:00
|
|
|
case 1: return 0;
|
2012-04-06 04:29:50 +00:00
|
|
|
case 2: return (volume << 5);
|
2015-11-14 00:52:51 +00:00
|
|
|
case 3: return 0;
|
|
|
|
case 4: return (counter << 6);
|
2012-04-06 04:29:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto APU::Wave::write(uint addr, uint8 byte) -> void {
|
2012-04-06 04:29:50 +00:00
|
|
|
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;
|
2013-12-10 12:12:54 +00:00
|
|
|
period = 1 * (2048 - frequency);
|
2012-04-06 04:29:50 +00:00
|
|
|
patternaddr = 0;
|
|
|
|
patternbank = mode ? (uint1)0 : bank;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto APU::Wave::readram(uint addr) const -> uint8 {
|
2012-04-06 04:29:50 +00:00
|
|
|
uint8 byte = 0;
|
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
|
|
|
byte |= pattern[!bank << 5 | addr << 1 | 0] << 0;
|
|
|
|
byte |= pattern[!bank << 5 | addr << 1 | 1] << 4;
|
2012-04-06 04:29:50 +00:00
|
|
|
return byte;
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto APU::Wave::writeram(uint addr, uint8 byte) -> void {
|
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
|
|
|
pattern[!bank << 5 | addr << 1 | 0] = byte >> 0;
|
|
|
|
pattern[!bank << 5 | addr << 1 | 1] = byte >> 4;
|
2012-04-06 04:29:50 +00:00
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto APU::Wave::power() -> void {
|
2012-04-06 04:29:50 +00:00
|
|
|
mode = 0;
|
|
|
|
bank = 0;
|
|
|
|
dacenable = 0;
|
|
|
|
length = 0;
|
|
|
|
volume = 0;
|
|
|
|
frequency = 0;
|
|
|
|
counter = 0;
|
|
|
|
initialize = 0;
|
2013-05-05 09:21:30 +00:00
|
|
|
for(auto& sample : pattern) sample = 0;
|
2012-04-06 04:29:50 +00:00
|
|
|
enable = 0;
|
|
|
|
output = 0;
|
|
|
|
patternaddr = 0;
|
|
|
|
patternbank = 0;
|
|
|
|
patternsample = 0;
|
|
|
|
period = 0;
|
|
|
|
}
|