bsnes/emulator/interface.hpp
Tim Allen a21ff570ee Update to v094r26 release (open beta).
byuu says:

Obviously, this is a fairly major WIP. It's the first public release in
17 months. The entire UI has been rewritten (for the 74th time), and is
now internally called tomoko. The official releases will be named higan
(both the binaries and title bar.)

Missing features from v094:

- ananke is missing (this means you will need v094 to create game
  folders to be loaded)
- key assignments are limited to one physical button = one mapping (no
  multi-mapping)
- shader support is missing
- audio/video profiling is missing
- DIP switch window is missing (used by NSS Actraiser with a special
  manifest; that's about it)
- alternate paths for game system folders and configuration BML files

There's some new stuff, but not much. This isn't going to be an exciting
WIP in terms of features. It's more about being a brand new release with
the brand new hiro port and its shared memory model. The goal is to get
these WIPs stable, get v095 out, and then finally start improving the
actual emulation again after that.
2015-06-16 20:30:04 +10:00

119 lines
4.4 KiB
C++

#ifndef EMULATOR_INTERFACE_HPP
#define EMULATOR_INTERFACE_HPP
namespace Emulator {
struct Interface {
struct Information {
string name;
unsigned width;
unsigned height;
bool overscan;
double aspectRatio;
bool resettable;
struct Capability {
bool states;
bool cheats;
} capability;
} information;
struct Media {
unsigned id;
string name;
string type;
bool bootable; //false for cartridge slots (eg Sufami Turbo cartridges)
};
vector<Media> media;
struct Device {
unsigned id;
unsigned portmask;
string name;
struct Input {
unsigned id;
unsigned type; //0 = digital, 1 = analog (relative), 2 = rumble
string name;
uintptr_t guid;
};
vector<Input> input;
vector<unsigned> order;
};
struct Port {
unsigned id;
string name;
vector<Device> device;
};
vector<Port> port;
struct Bind {
virtual auto loadRequest(unsigned, string, string) -> void {}
virtual auto loadRequest(unsigned, string) -> void {}
virtual auto saveRequest(unsigned, string) -> void {}
virtual auto videoColor(unsigned, uint16_t, uint16_t, uint16_t, uint16_t) -> uint32_t { return 0u; }
virtual auto videoRefresh(const uint32_t*, const uint32_t*, unsigned, unsigned, unsigned) -> void {}
virtual auto audioSample(int16_t, int16_t) -> void {}
virtual auto inputPoll(unsigned, unsigned, unsigned) -> int16_t { return 0; }
virtual auto inputRumble(unsigned, unsigned, unsigned, bool) -> void {}
virtual auto dipSettings(const Markup::Node&) -> unsigned { return 0; }
virtual auto path(unsigned) -> string { return ""; }
virtual auto server() -> string { return ""; }
virtual auto notify(string text) -> void { print(text, "\n"); }
};
Bind* bind = nullptr;
//callback bindings (provided by user interface)
auto loadRequest(unsigned id, string name, string type) -> void { return bind->loadRequest(id, name, type); }
auto loadRequest(unsigned id, string path) -> void { return bind->loadRequest(id, path); }
auto saveRequest(unsigned id, string path) -> void { return bind->saveRequest(id, path); }
auto videoColor(unsigned source, uint16_t alpha, uint16_t red, uint16_t green, uint16_t blue) -> uint32_t { return bind->videoColor(source, alpha, red, green, blue); }
auto videoRefresh(const uint32_t* palette, const uint32_t* data, unsigned pitch, unsigned width, unsigned height) -> void { return bind->videoRefresh(palette, data, pitch, width, height); }
auto audioSample(int16_t lsample, int16_t rsample) -> void { return bind->audioSample(lsample, rsample); }
auto inputPoll(unsigned port, unsigned device, unsigned input) -> int16_t { return bind->inputPoll(port, device, input); }
auto inputRumble(unsigned port, unsigned device, unsigned input, bool enable) -> void { return bind->inputRumble(port, device, input, enable); }
auto dipSettings(const Markup::Node& node) -> unsigned { return bind->dipSettings(node); }
auto path(unsigned group) -> string { return bind->path(group); }
auto server() -> string { return bind->server(); }
template<typename... P> auto notify(P&&... p) -> void { return bind->notify({forward<P>(p)...}); }
//information
virtual auto title() -> string = 0;
virtual auto videoFrequency() -> double = 0;
virtual auto audioFrequency() -> double = 0;
//media interface
virtual auto loaded() -> bool { return false; }
virtual auto sha256() -> string { return ""; }
virtual auto group(unsigned id) -> unsigned = 0;
virtual auto load(unsigned id) -> void {}
virtual auto save() -> void {}
virtual auto load(unsigned id, const stream& memory) -> void {}
virtual auto save(unsigned id, const stream& memory) -> void {}
virtual auto unload() -> void {}
//system interface
virtual auto connect(unsigned port, unsigned device) -> void {}
virtual auto power() -> void {}
virtual auto reset() -> void {}
virtual auto run() -> void {}
//time functions
virtual auto rtc() -> bool { return false; }
virtual auto rtcsync() -> void {}
//state functions
virtual auto serialize() -> serializer = 0;
virtual auto unserialize(serializer&) -> bool = 0;
//cheat functions
virtual auto cheatSet(const lstring& = lstring{}) -> void {}
//utility functions
enum class PaletteMode : unsigned { Literal, Channel, Standard, Emulation };
virtual auto paletteUpdate(PaletteMode mode) -> void {}
};
}
#endif