2011-02-02 10:37:31 +00:00
|
|
|
#ifdef APU_CPP
|
|
|
|
|
2011-09-05 03:48:23 +00:00
|
|
|
bool APU::Noise::dac_enable() {
|
|
|
|
return (envelope_volume || envelope_direction);
|
|
|
|
}
|
|
|
|
|
2011-02-02 10:37:31 +00:00
|
|
|
void APU::Noise::run() {
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
if(period && --period == 0) {
|
|
|
|
period = divisor << frequency;
|
|
|
|
if(frequency < 14) {
|
|
|
|
bool bit = (lfsr ^ (lfsr >> 1)) & 1;
|
2011-08-18 13:58:27 +00:00
|
|
|
lfsr = (lfsr >> 1) ^ (bit << (narrow_lfsr ? 6 : 14));
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
}
|
2011-02-02 10:37:31 +00:00
|
|
|
}
|
|
|
|
|
Update to v075r09 release.
byuu says:
Ported phoenix/Windows and phoenix/GTK+ over to the new system. There
are some problems that need to be addressed:
- Windows ComboBox height setting needs widget creation height to
properly scale itself (make Widget::setGeometry virtual and override
ComboBox::setGeometry)
- Windows Canvas is completely broken
- GTK+ Canvas is slow as shit compared to Qt Canvas, probably nothing
I can do about it, have to do a very costly conversion because GTK+ is
stupid and uses BGR like Nintendo
- GTK+ listboxes are fucking insanely complicated to set up. Currently
I just split the second-half of creation to the setHeaderText call,
but when you don't call that, things explode
- I'm probably going to have to completely destroy and recreate
listboxes when changing the header text / column count
- Qt resize code is still impossible to get right, it's not letting me
size a window > 2/3rds of the screen size (it's in their docs)
- I swear, Qt is the most painful API in the world to move/size
windows with
- now that Window is separate, it really needs geometry() and
frameGeometry() as the two are quite different
- I need a way to toggle window resizability for fixed layouts, Qt is
once again going to be a nightmare as it lacks a way to do this other
than fixed layouts
- GTK+ currently explodes on bsnes, millions of console messages,
wonderful
- plenty more I'm forgetting
One bit of really cool/good news though: I made
Fixed/Horizontal/Vertical layouts external to phoenix itself. The code
is included for all targets so that it's always there and compiled into
one object, but the great news is that you can easily write your own
layout widgets and they'll work on all toolkits instantly.
That resize issue with bsnes was so simple it's annoying: my FixedLayout
container was repositioning on geometry updates. Made it only do it once
at creation like it should.
bsnes now has a fancy resize, grow the window and get black borders,
shrink it and the video shrinks with it. I plan to make it fancier with
constraint settings (center, scale, stretch). Basically I want to turn
the fullscreen setting into a general setting that also applies to
windowed scaling. I will probably turn the video scale X sizes into
regular items instead of radio boxes, so you can easily reset to a fixed
size whenever you want. Update bsnes to remember width,height geometry
as well and it should be quite nice.
2011-02-07 09:18:01 +00:00
|
|
|
uint4 sample = (lfsr & 1) ? 0 : volume;
|
2011-09-05 03:48:23 +00:00
|
|
|
if(enable == false) sample = 0;
|
2011-02-02 10:37:31 +00:00
|
|
|
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
output = (sample * 4369) - 32768;
|
|
|
|
}
|
|
|
|
|
|
|
|
void APU::Noise::clock_length() {
|
2011-09-05 03:48:23 +00:00
|
|
|
if(counter && length) {
|
|
|
|
if(--length == 0) enable = false;
|
|
|
|
}
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
}
|
2011-02-02 10:37:31 +00:00
|
|
|
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
void APU::Noise::clock_envelope() {
|
|
|
|
if(envelope_period && --envelope_period == 0) {
|
|
|
|
envelope_period = envelope_frequency;
|
2011-09-05 03:48:23 +00:00
|
|
|
if(envelope_period == 0) envelope_period = 8;
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
if(envelope_direction == 0 && volume > 0) volume--;
|
|
|
|
if(envelope_direction == 1 && volume < 15) volume++;
|
|
|
|
}
|
2011-02-02 10:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void APU::Noise::write(unsigned r, uint8 data) {
|
2011-09-05 03:48:23 +00:00
|
|
|
if(r == 1) { //$ff20 NR41
|
|
|
|
length = 64 - (data & 0x3f);
|
2011-02-02 10:37:31 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 03:48:23 +00:00
|
|
|
if(r == 2) { //$ff21 NR42
|
2011-02-02 10:37:31 +00:00
|
|
|
envelope_volume = data >> 4;
|
|
|
|
envelope_direction = data & 0x08;
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
envelope_frequency = data & 0x07;
|
2011-09-05 03:48:23 +00:00
|
|
|
if(dac_enable() == false) enable = false;
|
2011-02-02 10:37:31 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 03:48:23 +00:00
|
|
|
if(r == 3) { //$ff22 NR43
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
frequency = data >> 4;
|
|
|
|
narrow_lfsr = data & 0x08;
|
|
|
|
divisor = (data & 0x07) << 4;
|
|
|
|
if(divisor == 0) divisor = 8;
|
|
|
|
period = divisor << frequency;
|
2011-02-02 10:37:31 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 03:48:23 +00:00
|
|
|
if(r == 4) { //$ff34 NR44
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
bool initialize = data & 0x80;
|
2011-02-02 10:37:31 +00:00
|
|
|
counter = data & 0x40;
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
|
|
|
|
if(initialize) {
|
2011-09-05 03:48:23 +00:00
|
|
|
enable = dac_enable();
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
lfsr = ~0U;
|
|
|
|
envelope_period = envelope_frequency;
|
|
|
|
volume = envelope_volume;
|
2011-09-05 03:48:23 +00:00
|
|
|
if(length == 0) length = 64;
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
}
|
2011-02-02 10:37:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void APU::Noise::power() {
|
2011-09-05 03:48:23 +00:00
|
|
|
enable = 0;
|
|
|
|
|
2011-02-02 10:37:31 +00:00
|
|
|
envelope_volume = 0;
|
|
|
|
envelope_direction = 0;
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
envelope_frequency = 0;
|
|
|
|
frequency = 0;
|
|
|
|
narrow_lfsr = 0;
|
2011-02-02 10:37:31 +00:00
|
|
|
divisor = 0;
|
|
|
|
counter = 0;
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
|
|
|
|
output = 0;
|
|
|
|
length = 0;
|
|
|
|
envelope_period = 0;
|
|
|
|
volume = 0;
|
|
|
|
period = 0;
|
|
|
|
lfsr = 0;
|
2011-02-02 10:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void APU::Noise::serialize(serializer &s) {
|
2011-09-05 03:48:23 +00:00
|
|
|
s.integer(enable);
|
|
|
|
|
2011-02-02 10:37:31 +00:00
|
|
|
s.integer(envelope_volume);
|
|
|
|
s.integer(envelope_direction);
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
s.integer(envelope_frequency);
|
|
|
|
s.integer(frequency);
|
|
|
|
s.integer(narrow_lfsr);
|
2011-02-02 10:37:31 +00:00
|
|
|
s.integer(divisor);
|
|
|
|
s.integer(counter);
|
Update to v075r05 release.
byuu says:
Added Game Boy sound emulation, all four channels.
It's really, really, really bad. Plenty of bugs, I don't even know what
the fuck a high-pass filter is so that isn't there. Hermite resampling
from 4MHz down to 44KHz. But it's tolerable.
I don't understand what sweep is for at all, and I'm sure I have that
insane recursive reload behavior wrong.
This is pretty much my own design. I referenced blargg's gb snd emu,
blargg's older gb apu ref, Cydrak's APU core, that lousy gbdev wiki
article, the completely and utterly worthless pandocs, and received
nothing but bad and wrong information that just wasted my time from
But I managed to pull it off. It's also painfully slow, like 250fps on
my machine slow. Countless optimizations are possible.
2011-02-02 10:38:28 +00:00
|
|
|
|
|
|
|
s.integer(output);
|
|
|
|
s.integer(length);
|
|
|
|
s.integer(envelope_period);
|
|
|
|
s.integer(volume);
|
|
|
|
s.integer(period);
|
|
|
|
s.integer(lfsr);
|
2011-02-02 10:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|