Skip to content

Commit

Permalink
v106.214
Browse files Browse the repository at this point in the history
Fix compilation issue with icarus property->attribute renaming.
Improve issues with nall suffix arrays (doesn't really affect higan.)
  • Loading branch information
byuu committed Sep 13, 2019
1 parent bb40d92 commit 92d91b9
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion higan/emulator/emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using namespace nall;

namespace higan {
static const string Name = "higan";
static const string Version = "106.213";
static const string Version = "106.214";
static const string Author = "byuu";
static const string License = "GPLv3";
static const string Website = "https://byuu.org";
Expand Down
4 changes: 2 additions & 2 deletions icarus/program/game-importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ auto GameImporter::import(string system, const vector<string>& files) -> void {
} else {
item.setIcon(Icon::Action::Close);
item.setForegroundColor({192, 0, 0});
item.setProperty("error", error);
item.setAttribute("error", error);
}
item.setText(Location::file(file));
importList.resizeColumn();
Expand All @@ -46,7 +46,7 @@ auto GameImporter::import(string system, const vector<string>& files) -> void {
auto GameImporter::eventChange() -> void {
if(processing) return;
if(auto item = importList.selected()) {
if(auto error = item.property("error")) {
if(auto error = item.attribute("error")) {
messageLabel.setText({"Error: ", error, "."});
} else {
messageLabel.setText("OK.");
Expand Down
2 changes: 1 addition & 1 deletion nall/beat/single/apply.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ inline auto apply(array_view<uint8_t> source, array_view<uint8_t> beat, maybe<st
if(mode == SourceRead) {
while(length--) write(source[target.size()]);
} else if(mode == TargetRead) {
while(length--) write(read());
while(length--)write(read());
} else {
int offset = decode();
offset = offset & 1 ? -(offset >> 1) : (offset >> 1);
Expand Down
4 changes: 2 additions & 2 deletions nall/beat/single/create.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ inline auto create(array_view<uint8_t> source, array_view<uint8_t> target, strin
while(targetReadLength) write(target[offset++]), targetReadLength--;
};

uint longestSize = max(source.size(), target.size());
uint overlap = min(source.size(), target.size());
while(outputOffset < target.size()) {
uint mode = TargetRead, longestLength = 3, longestOffset = 0;
int length = 0, offset = outputOffset;

while(offset < longestSize) {
while(offset < overlap) {
if(source[offset] != target[offset]) break;
length++, offset++;
}
Expand Down
7 changes: 4 additions & 3 deletions nall/induced-sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace nall {
//where the first character is the empty suffix, equal to size

template<typename T>
inline auto induced_sort(const T* data, const uint size, const uint characters = 256) -> vector<int> {
inline auto induced_sort(array_view<T> data, const uint characters = 256) -> vector<int> {
const uint size = data.size();
if(size == 0) return vector<int>{0}; //required to avoid out-of-bounds accesses
if(size == 1) return vector<int>{1, 0}; //not strictly necessary; but more performant

Expand Down Expand Up @@ -153,14 +154,14 @@ inline auto induced_sort(const T* data, const uint size, const uint characters =
}
} else {
//recurse until every character in summaryData is unique ...
summaries = induced_sort(summaryData.data(), summaryData.size() - 1, summaryCharacters);
summaries = induced_sort<int>({summaryData.data(), summaryData.size()}, summaryCharacters);
}

suffixes.fill(-1); //reuse existing buffer for accurate sort

//accurate LMS sort
getTails();
for(uint n : reverse(range(1, summaries.size()))) {
for(uint n : reverse(range(2, summaries.size()))) {
auto index = summaryOffsets[summaries[n]];
suffixes[tails[data[index]]--] = index; //advance from the tail of the bucket
}
Expand Down
4 changes: 4 additions & 0 deletions nall/random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ namespace PRNG {

//Galois linear feedback shift register using CRC64 polynomials
struct LFSR : RNG<LFSR> {
LFSR() { seed(); }

auto seed(maybe<uint64_t> seed = {}) -> void {
lfsr = seed ? seed() : (uint64_t)randomSeed();
for(uint n : range(8)) read(); //hide the CRC64 polynomial from initial output
Expand All @@ -84,6 +86,8 @@ struct LFSR : RNG<LFSR> {
};

struct PCG : RNG<PCG> {
PCG() { seed(); }

auto seed(maybe<uint32_t> seed = {}, maybe<uint32_t> sequence = {}) -> void {
if(!seed) seed = (uint32_t)randomSeed();
if(!sequence) sequence = 0;
Expand Down
1 change: 1 addition & 0 deletions nall/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct string_view {
inline auto operator=(const string_view& source) -> type&;
inline auto operator=(string_view&& source) -> type&;

inline explicit operator bool() const;
inline operator const char*() const;
inline auto data() const -> const char*;
inline auto size() const -> uint;
Expand Down
4 changes: 4 additions & 0 deletions nall/string/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ auto string_view::operator=(string_view&& source) -> type& {
return *this;
};

string_view::operator bool() const {
return _size > 0;
}

string_view::operator const char*() const {
return _data;
}
Expand Down
14 changes: 10 additions & 4 deletions nall/suffix-array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace nall {
// suffix array via induced sorting
// O(n)
inline auto suffix_array(array_view<uint8_t> input) -> vector<int> {
return induced_sort(input.data(), input.size());
return induced_sort(input);
}

// inverse
Expand Down Expand Up @@ -181,6 +181,7 @@ inline auto suffix_array_plcp(array_view<int> lcp, array_view<int> sa) -> vector
return plcp;
}

// TODO: this generates incorrect results in some cases; there is a bug somewhere in this function!
// longest common prefixes - left + right
// llcp[m] == lcp(l, m)
// rlcp[m] == lcp(m, r)
Expand Down Expand Up @@ -274,6 +275,8 @@ inline auto suffix_array_find(int& length, int& offset, array_view<int> sa, arra
if(k == match.size()) return true;
}

if(k == match.size() || s + k == input.size()) k--;

if(match[k] < input[s + k]) {
r = m;
} else {
Expand Down Expand Up @@ -304,6 +307,8 @@ inline auto suffix_array_find(int& length, int& offset, array_view<int> llcp, ar
if(k == match.size()) return true;
}

if(k == match.size() || s + k == input.size()) k--;

if(match[k] < input[s + k]) {
r = m;
k = min(k, llcp[m]);
Expand All @@ -330,12 +335,13 @@ struct SuffixArray {

//O(n)
inline auto lrcp() -> type& {
//TODO: disabled due to a big in suffix_array_lrcp: uses O(n log m) find algorithm instead
//if(!isa) isa = suffix_array_invert(sa);
//if(!lcp) lcp = suffix_array_lcp(sa, isa, input);
if(!phi) phi = suffix_array_phi(sa);
if(!plcp) plcp = suffix_array_plcp(phi, input);
//if(!phi) phi = suffix_array_phi(sa);
//if(!plcp) plcp = suffix_array_plcp(phi, input);
//if(!lcp) lcp = suffix_array_lcp(plcp, sa);
if(!llcp || !rlcp) suffix_array_lrcp(llcp, rlcp, lcp, plcp, sa, input);
//if(!llcp || !rlcp) suffix_array_lrcp(llcp, rlcp, lcp, plcp, sa, input);
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion ruby/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ifeq ($(ruby),)
ruby += input.sdl input.xlib input.udev
else ifeq ($(platform),bsd)
ruby += video.glx video.glx2 video.xvideo video.xshm
ruby += audio.oss
ruby += audio.oss #audio.pulseaudio
ruby += input.sdl input.xlib
endif
endif
Expand Down

0 comments on commit 92d91b9

Please sign in to comment.