From fb16700fe56c6b338ddfad653964b7adee064051 Mon Sep 17 00:00:00 2001
From: Jhynjhiruu <cub3r12@gmail.com>
Date: Sun, 21 Jul 2019 00:36:04 +0100
Subject: [PATCH 1/5] Update smdh.cpp

---
 src/core/loader/smdh.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp
index 3392739c5..e66605db9 100644
--- a/src/core/loader/smdh.cpp
+++ b/src/core/loader/smdh.cpp
@@ -52,6 +52,10 @@ SMDH::GameRegion SMDH::GetRegion() const {
     if (region_lockout == 0x7fffffff) {
         return GameRegion::RegionFree;
     }
+    
+    if (region_lockout == 0x00000050) {
+        return GameRegion::Taiwan;
+    } // hack to fix TWN games that support CHN consoles
 
     constexpr u32 REGION_COUNT = 7;
     u32 region = 0;

From 17ba67c8c9aa01dcbdc54d37e737787313a6e045 Mon Sep 17 00:00:00 2001
From: Jhynjhiruu <cub3r12@gmail.com>
Date: Sun, 21 Jul 2019 10:37:29 +0100
Subject: [PATCH 2/5] Remove magic number

---
 src/core/loader/smdh.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp
index e66605db9..d2dfe7f78 100644
--- a/src/core/loader/smdh.cpp
+++ b/src/core/loader/smdh.cpp
@@ -53,10 +53,11 @@ SMDH::GameRegion SMDH::GetRegion() const {
         return GameRegion::RegionFree;
     }
     
-    if (region_lockout == 0x00000050) {
+    constexpr u32 taiwan_and_china = (1 << GameRegion::Taiwan) & (1 << GameRegion::China);
+    if (region_lockout == taiwan_and_china) {
         return GameRegion::Taiwan;
     } // hack to fix TWN games that support CHN consoles
-
+    
     constexpr u32 REGION_COUNT = 7;
     u32 region = 0;
     for (; region < REGION_COUNT; ++region) {

From 3f49d9920c15080586cf41573273f32541c00518 Mon Sep 17 00:00:00 2001
From: Jhynjhiruu <cub3r12@gmail.com>
Date: Sun, 21 Jul 2019 10:39:20 +0100
Subject: [PATCH 3/5] Fix whitespace

---
 src/core/loader/smdh.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp
index d2dfe7f78..a575d04e1 100644
--- a/src/core/loader/smdh.cpp
+++ b/src/core/loader/smdh.cpp
@@ -52,12 +52,12 @@ SMDH::GameRegion SMDH::GetRegion() const {
     if (region_lockout == 0x7fffffff) {
         return GameRegion::RegionFree;
     }
-    
+
     constexpr u32 taiwan_and_china = (1 << GameRegion::Taiwan) & (1 << GameRegion::China);
     if (region_lockout == taiwan_and_china) {
         return GameRegion::Taiwan;
     } // hack to fix TWN games that support CHN consoles
-    
+
     constexpr u32 REGION_COUNT = 7;
     u32 region = 0;
     for (; region < REGION_COUNT; ++region) {

From 834a4873885ae84b7118bac1f05837bdfb549091 Mon Sep 17 00:00:00 2001
From: Jhynjhiruu <cub3r12@gmail.com>
Date: Sun, 21 Jul 2019 10:51:59 +0100
Subject: [PATCH 4/5] Fix build issue

Co-Authored-By: Ben <bene_thomas@web.de>
---
 src/core/loader/smdh.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp
index a575d04e1..a7b56360f 100644
--- a/src/core/loader/smdh.cpp
+++ b/src/core/loader/smdh.cpp
@@ -53,7 +53,8 @@ SMDH::GameRegion SMDH::GetRegion() const {
         return GameRegion::RegionFree;
     }
 
-    constexpr u32 taiwan_and_china = (1 << GameRegion::Taiwan) & (1 << GameRegion::China);
+    constexpr u32 taiwan_and_china =
+        (1 << static_cast<u32>(GameRegion::Taiwan)) & (1 << static_cast<u32>(GameRegion::China));
     if (region_lockout == taiwan_and_china) {
         return GameRegion::Taiwan;
     } // hack to fix TWN games that support CHN consoles

From e201d44aa9df54af0add21ab67a4521b4e045718 Mon Sep 17 00:00:00 2001
From: Jhynjhiruu <cub3r12@gmail.com>
Date: Sun, 21 Jul 2019 11:31:07 +0100
Subject: [PATCH 5/5] It's supposed to be OR, not AND!

---
 src/core/loader/smdh.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp
index a7b56360f..ebb35675c 100644
--- a/src/core/loader/smdh.cpp
+++ b/src/core/loader/smdh.cpp
@@ -54,7 +54,7 @@ SMDH::GameRegion SMDH::GetRegion() const {
     }
 
     constexpr u32 taiwan_and_china =
-        (1 << static_cast<u32>(GameRegion::Taiwan)) & (1 << static_cast<u32>(GameRegion::China));
+        (1 << static_cast<u32>(GameRegion::Taiwan)) | (1 << static_cast<u32>(GameRegion::China));
     if (region_lockout == taiwan_and_china) {
         return GameRegion::Taiwan;
     } // hack to fix TWN games that support CHN consoles