@@ -24,6 +24,17 @@ public RegionHandler(FileSystemInfo origin, FileSystemInfo target)
2424 ( _targetGameRegion , _originGameRegion ) = ( _originGameRegion , _targetGameRegion ) ;
2525 }
2626
27+ if ( _targetGameRegion == _originGameRegion )
28+ {
29+ throw new Exception (
30+ $ "You selected ISO for { _targetGameRegion } and { _originGameRegion } . Make sure to select US ISO then JP ISO.") ;
31+ }
32+
33+ if ( _targetGameRegion == GameRegions . EU )
34+ {
35+ throw new Exception ( $ "Sorry the EU version is not yet supported by this version!") ;
36+ }
37+
2738 OriginRegionInfo = GetRegionInfoFromGameRegion ( _originGameRegion ) ;
2839
2940 TargetRegionInfo = GetRegionInfoFromGameRegion ( _targetGameRegion ) ;
@@ -74,18 +85,33 @@ private static GameRegions GetGameRegionFromTitleId(FileSystemInfo file)
7485
7586 binaryReader . BaseStream . Position = Ps2Constants . GameTitleIdAddress ;
7687 var titleIdBytes = binaryReader . ReadBytes ( Ps2Constants . GameTitleIdLength ) ;
77-
78- binaryReader . Close ( ) ;
79-
88+
8089 var titleId = System . Text . Encoding . UTF8 . GetString ( titleIdBytes ) ;
8190
82- return titleId switch
91+ GameRegions gameRegion ;
92+
93+ switch ( titleId )
8394 {
84- GameRegionConstants . EuIsoConstants . TitleId => GameRegions . EU ,
85- GameRegionConstants . JpIsoConstants . TitleId => GameRegions . Japan ,
86- GameRegionConstants . UsIsoConstants . TitleId => GameRegions . USA ,
87- _ => GameRegions . UNKNOWN
88- } ;
95+ case GameRegionConstants . JpIsoConstants . TitleId :
96+ gameRegion = GameRegions . Japan ;
97+ break ;
98+ case GameRegionConstants . UsIsoConstants . TitleId :
99+ gameRegion = GameRegions . USA ;
100+ break ;
101+ default :
102+ binaryReader . BaseStream . Position = Ps2Constants . EuGameTitleIdAddress ;
103+ titleIdBytes = binaryReader . ReadBytes ( Ps2Constants . GameTitleIdLength ) ;
104+ titleId = System . Text . Encoding . UTF8 . GetString ( titleIdBytes ) ;
105+
106+ gameRegion = titleId == GameRegionConstants . EuIsoConstants . TitleId
107+ ? GameRegions . EU
108+ : GameRegions . UNKNOWN ;
109+ break ;
110+ }
111+
112+ binaryReader . Close ( ) ;
113+
114+ return gameRegion ;
89115 }
90116 }
91117
0 commit comments