Libretro: Added OSD messages (fds disk insert, vs coin insert, region change, game load, etc.)

This commit is contained in:
Sour 2018-01-08 20:11:11 -05:00
parent c003ec90ea
commit 8a9028f7e3
6 changed files with 32 additions and 6 deletions

View File

@ -422,7 +422,7 @@ void Console::RunSingleFrame()
//Used by Libretro
uint32_t lastFrameNumber = PPU::GetFrameCount();
_emulationThreadId = std::this_thread::get_id();
UpdateNesModel(false);
UpdateNesModel(true);
while(PPU::GetFrameCount() == lastFrameNumber) {
_cpu->Exec();

View File

@ -1,6 +1,7 @@
#pragma once
#include "stdafx.h"
#include "SystemActionManager.h"
#include "MessageManager.h"
#include "FDS.h"
class FdsSystemActionManager : public SystemActionManager
@ -95,6 +96,7 @@ public:
_insertDiskNumber = diskNumber;
_insertDiskDelay = 1;
}
MessageManager::DisplayMessage("FDS", "FdsDiskInserted", std::to_string(diskNumber / 2 + 1), diskNumber & 0x01 ? "B" : "A");
}
}

View File

@ -27,6 +27,7 @@ std::unordered_map<string, string> MessageManager::_enResources = {
{ "CheatApplied", u8"1 cheat applied." },
{ "CheatsApplied", u8"%1 cheats applied." },
{ "CheatsDisabled", u8"All cheats disabled." },
{ "CoinInsertedSlot", u8"Coin inserted (slot %1)" },
{ "ConnectedToServer", u8"Connected to server." },
{ "ConnectedAsPlayer", u8"Connected as player %1" },
{ "ConnectedAsSpectator", u8"Connected as spectator." },
@ -37,6 +38,7 @@ std::unordered_map<string, string> MessageManager::_enResources = {
{ "CouldNotLoadFile", u8"Could not load file: %1" },
{ "EmulationMaximumSpeed", u8"Maximum speed" },
{ "EmulationSpeedPercent", u8"%1%" },
{ "FdsDiskInserted", u8"Disk %1 Side %2 inserted." },
{ "Frame", u8"Frame" },
{ "GameCrash", u8"Game has crashed (%1)" },
{ "KeyboardModeDisabled", u8"Keyboard mode disabled." },
@ -100,6 +102,7 @@ std::unordered_map<string, string> MessageManager::_frResources = {
{ "CheatApplied", u8"%1 code activé." },
{ "CheatsApplied", u8"%1 codes activés." },
{ "CheatsDisabled", u8"Tous les codes ont étés désactivés." },
{ "CoinInsertedSlot", u8"Pièce insérée (%1)" },
{ "ConnectedToServer", u8"Connecté avec succès au serveur." },
{ "ConnectedAsPlayer", u8"Connecté en tant que joueur #%1" },
{ "ConnectedAsSpectator", u8"Connecté en tant que spectateur." },
@ -110,6 +113,7 @@ std::unordered_map<string, string> MessageManager::_frResources = {
{ "CouldNotLoadFile", u8"Impossible de charger le fichier : %1" },
{ "EmulationMaximumSpeed", u8"Vitesse maximale" },
{ "EmulationSpeedPercent", u8"%1%" },
{ "FdsDiskInserted", u8"Disque %1 Côté %2 inséré." },
{ "Frame", u8"Image" },
{ "GameCrash", u8"Le jeu a planté (%1)" },
{ "KeyboardModeDisabled", u8"Mode clavier activé." },
@ -173,6 +177,7 @@ std::unordered_map<string, string> MessageManager::_jaResources = {
{ "CheatApplied", u8"チートコード%1個を有効にしました。" },
{ "CheatsApplied", u8"チートコード%1個を有効にしました。" },
{ "CheatsDisabled", u8"チートコードを無効にしました。" },
{ "CoinInsertedSlot", u8"インサートコイン (%1)" },
{ "ConnectedToServer", u8"サーバに接続しました。" },
{ "ConnectedAsPlayer", u8"プレーヤー %1として接続しました。" },
{ "ConnectedAsSpectator", u8"観客として接続しました。" },
@ -183,6 +188,7 @@ std::unordered_map<string, string> MessageManager::_jaResources = {
{ "CouldNotLoadFile", u8"ファイルをロードできませんでした: %1" },
{ "EmulationMaximumSpeed", u8"最高速度" },
{ "EmulationSpeedPercent", u8"%1%" },
{ "FdsDiskInserted", u8"ディスク%1、%2面。" },
{ "Frame", u8"フレーム" },
{ "GameCrash", u8"ゲームは停止しました (%1)" },
{ "KeyboardModeDisabled", u8"キーボードモードを無効にしました。" },
@ -246,6 +252,7 @@ std::unordered_map<string, string> MessageManager::_ruResources = {
{ "CheatApplied", u8"1 Чит применён." },
{ "CheatsApplied", u8"Читов применено %1" },
{ "CheatsDisabled", u8"All cheats disabled." },
{ "CoinInsertedSlot", u8"Coin inserted (slot %1)" },
{ "ConnectedToServer", u8"Подключение к серверу." },
{ "ConnectedAsPlayer", u8"Подключен как игрок %1" },
{ "ConnectedAsSpectator", u8"Подключен как наблюдатель." },
@ -256,6 +263,7 @@ std::unordered_map<string, string> MessageManager::_ruResources = {
{ "CouldNotLoadFile", u8"Не удалось загрузить файл: %1" },
{ "EmulationMaximumSpeed", u8"Максимальная скорость" },
{ "EmulationSpeedPercent", u8"%1%" },
{ "FdsDiskInserted", u8"Disk %1 Side %2 inserted." },
{ "Frame", u8"Frame" },
{ "GameCrash", u8"Игра была аварийно завершена (%1)" },
{ "KeyboardModeDisabled", u8"Keyboard mode disabled." },
@ -319,6 +327,7 @@ std::unordered_map<string, string> MessageManager::_esResources = {
{ "CheatApplied", u8"1 truco aplicado." },
{ "CheatsApplied", u8"%1 trucos aplicados." },
{ "CheatsDisabled", u8"Todos los trucos deshabilitados." },
{ "CoinInsertedSlot", u8"Coin inserted (slot %1)" },
{ "ConnectedToServer", u8"Conectado al servidor." },
{ "ConnectedAsPlayer", u8"Conectado como jugador %1" },
{ "ConnectedAsSpectator", u8"Conectado como espectador." },
@ -329,6 +338,7 @@ std::unordered_map<string, string> MessageManager::_esResources = {
{ "CouldNotLoadFile", u8"No se puede cargar el archivo: %1" },
{ "EmulationMaximumSpeed", u8"Velocidad Máxima" },
{ "EmulationSpeedPercent", u8"%1%" },
{ "FdsDiskInserted", u8"Disk %1 Side %2 inserted." },
{ "Frame", u8"Frame" },
{ "GameCrash", u8"El juego se ha colgado (%1)" },
{ "KeyboardModeDisabled", u8"Keyboard mode disabled." },
@ -393,6 +403,7 @@ std::unordered_map<string, string> MessageManager::_ukResources = {
{ "CheatApplied", u8"1 Чiт застосований." },
{ "CheatsApplied", u8"Чiтів застосовано %1" },
{ "CheatsDisabled", u8"All cheats disabled." },
{ "CoinInsertedSlot", u8"Coin inserted (slot %1)" },
{ "ConnectedToServer", u8"Підключення до сервера." },
{ "ConnectedAsPlayer", u8"Пiдключен як гравець %1" },
{ "ConnectedAsSpectator", u8"Підключений як спостерігач." },
@ -403,6 +414,7 @@ std::unordered_map<string, string> MessageManager::_ukResources = {
{ "CouldNotLoadFile", u8"Не вдалося завантажити файл: %1" },
{ "EmulationMaximumSpeed", u8"Максимальна швидкiсть" },
{ "EmulationSpeedPercent", u8"%1%" },
{ "FdsDiskInserted", u8"Disk %1 Side %2 inserted." },
{ "Frame", u8"Frame" },
{ "GameCrash", u8"Гра була аварійно завершена (%1)" },
{ "KeyboardModeDisabled", u8"Keyboard mode disabled." },
@ -466,6 +478,7 @@ std::unordered_map<string, string> MessageManager::_ptResources = {
{ "CheatApplied", u8"1 cheat aplicado." },
{ "CheatsApplied", u8"%1 cheats aplicados." },
{ "CheatsDisabled", u8"All cheats disabled." },
{ "CoinInsertedSlot", u8"Coin inserted (slot %1)" },
{ "ConnectedToServer", u8"Conectado ao servidor." },
{ "ConnectedAsPlayer", u8"Conectado como jogador %1" },
{ "ConnectedAsSpectator", u8"Conectado como espectador." },
@ -476,6 +489,7 @@ std::unordered_map<string, string> MessageManager::_ptResources = {
{ "CouldNotLoadFile", u8"Não foi possível carregar o arquivo: %1" },
{ "EmulationMaximumSpeed", u8"Velocidade Máxima" },
{ "EmulationSpeedPercent", u8"%1%" },
{ "FdsDiskInserted", u8"Disk %1 Side %2 inserted." },
{ "Frame", u8"Frame" },
{ "GameCrash", u8"O jogo crashou (%1)" },
{ "KeyboardModeDisabled", u8"Keyboard mode disabled." },
@ -539,6 +553,7 @@ std::unordered_map<string, string> MessageManager::_caResources = {
{ "CheatApplied", u8"1 truc activat." },
{ "CheatsApplied", u8"%1 trucs activats." },
{ "CheatsDisabled", u8"Tots els trucs han estat desactivats." },
{ "CoinInsertedSlot", u8"Coin inserted (slot %1)" },
{ "ConnectedToServer", u8"Connectat al servidor." },
{ "ConnectedAsPlayer", u8"Connectat com a %1" },
{ "ConnectedAsSpectator", u8"Connectat com a espectador." },
@ -549,6 +564,7 @@ std::unordered_map<string, string> MessageManager::_caResources = {
{ "CouldNotLoadFile", u8"Incapaç de carregar el fitxer: %1" },
{ "EmulationMaximumSpeed", u8"Velocitat màxima" },
{ "EmulationSpeedPercent", u8"%1%" },
{ "FdsDiskInserted", u8"Disk %1 Side %2 inserted." },
{ "Frame", u8"Fotograma" },
{ "GameCrash", u8"El joc ha fallat (%1)" },
{ "KeyboardModeDisabled", u8"Keyboard mode disabled." },

View File

@ -62,6 +62,7 @@ public:
void InsertCoin(uint8_t port)
{
_needInsertCoin[port] = VsSystemActionManager::InsertCoinFrameCount;
MessageManager::DisplayMessage("VS System", "CoinInsertedSlot", std::to_string(port + 1));
}
void SetServiceButtonState(bool pressed)

View File

@ -7,11 +7,13 @@ class LibretroMessageManager : public IMessageManager
{
private:
retro_log_printf_t _log = nullptr;
retro_environment_t _retroEnv = nullptr;
public:
LibretroMessageManager(retro_log_printf_t logCallback)
LibretroMessageManager(retro_log_printf_t logCallback, retro_environment_t retroEnv)
{
_log = logCallback;
_retroEnv = retroEnv;
MessageManager::RegisterMessageManager(this);
}
@ -23,8 +25,14 @@ public:
// Inherited via IMessageManager
virtual void DisplayMessage(string title, string message) override
{
if(title.empty()) {
if(_log) {
_log(RETRO_LOG_INFO, message.c_str());
}
} else {
string osdMessage = "[" + title + "] " + message;
retro_message msg = { osdMessage.c_str(), 180 };
_retroEnv(RETRO_ENVIRONMENT_SET_MESSAGE, &msg);
}
}
};

View File

@ -91,10 +91,9 @@ extern "C" {
_renderer.reset(new LibretroRenderer());
_soundManager.reset(new LibretroSoundManager());
_keyManager.reset(new LibretroKeyManager());
_messageManager.reset(new LibretroMessageManager(logCallback));
_messageManager.reset(new LibretroMessageManager(logCallback, retroEnv));
EmulationSettings::SetFlags(EmulationFlags::FdsAutoLoadDisk);
EmulationSettings::SetFlags(EmulationFlags::DisableOsd);
EmulationSettings::SetFlags(EmulationFlags::AutoConfigureInput);
EmulationSettings::SetSampleRate(48000);
EmulationSettings::SetAutoSaveOptions(0, false);