Skip to content

Commit

Permalink
libretro: Run clang-tidy on all files.
Browse files Browse the repository at this point in the history
  • Loading branch information
sa666666 committed Aug 3, 2024
1 parent 67974a9 commit 352c449
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/os/libretro/FBBackendLIBRETRO.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FBBackendLIBRETRO : public FBBackend
{
public:
explicit FBBackendLIBRETRO(OSystem&) { }
~FBBackendLIBRETRO() override { }
~FBBackendLIBRETRO() override = default;

protected:
/**
Expand Down
4 changes: 2 additions & 2 deletions src/os/libretro/FBSurfaceLIBRETRO.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class FBSurfaceLIBRETRO : public FBSurface
FBSurfaceLIBRETRO(uInt32 width, uInt32 height)
: myWidth{width},
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
myPixels = myPixelData.get();
myPitch = myWidth;
////////////////////////////////////////////////////
}
~FBSurfaceLIBRETRO() override { }
~FBSurfaceLIBRETRO() override = default;

// Most of the surface drawing primitives are implemented in FBSurface;
void fillRect(uInt32 x, uInt32 y, uInt32 w,
Expand Down
8 changes: 7 additions & 1 deletion src/os/libretro/OSystemLIBRETRO.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "FSNode.hxx"
#include "OSystem.hxx"
#include "OSystemLIBRETRO.hxx"
#include "repository/KeyValueRepositoryNoop.hxx"
#include "repository/CompositeKeyValueRepositoryNoop.hxx"

Expand Down Expand Up @@ -80,6 +79,13 @@ class OSystemLIBRETRO : public OSystem
protected:
void initPersistence(FSNode& basedir) override { }
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
8 changes: 4 additions & 4 deletions src/os/libretro/SoundLIBRETRO.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ class SoundLIBRETRO : public Sound

for (uInt32 i = 0; i < myAudioQueue->fragmentSize(); ++i)
{
Int16 sampleL, sampleR;
Int16 sampleL = 0, sampleR = 0;

if (myAudioQueue->isStereo())
{
sampleL = static_cast<Int16>(myCurrentFragment[2*i + 0]);
sampleR = static_cast<Int16>(myCurrentFragment[2*i + 1]);
sampleL = myCurrentFragment[2*i + 0];
sampleR = myCurrentFragment[2*i + 1];
}
else
sampleL = sampleR = static_cast<Int16>(myCurrentFragment[i]);
sampleL = sampleR = myCurrentFragment[i];

stream[outIndex++] = sampleL;
stream[outIndex++] = sampleR;
Expand Down
18 changes: 11 additions & 7 deletions src/os/libretro/StellaLIBRETRO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool StellaLIBRETRO::create(bool logging)

myOSystem = make_unique<OSystemLIBRETRO>();

Settings::Options options;
const Settings::Options options;
myOSystem->initialize(options);

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -92,7 +92,7 @@ bool StellaLIBRETRO::create(bool logging)
settings.setValue(AudioSettings::SETTING_VOLUME, 100);
settings.setValue(AudioSettings::SETTING_STEREO, audio_mode);

FSNode rom(rom_path);
const FSNode rom(rom_path);

if(myOSystem->createConsole(rom) != EmptyString)
return false;
Expand Down Expand Up @@ -160,7 +160,7 @@ void StellaLIBRETRO::updateVideo()
{
TIA& tia = myOSystem->console().tia();

while (1)
while (true)
{
tia.updateScanline();

Expand Down Expand Up @@ -227,7 +227,7 @@ size_t StellaLIBRETRO::getStateSize() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float StellaLIBRETRO::getVideoAspectPar() const
{
float par;
float par = 0.F;

if (getVideoNTSC())
{
Expand All @@ -236,7 +236,7 @@ float StellaLIBRETRO::getVideoAspectPar() const
if (video_filter != NTSCFilter::Preset::OFF)
{
// 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
{
Expand All @@ -254,7 +254,7 @@ float StellaLIBRETRO::getVideoAspectPar() const
if (video_filter != NTSCFilter::Preset::OFF)
{
// 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
{
Expand All @@ -272,7 +272,7 @@ float StellaLIBRETRO::getVideoAspectPar() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float StellaLIBRETRO::getVideoAspect() const
{
uInt32 width = myOSystem->console().tia().width() * 2;
const uInt32 width = myOSystem->console().tia().width() * 2;

// display aspect ratio
return (width * getVideoAspectPar()) / getVideoHeight();
Expand Down Expand Up @@ -335,6 +335,7 @@ void StellaLIBRETRO::setConsoleFormat(uInt32 mode)
case 4: console_format = "NTSC50"; break;
case 5: console_format = "PAL60"; break;
case 6: console_format = "SECAM60"; break;
default: break;
}

if (system_ready)
Expand Down Expand Up @@ -371,6 +372,7 @@ void StellaLIBRETRO::setVideoPhosphor(uInt32 mode, uInt32 blend)
case 0: video_phosphor = "byrom"; break;
case 1: video_phosphor = "never"; break;
case 2: video_phosphor = "always"; break;
default: break;
}

video_phosphor_blend = blend;
Expand All @@ -385,6 +387,7 @@ void StellaLIBRETRO::setVideoPhosphor(uInt32 mode, uInt32 blend)
case 0: myOSystem->frameBuffer().tiaSurface().enablePhosphor(phosphor_default, blend); break;
case 1: myOSystem->frameBuffer().tiaSurface().enablePhosphor(false, blend); break;
case 2: myOSystem->frameBuffer().tiaSurface().enablePhosphor(true, blend); break;
default: break;
}
}
}
Expand All @@ -397,6 +400,7 @@ void StellaLIBRETRO::setAudioStereo(int mode)
case 0: audio_mode = "byrom"; break;
case 1: audio_mode = "mono"; break;
case 2: audio_mode = "stereo"; break;
default: break;
}

if (system_ready)
Expand Down
5 changes: 4 additions & 1 deletion src/os/libretro/StellaLIBRETRO.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class StellaLIBRETRO
{
public:
StellaLIBRETRO();
~StellaLIBRETRO() = default;

public:
OSystemLIBRETRO& osystem() const { return *myOSystem; }
Expand All @@ -60,7 +61,9 @@ class StellaLIBRETRO

void* getROM() const { return rom_image.get(); }
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; }
constexpr uInt32 getRAMSize() const { return 128; }
Expand Down
13 changes: 8 additions & 5 deletions src/os/libretro/libretro.cxx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// NOLINTBEGIN (misc-use-anonymous-namespace)

#ifndef _MSC_VER
#include <stdbool.h>
#include <sched.h>
#endif
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstddef>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#define snprintf _snprintf
Expand Down Expand Up @@ -74,7 +75,7 @@ static void update_input()
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; \
}
#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;
GET_BITMASK(pad)
Expand Down Expand Up @@ -761,3 +762,5 @@ void retro_cheat_reset()
void retro_cheat_set(unsigned index, bool enabled, const char *code)
{
}

// NOLINTEND

0 comments on commit 352c449

Please sign in to comment.