2010-08-09 13:28:56 +00:00
|
|
|
#ifndef NALL_CONFIG_HPP
|
|
|
|
#define NALL_CONFIG_HPP
|
|
|
|
|
2013-04-14 08:52:47 +00:00
|
|
|
#include <nall/platform.hpp>
|
2010-08-09 13:28:56 +00:00
|
|
|
#include <nall/file.hpp>
|
|
|
|
#include <nall/string.hpp>
|
|
|
|
|
|
|
|
namespace nall {
|
2013-04-14 08:52:47 +00:00
|
|
|
namespace Configuration {
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2013-04-14 08:52:47 +00:00
|
|
|
struct Node {
|
|
|
|
string name;
|
|
|
|
string desc;
|
2015-11-14 00:52:51 +00:00
|
|
|
enum class Type : unsigned { Null, Boolean, Integer, Natural, Double, String } type = Type::Null;
|
2013-04-14 08:52:47 +00:00
|
|
|
void* data = nullptr;
|
|
|
|
vector<Node> children;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto empty() const -> bool {
|
2013-04-14 08:52:47 +00:00
|
|
|
return data == nullptr;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto get() const -> string {
|
2013-04-14 08:52:47 +00:00
|
|
|
switch(type) {
|
2015-11-14 00:52:51 +00:00
|
|
|
case Type::Boolean: return {*(bool*)data};
|
|
|
|
case Type::Integer: return {*(int*)data};
|
|
|
|
case Type::Natural: return {*(uint*)data};
|
2013-04-14 08:52:47 +00:00
|
|
|
case Type::Double: return {*(double*)data};
|
|
|
|
case Type::String: return {*(string*)data};
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
2013-04-14 08:52:47 +00:00
|
|
|
return "";
|
|
|
|
}
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto set(const string& value) -> void {
|
2013-04-14 08:52:47 +00:00
|
|
|
switch(type) {
|
2015-11-14 00:52:51 +00:00
|
|
|
case Type::Boolean: *(bool*)data = (value != "false"); break;
|
|
|
|
case Type::Integer: *(int*)data = integer(value); break;
|
|
|
|
case Type::Natural: *(uint*)data = natural(value); break;
|
2013-07-29 09:42:45 +00:00
|
|
|
case Type::Double: *(double*)data = real(value); break;
|
2013-04-14 08:52:47 +00:00
|
|
|
case Type::String: *(string*)data = value; break;
|
2012-01-15 08:29:57 +00:00
|
|
|
}
|
2013-04-14 08:52:47 +00:00
|
|
|
}
|
2012-01-15 08:29:57 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto assign() { type = Type::Null; data = nullptr; }
|
2015-11-14 00:52:51 +00:00
|
|
|
auto assign(bool& bind) { type = Type::Boolean; data = (void*)&bind; }
|
|
|
|
auto assign(int& bind) { type = Type::Integer; data = (void*)&bind; }
|
|
|
|
auto assign(uint& bind) { type = Type::Natural; data = (void*)&bind; }
|
2015-07-14 09:32:43 +00:00
|
|
|
auto assign(double& bind) { type = Type::Double; data = (void*)&bind; }
|
|
|
|
auto assign(string& bind) { type = Type::String; data = (void*)&bind; }
|
|
|
|
auto assign(const Node& node) { operator=(node); }
|
2013-04-14 08:52:47 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
template<typename T> auto append(T& data, const string& name, const string& desc = "") -> void {
|
2013-04-14 08:52:47 +00:00
|
|
|
Node node;
|
|
|
|
node.assign(data);
|
|
|
|
node.name = name;
|
|
|
|
node.desc = desc;
|
|
|
|
children.append(node);
|
|
|
|
}
|
2010-08-09 13:28:56 +00:00
|
|
|
|
Update to v095r05 release.
byuu says:
Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection
GBA test scores: 1552/1552, 37/38, 1020/1260
(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)
Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.
Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 10:15:03 +00:00
|
|
|
auto find(const string& path) -> maybe<Node&> {
|
|
|
|
auto p = path.split("/");
|
|
|
|
auto name = p.takeFirst();
|
|
|
|
for(auto& child : children) {
|
|
|
|
if(child.name == name) {
|
|
|
|
if(p.size() == 0) return child;
|
|
|
|
return child.find(p.merge("/"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nothing;
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto load(Markup::Node path) -> void {
|
2013-04-14 08:52:47 +00:00
|
|
|
for(auto& child : children) {
|
Update to v094r17 release.
byuu says:
This updates higan to use the new Markup::Node changes. This is a really
big change, and one slight typo anywhere could break certain classes of
games from playing.
I don't have ananke hooked up again yet, so I don't have the ability to
test this much. If anyone with some v094 game folders wouldn't mind
testing, I'd help out a great deal.
I'm most concerned about testing one of each SNES special chip game.
Most notably, systems like the SA-1, HitachiDSP and NEC-DSP were using
the fancier lookups, eg node["rom[0]/name"], which I had to convert to
a rather ugly node["rom"].at(0)["name"], which I'm fairly confident
won't work. I'm going to blame that on the fumes from the shelves I just
stained >.> Might work with node.find("rom[0]/name")(0) though ...? But
so ugly ... ugh.
That aside, this WIP adds the accuracy-PPU inlining, so the accuracy
profile should run around 7.5% faster than before.
2015-05-02 13:05:46 +00:00
|
|
|
if(auto leaf = path[child.name]) {
|
|
|
|
if(!child.empty()) child.set(leaf.text());
|
|
|
|
child.load(leaf);
|
|
|
|
}
|
2013-04-14 08:52:47 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto save(file& fp, unsigned depth = 0) -> void {
|
2013-04-14 08:52:47 +00:00
|
|
|
for(auto& child : children) {
|
|
|
|
if(child.desc) {
|
2015-11-14 00:52:51 +00:00
|
|
|
for(auto n : range(depth)) fp.print(" ");
|
2013-04-14 08:52:47 +00:00
|
|
|
fp.print("//", child.desc, "\n");
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
2015-11-14 00:52:51 +00:00
|
|
|
for(auto n : range(depth)) fp.print(" ");
|
2013-04-14 08:52:47 +00:00
|
|
|
fp.print(child.name);
|
|
|
|
if(!child.empty()) fp.print(": ", child.get());
|
|
|
|
fp.print("\n");
|
|
|
|
child.save(fp, depth + 1);
|
|
|
|
if(depth == 0) fp.print("\n");
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
2013-04-14 08:52:47 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Document : Node {
|
2015-07-14 09:32:43 +00:00
|
|
|
auto load(const string& filename) -> bool {
|
2013-04-14 08:52:47 +00:00
|
|
|
if(!file::exists(filename)) return false;
|
Update to v094r17 release.
byuu says:
This updates higan to use the new Markup::Node changes. This is a really
big change, and one slight typo anywhere could break certain classes of
games from playing.
I don't have ananke hooked up again yet, so I don't have the ability to
test this much. If anyone with some v094 game folders wouldn't mind
testing, I'd help out a great deal.
I'm most concerned about testing one of each SNES special chip game.
Most notably, systems like the SA-1, HitachiDSP and NEC-DSP were using
the fancier lookups, eg node["rom[0]/name"], which I had to convert to
a rather ugly node["rom"].at(0)["name"], which I'm fairly confident
won't work. I'm going to blame that on the fumes from the shelves I just
stained >.> Might work with node.find("rom[0]/name")(0) though ...? But
so ugly ... ugh.
That aside, this WIP adds the accuracy-PPU inlining, so the accuracy
profile should run around 7.5% faster than before.
2015-05-02 13:05:46 +00:00
|
|
|
auto document = BML::unserialize(string::read(filename));
|
2013-04-14 08:52:47 +00:00
|
|
|
Node::load(document);
|
|
|
|
return true;
|
|
|
|
}
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto save(const string& filename) -> bool {
|
2013-04-14 08:52:47 +00:00
|
|
|
file fp(filename, file::mode::write);
|
|
|
|
if(!fp.open()) return false;
|
|
|
|
Node::save(fp);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2013-04-14 08:52:47 +00:00
|
|
|
}
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|