libretro: Run clang-tidy on all files.

This commit is contained in:
Stephen Anthony 2024-08-03 21:15:22 -02:30
parent 67974a92e0
commit 352c449940
7 changed files with 37 additions and 21 deletions

View File

@ -34,7 +34,7 @@ class FBBackendLIBRETRO : public FBBackend
{ {
public: public:
explicit FBBackendLIBRETRO(OSystem&) { } explicit FBBackendLIBRETRO(OSystem&) { }
~FBBackendLIBRETRO() override { } ~FBBackendLIBRETRO() override = default;
protected: protected:
/** /**

View File

@ -33,7 +33,7 @@ class FBSurfaceLIBRETRO : public FBSurface
FBSurfaceLIBRETRO(uInt32 width, uInt32 height) FBSurfaceLIBRETRO(uInt32 width, uInt32 height)
: myWidth{width}, : myWidth{width},
myHeight{height}, myHeight{height},
myPixelData{make_unique<uInt32[]>(myWidth * myHeight)} myPixelData{make_unique<uInt32[]>(static_cast<size_t>(myWidth) * myHeight)}
{ {
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// These *must* be set for the parent class // These *must* be set for the parent class
@ -41,7 +41,7 @@ class FBSurfaceLIBRETRO : public FBSurface
myPitch = myWidth; myPitch = myWidth;
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
} }
~FBSurfaceLIBRETRO() override { } ~FBSurfaceLIBRETRO() override = default;
// Most of the surface drawing primitives are implemented in FBSurface; // Most of the surface drawing primitives are implemented in FBSurface;
void fillRect(uInt32 x, uInt32 y, uInt32 w, void fillRect(uInt32 x, uInt32 y, uInt32 w,

View File

@ -20,7 +20,6 @@
#include "FSNode.hxx" #include "FSNode.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#include "OSystemLIBRETRO.hxx"
#include "repository/KeyValueRepositoryNoop.hxx" #include "repository/KeyValueRepositoryNoop.hxx"
#include "repository/CompositeKeyValueRepositoryNoop.hxx" #include "repository/CompositeKeyValueRepositoryNoop.hxx"
@ -80,6 +79,13 @@ class OSystemLIBRETRO : public OSystem
protected: protected:
void initPersistence(FSNode& basedir) override { } void initPersistence(FSNode& basedir) override { }
string describePresistence() override { return "none"; } string describePresistence() override { return "none"; }
private:
// Following constructors and assignment operators not supported
OSystemLIBRETRO(const OSystemLIBRETRO&) = delete;
OSystemLIBRETRO(OSystemLIBRETRO&&) = delete;
OSystemLIBRETRO& operator=(const OSystemLIBRETRO&) = delete;
OSystemLIBRETRO& operator=(OSystemLIBRETRO&&) = delete;
}; };
#endif #endif

View File

@ -104,15 +104,15 @@ class SoundLIBRETRO : public Sound
for (uInt32 i = 0; i < myAudioQueue->fragmentSize(); ++i) for (uInt32 i = 0; i < myAudioQueue->fragmentSize(); ++i)
{ {
Int16 sampleL, sampleR; Int16 sampleL = 0, sampleR = 0;
if (myAudioQueue->isStereo()) if (myAudioQueue->isStereo())
{ {
sampleL = static_cast<Int16>(myCurrentFragment[2*i + 0]); sampleL = myCurrentFragment[2*i + 0];
sampleR = static_cast<Int16>(myCurrentFragment[2*i + 1]); sampleR = myCurrentFragment[2*i + 1];
} }
else else
sampleL = sampleR = static_cast<Int16>(myCurrentFragment[i]); sampleL = sampleR = myCurrentFragment[i];
stream[outIndex++] = sampleL; stream[outIndex++] = sampleL;
stream[outIndex++] = sampleR; stream[outIndex++] = sampleR;

View File

@ -46,7 +46,7 @@ bool StellaLIBRETRO::create(bool logging)
myOSystem = make_unique<OSystemLIBRETRO>(); myOSystem = make_unique<OSystemLIBRETRO>();
Settings::Options options; const Settings::Options options;
myOSystem->initialize(options); myOSystem->initialize(options);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -92,7 +92,7 @@ bool StellaLIBRETRO::create(bool logging)
settings.setValue(AudioSettings::SETTING_VOLUME, 100); settings.setValue(AudioSettings::SETTING_VOLUME, 100);
settings.setValue(AudioSettings::SETTING_STEREO, audio_mode); settings.setValue(AudioSettings::SETTING_STEREO, audio_mode);
FSNode rom(rom_path); const FSNode rom(rom_path);
if(myOSystem->createConsole(rom) != EmptyString) if(myOSystem->createConsole(rom) != EmptyString)
return false; return false;
@ -160,7 +160,7 @@ void StellaLIBRETRO::updateVideo()
{ {
TIA& tia = myOSystem->console().tia(); TIA& tia = myOSystem->console().tia();
while (1) while (true)
{ {
tia.updateScanline(); tia.updateScanline();
@ -227,7 +227,7 @@ size_t StellaLIBRETRO::getStateSize() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float StellaLIBRETRO::getVideoAspectPar() const float StellaLIBRETRO::getVideoAspectPar() const
{ {
float par; float par = 0.F;
if (getVideoNTSC()) if (getVideoNTSC())
{ {
@ -236,7 +236,7 @@ float StellaLIBRETRO::getVideoAspectPar() const
if (video_filter != NTSCFilter::Preset::OFF) if (video_filter != NTSCFilter::Preset::OFF)
{ {
// non-interlace square pixel clock -- 1.0 pixel @ color burst -- double-width pixels // non-interlace square pixel clock -- 1.0 pixel @ color burst -- double-width pixels
par = (6.1363635f / 3.579545454f) / 2.0; par = (6.1363635F / 3.579545454F) / 2.0;
} }
else else
{ {
@ -254,7 +254,7 @@ float StellaLIBRETRO::getVideoAspectPar() const
if (video_filter != NTSCFilter::Preset::OFF) if (video_filter != NTSCFilter::Preset::OFF)
{ {
// non-interlace square pixel clock -- 0.8 pixel @ color burst -- double-width pixels // non-interlace square pixel clock -- 0.8 pixel @ color burst -- double-width pixels
par = (7.3750000f / (4.43361875f * 4.0f / 5.0f)) / 2.0f; par = (7.3750000F / (4.43361875F * 4.F / 5.F)) / 2.F;
} }
else else
{ {
@ -272,7 +272,7 @@ float StellaLIBRETRO::getVideoAspectPar() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float StellaLIBRETRO::getVideoAspect() const float StellaLIBRETRO::getVideoAspect() const
{ {
uInt32 width = myOSystem->console().tia().width() * 2; const uInt32 width = myOSystem->console().tia().width() * 2;
// display aspect ratio // display aspect ratio
return (width * getVideoAspectPar()) / getVideoHeight(); return (width * getVideoAspectPar()) / getVideoHeight();
@ -335,6 +335,7 @@ void StellaLIBRETRO::setConsoleFormat(uInt32 mode)
case 4: console_format = "NTSC50"; break; case 4: console_format = "NTSC50"; break;
case 5: console_format = "PAL60"; break; case 5: console_format = "PAL60"; break;
case 6: console_format = "SECAM60"; break; case 6: console_format = "SECAM60"; break;
default: break;
} }
if (system_ready) if (system_ready)
@ -371,6 +372,7 @@ void StellaLIBRETRO::setVideoPhosphor(uInt32 mode, uInt32 blend)
case 0: video_phosphor = "byrom"; break; case 0: video_phosphor = "byrom"; break;
case 1: video_phosphor = "never"; break; case 1: video_phosphor = "never"; break;
case 2: video_phosphor = "always"; break; case 2: video_phosphor = "always"; break;
default: break;
} }
video_phosphor_blend = blend; video_phosphor_blend = blend;
@ -385,6 +387,7 @@ void StellaLIBRETRO::setVideoPhosphor(uInt32 mode, uInt32 blend)
case 0: myOSystem->frameBuffer().tiaSurface().enablePhosphor(phosphor_default, blend); break; case 0: myOSystem->frameBuffer().tiaSurface().enablePhosphor(phosphor_default, blend); break;
case 1: myOSystem->frameBuffer().tiaSurface().enablePhosphor(false, blend); break; case 1: myOSystem->frameBuffer().tiaSurface().enablePhosphor(false, blend); break;
case 2: myOSystem->frameBuffer().tiaSurface().enablePhosphor(true, blend); break; case 2: myOSystem->frameBuffer().tiaSurface().enablePhosphor(true, blend); break;
default: break;
} }
} }
} }
@ -397,6 +400,7 @@ void StellaLIBRETRO::setAudioStereo(int mode)
case 0: audio_mode = "byrom"; break; case 0: audio_mode = "byrom"; break;
case 1: audio_mode = "mono"; break; case 1: audio_mode = "mono"; break;
case 2: audio_mode = "stereo"; break; case 2: audio_mode = "stereo"; break;
default: break;
} }
if (system_ready) if (system_ready)

View File

@ -41,6 +41,7 @@ class StellaLIBRETRO
{ {
public: public:
StellaLIBRETRO(); StellaLIBRETRO();
~StellaLIBRETRO() = default;
public: public:
OSystemLIBRETRO& osystem() const { return *myOSystem; } OSystemLIBRETRO& osystem() const { return *myOSystem; }
@ -60,7 +61,9 @@ class StellaLIBRETRO
void* getROM() const { return rom_image.get(); } void* getROM() const { return rom_image.get(); }
uInt32 getROMSize() const { return rom_size; } uInt32 getROMSize() const { return rom_size; }
constexpr uInt32 getROMMax() const { return uInt32(Cartridge::maxSize()); } constexpr uInt32 getROMMax() const {
return static_cast<uInt32>(Cartridge::maxSize());
}
uInt8* getRAM() { return system_ram; } uInt8* getRAM() { return system_ram; }
constexpr uInt32 getRAMSize() const { return 128; } constexpr uInt32 getRAMSize() const { return 128; }

View File

@ -1,10 +1,11 @@
// NOLINTBEGIN (misc-use-anonymous-namespace)
#ifndef _MSC_VER #ifndef _MSC_VER
#include <stdbool.h>
#include <sched.h> #include <sched.h>
#endif #endif
#include <stddef.h> #include <cstddef>
#include <stdio.h> #include <cstdio>
#include <stdlib.h> #include <cstdlib>
#ifdef _MSC_VER #ifdef _MSC_VER
#define snprintf _snprintf #define snprintf _snprintf
@ -74,7 +75,7 @@ static void update_input()
for (int i = 0; i <= RETRO_DEVICE_ID_JOYPAD_R3; i++) \ for (int i = 0; i <= RETRO_DEVICE_ID_JOYPAD_R3; i++) \
input_bitmask[(pad)] |= input_state_cb((pad), RETRO_DEVICE_JOYPAD, 0, i) ? (1 << i) : 0; \ input_bitmask[(pad)] |= input_state_cb((pad), RETRO_DEVICE_JOYPAD, 0, i) ? (1 << i) : 0; \
} }
#define MASK_EVENT(evt, pad, id) stella.setInputEvent((evt), (input_bitmask[(pad)] & (1 << id)) ? 1 : 0) #define MASK_EVENT(evt, pad, id) stella.setInputEvent((evt), (input_bitmask[(pad)] & (1 << (id))) ? 1 : 0)
int pad = 0; int pad = 0;
GET_BITMASK(pad) GET_BITMASK(pad)
@ -761,3 +762,5 @@ void retro_cheat_reset()
void retro_cheat_set(unsigned index, bool enabled, const char *code) void retro_cheat_set(unsigned index, bool enabled, const char *code)
{ {
} }
// NOLINTEND