mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-04-02 10:42:14 -04:00
byuu says: Most notably, this release adds Nintendo DS emulation. The Nintendo DS module was written entirely by Cydrak, so please give him all of the credit for it. I for one am extremely grateful to be allowed to use his module in bsnes. The Nintendo DS emulator's standalone name is dasShiny. You will need the Nintendo DS firmware, which I cannot provide, in order to use it. It also cannot (currently?) detect the save type used by NDS games. As such, manifest.xml files must be created manually for this purpose. The long-term plan is to create a database of save types for each game. Also, you will need an analog input device for the touch screen for now (joypad axes work well.) There have also been a lot of changes from my end: a unified manifest.xml format across all systems, major improvements to SPC7110 emulation, enhancements to RTC emulation, MSU1 enhancements, icons in the file browser list, improvements to SNES coprocessor memory mapping, cleanups and improvements in the libraries used to build bsnes, etc. I've also included kaijuu (which allows launching game folders directly with bsnes) and purify (which allows opening images that are compressed, have copier headers, and have wrong extensions); both of which are fully GUI-based. This release only loads game folders, not files. Use purify to load ROM files in bsnes. Note that this will likely be the last release for a long time, and that I will probably rename the emulator for the next release, due to how many additional systems it now supports.
82 lines
2.1 KiB
C++
82 lines
2.1 KiB
C++
#ifndef NALL_BIT_HPP
|
|
#define NALL_BIT_HPP
|
|
|
|
#include <nall/stdint.hpp>
|
|
|
|
namespace nall {
|
|
template<unsigned bits>
|
|
inline uintmax_t uclamp(const uintmax_t x) {
|
|
enum : uintmax_t { b = 1ull << (bits - 1), y = b * 2 - 1 };
|
|
return y + ((x - y) & -(x < y)); //min(x, y);
|
|
}
|
|
|
|
template<unsigned bits>
|
|
inline uintmax_t uclip(const uintmax_t x) {
|
|
enum : uintmax_t { b = 1ull << (bits - 1), m = b * 2 - 1 };
|
|
return (x & m);
|
|
}
|
|
|
|
template<unsigned bits>
|
|
inline intmax_t sclamp(const intmax_t x) {
|
|
enum : intmax_t { b = 1ull << (bits - 1), m = b - 1 };
|
|
return (x > m) ? m : (x < -b) ? -b : x;
|
|
}
|
|
|
|
template<unsigned bits>
|
|
inline intmax_t sclip(const intmax_t x) {
|
|
enum : uintmax_t { b = 1ull << (bits - 1), m = b * 2 - 1 };
|
|
return ((x & m) ^ b) - b;
|
|
}
|
|
|
|
namespace bit {
|
|
constexpr inline uintmax_t mask(const char *s, uintmax_t sum = 0) {
|
|
return (
|
|
*s == '0' || *s == '1' ? mask(s + 1, (sum << 1) | 1) :
|
|
*s == ' ' || *s == '_' ? mask(s + 1, sum) :
|
|
*s ? mask(s + 1, sum << 1) :
|
|
sum
|
|
);
|
|
}
|
|
|
|
constexpr inline uintmax_t test(const char *s, uintmax_t sum = 0) {
|
|
return (
|
|
*s == '0' || *s == '1' ? test(s + 1, (sum << 1) | (*s - '0')) :
|
|
*s == ' ' || *s == '_' ? test(s + 1, sum) :
|
|
*s ? test(s + 1, sum << 1) :
|
|
sum
|
|
);
|
|
}
|
|
|
|
//lowest(0b1110) == 0b0010
|
|
constexpr inline uintmax_t lowest(const uintmax_t x) {
|
|
return x & -x;
|
|
}
|
|
|
|
//clear_lowest(0b1110) == 0b1100
|
|
constexpr inline uintmax_t clear_lowest(const uintmax_t x) {
|
|
return x & (x - 1);
|
|
}
|
|
|
|
//set_lowest(0b0101) == 0b0111
|
|
constexpr inline uintmax_t set_lowest(const uintmax_t x) {
|
|
return x | (x + 1);
|
|
}
|
|
|
|
//count number of bits set in a byte
|
|
inline unsigned count(uintmax_t x) {
|
|
unsigned count = 0;
|
|
do count += x & 1; while(x >>= 1);
|
|
return count;
|
|
}
|
|
|
|
//round up to next highest single bit:
|
|
//round(15) == 16, round(16) == 16, round(17) == 32
|
|
inline uintmax_t round(uintmax_t x) {
|
|
if((x & (x - 1)) == 0) return x;
|
|
while(x & (x - 1)) x &= x - 1;
|
|
return x << 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|