mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 07:02:27 +01:00
byuu says: Changelog: - PCE: emulated PSG volume controls (vastly enhances audio quality) - PCE: emulated PSG noise as a square wave (somewhat enhances audio quality) - PCE: added save state support (currently broken and deadlocks the emulator though) Thankfully, MAME had some rather easy to read code on how the volume adjustment works, which they apparently ripped out of expired patents. Hooray! The two remaining sound issues are: 1. the random number generator for the noise channel is definitely not hardware accurate. But it won't affect the sound quality at all. You'd only be able to tell the difference by looking at hex bytes of a stream rip. 2. I have no clue how to emulate the LFO (frequency modulation). A comment in MAME's code (they also don't emulate it) advises that they aren't aware of any games that even use it. But I'm there has to be at least one? Given LFO not being used, and the RNG not really mattering all that much ... the sound's pretty close to perfect now.
72 lines
1.3 KiB
C++
72 lines
1.3 KiB
C++
//Hudson Soft HuC6280
|
|
|
|
struct CPU : Processor::HuC6280, Thread {
|
|
static auto Enter() -> void;
|
|
auto main() -> void;
|
|
auto step(uint clocks) -> void override;
|
|
auto power() -> void;
|
|
auto lastCycle() -> void override;
|
|
|
|
//memory.cpp
|
|
auto load() -> void;
|
|
auto save() -> void;
|
|
|
|
//io.cpp
|
|
auto read(uint8 bank, uint13 addr) -> uint8 override;
|
|
auto write(uint8 bank, uint13 addr, uint8 data) -> void override;
|
|
auto store(uint2 addr, uint8 data) -> void override;
|
|
|
|
//timer.cpp
|
|
auto timerStep(uint clocks) -> void;
|
|
|
|
//serialization.cpp
|
|
auto serialize(serializer&) -> void;
|
|
|
|
vector<Thread*> peripherals;
|
|
|
|
private:
|
|
uint8 ram[0x8000]; //PC Engine = 8KB, SuperGrafx = 32KB
|
|
uint8 bram[0x800]; //PC Engine CD-ROM Backup RAM = 2KB
|
|
|
|
struct IRQ {
|
|
//irq.cpp
|
|
auto pending() const -> bool;
|
|
auto vector() const -> uint16;
|
|
auto poll() -> void;
|
|
|
|
private:
|
|
bool disableExternal;
|
|
bool disableVDC;
|
|
bool disableTimer;
|
|
|
|
bool pendingIRQ;
|
|
uint16 pendingVector;
|
|
|
|
friend class CPU;
|
|
} irq;
|
|
|
|
struct Timer {
|
|
inline auto irqLine() const { return line; }
|
|
|
|
//timer.cpp
|
|
auto start() -> void;
|
|
auto step(uint clocks) -> void;
|
|
|
|
private:
|
|
bool enable;
|
|
uint7 latch;
|
|
uint7 value;
|
|
uint clock;
|
|
|
|
bool line;
|
|
|
|
friend class CPU;
|
|
} timer;
|
|
|
|
struct IO {
|
|
uint8 mdr;
|
|
} io;
|
|
};
|
|
|
|
extern CPU cpu;
|