mirror of
https://github.com/libretro/higan.git
synced 2025-02-21 09:20:47 +00:00

byuu says: Changelog: - reverted nall/inline-if.hpp usage for now, since the nall/primitives.hpp math operators still cast to (u)int64_t - improved nall/primitives.hpp more; integer8 x = -128; print(-x) will now print 128 (unary operator+ and - cast to (u)int64_t) - renamed processor/lr35902 to processor/sm83; after the Sharp SM83 CPU core [gekkio discovered the name] - a few bugfixes to the TLCS900H CPU core - completed the disassembler for the TLCS900H core As a result of reverting most of the inline if stuff, I guess the testing priority has been reduced. Which is probably a good thing, considering I seem to have a smaller pool of testers these days. Indeed, the TLCS900H core has ended up at 131KiB compared to the M68000 core at 128KiB. So it's now the largest CPU core in all of higan. It's even more ridiculous because the M68000 core would ordinarily be quite a bit smaller, had I not gone overboard with the extreme templating to reduce instruction decoding overhead (you kind of have to do this for RISC CPUs, and the inverted design of the TLCS900H kind of makes it infeasible to do the same there.) This CPU core is bound to have dozens of extremely difficult CPU bugs, and there's no easy way for me to test them. I would greatly appreciate any help in looking over the core for bugs. A fresh pair of eyes to spot a mistake could save me up to several days of tedious debugging work. The core still isn't ready to actually be tested: I have to hook up cartridge loading, a memory bus, interrupts, timers, and the micro DMA controller before it's likely that anything happens at all.
85 lines
2.0 KiB
C++
85 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <nall/array-view.hpp>
|
|
#include <nall/range.hpp>
|
|
#include <nall/view.hpp>
|
|
|
|
namespace nall {
|
|
|
|
template<typename T> struct array;
|
|
|
|
//usage: int x[256] => array<int[256]> x
|
|
template<typename T, uint Size> struct array<T[Size]> {
|
|
array() = default;
|
|
|
|
array(const initializer_list<T>& source) {
|
|
uint index = 0;
|
|
for(auto& value : source) {
|
|
operator[](index++) = value;
|
|
}
|
|
}
|
|
|
|
operator array_view<T>() const {
|
|
return {data(), size()};
|
|
}
|
|
|
|
alwaysinline auto operator[](uint index) -> T& {
|
|
#ifdef DEBUG
|
|
struct out_of_bounds {};
|
|
if(index >= Size) throw out_of_bounds{};
|
|
#endif
|
|
return values[index];
|
|
}
|
|
|
|
alwaysinline auto operator[](uint index) const -> const T& {
|
|
#ifdef DEBUG
|
|
struct out_of_bounds {};
|
|
if(index >= Size) throw out_of_bounds{};
|
|
#endif
|
|
return values[index];
|
|
}
|
|
|
|
alwaysinline auto operator()(uint index, const T& fallback = {}) const -> const T& {
|
|
if(index >= Size) return fallback;
|
|
return values[index];
|
|
}
|
|
|
|
auto fill(const T& fill = {}) -> array& {
|
|
for(auto& value : values) value = fill;
|
|
return *this;
|
|
}
|
|
|
|
auto data() -> T* { return values; }
|
|
auto data() const -> const T* { return values; }
|
|
auto size() const -> uint { return Size; }
|
|
|
|
auto begin() -> T* { return &values[0]; }
|
|
auto end() -> T* { return &values[Size]; }
|
|
|
|
auto begin() const -> const T* { return &values[0]; }
|
|
auto end() const -> const T* { return &values[Size]; }
|
|
|
|
private:
|
|
T values[Size];
|
|
};
|
|
|
|
template<typename T, T... p> auto from_array(uint index) -> T {
|
|
static const array<T[sizeof...(p)]> table{p...};
|
|
struct out_of_bounds {};
|
|
#if defined(DEBUG)
|
|
if(index >= sizeof...(p)) throw out_of_bounds{};
|
|
#endif
|
|
return table[index];
|
|
}
|
|
|
|
template<int64_t... p> auto from_array(uint index) -> int64_t {
|
|
static const array<int64_t[sizeof...(p)]> table{p...};
|
|
struct out_of_bounds {};
|
|
#if defined(DEBUG)
|
|
if(index >= sizeof...(p)) throw out_of_bounds{};
|
|
#endif
|
|
return table[index];
|
|
}
|
|
|
|
}
|