mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-27 03:44:39 +02:00
Update to v106r2 release.
byuu says: Changelog: - Super Famicom: added support for loading manifests without embedded mapping information¹ - genius: initial commit - various Makefile cleanups ¹: so the idea here is to try and aim for a stable manifest format, and to allow direct transposition of icarus/genius database entries into manifest files. The exact mechanics of how this is going to work is currently in flux, but we'll get there. For right now, `Super Famicom.sys` gains `boards.bml`, which is the raw database from my board-editor tool, and higan itself tries to load `boards.bml`, match an entry to game/board from the game's `manifest.bml` file, and then transform it into the format currently used by higan. It does this only when the game's `manifest.bml` file lacks a board node. When such a board node exists, it works as previous versions of higan did. The only incompatible change right now is information/title is now located at game/label. I may transition window title display to just use the filenames instead. Longer term, some thought is going to need to go into the format of the `boards.bml` database itself, and at which point in the process I should be transforming things. Give it time, we'll refine this into something nicer.
This commit is contained in:
37
nall/decode/base.hpp
Normal file
37
nall/decode/base.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <nall/arithmetic.hpp>
|
||||
|
||||
namespace nall { namespace Decode {
|
||||
|
||||
template<uint Bits, typename T> inline auto Base(const string& value) -> T {
|
||||
static const string format =
|
||||
Bits == 2 ? "01"
|
||||
: Bits == 8 ? "01234567"
|
||||
: Bits == 10 ? "0123456789"
|
||||
: Bits == 16 ? "0123456789abcdef"
|
||||
: Bits == 32 ? "0123456789abcdefghijklmnopqrstuv"
|
||||
: Bits == 34 ? "023456789abcdefghijkmnopqrstuvwxyz" //1l
|
||||
: Bits == 36 ? "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
: Bits == 57 ? "23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" //01IOl
|
||||
: Bits == 62 ? "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
: Bits == 64 ? "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz{}"
|
||||
: Bits == 85 ? "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%()+,-.:;=@[]^_`{|}~" //\ "&'*/<>?
|
||||
: "";
|
||||
static bool initialized = false;
|
||||
static uint8_t lookup[256] = {0};
|
||||
if(!initialized) {
|
||||
initialized = true;
|
||||
for(uint n : range(format.size())) {
|
||||
lookup[format[n]] = n;
|
||||
}
|
||||
}
|
||||
|
||||
T result = 0;
|
||||
for(auto byte : value) {
|
||||
result = result * Bits + lookup[byte];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}}
|
@@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <nall/arithmetic.hpp>
|
||||
|
||||
namespace nall { namespace Decode {
|
||||
|
||||
template<typename T> inline auto Base57(const string& value) -> T {
|
||||
T result = 0;
|
||||
for(auto n : rrange(value.size())) {
|
||||
auto byte = value[n];
|
||||
if(byte >= '2' && byte <= '9') byte -= '2' - 0;
|
||||
else if(byte >= 'A' && byte <= 'H') byte -= 'A' - 8;
|
||||
else if(byte >= 'J' && byte <= 'N') byte -= 'J' - 16;
|
||||
else if(byte >= 'P' && byte <= 'Z') byte -= 'P' - 21;
|
||||
else if(byte >= 'a' && byte <= 'k') byte -= 'a' - 32;
|
||||
else if(byte >= 'm' && byte <= 'z') byte -= 'm' - 43;
|
||||
else return 0;
|
||||
result = result * 57 + byte;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}}
|
@@ -3,23 +3,23 @@
|
||||
namespace nall { namespace Decode {
|
||||
|
||||
inline auto Base64(const string& text) -> vector<uint8_t> {
|
||||
auto value = [](char n) -> uint8_t {
|
||||
if(n >= 'A' && n <= 'Z') return n - 'A' + 0;
|
||||
if(n >= 'a' && n <= 'z') return n - 'a' + 26;
|
||||
if(n >= '0' && n <= '9') return n - '0' + 52;
|
||||
if(n == '+' || n == '-') return 62;
|
||||
if(n == '/' || n == '_') return 63;
|
||||
return 64; //error code
|
||||
};
|
||||
static bool initialized = false;
|
||||
static uint8_t lookup[256] = {0};
|
||||
if(!initialized) {
|
||||
initialized = true;
|
||||
for(uint n : range(26)) lookup['A' + n] = n;
|
||||
for(uint n : range(26)) lookup['a' + n] = n + 26;
|
||||
for(uint n : range(10)) lookup['0' + n] = n + 52;
|
||||
lookup['+'] = lookup['-'] = 62;
|
||||
lookup['/'] = lookup['_'] = 63;
|
||||
}
|
||||
|
||||
vector<uint8_t> result;
|
||||
|
||||
uint8_t buffer, output;
|
||||
for(unsigned i = 0; i < text.size(); i++) {
|
||||
uint8_t buffer = value(text[i]);
|
||||
if(buffer > 63) break;
|
||||
for(uint n : range(text.size())) {
|
||||
uint8_t buffer = lookup[text[n]];
|
||||
|
||||
switch(i & 3) {
|
||||
switch(n & 3) {
|
||||
case 0:
|
||||
output = buffer << 2;
|
||||
break;
|
||||
@@ -40,6 +40,7 @@ inline auto Base64(const string& text) -> vector<uint8_t> {
|
||||
}
|
||||
}
|
||||
|
||||
if(text.size() & 3) result.append(output | buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user