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.
126 lines
3.9 KiB
C++
126 lines
3.9 KiB
C++
#ifndef NALL_CONFIG_HPP
|
|
#define NALL_CONFIG_HPP
|
|
|
|
#include <nall/file.hpp>
|
|
#include <nall/string.hpp>
|
|
#include <nall/vector.hpp>
|
|
|
|
namespace nall {
|
|
namespace configuration_traits {
|
|
template<typename T> struct is_boolean { enum { value = false }; };
|
|
template<> struct is_boolean<bool> { enum { value = true }; };
|
|
|
|
template<typename T> struct is_signed { enum { value = false }; };
|
|
template<> struct is_signed<signed> { enum { value = true }; };
|
|
|
|
template<typename T> struct is_unsigned { enum { value = false }; };
|
|
template<> struct is_unsigned<unsigned> { enum { value = true }; };
|
|
|
|
template<typename T> struct is_double { enum { value = false }; };
|
|
template<> struct is_double<double> { enum { value = true }; };
|
|
|
|
template<typename T> struct is_string { enum { value = false }; };
|
|
template<> struct is_string<string> { enum { value = true }; };
|
|
}
|
|
|
|
class configuration {
|
|
public:
|
|
enum type_t { boolean_t, signed_t, unsigned_t, double_t, string_t, unknown_t };
|
|
struct item_t {
|
|
uintptr_t data;
|
|
string name;
|
|
string desc;
|
|
type_t type;
|
|
|
|
inline string get() const {
|
|
switch(type) {
|
|
case boolean_t: return { *(bool*)data };
|
|
case signed_t: return { *(signed*)data };
|
|
case unsigned_t: return { *(unsigned*)data };
|
|
case double_t: return { *(double*)data };
|
|
case string_t: return { "\"", *(string*)data, "\"" };
|
|
}
|
|
return "???";
|
|
}
|
|
|
|
inline void set(string s) {
|
|
switch(type) {
|
|
case boolean_t: *(bool*)data = (s == "true"); break;
|
|
case signed_t: *(signed*)data = integer(s); break;
|
|
case unsigned_t: *(unsigned*)data = decimal(s); break;
|
|
case double_t: *(double*)data = fp(s); break;
|
|
case string_t: s.trim("\""); *(string*)data = s; break;
|
|
}
|
|
}
|
|
};
|
|
vector<item_t> list;
|
|
|
|
template<typename T>
|
|
inline void append(T &data, const char *name, const char *desc = "") {
|
|
item_t item = { (uintptr_t)&data, name, desc };
|
|
if(configuration_traits::is_boolean<T>::value) item.type = boolean_t;
|
|
else if(configuration_traits::is_signed<T>::value) item.type = signed_t;
|
|
else if(configuration_traits::is_unsigned<T>::value) item.type = unsigned_t;
|
|
else if(configuration_traits::is_double<T>::value) item.type = double_t;
|
|
else if(configuration_traits::is_string<T>::value) item.type = string_t;
|
|
else item.type = unknown_t;
|
|
list.append(item);
|
|
}
|
|
|
|
//deprecated
|
|
template<typename T>
|
|
inline void attach(T &data, const char *name, const char *desc = "") {
|
|
append(data, name, desc);
|
|
}
|
|
|
|
inline virtual bool load(const string &filename) {
|
|
string data;
|
|
if(data.readfile(filename) == true) {
|
|
data.replace("\r", "");
|
|
lstring line;
|
|
line.split("\n", data);
|
|
|
|
for(unsigned i = 0; i < line.size(); i++) {
|
|
if(auto position = qstrpos(line[i], "#")) line[i][position()] = 0;
|
|
if(!qstrpos(line[i], " = ")) continue;
|
|
|
|
lstring part;
|
|
part.qsplit(" = ", line[i]);
|
|
part[0].trim();
|
|
part[1].trim();
|
|
|
|
for(unsigned n = 0; n < list.size(); n++) {
|
|
if(part[0] == list[n].name) {
|
|
list[n].set(part[1]);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
inline virtual bool save(const string &filename) const {
|
|
file fp;
|
|
if(fp.open(filename, file::mode::write)) {
|
|
for(unsigned i = 0; i < list.size(); i++) {
|
|
string output;
|
|
output.append(list[i].name, " = ", list[i].get());
|
|
if(list[i].desc != "") output.append(" # ", list[i].desc);
|
|
output.append("\r\n");
|
|
fp.print(output);
|
|
}
|
|
|
|
fp.close();
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif
|