libretro: Clean up redundant cxx files.

This commit is contained in:
Stephen Anthony 2022-08-14 20:25:41 -02:30
parent 9077ee8642
commit 813bdc6749
11 changed files with 136 additions and 317 deletions

View File

@ -1,39 +0,0 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2022 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "EventHandlerLIBRETRO.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandlerLIBRETRO::EventHandlerLIBRETRO(OSystem& osystem)
: EventHandler(osystem)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandlerLIBRETRO::~EventHandlerLIBRETRO()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandlerLIBRETRO::enableTextEvents(bool enable)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandlerLIBRETRO::pollEvent()
{
}

View File

@ -33,19 +33,19 @@ class EventHandlerLIBRETRO : public EventHandler
/** /**
Create a new LIBRETRO event handler object Create a new LIBRETRO event handler object
*/ */
explicit EventHandlerLIBRETRO(OSystem& osystem); explicit EventHandlerLIBRETRO(OSystem& osystem) : EventHandler(osystem) { }
~EventHandlerLIBRETRO() override; ~EventHandlerLIBRETRO() override = default;
private: private:
/** /**
Enable/disable text events (distinct from single-key events). Enable/disable text events (distinct from single-key events).
*/ */
void enableTextEvents(bool enable) override; void enableTextEvents(bool enable) override { }
/** /**
Collects and dispatches any pending SDL2 events. Collects and dispatches any pending SDL2 events.
*/ */
void pollEvent() override; void pollEvent() override { }
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -1,38 +0,0 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2022 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "bspf.hxx"
#include "FBSurfaceLIBRETRO.hxx"
#include "FBBackendLIBRETRO.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBBackendLIBRETRO::queryHardware(vector<Common::Size>& fullscreenRes,
vector<Common::Size>& windowedRes,
VariantList& renderers)
{
fullscreenRes.emplace_back(1920, 1080);
windowedRes.emplace_back(1920, 1080);
VarList::push_back(renderers, "software", "Software");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
unique_ptr<FBSurface> FBBackendLIBRETRO::createSurface(
uInt32 w, uInt32 h, ScalingInterpolation, const uInt32*) const
{
return make_unique<FBSurfaceLIBRETRO>(w, h);
}

View File

@ -22,6 +22,7 @@ class OSystem;
#include "bspf.hxx" #include "bspf.hxx"
#include "FBBackend.hxx" #include "FBBackend.hxx"
#include "FBSurfaceLIBRETRO.hxx"
/** /**
This class implements a standard LIBRETRO framebuffer backend. Most of This class implements a standard LIBRETRO framebuffer backend. Most of
@ -58,7 +59,13 @@ class FBBackendLIBRETRO : public FBBackend
*/ */
void queryHardware(vector<Common::Size>& fullscreenRes, void queryHardware(vector<Common::Size>& fullscreenRes,
vector<Common::Size>& windowedRes, vector<Common::Size>& windowedRes,
VariantList& renderers) override; VariantList& renderers) override
{
fullscreenRes.emplace_back(1920, 1080);
windowedRes.emplace_back(1920, 1080);
VarList::push_back(renderers, "software", "Software");
}
/** /**
This method is called to create a surface with the given attributes. This method is called to create a surface with the given attributes.
@ -68,7 +75,10 @@ class FBBackendLIBRETRO : public FBBackend
*/ */
unique_ptr<FBSurface> unique_ptr<FBSurface>
createSurface(uInt32 w, uInt32 h, ScalingInterpolation, createSurface(uInt32 w, uInt32 h, ScalingInterpolation,
const uInt32*) const override; const uInt32*) const override
{
return make_unique<FBSurfaceLIBRETRO>(w, h);
}
/** /**
This method is called to provide information about the backend. This method is called to provide information about the backend.

View File

@ -1,31 +0,0 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2022 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "FBSurfaceLIBRETRO.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurfaceLIBRETRO::FBSurfaceLIBRETRO(uInt32 width, uInt32 height)
: myWidth{width},
myHeight{height},
myPixelData{make_unique<uInt32[]>(myWidth * myHeight)}
{
////////////////////////////////////////////////////
// These *must* be set for the parent class
myPixels = myPixelData.get();
myPitch = myWidth;
////////////////////////////////////////////////////
}

View File

@ -30,7 +30,17 @@
class FBSurfaceLIBRETRO : public FBSurface class FBSurfaceLIBRETRO : public FBSurface
{ {
public: public:
FBSurfaceLIBRETRO(uInt32 width, uInt32 height); FBSurfaceLIBRETRO(uInt32 width, uInt32 height)
: myWidth{width},
myHeight{height},
myPixelData{make_unique<uInt32[]>(myWidth * myHeight)}
{
////////////////////////////////////////////////////
// These *must* be set for the parent class
myPixels = myPixelData.get();
myPitch = myWidth;
////////////////////////////////////////////////////
}
~FBSurfaceLIBRETRO() override { } ~FBSurfaceLIBRETRO() override { }
// Most of the surface drawing primitives are implemented in FBSurface; // Most of the surface drawing primitives are implemented in FBSurface;

View File

@ -7,12 +7,7 @@ endif
SOURCES_CXX := \ SOURCES_CXX := \
$(CORE_DIR)/libretro/libretro.cxx \ $(CORE_DIR)/libretro/libretro.cxx \
$(CORE_DIR)/libretro/EventHandlerLIBRETRO.cxx \
$(CORE_DIR)/libretro/FSNodeLIBRETRO.cxx \ $(CORE_DIR)/libretro/FSNodeLIBRETRO.cxx \
$(CORE_DIR)/libretro/FBBackendLIBRETRO.cxx \
$(CORE_DIR)/libretro/FBSurfaceLIBRETRO.cxx \
$(CORE_DIR)/libretro/OSystemLIBRETRO.cxx \
$(CORE_DIR)/libretro/SoundLIBRETRO.cxx \
$(CORE_DIR)/libretro/StellaLIBRETRO.cxx \ $(CORE_DIR)/libretro/StellaLIBRETRO.cxx \
$(CORE_DIR)/common/AudioQueue.cxx \ $(CORE_DIR)/common/AudioQueue.cxx \
$(CORE_DIR)/common/AudioSettings.cxx \ $(CORE_DIR)/common/AudioSettings.cxx \

View File

@ -1,63 +0,0 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2022 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "FSNode.hxx"
#include "OSystemLIBRETRO.hxx"
#include "repository/KeyValueRepositoryNoop.hxx"
#include "repository/CompositeKeyValueRepositoryNoop.hxx"
#ifdef _WIN32
const string slash = "\\";
#else
const string slash = "/";
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystemLIBRETRO::getBaseDirectories(string& basedir, string& homedir,
bool useappdir, const string& usedir)
{
basedir = homedir = "." + slash;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystemLIBRETRO::initPersistence(FSNode& basedir)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string OSystemLIBRETRO::describePresistence()
{
return "none";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
shared_ptr<KeyValueRepository> OSystemLIBRETRO::getSettingsRepository()
{
return make_shared<KeyValueRepositoryNoop>();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
shared_ptr<CompositeKeyValueRepository> OSystemLIBRETRO::getPropertyRepository()
{
return make_shared<CompositeKeyValueRepositoryNoop>();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
shared_ptr<CompositeKeyValueRepositoryAtomic> OSystemLIBRETRO::getHighscoreRepository()
{
return make_shared<CompositeKeyValueRepositoryNoop>();
}

View File

@ -18,7 +18,17 @@
#ifndef OSYSTEM_LIBRETRO_HXX #ifndef OSYSTEM_LIBRETRO_HXX
#define OSYSTEM_LIBRETRO_HXX #define OSYSTEM_LIBRETRO_HXX
#include "FSNode.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#include "OSystemLIBRETRO.hxx"
#include "repository/KeyValueRepositoryNoop.hxx"
#include "repository/CompositeKeyValueRepositoryNoop.hxx"
#ifdef _WIN32
const string slash = "\\";
#else
const string slash = "/";
#endif
/** /**
This class defines an OSystem object for libretro. This class defines an OSystem object for libretro.
@ -47,19 +57,29 @@ class OSystemLIBRETRO : public OSystem
they are free to ignore it they are free to ignore it
*/ */
void getBaseDirectories(string& basedir, string& homedir, void getBaseDirectories(string& basedir, string& homedir,
bool useappdir, const string& usedir) override; bool useappdir, const string& usedir) override
{
basedir = homedir = "." + slash;
}
shared_ptr<KeyValueRepository> getSettingsRepository() override; shared_ptr<KeyValueRepository>
getSettingsRepository() override {
return make_shared<KeyValueRepositoryNoop>();
}
shared_ptr<CompositeKeyValueRepository> getPropertyRepository() override; shared_ptr<CompositeKeyValueRepository>
getPropertyRepository() override {
return make_shared<CompositeKeyValueRepositoryNoop>();
}
shared_ptr<CompositeKeyValueRepositoryAtomic> getHighscoreRepository() override; shared_ptr<CompositeKeyValueRepositoryAtomic>
getHighscoreRepository() override {
return make_shared<CompositeKeyValueRepositoryNoop>();
}
protected: protected:
void initPersistence(FSNode& basedir) override { }
void initPersistence(FSNode& basedir) override; string describePresistence() override { return "none"; }
string describePresistence() override;
}; };
#endif #endif

View File

@ -1,117 +0,0 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2022 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifdef SOUND_SUPPORT
#include <sstream>
#include <cassert>
#include <cmath>
#include "Logger.hxx"
#include "FrameBuffer.hxx"
#include "Settings.hxx"
#include "System.hxx"
#include "OSystem.hxx"
#include "Console.hxx"
#include "SoundLIBRETRO.hxx"
#include "AudioQueue.hxx"
#include "EmulationTiming.hxx"
#include "AudioSettings.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundLIBRETRO::SoundLIBRETRO(OSystem& osystem, AudioSettings& audioSettings)
: Sound(osystem),
myAudioSettings{audioSettings}
{
Logger::debug("SoundLIBRETRO::SoundLIBRETRO started ...");
Logger::debug("SoundLIBRETRO::SoundLIBRETRO initialized");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundLIBRETRO::~SoundLIBRETRO()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundLIBRETRO::open(shared_ptr<AudioQueue> audioQueue,
EmulationTiming* emulationTiming)
{
myEmulationTiming = emulationTiming;
Logger::debug("SoundLIBRETRO::open started ...");
audioQueue->ignoreOverflows(!myAudioSettings.enabled());
myAudioQueue = audioQueue;
myUnderrun = true;
myCurrentFragment = nullptr;
Logger::debug("SoundLIBRETRO::open finished");
myIsInitializedFlag = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundLIBRETRO::close()
{
if(!myIsInitializedFlag) return;
if (myAudioQueue) myAudioQueue->closeSink(myCurrentFragment);
myAudioQueue.reset();
myCurrentFragment = nullptr;
Logger::debug("SoundLIBRETRO::close");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundLIBRETRO::dequeue(Int16* stream, uInt32* samples)
{
uInt32 outIndex = 0;
while (myAudioQueue->size())
{
Int16* nextFragment = myAudioQueue->dequeue(myCurrentFragment);
if (!nextFragment)
{
*samples = outIndex / 2;
return;
}
myCurrentFragment = nextFragment;
for (uInt32 i = 0; i < myAudioQueue->fragmentSize(); ++i)
{
Int16 sampleL, sampleR;
if (myAudioQueue->isStereo())
{
sampleL = static_cast<Int16>(myCurrentFragment[2*i + 0]);
sampleR = static_cast<Int16>(myCurrentFragment[2*i + 1]);
}
else
sampleL = sampleR = static_cast<Int16>(myCurrentFragment[i]);
stream[outIndex++] = sampleL;
stream[outIndex++] = sampleR;
}
}
*samples = outIndex / 2;
}
#endif // SOUND_SUPPORT

View File

@ -20,13 +20,21 @@
#ifndef SOUND_LIBRETRO_HXX #ifndef SOUND_LIBRETRO_HXX
#define SOUND_LIBRETRO_HXX #define SOUND_LIBRETRO_HXX
class OSystem; #include <sstream>
class AudioQueue; #include <cassert>
class EmulationTiming; #include <cmath>
class AudioSettings;
#include "bspf.hxx" #include "bspf.hxx"
#include "Logger.hxx"
#include "FrameBuffer.hxx"
#include "Settings.hxx"
#include "System.hxx"
#include "OSystem.hxx"
#include "Console.hxx"
#include "Sound.hxx" #include "Sound.hxx"
#include "AudioQueue.hxx"
#include "EmulationTiming.hxx"
#include "AudioSettings.hxx"
/** /**
This class implements the sound API for LIBRETRO. This class implements the sound API for LIBRETRO.
@ -40,8 +48,14 @@ class SoundLIBRETRO : public Sound
Create a new sound object. The init method must be invoked before Create a new sound object. The init method must be invoked before
using the object. using the object.
*/ */
SoundLIBRETRO(OSystem& osystem, AudioSettings& audioSettings); SoundLIBRETRO(OSystem& osystem, AudioSettings& audioSettings)
~SoundLIBRETRO() override; : Sound(osystem),
myAudioSettings{audioSettings}
{
Logger::debug("SoundLIBRETRO::SoundLIBRETRO started ...");
Logger::debug("SoundLIBRETRO::SoundLIBRETRO initialized");
}
~SoundLIBRETRO() override = default;
public: public:
/** /**
@ -49,13 +63,38 @@ class SoundLIBRETRO : public Sound
calls are made to derived methods. calls are made to derived methods.
*/ */
void open(shared_ptr<AudioQueue> audioQueue, void open(shared_ptr<AudioQueue> audioQueue,
EmulationTiming* emulationTiming) override; EmulationTiming* emulationTiming) override
{
myEmulationTiming = emulationTiming;
Logger::debug("SoundLIBRETRO::open started ...");
audioQueue->ignoreOverflows(!myAudioSettings.enabled());
myAudioQueue = audioQueue;
myUnderrun = true;
myCurrentFragment = nullptr;
Logger::debug("SoundLIBRETRO::open finished");
myIsInitializedFlag = true;
}
/** /**
Should be called to close the sound device. Once called the sound Should be called to close the sound device. Once called the sound
device can be started again using the open method. device can be started again using the open method.
*/ */
void close() override; void close() override
{
if (!myIsInitializedFlag)
return;
if (myAudioQueue)
myAudioQueue->closeSink(myCurrentFragment);
myAudioQueue.reset();
myCurrentFragment = nullptr;
Logger::debug("SoundLIBRETRO::close");
}
/** /**
Empties the playback buffer. Empties the playback buffer.
@ -63,7 +102,40 @@ class SoundLIBRETRO : public Sound
@param stream Output audio buffer @param stream Output audio buffer
@param samples Number of audio samples read @param samples Number of audio samples read
*/ */
void dequeue(Int16* stream, uInt32* samples); void dequeue(Int16* stream, uInt32* samples)
{
uInt32 outIndex = 0;
while (myAudioQueue->size())
{
Int16* nextFragment = myAudioQueue->dequeue(myCurrentFragment);
if (!nextFragment)
{
*samples = outIndex / 2;
return;
}
myCurrentFragment = nextFragment;
for (uInt32 i = 0; i < myAudioQueue->fragmentSize(); ++i)
{
Int16 sampleL, sampleR;
if (myAudioQueue->isStereo())
{
sampleL = static_cast<Int16>(myCurrentFragment[2*i + 0]);
sampleR = static_cast<Int16>(myCurrentFragment[2*i + 1]);
}
else
sampleL = sampleR = static_cast<Int16>(myCurrentFragment[i]);
stream[outIndex++] = sampleL;
stream[outIndex++] = sampleR;
}
}
*samples = outIndex / 2;
}
protected: protected:
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////