mirror of
https://github.com/ScrelliCopter/tmx2gba.git
synced 2025-02-21 03:29:25 +11:00
remove masm hex generator
This commit is contained in:
@@ -5,16 +5,10 @@
|
||||
#include <limits>
|
||||
#include <assert.h>
|
||||
|
||||
#define GNU_STYLE 0
|
||||
#define MASM_STYLE 1
|
||||
|
||||
#define HEX_STYLE GNU_STYLE
|
||||
|
||||
|
||||
static inline constexpr char HexU(uint8_t h) { return "0123456789ABCDEF"[h >> 4]; }
|
||||
static inline constexpr char HexL(uint8_t l) { return "0123456789ABCDEF"[l & 15]; }
|
||||
|
||||
#if HEX_STYLE == GNU_STYLE
|
||||
template <typename T> static void CHex(std::ostream& s, T x);
|
||||
template <> void CHex(std::ostream& s, uint8_t x)
|
||||
{
|
||||
@@ -42,40 +36,6 @@ template <> void CHex(std::ostream& s, uint32_t x)
|
||||
if (x > 15) s << HexU(static_cast<uint8_t>(x));
|
||||
s << HexL(static_cast<uint8_t>(x));
|
||||
}
|
||||
#elif HEX_STYLE == MASM_STYLE
|
||||
template <typename T> static void MHex(std::ostream& s, T x);
|
||||
template <> void MHex(std::ostream& s, uint8_t x)
|
||||
{
|
||||
if (x > 159) s << "0";
|
||||
if (x > 15) s << HexU(x); else if (x > 9) s << "0";
|
||||
s << HexL(x);
|
||||
if (x > 9) s << "h";
|
||||
}
|
||||
template <> void MHex(std::ostream& s, uint16_t x)
|
||||
{
|
||||
if (x > 40959) s << "0";
|
||||
if (x > 4095) s << HexU(static_cast<uint8_t>(x >> 8)); else if (x > 2559) s << "0";
|
||||
if (x > 255) s << HexL(static_cast<uint8_t>(x >> 8)); else if (x > 159) s << "0";
|
||||
if (x > 15) s << HexU(static_cast<uint8_t>(x)); else if (x > 9) s << "0";
|
||||
s << HexL(static_cast<uint8_t>(x));
|
||||
if (x > 9) s << "h";
|
||||
}
|
||||
template <> void MHex(std::ostream& s, uint32_t x)
|
||||
{
|
||||
if (x > 0x9FFFFFFF) s << "0";
|
||||
if (x > 0xFFFFFFF) s << HexU(static_cast<uint8_t>(x >> 24)); else if (x > 0x9FFFFFF) s << "0";
|
||||
if (x > 0xFFFFFF) s << HexL(static_cast<uint8_t>(x >> 24)); else if (x > 0x9FFFFF) s << "0";
|
||||
if (x > 0xFFFFF) s << HexU(static_cast<uint8_t>(x >> 16)); else if (x > 655359) s << "0";
|
||||
if (x > 65535) s << HexL(static_cast<uint8_t>(x >> 16)); else if (x > 40959) s << "0";
|
||||
if (x > 4095) s << HexU(static_cast<uint8_t>(x >> 8)); else if (x > 2559) s << "0";
|
||||
if (x > 255) s << HexL(static_cast<uint8_t>(x >> 8)); else if (x > 159) s << "0";
|
||||
if (x > 15) s << HexU(static_cast<uint8_t>(x)); else if (x > 9) s << "0";
|
||||
s << HexL(static_cast<uint8_t>(x));
|
||||
if (x > 9) s << "h";
|
||||
}
|
||||
#else
|
||||
# error "Unknown hex style"
|
||||
#endif
|
||||
|
||||
|
||||
template <typename T> static constexpr const std::string_view DataType();
|
||||
@@ -95,11 +55,7 @@ static void WriteArrayDetail(std::ostream& s, const I beg, const I end, int perC
|
||||
s << "\t" << DataType<Element>() << " ";
|
||||
|
||||
const Element e = *it;
|
||||
#if HEX_STYLE == MASM_STYLE
|
||||
MHex(s, e);
|
||||
#elif HEX_STYLE == GNU_STYLE
|
||||
CHex(s, e);
|
||||
#endif
|
||||
|
||||
if (++it == end)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user