Update to v106r85 release.

byuu says:

The bad instruction was due to the instruction before it fetching one
too many bytes. Didn't notice right away as the disassembler got it
right.

The register map was incorrect on the active 16-bit flags.

I fixed and improved some other things along those lines. Hooked up some
basic KnGE (VPU) timings, made it print out VRAM and some of the WRAM
onto the screen each frame, tried to drive Vblank and Hblank IRQs, but
... I don't know for sure what vector addresses they belong to.

MAME says "INT4" for Vblank, and says nothing for Hblank. I am wildly
guessing INT4==SWI 4==0xffff10, but ... I have no idea. I'm also not
emulating the interrupts properly based on line levels, I'm just firing
on the 0→1 transitions. Sounds like Vblank is more nuanced too, but I
guess we'll see.

Emulation is running further along now, even to the point of it
successfully enabling the KnGE IRQs, but VRAM doesn't appear to get much
useful stuff written into it yet.

I reverted the nall/primitive changes, so request for testing is I guess
rescinded, for whatever it was worth.
This commit is contained in:
Tim Allen
2019-01-22 11:26:20 +11:00
parent 53843934c0
commit fbc1571889
32 changed files with 150 additions and 167 deletions

View File

@@ -2,15 +2,18 @@
namespace nall {
//warning: so that BitRange can modify the underlying number directly, it must bind a reference.
//as a result, auto value = number.bits() will capture by-reference, rather than by-value.
template<int Precision> struct BitRange {
static_assert(Precision >= 1 && Precision <= 64);
static inline constexpr auto bits() -> uint { return Precision; }
using utype =
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;
conditional_t<bits() <= 8, uint8_t,
conditional_t<bits() <= 16, uint16_t,
conditional_t<bits() <= 32, uint32_t,
conditional_t<bits() <= 64, uint64_t,
void>>>>;
static inline constexpr auto mask() -> utype { return ~0ull >> 64 - bits(); }
inline BitRange(utype& source, int lo, int hi) : source(source) {
@@ -22,13 +25,14 @@ template<int Precision> struct BitRange {
}
inline auto& operator=(BitRange& source) { return set(source.get()); }
inline operator utype() const { return get(); }
inline auto operator++(int) { auto value = get(); set(value + 1); return value; }
inline auto operator--(int) { auto value = get(); set(value - 1); return value; }
inline auto& operator++() { return set(get() + 1); }
inline auto& operator--() { return set(get() - 1); }
inline operator utype() const { return get(); }
template<typename T> inline auto& operator =(const T& value) { return set( value); }
template<typename T> inline auto& operator *=(const T& value) { return set(get() * value); }
template<typename T> inline auto& operator /=(const T& value) { return set(get() / value); }

View File

@@ -4,7 +4,7 @@ namespace nall {
struct Boolean {
static inline constexpr auto bits() -> uint { return 1; }
using type = bool;
using btype = bool;
inline Boolean() : data(false) {}
template<typename T> inline Boolean(const T& value) : data(value) {}
@@ -23,7 +23,7 @@ struct Boolean {
inline auto serialize(serializer& s) { s(data); }
private:
type data;
btype data;
};
}

View File

@@ -2,7 +2,7 @@
namespace nall {
template<uint Precision = 64> struct Integer {
template<uint Precision> struct Integer {
static_assert(Precision >= 1 && Precision <= 64);
static inline constexpr auto bits() -> uint { return Precision; }
using stype =
@@ -16,11 +16,10 @@ template<uint Precision = 64> struct Integer {
static inline constexpr auto sign() -> utype { return 1ull << Precision - 1; }
inline Integer() : data(0) {}
template<int Bits> inline Integer(Integer<Bits> value) { data = mask(value); }
template<uint Bits> inline Integer(Integer<Bits> value) { data = mask(value); }
template<typename T> inline Integer(const T& value) { data = mask(value); }
explicit inline operator bool() const { return data; }
inline operator int64_t() const { return data; }
inline operator stype() const { return data; }
inline auto operator++(int) { auto value = *this; data = mask(data + 1); return value; }
inline auto operator--(int) { auto value = *this; data = mask(data - 1); return value; }
@@ -28,29 +27,17 @@ template<uint Precision = 64> struct Integer {
inline auto& operator++() { data = mask(data + 1); return *this; }
inline auto& operator--() { data = mask(data - 1); return *this; }
inline auto operator!() const { return !data; }
inline auto operator~() const { return Integer<>{mask(~data)}; }
inline auto operator+() const { return Integer<>{+data}; }
inline auto operator-() const { return Integer<>{data == sign() ? data : -data}; }
#define lhs data
#define rhs value
template<typename T> inline auto& operator =(const T& value) { lhs = mask( rhs); return *this; }
template<typename T> inline auto& operator *=(const T& value) { lhs = mask(lhs * rhs); return *this; }
template<typename T> inline auto& operator /=(const T& value) { lhs = mask(lhs / rhs); return *this; }
template<typename T> inline auto& operator %=(const T& value) { lhs = mask(lhs % rhs); return *this; }
template<typename T> inline auto& operator +=(const T& value) { lhs = mask(lhs + rhs); return *this; }
template<typename T> inline auto& operator -=(const T& value) { lhs = mask(lhs - rhs); return *this; }
template<typename T> inline auto& operator<<=(const T& value) { lhs = mask(lhs << rhs); return *this; }
template<typename T> inline auto& operator>>=(const T& value) { lhs = mask(lhs >> rhs); return *this; }
template<typename T> inline auto& operator &=(const T& value) { lhs = mask(lhs & rhs); return *this; }
template<typename T> inline auto& operator ^=(const T& value) { lhs = mask(lhs ^ rhs); return *this; }
template<typename T> inline auto& operator |=(const T& value) { lhs = mask(lhs | rhs); return *this; }
#undef lhs
#undef rhs
//warning: this does not and cannot short-circuit; value is always evaluated
template<typename T> inline auto orElse(const T& value) { return Integer<>{data ? data : value}; }
template<typename T> inline auto& operator =(const T& value) { data = mask( value); return *this; }
template<typename T> inline auto& operator *=(const T& value) { data = mask(data * value); return *this; }
template<typename T> inline auto& operator /=(const T& value) { data = mask(data / value); return *this; }
template<typename T> inline auto& operator %=(const T& value) { data = mask(data % value); return *this; }
template<typename T> inline auto& operator +=(const T& value) { data = mask(data + value); return *this; }
template<typename T> inline auto& operator -=(const T& value) { data = mask(data - value); return *this; }
template<typename T> inline auto& operator<<=(const T& value) { data = mask(data << value); return *this; }
template<typename T> inline auto& operator>>=(const T& value) { data = mask(data >> value); return *this; }
template<typename T> inline auto& operator &=(const T& value) { data = mask(data & value); return *this; }
template<typename T> inline auto& operator ^=(const T& value) { data = mask(data ^ value); return *this; }
template<typename T> inline auto& operator |=(const T& value) { data = mask(data | value); return *this; }
inline auto bits(int lo, int hi) -> BitRange<Precision> { return {(utype&)data, lo, hi}; }
inline auto bit(int index) -> BitRange<Precision> { return {(utype&)data, index, index}; }
@@ -63,16 +50,16 @@ template<uint Precision = 64> struct Integer {
inline auto slice(int index) const { return Natural<>{bit(index)}; }
inline auto slice(int lo, int hi) const { return Natural<>{bit(lo, hi)}; }
inline auto clamp(uint bits) {
inline auto clamp(uint bits) -> stype {
const int64_t b = 1ull << (bits - 1);
const int64_t m = b - 1;
return Integer<>{data > m ? m : data < -b ? -b : data};
return data > m ? m : data < -b ? -b : data;
}
inline auto clip(uint bits) {
inline auto clip(uint bits) -> stype {
const uint64_t b = 1ull << (bits - 1);
const uint64_t m = b * 2 - 1;
return Integer<>{(data & m ^ b) - b};
return (data & m ^ b) - b;
}
inline auto serialize(serializer& s) { s(data); }
@@ -86,19 +73,4 @@ private:
stype data;
};
#define lhs (int64_t)l
#define rhs r
template<int LHS, int RHS> inline auto operator *(Integer<LHS> l, Integer<RHS> r) { return Integer{lhs * rhs}; }
template<int LHS, int RHS> inline auto operator /(Integer<LHS> l, Integer<RHS> r) { return Integer{lhs / rhs}; }
template<int LHS, int RHS> inline auto operator %(Integer<LHS> l, Integer<RHS> r) { return Integer{lhs % rhs}; }
template<int LHS, int RHS> inline auto operator +(Integer<LHS> l, Integer<RHS> r) { return Integer{lhs + rhs}; }
template<int LHS, int RHS> inline auto operator -(Integer<LHS> l, Integer<RHS> r) { return Integer{lhs - rhs}; }
template<int LHS, int RHS> inline auto operator<<(Integer<LHS> l, Integer<RHS> r) { return Integer{lhs << rhs}; }
template<int LHS, int RHS> inline auto operator>>(Integer<LHS> l, Integer<RHS> r) { return Integer{lhs >> rhs}; }
template<int LHS, int RHS> inline auto operator &(Integer<LHS> l, Integer<RHS> r) { return Integer{lhs & rhs}; }
template<int LHS, int RHS> inline auto operator ^(Integer<LHS> l, Integer<RHS> r) { return Integer{lhs ^ rhs}; }
template<int LHS, int RHS> inline auto operator |(Integer<LHS> l, Integer<RHS> r) { return Integer{lhs | rhs}; }
#undef lhs
#undef rhs
}

View File

@@ -2,7 +2,7 @@
namespace nall {
template<uint Precision = 64> struct Natural {
template<uint Precision> struct Natural {
static_assert(Precision >= 1 && Precision <= 64);
static inline constexpr auto bits() -> uint { return Precision; }
using utype =
@@ -14,11 +14,10 @@ template<uint Precision = 64> struct Natural {
static inline constexpr auto mask() -> utype { return ~0ull >> 64 - bits(); }
inline Natural() : data(0) {}
template<int Bits> inline Natural(Natural<Bits> value) { data = mask(value); }
template<uint Bits> inline Natural(Natural<Bits> value) { data = mask(value); }
template<typename T> inline Natural(const T& value) { data = mask(value); }
explicit inline operator bool() const { return data; }
inline operator uint64_t() const { return data; }
inline operator utype() const { return data; }
inline auto operator++(int) { auto value = *this; data = mask(data + 1); return value; }
inline auto operator--(int) { auto value = *this; data = mask(data - 1); return value; }
@@ -26,29 +25,17 @@ template<uint Precision = 64> struct Natural {
inline auto& operator++() { data = mask(data + 1); return *this; }
inline auto& operator--() { data = mask(data - 1); return *this; }
inline auto operator!() const { return !data; }
inline auto operator~() const { return Natural<>{mask(~data)}; }
inline auto operator+() const { return Natural<>{+data}; }
inline auto operator-() const { return Natural<>{-(uint64_t)data}; }
#define lhs data
#define rhs value
template<typename T> inline auto& operator =(const T& value) { lhs = mask( rhs); return *this; }
template<typename T> inline auto& operator *=(const T& value) { lhs = mask(lhs * rhs); return *this; }
template<typename T> inline auto& operator /=(const T& value) { lhs = mask(lhs / rhs); return *this; }
template<typename T> inline auto& operator %=(const T& value) { lhs = mask(lhs % rhs); return *this; }
template<typename T> inline auto& operator +=(const T& value) { lhs = mask(lhs + rhs); return *this; }
template<typename T> inline auto& operator -=(const T& value) { lhs = mask(lhs - rhs); return *this; }
template<typename T> inline auto& operator<<=(const T& value) { lhs = mask(lhs << rhs); return *this; }
template<typename T> inline auto& operator>>=(const T& value) { lhs = mask(lhs >> rhs); return *this; }
template<typename T> inline auto& operator &=(const T& value) { lhs = mask(lhs & rhs); return *this; }
template<typename T> inline auto& operator ^=(const T& value) { lhs = mask(lhs ^ rhs); return *this; }
template<typename T> inline auto& operator |=(const T& value) { lhs = mask(lhs | rhs); return *this; }
#undef lhs
#undef rhs
//warning: this does not and cannot short-circuit; value is always evaluated
template<typename T> inline auto orElse(const T& value) { return Natural<>{data ? data : value}; }
template<typename T> inline auto& operator =(const T& value) { data = mask( value); return *this; }
template<typename T> inline auto& operator *=(const T& value) { data = mask(data * value); return *this; }
template<typename T> inline auto& operator /=(const T& value) { data = mask(data / value); return *this; }
template<typename T> inline auto& operator %=(const T& value) { data = mask(data % value); return *this; }
template<typename T> inline auto& operator +=(const T& value) { data = mask(data + value); return *this; }
template<typename T> inline auto& operator -=(const T& value) { data = mask(data - value); return *this; }
template<typename T> inline auto& operator<<=(const T& value) { data = mask(data << value); return *this; }
template<typename T> inline auto& operator>>=(const T& value) { data = mask(data >> value); return *this; }
template<typename T> inline auto& operator &=(const T& value) { data = mask(data & value); return *this; }
template<typename T> inline auto& operator ^=(const T& value) { data = mask(data ^ value); return *this; }
template<typename T> inline auto& operator |=(const T& value) { data = mask(data | value); return *this; }
inline auto bits(int lo, int hi) -> BitRange<Precision> { return {(utype&)data, lo, hi}; }
inline auto bit(int index) -> BitRange<Precision> { return {(utype&)data, index, index}; }
@@ -61,16 +48,16 @@ template<uint Precision = 64> struct Natural {
inline auto slice(int index) const { return Natural<>{bit(index)}; }
inline auto slice(int lo, int hi) const { return Natural<>{bits(lo, hi)}; }
inline auto clamp(uint bits) {
inline auto clamp(uint bits) -> utype {
const uint64_t b = 1ull << (bits - 1);
const uint64_t m = b * 2 - 1;
return Natural<>{data < m ? data : m};
return data < m ? data : m;
}
inline auto clip(uint bits) {
inline auto clip(uint bits) -> utype {
const uint64_t b = 1ull << (bits - 1);
const uint64_t m = b * 2 - 1;
return Natural<>{data & m};
return data & m;
}
inline auto serialize(serializer& s) { s(data); }
@@ -84,19 +71,4 @@ private:
utype data;
};
#define lhs (uint64_t)l
#define rhs r
template<int LHS, int RHS> inline auto operator *(Natural<LHS> l, Natural<RHS> r) { return Natural{lhs * rhs}; }
template<int LHS, int RHS> inline auto operator /(Natural<LHS> l, Natural<RHS> r) { return Natural{lhs / rhs}; }
template<int LHS, int RHS> inline auto operator %(Natural<LHS> l, Natural<RHS> r) { return Natural{lhs % rhs}; }
template<int LHS, int RHS> inline auto operator +(Natural<LHS> l, Natural<RHS> r) { return Natural{lhs + rhs}; }
template<int LHS, int RHS> inline auto operator -(Natural<LHS> l, Natural<RHS> r) { return Natural{lhs - rhs}; }
template<int LHS, int RHS> inline auto operator<<(Natural<LHS> l, Natural<RHS> r) { return Natural{lhs << rhs}; }
template<int LHS, int RHS> inline auto operator>>(Natural<LHS> l, Natural<RHS> r) { return Natural{lhs >> rhs}; }
template<int LHS, int RHS> inline auto operator &(Natural<LHS> l, Natural<RHS> r) { return Natural{lhs & rhs}; }
template<int LHS, int RHS> inline auto operator ^(Natural<LHS> l, Natural<RHS> r) { return Natural{lhs ^ rhs}; }
template<int LHS, int RHS> inline auto operator |(Natural<LHS> l, Natural<RHS> r) { return Natural{lhs | rhs}; }
#undef lhs
#undef rhs
}

View File

@@ -2,7 +2,7 @@
namespace nall {
template<uint Precision = 64> struct Real {
template<uint Precision> struct Real {
static_assert(Precision == 32 || Precision == 64);
static inline constexpr auto bits() -> uint { return Precision; }
using ftype =
@@ -14,8 +14,7 @@ template<uint Precision = 64> struct Real {
template<int Bits> inline Real(Real<Bits> value) : data((ftype)value) {}
template<typename T> inline Real(const T& value) : data((ftype)value) {}
explicit inline operator bool() const { return data; }
inline operator float64_t() const { return data; }
inline operator ftype() const { return data; }
inline auto operator++(int) { auto value = *this; ++data; return value; }
inline auto operator--(int) { auto value = *this; --data; return value; }
@@ -36,14 +35,4 @@ private:
ftype data;
};
#define lhs (float64_t)(typename Real<LHS>::type)l
#define rhs (typename Real<RHS>::type)r
template<int LHS, int RHS> inline auto operator*(Real<LHS> l, Real<RHS> r) { return Real<>{lhs * rhs}; }
template<int LHS, int RHS> inline auto operator/(Real<LHS> l, Real<RHS> r) { return Real<>{lhs / rhs}; }
template<int LHS, int RHS> inline auto operator%(Real<LHS> l, Real<RHS> r) { return Real<>{lhs % rhs}; }
template<int LHS, int RHS> inline auto operator+(Real<LHS> l, Real<RHS> r) { return Real<>{lhs + rhs}; }
template<int LHS, int RHS> inline auto operator-(Real<LHS> l, Real<RHS> r) { return Real<>{lhs - rhs}; }
#undef lhs
#undef rhs
}