2012-03-23 10:43:39 +00:00
|
|
|
struct APU : Thread {
|
Update to v098r06 release.
byuu says:
Changelog:
- emulation cores now refresh video from host thread instead of
cothreads (fix AMD crash)
- SFC: fixed another bug with leap year months in SharpRTC emulation
- SFC: cleaned up camelCase on function names for
armdsp,epsonrtc,hitachidsp,mcc,nss,sharprtc classes
- GB: added MBC1M emulation (requires manually setting mapper=MBC1M in
manifest.bml for now, sorry)
- audio: implemented Emulator::Audio mixer and effects processor
- audio: implemented Emulator::Stream interface
- it is now possible to have more than two audio streams: eg SNES
+ SGB + MSU1 + Voicer-Kun (eventually)
- audio: added reverb delay + reverb level settings; exposed balance
configuration in UI
- video: reworked palette generation to re-enable saturation, gamma,
luminance adjustments
- higan/emulator.cpp is gone since there was nothing left in it
I know you guys are going to say the color adjust/balance/reverb stuff
is pointless. And indeed it mostly is. But I like the idea of allowing
some fun special effects and configurability that isn't system-wide.
Note: there seems to be some kind of added audio lag in the SGB
emulation now, and I don't really understand why. The code should be
effectively identical to what I had before. The only main thing is that
I'm sampling things to 48000hz instead of 32040hz before mixing. There's
no point where I'm intentionally introducing added latency though. I'm
kind of stumped, so if anyone wouldn't mind taking a look at it, it'd be
much appreciated :/
I don't have an MSU1 test ROM, but the latency issue may affect MSU1 as
well, and that would be very bad.
2016-04-22 13:35:51 +00:00
|
|
|
shared_pointer<Emulator::Stream> stream;
|
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
APU();
|
2011-09-12 10:30:44 +00:00
|
|
|
|
2016-02-09 11:51:12 +00:00
|
|
|
static auto Enter() -> void;
|
2015-12-05 05:44:49 +00:00
|
|
|
auto main() -> void;
|
|
|
|
auto tick() -> void;
|
2016-06-27 13:07:57 +00:00
|
|
|
auto setIRQ() -> void;
|
|
|
|
auto setSample(int16 sample) -> void;
|
2011-09-12 10:30:44 +00:00
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
auto power() -> void;
|
|
|
|
auto reset() -> void;
|
2011-09-12 10:30:44 +00:00
|
|
|
|
Update to v099r04 release.
byuu says:
Changelog:
- lots of code cleanups to processor/r6502 (the switch.cpp file is only
halfway done ...)
- lots of code cleanups to fc/cpu
- removed fc/input
- implemented fc/controller
hex_usr, you may not like this, but I want to keep the controller port
and expansion port interface separate, like I do with the SNES. I realize
the NES' is used more for controllers, and the SNES' more for hardware
expansions, but ... they're not compatible pinouts and you can't really
connect one to the other.
Right now, I've only implemented the controller portion. I'll have to
get to the peripheral portion later.
Also, the gamepad implementation there now may be wrong. It's based off
the Super Famicom version obviously. I'm not sure if the Famicom has
different behavior with latching $4016 writes, or not. But, it works in
Mega Man II, so it's a start.
Everyone, be sure to remap your controls, and then set port 1 -> gamepad
after loading your first Famicom game with the new WIP.
2016-06-18 06:04:32 +00:00
|
|
|
auto readIO(uint16 addr) -> uint8;
|
|
|
|
auto writeIO(uint16 addr, uint8 data) -> void;
|
2015-12-05 05:44:49 +00:00
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
2011-09-15 12:33:26 +00:00
|
|
|
|
2011-09-26 11:38:57 +00:00
|
|
|
struct Filter {
|
2016-06-27 13:07:57 +00:00
|
|
|
auto runHipassStrong(int sample) -> int;
|
|
|
|
auto runHipassWeak(int sample) -> int;
|
|
|
|
auto runLopass(int sample) -> int;
|
2015-12-05 05:44:49 +00:00
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
enum : int { HiPassStrong = 225574, HiPassWeak = 57593, LoPass = 86322413 };
|
2011-09-26 11:38:57 +00:00
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
int64 hipassStrong;
|
|
|
|
int64 hipassWeak;
|
2011-09-26 11:38:57 +00:00
|
|
|
int64 lopass;
|
2015-12-05 05:44:49 +00:00
|
|
|
};
|
2011-09-26 11:38:57 +00:00
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
struct Envelope {
|
|
|
|
auto volume() const -> uint;
|
|
|
|
auto clock() -> void;
|
|
|
|
|
|
|
|
auto power() -> void;
|
|
|
|
auto reset() -> void;
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
uint4 speed;
|
|
|
|
bool useSpeedAsVolume;
|
|
|
|
bool loopMode;
|
|
|
|
|
|
|
|
bool reloadDecay;
|
|
|
|
uint8 decayCounter;
|
|
|
|
uint4 decayVolume;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Sweep {
|
|
|
|
auto checkPeriod() -> bool;
|
|
|
|
auto clock(uint channel) -> void;
|
|
|
|
|
|
|
|
auto power() -> void;
|
|
|
|
auto reset() -> void;
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
uint8 shift;
|
|
|
|
bool decrement;
|
|
|
|
uint3 period;
|
|
|
|
uint8 counter;
|
|
|
|
bool enable;
|
|
|
|
bool reload;
|
|
|
|
uint11 pulsePeriod;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Pulse {
|
|
|
|
auto clockLength() -> void;
|
|
|
|
auto checkPeriod() -> bool;
|
|
|
|
auto clock() -> uint8;
|
|
|
|
|
|
|
|
auto power() -> void;
|
|
|
|
auto reset() -> void;
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
uint lengthCounter;
|
|
|
|
|
|
|
|
Envelope envelope;
|
|
|
|
Sweep sweep;
|
|
|
|
|
|
|
|
uint2 duty;
|
|
|
|
uint3 dutyCounter;
|
|
|
|
|
|
|
|
uint11 period;
|
|
|
|
uint periodCounter;
|
|
|
|
} pulse[2];
|
|
|
|
|
|
|
|
struct Triangle {
|
|
|
|
auto clockLength() -> void;
|
|
|
|
auto clockLinearLength() -> void;
|
|
|
|
auto clock() -> uint8;
|
|
|
|
|
|
|
|
auto power() -> void;
|
|
|
|
auto reset() -> void;
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
uint lengthCounter;
|
|
|
|
|
|
|
|
uint8 linearLength;
|
|
|
|
bool haltLengthCounter;
|
|
|
|
|
|
|
|
uint11 period;
|
|
|
|
uint periodCounter;
|
|
|
|
|
|
|
|
uint5 stepCounter;
|
|
|
|
uint8 linearLengthCounter;
|
|
|
|
bool reloadLinear;
|
|
|
|
} triangle;
|
|
|
|
|
|
|
|
struct Noise {
|
|
|
|
auto clockLength() -> void;
|
|
|
|
auto clock() -> uint8;
|
|
|
|
|
|
|
|
auto power() -> void;
|
|
|
|
auto reset() -> void;
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
uint lengthCounter;
|
|
|
|
|
|
|
|
Envelope envelope;
|
|
|
|
|
|
|
|
uint4 period;
|
|
|
|
uint periodCounter;
|
|
|
|
|
|
|
|
bool shortMode;
|
|
|
|
uint15 lfsr;
|
|
|
|
} noise;
|
|
|
|
|
|
|
|
struct DMC {
|
|
|
|
auto start() -> void;
|
|
|
|
auto stop() -> void;
|
|
|
|
auto clock() -> uint8;
|
|
|
|
|
|
|
|
auto power() -> void;
|
|
|
|
auto reset() -> void;
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
uint lengthCounter;
|
|
|
|
bool irqPending;
|
|
|
|
|
|
|
|
uint4 period;
|
|
|
|
uint periodCounter;
|
|
|
|
|
|
|
|
bool irqEnable;
|
|
|
|
bool loopMode;
|
|
|
|
|
|
|
|
uint8 dacLatch;
|
|
|
|
uint8 addrLatch;
|
|
|
|
uint8 lengthLatch;
|
|
|
|
|
|
|
|
uint15 readAddr;
|
|
|
|
uint dmaDelayCounter;
|
|
|
|
|
|
|
|
uint3 bitCounter;
|
|
|
|
bool dmaBufferValid;
|
|
|
|
uint8 dmaBuffer;
|
|
|
|
|
|
|
|
bool sampleValid;
|
|
|
|
uint8 sample;
|
|
|
|
} dmc;
|
2011-09-15 12:33:26 +00:00
|
|
|
|
|
|
|
struct FrameCounter {
|
2015-12-05 05:44:49 +00:00
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
enum : uint { NtscPeriod = 14915 }; //~(21.477MHz / 6 / 240hz)
|
2011-09-16 11:44:07 +00:00
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
bool irqPending;
|
2011-09-16 11:44:07 +00:00
|
|
|
|
2011-09-15 12:33:26 +00:00
|
|
|
uint2 mode;
|
|
|
|
uint2 counter;
|
2015-12-05 05:44:49 +00:00
|
|
|
int divider;
|
|
|
|
};
|
2011-09-23 11:13:57 +00:00
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
auto clockFrameCounter() -> void;
|
|
|
|
auto clockFrameCounterDivider() -> void;
|
2011-09-15 12:33:26 +00:00
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
Filter filter;
|
|
|
|
FrameCounter frame;
|
2011-09-15 12:33:26 +00:00
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
uint8 enabledChannels;
|
|
|
|
int16 cartridgeSample;
|
2011-09-15 12:33:26 +00:00
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
int16 pulseDAC[32];
|
|
|
|
int16 dmcTriangleNoiseDAC[128][16][16];
|
2011-09-15 12:33:26 +00:00
|
|
|
|
2016-06-27 13:07:57 +00:00
|
|
|
static const uint8 lengthCounterTable[32];
|
|
|
|
static const uint16 dmcPeriodTableNTSC[16];
|
|
|
|
static const uint16 dmcPeriodTablePAL[16];
|
|
|
|
static const uint16 noisePeriodTableNTSC[16];
|
|
|
|
static const uint16 noisePeriodTablePAL[16];
|
2011-09-12 10:30:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern APU apu;
|