Skip to content

Commit

Permalink
Update to v105r1 release.
Browse files Browse the repository at this point in the history
byuu says:

Changelog:

  - higan: readded support for soft-reset to Famicom, Super Famicom,
    Mega Drive cores (work in progress)
      - handhelds lack soft reset obviously
      - the PC Engine also lacks a physical reset button
      - the Master System's reset button acts like a gamepad button, so
        can't show up in the menu
  - Mega Drive: power cycle wasn't initializing CPU (M68K) or APU (Z80)
    RAM
  - Super Famicom: fix SPC700 opcode 0x3b regression; fixes Majuu Ou
    [Jonas Quinn]
  - Super Famicom: fix SharpRTC save regression; fixes Dai Kaijuu
    Monogatari II's real-time clock [Talarubi]
  - Super Famicom: fix EpsonRTC save regression; fixes Tengai Makyou
    Zero's real-time clock [Talarubi]
  - Super Famicom: removed `*::init()` functions, as they were never used
  - Super Famicom: removed all but two `*::load()` functions, as they
    were not used
  - higan: added option to auto-save backup RAM every five seconds
    (enabled by default)
      - this is in case the emulator crashes, or there's a power outage;
        turn it off under advanced settings if you want
  - libco: updated license from public domain to ISC, for consistency
    with nall, ruby, hiro
  - nall: Linux compiler defaults to g++; override with g++-version if
    g++ is <= 4.8
      - FreeBSD compiler default is going to remain g++49 until my dev
        box OS ships with g++ >= 4.9

Errata: I have weird RAM initialization constants, thanks to hex_usr
and onethirdxcubed for both finding this:
http://wiki.nesdev.com/w/index.php?title=CPU_power_up_state&diff=11711&oldid=11184

I'll remove this in the next WIP.
  • Loading branch information
Screwtapello committed Nov 6, 2017
1 parent 6d48792 commit e9d2d56
Show file tree
Hide file tree
Showing 89 changed files with 166 additions and 314 deletions.
2 changes: 1 addition & 1 deletion higan/emulator/emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using namespace nall;

namespace Emulator {
static const string Name = "higan";
static const string Version = "105 (tr1)";
static const string Version = "105.01";
static const string Author = "byuu";
static const string License = "GPLv3";
static const string Website = "https://byuu.org/";
Expand Down
4 changes: 3 additions & 1 deletion higan/emulator/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ struct Interface {
struct Information {
string manufacturer;
string name;
bool overscan;
bool overscan = false;
bool resettable = false;
} information;

struct Medium {
Expand Down Expand Up @@ -59,6 +60,7 @@ 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
Expand Down
2 changes: 1 addition & 1 deletion higan/fc/apu/apu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ auto APU::setSample(int16 sample) -> void {
cartridgeSample = sample;
}

auto APU::power() -> void {
auto APU::power(bool reset) -> void {
create(APU::Enter, system.frequency());
stream = Emulator::audio.createStream(1, frequency() / rate());
stream->addFilter(Emulator::Filter::Order::First, Emulator::Filter::Type::HighPass, 90.0);
Expand Down
2 changes: 1 addition & 1 deletion higan/fc/apu/apu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct APU : Thread {
auto setIRQ() -> void;
auto setSample(int16 sample) -> void;

auto power() -> void;
auto power(bool reset) -> void;

auto readIO(uint16 addr) -> uint8;
auto writeIO(uint16 addr, uint8 data) -> void;
Expand Down
12 changes: 6 additions & 6 deletions higan/fc/cpu/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ auto CPU::step(uint clocks) -> void {
for(auto peripheral : peripherals) synchronize(*peripheral);
}

auto CPU::power() -> void {
auto CPU::power(bool reset) -> void {
MOS6502::BCD = 0;
MOS6502::power();
create(CPU::Enter, system.frequency());

for(auto addr : range(0x0800)) ram[addr] = 0xff;
ram[0x0008] = 0xf7;
ram[0x0009] = 0xef;
ram[0x000a] = 0xdf;
ram[0x000f] = 0xbf;
if(!reset) for(auto& data : ram) data = 0xff;
ram[0x008] = 0xf7; //todo: what is this about?
ram[0x009] = 0xef;
ram[0x00a] = 0xdf;
ram[0x00f] = 0xbf;

r.pc.byte(0) = bus.read(0xfffc);
r.pc.byte(1) = bus.read(0xfffd);
Expand Down
4 changes: 2 additions & 2 deletions higan/fc/cpu/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct CPU : Processor::MOS6502, Thread {
auto main() -> void;
auto step(uint clocks) -> void;

auto power() -> void;
auto power(bool reset) -> void;

//memory.cpp
auto readRAM(uint11 addr) -> uint8;
Expand Down Expand Up @@ -37,7 +37,7 @@ struct CPU : Processor::MOS6502, Thread {
//protected:
vector<Thread*> peripherals;

uint8 ram[0x0800];
uint8 ram[0x800];

struct IO {
bool interruptPending;
Expand Down
7 changes: 6 additions & 1 deletion higan/fc/interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Interface::Interface() {
information.manufacturer = "Nintendo";
information.name = "Famicom";
information.overscan = true;
information.resettable = true;

media.append({ID::Famicom, "Famicom", "fc"});

Expand Down Expand Up @@ -137,7 +138,11 @@ auto Interface::connect(uint port, uint device) -> void {
}

auto Interface::power() -> void {
system.power();
system.power(/* reset = */ false);
}

auto Interface::reset() -> void {
system.power(/* reset = */ true);
}

auto Interface::run() -> void {
Expand Down
1 change: 1 addition & 0 deletions higan/fc/interface/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ 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;
Expand Down
12 changes: 7 additions & 5 deletions higan/fc/ppu/ppu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,20 @@ auto PPU::refresh() -> void {
Emulator::video.refresh(buffer, 256 * sizeof(uint32), 256, 240);
}

auto PPU::power() -> void {
auto PPU::power(bool reset) -> void {
create(PPU::Enter, system.frequency());

memory::fill(&io, sizeof(IO));
memory::fill(&latch, sizeof(Latches));
io.vramIncrement = 1;

for(auto& n : ciram ) n = 0;
for(auto& n : cgram ) n = 0;
for(auto& n : oam ) n = 0;
if(!reset) {
for(auto& data : ciram ) data = 0;
for(auto& data : cgram ) data = 0;
for(auto& data : oam ) data = 0;
}

for(auto& n : buffer) n = 0;
for(auto& data : buffer) data = 0;
}

}
2 changes: 1 addition & 1 deletion higan/fc/ppu/ppu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct PPU : Thread {
auto frame() -> void;
auto refresh() -> void;

auto power() -> void;
auto power(bool reset) -> void;

//memory.cpp
auto readCIRAM(uint11 addr) -> uint8;
Expand Down
2 changes: 1 addition & 1 deletion higan/fc/system/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ auto System::unserialize(serializer& s) -> bool {
if(signature != 0x31545342) return false;
if(string{version} != Emulator::SerializerVersion) return false;

power();
power(/* reset = */ false);
serializeAll(s);
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions higan/fc/system/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ auto System::unload() -> void {
information.loaded = false;
}

auto System::power() -> void {
auto System::power(bool reset) -> void {
Emulator::video.reset();
Emulator::video.setInterface(interface);
configureVideoPalette();
Expand All @@ -73,9 +73,9 @@ auto System::power() -> void {

scheduler.reset();
cartridge.power();
cpu.power();
apu.power();
ppu.power();
cpu.power(reset);
apu.power(reset);
ppu.power(reset);
scheduler.primary(cpu);

controllerPort1.power(ID::Port::Controller1);
Expand Down
2 changes: 1 addition & 1 deletion higan/fc/system/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct System {
auto load(Emulator::Interface*) -> bool;
auto save() -> void;
auto unload() -> void;
auto power() -> void;
auto power(bool reset) -> void;

auto init() -> void;
auto term() -> void;
Expand Down
4 changes: 3 additions & 1 deletion higan/md/apu/apu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ auto APU::enable(bool value) -> void {
state.enabled = value;
}

auto APU::power() -> void {
auto APU::power(bool reset) -> void {
Z80::bus = this;
Z80::power();
bus->grant(false);
create(APU::Enter, system.frequency() / 15.0);

if(!reset) memory::fill(ram, sizeof ram);
state = {};
}

Expand Down
2 changes: 1 addition & 1 deletion higan/md/apu/apu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct APU : Processor::Z80, Processor::Z80::Bus, Thread {
auto synchronizing() const -> bool override;

auto enable(bool) -> void;
auto power() -> void;
auto power(bool reset) -> void;
auto reset() -> void;

auto setNMI(bool value) -> void;
Expand Down
4 changes: 3 additions & 1 deletion higan/md/cpu/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ auto CPU::load(Markup::Node node) -> bool {
return true;
}

auto CPU::power() -> void {
auto CPU::power(bool reset) -> void {
M68K::bus = this;
M68K::power();
create(CPU::Enter, system.frequency() / 7.0);

if(!reset) memory::fill(ram, sizeof ram);

io = {};
io.version = tmssEnable;
io.romEnable = !tmssEnable;
Expand Down
2 changes: 1 addition & 1 deletion higan/md/cpu/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct CPU : Processor::M68K, Processor::M68K::Bus, Thread {
auto lower(Interrupt) -> void;

auto load(Markup::Node) -> bool;
auto power() -> void;
auto power(bool reset) -> void;

//bus.cpp
auto readByte(uint24 address) -> uint16 override;
Expand Down
7 changes: 6 additions & 1 deletion higan/md/interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Interface::Interface() {
information.manufacturer = "Sega";
information.name = "Mega Drive";
information.overscan = true;
information.resettable = true;

media.append({ID::MegaDrive, "Mega Drive", "md"});

Expand Down Expand Up @@ -122,7 +123,11 @@ auto Interface::connect(uint port, uint device) -> void {
}

auto Interface::power() -> void {
system.power();
system.power(/* reset = */ false);
}

auto Interface::reset() -> void {
system.power(/* reset = */ true);
}

auto Interface::run() -> void {
Expand Down
1 change: 1 addition & 0 deletions higan/md/interface/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ 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;
Expand Down
2 changes: 1 addition & 1 deletion higan/md/psg/psg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ auto PSG::step(uint clocks) -> void {
synchronize(apu);
}

auto PSG::power() -> void {
auto PSG::power(bool reset) -> void {
create(PSG::Enter, system.frequency() / 15.0);
stream = Emulator::audio.createStream(1, frequency() / 16.0);
stream->addFilter(Emulator::Filter::Order::First, Emulator::Filter::Type::HighPass, 20.0);
Expand Down
2 changes: 1 addition & 1 deletion higan/md/psg/psg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct PSG : Thread {
auto main() -> void;
auto step(uint clocks) -> void;

auto power() -> void;
auto power(bool reset) -> void;

//io.cpp
auto write(uint8 data) -> void;
Expand Down
2 changes: 1 addition & 1 deletion higan/md/system/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ auto System::unserialize(serializer& s) -> bool {
if(signature != 0x31545342) return false;
if(string{version} != Emulator::SerializerVersion) return false;

power();
power(/* reset = */ false);
serializeAll(s);
return true;
}
Expand Down
12 changes: 6 additions & 6 deletions higan/md/system/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ auto System::unload() -> void {
cartridge.unload();
}

auto System::power() -> void {
auto System::power(bool reset) -> void {
Emulator::video.reset();
Emulator::video.setInterface(interface);
Emulator::video.setPalette();
Expand All @@ -71,11 +71,11 @@ auto System::power() -> void {

scheduler.reset();
cartridge.power();
cpu.power();
apu.power();
vdp.power();
psg.power();
ym2612.power();
cpu.power(reset);
apu.power(reset);
vdp.power(reset);
psg.power(reset);
ym2612.power(reset);
scheduler.primary(cpu);

controllerPort1.power(ID::Port::Controller1);
Expand Down
2 changes: 1 addition & 1 deletion higan/md/system/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct System {
auto load(Emulator::Interface*, maybe<Region> = nothing) -> bool;
auto save() -> void;
auto unload() -> void;
auto power() -> void;
auto power(bool reset) -> void;

//serialization.cpp
auto serializeInit() -> void;
Expand Down
8 changes: 7 additions & 1 deletion higan/md/vdp/vdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ auto VDP::refresh() -> void {
Emulator::video.refresh(data, 1280 * sizeof(uint32), 1280, 480);
}

auto VDP::power() -> void {
auto VDP::power(bool reset) -> void {
create(VDP::Enter, system.frequency() / 2.0);

output = buffer + 16 * 1280; //overscan offset

if(!reset) {
for(auto& data : vram.memory) data = 0;
for(auto& data : vsram.memory) data = 0;
for(auto& data : cram.memory) data = 0;
}

io = {};
latch = {};
state = {};
Expand Down
5 changes: 1 addition & 4 deletions higan/md/vdp/vdp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct VDP : Thread {
auto step(uint clocks) -> void;
auto refresh() -> void;

auto power() -> void;
auto power(bool reset) -> void;

//io.cpp
auto read(uint24 addr) -> uint16;
Expand Down Expand Up @@ -166,7 +166,6 @@ struct VDP : Thread {
//serialization.cpp
auto serialize(serializer&) -> void;

private:
uint16 memory[32768];
} vram;

Expand All @@ -179,7 +178,6 @@ struct VDP : Thread {
//serialization.cpp
auto serialize(serializer&) -> void;

private:
uint10 memory[40];
} vsram;

Expand All @@ -192,7 +190,6 @@ struct VDP : Thread {
//serialization.cpp
auto serialize(serializer&) -> void;

private:
uint9 memory[64];
} cram;

Expand Down
2 changes: 1 addition & 1 deletion higan/md/ym2612/ym2612.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ auto YM2612::step(uint clocks) -> void {
synchronize(apu);
}

auto YM2612::power() -> void {
auto YM2612::power(bool reset) -> void {
create(YM2612::Enter, system.frequency() / 7.0);
stream = Emulator::audio.createStream(2, frequency() / 144.0);
stream->addFilter(Emulator::Filter::Order::First, Emulator::Filter::Type::HighPass, 20.0);
Expand Down
2 changes: 1 addition & 1 deletion higan/md/ym2612/ym2612.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct YM2612 : Thread {
auto sample() -> void;
auto step(uint clocks) -> void;

auto power() -> void;
auto power(bool reset) -> void;

//io.cpp
auto readStatus() -> uint8;
Expand Down
Loading

0 comments on commit e9d2d56

Please sign in to comment.