mirror of
https://github.com/libretro/bsnes-libretro.git
synced 2024-11-23 08:59:40 +00:00
3159285eaa
byuu says: Changelog: - nall: converted range, iterator, vector to 64-bit - added (very poor) ColecoVision emulation (including Coleco Adam expansion) - added MSX skeleton - added Neo Geo Pocket skeleton - moved audio,video,resource folders into emulator folder - SFC heuristics: BS-X Town cart is "ZBSJ" [hex_usr] The nall change is for future work on things like BPA: I need to be able to handle files larger than 4GB. It is extremely possible that there are still some truncations to 32-bit lurking around, and even more disastrously, possibly some -1s lurking that won't sign-extend to `(uint64_t)0-1`. There's a lot more classes left to do: `string`, `array_view`, `array_span`, etc.
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
#pragma once
|
|
|
|
namespace nall {
|
|
|
|
struct range_t {
|
|
struct iterator {
|
|
iterator(int64_t position, int64_t step = 0) : position(position), step(step) {}
|
|
auto operator*() const -> int64_t { return position; }
|
|
auto operator!=(const iterator& source) const -> bool { return step > 0 ? position < source.position : position > source.position; }
|
|
auto operator++() -> iterator& { position += step; return *this; }
|
|
|
|
private:
|
|
int64_t position;
|
|
const int64_t step;
|
|
};
|
|
|
|
struct reverse_iterator {
|
|
reverse_iterator(int64_t position, int64_t step = 0) : position(position), step(step) {}
|
|
auto operator*() const -> int64_t { return position; }
|
|
auto operator!=(const reverse_iterator& source) const -> bool { return step > 0 ? position > source.position : position < source.position; }
|
|
auto operator++() -> reverse_iterator& { position -= step; return *this; }
|
|
|
|
private:
|
|
int64_t position;
|
|
const int64_t step;
|
|
};
|
|
|
|
auto begin() const -> iterator { return {origin, stride}; }
|
|
auto end() const -> iterator { return {target}; }
|
|
|
|
auto rbegin() const -> reverse_iterator { return {target - stride, stride}; }
|
|
auto rend() const -> reverse_iterator { return {origin - stride}; }
|
|
|
|
int64_t origin;
|
|
int64_t target;
|
|
int64_t stride;
|
|
};
|
|
|
|
inline auto range(int64_t size) {
|
|
return range_t{0, size, 1};
|
|
}
|
|
|
|
inline auto range(int64_t offset, int64_t size) {
|
|
return range_t{offset, size, 1};
|
|
}
|
|
|
|
inline auto range(int64_t offset, int64_t size, int64_t step) {
|
|
return range_t{offset, size, step};
|
|
}
|
|
|
|
}
|