Update to v073 release.
byuu says:
This release marks a major step forward, offering full low-level
emulation of all four DSP coprocessors based on the NEC uPD77C25
processor core. Many people were responsible for this milestone: Dr.
Decapitator for the actual decapping and extraction; Lord Nightmare for
the cartridges and some special analysis tools; myself, Jonas Quinn and
Cydrak for the uPD77C25 emulation; and all of the donors who raised the
necessary $1,000 for the necessary hardware and equipment needed to pull
this all off. To say thanks to the donors, I am releasing the uPD77C25
emulation core to the public domain, so that everyone can benefit from
it.
All four DSP emulations will be improved by this by way of having
realistic timing; the DSP-4 will benefit further as the high-level
emulation was incomplete and somewhat buggy; and the DSP-3 will benefit
the most as the high-levle emulation there was not complete enough to be
playable. As a result, most notably, this means bsnes v073 is the first
emulator to fully be able to play SD Gundam GX (J)!
As bsnes' primary goal is accuracy, the LLE DSP support renders the old
HLE DSP support obsolete. Ergo, I have removed the 166KB of HLE source
code, and replaced it with the uPD77C25 core, which comprises a mere
20KB of source code. As this LLE module supports save states, this also
means that for the first time, DSP-3 and DSP-4 games have save state
support.
On the other hand, this also means that to run any DSP game, you will
need the appropriate program ROM. As these are copyrighted, I cannot
distribute them nor tell you where to get them. All I can do is provide
you with the necessary filenames and hashes.
Changelog (since v072 release):
* added NEC uPD77C25 emulation core
* added low-level emulation of the DSP-1, DSP-1B, DSP-2, DSP-3, DSP-4
coprocessors
* removed high-level emulation of the DSP-n coprocessors
* added blargg's libco::ppc.c module, which is far more portable, even
running on the PS3
* added software filter support via binary plugins
* added debugger (currently Linux-only); but it is as yet unstable
* added pause shortcut
* updated mightymo's cheat code database
2010-12-26 12:24:34 +00:00
|
|
|
#ifndef NALL_VECTOR_HPP
|
|
|
|
#define NALL_VECTOR_HPP
|
|
|
|
|
2012-04-24 13:13:42 +00:00
|
|
|
#include <algorithm>
|
Update to v073 release.
byuu says:
This release marks a major step forward, offering full low-level
emulation of all four DSP coprocessors based on the NEC uPD77C25
processor core. Many people were responsible for this milestone: Dr.
Decapitator for the actual decapping and extraction; Lord Nightmare for
the cartridges and some special analysis tools; myself, Jonas Quinn and
Cydrak for the uPD77C25 emulation; and all of the donors who raised the
necessary $1,000 for the necessary hardware and equipment needed to pull
this all off. To say thanks to the donors, I am releasing the uPD77C25
emulation core to the public domain, so that everyone can benefit from
it.
All four DSP emulations will be improved by this by way of having
realistic timing; the DSP-4 will benefit further as the high-level
emulation was incomplete and somewhat buggy; and the DSP-3 will benefit
the most as the high-levle emulation there was not complete enough to be
playable. As a result, most notably, this means bsnes v073 is the first
emulator to fully be able to play SD Gundam GX (J)!
As bsnes' primary goal is accuracy, the LLE DSP support renders the old
HLE DSP support obsolete. Ergo, I have removed the 166KB of HLE source
code, and replaced it with the uPD77C25 core, which comprises a mere
20KB of source code. As this LLE module supports save states, this also
means that for the first time, DSP-3 and DSP-4 games have save state
support.
On the other hand, this also means that to run any DSP game, you will
need the appropriate program ROM. As these are copyrighted, I cannot
distribute them nor tell you where to get them. All I can do is provide
you with the necessary filenames and hashes.
Changelog (since v072 release):
* added NEC uPD77C25 emulation core
* added low-level emulation of the DSP-1, DSP-1B, DSP-2, DSP-3, DSP-4
coprocessors
* removed high-level emulation of the DSP-n coprocessors
* added blargg's libco::ppc.c module, which is far more portable, even
running on the PS3
* added software filter support via binary plugins
* added debugger (currently Linux-only); but it is as yet unstable
* added pause shortcut
* updated mightymo's cheat code database
2010-12-26 12:24:34 +00:00
|
|
|
#include <initializer_list>
|
|
|
|
#include <new>
|
|
|
|
#include <type_traits>
|
|
|
|
#include <utility>
|
|
|
|
#include <nall/algorithm.hpp>
|
|
|
|
#include <nall/bit.hpp>
|
2012-04-24 13:13:42 +00:00
|
|
|
#include <nall/sort.hpp>
|
Update to v073 release.
byuu says:
This release marks a major step forward, offering full low-level
emulation of all four DSP coprocessors based on the NEC uPD77C25
processor core. Many people were responsible for this milestone: Dr.
Decapitator for the actual decapping and extraction; Lord Nightmare for
the cartridges and some special analysis tools; myself, Jonas Quinn and
Cydrak for the uPD77C25 emulation; and all of the donors who raised the
necessary $1,000 for the necessary hardware and equipment needed to pull
this all off. To say thanks to the donors, I am releasing the uPD77C25
emulation core to the public domain, so that everyone can benefit from
it.
All four DSP emulations will be improved by this by way of having
realistic timing; the DSP-4 will benefit further as the high-level
emulation was incomplete and somewhat buggy; and the DSP-3 will benefit
the most as the high-levle emulation there was not complete enough to be
playable. As a result, most notably, this means bsnes v073 is the first
emulator to fully be able to play SD Gundam GX (J)!
As bsnes' primary goal is accuracy, the LLE DSP support renders the old
HLE DSP support obsolete. Ergo, I have removed the 166KB of HLE source
code, and replaced it with the uPD77C25 core, which comprises a mere
20KB of source code. As this LLE module supports save states, this also
means that for the first time, DSP-3 and DSP-4 games have save state
support.
On the other hand, this also means that to run any DSP game, you will
need the appropriate program ROM. As these are copyrighted, I cannot
distribute them nor tell you where to get them. All I can do is provide
you with the necessary filenames and hashes.
Changelog (since v072 release):
* added NEC uPD77C25 emulation core
* added low-level emulation of the DSP-1, DSP-1B, DSP-2, DSP-3, DSP-4
coprocessors
* removed high-level emulation of the DSP-n coprocessors
* added blargg's libco::ppc.c module, which is far more portable, even
running on the PS3
* added software filter support via binary plugins
* added debugger (currently Linux-only); but it is as yet unstable
* added pause shortcut
* updated mightymo's cheat code database
2010-12-26 12:24:34 +00:00
|
|
|
#include <nall/utility.hpp>
|
|
|
|
|
|
|
|
namespace nall {
|
2012-04-24 13:13:42 +00:00
|
|
|
template<typename T> struct vector {
|
|
|
|
struct exception_out_of_bounds{};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
T *pool;
|
|
|
|
unsigned poolsize;
|
|
|
|
unsigned objectsize;
|
|
|
|
|
|
|
|
public:
|
2012-06-25 12:49:39 +00:00
|
|
|
operator bool() const { return pool; }
|
|
|
|
T* data() { return pool; }
|
|
|
|
|
Update to v089r17 release.
byuu says:
This implements the spec from the XML part 3 thread:
http://board.byuu.org/viewtopic.php?f=16&t=2998
It's also propagated the changes to nall and purify, so you can test
this one.
This is basically it, after years of effort I feel I finally have
a fully consistent and logical XML board format.
The only things left to change will be: modifications if emulation turns
out to be incorrect (eg we missed some MMIO mirrors, or mirrored too
much), and new additions.
And of course, I'm giving it a bit of time for good arguments against
the format.
Other than that, this release removes linear_vector and pointer_vector,
as vector is better than linear_vector and I've never used
pointer_vector.
vector also gets move(), which is a way to use move-semantics across
types. It lets you steal the underlying memory pool, effectively
destroying the vector without a copy.
This works really nicely with the move for read() functions to return
vector<uint8> instead of taking (uint8_t*&, unsigned&) parameters.
2012-07-15 13:02:27 +00:00
|
|
|
bool empty() const { return objectsize == 0; }
|
2012-04-24 13:13:42 +00:00
|
|
|
unsigned size() const { return objectsize; }
|
|
|
|
unsigned capacity() const { return poolsize; }
|
|
|
|
|
Update to v089r17 release.
byuu says:
This implements the spec from the XML part 3 thread:
http://board.byuu.org/viewtopic.php?f=16&t=2998
It's also propagated the changes to nall and purify, so you can test
this one.
This is basically it, after years of effort I feel I finally have
a fully consistent and logical XML board format.
The only things left to change will be: modifications if emulation turns
out to be incorrect (eg we missed some MMIO mirrors, or mirrored too
much), and new additions.
And of course, I'm giving it a bit of time for good arguments against
the format.
Other than that, this release removes linear_vector and pointer_vector,
as vector is better than linear_vector and I've never used
pointer_vector.
vector also gets move(), which is a way to use move-semantics across
types. It lets you steal the underlying memory pool, effectively
destroying the vector without a copy.
This works really nicely with the move for read() functions to return
vector<uint8> instead of taking (uint8_t*&, unsigned&) parameters.
2012-07-15 13:02:27 +00:00
|
|
|
T* move() {
|
2012-07-23 12:53:28 +00:00
|
|
|
T *result = pool;
|
Update to v089r17 release.
byuu says:
This implements the spec from the XML part 3 thread:
http://board.byuu.org/viewtopic.php?f=16&t=2998
It's also propagated the changes to nall and purify, so you can test
this one.
This is basically it, after years of effort I feel I finally have
a fully consistent and logical XML board format.
The only things left to change will be: modifications if emulation turns
out to be incorrect (eg we missed some MMIO mirrors, or mirrored too
much), and new additions.
And of course, I'm giving it a bit of time for good arguments against
the format.
Other than that, this release removes linear_vector and pointer_vector,
as vector is better than linear_vector and I've never used
pointer_vector.
vector also gets move(), which is a way to use move-semantics across
types. It lets you steal the underlying memory pool, effectively
destroying the vector without a copy.
This works really nicely with the move for read() functions to return
vector<uint8> instead of taking (uint8_t*&, unsigned&) parameters.
2012-07-15 13:02:27 +00:00
|
|
|
pool = nullptr;
|
|
|
|
poolsize = 0;
|
|
|
|
objectsize = 0;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-04-24 13:13:42 +00:00
|
|
|
void reset() {
|
|
|
|
if(pool) {
|
|
|
|
for(unsigned n = 0; n < objectsize; n++) pool[n].~T();
|
|
|
|
free(pool);
|
|
|
|
}
|
|
|
|
pool = nullptr;
|
|
|
|
poolsize = 0;
|
|
|
|
objectsize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void reserve(unsigned size) {
|
|
|
|
size = bit::round(size); //amortize growth
|
|
|
|
T *copy = (T*)calloc(size, sizeof(T));
|
|
|
|
for(unsigned n = 0; n < min(size, objectsize); n++) new(copy + n) T(pool[n]);
|
|
|
|
for(unsigned n = 0; n < objectsize; n++) pool[n].~T();
|
|
|
|
free(pool);
|
|
|
|
pool = copy;
|
|
|
|
poolsize = size;
|
|
|
|
objectsize = min(size, objectsize);
|
|
|
|
}
|
|
|
|
|
2012-06-25 12:49:39 +00:00
|
|
|
//requires trivial constructor
|
|
|
|
void resize(unsigned size) {
|
|
|
|
if(size == objectsize) return;
|
|
|
|
if(size < objectsize) return reserve(size);
|
|
|
|
while(size > objectsize) append(T());
|
|
|
|
}
|
|
|
|
|
2012-04-24 13:13:42 +00:00
|
|
|
template<typename... Args>
|
|
|
|
void append(const T& data, Args&&... args) {
|
|
|
|
append(data);
|
|
|
|
append(std::forward<Args>(args)...);
|
|
|
|
}
|
|
|
|
|
|
|
|
void append(const T& data) {
|
|
|
|
if(objectsize + 1 > poolsize) reserve(objectsize + 1);
|
|
|
|
new(pool + objectsize++) T(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool appendonce(const T& data) {
|
|
|
|
if(find(data) == true) return false;
|
|
|
|
append(data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void insert(unsigned position, const T& data) {
|
|
|
|
append(data);
|
|
|
|
for(signed n = size() - 1; n > position; n--) pool[n] = pool[n - 1];
|
|
|
|
pool[position] = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void prepend(const T& data) {
|
|
|
|
insert(0, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void remove(unsigned index = ~0u, unsigned count = 1) {
|
|
|
|
if(index == ~0) index = objectsize ? objectsize - 1 : 0;
|
|
|
|
for(unsigned n = index; count + n < objectsize; n++) pool[n] = pool[count + n];
|
|
|
|
objectsize = (count + index >= objectsize) ? index : objectsize - count;
|
|
|
|
}
|
|
|
|
|
|
|
|
T take(unsigned index = ~0u) {
|
|
|
|
if(index == ~0) index = objectsize ? objectsize - 1 : 0;
|
|
|
|
if(index >= objectsize) throw exception_out_of_bounds();
|
|
|
|
T item = pool[index];
|
|
|
|
remove(index);
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
Update to v089r17 release.
byuu says:
This implements the spec from the XML part 3 thread:
http://board.byuu.org/viewtopic.php?f=16&t=2998
It's also propagated the changes to nall and purify, so you can test
this one.
This is basically it, after years of effort I feel I finally have
a fully consistent and logical XML board format.
The only things left to change will be: modifications if emulation turns
out to be incorrect (eg we missed some MMIO mirrors, or mirrored too
much), and new additions.
And of course, I'm giving it a bit of time for good arguments against
the format.
Other than that, this release removes linear_vector and pointer_vector,
as vector is better than linear_vector and I've never used
pointer_vector.
vector also gets move(), which is a way to use move-semantics across
types. It lets you steal the underlying memory pool, effectively
destroying the vector without a copy.
This works really nicely with the move for read() functions to return
vector<uint8> instead of taking (uint8_t*&, unsigned&) parameters.
2012-07-15 13:02:27 +00:00
|
|
|
void reverse() {
|
|
|
|
unsigned pivot = size() / 2;
|
|
|
|
for(unsigned l = 0, r = size() - 1; l < pivot; l++, r--) {
|
|
|
|
std::swap(pool[l], pool[r]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-24 13:13:42 +00:00
|
|
|
void sort() {
|
|
|
|
nall::sort(pool, objectsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Comparator> void sort(const Comparator &lessthan) {
|
|
|
|
nall::sort(pool, objectsize, lessthan);
|
|
|
|
}
|
|
|
|
|
|
|
|
optional<unsigned> find(const T& data) {
|
|
|
|
for(unsigned n = 0; n < size(); n++) if(pool[n] == data) return { true, n };
|
|
|
|
return { false, 0u };
|
|
|
|
}
|
|
|
|
|
|
|
|
T& first() {
|
|
|
|
if(objectsize == 0) throw exception_out_of_bounds();
|
|
|
|
return pool[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
T& last() {
|
|
|
|
if(objectsize == 0) throw exception_out_of_bounds();
|
|
|
|
return pool[objectsize - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
//access
|
|
|
|
inline T& operator[](unsigned position) {
|
|
|
|
if(position >= objectsize) throw exception_out_of_bounds();
|
|
|
|
return pool[position];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const T& operator[](unsigned position) const {
|
|
|
|
if(position >= objectsize) throw exception_out_of_bounds();
|
|
|
|
return pool[position];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline T& operator()(unsigned position) {
|
|
|
|
if(position >= poolsize) reserve(position + 1);
|
|
|
|
while(position >= objectsize) append(T());
|
|
|
|
return pool[position];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const T& operator()(unsigned position, const T& data) const {
|
|
|
|
if(position >= objectsize) return data;
|
|
|
|
return pool[position];
|
|
|
|
}
|
|
|
|
|
|
|
|
//iteration
|
|
|
|
T* begin() { return &pool[0]; }
|
|
|
|
T* end() { return &pool[objectsize]; }
|
|
|
|
const T* begin() const { return &pool[0]; }
|
|
|
|
const T* end() const { return &pool[objectsize]; }
|
|
|
|
|
|
|
|
//copy
|
|
|
|
inline vector& operator=(const vector &source) {
|
|
|
|
reset();
|
|
|
|
reserve(source.capacity());
|
|
|
|
for(auto &data : source) append(data);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
vector(const vector &source) : pool(nullptr), poolsize(0), objectsize(0) {
|
|
|
|
operator=(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
//move
|
|
|
|
inline vector& operator=(vector &&source) {
|
|
|
|
reset();
|
|
|
|
pool = source.pool, poolsize = source.poolsize, objectsize = source.objectsize;
|
|
|
|
source.pool = nullptr, source.poolsize = 0, source.objectsize = 0;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
vector(vector &&source) : pool(nullptr), poolsize(0), objectsize(0) {
|
|
|
|
operator=(std::move(source));
|
|
|
|
}
|
|
|
|
|
|
|
|
//construction
|
|
|
|
vector() : pool(nullptr), poolsize(0), objectsize(0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
vector(std::initializer_list<T> list) : pool(nullptr), poolsize(0), objectsize(0) {
|
|
|
|
for(auto &data : list) append(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
~vector() {
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
};
|
Update to v073 release.
byuu says:
This release marks a major step forward, offering full low-level
emulation of all four DSP coprocessors based on the NEC uPD77C25
processor core. Many people were responsible for this milestone: Dr.
Decapitator for the actual decapping and extraction; Lord Nightmare for
the cartridges and some special analysis tools; myself, Jonas Quinn and
Cydrak for the uPD77C25 emulation; and all of the donors who raised the
necessary $1,000 for the necessary hardware and equipment needed to pull
this all off. To say thanks to the donors, I am releasing the uPD77C25
emulation core to the public domain, so that everyone can benefit from
it.
All four DSP emulations will be improved by this by way of having
realistic timing; the DSP-4 will benefit further as the high-level
emulation was incomplete and somewhat buggy; and the DSP-3 will benefit
the most as the high-levle emulation there was not complete enough to be
playable. As a result, most notably, this means bsnes v073 is the first
emulator to fully be able to play SD Gundam GX (J)!
As bsnes' primary goal is accuracy, the LLE DSP support renders the old
HLE DSP support obsolete. Ergo, I have removed the 166KB of HLE source
code, and replaced it with the uPD77C25 core, which comprises a mere
20KB of source code. As this LLE module supports save states, this also
means that for the first time, DSP-3 and DSP-4 games have save state
support.
On the other hand, this also means that to run any DSP game, you will
need the appropriate program ROM. As these are copyrighted, I cannot
distribute them nor tell you where to get them. All I can do is provide
you with the necessary filenames and hashes.
Changelog (since v072 release):
* added NEC uPD77C25 emulation core
* added low-level emulation of the DSP-1, DSP-1B, DSP-2, DSP-3, DSP-4
coprocessors
* removed high-level emulation of the DSP-n coprocessors
* added blargg's libco::ppc.c module, which is far more portable, even
running on the PS3
* added software filter support via binary plugins
* added debugger (currently Linux-only); but it is as yet unstable
* added pause shortcut
* updated mightymo's cheat code database
2010-12-26 12:24:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|