Codechange: Use std::endian instead of TTD_ENDIAN where trivial. (#12778)

pull/741/head
Peter Nelson 3 months ago committed by GitHub
parent f9f07e9001
commit b68172c225
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -71,7 +71,7 @@ struct ScreenshotFormat {
ScreenshotHandlerProc *proc; ///< Function for writing the screenshot.
};
#define MKCOLOUR(x) TO_LE32X(x)
#define MKCOLOUR(x) TO_LE32(x)
/*************************************************
**** SCREENSHOT CODE FOR WINDOWS BITMAP (.BMP)
@ -360,12 +360,12 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
sig_bit.gray = 8;
png_set_sBIT(png_ptr, info_ptr, &sig_bit);
#if TTD_ENDIAN == TTD_LITTLE_ENDIAN
png_set_bgr(png_ptr);
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
#else
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
#endif /* TTD_ENDIAN == TTD_LITTLE_ENDIAN */
if constexpr (std::endian::native == std::endian::little) {
png_set_bgr(png_ptr);
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
} else {
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
}
}
/* use by default 64k temp memory */

@ -137,15 +137,15 @@ static bool SetBankSource(MixerChannel *mc, const SoundEntry *sound)
}
}
#if TTD_ENDIAN == TTD_BIG_ENDIAN
if (sound->bits_per_sample == 16) {
uint num_samples = sound->file_size / 2;
int16_t *samples = (int16_t *)mem;
for (uint i = 0; i < num_samples; i++) {
samples[i] = BSWAP16(samples[i]);
if constexpr (std::endian::native == std::endian::big) {
if (sound->bits_per_sample == 16) {
size_t num_samples = sound->file_size / 2;
int16_t *samples = reinterpret_cast<int16_t *>(mem);
for (size_t i = 0; i < num_samples; i++) {
samples[i] = BSWAP16(samples[i]);
}
}
}
#endif
assert(sound->bits_per_sample == 8 || sound->bits_per_sample == 16);
assert(sound->channels == 1);

@ -20,7 +20,6 @@
#include "../debug.h"
#include "../driver.h"
#include "../mixer.h"
#include "../core/endian_type.hpp"
#include "cocoa_s.h"
#define Rect OTTDRect
@ -58,9 +57,9 @@ std::optional<std::string_view> SoundDriver_Cocoa::Start(const StringList &parm)
requestedDesc.mBitsPerChannel = 16;
requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
#if TTD_ENDIAN == TTD_BIG_ENDIAN
requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */
if constexpr (std::endian::native == std::endian::big) {
requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
}
requestedDesc.mFramesPerPacket = 1;
requestedDesc.mBytesPerFrame = requestedDesc.mBitsPerChannel * requestedDesc.mChannelsPerFrame / 8;

@ -219,13 +219,8 @@ void SurveyOpenTTD(nlohmann::json &survey)
32
#endif
;
survey["endian"] =
#if (TTD_ENDIAN == TTD_LITTLE_ENDIAN)
"little"
#else
"big"
#endif
;
if constexpr (std::endian::native == std::endian::little) survey["endian"] = "little";
if constexpr (std::endian::native == std::endian::big) survey["endian"] = "big";
survey["dedicated_build"] =
#ifdef DEDICATED
"yes"

Loading…
Cancel
Save