mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-16 13:04:22 +02:00
Update to v106r78 release.
byuu says: I've implemented a lot more TLCS900H instructions. There are currently 20 missing spots, all of which are unique instructions (well, MINC and MDEC could be considered pairs of 3 each), from a map of 1024 slots. After that, I have to write the disassembler. Then the memory bus. Then I get to start the fun process of debugging this monstrosity. Also new is nall/inline-if.hpp. Note that this file is technically a war crime, so be careful when opening it. This replaces ternary() from the previous WIP.
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace nall {
|
||||
|
||||
template<int RequestedPrecision> struct BitRange {
|
||||
enum : uint { Precision = RequestedPrecision < 1 ? 1 : RequestedPrecision > 64 ? 64 : RequestedPrecision };
|
||||
template<int Requested> struct BitRange {
|
||||
enum : uint { Precision = Requested < 1 ? 1 : Requested > 64 ? 64 : Requested };
|
||||
static inline constexpr auto bits() -> uint { return Precision; }
|
||||
using type =
|
||||
typename conditional<bits() <= 8, uint8_t,
|
||||
@@ -13,8 +13,13 @@ template<int RequestedPrecision> struct BitRange {
|
||||
void>::type>::type>::type>::type;
|
||||
static inline constexpr auto mask() -> type { return ~0ull >> 64 - bits(); }
|
||||
|
||||
inline BitRange(type& source, uint low, uint high)
|
||||
: source(source), lo(low < high ? low : high), hi(high > low ? high : low) {}
|
||||
inline BitRange(type& source, int lo, int hi) : source(source) {
|
||||
if(lo < 0) lo = Precision + lo;
|
||||
if(hi < 0) hi = Precision + hi;
|
||||
if(lo > hi) swap(lo, hi);
|
||||
this->lo = lo;
|
||||
this->hi = hi;
|
||||
}
|
||||
inline auto& operator=(BitRange& source) { return set(source.get()); }
|
||||
|
||||
inline auto operator++(int) { auto value = get(); set(value + 1); return value; }
|
||||
@@ -23,7 +28,7 @@ template<int RequestedPrecision> struct BitRange {
|
||||
inline auto& operator++() { return set(get() + 1); }
|
||||
inline auto& operator--() { return set(get() - 1); }
|
||||
|
||||
inline operator uint64_t() const { return get(); }
|
||||
inline operator type() 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); }
|
||||
@@ -37,7 +42,7 @@ template<int RequestedPrecision> struct BitRange {
|
||||
template<typename T> inline auto& operator |=(const T& value) { return set(get() | value); }
|
||||
|
||||
private:
|
||||
inline auto get() const -> uint64_t {
|
||||
inline auto get() const -> type {
|
||||
const type rangeBits = hi - lo + 1;
|
||||
const type rangeMask = (1ull << rangeBits) - 1 << lo & mask();
|
||||
return (source & rangeMask) >> lo;
|
||||
@@ -51,8 +56,8 @@ private:
|
||||
}
|
||||
|
||||
type& source;
|
||||
const uint lo;
|
||||
const uint hi;
|
||||
uint lo;
|
||||
uint hi;
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user