2016-01-07 08:14:33 +00:00
|
|
|
#pragma once
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
#include <nall/serializer.hpp>
|
|
|
|
#include <nall/traits.hpp>
|
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
|
|
|
struct Boolean {
|
|
|
|
inline Boolean() : data(false) {}
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
template<typename T> inline Boolean(const T& value) : data(value) {}
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
inline operator bool() const { return data; }
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
template<typename T> inline auto& operator=(const T& value) { data = value; return *this; }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
Update to v100r14 release.
byuu says:
(Windows: compile with -fpermissive to silence an annoying error. I'll
fix it in the next WIP.)
I completely replaced the time management system in higan and overhauled
the scheduler.
Before, processor threads would have "int64 clock"; and there would
be a 1:1 relationship between two threads. When thread A ran for X
cycles, it'd subtract X * B.Frequency from clock; and when thread B ran
for Y cycles, it'd add Y * A.Frequency from clock. This worked well
and allowed perfect precision; but it doesn't work when you have more
complicated relationships: eg the 68K can sync to the Z80 and PSG; the
Z80 to the 68K and PSG; so the PSG needs two counters.
The new system instead uses a "uint64 clock" variable that represents
time in attoseconds. Every time the scheduler exits, it subtracts
the smallest clock count from all threads, to prevent an overflow
scenario. The only real downside is that rounding errors mean that
roughly every 20 minutes, we have a rounding error of one clock cycle
(one 20,000,000th of a second.) However, this only applies to systems
with multiple oscillators, like the SNES. And when you're in that
situation ... there's no such thing as a perfect oscillator anyway. A
real SNES will be thousands of times less out of spec than 1hz per 20
minutes.
The advantages are pretty immense. First, we obviously can now support
more complex relationships between threads. Second, we can build a
much more abstracted scheduler. All of libco is now abstracted away
completely, which may permit a state-machine / coroutine version of
Thread in the future. We've basically gone from this:
auto SMP::step(uint clocks) -> void {
clock += clocks * (uint64)cpu.frequency;
dsp.clock -= clocks;
if(dsp.clock < 0 && !scheduler.synchronizing()) co_switch(dsp.thread);
if(clock >= 0 && !scheduler.synchronizing()) co_switch(cpu.thread);
}
To this:
auto SMP::step(uint clocks) -> void {
Thread::step(clocks);
synchronize(dsp);
synchronize(cpu);
}
As you can see, we don't have to do multiple clock adjustments anymore.
This is a huge win for the SNES CPU that had to update the SMP, DSP, all
peripherals and all coprocessors. Likewise, we don't have to synchronize
all coprocessors when one runs, now we can just synchronize the active
one to the CPU.
Third, when changing the frequencies of threads (think SGB speed setting
modes, GBC double-speed mode, etc), it no longer causes the "int64
clock" value to be erroneous.
Fourth, this results in a fairly decent speedup, mostly across the
board. Aside from the GBA being mostly a wash (for unknown reasons),
it's about an 8% - 12% speedup in every other emulation core.
Now, all of this said ... this was an unbelievably massive change, so
... you know what that means >_> If anyone can help test all types of
SNES coprocessors, and some other system games, it'd be appreciated.
----
Lastly, we have a bitchin' new about screen. It unfortunately adds
~200KiB onto the binary size, because the PNG->C++ header file
transformation doesn't compress very well, and I want to keep the
original resource files in with the higan archive. I might try some
things to work around this file size increase in the future, but for now
... yeah, slightly larger archive sizes, sorry.
The logo's a bit busted on Windows (the Label control's background
transparency and alignment settings aren't working), but works well on
GTK. I'll have to fix Windows before the next official release. For now,
look on my Twitter feed if you want to see what it's supposed to look
like.
----
EDIT: forgot about ICD2::Enter. It's doing some weird inverse
run-to-save thing that I need to implement support for somehow. So, save
states on the SGB core probably won't work with this WIP.
2016-07-30 03:56:12 +00:00
|
|
|
inline auto flip() { return data ^= 1; }
|
2016-07-17 03:24:28 +00:00
|
|
|
inline auto raise() { return data == 0 ? data = 1, true : false; }
|
|
|
|
inline auto lower() { return data == 1 ? data = 0, true : false; }
|
|
|
|
|
2015-12-06 21:11:41 +00:00
|
|
|
inline auto serialize(serializer& s) { s(data); }
|
|
|
|
|
2016-02-16 09:32:49 +00:00
|
|
|
private:
|
2015-12-06 21:11:41 +00:00
|
|
|
bool data;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<uint Bits> struct Natural {
|
|
|
|
using type =
|
2016-10-27 21:16:58 +00:00
|
|
|
typename conditional<Bits <= 8, uint8_t,
|
|
|
|
typename conditional<Bits <= 16, uint16_t,
|
|
|
|
typename conditional<Bits <= 32, uint32_t,
|
|
|
|
typename conditional<Bits <= 64, uint64_t,
|
|
|
|
void>::type>::type>::type>::type;
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
enum : type { Mask = ~0ull >> (64 - Bits) };
|
|
|
|
|
|
|
|
inline Natural() : data(0) {}
|
2016-06-07 11:55:03 +00:00
|
|
|
template<typename T> inline Natural(const T& value) { set(value); }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
inline operator type() const { return data; }
|
2016-06-07 11:55:03 +00:00
|
|
|
template<typename T> inline auto& operator=(const T& value) { set(value); return *this; }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
2016-06-07 11:55:03 +00:00
|
|
|
inline auto operator++(int) { type value = data; set(data + 1); return value; }
|
|
|
|
inline auto operator--(int) { type value = data; set(data - 1); return value; }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
2016-06-07 11:55:03 +00:00
|
|
|
inline auto& operator++() { set(data + 1); return *this; }
|
|
|
|
inline auto& operator--() { set(data - 1); return *this; }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
2016-06-07 11:55:03 +00:00
|
|
|
inline auto& operator &=(const type value) { set(data & value); return *this; }
|
|
|
|
inline auto& operator |=(const type value) { set(data | value); return *this; }
|
|
|
|
inline auto& operator ^=(const type value) { set(data ^ value); return *this; }
|
|
|
|
inline auto& operator<<=(const type value) { set(data << value); return *this; }
|
|
|
|
inline auto& operator>>=(const type value) { set(data >> value); return *this; }
|
|
|
|
inline auto& operator +=(const type value) { set(data + value); return *this; }
|
|
|
|
inline auto& operator -=(const type value) { set(data - value); return *this; }
|
|
|
|
inline auto& operator *=(const type value) { set(data * value); return *this; }
|
|
|
|
inline auto& operator /=(const type value) { set(data / value); return *this; }
|
|
|
|
inline auto& operator %=(const type value) { set(data % value); return *this; }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
inline auto serialize(serializer& s) { s(data); }
|
|
|
|
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
struct Reference {
|
2016-02-16 09:32:49 +00:00
|
|
|
inline Reference(Natural& source, uint lo, uint hi) : source(source), Lo(lo), Hi(hi) {}
|
2016-08-12 23:47:30 +00:00
|
|
|
inline auto& operator=(Reference& source) { return set(source.get()); }
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
inline auto get() const -> type {
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
const type RangeBits = Hi - Lo + 1;
|
|
|
|
const type RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask;
|
|
|
|
return (source & RangeMask) >> Lo;
|
|
|
|
}
|
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
inline auto& set(const type value) {
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
const type RangeBits = Hi - Lo + 1;
|
|
|
|
const type RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask;
|
|
|
|
source = (source & ~RangeMask) | ((value << Lo) & RangeMask);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
inline operator type() const { return get(); }
|
|
|
|
inline auto& operator =(const type value) { return set( value); }
|
|
|
|
inline auto& operator &=(const type value) { return set(get() & value); }
|
|
|
|
inline auto& operator |=(const type value) { return set(get() | value); }
|
|
|
|
inline auto& operator ^=(const type value) { return set(get() ^ value); }
|
|
|
|
inline auto& operator<<=(const type value) { return set(get() << value); }
|
|
|
|
inline auto& operator>>=(const type value) { return set(get() >> value); }
|
|
|
|
inline auto& operator +=(const type value) { return set(get() + value); }
|
|
|
|
inline auto& operator -=(const type value) { return set(get() - value); }
|
|
|
|
inline auto& operator *=(const type value) { return set(get() * value); }
|
|
|
|
inline auto& operator /=(const type value) { return set(get() / value); }
|
|
|
|
inline auto& operator %=(const type value) { return set(get() % value); }
|
2016-08-17 12:31:22 +00:00
|
|
|
inline auto operator++(int) { auto value = get(); set(value + 1); return value; }
|
|
|
|
inline auto operator--(int) { auto value = get(); set(value - 1); return value; }
|
2016-08-09 11:07:18 +00:00
|
|
|
inline auto& operator++() { return set(get() + 1); }
|
|
|
|
inline auto& operator--() { return set(get() - 1); }
|
|
|
|
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
private:
|
|
|
|
Natural& source;
|
2016-02-16 09:32:49 +00:00
|
|
|
const type Lo;
|
|
|
|
const type Hi;
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
};
|
|
|
|
|
2016-02-16 09:32:49 +00:00
|
|
|
inline auto bits(uint lo, uint hi) -> Reference { return {*this, lo < hi ? lo : hi, hi > lo ? hi : lo}; }
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
inline auto bit(uint index) -> Reference { return {*this, index, index}; }
|
|
|
|
inline auto byte(uint index) -> Reference { return {*this, index * 8 + 0, index * 8 + 7}; }
|
|
|
|
|
2016-07-12 22:47:04 +00:00
|
|
|
inline auto bits(uint lo, uint hi) const -> const Reference { return {(Natural&)*this, lo < hi ? lo : hi, hi > lo ? hi : lo}; }
|
|
|
|
inline auto bit(uint index) const -> const Reference { return {(Natural&)*this, index, index}; }
|
|
|
|
inline auto byte(uint index) const -> const Reference { return {(Natural&)*this, index * 8 + 0, index * 8 + 7}; }
|
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
inline auto clamp(uint bits) -> uintmax {
|
|
|
|
const uintmax b = 1ull << (bits - 1);
|
|
|
|
const uintmax m = b * 2 - 1;
|
2016-02-16 09:32:49 +00:00
|
|
|
return data < m ? data : m;
|
|
|
|
}
|
2015-12-06 21:11:41 +00:00
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
inline auto clip(uint bits) -> uintmax {
|
|
|
|
const uintmax b = 1ull << (bits - 1);
|
|
|
|
const uintmax m = b * 2 - 1;
|
2016-02-16 09:32:49 +00:00
|
|
|
return data & m;
|
|
|
|
}
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
private:
|
2016-06-07 11:55:03 +00:00
|
|
|
auto set(type value) -> void {
|
2016-02-16 09:32:49 +00:00
|
|
|
data = value & Mask;
|
2015-12-06 21:11:41 +00:00
|
|
|
}
|
2016-02-16 09:32:49 +00:00
|
|
|
|
|
|
|
type data;
|
2015-12-06 21:11:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template<uint Bits> struct Integer {
|
|
|
|
using type =
|
2016-10-27 21:16:58 +00:00
|
|
|
typename conditional<Bits <= 8, int8_t,
|
|
|
|
typename conditional<Bits <= 16, int16_t,
|
|
|
|
typename conditional<Bits <= 32, int32_t,
|
|
|
|
typename conditional<Bits <= 64, int64_t,
|
|
|
|
void>::type>::type>::type>::type;
|
2015-12-06 21:11:41 +00:00
|
|
|
using utype = typename Natural<Bits>::type;
|
|
|
|
|
|
|
|
enum : utype { Mask = ~0ull >> (64 - Bits), Sign = 1ull << (Bits - 1) };
|
|
|
|
|
|
|
|
inline Integer() : data(0) {}
|
2016-06-07 11:55:03 +00:00
|
|
|
template<typename T> inline Integer(const T& value) { set(value); }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
inline operator type() const { return data; }
|
2016-06-07 11:55:03 +00:00
|
|
|
template<typename T> inline auto& operator=(const T& value) { set(value); return *this; }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
2016-06-07 11:55:03 +00:00
|
|
|
inline auto operator++(int) { type value = data; set(data + 1); return value; }
|
|
|
|
inline auto operator--(int) { type value = data; set(data - 1); return value; }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
2016-06-07 11:55:03 +00:00
|
|
|
inline auto& operator++() { set(data + 1); return *this; }
|
|
|
|
inline auto& operator--() { set(data - 1); return *this; }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
2016-06-07 11:55:03 +00:00
|
|
|
inline auto& operator &=(const type value) { set(data & value); return *this; }
|
|
|
|
inline auto& operator |=(const type value) { set(data | value); return *this; }
|
|
|
|
inline auto& operator ^=(const type value) { set(data ^ value); return *this; }
|
|
|
|
inline auto& operator<<=(const type value) { set(data << value); return *this; }
|
|
|
|
inline auto& operator>>=(const type value) { set(data >> value); return *this; }
|
|
|
|
inline auto& operator +=(const type value) { set(data + value); return *this; }
|
|
|
|
inline auto& operator -=(const type value) { set(data - value); return *this; }
|
|
|
|
inline auto& operator *=(const type value) { set(data * value); return *this; }
|
|
|
|
inline auto& operator /=(const type value) { set(data / value); return *this; }
|
|
|
|
inline auto& operator %=(const type value) { set(data % value); return *this; }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
inline auto serialize(serializer& s) { s(data); }
|
|
|
|
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
struct Reference {
|
2016-02-16 09:32:49 +00:00
|
|
|
inline Reference(Integer& source, uint lo, uint hi) : source(source), Lo(lo), Hi(hi) {}
|
2016-08-12 23:47:30 +00:00
|
|
|
inline auto& operator=(const Reference& source) { return set(source.get()); }
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
inline auto get() const -> utype {
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
const type RangeBits = Hi - Lo + 1;
|
|
|
|
const type RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask;
|
|
|
|
return ((utype)source & RangeMask) >> Lo;
|
|
|
|
}
|
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
inline auto& set(const utype value) {
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
const type RangeBits = Hi - Lo + 1;
|
|
|
|
const type RangeMask = (((1ull << RangeBits) - 1) << Lo) & Mask;
|
|
|
|
source = ((utype)source & ~RangeMask) | ((value << Lo) & RangeMask);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
inline operator utype() const { return get(); }
|
|
|
|
inline auto& operator =(const utype value) { return set( value); }
|
|
|
|
inline auto& operator &=(const utype value) { return set(get() & value); }
|
|
|
|
inline auto& operator |=(const utype value) { return set(get() | value); }
|
|
|
|
inline auto& operator ^=(const utype value) { return set(get() ^ value); }
|
|
|
|
inline auto& operator<<=(const utype value) { return set(get() << value); }
|
|
|
|
inline auto& operator>>=(const utype value) { return set(get() >> value); }
|
|
|
|
inline auto& operator +=(const utype value) { return set(get() + value); }
|
|
|
|
inline auto& operator -=(const utype value) { return set(get() - value); }
|
|
|
|
inline auto& operator *=(const utype value) { return set(get() * value); }
|
|
|
|
inline auto& operator /=(const utype value) { return set(get() / value); }
|
|
|
|
inline auto& operator %=(const utype value) { return set(get() % value); }
|
2016-08-17 12:31:22 +00:00
|
|
|
inline auto operator++(int) { auto value = get(); set(value + 1); return value; }
|
|
|
|
inline auto operator--(int) { auto value = get(); set(value - 1); return value; }
|
2016-08-09 11:07:18 +00:00
|
|
|
inline auto& operator++() { return set(get() + 1); }
|
|
|
|
inline auto& operator--() { return set(get() - 1); }
|
|
|
|
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
private:
|
|
|
|
Integer& source;
|
2016-02-16 09:32:49 +00:00
|
|
|
const uint Lo;
|
|
|
|
const uint Hi;
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
};
|
|
|
|
|
2016-07-12 22:47:04 +00:00
|
|
|
inline auto bits(uint lo, uint hi) -> Reference { return {*this, lo < hi ? lo : hi, hi > lo ? hi : lo}; }
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
inline auto bit(uint index) -> Reference { return {*this, index, index}; }
|
|
|
|
inline auto byte(uint index) -> Reference { return {*this, index * 8 + 0, index * 8 + 7}; }
|
|
|
|
|
2016-07-12 22:47:04 +00:00
|
|
|
inline auto bits(uint lo, uint hi) const -> const Reference { return {(Integer&)*this, lo < hi ? lo : hi, hi > lo ? hi : lo}; }
|
|
|
|
inline auto bit(uint index) const -> const Reference { return {(Integer&)*this, index, index}; }
|
|
|
|
inline auto byte(uint index) const -> const Reference { return {(Integer&)*this, index * 8 + 0, index * 8 + 7}; }
|
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
inline auto clamp(uint bits) -> intmax {
|
|
|
|
const intmax b = 1ull << (bits - 1);
|
|
|
|
const intmax m = b - 1;
|
2016-02-16 09:32:49 +00:00
|
|
|
return data > m ? m : data < -b ? -b : data;
|
|
|
|
}
|
2015-12-06 21:11:41 +00:00
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
inline auto clip(uint bits) -> intmax {
|
|
|
|
const uintmax b = 1ull << (bits - 1);
|
|
|
|
const uintmax m = b * 2 - 1;
|
2016-02-16 09:32:49 +00:00
|
|
|
return ((data & m) ^ b) - b;
|
|
|
|
}
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
private:
|
2016-06-07 11:55:03 +00:00
|
|
|
auto set(type value) -> void {
|
2016-02-16 09:32:49 +00:00
|
|
|
data = ((value & Mask) ^ Sign) - Sign;
|
2015-12-06 21:11:41 +00:00
|
|
|
}
|
2016-02-16 09:32:49 +00:00
|
|
|
|
|
|
|
type data;
|
2015-12-06 21:11:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template<uint Bits> struct Real {
|
|
|
|
using type =
|
2016-10-27 21:16:58 +00:00
|
|
|
typename conditional<Bits == 32, float32_t,
|
|
|
|
typename conditional<Bits == 64, float64_t,
|
|
|
|
void>::type>::type;
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
inline Real() : data(0.0) {}
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
template<typename T> inline Real(const T& value) : data((type)value) {}
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
inline operator type() const { return data; }
|
Update to v097r14 release.
byuu says:
This is a few days old, but oh well.
This WIP changes nall,hiro,ruby,icarus back to (u)int(8,16,32,64)_t.
I'm slowly pushing for (u)int(8,16,32,64) to use my custom
Integer<Size>/Natural<Size> classes instead. But it's going to be one
hell of a struggle to get that into higan.
2016-02-16 09:11:58 +00:00
|
|
|
template<typename T> inline auto& operator=(const T& value) { data = (type)value; return *this; }
|
2015-12-06 21:11:41 +00:00
|
|
|
|
|
|
|
inline auto operator++(int) { type value = data; ++data; return value; }
|
|
|
|
inline auto operator--(int) { type value = data; --data; return value; }
|
|
|
|
|
|
|
|
inline auto& operator++() { data++; return *this; }
|
|
|
|
inline auto& operator--() { data--; return *this; }
|
|
|
|
|
|
|
|
inline auto& operator+=(const type value) { data = data + value; return *this; }
|
|
|
|
inline auto& operator-=(const type value) { data = data - value; return *this; }
|
|
|
|
inline auto& operator*=(const type value) { data = data * value; return *this; }
|
|
|
|
inline auto& operator/=(const type value) { data = data / value; return *this; }
|
|
|
|
inline auto& operator%=(const type value) { data = data % value; return *this; }
|
|
|
|
|
|
|
|
inline auto serialize(serializer& s) { s(data); }
|
|
|
|
|
2016-06-07 11:55:03 +00:00
|
|
|
private:
|
2015-12-06 21:11:41 +00:00
|
|
|
type data;
|
|
|
|
};
|
|
|
|
|
Update to v097r17 release.
byuu says:
Changelog:
- ruby: if DirectSoundCreate fails (no sound device present), return
false from init instead of crashing
- nall: improved edge case return values for
(basename,pathname,dirname,...)
- nall: renamed file_system_object class to inode
- nall: varuint_t replaced with VariadicNatural; which contains
.bit,.bits,.byte ala Natural/Integer
- nall: fixed boolean compilation error on Windows
- WS: popa should not restore SP
- GBA: rewrote the CPU/APU cores to use the .bit,.bits functions;
removed registers.cpp from each
Note that the GBA changes are extremely major. This is about five hours
worth of extremely delicate work. Any slight errors could break
emulation in extremely bad ways. Let's hold off on extensive testing
until the next WIP, after I do the same to the PPU.
So far ... endrift's SOUNDCNT_X I/O test is failing, although that code
didn't change, so clearly I messed up SOUNDCNT_H somehow ...
To compile on Windows:
1. change nall/string/platform.hpp line 47 to
return slice(result, 0, 3);
2. change ruby/video.wgl.cpp line 72 to
auto lock(uint32_t*& data, uint& pitch, uint width, uint height) -> bool {
3. add this line to the very top of hiro/windows/header.cpp:
#define boolean FuckYouMicrosoft
2016-02-23 11:08:44 +00:00
|
|
|
using boolean = nall::Boolean;
|
Update to v099r14 release.
byuu says:
Changelog:
- (u)int(max,ptr) abbreviations removed; use _t suffix now [didn't feel
like they were contributing enough to be worth it]
- cleaned up nall::integer,natural,real functionality
- toInteger, toNatural, toReal for parsing strings to numbers
- fromInteger, fromNatural, fromReal for creating strings from numbers
- (string,Markup::Node,SQL-based-classes)::(integer,natural,real)
left unchanged
- template<typename T> numeral(T value, long padding, char padchar)
-> string for print() formatting
- deduces integer,natural,real based on T ... cast the value if you
want to override
- there still exists binary,octal,hex,pointer for explicit print()
formatting
- lstring -> string_vector [but using lstring = string_vector; is
declared]
- would be nice to remove the using lstring eventually ... but that'd
probably require 10,000 lines of changes >_>
- format -> string_format [no using here; format was too ambiguous]
- using integer = Integer<sizeof(int)*8>; and using natural =
Natural<sizeof(uint)*8>; declared
- for consistency with boolean. These three are meant for creating
zero-initialized values implicitly (various uses)
- R65816::io() -> idle() and SPC700::io() -> idle() [more clear; frees
up struct IO {} io; naming]
- SFC CPU, PPU, SMP use struct IO {} io; over struct (Status,Registers) {}
(status,registers); now
- still some CPU::Status status values ... they didn't really fit into
IO functionality ... will have to think about this more
- SFC CPU, PPU, SMP now use step() exclusively instead of addClocks()
calling into step()
- SFC CPU joypad1_bits, joypad2_bits were unused; killed them
- SFC PPU CGRAM moved into PPU::Screen; since nothing else uses it
- SFC PPU OAM moved into PPU::Object; since nothing else uses it
- the raw uint8[544] array is gone. OAM::read() constructs values from
the OAM::Object[512] table now
- this avoids having to determine how we want to sub-divide the two
OAM memory sections
- this also eliminates the OAM::synchronize() functionality
- probably more I'm forgetting
The FPS fluctuations are driving me insane. This WIP went from 128fps to
137fps. Settled on 133.5fps for the final build. But nothing I changed
should have affected performance at all. This level of fluctuation makes
it damn near impossible to know whether I'm speeding things up or slowing
things down with changes.
2016-07-01 11:50:32 +00:00
|
|
|
using natural = nall::Natural<sizeof(uint) * 8>;
|
Update to v101r04 release.
byuu says:
Changelog:
- pulled the (u)intN type aliases into higan instead of leaving them
in nall
- added 68K LINEA, LINEF hooks for illegal instructions
- filled the rest of the 68K lambda table with generic instance of
ILLEGAL
- completed the 68K disassembler effective addressing modes
- still unsure whether I should use An to decode absolute
addresses or not
- pro: way easier to read where accesses are taking place
- con: requires An to be valid; so as a disassembler it does a
poor job
- making it optional: too much work; ick
- added I/O decoding for the VDP command-port registers
- added skeleton timing to all five processor cores
- output at 1280x480 (needed for mixed 256/320 widths; and to handle
interlace modes)
The VDP, PSG, Z80, YM2612 are all stepping one clock at a time and
syncing; which is the pathological worst case for libco. But they also
have no logic inside of them. With all the above, I'm averaging around
250fps with just the 68K core actually functional, and the VDP doing a
dumb "draw white pixels" loop. Still way too early to tell how this
emulator is going to perform.
Also, the 320x240 mode of the Genesis means that we don't need an aspect
correction ratio. But we do need to ensure the output window is a
multiple 320x240 so that the scale values work correctly. I was
hard-coding aspect correction to stretch the window an additional \*8/7.
But that won't work anymore so ... the main higan window is now 640x480,
960x720, or 1280x960. Toggling aspect correction only changes the video
width inside the window.
It's a bit jarring ... the window is a lot wider, more black space now
for most modes. But for now, it is what it is.
2016-08-12 01:07:04 +00:00
|
|
|
using integer = nall::Integer<sizeof(int) * 8>;
|
2016-07-01 11:58:12 +00:00
|
|
|
using real = nall::Real<sizeof(double) * 8>;
|
Update to v097r17 release.
byuu says:
Changelog:
- ruby: if DirectSoundCreate fails (no sound device present), return
false from init instead of crashing
- nall: improved edge case return values for
(basename,pathname,dirname,...)
- nall: renamed file_system_object class to inode
- nall: varuint_t replaced with VariadicNatural; which contains
.bit,.bits,.byte ala Natural/Integer
- nall: fixed boolean compilation error on Windows
- WS: popa should not restore SP
- GBA: rewrote the CPU/APU cores to use the .bit,.bits functions;
removed registers.cpp from each
Note that the GBA changes are extremely major. This is about five hours
worth of extremely delicate work. Any slight errors could break
emulation in extremely bad ways. Let's hold off on extensive testing
until the next WIP, after I do the same to the PPU.
So far ... endrift's SOUNDCNT_X I/O test is failing, although that code
didn't change, so clearly I messed up SOUNDCNT_H somehow ...
To compile on Windows:
1. change nall/string/platform.hpp line 47 to
return slice(result, 0, 3);
2. change ruby/video.wgl.cpp line 72 to
auto lock(uint32_t*& data, uint& pitch, uint width, uint height) -> bool {
3. add this line to the very top of hiro/windows/header.cpp:
#define boolean FuckYouMicrosoft
2016-02-23 11:08:44 +00:00
|
|
|
|
2016-08-09 11:07:18 +00:00
|
|
|
}
|