Commit Graph

12927 Commits

Author SHA1 Message Date
David Korth
03df42456c Multi-line constexpr functions are only supported as of MSVC 2022.
Some checks are pending
Codecov / run (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
New macros:
- CONSTEXPR_IF_MSVC2022: constexpr for MSVC 2022 and later (also gcc).
- CONSTEXPR_NO_MSVC: no constexpr on any MSVC (but yes on gcc).

Use CONSTEXPR_IF_MSVC2022 on multi-line constexpr functions.

Use CONSTEXPR_NO_MSVC on functions that can be constexpr on gcc but
not any version of MSVC.
2025-05-11 00:58:11 -04:00
David Korth
d241d33537 NEWS.md: Mention more rpcli colorization and libgsvt refactoring. 2025-05-11 00:44:33 -04:00
David Korth
e495796ee8 [rpcli] verifykeys.cpp: Missed a gsvt_fputs() conversion.
Code size difference: (64-bit Gentoo Linux, gcc-15.1.0, release build, no LTO)

   text    data     bss     dec     hex filename
  45968    2176     416   48560    bdb0 rpcli [before]
  45904    2176     416   48496    bd70 rpcli [after]
    -64       0       0     -64     -40 Difference
2025-05-11 00:41:31 -04:00
David Korth
e81f24cc39 [libgsvt] Added a gsvt_fflush() wrapper function.
Also Gsvt::Console::fflush().

[rpcli] rpcli.cpp, verifykeys.cpp: Use Gsvt::Console::fflush().

verifykeys.cpp: Only call fflush() at the end of the function.

Code size difference: (64-bit Gentoo Linux, gcc-15.1.0, release build, no LTO)

   text    data     bss     dec     hex filename
  45929    2168     432   48529    bd91 rpcli [before]
  45968    2176     416   48560    bdb0 rpcli [after]
    -39      +8     -16     -31     -1f Difference
2025-05-11 00:37:08 -04:00
David Korth
381980d13e [libgsvt] gsvtpp: New C++ wrapper class.
Gsvt::StdOut and Gsvt::StdErr are predefined as wrappers around
gsvt_stdout and gsvt_stderr.

Accessing either of the wrapper classes automatically calls gsvt_init().

gsvt_posix.c, gsvt_win32.c: Rework gsvt_init() to use pthread_once() so
multiple initializations won't cause problems.

[rpcli] rpcli.cpp, verifykeys.cpp: Use gsvtpp.

This does increase the code size a tiny bit...

Code size difference: (64-bit Gentoo Linux, gcc-15.1.0, release build, no LTO)

   text    data     bss     dec     hex filename
  45810    2152     416   48378    bcfa rpcli [before]
  45929    2168     432   48529    bd91 rpcli [after]
   +119     +16     +16    +151     +97 Difference
2025-05-11 00:30:53 -04:00
David Korth
23f71c4f9c [rpcli] rpcli.cpp: Use the C++ string version of gsvt_fputs() on Windows.
This function calls gsvt_write() internally.
2025-05-11 00:15:51 -04:00
David Korth
78da45fb5d [rpcli] rpcli.cpp: Colorize more warnings. 2025-05-10 23:44:02 -04:00
David Korth
f2c3b6c5ba [rpcli] rpcli.cpp: Improve language code handling.
- Convert the language code from uppercase to lowercase.

- After the conversion, make sure that the language code is all
  lowercase characters.

- Colorize the warning message in yellow.

ctypex.h:

- Use `int` instead of `char` in the non-localized functions. This
  ensures Windows TCHAR works properly without getting truncated.

- New functions toupper_ascii() and tolower_ascii().
2025-05-10 23:27:36 -04:00
David Korth
d5ede2ee5b [rpcli] Remove vt.cpp.
libgsvt now has all of its functionality.
2025-05-10 23:07:28 -04:00
David Korth
23c473e5e3 [rpcli] verifykeys.cpp: Update to use libgsvt instead of rpcli's vt.hpp. 2025-05-10 23:05:47 -04:00
David Korth
1f856117ec Move Win32 console output code page handling from rpcli.cpp to libgsvt/gsvt_win32.c. 2025-05-10 23:05:47 -04:00
David Korth
3efdc825d9 [libgsvt] Optimize gsvt_text_color_set8().
- POSIX: Use fprintf().
- Win32: Use WriteConsoleA() if it's a real console.
2025-05-10 23:05:47 -04:00
David Korth
611fea3782 [libgsvt] gsvt_win32.c: Windows implementation.
Mostly copied from rpcli's vt.cpp, but with a few changes. In particular:

- gsvt_fwrite() and gsvt_fputs() are wrappers around the ANSI emulation
  code, *if* ANSI isn't supported and it's a real console.

- The ANSI emulation code no longer resets attributes after data is
  written, since we might make multiple calls with color changes.

[rpcli] rpcli.cpp: Simplify the Windows-specific code.

Instead of checking if the console is a console, just use gsvt_fwrite().
gsvt_fwrite() will handle this.

FIXME: gsvt_cout wrapper so we can get rid of this.
2025-05-10 23:05:47 -04:00
David Korth
44608520b8 Initial refactoring of rpcli's VT code into a separate library.
Currently for Linux only. The Linux implementation is mostly just
wrapper functions around stdio.

gsvt_fputs() does not have a `newline` parameter, so anything that
used ConsolePrint()'s `newline` parameter now has to explicitly
call gsvt_newline().
2025-05-10 23:05:47 -04:00
David Korth
0328879a01 [rpcli] verifykeys.cpp: Remove some extra newlines.
Forgot to remove these when colorizing warning messages in
commit 365a7d5302.
([rpcli] verifykeys.cpp: Colorize output.)

Affects: v2.5.1
2025-05-10 23:05:47 -04:00
David Korth
53b74e0467 [debian] rules: Explicitly specify the Tracker API version, again.
Otherwise, we have to install the specific Tracker library, which is
versioned, so we end up with more problems.

(cherry picked from commit 1356d23d4c)
2025-05-10 21:04:30 -04:00
David Korth
c632a35c62 Version bump for development. (v2.5.1+) 2025-05-10 21:04:16 -04:00
David Korth
1f246e4ff6 rom-properties 2.5.1 2025-05-10 16:41:45 -04:00
David Korth
f5334daa78 [kde] Ext2AttrView: Use QString::arg() instead of fmt::format().
fmt::format() worked on my main system, but on Xubuntu 16.04, it didn't
work because the fmt headers aren't included:

src/kde/xattr/Ext2AttrView.cpp: In member function ‘void Ext2AttrViewPrivate::retranslateUi_nonDesigner()’:
src/kde/xattr/Ext2AttrView.cpp:94:13: error: ‘fmt’ has not been declared
   s_label = fmt::format(FRUN(s_lsattr_fmt), p->lsattr_chr,
             ^
src/kde/xattr/Ext2AttrView.cpp:94:42: error: ‘FRUN’ was not declared in this scope
   s_label = fmt::format(FRUN(s_lsattr_fmt), p->lsattr_chr,
                                          ^

We're not linking to fmt in the XAttrView plugin, so use QString::arg()
instead. (I'm guessing CMake auto-magically linked to fmt because
libromdata links to it...)

NOTE: The debug build still links to libfmt-11.so (and a bunch of other
libraries that aren't actually needed). The release build no longer links
to libfmt-11.so. I'm guessing CMake is skipping .so trimming in the debug
builds in order to save time.
2025-05-10 16:19:20 -04:00
David Korth
9d50275042 [libromdata] GameCubeSavePrivate::PDP_SWAP(): Initialize the union to 0.
This doesn't affect the compiled output, but it's needed by gcc-5.4
in order to be marked as constexpr.

The uninitialized union *is* allowed as of C++20, supported in
gcc-10.1 and later.

Also, put 'd' first so the whole DWORD is initialized instead of just
one 16-bit WORD.
2025-05-10 15:50:35 -04:00
David Korth
8c00596598 [librptexture] ImageDecoder_BC7.cpp, get_mode(): Remove constexpr.
assert() isn't constexpr-safe on Ubuntu 16.04. (glibc-2.23)
2025-05-10 15:16:18 -04:00
David Korth
7efa014ba8 [librpbyteswap] byteswap_rp.h, __swabf(): Initialize the union to 0.
This doesn't affect the compiled output, but it's needed by gcc-5.4
in order to be marked as constexpr.

The uninitialized union *is* allowed as of C++20, supported in
gcc-10.1 and later.
2025-05-10 15:09:57 -04:00
David Korth
3d0fd3627b [librptexture] PixelConversion.hpp: Remove constexpr for RGB9_E5_to_ARGB32().
MSVC 2022 doesn't like it, and apparently gcc-13.2.1 didn't like it.
(gcc-15.1.0 is fine with it, though...)
2025-05-10 14:54:13 -04:00
David Korth
9e2aff3d1a Undo some constexpr for MSVC.
Some checks are pending
Codecov / run (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
MSVC's byteswapping intrinsics are not constexpr.
2025-05-10 14:45:49 -04:00
David Korth
05e95ec9a8 [libromdata] Xbox360_XEX_Private::getOptHdrData(): Limit the maximum header size to 16 MB.
aflplusplus, and the debug version of rpcli, was hanging on some fuzzed
XEXes with ~4 GB headers because the debug version of std::vector<> was
initializing each byte, one at a time.

Headers shouldn't be that big, but we'll go with a maximum of 16 MB
just in case.

Found using aflplusplus-4.32c.
2025-05-10 14:16:25 -04:00
David Korth
4a85bc7be4 Added constexpr to a bunch of static inline functions.
[libromdata]
- SNES, isValidGameIDChar(): Use the is*_ascii() functions.
- DMG: Remove `inline` from some functions.
- GcnFst, WiiUFst: Completely inline the is_dir() functions.

[librpbase]
- cdrom_structs.h: Add CONSTEXPR; make CdromSectorInfo extern "C".
- RpPngWriter: Remove `inline` from u8strIsPngLatin1().

[librpbyteswap]
- bitstuff.h: CONSTEXPR and ATTR_CONST stuff.
- byteswap_rp.h: Likewise.

[librptexture]
- XboxXPR: Fully inline and constexpr fill_pattern() and
  get_swizzled_offset().

The inlining and constexpr for XboxXPR does reduce the code size
slightly:

Code size difference: (64-bit Gentoo Linux, gcc-15.1.0, release build, no LTO)

   text    data     bss     dec     hex filename
   8336    1208       0    9544    2548 XboxXPR.cpp.o [before]
   8240    1208       0    9448    24e8 XboxXPR.cpp.o [after]
    -96       0       0     -96     -60 Difference
2025-05-10 13:26:36 -04:00
David Korth
ae3dd69c78 [librptext] conversion_iconv.cpp: codePageToEncName(): Return an std::string.
This cleans up the code a bit, but does increase the .o size due to the
use of std::string.

Code size difference: (64-bit Gentoo Linux, gcc-15.1.0, release build, no LTO)

   text    data     bss     dec     hex filename
   6898       8       0    6906    1afa conversion_iconv.cpp.o [before]
   9780       8       0    9788    263c conversion_iconv.cpp.o [after]
  +2882       0       0   +2882    +b42 Difference
2025-05-10 13:18:05 -04:00
David Korth
b32ddb101e [librptexture] qoi.h: Update to latest git master release.
Upstream commit message:

Merge pull request #319 from DeeJayLSP/modulo

Make encoding 1.4% faster by replacing modulo with mask
2025-05-10 12:48:06 -04:00
David Korth
d58918f101 [rpcli] rpcli.cpp: Fix two errors introduced since switching over to vt.cpp.
- DoFile(): JSON errors should be printed to stdout, not stderr.

- _tmain(): Remove an extra newline after the `default:` case's
  "skipping unknown switch" message.
2025-05-10 12:46:07 -04:00
David Korth
25c5aa02cc [minizip] Update: v4.0.9 -> v4.0.10
Some checks failed
Codecov / run (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CMakeLists.txt: Add a missing "LINKER_LANGUAGE C". Not entirely sure
when this was added, or why I missed it...
2025-05-06 18:49:33 -04:00
David Korth
29aa2dacc9 [librpbase] TextOut_text.cpp, formatDateTime(): Use localtime_r() instead of fmt::localtime().
Some checks failed
Codecov / run (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
Interestingly, this didn't print any warnings or errors on gcc, but on
MSVC, this warning was produced:

src\librpbase\TextOut_text.cpp(359,20): error C2220: the following warning is treated as an error
src\librpbase\TextOut_text.cpp(359,20): warning C4996: 'fmt::v11::localtime': was declared deprecated
2025-05-04 20:33:27 -04:00
David Korth
10785d08fb Revert "time_r.h: Remove gmtime_r() and localtime_r() wrappers."
fmt-11.2.0 deprecated fmt::localtime(), so we'll need to bring back
our localtime_r() wrapper.

This reverts commit 137a7c0f5f.
2025-05-04 20:07:50 -04:00
David Korth
c66cd83539 [fmt] Update: v11.1.4 -> v11.2.0 2025-05-04 20:07:29 -04:00
David Korth
425f5a77e4 [libromdata] Nintendo3DSPrivate: Reduce headers_loaded from uint32_t to uint8_t.
Only 5 bits are currently used, and this reduces padding due to 64-bit
alignment in the mxh union.

Total struct size before: 9,176
Total struct size after:  9,168
Difference:                  -8
2025-05-04 12:51:20 -04:00
David Korth
050380db45 ctypex.h: Add is*_ascii() functions.
Some checks are pending
Codecov / run (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
These functions do non-localized checks, which improves performance in
most cases (due to not need to do locale lookups) and is more "correct"
when checking ROM headers in most cases.

[rpcli] vt.cpp: Removed vt_isdigit() and vt_isalpha(). We can use
isdigit_ascii() and isalpha_ascii() instead.

[libromdata] Updated most IS*() uses to is*_ascii().
NOTE: ISPRINT() and ISSPACE() are left as-is for now.

VirtualBoy: We can mark all of the private is*() functions as
constexpr now.
2025-05-04 12:45:15 -04:00
David Korth
b4ba027439 [libpng] Forgot to check in new file PNGCheckLibconf.cmake.
Some checks are pending
Codecov / run (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
2025-05-03 20:18:22 -04:00
David Korth
66e75f5a40 [libromdata] WiiTicketPrivate::getEncKey(): Use a lookup table for the CA/XS combinations.
Code size difference: (64-bit Gentoo Linux, gcc-15.1.0, release build, no LTO)

   text    data     bss     dec     hex filename
   8077     808       0    8885    22b5 WiiTicket.cpp.o [before]
   8029     808       0    8837    2285 WiiTicket.cpp.o [after]
    -48       0       0     -48     -30 Difference
2025-05-03 19:15:14 -04:00
David Korth
e804c1236f NEWS.md: Mention vWii packages. 2025-05-03 19:03:00 -04:00
David Korth
91e4a39eb1 [libromdata] WiiUPackage: Don't attempt to access Wii U-specific TMD or FST stuff in vWii packages.
vWii packages use v0 tickets and TMDs. The "content groups" doesn't
exist, nor does the FST, the system XMLs, or the TGA icons.

Skip all of these if a v0 TMD is detected.

TODO: Change the system name for v0?
2025-05-03 19:01:54 -04:00
David Korth
cbbe2e1a3d [libromdata] WiiTicket::isRomSupported_static(): Allow larger tickets for vWii titles.
NUS vWii titles may have a certificate chain appended to the ticket.
2025-05-03 19:01:26 -04:00
David Korth
85e9ca4fad [rpcli] vt.cpp: win32_color_map is only used on Windows. 2025-05-03 11:31:50 -04:00
David Korth
a077d26d67 [rpcli] vt.cpp, ConsoleSetTextColor(): Combine the two snprintf() calls into one. 2025-05-03 10:59:17 -04:00
David Korth
c706f7ba9b [libpng] Update: v1.6.47 -> v1.6.48
The APNG patch for v1.6.48 isn't out yet, but unlike v1.6.47, this
release doesn't have any major breaking changes.
2025-05-03 10:23:59 -04:00
David Korth
e07a45be0e NEWS.md: Mention URL colorization and "OSC 8" markup. 2025-05-03 09:45:59 -04:00
David Korth
45e049168e Merge branch 'feature/xattr-compression-algorithm'
Some checks are pending
Codecov / run (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
2025-05-03 09:44:46 -04:00
David Korth
6056d61f2c NEWS.md: Mention xattr compression algorithms.
Some checks failed
Codecov / run (push) Has been cancelled
2025-05-03 09:44:05 -04:00
David Korth
21cc92b9c6 [librpfile] XAttrReader_p.hpp: Use bitflags instead of bools for all the "has*" variables.
std::bitset<> would also work, but the minimum size of std::bitset<> is
`unsigned long`, so it'd take up 8 bytes.
2025-05-02 23:19:58 -04:00
David Korth
594f379fe3 [librpfile] XAttrReader::hasXfsAttributes(): Fix typo; should return d->hasXfsAttributes, not d->hasExt2Attributes.
Not sure if this caused any weird issues...
2025-05-02 23:12:30 -04:00
David Korth
4c944a2add [gtk] Ext2AttrView: Fix alignment of lblCompression on GTK4.
Needed to enable hexpand and set xalign.

Not sure if this is needed or supported on GTK2 or GTK3, but using
gtk_box_pack_end() seems to work on the older versions anyway.
2025-05-02 21:38:52 -04:00
David Korth
88b9552cca [gtk] Ext2AttrView: Display the compression algorithm, if available.
XAttrView: Set the compression algorithm in Ext2AttrView.

We're using Ext2AttrView because most Linux file systems that support
compression also support Ext2-style attributes.
2025-05-02 21:34:37 -04:00