2015-02-28 01:51:53 +00:00
|
|
|
//request from emulation core to load non-volatile media folder
|
|
|
|
auto Program::loadRequest(unsigned id, string name, string type) -> void {
|
|
|
|
}
|
|
|
|
|
|
|
|
//request from emulation core to load non-volatile media file
|
|
|
|
auto Program::loadRequest(unsigned id, string path) -> void {
|
2015-04-21 11:51:57 +00:00
|
|
|
string location = {mediaPaths(emulator->group(id)), path};
|
2015-02-28 01:51:53 +00:00
|
|
|
if(!file::exists(location)) return;
|
|
|
|
mmapstream stream{location};
|
2015-04-21 11:51:57 +00:00
|
|
|
return emulator->load(id, stream);
|
2015-02-28 01:51:53 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 09:13:28 +00:00
|
|
|
//request from emulation core to save non-volatile media file
|
2015-02-28 01:51:53 +00:00
|
|
|
auto Program::saveRequest(unsigned id, string path) -> void {
|
2015-04-21 11:51:57 +00:00
|
|
|
string location = {mediaPaths(emulator->group(id)), path};
|
2015-03-02 09:13:28 +00:00
|
|
|
filestream stream{location, file::mode::write};
|
2015-04-21 11:51:57 +00:00
|
|
|
return emulator->save(id, stream);
|
2015-02-28 01:51:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto Program::videoColor(unsigned source, uint16 alpha, uint16 red, uint16 green, uint16 blue) -> uint32 {
|
|
|
|
alpha >>= 8;
|
|
|
|
red >>= 8;
|
|
|
|
green >>= 8;
|
|
|
|
blue >>= 8;
|
|
|
|
return alpha << 24 | red << 16 | green << 8 | blue << 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Program::videoRefresh(const uint32* palette, const uint32* data, unsigned pitch, unsigned width, unsigned height) -> void {
|
|
|
|
uint32* output;
|
|
|
|
unsigned length;
|
|
|
|
|
|
|
|
if(video.lock(output, length, width, height)) {
|
|
|
|
pitch >>= 2, length >>= 2;
|
|
|
|
|
|
|
|
for(auto y : range(height)) {
|
|
|
|
const uint32* sp = data + y * pitch;
|
|
|
|
uint32* dp = output + y * length;
|
|
|
|
for(auto x : range(width)) {
|
|
|
|
*dp++ = palette[*sp++];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
video.unlock();
|
|
|
|
video.refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned frameCounter = 0;
|
|
|
|
static time_t previous, current;
|
|
|
|
frameCounter++;
|
|
|
|
|
|
|
|
time(¤t);
|
|
|
|
if(current != previous) {
|
|
|
|
previous = current;
|
2015-04-13 11:16:33 +00:00
|
|
|
statusText = {"FPS: ", frameCounter};
|
2015-02-28 01:51:53 +00:00
|
|
|
frameCounter = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Program::audioSample(int16 lsample, int16 rsample) -> void {
|
|
|
|
signed samples[] = {lsample, rsample};
|
|
|
|
dsp.sample(samples);
|
|
|
|
while(dsp.pending()) {
|
|
|
|
dsp.read(samples);
|
|
|
|
audio.sample(samples[0], samples[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Program::inputPoll(unsigned port, unsigned device, unsigned input) -> int16 {
|
2015-03-03 10:14:49 +00:00
|
|
|
if(presentation->focused()) {
|
2015-04-21 11:51:57 +00:00
|
|
|
auto guid = emulator->port[port].device[device].input[input].guid;
|
2015-03-03 10:14:49 +00:00
|
|
|
auto mapping = (InputMapping*)guid;
|
|
|
|
if(mapping) return mapping->poll();
|
|
|
|
}
|
2015-03-02 09:13:28 +00:00
|
|
|
return 0;
|
2015-02-28 01:51:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto Program::inputRumble(unsigned port, unsigned device, unsigned input, bool enable) -> void {
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Program::dipSettings(const Markup::Node& node) -> unsigned {
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Program::path(unsigned group) -> string {
|
|
|
|
return mediaPaths(group);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Program::notify(string text) -> void {
|
|
|
|
}
|