Reformat Libretro (Resharper)

This commit is contained in:
Vladimir Kononovich 2020-12-19 23:31:01 +03:00
parent f3f15a32fe
commit a6e89dd132
6 changed files with 2244 additions and 2076 deletions

View file

@ -15,13 +15,17 @@ private:
bool ProcessAction(uint32_t button)
{
if(_getInputState(0, RETRO_DEVICE_JOYPAD, 0, button)) {
if(!_wasPushed[button]) {
if (_getInputState(0, RETRO_DEVICE_JOYPAD, 0, button))
{
if (!_wasPushed[button])
{
//Newly pressed, process action
_wasPushed[button] = true;
return true;
}
} else {
}
else
{
_wasPushed[button] = false;
}
return false;
@ -52,11 +56,13 @@ public:
// Inherited via IKeyManager
virtual void RefreshState() override
{
if(_pollInput) {
if (_pollInput)
{
_pollInput();
}
if(_getInputState) {
if (_getInputState)
{
int32_t x = _getInputState(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
int32_t y = _getInputState(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);
@ -69,17 +75,23 @@ public:
int16_t dy = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
KeyManager::SetMouseMovement(dx, dy);
_mouseButtons[(int)MouseButton::LeftButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT) != 0;
_mouseButtons[(int)MouseButton::RightButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT) != 0;
_mouseButtons[(int)MouseButton::MiddleButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_MIDDLE) != 0;
_mouseButtons[(int)MouseButton::LeftButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0,
RETRO_DEVICE_ID_MOUSE_LEFT) != 0;
_mouseButtons[(int)MouseButton::RightButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0,
RETRO_DEVICE_ID_MOUSE_RIGHT) != 0;
_mouseButtons[(int)MouseButton::MiddleButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0,
RETRO_DEVICE_ID_MOUSE_MIDDLE) != 0;
}
}
virtual bool IsKeyPressed(uint32_t keyCode) override
{
if(keyCode > 0 && _getInputState) {
if (keyCode > 0 && _getInputState)
{
return _getInputState(keyCode >> 8, RETRO_DEVICE_JOYPAD, 0, (keyCode - 1) & 0xFF) != 0;
} else {
}
else
{
return false;
}
}

View file

@ -25,11 +25,15 @@ public:
// Inherited via IMessageManager
virtual void DisplayMessage(string title, string message) override
{
if(title.empty()) {
if(_log) {
if (title.empty())
{
if (_log)
{
_log(RETRO_LOG_INFO, message.c_str());
}
} else {
}
else
{
string osdMessage = "[" + title + "] " + message;
retro_message msg = {osdMessage.c_str(), 180};
_retroEnv(RETRO_ENVIRONMENT_SET_MESSAGE, &msg);

View file

@ -32,11 +32,13 @@ public:
// Inherited via IRenderingDevice
virtual void UpdateFrame(void* frameBuffer, uint32_t width, uint32_t height) override
{
if(!_skipMode && _sendFrame) {
if (!_skipMode && _sendFrame)
{
//Use Blargg's NTSC filter's max size as a minimum resolution, to prevent changing resolution too often
int32_t newWidth = std::max<int32_t>(width, SNES_NTSC_OUT_WIDTH(256));
int32_t newHeight = std::max<int32_t>(height, 239 * 2);
if(_retroEnv != nullptr && (_previousWidth != newWidth || _previousHeight != newHeight)) {
if (_retroEnv != nullptr && (_previousWidth != newWidth || _previousHeight != newHeight))
{
//Resolution change is needed
retro_system_av_info avInfo = {};
GetSystemAudioVideoInfo(avInfo, newWidth, newHeight);
@ -54,7 +56,9 @@ public:
{
AudioConfig audio = _console->GetSettings()->GetAudioConfig();
info.timing.fps = _console->GetRegion() == ConsoleRegion::Ntsc ? 60.098811862348404716732985230828 : 50.006977968268290848936010226333;
info.timing.fps = _console->GetRegion() == ConsoleRegion::Ntsc
? 60.098811862348404716732985230828
: 50.006977968268290848936010226333;
info.timing.sample_rate = audio.SampleRate;
OverscanDimensions overscan = _console->GetSettings()->GetOverscan();
@ -62,15 +66,22 @@ public:
int height = (239 - overscan.Top - overscan.Bottom);
double aspectRatio = _console->GetSettings()->GetAspectRatio(_console->GetRegion());
if(aspectRatio != 0.0) {
if (aspectRatio != 0.0)
{
VideoAspectRatio aspect = _console->GetSettings()->GetVideoConfig().AspectRatio;
bool usePar = aspect == VideoAspectRatio::NTSC || aspect == VideoAspectRatio::PAL || aspect == VideoAspectRatio::Auto;
if(usePar) {
bool usePar = aspect == VideoAspectRatio::NTSC || aspect == VideoAspectRatio::PAL || aspect ==
VideoAspectRatio::Auto;
if (usePar)
{
info.geometry.aspect_ratio = (float)(width * aspectRatio / height);
} else {
}
else
{
info.geometry.aspect_ratio = (float)aspectRatio;
}
} else {
}
else
{
info.geometry.aspect_ratio = (float)width / height;
}
@ -80,7 +91,8 @@ public:
info.geometry.max_width = maxWidth;
info.geometry.max_height = maxHeight;
if(maxHeight > 0 && maxWidth > 0) {
if (maxHeight > 0 && maxWidth > 0)
{
_previousWidth = maxWidth;
_previousHeight = maxHeight;
}
@ -104,7 +116,8 @@ public:
{
}
virtual void SetFullscreenMode(bool fullscreen, void *windowHandle, uint32_t monitorWidth, uint32_t monitorHeight) override
virtual void SetFullscreenMode(bool fullscreen, void* windowHandle, uint32_t monitorWidth,
uint32_t monitorHeight) override
{
}
};

View file

@ -25,8 +25,10 @@ public:
// Inherited via IAudioDevice
virtual void PlayBuffer(int16_t* soundBuffer, uint32_t sampleCount, uint32_t sampleRate, bool isStereo) override
{
if(!_skipMode && _sendAudioSample) {
for(uint32_t total = 0; total < sampleCount; ) {
if (!_skipMode && _sendAudioSample)
{
for (uint32_t total = 0; total < sampleCount;)
{
total += (uint32_t)_sendAudioSample(soundBuffer + total * 2, (size_t)(sampleCount - total));
}
}

View file

@ -57,7 +57,8 @@ static constexpr const char* MesenGbSgb2 = "mesen-s_sgb2";
extern "C" {
void logMessage(retro_log_level level, const char* message)
{
if(logCallback) {
if (logCallback)
{
logCallback(level, message);
}
}
@ -70,9 +71,12 @@ extern "C" {
RETRO_API void retro_init()
{
struct retro_log_callback log;
if(retroEnv(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log)) {
if (retroEnv(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log))
{
logCallback = log.log;
} else {
}
else
{
logCallback = nullptr;
}
@ -206,7 +210,8 @@ extern "C" {
{
var.key = key;
var.value = nullptr;
if(retroEnv(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value != nullptr) {
if (retroEnv(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value != nullptr)
{
return true;
}
return false;
@ -227,11 +232,15 @@ extern "C" {
video.Saturation = 0;
video.ScanlineIntensity = 0;
if(readVariable(MesenNtscFilter, var)) {
if (readVariable(MesenNtscFilter, var))
{
string value = string(var.value);
if(value == "Disabled") {
if (value == "Disabled")
{
video.VideoFilter = VideoFilterType::None;
} else if(value == "Composite (Blargg)") {
}
else if (value == "Composite (Blargg)")
{
video.VideoFilter = VideoFilterType::NTSC;
video.NtscArtifacts = 0;
video.NtscBleed = 0;
@ -240,7 +249,9 @@ extern "C" {
video.NtscResolution = 0;
video.NtscSharpness = 0;
video.NtscMergeFields = false;
} else if(value == "S-Video (Blargg)") {
}
else if (value == "S-Video (Blargg)")
{
video.VideoFilter = VideoFilterType::NTSC;
video.NtscArtifacts = -1.0;
video.NtscBleed = 0;
@ -249,7 +260,9 @@ extern "C" {
video.NtscResolution = 0.2;
video.NtscSharpness = 0.2;
video.NtscMergeFields = false;
} else if(value == "RGB (Blargg)") {
}
else if (value == "RGB (Blargg)")
{
video.VideoFilter = VideoFilterType::NTSC;
video.NtscArtifacts = -1.0;
video.NtscBleed = -1.0;
@ -258,7 +271,9 @@ extern "C" {
video.NtscResolution = 0.7;
video.NtscSharpness = 0.2;
video.NtscMergeFields = false;
} else if(value == "Monochrome (Blargg)") {
}
else if (value == "Monochrome (Blargg)")
{
video.VideoFilter = VideoFilterType::NTSC;
video.Saturation = -1.0;
video.NtscArtifacts = -0.2;
@ -272,71 +287,106 @@ extern "C" {
}
bool beforeNmi = true;
if(readVariable(MesenOverclockType, var)) {
if (readVariable(MesenOverclockType, var))
{
string value = string(var.value);
if(value == "After NMI") {
if (value == "After NMI")
{
beforeNmi = false;
}
}
if(readVariable(MesenOverclock, var)) {
if (readVariable(MesenOverclock, var))
{
string value = string(var.value);
int lineCount = 0;
if(value == "None") {
if (value == "None")
{
lineCount = 0;
} else if(value == "Low") {
}
else if (value == "Low")
{
lineCount = 100;
} else if(value == "Medium") {
}
else if (value == "Medium")
{
lineCount = 250;
} else if(value == "High") {
}
else if (value == "High")
{
lineCount = 500;
} else if(value == "Very High") {
}
else if (value == "Very High")
{
lineCount = 1000;
}
if(beforeNmi) {
if (beforeNmi)
{
emulation.PpuExtraScanlinesBeforeNmi = lineCount;
emulation.PpuExtraScanlinesAfterNmi = 0;
} else {
}
else
{
emulation.PpuExtraScanlinesAfterNmi = lineCount;
emulation.PpuExtraScanlinesBeforeNmi = 0;
}
}
emulation.GsuClockSpeed = 100;
if(readVariable(MesenSuperFxOverclock, var)) {
if (readVariable(MesenSuperFxOverclock, var))
{
string value = string(var.value);
if(value == "100%") {
if (value == "100%")
{
emulation.GsuClockSpeed = 100;
} else if(value == "200%") {
}
else if (value == "200%")
{
emulation.GsuClockSpeed = 200;
} else if(value == "300%") {
}
else if (value == "300%")
{
emulation.GsuClockSpeed = 300;
} else if(value == "400%") {
}
else if (value == "400%")
{
emulation.GsuClockSpeed = 400;
} else if(value == "500%") {
}
else if (value == "500%")
{
emulation.GsuClockSpeed = 500;
} else if(value == "1000%") {
}
else if (value == "1000%")
{
emulation.GsuClockSpeed = 1000;
}
}
int overscanHorizontal = 0;
int overscanVertical = 0;
if(readVariable(MesenOverscanHorizontal, var)) {
if (readVariable(MesenOverscanHorizontal, var))
{
string value = string(var.value);
if(value == "8px") {
if (value == "8px")
{
overscanHorizontal = 8;
} else if(value == "16px") {
}
else if (value == "16px")
{
overscanHorizontal = 16;
}
}
if(readVariable(MesenOverscanVertical, var)) {
if (readVariable(MesenOverscanVertical, var))
{
string value = string(var.value);
if(value == "8px") {
if (value == "8px")
{
overscanVertical = 8;
} else if(value == "16px") {
}
else if (value == "16px")
{
overscanVertical = 16;
}
}
@ -346,78 +396,115 @@ extern "C" {
video.OverscanTop = std::max(0, overscanVertical - 1);
video.OverscanBottom = overscanVertical;
if(readVariable(MesenAspectRatio, var)) {
if (readVariable(MesenAspectRatio, var))
{
string value = string(var.value);
if(value == "Auto") {
if (value == "Auto")
{
video.AspectRatio = VideoAspectRatio::Auto;
} else if(value == "No Stretching") {
}
else if (value == "No Stretching")
{
video.AspectRatio = VideoAspectRatio::NoStretching;
} else if(value == "NTSC") {
}
else if (value == "NTSC")
{
video.AspectRatio = VideoAspectRatio::NTSC;
} else if(value == "PAL") {
}
else if (value == "PAL")
{
video.AspectRatio = VideoAspectRatio::PAL;
} else if(value == "4:3") {
}
else if (value == "4:3")
{
video.AspectRatio = VideoAspectRatio::Standard;
} else if(value == "16:9") {
}
else if (value == "16:9")
{
video.AspectRatio = VideoAspectRatio::Widescreen;
}
}
if(readVariable(MesenRegion, var)) {
if (readVariable(MesenRegion, var))
{
string value = string(var.value);
if(value == "Auto") {
if (value == "Auto")
{
emulation.Region = ConsoleRegion::Auto;
} else if(value == "NTSC") {
}
else if (value == "NTSC")
{
emulation.Region = ConsoleRegion::Ntsc;
} else if(value == "PAL") {
}
else if (value == "PAL")
{
emulation.Region = ConsoleRegion::Pal;
}
}
if(readVariable(MesenRamState, var)) {
if (readVariable(MesenRamState, var))
{
string value = string(var.value);
if(value == "Random Values (Default)") {
if (value == "Random Values (Default)")
{
emulation.RamPowerOnState = RamState::Random;
} else if(value == "All 0s") {
}
else if (value == "All 0s")
{
emulation.RamPowerOnState = RamState::AllZeros;
} else if(value == "All 1s") {
}
else if (value == "All 1s")
{
emulation.RamPowerOnState = RamState::AllOnes;
}
}
if(readVariable(MesenBlendHighRes, var)) {
if (readVariable(MesenBlendHighRes, var))
{
string value = string(var.value);
video.BlendHighResolutionModes = (value == "enabled");
}
if(readVariable(MesenCubicInterpolation, var)) {
if (readVariable(MesenCubicInterpolation, var))
{
string value = string(var.value);
audio.EnableCubicInterpolation = (value == "enabled");
}
if(readVariable(MesenGbModel, var)) {
if (readVariable(MesenGbModel, var))
{
string value = string(var.value);
if(value == "Game Boy") {
if (value == "Game Boy")
{
gbConfig.Model = GameboyModel::Gameboy;
} else if(value == "Game Boy Color") {
}
else if (value == "Game Boy Color")
{
gbConfig.Model = GameboyModel::GameboyColor;
} else if(value == "Super Game Boy") {
}
else if (value == "Super Game Boy")
{
gbConfig.Model = GameboyModel::SuperGameboy;
} else {
}
else
{
gbConfig.Model = GameboyModel::Auto;
}
}
if(readVariable(MesenGbSgb2, var)) {
if (readVariable(MesenGbSgb2, var))
{
string value = string(var.value);
gbConfig.UseSgb2 = (value == "enabled");
}
auto getKeyCode = [=](int port, int retroKey) {
auto getKeyCode = [=](int port, int retroKey)
{
return (port << 8) | (retroKey + 1);
};
auto getKeyBindings = [=](int port) {
auto getKeyBindings = [=](int port)
{
KeyMappingSet keyMappings;
keyMappings.TurboSpeed = 0;
keyMappings.Mapping1.L = getKeyCode(port, RETRO_DEVICE_ID_JOYPAD_L);
@ -457,23 +544,28 @@ extern "C" {
RETRO_API void retro_run()
{
bool updated = false;
if(retroEnv(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) {
if (retroEnv(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
{
update_settings();
}
bool isFastForward = false;
EmulationConfig cfg = _console->GetSettings()->GetEmulationConfig();
if(retroEnv(RETRO_ENVIRONMENT_GET_FASTFORWARDING, &isFastForward) && isFastForward) {
if (retroEnv(RETRO_ENVIRONMENT_GET_FASTFORWARDING, &isFastForward) && isFastForward)
{
//Allow core to skip frame rendering during fast forwarding
cfg.EmulationSpeed = 0;
} else {
}
else
{
cfg.EmulationSpeed = 100;
}
_console->GetSettings()->SetEmulationConfig(cfg);
_console->RunSingleFrame();
if(updated) {
if (updated)
{
//Update geometry after running the frame, in case the console's region changed (affects "auto" aspect ratio)
retro_system_av_info avInfo = {};
_renderer->GetSystemAudioVideoInfo(avInfo);
@ -512,7 +604,8 @@ extern "C" {
RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char* codeStr)
{
if(codeStr) {
if (codeStr)
{
_console->GetCheatManager()->AddStringCheat(codeStr);
}
}
@ -521,27 +614,36 @@ extern "C" {
{
vector<retro_input_descriptor> desc;
auto addDesc = [&desc](unsigned port, unsigned button, const char* name) {
auto addDesc = [&desc](unsigned port, unsigned button, const char* name)
{
retro_input_descriptor d = {port, RETRO_DEVICE_JOYPAD, 0, button, name};
desc.push_back(d);
};
auto setupPlayerButtons = [addDesc](int port) {
auto setupPlayerButtons = [addDesc](int port)
{
unsigned device = _inputDevices[port];
if(device == DEVICE_AUTO) {
if(port <= 4) {
switch(_console->GetSettings()->GetInputConfig().Controllers[port].Type) {
if (device == DEVICE_AUTO)
{
if (port <= 4)
{
switch (_console->GetSettings()->GetInputConfig().Controllers[port].Type)
{
case ControllerType::Multitap:
case ControllerType::SnesController: device = DEVICE_GAMEPAD; break;
case ControllerType::SnesController: device = DEVICE_GAMEPAD;
break;
case ControllerType::SuperScope: device = DEVICE_SUPERSCOPE; break;
case ControllerType::SnesMouse: device = DEVICE_SNESMOUSE; break;
case ControllerType::SuperScope: device = DEVICE_SUPERSCOPE;
break;
case ControllerType::SnesMouse: device = DEVICE_SNESMOUSE;
break;
default: return;
}
}
}
if(device == DEVICE_GAMEPAD) {
if (device == DEVICE_GAMEPAD)
{
addDesc(port, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left");
addDesc(port, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up");
addDesc(port, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down");
@ -559,7 +661,8 @@ extern "C" {
setupPlayerButtons(0);
setupPlayerButtons(1);
if(_console->GetSettings()->GetInputConfig().Controllers[1].Type == ControllerType::Multitap) {
if (_console->GetSettings()->GetInputConfig().Controllers[1].Type == ControllerType::Multitap)
{
setupPlayerButtons(2);
setupPlayerButtons(3);
setupPlayerButtons(4);
@ -574,14 +677,21 @@ extern "C" {
void update_core_controllers()
{
InputConfig input = _console->GetSettings()->GetInputConfig();
for(int port = 0; port < 2; port++) {
for (int port = 0; port < 2; port++)
{
ControllerType type = ControllerType::SnesController;
switch(_inputDevices[port]) {
case RETRO_DEVICE_NONE: type = ControllerType::None; break;
case DEVICE_GAMEPAD: type = ControllerType::SnesController; break;
case DEVICE_MULTITAP: type = ControllerType::Multitap; break;
case DEVICE_SNESMOUSE: type = ControllerType::SnesMouse; break;
case DEVICE_SUPERSCOPE: type = ControllerType::SuperScope; break;
switch (_inputDevices[port])
{
case RETRO_DEVICE_NONE: type = ControllerType::None;
break;
case DEVICE_GAMEPAD: type = ControllerType::SnesController;
break;
case DEVICE_MULTITAP: type = ControllerType::Multitap;
break;
case DEVICE_SNESMOUSE: type = ControllerType::SnesMouse;
break;
case DEVICE_SUPERSCOPE: type = ControllerType::SuperScope;
break;
}
input.Controllers[port].Type = type;
}
@ -593,20 +703,24 @@ extern "C" {
{
shared_ptr<BaseCartridge> cart = _console->GetCartridge();
Gameboy* gb = cart->GetGameboy();
if(gb) {
if (gb)
{
retro_memory_descriptor descriptors[20] = {};
uint32_t count = 0;
auto addDescriptor = [&count, &descriptors](uint8_t* ptr, uint32_t address, uint32_t length) {
auto addDescriptor = [&count, &descriptors](uint8_t* ptr, uint32_t address, uint32_t length)
{
descriptors[count].ptr = ptr;
descriptors[count].start = (size_t)address;
descriptors[count].len = (size_t)length;
count++;
};
addDescriptor(gb->DebugGetMemory(SnesMemoryType::GbPrgRom), 0x0000, std::min(0x8000, (int)gb->DebugGetMemorySize(SnesMemoryType::GbPrgRom)));
addDescriptor(gb->DebugGetMemory(SnesMemoryType::GbPrgRom), 0x0000,
std::min(0x8000, (int)gb->DebugGetMemorySize(SnesMemoryType::GbPrgRom)));
addDescriptor(gb->DebugGetMemory(SnesMemoryType::GbVideoRam), 0x8000, 0x2000);
if(gb->DebugGetMemory(SnesMemoryType::GbCartRam)) {
if (gb->DebugGetMemory(SnesMemoryType::GbCartRam))
{
uint32_t size = std::min(0x2000u, gb->DebugGetMemorySize(SnesMemoryType::GbCartRam));
addDescriptor(gb->DebugGetMemory(SnesMemoryType::GbCartRam), 0xA000, size);
}
@ -616,7 +730,8 @@ extern "C" {
addDescriptor(gb->DebugGetMemory(SnesMemoryType::GbHighRam), 0xFF80, 0x80);
if(gb->DebugGetMemorySize(SnesMemoryType::GbWorkRam) == 0x8000) {
if (gb->DebugGetMemorySize(SnesMemoryType::GbWorkRam) == 0x8000)
{
//GBC - map extra work ram at "fake" 0x10000-0x16000 range
addDescriptor(gb->DebugGetMemory(SnesMemoryType::WorkRam) + 0x2000, 0x10000, 0x6000);
}
@ -630,7 +745,8 @@ extern "C" {
RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device)
{
if(port < 5 && _inputDevices[port] != device) {
if (port < 5 && _inputDevices[port] != device)
{
_inputDevices[port] = device;
update_core_controllers();
update_input_descriptors();
@ -640,17 +756,20 @@ extern "C" {
RETRO_API bool retro_load_game(const struct retro_game_info* game)
{
char* systemFolder;
if(!retroEnv(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &systemFolder) || !systemFolder) {
if (!retroEnv(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &systemFolder) || !systemFolder)
{
return false;
}
char* saveFolder;
if(!retroEnv(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &saveFolder)) {
if (!retroEnv(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &saveFolder))
{
logMessage(RETRO_LOG_ERROR, "Could not find save directory.\n");
}
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
if(!retroEnv(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
if (!retroEnv(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
{
logMessage(RETRO_LOG_ERROR, "XRGB8888 is not supported.\n");
return false;
}
@ -673,7 +792,8 @@ extern "C" {
VirtualFile patch;
bool result = _console->LoadRom(romData, patch);
if(result) {
if (result)
{
update_core_controllers();
update_input_descriptors();
@ -709,7 +829,8 @@ extern "C" {
RETRO_API void retro_get_system_info(struct retro_system_info* info)
{
if(!_console) {
if (!_console)
{
_console.reset(new Console());
_console->Initialize();
}
@ -730,13 +851,18 @@ extern "C" {
RETRO_API void* retro_get_memory_data(unsigned id)
{
shared_ptr<BaseCartridge> cart = _console->GetCartridge();
if(cart->GetGameboy()) {
switch(id) {
if (cart->GetGameboy())
{
switch (id)
{
case RETRO_MEMORY_SAVE_RAM: return cart->GetGameboy()->DebugGetMemory(SnesMemoryType::GbCartRam);
case RETRO_MEMORY_SYSTEM_RAM: return cart->GetGameboy()->DebugGetMemory(SnesMemoryType::GbWorkRam);
}
} else {
switch(id) {
}
else
{
switch (id)
{
case RETRO_MEMORY_SAVE_RAM: return cart->DebugGetSaveRam();
case RETRO_MEMORY_SYSTEM_RAM: return _console->GetMemoryManager()->DebugGetWorkRam();
}
@ -747,14 +873,20 @@ extern "C" {
RETRO_API size_t retro_get_memory_size(unsigned id)
{
shared_ptr<BaseCartridge> cart = _console->GetCartridge();
if(cart->GetGameboy()) {
switch(id) {
if (cart->GetGameboy())
{
switch (id)
{
case RETRO_MEMORY_SAVE_RAM: return cart->GetGameboy()->DebugGetMemorySize(SnesMemoryType::GbCartRam);
case RETRO_MEMORY_SYSTEM_RAM: return cart->GetGameboy()->DebugGetMemorySize(SnesMemoryType::GbWorkRam);
}
} else {
switch(id) {
case RETRO_MEMORY_SAVE_RAM: return cart->DebugGetSaveRamSize(); break;
}
else
{
switch (id)
{
case RETRO_MEMORY_SAVE_RAM: return cart->DebugGetSaveRamSize();
break;
case RETRO_MEMORY_SYSTEM_RAM: return MemoryManager::WorkRamSize;
}
}

View file

@ -1344,7 +1344,8 @@ typedef const char *(RETRO_CALLCONV *retro_vfs_get_path_t)(struct retro_vfs_file
/* Open a file for reading or writing. If path points to a directory, this will
* fail. Returns the opaque file handle, or NULL for error.
* Introduced in VFS API v1 */
typedef struct retro_vfs_file_handle *(RETRO_CALLCONV *retro_vfs_open_t)(const char *path, unsigned mode, unsigned hints);
typedef struct retro_vfs_file_handle*(RETRO_CALLCONV *retro_vfs_open_t
)(const char* path, unsigned mode, unsigned hints);
/* Close the file and release its resources. Must be called if open_file returns non-NULL. Returns 0 on success, -1 on failure.
* Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used.
@ -1365,7 +1366,8 @@ typedef int64_t (RETRO_CALLCONV *retro_vfs_tell_t)(struct retro_vfs_file_handle
/* Set the current read/write position for the file. Returns the new position, -1 for error.
* Introduced in VFS API v1 */
typedef int64_t (RETRO_CALLCONV *retro_vfs_seek_t)(struct retro_vfs_file_handle *stream, int64_t offset, int seek_position);
typedef int64_t (RETRO_CALLCONV *retro_vfs_seek_t)(struct retro_vfs_file_handle* stream, int64_t offset,
int seek_position);
/* Read data from a file. Returns the number of bytes read, or -1 for error.
* Introduced in VFS API v1 */
@ -1479,6 +1481,7 @@ struct retro_hw_render_interface
};
typedef void (RETRO_CALLCONV *retro_set_led_state_t)(int led, int state);
struct retro_led_interface
{
retro_set_led_state_t set_led_state;
@ -1563,6 +1566,7 @@ struct retro_hw_render_context_negotiation_interface
#define RETRO_MEMDESC_MINSIZE_2 (1 << 24) /* All memory in this region is accessed at least 2 bytes at the time. */
#define RETRO_MEMDESC_MINSIZE_4 (2 << 24)
#define RETRO_MEMDESC_MINSIZE_8 (3 << 24)
struct retro_memory_descriptor
{
uint64_t flags;
@ -2167,6 +2171,7 @@ struct retro_audio_callback
* In those scenarios the reference frame time value will be used. */
typedef int64_t retro_usec_t;
typedef void (RETRO_CALLCONV *retro_frame_time_callback_t)(retro_usec_t usec);
struct retro_frame_time_callback
{
retro_frame_time_callback_t callback;