Skip to content

Commit

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

These WIPs are gonna be unstable for a bit, sorry. Large amounts of
changes. Right now, higan+bsnes compile, but only with cores="sfc gb".

There's a new nall::Settings class, which I really dislike the design
of, but as long as the classes that use it remain stable, then ... I'll
have to live with it for now.

Interface loses both the old get/set/cap interface, plus the
configuration interface. It now returns either properties() or
options(). Both return a Settings& object. There's also helpers for
accessing individual properties and options by string lookup.

Properties are immutable traits of the hardware itself: CPU version, PPU
VRAM size, boot ROM information, etc.

Options are mutable traits that users may change.

The idea with nall/settings is to build out a kind of extremely complex
configuration object that'll do everything we'd ever want:

  - allow recursive children settings similar to Markup::Node
  - access values directly without dynamic_cast (type erasure) or
    string conversion (Markup::Node style)
  - serialize to and unserialize from BML
  - support valid values to guarantee that the settings are never in an
    invalid state
  - support latching of values to cache reads without another separate
    variable (so the GUI can modify any variables at any time safely)

Todo:

  - allow binding callback functions on assignment, so that eg changing
    video/colorEmulation will regenerate the video palette
  - provide a hint on whether an option can be changed dynamically at
    run-time, or only statically at first load
  - provide descriptions for each setting

And then once the class is fully fleshed out, I want to build a tool
that will generate a fancy modal hiro Window from a Settings& object.

Once that is complete, we'll then have System → Options to configure
per-emulator settings (like bsnes PPU stuff) that otherwise doesn't fit
into higan's GUI. We will be exposing the extended Super Famicom options
to the bsnes GUI, of course. That's the emulator tab there.

Next up, higan's systems tab will need to generate blank default
property files for each system, and let you configure system properties
from this screen. That's going to mean that, by allowing the same system
to appear multiple times, that each entry gets its own options file,
which will have to be stored somewhere.

And to do all of that, we really need to work out how to handle regions
first. It may have to be something radical like FitzRoy's idea, or it
may be that we can come up with something a little less drastic. But I
have no idea right now ...

What I'd really like to do is start trying to get bsnes v107 out
already. The two things holding it up are: fixing the desync between the
settings.bml GUI settings and options.bml SNES properties (I know what's
wrong, I just have to fix it), and getting XAudio2 DRC working (I copied
BearOso's implementation details, but it just doesn't work for me ...).
Then I also have to install Windows, set up a dev environment with
msys2, and build it all.

Lots and lots of work ...
  • Loading branch information
Screwtapello committed Jan 25, 2019
1 parent 631baa4 commit 94c691e
Show file tree
Hide file tree
Showing 53 changed files with 555 additions and 441 deletions.
4 changes: 2 additions & 2 deletions higan/emulator/emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <nall/literals.hpp>
#include <nall/random.hpp>
#include <nall/serializer.hpp>
#include <nall/settings.hpp>
#include <nall/shared-pointer.hpp>
#include <nall/string.hpp>
#include <nall/traits.hpp>
Expand All @@ -23,7 +24,6 @@ using namespace nall;

#include <libco/libco.h>
#include <emulator/types.hpp>
#include <emulator/setting.hpp>
#include <emulator/platform.hpp>
#include <emulator/interface.hpp>
#include <emulator/game.hpp>
Expand All @@ -35,7 +35,7 @@ using namespace nall;

namespace higan {
static const string Name = "higan";
static const string Version = "106.86";
static const string Version = "106.87";
static const string Author = "byuu";
static const string License = "GPLv3";
static const string Website = "https://byuu.org/";
Expand Down
45 changes: 31 additions & 14 deletions higan/emulator/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,37 @@ struct Interface {
//cheat functions
virtual auto cheats(const vector<string>& = {}) -> void {}

//properties and settings
virtual auto properties() -> AbstractSetting* { return nullptr; }
virtual auto settings() -> AbstractSetting* { return nullptr; }

//configuration
virtual auto configuration() -> string { return {}; }
virtual auto configuration(string name) -> string { return {}; }
virtual auto configure(string configuration = "") -> bool { return false; }
virtual auto configure(string name, string value) -> bool { return false; }

//settings
virtual auto cap(const string& name) -> bool { return false; }
virtual auto get(const string& name) -> any { return {}; }
virtual auto set(const string& name, const any& value) -> bool { return false; }
//options
virtual auto options() -> Settings& { static Setting<> noOptions; return noOptions; }

auto hasOption(string name) -> bool { name.prepend("options/"); return (bool)options()[name]; }

auto getOption(string name) -> string {
name.prepend("options/");
if(auto option = options()[name]) return option->value();
return {};
}

auto setOption(string name, string value) -> bool {
name.prepend("options/");
if(auto option = options()[name]) return option->setValue(value);
return false;
}

//properties
virtual auto properties() -> Settings& { static Setting<> noProperties; return noProperties; }

auto hasProperty(string name) -> bool { return (bool)properties()[name]; }

auto getProperty(string name) -> string {
if(auto property = properties()[name]) return property->value();
return {};
}

auto setProperty(string name, string value) -> bool {
if(auto property = properties()[name]) return property->setValue(value);
return false;
}
};

}
80 changes: 0 additions & 80 deletions higan/emulator/setting.hpp

This file was deleted.

26 changes: 8 additions & 18 deletions higan/gb/cartridge/cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,28 +145,18 @@ auto Cartridge::unload() -> void {
rtc = {};
}

auto Cartridge::readIO(uint16 addr) -> uint8 {
if(addr == 0xff50) return 0xff;

auto Cartridge::readIO(uint16 address) -> uint8 {
if(address == 0xff50) return 0xff;
if(bootromEnable) {
const uint8* data = nullptr;
if(Model::GameBoy()) data = system.bootROM.dmg;
if(Model::GameBoyColor()) data = system.bootROM.cgb;
if(Model::SuperGameBoy()) data = system.bootROM.sgb;
if(addr >= 0x0000 && addr <= 0x00ff) return data[addr];
if(addr >= 0x0200 && addr <= 0x08ff && Model::GameBoyColor()) return data[addr - 0x100];
if(address >= 0x0000 && address <= 0x00ff) return system.bootROM.read(address);
if(address >= 0x0200 && address <= 0x08ff && Model::GameBoyColor()) return system.bootROM.read(address - 0x100);
}

return mapper->read(addr);
return mapper->read(address);
}

auto Cartridge::writeIO(uint16 addr, uint8 data) -> void {
if(bootromEnable && addr == 0xff50) {
bootromEnable = false;
return;
}

mapper->write(addr, data);
auto Cartridge::writeIO(uint16 address, uint8 data) -> void {
if(bootromEnable && address == 0xff50) return void(bootromEnable = false);
mapper->write(address, data);
}

auto Cartridge::power() -> void {
Expand Down
10 changes: 9 additions & 1 deletion higan/gb/interface/game-boy-color.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
GameBoyColorInterface::GameBoyColorInterface() {
propertyGameBoyColor.memory.size(2048);
}

auto GameBoyColorInterface::information() -> Information {
Information information;
information.manufacturer = "Nintendo";
Expand All @@ -15,7 +19,7 @@ auto GameBoyColorInterface::color(uint32 color) -> uint64 {
uint64_t G = image::normalize(g, 5, 16);
uint64_t B = image::normalize(b, 5, 16);

if(settings.colorEmulation) {
if(option.video.colorEmulation()) {
R = (r * 26 + g * 4 + b * 2);
G = ( g * 24 + b * 8);
B = (r * 6 + g * 4 + b * 22);
Expand All @@ -30,3 +34,7 @@ auto GameBoyColorInterface::color(uint32 color) -> uint64 {
auto GameBoyColorInterface::load() -> bool {
return system.load(this, System::Model::GameBoyColor);
}

auto GameBoyColorInterface::properties() -> Settings& {
return propertyGameBoyColor;
}
10 changes: 9 additions & 1 deletion higan/gb/interface/game-boy.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
GameBoyInterface::GameBoyInterface() {
propertyGameBoy.memory.size(256);
}

auto GameBoyInterface::information() -> Information {
Information information;
information.manufacturer = "Nintendo";
Expand All @@ -7,7 +11,7 @@ auto GameBoyInterface::information() -> Information {
}

auto GameBoyInterface::color(uint32 color) -> uint64 {
if(!settings.colorEmulation) {
if(!option.video.colorEmulation()) {
uint64 L = image::normalize(3 - color, 2, 16);
return L << 32 | L << 16 | L << 0;
} else {
Expand Down Expand Up @@ -45,3 +49,7 @@ auto GameBoyInterface::color(uint32 color) -> uint64 {
auto GameBoyInterface::load() -> bool {
return system.load(this, System::Model::GameBoy);
}

auto GameBoyInterface::properties() -> Settings& {
return propertyGameBoy;
}
10 changes: 9 additions & 1 deletion higan/gb/interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace higan::GameBoy {

SuperGameBoyInterface* superGameBoy = nullptr;
Settings settings;
Options option;
Properties propertyGameBoy;
Properties propertyGameBoyColor;
#include "game-boy.cpp"
#include "game-boy-color.cpp"

Expand Down Expand Up @@ -109,6 +111,11 @@ auto AbstractInterface::cheats(const vector<string>& list) -> void {
cheat.assign(list);
}

auto AbstractInterface::options() -> Settings& {
return option;
}

/*
auto AbstractInterface::cap(const string& name) -> bool {
if(name == "Blur Emulation") return true;
if(name == "Color Emulation") return true;
Expand Down Expand Up @@ -138,5 +145,6 @@ auto AbstractInterface::set(const string& name, const any& value) -> bool {
return false;
}
*/

}
19 changes: 10 additions & 9 deletions higan/gb/interface/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,29 @@ struct AbstractInterface : Interface {

auto cheats(const vector<string>&) -> void override;

auto cap(const string& name) -> bool override;
auto get(const string& name) -> any override;
auto set(const string& name, const any& value) -> bool override;
auto options() -> Settings& override;
};

struct GameBoyInterface : AbstractInterface {
GameBoyInterface();
auto information() -> Information override;

auto color(uint32 color) -> uint64 override;

auto load() -> bool override;

auto properties() -> Settings& override;
};

struct GameBoyColorInterface : AbstractInterface {
GameBoyColorInterface();
auto information() -> Information override;

auto color(uint32 color) -> uint64 override;

auto load() -> bool override;

auto properties() -> Settings& override;
};

struct SuperGameBoyInterface {
Expand All @@ -76,13 +80,10 @@ struct SuperGameBoyInterface {
virtual auto joypWrite(bool p15, bool p14) -> void = 0;
};

struct Settings {
bool blurEmulation = true;
bool colorEmulation = true;
};

extern SuperGameBoyInterface* superGameBoy;
extern Settings settings;

#include "options.hpp"
#include "properties.hpp"

}

Expand Down
11 changes: 11 additions & 0 deletions higan/gb/interface/options.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
struct Options : Setting<> {
struct Video : Setting<> { using Setting::Setting;
Setting<boolean> blurEmulation{this, "blurEmulation", true};
Setting<boolean> colorEmulation{this, "colorEmulation", true};
} video{this, "video"};

Options() : Setting{"options"} {
}
};

extern Options option;
13 changes: 13 additions & 0 deletions higan/gb/interface/properties.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
struct Properties : Setting<string> {
struct Memory : Setting<> { using Setting::Setting;
Setting<string> type{this, "type", "ROM"};
Setting<natural> size{this, "size"};
Setting<string> content{this, "content", "Boot"};
} memory{this, "memory"};

Properties() : Setting{"system"} {
}
};

extern Properties propertyGameBoy;
extern Properties propertyGameBoyColor;
Loading

0 comments on commit 94c691e

Please sign in to comment.