Skip to content

Commit

Permalink
Merge pull request #1050 from grumpycoders/chores-code-format
Browse files Browse the repository at this point in the history
[Chores] Format code
  • Loading branch information
nicolasnoble authored Dec 10, 2023
2 parents 67179fa + 07974d0 commit e2039fa
Show file tree
Hide file tree
Showing 60 changed files with 859 additions and 2,066 deletions.
10 changes: 4 additions & 6 deletions src/cdrom/cdriso.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,10 @@ uint8_t *PCSX::CDRIso::getBuffer() {

void PCSX::CDRIso::printTracks() {
for (int i = 1; i <= m_numtracks; i++) {
PCSX::g_system->printf(_("Track %.2d (%s) - Start %.2d:%.2d:%.2d, Length %.2d:%.2d:%.2d\n"), i,
(m_ti[i].type == TrackType::DATA ? "DATA"
: m_ti[i].cddatype == trackinfo::CCDDA ? "CZDA"
: "CDDA"),
m_ti[i].start.m, m_ti[i].start.s, m_ti[i].start.f, m_ti[i].length.m, m_ti[i].length.s,
m_ti[i].length.f);
PCSX::g_system->printf(
_("Track %.2d (%s) - Start %.2d:%.2d:%.2d, Length %.2d:%.2d:%.2d\n"), i,
(m_ti[i].type == TrackType::DATA ? "DATA" : m_ti[i].cddatype == trackinfo::CCDDA ? "CZDA" : "CDDA"),
m_ti[i].start.m, m_ti[i].start.s, m_ti[i].start.f, m_ti[i].length.m, m_ti[i].length.s, m_ti[i].length.f);
}
}

Expand Down
14 changes: 8 additions & 6 deletions src/core/gpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1097,9 +1097,10 @@ void PCSX::GPU::Poly<shading, shape, textured, blend, modulation>::drawLogNode(u
ImGui::SameLine();
std::string label = fmt::format(f_("Go to texture##{}"), n);
if (ImGui::Button(label.c_str())) {
const auto mode = tpage.texDepth == TexDepth::Tex16Bits ? Events::GUI::VRAMFocus::VRAM_16BITS
: tpage.texDepth == TexDepth::Tex8Bits ? Events::GUI::VRAMFocus::VRAM_8BITS
: Events::GUI::VRAMFocus::VRAM_4BITS;
const auto mode = tpage.texDepth == TexDepth::Tex16Bits
? Events::GUI::VRAMFocus::VRAM_16BITS
: tpage.texDepth == TexDepth::Tex8Bits ? Events::GUI::VRAMFocus::VRAM_8BITS
: Events::GUI::VRAMFocus::VRAM_4BITS;
g_system->m_eventBus->signal(Events::GUI::SelectClut{clutX(), clutY()});
g_system->m_eventBus->signal(
Events::GUI::VRAMFocus{int(minU + tx), int(minV + ty), int(maxU + tx), int(maxV + ty), mode});
Expand Down Expand Up @@ -1193,9 +1194,10 @@ void PCSX::GPU::Rect<size, textured, blend, modulation>::drawLogNode(unsigned n)
ImGui::SameLine();
std::string label = fmt::format(f_("Go to texture##{}"), n);
if (ImGui::Button(label.c_str())) {
const auto mode = tpage.texDepth == TexDepth::Tex16Bits ? Events::GUI::VRAMFocus::VRAM_16BITS
: tpage.texDepth == TexDepth::Tex8Bits ? Events::GUI::VRAMFocus::VRAM_8BITS
: Events::GUI::VRAMFocus::VRAM_4BITS;
const auto mode = tpage.texDepth == TexDepth::Tex16Bits
? Events::GUI::VRAMFocus::VRAM_16BITS
: tpage.texDepth == TexDepth::Tex8Bits ? Events::GUI::VRAMFocus::VRAM_8BITS
: Events::GUI::VRAMFocus::VRAM_4BITS;
g_system->m_eventBus->signal(Events::GUI::SelectClut{clutX(), clutY()});
g_system->m_eventBus->signal(Events::GUI::VRAMFocus{int((u >> shift) + tx), int(v + ty),
int(((u + w) >> shift) + tx), int(v + h + ty), mode});
Expand Down
21 changes: 8 additions & 13 deletions src/core/isoffi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,17 @@ end

local function createIsoBuilderWrapper(wrapper)
local iso = {
_wrapper = ffi.gc(wrapper, function(self) C.isoBuilderClose(self) C.deleteIsoBuilder(self) end),
_wrapper = ffi.gc(wrapper, function(self)
C.isoBuilderClose(self)
C.deleteIsoBuilder(self)
end),
writeLicense = function(self, file)
if not file then file = Support.File.failedFile() end
C.isoBuilderWriteLicense(self._wrapper, file._wrapper)
end,
writeSector = function(self, sectorData, mode)
if not mode then mode = 'M2_FORM1' end
if Support.isLuaBuffer(sectorData) then
sectorData = sectorData.data
end
if Support.isLuaBuffer(sectorData) then sectorData = sectorData.data end
C.isoBuilderWriteSector(self._wrapper, sectorData, mode)
end,
close = function(self) C.isoBuilderClose(self._wrapper) end,
Expand All @@ -116,9 +117,7 @@ PCSX.isoTools = {
local mul = 1
while bcd ~= 0 do
local digit = bcd % 16
if digit >= 10 then
error('Invalid BCD digit: ' .. digit)
end
if digit >= 10 then error('Invalid BCD digit: ' .. digit) end
dec = dec + mul * digit
mul = mul * 10
bcd = math.floor(bcd / 16)
Expand All @@ -140,12 +139,8 @@ PCSX.isoTools = {
m = PCSX.isoTools.fromBCD(m)
s = PCSX.isoTools.fromBCD(s)
f = PCSX.isoTools.fromBCD(f)
if s >= 60 then
error('Invalid MSF seconds: ' .. s)
end
if f >= 75 then
error('Invalid MSF frames: ' .. f)
end
if s >= 60 then error('Invalid MSF seconds: ' .. s) end
if f >= 75 then error('Invalid MSF frames: ' .. f) end
return (m * 60 + s) * 75 + f - 150
end,
toMSF = function(lba)
Expand Down
2 changes: 1 addition & 1 deletion src/core/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum class LogClass : unsigned {
template <LogClass logClass, bool enabled>
struct Logger {
template <typename... Args>
static void Log(const char *format, const Args &...args) {
static void Log(const char *format, const Args &... args) {
if (!enabled) return;
std::string s = fmt::sprintf(format, args...);
g_system->log(logClass, std::move(s));
Expand Down
30 changes: 20 additions & 10 deletions src/core/pad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,8 @@ void PadsImpl::setLua(PCSX::Lua L) {
L.getfieldtable(1);

L.declareFunc(
"getButton", [this, pad](PCSX::Lua L) -> int {
"getButton",
[this, pad](PCSX::Lua L) -> int {
int n = L.gettop();
if (n == 0) {
return L.error("Not enough arguments to getButton");
Expand All @@ -1316,9 +1317,11 @@ void PadsImpl::setLua(PCSX::Lua L) {
unsigned button = L.checknumber(1);
L.push(((overrides & buttons) & (1 << button)) == 0);
return 1;
}, -1);
},
-1);
L.declareFunc(
"setOverride", [this, pad](PCSX::Lua L) -> int {
"setOverride",
[this, pad](PCSX::Lua L) -> int {
int n = L.gettop();
if (n == 0) {
return L.error("Not enough arguments to setOverride");
Expand All @@ -1331,9 +1334,11 @@ void PadsImpl::setLua(PCSX::Lua L) {
button = 1 << button;
overrides &= ~button;
return 0;
}, -1);
},
-1);
L.declareFunc(
"clearOverride", [this, pad](PCSX::Lua L) -> int {
"clearOverride",
[this, pad](PCSX::Lua L) -> int {
int n = L.gettop();
if (n == 0) {
return L.error("Not enough arguments to clearOverride");
Expand All @@ -1346,22 +1351,27 @@ void PadsImpl::setLua(PCSX::Lua L) {
button = 1 << button;
overrides |= button;
return 0;
}, -1);
},
-1);
L.declareFunc(
"setAnalogMode", [this, pad](PCSX::Lua L) -> int {
"setAnalogMode",
[this, pad](PCSX::Lua L) -> int {
int n = L.gettop();
if (n == 0) {
m_pads[pad].m_analogMode = false;
} else {
m_pads[pad].m_analogMode = L.toboolean();
}
return 0;
}, -1);
},
-1);
L.declareFunc(
"map", [this, pad](PCSX::Lua L) -> int {
"map",
[this, pad](PCSX::Lua L) -> int {
m_pads[pad].map();
return 0;
}, -1);
},
-1);

L.pop();
L.pop();
Expand Down
7 changes: 6 additions & 1 deletion src/core/pcsxffi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ PCSX = {
GPU = {
takeScreenShot = function()
local ss = C.takeScreenShot()
return { data = Support.File._createSliceWrapper(ss.data), width = ss.width, height = ss.height, bpp = ss.bpp }
return {
data = Support.File._createSliceWrapper(ss.data),
width = ss.width,
height = ss.height,
bpp = ss.bpp,
}
end,
},
createSaveState = function()
Expand Down
4 changes: 1 addition & 3 deletions src/core/pio-cart.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ namespace PCSX {

class PIOCart {
public:
PIOCart() : m_pal(this) {
memset(m_detachedMemory, 0xff, sizeof(m_detachedMemory));
}
PIOCart() : m_pal(this) { memset(m_detachedMemory, 0xff, sizeof(m_detachedMemory)); }

void setLuts();

Expand Down
16 changes: 8 additions & 8 deletions src/core/psxemulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ class Emulator {
typedef SettingPath<TYPESTRING("EXP1BrowsePath")> SettingEXP1BrowsePath;
typedef Setting<bool, TYPESTRING("PIOConnected")> SettingPIOConnected;

Settings<SettingMcd1, SettingMcd2, SettingBios, SettingPpfDir, SettingPsxExe,
SettingXa, SettingSpuIrq, SettingBnWMdec, SettingScaler, SettingAutoVideo, SettingVideo, SettingFastBoot,
SettingDebugSettings, SettingRCntFix, SettingIsoPath, SettingLocale, SettingMcd1Inserted,
SettingMcd2Inserted, SettingDynarec, Setting8MB,SettingGUITheme, SettingDither, SettingCachedDithering,
SettingGLErrorReporting, SettingGLErrorReportingSeverity, SettingFullCaching, SettingHardwareRenderer,
SettingShownAutoUpdateConfig, SettingAutoUpdate, SettingMSAA, SettingLinearFiltering, SettingKioskMode,
SettingMcd1Pocketstation, SettingMcd2Pocketstation, SettingBiosBrowsePath, SettingEXP1Filepath,
SettingEXP1BrowsePath, SettingPIOConnected>
Settings<SettingMcd1, SettingMcd2, SettingBios, SettingPpfDir, SettingPsxExe, SettingXa, SettingSpuIrq,
SettingBnWMdec, SettingScaler, SettingAutoVideo, SettingVideo, SettingFastBoot, SettingDebugSettings,
SettingRCntFix, SettingIsoPath, SettingLocale, SettingMcd1Inserted, SettingMcd2Inserted, SettingDynarec,
Setting8MB, SettingGUITheme, SettingDither, SettingCachedDithering, SettingGLErrorReporting,
SettingGLErrorReportingSeverity, SettingFullCaching, SettingHardwareRenderer, SettingShownAutoUpdateConfig,
SettingAutoUpdate, SettingMSAA, SettingLinearFiltering, SettingKioskMode, SettingMcd1Pocketstation,
SettingMcd2Pocketstation, SettingBiosBrowsePath, SettingEXP1Filepath, SettingEXP1BrowsePath,
SettingPIOConnected>
settings;
class PcsxConfig {
public:
Expand Down
3 changes: 2 additions & 1 deletion src/core/psxmem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ void PCSX::Memory::write32(uint32_t address, uint32_t value) {
address);
} else {
g_system->log(LogClass::CPU, _("32-bit write to unknown address: %8.8lx\n"), address);
if (g_emulator->settings.get<Emulator::SettingDebugSettings>().get<Emulator::DebugSettings::Debug>()) {
if (g_emulator->settings.get<Emulator::SettingDebugSettings>()
.get<Emulator::DebugSettings::Debug>()) {
g_system->pause();
}
}
Expand Down
1 change: 0 additions & 1 deletion src/core/psxmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ class Memory {

// hopefully this should become private eventually, with only certain classes having direct access.
public:

uint8_t *m_wram = nullptr; // Kernel & User Memory (8 Meg)
uint8_t *m_exp1 = nullptr; // Expansion Region 1 (ROM/RAM) / Parallel Port (512K)
uint8_t *m_bios = nullptr; // BIOS ROM (512K)
Expand Down
6 changes: 3 additions & 3 deletions src/core/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,21 @@ class System {

// Legacy printf stuff; needs to be replaced with loggers
template <typename... Args>
void printf(const char *format, const Args &...args) {
void printf(const char *format, const Args &... args) {
std::string s = fmt::sprintf(format, args...);
printf(std::move(s));
}
virtual void printf(std::string &&) = 0;
// Add a log line
template <typename... Args>
void log(LogClass logClass, const char *format, const Args &...args) {
void log(LogClass logClass, const char *format, const Args &... args) {
std::string s = fmt::sprintf(format, args...);
log(logClass, std::move(s));
}
virtual void log(LogClass, std::string &&) = 0;
// Display a popup message to the user
template <typename... Args>
void message(const char *format, const Args &...args) {
void message(const char *format, const Args &... args) {
std::string s = fmt::sprintf(format, args...);
message(std::move(s));
}
Expand Down
1 change: 0 additions & 1 deletion src/gui/extra.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
-- along with this program; if not, write to the
-- Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

PCSX.Helpers = PCSX.Helpers or {}
PCSX.Helpers.UI = {
imageCoordinates = function(x, y, w, h, imageW, imageH)
Expand Down
15 changes: 8 additions & 7 deletions src/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ class GUI final : public UI {
IdleSwapInterval, ShowLuaConsole, ShowLuaInspector, ShowLuaEditor, ShowMainVRAMViewer, ShowCLUTVRAMViewer,
ShowVRAMViewer1, ShowVRAMViewer2, ShowVRAMViewer3, ShowVRAMViewer4, ShowMemoryObserver, ShowTypedDebugger,
ShowMemcardManager, ShowRegisters, ShowAssembly, ShowDisassembly, ShowBreakpoints, ShowNamedSaveStates,
ShowEvents, ShowHandlers, ShowKernelLog, ShowCallstacks, ShowSIO1, ShowIsoBrowser, ShowGPULogger, MainFontSize,
MonoFontSize, GUITheme, AllowMouseCaptureToggle, EnableRawMouseMotion, WidescreenRatio, ShowPIOCartConfig,
ShowMemoryEditor1, ShowMemoryEditor2, ShowMemoryEditor3, ShowMemoryEditor4, ShowMemoryEditor5,
ShowMemoryEditor6, ShowMemoryEditor7, ShowMemoryEditor8, ShowParallelPortEditor, ShowScratchpadEditor,
ShowHWRegsEditor, ShowBiosEditor, ShowVRAMEditor, MemoryEditor1Addr, MemoryEditor2Addr, MemoryEditor3Addr,
MemoryEditor4Addr, MemoryEditor5Addr, MemoryEditor6Addr, MemoryEditor7Addr, MemoryEditor8Addr,
ParallelPortEditorAddr, ScratchpadEditorAddr, HWRegsEditorAddr, BiosEditorAddr, VRAMEditorAddr>
ShowEvents, ShowHandlers, ShowKernelLog, ShowCallstacks, ShowSIO1, ShowIsoBrowser, ShowGPULogger,
MainFontSize, MonoFontSize, GUITheme, AllowMouseCaptureToggle, EnableRawMouseMotion, WidescreenRatio,
ShowPIOCartConfig, ShowMemoryEditor1, ShowMemoryEditor2, ShowMemoryEditor3, ShowMemoryEditor4,
ShowMemoryEditor5, ShowMemoryEditor6, ShowMemoryEditor7, ShowMemoryEditor8, ShowParallelPortEditor,
ShowScratchpadEditor, ShowHWRegsEditor, ShowBiosEditor, ShowVRAMEditor, MemoryEditor1Addr,
MemoryEditor2Addr, MemoryEditor3Addr, MemoryEditor4Addr, MemoryEditor5Addr, MemoryEditor6Addr,
MemoryEditor7Addr, MemoryEditor8Addr, ParallelPortEditorAddr, ScratchpadEditorAddr, HWRegsEditorAddr,
BiosEditorAddr, VRAMEditorAddr>
settings;

// imgui can't handle more than one "instance", so...
Expand Down
1 change: 0 additions & 1 deletion src/gui/imguiextraffi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
-- along with this program; if not, write to the
-- Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

ffi.cdef [[
typedef struct { float x, y; } ImVec2;

Expand Down
21 changes: 5 additions & 16 deletions src/gui/imguisafe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,20 @@
-- along with this program; if not, write to the
-- Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

if not imgui.safe then
imgui.safe = {}
end
if not imgui.safe then imgui.safe = {} end

function imgui.safe.builder(proxy, finalIfShown, final)
local function builder(...)
local args = { ... }
local lambda = args[#args]
if type(lambda) ~= 'function' then
error('Last argument must be a function')
end
if type(lambda) ~= 'function' then error('Last argument must be a function') end
args[#args] = nil
local rets = { proxy(...) }
local shown = rets[1]
local status, err = pcall(function() lambda(table.unpack(args)) end)
if shown and finalIfShown then
finalIfShown()
end
if final then
final()
end
if not status then
error(err)
end
if shown and finalIfShown then finalIfShown() end
if final then final() end
if not status then error(err) end
return table.unpack(rets)
end
return builder
Expand Down
16 changes: 11 additions & 5 deletions src/gui/luanvg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,30 @@ void guiDrawBezierArrow(PCSX::GUI* gui, float width, ImVec2 p1, ImVec2 c1, ImVec

void nvgRGBWrapper(unsigned char r, unsigned char g, unsigned char b, NVGcolor* ret) { *ret = nvgRGB(r, g, b); }
void nvgRGBfWrapper(float r, float g, float b, NVGcolor* ret) { *ret = nvgRGBf(r, g, b); }
void nvgRGBAWrapper(unsigned char r, unsigned char g, unsigned char b, unsigned char a, NVGcolor* ret) { *ret = nvgRGBA(r, g, b, a); }
void nvgRGBAWrapper(unsigned char r, unsigned char g, unsigned char b, unsigned char a, NVGcolor* ret) {
*ret = nvgRGBA(r, g, b, a);
}
void nvgRGBAfWrapper(float r, float g, float b, float a, NVGcolor* ret) { *ret = nvgRGBAf(r, g, b, a); }
void nvgLerpRGBAWrapper(NVGcolor c0, NVGcolor c1, float u, NVGcolor* ret) { *ret = nvgLerpRGBA(c0, c1, u); }
void nvgTransRGBAWrapper(NVGcolor c0, unsigned char a, NVGcolor* ret) { *ret = nvgTransRGBA(c0, a); }
void nvgTransRGBAfWrapper(NVGcolor c0, float a, NVGcolor* ret) { *ret = nvgTransRGBAf(c0, a); }
void nvgHSLWrapper(float h, float s, float l, NVGcolor* ret) { *ret = nvgHSL(h, s, l); }
void nvgHSLAWrapper(float h, float s, float l, unsigned char a, NVGcolor* ret) { *ret = nvgHSLA(h, s, l, a); }

void nvgLinearGradientWrapper(NVGcontext* ctx, float sx, float sy, float ex, float ey, NVGcolor icol, NVGcolor ocol, NVGpaint* ret) {
void nvgLinearGradientWrapper(NVGcontext* ctx, float sx, float sy, float ex, float ey, NVGcolor icol, NVGcolor ocol,
NVGpaint* ret) {
*ret = nvgLinearGradient(ctx, sx, sy, ex, ey, icol, ocol);
}
void nvgBoxGradientWrapper(NVGcontext* ctx, float x, float y, float w, float h, float r, float f, NVGcolor icol, NVGcolor ocol, NVGpaint* ret) {
void nvgBoxGradientWrapper(NVGcontext* ctx, float x, float y, float w, float h, float r, float f, NVGcolor icol,
NVGcolor ocol, NVGpaint* ret) {
*ret = nvgBoxGradient(ctx, x, y, w, h, r, f, icol, ocol);
}
void nvgRadialGradientWrapper(NVGcontext* ctx, float cx, float cy, float inr, float outr, NVGcolor icol, NVGcolor ocol, NVGpaint* ret) {
void nvgRadialGradientWrapper(NVGcontext* ctx, float cx, float cy, float inr, float outr, NVGcolor icol, NVGcolor ocol,
NVGpaint* ret) {
*ret = nvgRadialGradient(ctx, cx, cy, inr, outr, icol, ocol);
}
void nvgImagePatternWrapper(NVGcontext* ctx, float ox, float oy, float ex, float ey, float angle, int image, float alpha, NVGpaint* ret) {
void nvgImagePatternWrapper(NVGcontext* ctx, float ox, float oy, float ex, float ey, float angle, int image,
float alpha, NVGpaint* ret) {
*ret = nvgImagePattern(ctx, ox, oy, ex, ey, angle, image, alpha);
}

Expand Down
1 change: 0 additions & 1 deletion src/gui/nvgffi-cdefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
-- along with this program; if not, write to the
-- Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

ffi.cdef [[
typedef struct NVGcontext NVGcontext;

Expand Down
Loading

0 comments on commit e2039fa

Please sign in to comment.