Commit bdc100e1 authored by Screwtape's avatar Screwtape

Update to v102r02 release.

byuu says:

Changelog:

  - I caved on the `samples[] = {0.0}` thing, but I'm very unhappy about it
      - if it's really invalid C++, then GCC needs to stop accepting it
        in strict `-std=c++14` mode
  - Emulator::Interface::Information::resettable is gone
  - Emulator::Interface::reset() is gone
  - FC, SFC, MD cores updated to remove soft reset behavior
  - split GameBoy::Interface into GameBoyInterface,
    GameBoyColorInterface
  - split WonderSwan::Interface into WonderSwanInterface,
    WonderSwanColorInterface
  - PCE: fixed off-by-one scanline error [hex_usr]
  - PCE: temporary hack to prevent crashing when VDS is set to < 2
  - hiro: Cocoa: removed (u)int(#) constants; converted (u)int(#)
    types to (u)int_(#)t types
  - icarus: replaced usage of unique with strip instead (so we don't
    mess up frameworks on macOS)
  - libco: added macOS-specific section marker [Ryphecha]

So ... the major news this time is the removal of the soft reset
behavior. This is a major!! change that results in a 100KiB diff file,
and it's very prone to accidental mistakes!! If anyone is up for
testing, or even better -- looking over the code changes between v102r01
and v102r02 and looking for any issues, please do so. Ideally we'll want
to test every NES mapper type and every SNES coprocessor type by loading
said games and power cycling to make sure the games are all cleanly
resetting. It's too big of a change for me to cover there not being any
issues on my own, but this is truly critical code, so yeah ... please
help if you can.

We technically lose a bit of hardware documentation here. The soft reset
events do all kinds of interesting things in all kinds of different
chips -- or at least they do on the SNES. This is obviously not ideal.
But in the process of removing these portions of code, I found a few
mistakes I had made previously. It simplifies resetting the system state
a lot when not trying to have all the power() functions call the reset()
functions to share partial functionality.

In the future, the goal will be to come up with a way to add back in the
soft reset behavior via keyboard binding as with the Master System core.
What's going to have to happen is that the key binding will have to send
a "reset pulse" to every emulated chip, and those chips are going to
have to act independently to power() instead of reusing functionality.
We'll get there eventually, but there's many things of vastly greater
importance to work on right now, so it'll be a while. The information
isn't lost ... we'll just have to pull it out of v102 when we are ready.

Note that I left the SNES reset vector simulation code in, even though
it's not possible to trigger, for the time being.

Also ... the Super Game Boy core is still disconnected. To be honest, it
totally slipped my mind when I released v102 that it wasn't connected
again yet. This one's going to be pretty tricky to be honest. I'm
thinking about making a third GameBoy::Interface class just for SGB, and
coming up with some way of bypassing platform-> calls when in this
mode.
parent c40e9754
......@@ -56,13 +56,15 @@ auto Audio::process() -> void {
if(!stream->pending()) return;
}
double samples[channels] = {0.0};
double samples[channels];
for(auto& sample : samples) sample = 0.0;
for(auto& stream : streams) {
double buffer[16];
uint length = stream->read(buffer), offset = 0;
for(auto c : range(channels)) {
samples[c] += buffer[offset];
for(auto& sample : samples) {
sample += buffer[offset];
if(++offset >= length) offset = 0;
}
}
......
......@@ -12,7 +12,7 @@ using namespace nall;
namespace Emulator {
static const string Name = "higan";
static const string Version = "102.01";
static const string Version = "102.02";
static const string Author = "byuu";
static const string License = "GPLv3";
static const string Website = "http://byuu.org/";
......
......@@ -19,7 +19,6 @@ struct Interface {
string manufacturer;
string name;
bool overscan;
bool resettable;
struct Capability {
bool states;
bool cheats;
......@@ -75,7 +74,6 @@ struct Interface {
//system interface
virtual auto connect(uint port, uint device) -> void {}
virtual auto power() -> void {}
virtual auto reset() -> void {}
virtual auto run() -> void {}
//time functions
......
......@@ -76,6 +76,9 @@ auto APU::setSample(int16 sample) -> void {
}
auto APU::power() -> void {
create(APU::Enter, system.colorburst() * 6.0);
stream = Emulator::audio.createStream(1, system.colorburst() / 2.0);
filter.hipassStrong = 0;
filter.hipassWeak = 0;
filter.lopass = 0;
......@@ -85,17 +88,6 @@ auto APU::power() -> void {
triangle.power();
noise.power();
dmc.power();
}
auto APU::reset() -> void {
create(APU::Enter, system.colorburst() * 6.0);
stream = Emulator::audio.createStream(1, system.colorburst() / 2.0);
pulse[0].reset();
pulse[1].reset();
triangle.reset();
noise.reset();
dmc.reset();
frame.irqPending = 0;
......
......@@ -10,7 +10,6 @@ struct APU : Thread {
auto setSample(int16 sample) -> void;
auto power() -> void;
auto reset() -> void;
auto readIO(uint16 addr) -> uint8;
auto writeIO(uint16 addr, uint8 data) -> void;
......@@ -36,7 +35,6 @@ struct APU : Thread {
auto clock() -> void;
auto power() -> void;
auto reset() -> void;
auto serialize(serializer&) -> void;
......@@ -54,7 +52,6 @@ struct APU : Thread {
auto clock(uint channel) -> void;
auto power() -> void;
auto reset() -> void;
auto serialize(serializer&) -> void;
......@@ -73,7 +70,6 @@ struct APU : Thread {
auto clock() -> uint8;
auto power() -> void;
auto reset() -> void;
auto serialize(serializer&) -> void;
......@@ -95,7 +91,6 @@ struct APU : Thread {
auto clock() -> uint8;
auto power() -> void;
auto reset() -> void;
auto serialize(serializer&) -> void;
......@@ -117,7 +112,6 @@ struct APU : Thread {
auto clock() -> uint8;
auto power() -> void;
auto reset() -> void;
auto serialize(serializer&) -> void;
......@@ -138,7 +132,6 @@ struct APU : Thread {
auto clock() -> uint8;
auto power() -> void;
auto reset() -> void;
auto serialize(serializer&) -> void;
......
......@@ -69,9 +69,6 @@ auto APU::DMC::clock() -> uint8 {
}
auto APU::DMC::power() -> void {
}
auto APU::DMC::reset() -> void {
lengthCounter = 0;
irqPending = 0;
......
......@@ -17,9 +17,6 @@ auto APU::Envelope::clock() -> void {
}
auto APU::Envelope::power() -> void {
}
auto APU::Envelope::reset() -> void {
speed = 0;
useSpeedAsVolume = 0;
loopMode = 0;
......
......@@ -26,9 +26,6 @@ auto APU::Noise::clock() -> uint8 {
}
auto APU::Noise::power() -> void {
}
auto APU::Noise::reset() -> void {
lengthCounter = 0;
envelope.speed = 0;
......
......@@ -23,11 +23,6 @@ auto APU::Pulse::clock() -> uint8 {
auto APU::Pulse::power() -> void {
envelope.power();
sweep.power();
}
auto APU::Pulse::reset() -> void {
envelope.reset();
sweep.reset();
lengthCounter = 0;
......
......@@ -38,6 +38,3 @@ auto APU::Sweep::power() -> void {
reload = 0;
pulsePeriod = 0;
}
auto APU::Sweep::reset() -> void {
}
......@@ -28,10 +28,6 @@ auto APU::Triangle::clock() -> uint8 {
}
auto APU::Triangle::power() -> void {
reset();
}
auto APU::Triangle::reset() -> void {
lengthCounter = 0;
linearLength = 0;
......
......@@ -131,9 +131,6 @@ auto Board::writeCHR(uint addr, uint8 data) -> void {
auto Board::power() -> void {
}
auto Board::reset() -> void {
}
auto Board::serialize(serializer& s) -> void {
if(prgram.size) s.array(prgram.data, prgram.size);
if(chrram.size) s.array(chrram.data, chrram.size);
......
......@@ -32,7 +32,6 @@ struct Board {
virtual inline auto scanline(uint y) -> void {}
virtual auto power() -> void;
virtual auto reset() -> void;
virtual auto serialize(serializer&) -> void;
......
......@@ -25,10 +25,6 @@ struct KonamiVRC1 : Board {
vrc1.power();
}
auto reset() -> void {
vrc1.reset();
}
auto serialize(serializer& s) -> void {
Board::serialize(s);
vrc1.serialize(s);
......
......@@ -35,10 +35,6 @@ struct KonamiVRC2 : Board {
vrc2.power();
}
auto reset() -> void {
vrc2.reset();
}
auto serialize(serializer& s) -> void {
Board::serialize(s);
vrc2.serialize(s);
......
......@@ -38,10 +38,6 @@ struct KonamiVRC3 : Board {
vrc3.power();
}
auto reset() -> void {
vrc3.reset();
}
auto serialize(serializer& s) -> void {
Board::serialize(s);
vrc3.serialize(s);
......
......@@ -39,10 +39,6 @@ struct KonamiVRC4 : Board {
vrc4.power();
}
auto reset() -> void {
vrc4.reset();
}
auto serialize(serializer& s) -> void {
Board::serialize(s);
vrc4.serialize(s);
......
......@@ -34,7 +34,6 @@ struct KonamiVRC6 : Board {
auto main() -> void { vrc6.main(); }
auto power() -> void { vrc6.power(); }
auto reset() -> void { vrc6.reset(); }
VRC6 vrc6;
};
......@@ -32,10 +32,6 @@ struct KonamiVRC7 : Board {
vrc7.power();
}
auto reset() -> void {
vrc7.reset();
}
auto serialize(serializer& s) -> void {
Board::serialize(s);
vrc7.serialize(s);
......
......@@ -30,9 +30,6 @@ struct NES_AxROM : Board {
}
auto power() -> void {
}
auto reset() -> void {
prgBank = 0x0f;
mirrorSelect = 0;
}
......
......@@ -31,9 +31,6 @@ struct NES_BNROM : Board {
}
auto power() -> void {
}
auto reset() -> void {
prgBank = 0;
}
......
......@@ -33,9 +33,6 @@ struct NES_CNROM : Board {
}
auto power() -> void {
}
auto reset() -> void {
chrBank = 0;
}
......
......@@ -31,10 +31,6 @@ struct NES_ExROM : Board {
mmc5.power();
}
auto reset() -> void {
mmc5.reset();
}
auto serialize(serializer& s) -> void {
Board::serialize(s);
mmc5.serialize(s);
......
......@@ -52,9 +52,6 @@ struct NES_FxROM : Board {
}
auto power() -> void {
}
auto reset() -> void {
prgBank = 0;
chrBank[0][0] = 0;
chrBank[0][1] = 0;
......
......@@ -37,9 +37,6 @@ struct NES_GxROM : Board {
}
auto power() -> void {
}
auto reset() -> void {
prgBank = 0;
chrBank = 0;
}
......
......@@ -33,10 +33,6 @@ struct NES_HKROM : Board {
mmc6.power();
}
auto reset() -> void {
mmc6.reset();
}
auto serialize(serializer& s) -> void {
Board::serialize(s);
mmc6.serialize(s);
......
......@@ -31,6 +31,9 @@ struct NES_NROM : Board {
if(chrram.size) return chrram.write(addr, data);
}
auto power() -> void {
}
auto serialize(serializer& s) -> void {
Board::serialize(s);
}
......
......@@ -58,9 +58,6 @@ struct NES_PxROM : Board {
}
auto power() -> void {
}
auto reset() -> void {
prgBank = 0;
chrBank[0][0] = 0;
chrBank[0][1] = 0;
......
......@@ -61,10 +61,6 @@ struct NES_SxROM : Board {
mmc1.power();
}
auto reset() -> void {
mmc1.reset();
}
auto serialize(serializer& s) -> void {
Board::serialize(s);
mmc1.serialize(s);
......
......@@ -34,10 +34,6 @@ struct NES_TxROM : Board {
mmc3.power();
}
auto reset() -> void {
mmc3.reset();
}
auto serialize(serializer& s) -> void {
Board::serialize(s);
mmc3.serialize(s);
......
......@@ -33,9 +33,6 @@ struct NES_UxROM : Board {
}
auto power() -> void {
}
auto reset() -> void {
prgBank = 0;
}
......
......@@ -14,7 +14,7 @@ struct Sunsoft5B : Board {
if(disable) output = 0;
}
auto reset() -> void {
auto power() -> void {
disable = 1;
frequency = 1;
volume = 0;
......@@ -164,13 +164,11 @@ struct Sunsoft5B : Board {
}
auto power() -> void {
for(signed n : range(16)) {
for(int n : range(16)) {
double volume = 1.0 / pow(2, 1.0 / 2 * (15 - n));
dac[n] = volume * 8192.0;
}
}
auto reset() -> void {
mmuPort = 0;
apuPort = 0;
......@@ -181,9 +179,9 @@ struct Sunsoft5B : Board {
irqCounterEnable = 0;
irqCounter = 0;
pulse[0].reset();
pulse[1].reset();
pulse[2].reset();
pulse[0].power();
pulse[1].power();
pulse[2].power();
}
auto serialize(serializer& s) -> void {
......
......@@ -45,12 +45,8 @@ auto Cartridge::unload() -> void {
}
auto Cartridge::power() -> void {
board->power();
}
auto Cartridge::reset() -> void {
create(Cartridge::Enter, system.colorburst() * 6.0);
board->reset();
board->power();
}
auto Cartridge::readPRG(uint addr) -> uint8 {
......
......@@ -15,7 +15,6 @@ struct Cartridge : Thread {
auto unload() -> void;
auto power() -> void;
auto reset() -> void;
auto serialize(serializer&) -> void;
......
......@@ -74,9 +74,6 @@ struct MMC1 : Chip {
}
auto power() -> void {
}
auto reset() -> void {
writedelay = 0;
shiftaddr = 0;
shiftdata = 0;
......
......@@ -119,9 +119,6 @@ struct MMC3 : Chip {
}
auto power() -> void {
}
auto reset() -> void {
chrMode = 0;
prgMode = 0;
bankSelect = 0;
......
......@@ -335,9 +335,6 @@ struct MMC5 : Chip {
}
auto power() -> void {
}
auto reset() -> void {
for(auto& n : exram) n = 0xff;
prgMode = 3;
......
......@@ -133,9 +133,6 @@ struct MMC6 : Chip {
}
auto power() -> void {
}
auto reset() -> void {
chrMode = 0;
prgMode = 0;
ramEnable = 0;
......
......@@ -55,9 +55,6 @@ struct VRC1 : Chip {
}
auto power() -> void {
}
auto reset() -> void {
for(auto& n : prgBank) n = 0;
for(auto& n : chrBankLo) n = 0;
for(auto& n : chrBankHi) n = 0;
......
......@@ -85,9 +85,6 @@ struct VRC2 : Chip {
}
auto power() -> void {
}
auto reset() -> void {
for(auto& n : prgBank) n = 0;
for(auto& n : chrBank) n = 0;
mirror = 0;
......
......@@ -55,9 +55,6 @@ struct VRC3 : Chip {
}
auto power() -> void {
}
auto reset() -> void {
prgBank = 0;
irqMode = 0;
irqEnable = 0;
......
......@@ -126,9 +126,6 @@ struct VRC4 : Chip {
}
auto power() -> void {
}
auto reset() -> void {
prgMode = 0;
for(auto& n : prgBank) n = 0;
mirror = 0;
......
......@@ -227,9 +227,6 @@ struct VRC6 : Chip {
}
auto power() -> void {
}
auto reset() -> void {
prgBank[0] = 0;
prgBank[1] = 0;
chrBank[0] = 0;
......
......@@ -99,9 +99,6 @@ struct VRC7 : Chip {
}
auto power() -> void {
}
auto reset() -> void {
for(auto& n : prgBank) n = 0;
for(auto& n : chrBank) n = 0;
mirror = 0;
......
......@@ -26,17 +26,13 @@ auto CPU::step(uint clocks) -> void {
auto CPU::power() -> void {
R6502::power();
create(CPU::Enter, system.colorburst() * 6.0);
for(auto addr : range(0x0800)) ram[addr] = 0xff;
ram[0x0008] = 0xf7;
ram[0x0009] = 0xef;
ram[0x000a] = 0xdf;
ram[0x000f] = 0xbf;
}
auto CPU::reset() -> void {
R6502::reset();
create(CPU::Enter, system.colorburst() * 6.0);
regs.pc = bus.read(0xfffc) << 0;
regs.pc |= bus.read(0xfffd) << 8;
......
......@@ -4,7 +4,6 @@ struct CPU : Processor::R6502, Thread {
auto step(uint clocks) -> void;
auto power() -> void;
auto reset() -> void;
//memory.cpp
auto readRAM(uint11 addr) -> uint8;
......
......@@ -8,7 +8,6 @@ Interface::Interface() {
information.manufacturer = "Nintendo";
information.name = "Famicom";
information.overscan = true;
information.resettable = true;
information.capability.states = true;
information.capability.cheats = true;
......@@ -151,10 +150,6 @@ auto Interface::power() -> void {
system.power();
}
auto Interface::reset() -> void {
system.reset();
}
auto Interface::run() -> void {
system.run();
}
......
......@@ -42,7 +42,6 @@ struct Interface : Emulator::Interface {
auto connect(uint port, uint device) -> void override;
auto power() -> void override;
auto reset() -> void override;
auto run() -> void override;
auto serialize() -> serializer override;
......
......@@ -53,9 +53,6 @@ auto PPU::refresh() -> void {
}
auto PPU::power() -> void {
}
auto PPU::reset() -> void {
create(PPU::Enter, system.colorburst() * 6.0);
memory::fill(&io, sizeof(IO));
......
......@@ -8,7 +8,6 @@ struct PPU : Thread {
auto refresh() -> void;
auto power() -> void;
auto reset() -> void;
//memory.cpp
auto readCIRAM(uint11 addr) -> uint8;
......
......@@ -49,14 +49,6 @@ auto System::unload() -> void {
}
auto System::power() -> void {
cartridge.power();
cpu.power();
apu.power();
ppu.power();
reset();
}
auto System::reset() -> void {
Emulator::video.reset();
Emulator::video.setInterface(interface);
configureVideoPalette();
......@@ -66,10 +58,10 @@ auto System::reset() -> void {