| 
									
										
										
										
											2015-05-24 06:55:12 +02:00
										 |  |  | // Copyright 2008 Dolphin Emulator Project
 | 
					
						
							| 
									
										
										
										
											2015-05-18 01:08:10 +02:00
										 |  |  | // Licensed under GPLv2+
 | 
					
						
							| 
									
										
										
										
											2013-04-17 23:09:55 -04:00
										 |  |  | // Refer to the license.txt file included.
 | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-21 01:47:53 +01:00
										 |  |  | #include <cstddef>
 | 
					
						
							| 
									
										
										
										
											2015-04-09 17:44:53 +02:00
										 |  |  | #include <map>
 | 
					
						
							| 
									
										
										
										
											2014-08-31 09:34:58 -04:00
										 |  |  | #include <memory>
 | 
					
						
							| 
									
										
										
										
											2014-02-21 01:47:53 +01:00
										 |  |  | #include <string>
 | 
					
						
							| 
									
										
										
										
											2015-08-31 19:27:18 -04:00
										 |  |  | #include <utility>
 | 
					
						
							| 
									
										
										
										
											2014-02-21 01:47:53 +01:00
										 |  |  | #include <vector>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | #include "Common/ColorUtil.h"
 | 
					
						
							| 
									
										
										
										
											2014-09-07 20:06:58 -05:00
										 |  |  | #include "Common/CommonTypes.h"
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | #include "Common/Logging/Log.h"
 | 
					
						
							| 
									
										
										
										
											2015-09-26 17:13:07 -04:00
										 |  |  | #include "Common/MsgHandler.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "Common/StringUtil.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-21 01:47:53 +01:00
										 |  |  | #include "DiscIO/Blob.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "DiscIO/FileMonitor.h"
 | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | #include "DiscIO/Filesystem.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-21 01:47:53 +01:00
										 |  |  | #include "DiscIO/Volume.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "DiscIO/VolumeGC.h"
 | 
					
						
							| 
									
										
										
										
											2009-01-03 18:50:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | namespace DiscIO | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | CVolumeGC::CVolumeGC(std::unique_ptr<IBlobReader> reader) : m_pReader(std::move(reader)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | CVolumeGC::~CVolumeGC() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-28 10:35:48 +01:00
										 |  |  | bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (decrypt) | 
					
						
							|  |  |  |     PanicAlertT("Tried to decrypt data from a non-Wii volume"); | 
					
						
							| 
									
										
										
										
											2014-12-28 10:35:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (m_pReader == nullptr) | 
					
						
							|  |  |  |     return false; | 
					
						
							| 
									
										
										
										
											2009-07-03 03:26:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   FileMon::FindFilename(_Offset); | 
					
						
							| 
									
										
										
										
											2009-09-03 20:00:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   return m_pReader->Read(_Offset, _Length, _pBuffer); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | std::string CVolumeGC::GetUniqueID() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   static const std::string NO_UID("NO_UID"); | 
					
						
							|  |  |  |   if (m_pReader == nullptr) | 
					
						
							|  |  |  |     return NO_UID; | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   char ID[6]; | 
					
						
							| 
									
										
										
										
											2011-01-30 17:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (!Read(0, sizeof(ID), reinterpret_cast<u8*>(ID))) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     PanicAlertT("Failed to read unique ID from disc image"); | 
					
						
							|  |  |  |     return NO_UID; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   return DecodeString(ID); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | IVolume::ECountry CVolumeGC::GetCountry() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (!m_pReader) | 
					
						
							|  |  |  |     return COUNTRY_UNKNOWN; | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   u8 country_code; | 
					
						
							|  |  |  |   m_pReader->Read(3, 1, &country_code); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   return CountrySwitch(country_code); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | std::string CVolumeGC::GetMakerID() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (m_pReader == nullptr) | 
					
						
							|  |  |  |     return std::string(); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   char makerID[2]; | 
					
						
							|  |  |  |   if (!Read(0x4, 0x2, (u8*)&makerID)) | 
					
						
							|  |  |  |     return std::string(); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   return DecodeString(makerID); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-29 21:14:02 +02:00
										 |  |  | u16 CVolumeGC::GetRevision() const | 
					
						
							| 
									
										
										
										
											2013-04-16 22:29:01 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (!m_pReader) | 
					
						
							|  |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2013-04-16 22:29:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   u8 revision; | 
					
						
							|  |  |  |   if (!Read(7, 1, &revision)) | 
					
						
							|  |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2013-04-16 22:29:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   return revision; | 
					
						
							| 
									
										
										
										
											2013-04-16 22:29:01 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-11 11:19:30 +02:00
										 |  |  | std::string CVolumeGC::GetInternalName() const | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   char name[0x60]; | 
					
						
							|  |  |  |   if (m_pReader != nullptr && Read(0x20, 0x60, (u8*)name)) | 
					
						
							|  |  |  |     return DecodeString(name); | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return ""; | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  | std::map<IVolume::ELanguage, std::string> CVolumeGC::GetShortNames() const | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |   LoadBannerFile(); | 
					
						
							|  |  |  |   return m_short_names; | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  | std::map<IVolume::ELanguage, std::string> CVolumeGC::GetLongNames() const | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |   LoadBannerFile(); | 
					
						
							|  |  |  |   return m_long_names; | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  | std::map<IVolume::ELanguage, std::string> CVolumeGC::GetShortMakers() const | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |   LoadBannerFile(); | 
					
						
							|  |  |  |   return m_short_makers; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  | std::map<IVolume::ELanguage, std::string> CVolumeGC::GetLongMakers() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   LoadBannerFile(); | 
					
						
							|  |  |  |   return m_long_makers; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  | std::map<IVolume::ELanguage, std::string> CVolumeGC::GetDescriptions() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   LoadBannerFile(); | 
					
						
							|  |  |  |   return m_descriptions; | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | std::vector<u32> CVolumeGC::GetBanner(int* width, int* height) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |   LoadBannerFile(); | 
					
						
							|  |  |  |   *width = m_image_width; | 
					
						
							|  |  |  |   *height = m_image_height; | 
					
						
							|  |  |  |   return m_image_buffer; | 
					
						
							| 
									
										
										
										
											2015-04-10 22:10:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-10 16:35:23 +02:00
										 |  |  | u64 CVolumeGC::GetFSTSize() const | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (m_pReader == nullptr) | 
					
						
							|  |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   u32 size; | 
					
						
							|  |  |  |   if (!Read(0x428, 0x4, (u8*)&size)) | 
					
						
							|  |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   return Common::swap32(size); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | std::string CVolumeGC::GetApploaderDate() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (m_pReader == nullptr) | 
					
						
							|  |  |  |     return std::string(); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   char date[16]; | 
					
						
							|  |  |  |   if (!Read(0x2440, 0x10, (u8*)&date)) | 
					
						
							|  |  |  |     return std::string(); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   return DecodeString(date); | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-27 14:01:12 +02:00
										 |  |  | BlobType CVolumeGC::GetBlobType() const | 
					
						
							| 
									
										
										
										
											2015-09-26 15:24:29 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   return m_pReader ? m_pReader->GetBlobType() : BlobType::PLAIN; | 
					
						
							| 
									
										
										
										
											2015-09-26 15:24:29 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | u64 CVolumeGC::GetSize() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (m_pReader) | 
					
						
							|  |  |  |     return m_pReader->GetDataSize(); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2008-12-08 05:30:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-09 12:58:56 -05:00
										 |  |  | u64 CVolumeGC::GetRawSize() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   if (m_pReader) | 
					
						
							|  |  |  |     return m_pReader->GetRawSize(); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											2013-04-09 12:58:56 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-29 21:14:02 +02:00
										 |  |  | u8 CVolumeGC::GetDiscNumber() const | 
					
						
							| 
									
										
										
										
											2013-01-25 21:28:04 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   u8 disc_number; | 
					
						
							|  |  |  |   Read(6, 1, &disc_number); | 
					
						
							|  |  |  |   return disc_number; | 
					
						
							| 
									
										
										
										
											2013-01-25 21:28:04 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-04 16:26:36 +02:00
										 |  |  | IVolume::EPlatform CVolumeGC::GetVolumeType() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   return GAMECUBE_DISC; | 
					
						
							| 
									
										
										
										
											2015-06-04 16:26:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  | void CVolumeGC::LoadBannerFile() const | 
					
						
							| 
									
										
										
										
											2013-03-03 16:51:26 -06:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   // If opening.bnr has been loaded already, return immediately
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |   if (m_banner_loaded) | 
					
						
							|  |  |  |     return; | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |   GCBanner banner_file; | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   std::unique_ptr<IFileSystem> file_system(CreateFileSystem(this)); | 
					
						
							|  |  |  |   size_t file_size = (size_t)file_system->GetFileSize("opening.bnr"); | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  |   constexpr int BNR1_MAGIC = 0x31524e42; | 
					
						
							|  |  |  |   constexpr int BNR2_MAGIC = 0x32524e42; | 
					
						
							|  |  |  |   if (file_size != BNR1_SIZE && file_size != BNR2_SIZE) | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |     WARN_LOG(DISCIO, "Invalid opening.bnr. Size: %0zx", file_size); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   file_system->ReadFile("opening.bnr", reinterpret_cast<u8*>(&banner_file), file_size); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   bool is_bnr1; | 
					
						
							|  |  |  |   if (banner_file.id == BNR1_MAGIC && file_size == BNR1_SIZE) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     is_bnr1 = true; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else if (banner_file.id == BNR2_MAGIC && file_size == BNR2_SIZE) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     is_bnr1 = false; | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |     WARN_LOG(DISCIO, "Invalid opening.bnr. Type: %0x Size: %0zx", banner_file.id, file_size); | 
					
						
							|  |  |  |     return; | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |   ExtractBannerInformation(banner_file, is_bnr1); | 
					
						
							|  |  |  |   m_banner_loaded = true; | 
					
						
							| 
									
										
										
										
											2013-03-03 16:51:26 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  | void CVolumeGC::ExtractBannerInformation(const GCBanner& banner_file, bool is_bnr1) const | 
					
						
							| 
									
										
										
										
											2015-05-10 19:09:11 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   u32 number_of_languages = 0; | 
					
						
							|  |  |  |   ELanguage start_language = LANGUAGE_UNKNOWN; | 
					
						
							|  |  |  |   bool is_japanese = GetCountry() == ECountry::COUNTRY_JAPAN; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |   if (is_bnr1)  // NTSC
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   { | 
					
						
							|  |  |  |     number_of_languages = 1; | 
					
						
							|  |  |  |     start_language = is_japanese ? ELanguage::LANGUAGE_JAPANESE : ELanguage::LANGUAGE_ENGLISH; | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |   } | 
					
						
							|  |  |  |   else  // PAL
 | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |     number_of_languages = 6; | 
					
						
							|  |  |  |     start_language = ELanguage::LANGUAGE_ENGLISH; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |   m_image_width = GC_BANNER_WIDTH; | 
					
						
							|  |  |  |   m_image_height = GC_BANNER_HEIGHT; | 
					
						
							|  |  |  |   m_image_buffer = std::vector<u32>(m_image_width * m_image_height); | 
					
						
							|  |  |  |   ColorUtil::decode5A3image(m_image_buffer.data(), banner_file.image, m_image_width, | 
					
						
							|  |  |  |                             m_image_height); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   for (u32 i = 0; i < number_of_languages; ++i) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |     const GCBannerInformation& info = banner_file.information[i]; | 
					
						
							|  |  |  |     ELanguage language = static_cast<ELanguage>(start_language + i); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::string description = DecodeString(info.description); | 
					
						
							|  |  |  |     if (!description.empty()) | 
					
						
							|  |  |  |       m_descriptions[language] = description; | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-29 19:52:15 +11:00
										 |  |  |     std::string short_name = DecodeString(info.short_name); | 
					
						
							|  |  |  |     if (!short_name.empty()) | 
					
						
							|  |  |  |       m_short_names[language] = short_name; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::string long_name = DecodeString(info.long_name); | 
					
						
							|  |  |  |     if (!long_name.empty()) | 
					
						
							|  |  |  |       m_long_names[language] = long_name; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::string short_maker = DecodeString(info.short_maker); | 
					
						
							|  |  |  |     if (!short_maker.empty()) | 
					
						
							|  |  |  |       m_short_makers[language] = short_maker; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::string long_maker = DecodeString(info.long_maker); | 
					
						
							|  |  |  |     if (!long_maker.empty()) | 
					
						
							|  |  |  |       m_long_makers[language] = long_maker; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-05-10 19:09:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | }  // namespace
 |