diff --git a/source/game/gameutil.c b/source/game/gameutil.c index c53edcc..8608443 100644 --- a/source/game/gameutil.c +++ b/source/game/gameutil.c @@ -1898,11 +1898,11 @@ u32 GetGoodName(char* name, const char* path, bool quick) { char region[8] = { 0 }; if (twl->region_flags == TWL_REGION_FREE) snprintf(region, 8, "W"); snprintf(region, 8, "%s%s%s%s%s", - (twl->region_flags & TWL_REGION_JAP) ? "J" : "", - (twl->region_flags & TWL_REGION_USA) ? "U" : "", - (twl->region_flags & TWL_REGION_EUR) ? "E" : "", - (twl->region_flags & TWL_REGION_CHN) ? "C" : "", - (twl->region_flags & TWL_REGION_KOR) ? "K" : ""); + (twl->region_flags & REGION_MASK_JPN) ? "J" : "", + (twl->region_flags & REGION_MASK_USA) ? "U" : "", + (twl->region_flags & REGION_MASK_EUR) ? "E" : "", + (twl->region_flags & REGION_MASK_CHN) ? "C" : "", + (twl->region_flags & REGION_MASK_KOR) ? "K" : ""); if (strncmp(region, "JUECK", 8) == 0) snprintf(region, 8, "W"); if (!*region) snprintf(region, 8, "UNK"); @@ -1926,12 +1926,12 @@ u32 GetGoodName(char* name, const char* path, bool quick) { char region[8] = { 0 }; if (smdh->region_lockout == SMDH_REGION_FREE) snprintf(region, 8, "W"); snprintf(region, 8, "%s%s%s%s%s%s", - (smdh->region_lockout & SMDH_REGION_JAP) ? "J" : "", - (smdh->region_lockout & SMDH_REGION_USA) ? "U" : "", - (smdh->region_lockout & SMDH_REGION_EUR) ? "E" : "", - (smdh->region_lockout & SMDH_REGION_CHN) ? "C" : "", - (smdh->region_lockout & SMDH_REGION_KOR) ? "K" : "", - (smdh->region_lockout & SMDH_REGION_TWN) ? "T" : ""); + (smdh->region_lockout & REGION_MASK_JPN) ? "J" : "", + (smdh->region_lockout & REGION_MASK_USA) ? "U" : "", + (smdh->region_lockout & REGION_MASK_EUR) ? "E" : "", + (smdh->region_lockout & REGION_MASK_CHN) ? "C" : "", + (smdh->region_lockout & REGION_MASK_KOR) ? "K" : "", + (smdh->region_lockout & REGION_MASK_TWN) ? "T" : ""); if (strncmp(region, "JUECKT", 8) == 0) snprintf(region, 8, "W"); if (!*region) snprintf(region, 8, "UNK"); diff --git a/source/game/nds.h b/source/game/nds.h index 7473e62..d5c74c5 100644 --- a/source/game/nds.h +++ b/source/game/nds.h @@ -1,10 +1,11 @@ #pragma once #include "common.h" +#include "region.h" // size of the icon struct: // see: http://problemkaputt.de/gbatek.htm#dscartridgeicontitle -// v0x0001 -> 0x0840 byte (contains JAP, USA, FRE, GER, ITA, ESP titles) +// v0x0001 -> 0x0840 byte (contains JPN, USA, FRE, GER, ITA, ESP titles) // v0x0002 -> 0x0940 byte (adds CHN title) // v0x0003 -> 0x0A40 byte (adds KOR title) // v0x0103 -> 0x23C0 byte (adds TWL animated icon data) @@ -19,14 +20,6 @@ #define TWL_UNITCODE_TWLNTR 0x02 #define TWL_UNITCODE_TWL 0x03 -#define TWL_REGION_JAP 0x01 -#define TWL_REGION_USA 0x02 -#define TWL_REGION_EUR 0x04 -#define TWL_REGION_AUS 0x08 -#define TWL_REGION_CHN 0x10 -#define TWL_REGION_KOR 0x20 -#define TWL_REGION_FREE 0xFFFFFFFF - // see: http://problemkaputt.de/gbatek.htm#dscartridgeicontitle typedef struct { u16 version; diff --git a/source/game/region.c b/source/game/region.c new file mode 100644 index 0000000..a224d53 --- /dev/null +++ b/source/game/region.c @@ -0,0 +1,24 @@ +#include "common.h" +#include "region.h" + +// Names of system regions, short form. +const char* const g_regionNamesShort[SMDH_NUM_REGIONS] = { + "JPN", + "USA", + "EUR", + "AUS", // mostly unused + "CHN", + "KOR", + "TWN", +}; + +// Names of system regions, long form. +const char* const g_regionNamesLong[SMDH_NUM_REGIONS] = { + "Japan", + "Americas", + "Europe", + "Australia", + "China", + "Korea", + "Taiwan", +}; diff --git a/source/game/region.h b/source/game/region.h new file mode 100644 index 0000000..20c2cb8 --- /dev/null +++ b/source/game/region.h @@ -0,0 +1,31 @@ +// List of region IDs. + +#pragma once + +// TWL and CTR share region values, except that TWL doesn't have Taiwan. +#define REGION_JPN 0 +#define REGION_USA 1 +#define REGION_EUR 2 +#define REGION_AUS 3 +#define REGION_CHN 4 +#define REGION_KOR 5 +#define REGION_TWN 6 + +#define REGION_MASK_JPN (1u << REGION_JPN) +#define REGION_MASK_USA (1u << REGION_USA) +#define REGION_MASK_EUR (1u << REGION_EUR) +#define REGION_MASK_AUS (1u << REGION_AUS) +#define REGION_MASK_CHN (1u << REGION_CHN) +#define REGION_MASK_KOR (1u << REGION_KOR) +#define REGION_MASK_TWN (1u << REGION_TWN) + +#define TWL_REGION_FREE 0xFFFFFFFF +#define TWL_NUM_REGIONS (REGION_KOR + 1) + +#define SMDH_REGION_FREE 0x7FFFFFFF +#define SMDH_NUM_REGIONS (REGION_TWN + 1) + +// Names of system regions, short form. +extern const char* const g_regionNamesShort[SMDH_NUM_REGIONS]; +// Names of system regions, long form. +extern const char* const g_regionNamesLong[SMDH_NUM_REGIONS]; diff --git a/source/game/smdh.h b/source/game/smdh.h index 536375e..e1ce89e 100644 --- a/source/game/smdh.h +++ b/source/game/smdh.h @@ -1,6 +1,7 @@ #pragma once #include "common.h" +#include "region.h" #define SMDH_MAGIC 'S', 'M', 'D', 'H' #define SMDH_SIZE_DESC_SHORT 64 @@ -11,15 +12,6 @@ #define SMDH_SIZE_ICON_SMALL (SMDH_DIM_ICON_SMALL * SMDH_DIM_ICON_SMALL * 3) // w * h * bpp (rgb888) #define SMDH_SIZE_ICON_BIG (SMDH_DIM_ICON_BIG * SMDH_DIM_ICON_BIG * 3) // w * h * bpp (rgb888) -#define SMDH_REGION_JAP 0x01 -#define SMDH_REGION_USA 0x02 -#define SMDH_REGION_EUR 0x04 -#define SMDH_REGION_AUS 0x08 -#define SMDH_REGION_CHN 0x10 -#define SMDH_REGION_KOR 0x20 -#define SMDH_REGION_TWN 0x40 -#define SMDH_REGION_FREE 0x7FFFFFFF - // see: https://www.3dbrew.org/wiki/SMDH#Application_Titles typedef struct { u16 short_desc[0x40];