2010-08-09 13:28:56 +00:00
|
|
|
#ifndef NALL_VECTOR_HPP
|
|
|
|
#define NALL_VECTOR_HPP
|
|
|
|
|
2011-09-27 11:55:02 +00:00
|
|
|
#include <algorithm>
|
2010-08-09 13:28:56 +00:00
|
|
|
#include <initializer_list>
|
|
|
|
#include <new>
|
|
|
|
#include <utility>
|
|
|
|
#include <nall/algorithm.hpp>
|
|
|
|
#include <nall/bit.hpp>
|
2014-02-09 05:59:46 +00:00
|
|
|
#include <nall/maybe.hpp>
|
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
|
|
|
#include <nall/memory.hpp>
|
2012-01-26 06:50:09 +00:00
|
|
|
#include <nall/sort.hpp>
|
2010-08-09 13:28:56 +00:00
|
|
|
#include <nall/utility.hpp>
|
|
|
|
|
|
|
|
namespace nall {
|
2011-10-16 09:44:48 +00:00
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
template<typename T> struct vector {
|
|
|
|
struct exception_out_of_bounds{};
|
|
|
|
|
Update to v093r01 release.
byuu says:
Changelog:
- added SA-1 MDR; fixes bug in SD Gundam G-Next where the main
battleship was unable to fire
- added out-of-the-box support for any BSD running Clang 3.3+ (FreeBSD
10+, notably)
- added new video shader, "Display Emulation", which changes the shader
based on the emulated system
- fixed the home button to go to your default library path
- phoenix: Windows port won't send onActivate unless an item is selected
(prevents crashing on pressing enter in file dialog)
- ruby: removed vec4 position from out Vertex {} (helps AMD cards)
- shaders: updated all shaders to use texture() instead of texture2D()
(helps AMD cards)
The "Display Emulation" option works like this: when selected, it tries
to load "<path>/Video Shaders/Emulation/<systemName>.shader/"; otherwise
it falls back to the blur shader. <path> is the usual (next to binary,
then in <config>/higan, then in /usr/share/higan, etc); and <systemName>
is "Famicom", "Super Famicom", "Game Boy", "Game Boy Color", "Game Boy
Advance"
To support BSD, I had to modify the $(platform) variable to
differentiate between Linux and BSD.
As such, the new $(platform) values are:
win -> windows
osx -> macosx
x -> linux or bsd
I am also checking uname -s instead of uname -a now. No reason to
potentially match the hostname to the wrong OS type.
2013-10-21 11:45:39 +00:00
|
|
|
explicit operator bool() const { return objectsize; }
|
2015-07-14 09:32:43 +00:00
|
|
|
auto data() -> T* { return pool + poolbase; }
|
|
|
|
auto data() const -> const T* { return pool + poolbase; }
|
2013-05-02 11:25:45 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto empty() const -> bool { return objectsize == 0; }
|
|
|
|
auto size() const -> unsigned { return objectsize; }
|
|
|
|
auto capacity() const -> unsigned { return poolsize; }
|
2013-05-02 11:25:45 +00:00
|
|
|
|
2015-09-28 11:56:46 +00:00
|
|
|
auto release() -> T* {
|
2013-05-02 11:25:45 +00:00
|
|
|
T* result = pool + poolbase;
|
|
|
|
pool = nullptr;
|
|
|
|
poolbase = 0;
|
|
|
|
poolsize = 0;
|
|
|
|
objectsize = 0;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto reset() -> void {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(pool) {
|
|
|
|
for(unsigned n = 0; n < objectsize; n++) pool[poolbase + n].~T();
|
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
|
|
|
memory::free(pool);
|
2011-10-16 09:44:48 +00:00
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
pool = nullptr;
|
|
|
|
poolbase = 0;
|
|
|
|
poolsize = 0;
|
|
|
|
objectsize = 0;
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto reserve(unsigned size) -> void {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(size <= poolsize) return;
|
|
|
|
size = bit::round(size); //amortize growth
|
|
|
|
|
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
|
|
|
T* copy = (T*)memory::allocate(size * sizeof(T));
|
2015-09-28 11:56:46 +00:00
|
|
|
for(unsigned n = 0; n < objectsize; n++) new(copy + n) T(move(pool[poolbase + n]));
|
2013-05-02 11:25:45 +00:00
|
|
|
free(pool);
|
|
|
|
pool = copy;
|
|
|
|
poolbase = 0;
|
|
|
|
poolsize = size;
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto resize(unsigned size, T value = T()) -> void {
|
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
|
|
|
T* copy = (T*)memory::allocate(size * sizeof(T));
|
2015-09-28 11:56:46 +00:00
|
|
|
for(unsigned n = 0; n < size && n < objectsize; n++) new(copy + n) T(move(pool[poolbase + n]));
|
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
|
|
|
for(unsigned n = objectsize; n < size; n++) new(copy + n) T(value);
|
2013-05-02 11:25:45 +00:00
|
|
|
reset();
|
|
|
|
pool = copy;
|
|
|
|
poolbase = 0;
|
|
|
|
poolsize = size;
|
|
|
|
objectsize = size;
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto reallocate(unsigned size, T value = T()) -> void {
|
2015-06-12 13:14:38 +00:00
|
|
|
reset();
|
|
|
|
resize(size, value);
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
template<typename... Args> auto prepend(const T& data, Args&&... args) -> void {
|
|
|
|
prepend(forward<Args>(args)...);
|
2013-05-02 11:25:45 +00:00
|
|
|
prepend(data);
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto prepend(const T& data) -> T& {
|
2013-05-02 11:25:45 +00:00
|
|
|
reserve(objectsize + 1);
|
|
|
|
if(poolbase == 0) {
|
|
|
|
unsigned available = poolsize - objectsize;
|
|
|
|
poolbase = max(1u, available >> 1);
|
|
|
|
for(signed n = objectsize - 1; n >= 0; n--) {
|
2015-09-28 11:56:46 +00:00
|
|
|
pool[poolbase + n] = move(pool[n]);
|
2012-07-08 02:57:34 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
new(pool + --poolbase) T(data);
|
|
|
|
objectsize++;
|
2013-07-29 09:42:45 +00:00
|
|
|
return first();
|
2013-05-02 11:25:45 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
template<typename... Args> auto append(const T& data, Args&&... args) -> void {
|
2013-05-02 11:25:45 +00:00
|
|
|
append(data);
|
2015-07-14 09:32:43 +00:00
|
|
|
append(forward<Args>(args)...);
|
2013-05-02 11:25:45 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto append(const T& data) -> T& {
|
2013-05-02 11:25:45 +00:00
|
|
|
reserve(poolbase + objectsize + 1);
|
|
|
|
new(pool + poolbase + objectsize++) T(data);
|
2013-07-29 09:42:45 +00:00
|
|
|
return last();
|
2013-05-02 11:25:45 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto appendOnce(const T& data) -> bool {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(find(data)) return false;
|
|
|
|
return append(data), true;
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto insert(unsigned position, const T& data) -> void {
|
Update to v094r09 release.
byuu says:
This will easily be the biggest diff in the history of higan. And not in
a good way.
* target-higan and target-loki have been blown away completely
* nall and ruby massively updated
* phoenix replaced with hiro (pretty near a total rewrite)
* target-higan restarted using hiro (just a window for now)
* all emulation cores updated to compile again
* installation changed to not require root privileges (installs locally)
For the foreseeable future (maybe even permanently?), the new higan UI
will only build under Linux/BSD with GTK+ 2.20+. Probably the most
likely route for Windows/OS X will be to try and figure out how to build
hiro/GTK on those platforms, as awful as that would be. The other
alternative would be to produce new UIs for those platforms ... which
would actually be a good opportunity to make something much more user
friendly.
Being that I just started on this a few hours ago, that means that for
at least a few weeks, don't expect to be able to actually play any
games. Right now, you can pretty much just compile the binary and that's
it. It's quite possible that some nall changes didn't produce
compilation errors, but will produce runtime errors. So until the UI can
actually load games, we won't know if anything is broken. But we should
mostly be okay. It was mostly just trim<1> -> trim changes, moving to
Hash::SHA256 (much cleaner), and patching some reckless memory copy
functions enough to compile.
Progress isn't going to be like it was before: I'm now dividing my time
much thinner between studying and other hobbies.
My aim this time is not to produce a binary for everyone to play games
on. Rather, it's to keep the emulator alive. I want to be able to apply
critical patches again. And I would also like the base of the emulator
to live on, for use in other emulator frontends that utilize higan.
2015-02-26 10:10:46 +00:00
|
|
|
if(position == 0) {
|
|
|
|
prepend(data);
|
|
|
|
return;
|
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
append(data);
|
|
|
|
if(position == ~0u) return;
|
|
|
|
for(signed n = objectsize - 1; n > position; n--) {
|
2015-09-28 11:56:46 +00:00
|
|
|
pool[poolbase + n] = move(pool[poolbase + n - 1]);
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
pool[poolbase + position] = data;
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto remove(unsigned position = ~0u, unsigned length = 1) -> void {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(position == ~0u) position = objectsize - 1;
|
|
|
|
if(position + length > objectsize) throw exception_out_of_bounds{};
|
|
|
|
|
|
|
|
if(position == 0) {
|
|
|
|
for(unsigned n = 0; n < length; n++) pool[poolbase + n].~T();
|
|
|
|
poolbase += length;
|
|
|
|
} else {
|
|
|
|
for(unsigned n = position; n < objectsize; n++) {
|
|
|
|
if(n + length < objectsize) {
|
2015-09-28 11:56:46 +00:00
|
|
|
pool[poolbase + n] = move(pool[poolbase + n + length]);
|
2013-05-02 11:25:45 +00:00
|
|
|
} else {
|
|
|
|
pool[poolbase + n].~T();
|
|
|
|
}
|
|
|
|
}
|
2011-10-16 09:44:48 +00:00
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
objectsize -= length;
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto removeFirst() -> void { return remove(0); }
|
|
|
|
auto removeLast() -> void { return remove(~0u); }
|
Update to v093r01 release.
byuu says:
Changelog:
- added SA-1 MDR; fixes bug in SD Gundam G-Next where the main
battleship was unable to fire
- added out-of-the-box support for any BSD running Clang 3.3+ (FreeBSD
10+, notably)
- added new video shader, "Display Emulation", which changes the shader
based on the emulated system
- fixed the home button to go to your default library path
- phoenix: Windows port won't send onActivate unless an item is selected
(prevents crashing on pressing enter in file dialog)
- ruby: removed vec4 position from out Vertex {} (helps AMD cards)
- shaders: updated all shaders to use texture() instead of texture2D()
(helps AMD cards)
The "Display Emulation" option works like this: when selected, it tries
to load "<path>/Video Shaders/Emulation/<systemName>.shader/"; otherwise
it falls back to the blur shader. <path> is the usual (next to binary,
then in <config>/higan, then in /usr/share/higan, etc); and <systemName>
is "Famicom", "Super Famicom", "Game Boy", "Game Boy Color", "Game Boy
Advance"
To support BSD, I had to modify the $(platform) variable to
differentiate between Linux and BSD.
As such, the new $(platform) values are:
win -> windows
osx -> macosx
x -> linux or bsd
I am also checking uname -s instead of uname -a now. No reason to
potentially match the hostname to the wrong OS type.
2013-10-21 11:45:39 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto take(unsigned position = ~0u) -> T {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(position == ~0u) position = objectsize - 1;
|
|
|
|
T object = pool[poolbase + position];
|
|
|
|
remove(position);
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto takeFirst() -> T { return take(0); }
|
|
|
|
auto takeLast() -> T { return take(~0u); }
|
Update to v093r01 release.
byuu says:
Changelog:
- added SA-1 MDR; fixes bug in SD Gundam G-Next where the main
battleship was unable to fire
- added out-of-the-box support for any BSD running Clang 3.3+ (FreeBSD
10+, notably)
- added new video shader, "Display Emulation", which changes the shader
based on the emulated system
- fixed the home button to go to your default library path
- phoenix: Windows port won't send onActivate unless an item is selected
(prevents crashing on pressing enter in file dialog)
- ruby: removed vec4 position from out Vertex {} (helps AMD cards)
- shaders: updated all shaders to use texture() instead of texture2D()
(helps AMD cards)
The "Display Emulation" option works like this: when selected, it tries
to load "<path>/Video Shaders/Emulation/<systemName>.shader/"; otherwise
it falls back to the blur shader. <path> is the usual (next to binary,
then in <config>/higan, then in /usr/share/higan, etc); and <systemName>
is "Famicom", "Super Famicom", "Game Boy", "Game Boy Color", "Game Boy
Advance"
To support BSD, I had to modify the $(platform) variable to
differentiate between Linux and BSD.
As such, the new $(platform) values are:
win -> windows
osx -> macosx
x -> linux or bsd
I am also checking uname -s instead of uname -a now. No reason to
potentially match the hostname to the wrong OS type.
2013-10-21 11:45:39 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto reverse() -> void {
|
2013-05-02 11:25:45 +00:00
|
|
|
unsigned pivot = size() / 2;
|
|
|
|
for(unsigned l = 0, r = size() - 1; l < pivot; l++, r--) {
|
2015-09-28 11:56:46 +00:00
|
|
|
swap(pool[poolbase + l], pool[poolbase + r]);
|
2011-10-16 09:44:48 +00:00
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
}
|
|
|
|
|
Update to v095r03 release and icarus 20151107.
byuu says:
Note: you will need the new icarus (and please use the "no manifest"
system) to run GBA games with this WIP.
Changelog:
- fixed caching of r(d) to pass armwrestler tests [Jonas Quinn]
- DMA to/from GBA BIOS should fail [Cydrak]
- fixed sign-extend and rotate on ldrs instructions [Cydrak]
- fixed 8-bit SRAM reading/writing [byuu]
- refactored GBA/cartridge
- cartridge/rom,ram.type is now cartridge/mrom,sram,eeprom,flash
- things won't crash horribly if you specify a RAM size larger than
the largest legal size in the manifest
- specialized MROM / SRAM classes replace all the shared read/write
functions that didn't work right anyway
- there's a new ruby/video.glx2 driver, which is not enabled by default
- use this if you are running Linux/BSD, but don't have OpenGL 3.2 yet
- I'm not going to support OpenGL2 on Windows/OS X, because these OSes
don't ship ancient video card drivers
- probably more. What am I, clairvoyant? :P
For endrift's tests, this gets us to 1348/1552 memory and 1016/1260
timing. Overall, this puts us back in second place. Only no$ is ahead
on memory, but bgba is even more ahead on timing.
2015-11-08 09:09:18 +00:00
|
|
|
auto sort(const function<bool (const T& lhs, const T& rhs)>& comparator = [](const T& lhs, const T& rhs) -> bool {
|
|
|
|
return lhs < rhs;
|
|
|
|
}) -> void {
|
|
|
|
nall::sort(pool + poolbase, objectsize, comparator);
|
2013-05-02 11:25:45 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto find(const T& data) const -> maybe<unsigned> {
|
2014-02-09 05:59:46 +00:00
|
|
|
for(unsigned n = 0; n < objectsize; n++) if(pool[poolbase + n] == data) return n;
|
|
|
|
return nothing;
|
2013-05-02 11:25:45 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto first() -> T& {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(objectsize == 0) throw exception_out_of_bounds();
|
|
|
|
return pool[poolbase];
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto first() const -> const T& {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(objectsize == 0) throw exception_out_of_bounds();
|
|
|
|
return pool[poolbase];
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto last() -> T& {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(objectsize == 0) throw exception_out_of_bounds();
|
|
|
|
return pool[poolbase + objectsize - 1];
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto last() const -> const T& {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(objectsize == 0) throw exception_out_of_bounds();
|
|
|
|
return pool[poolbase + objectsize - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
//access
|
2015-07-14 09:32:43 +00:00
|
|
|
inline auto operator[](unsigned position) -> T& {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(position >= objectsize) throw exception_out_of_bounds();
|
|
|
|
return pool[poolbase + position];
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
inline auto operator[](unsigned position) const -> const T& {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(position >= objectsize) throw exception_out_of_bounds();
|
|
|
|
return pool[poolbase + position];
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
inline auto operator()(unsigned position) -> T& {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(position >= poolsize) reserve(position + 1);
|
|
|
|
while(position >= objectsize) append(T());
|
|
|
|
return pool[poolbase + position];
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
inline auto operator()(unsigned position, const T& data) const -> const T& {
|
2013-05-02 11:25:45 +00:00
|
|
|
if(position >= objectsize) return data;
|
|
|
|
return pool[poolbase + position];
|
|
|
|
}
|
|
|
|
|
|
|
|
//iteration
|
|
|
|
struct iterator {
|
|
|
|
iterator(vector& source, unsigned position) : source(source), position(position) {}
|
2015-07-14 09:32:43 +00:00
|
|
|
auto operator*() -> T& { return source.operator[](position); }
|
|
|
|
auto operator!=(const iterator& source) const -> bool { return position != source.position; }
|
|
|
|
auto operator++() -> iterator& { position++; return *this; }
|
2013-05-02 11:25:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
vector& source;
|
|
|
|
unsigned position;
|
|
|
|
};
|
2011-10-16 09:44:48 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto begin() -> iterator { return iterator(*this, 0); }
|
|
|
|
auto end() -> iterator { return iterator(*this, size()); }
|
2011-10-16 09:44:48 +00:00
|
|
|
|
2013-12-03 10:01:59 +00:00
|
|
|
struct constIterator {
|
|
|
|
constIterator(const vector& source, unsigned position) : source(source), position(position) {}
|
2015-07-14 09:32:43 +00:00
|
|
|
auto operator*() const -> const T& { return source.operator[](position); }
|
|
|
|
auto operator!=(const constIterator& source) const -> bool { return position != source.position; }
|
|
|
|
auto operator++() -> constIterator& { position++; return *this; }
|
2011-10-16 09:44:48 +00:00
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
private:
|
|
|
|
const vector& source;
|
|
|
|
unsigned position;
|
|
|
|
};
|
2011-10-16 09:44:48 +00:00
|
|
|
|
2015-07-14 09:32:43 +00:00
|
|
|
auto begin() const -> const constIterator { return constIterator(*this, 0); }
|
|
|
|
auto end() const -> const constIterator { return constIterator(*this, size()); }
|
2013-05-02 11:25:45 +00:00
|
|
|
|
|
|
|
//copy
|
2015-07-14 09:32:43 +00:00
|
|
|
inline auto operator=(const vector& source) -> vector& {
|
Update to v094r09 release.
byuu says:
This will easily be the biggest diff in the history of higan. And not in
a good way.
* target-higan and target-loki have been blown away completely
* nall and ruby massively updated
* phoenix replaced with hiro (pretty near a total rewrite)
* target-higan restarted using hiro (just a window for now)
* all emulation cores updated to compile again
* installation changed to not require root privileges (installs locally)
For the foreseeable future (maybe even permanently?), the new higan UI
will only build under Linux/BSD with GTK+ 2.20+. Probably the most
likely route for Windows/OS X will be to try and figure out how to build
hiro/GTK on those platforms, as awful as that would be. The other
alternative would be to produce new UIs for those platforms ... which
would actually be a good opportunity to make something much more user
friendly.
Being that I just started on this a few hours ago, that means that for
at least a few weeks, don't expect to be able to actually play any
games. Right now, you can pretty much just compile the binary and that's
it. It's quite possible that some nall changes didn't produce
compilation errors, but will produce runtime errors. So until the UI can
actually load games, we won't know if anything is broken. But we should
mostly be okay. It was mostly just trim<1> -> trim changes, moving to
Hash::SHA256 (much cleaner), and patching some reckless memory copy
functions enough to compile.
Progress isn't going to be like it was before: I'm now dividing my time
much thinner between studying and other hobbies.
My aim this time is not to produce a binary for everyone to play games
on. Rather, it's to keep the emulator alive. I want to be able to apply
critical patches again. And I would also like the base of the emulator
to live on, for use in other emulator frontends that utilize higan.
2015-02-26 10:10:46 +00:00
|
|
|
if(this == &source) return *this;
|
2013-05-02 11:25:45 +00:00
|
|
|
reset();
|
|
|
|
reserve(source.size());
|
|
|
|
for(auto& data : source) append(data);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//move
|
2015-07-14 09:32:43 +00:00
|
|
|
inline auto operator=(vector&& source) -> vector& {
|
Update to v094r09 release.
byuu says:
This will easily be the biggest diff in the history of higan. And not in
a good way.
* target-higan and target-loki have been blown away completely
* nall and ruby massively updated
* phoenix replaced with hiro (pretty near a total rewrite)
* target-higan restarted using hiro (just a window for now)
* all emulation cores updated to compile again
* installation changed to not require root privileges (installs locally)
For the foreseeable future (maybe even permanently?), the new higan UI
will only build under Linux/BSD with GTK+ 2.20+. Probably the most
likely route for Windows/OS X will be to try and figure out how to build
hiro/GTK on those platforms, as awful as that would be. The other
alternative would be to produce new UIs for those platforms ... which
would actually be a good opportunity to make something much more user
friendly.
Being that I just started on this a few hours ago, that means that for
at least a few weeks, don't expect to be able to actually play any
games. Right now, you can pretty much just compile the binary and that's
it. It's quite possible that some nall changes didn't produce
compilation errors, but will produce runtime errors. So until the UI can
actually load games, we won't know if anything is broken. But we should
mostly be okay. It was mostly just trim<1> -> trim changes, moving to
Hash::SHA256 (much cleaner), and patching some reckless memory copy
functions enough to compile.
Progress isn't going to be like it was before: I'm now dividing my time
much thinner between studying and other hobbies.
My aim this time is not to produce a binary for everyone to play games
on. Rather, it's to keep the emulator alive. I want to be able to apply
critical patches again. And I would also like the base of the emulator
to live on, for use in other emulator frontends that utilize higan.
2015-02-26 10:10:46 +00:00
|
|
|
if(this == &source) return *this;
|
2013-05-02 11:25:45 +00:00
|
|
|
reset();
|
|
|
|
pool = source.pool;
|
|
|
|
poolbase = source.poolbase;
|
|
|
|
poolsize = source.poolsize;
|
|
|
|
objectsize = source.objectsize;
|
|
|
|
source.pool = nullptr;
|
|
|
|
source.poolbase = 0;
|
|
|
|
source.poolsize = 0;
|
|
|
|
source.objectsize = 0;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//construction and destruction
|
|
|
|
vector() = default;
|
2015-09-28 11:56:46 +00:00
|
|
|
vector(initializer_list<T> list) { for(auto& data : list) append(data); }
|
2013-05-02 11:25:45 +00:00
|
|
|
vector(const vector& source) { operator=(source); }
|
2015-09-28 11:56:46 +00:00
|
|
|
vector(vector&& source) { operator=(move(source)); }
|
2013-05-02 11:25:45 +00:00
|
|
|
~vector() { reset(); }
|
2015-07-14 09:32:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
T* pool = nullptr;
|
|
|
|
unsigned poolbase = 0;
|
|
|
|
unsigned poolsize = 0;
|
|
|
|
unsigned objectsize = 0;
|
2013-05-02 11:25:45 +00:00
|
|
|
};
|
2011-10-16 09:44:48 +00:00
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|