diff --git a/bsnes/emulator/emulator.hpp b/bsnes/emulator/emulator.hpp index 53017e38..b63e3765 100644 --- a/bsnes/emulator/emulator.hpp +++ b/bsnes/emulator/emulator.hpp @@ -29,7 +29,7 @@ using namespace nall; namespace Emulator { static const string Name = "bsnes"; - static const string Version = "112.10"; + static const string Version = "112.11"; static const string Author = "byuu"; static const string License = "GPLv3"; static const string Website = "https://byuu.org"; diff --git a/bsnes/sfc/ppu/screen.cpp b/bsnes/sfc/ppu/screen.cpp index 7069cff4..7455effc 100644 --- a/bsnes/sfc/ppu/screen.cpp +++ b/bsnes/sfc/ppu/screen.cpp @@ -10,8 +10,8 @@ auto PPU::Screen::scanline() -> void { math.above.color = paletteColor(0); math.below.color = math.above.color; - math.above.colorEnable = !(ppu.window.io.col.aboveMask & 1); - math.below.colorEnable = !(ppu.window.io.col.belowMask & 1) && io.back.colorEnable; + math.above.colorEnable = false; + math.below.colorEnable = false; math.transparent = true; math.blendMode = false; diff --git a/bsnes/target-bsnes/GNUmakefile b/bsnes/target-bsnes/GNUmakefile index df239bf8..4c67bde5 100644 --- a/bsnes/target-bsnes/GNUmakefile +++ b/bsnes/target-bsnes/GNUmakefile @@ -39,9 +39,9 @@ endif verbose: hiro.verbose ruby.verbose nall.verbose all; install: all -ifeq ($(shell id -un),root) +ifeq ($(platform),windows) +else ifeq ($(shell id -un),root) $(error "make install should not be run as root") -else ifeq ($(platform),windows) else ifeq ($(platform),macos) mkdir -p ~/Library/Application\ Support/$(name)/ mkdir -p ~/Library/Application\ Support/$(name)/Database/ @@ -64,9 +64,9 @@ else ifneq ($(filter $(platform),linux bsd),) endif uninstall: -ifeq ($(shell id -un),root) +ifeq ($(platform),windows) +else ifeq ($(shell id -un),root) $(error "make uninstall should not be run as root") -else ifeq ($(platform),windows) else ifeq ($(platform),macos) rm -rf /Applications/$(name).app else ifneq ($(filter $(platform),linux bsd),) diff --git a/libco/aarch64.c b/libco/aarch64.c index b3ffcc49..2132b4e5 100644 --- a/libco/aarch64.c +++ b/libco/aarch64.c @@ -5,8 +5,10 @@ #include #include #include -#include -#include +#ifdef LIBCO_MPROTECT + #include + #include +#endif #ifdef __cplusplus extern "C" { diff --git a/libco/amd64.c b/libco/amd64.c index e9424c0b..e96e5247 100755 --- a/libco/amd64.c +++ b/libco/amd64.c @@ -98,8 +98,10 @@ static void (*co_swap)(cothread_t, cothread_t) = 0; 0xff, 0xe0, /* jmp rax */ }; - #include - #include + #ifdef LIBCO_MPROTECT + #include + #include + #endif static void co_init() { #ifdef LIBCO_MPROTECT diff --git a/libco/arm.c b/libco/arm.c index 95adf6b2..1c9dff5c 100644 --- a/libco/arm.c +++ b/libco/arm.c @@ -4,8 +4,10 @@ #include #include -#include -#include +#ifdef LIBCO_MPROTECT + #include + #include +#endif #ifdef __cplusplus extern "C" { diff --git a/libco/ppc.c b/libco/ppc.c index 6b7f4acd..ee6a9a87 100755 --- a/libco/ppc.c +++ b/libco/ppc.c @@ -8,7 +8,7 @@ #include #include -#if LIBCO_MPROTECT +#ifdef LIBCO_MPROTECT #include #include #endif diff --git a/libco/x86.c b/libco/x86.c index fa1c538f..c539a299 100755 --- a/libco/x86.c +++ b/libco/x86.c @@ -52,8 +52,10 @@ static const unsigned char co_swap_function[4096] = { #endif } #else - #include - #include + #ifdef LIBCO_MPROTECT + #include + #include + #endif static void co_init() { #ifdef LIBCO_MPROTECT diff --git a/nall/GNUmakefile b/nall/GNUmakefile index 3a4c683e..7c43e3db 100755 --- a/nall/GNUmakefile +++ b/nall/GNUmakefile @@ -11,6 +11,12 @@ MAKEFLAGS := Rr [space] += # platform detection +ifeq ($(platform),) + ifeq ($(OS),Windows_NT) + platform := windows + endif +endif + ifeq ($(platform),) uname := $(shell uname) ifeq ($(uname),) diff --git a/nall/http/message.hpp b/nall/http/message.hpp index 1f7f237d..e4c543d1 100755 --- a/nall/http/message.hpp +++ b/nall/http/message.hpp @@ -11,17 +11,22 @@ struct Variable { }; struct SharedVariable { - SharedVariable(const string& name = "", const string& value = "") : shared(new Variable{name, value}) {} + SharedVariable(const nall::string& name = "", const nall::string& value = "") : shared(new Variable{name, value}) {} explicit operator bool() const { return (bool)shared->name; } auto operator()() const { return shared->value; } - auto& operator=(const string& value) { shared->value = value; return *this; } + auto& operator=(const nall::string& value) { shared->value = value; return *this; } auto name() const { return shared->name; } auto value() const { return shared->value; } + auto string() const { return nall::string{shared->value}.strip().replace("\r", ""); } + auto boolean() const { return string() == "true"; } + auto integer() const { return string().integer(); } + auto natural() const { return string().natural(); } + auto real() const { return string().real(); } - auto& setName(const string& name) { shared->name = name; return *this; } - auto& setValue(const string& value = "") { shared->value = value; return *this; } + auto& setName(const nall::string& name) { shared->name = name; return *this; } + auto& setValue(const nall::string& value = "") { shared->value = value; return *this; } shared_pointer shared; }; diff --git a/nall/serializer.hpp b/nall/serializer.hpp index 0993e8cc..0910529b 100755 --- a/nall/serializer.hpp +++ b/nall/serializer.hpp @@ -35,6 +35,11 @@ struct serializer { return _size; } + auto setMode(Mode mode) -> void { + _mode = mode; + _size = 0; + } + auto mode() const -> Mode { return _mode; } @@ -51,11 +56,6 @@ struct serializer { return _capacity; } - auto setMode(Mode mode) -> void { - _mode = mode; - _size = 0; - } - template auto real(T& value) -> serializer& { enum : uint { size = sizeof(T) }; //this is rather dangerous, and not cross-platform safe; diff --git a/nall/string/transform/dml.hpp b/nall/string/transform/dml.hpp index 616d6232..7fbb1065 100755 --- a/nall/string/transform/dml.hpp +++ b/nall/string/transform/dml.hpp @@ -23,6 +23,8 @@ struct DML { auto parse(const string& filedata, const string& pathname) -> string; auto parse(const string& filename) -> string; + auto attribute(const string& name) const -> string; + private: struct Settings { bool allowHTML = true; @@ -40,6 +42,12 @@ private: uint sections = 0; } state; + struct Attribute { + string name; + string value; + }; + vector attributes; + auto parseDocument(const string& filedata, const string& pathname, uint depth) -> bool; auto parseBlock(string& block, const string& pathname, uint depth) -> bool; auto count(const string& text, char value) -> uint; @@ -48,6 +56,13 @@ private: auto markup(const string& text) -> string; }; +inline auto DML::attribute(const string& name) const -> string { + for(auto& attribute : attributes) { + if(attribute.name == name) return attribute.value; + } + return {}; +} + inline auto DML::parse(const string& filedata, const string& pathname) -> string { state = {}; settings.path = pathname; @@ -91,15 +106,12 @@ inline auto DML::parseBlock(string& block, const string& pathname, uint depth) - } } - //title + //attribute else if(block.beginsWith("! ")) { - state.title = lines.takeLeft().trimLeft("! ", 1L); - state.output.append("

", markup(state.title)); for(auto& line : lines) { - if(!line.beginsWith("! ")) continue; - state.output.append("", markup(line.trimLeft("! ", 1L)), ""); + auto parts = line.trimLeft("! ", 1L).split(":", 1L); + if(parts.size() == 2) attributes.append({parts[0].strip(), parts[1].strip()}); } - state.output.append("

\n"); } //description @@ -206,7 +218,12 @@ inline auto DML::parseBlock(string& block, const string& pathname, uint depth) - //paragraph else { - state.output.append("

", markup(block), "

\n"); + auto content = markup(block); + if(content.beginsWith("")) { + state.output.append(content, "\n"); + } else { + state.output.append("

", content, "

\n"); + } } return true; @@ -243,58 +260,87 @@ inline auto DML::markup(const string& s) -> string { boolean deletion; boolean code; - natural link, linkBase; - natural embed, embedBase; - natural photo, photoBase; - natural iframe, iframeBase; + maybe link; + maybe image; for(uint n = 0; n < s.size();) { char a = s[n]; char b = s[n + 1]; - if(!link && !embed && !photo && !iframe) { + if(!link && !image) { if(a == '*' && b == '*') { t.append(strong.flip() ? "" : ""); n += 2; continue; } if(a == '/' && b == '/') { t.append(emphasis.flip() ? "" : ""); n += 2; continue; } if(a == '_' && b == '_') { t.append(insertion.flip() ? "" : ""); n += 2; continue; } if(a == '~' && b == '~') { t.append(deletion.flip() ? "" : ""); n += 2; continue; } if(a == '|' && b == '|') { t.append(code.flip() ? "" : ""); n += 2; continue; } if(a =='\\' && b =='\\') { t.append("
"); n += 2; continue; } + + if(a == '[' && b == '[') { n += 2; link = n; continue; } + if(a == '{' && b == '{') { n += 2; image = n; continue; } } - if(iframe == 0 && a == '<' && b == '<') { t.append(""); iframe = 0; n += 2; continue; } + if(link && !image && a == ']' && b == ']') { + auto list = slice(s, link(), n - link()).split("::", 1L); + string uri = list.last(); + string name = list.size() == 2 ? list.first() : list.last().split("//", 1L).last(); - if(!embed && !link) { - if(photo == 0 && a == '[' && b == '{') { t.append("\"\""); n += 2; photo = 0; continue; } - if(photo == 1 && a == ':' && b == ':') { t.append(slice(s, photoBase, n - photoBase).replace("@/", settings.host), "\">\"");"); n += 2; photo = 0; continue; } - if(photo != 0) { n++; continue; } + t.append("", escape(name), ""); + + n += 2; + link = nothing; + continue; } - if(!photo && !embed) { - if(link == 0 && a == '[' && b == '[') { t.append(""); link = 2; n += 2; continue; } - if(link == 1 && a == ']' && b == ']') { t.append("\">", slice(s, linkBase, n - linkBase), ""); n += 2; link = 0; continue; } - if(link == 2 && a == ']' && b == ']') { t.append(""); n += 2; link = 0; continue; } - if(link == 1 && a == '@' && b == '/') { t.append(settings.host); n += 2; continue; } - } - - if(!photo && !link) { - if(embed == 0 && a == '{' && b == '{') { t.append("\"");"); embed = 0; n += 2; continue; } - if(embed == 1 && a == '@' && b == '/') { t.append(settings.host); n += 2; continue; } + if(image && !link && a == '}' && b == '}') { + auto side = slice(s, image(), n - image()).split("}{", 1L); + auto list = side(0).split("::", 1L); + string uri = list.last(); + string name = list.size() == 2 ? list.first() : list.last().split("//", 1L).last(); + list = side(1).split("; "); + boolean link, title, caption; + string width, height; + for(auto p : list) { + if(p == "link") { link = true; continue; } + if(p == "title") { title = true; continue; } + if(p == "caption") { caption = true; continue; } + if(p.beginsWith("width:")) { p.trimLeft("width:", 1L); width = p.strip(); continue; } + if(p.beginsWith("height:")) { p.trimLeft("height:", 1L); height = p.strip(); continue; } + } + + if(caption) { + t.append("
\n"); + if(link) t.append(""); + t.append("\"",\n"); + if(link) t.append("\n"); + t.append("
", escape(name), "
\n"); + t.append("
"); + } else { + if(link) t.append(""); + t.append("\"","); + if(link) t.append(""); + } + + n += 2; + image = nothing; + continue; } + if(link || image) { n++; continue; } if(a =='\\') { t.append(b); n += 2; continue; } if(a == '&') { t.append("&"); n++; continue; } if(a == '<') { t.append("<"); n++; continue; } if(a == '>') { t.append(">"); n++; continue; } if(a == '"') { t.append("""); n++; continue; } - - t.append(a); - n++; + t.append(a); n++; continue; } if(strong) t.append(""); @@ -302,9 +348,6 @@ inline auto DML::markup(const string& s) -> string { if(insertion) t.append(""); if(deletion) t.append(""); if(code) t.append(""); - if(link == 1) t.append("\">", slice(s, linkBase, s.size() - linkBase), ""); - if(link == 2) t.append(""); - if(embed != 0) t.append("\">"); return t; }