diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/Debug/RomFilenameDecoderTWL.ilk b/build/tools/MasterEditor/RomFilenameDecoderTWL/Debug/RomFilenameDecoderTWL.ilk new file mode 100644 index 0000000..e69de29 diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL.ncb b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL.ncb new file mode 100644 index 0000000..a556d08 Binary files /dev/null and b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL.ncb differ diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL.sln b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL.sln new file mode 100644 index 0000000..600c856 --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RomFilenameDecoderTWL", "RomFilenameDecoderTWL\RomFilenameDecoderTWL.vcproj", "{366CCEEF-B820-4B00-9129-0BDA482DD939}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {366CCEEF-B820-4B00-9129-0BDA482DD939}.Debug|Win32.ActiveCfg = Debug|Win32 + {366CCEEF-B820-4B00-9129-0BDA482DD939}.Debug|Win32.Build.0 = Debug|Win32 + {366CCEEF-B820-4B00-9129-0BDA482DD939}.Release|Win32.ActiveCfg = Release|Win32 + {366CCEEF-B820-4B00-9129-0BDA482DD939}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL.suo b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL.suo new file mode 100644 index 0000000..d85bca5 Binary files /dev/null and b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL.suo differ diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/AssemblyInfo.cpp b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/AssemblyInfo.cpp new file mode 100644 index 0000000..e287355 --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// ƒAƒZƒ“ƒuƒŠ‚ÉŠÖ‚·‚éˆê”Êî•ñ‚͈ȉº‚Ì‘®«ƒZƒbƒg‚ð‚Æ‚¨‚µ‚ħŒä‚³‚ê‚Ü‚·B +// ƒAƒZƒ“ƒuƒŠ‚ÉŠÖ˜A•t‚¯‚ç‚ê‚Ä‚¢‚éî•ñ‚ð•ÏX‚·‚é‚É‚ÍA +// ‚±‚ê‚ç‚Ì‘®«’l‚ð•ÏX‚µ‚Ä‚­‚¾‚³‚¢B +// +[assembly:AssemblyTitleAttribute("RomFilenameDecoderTWL")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("”C“V“°Š”Ž®‰ïŽÐ")]; +[assembly:AssemblyProductAttribute("RomFilenameDecoderTWL")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) ”C“V“°Š”Ž®‰ïŽÐ 2009")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// ƒAƒZƒ“ƒuƒŠ‚̃o[ƒWƒ‡ƒ“î•ñ‚ÍAˆÈ‰º‚Ì 4 ‚‚̒l‚Å\¬‚³‚ê‚Ä‚¢‚Ü‚·: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// ‚·‚ׂĂ̒l‚ðŽw’è‚·‚é‚©A‰º‚̂悤‚É '*' ‚ðŽg‚Á‚ÄƒŠƒrƒWƒ‡ƒ“‚¨‚æ‚уrƒ‹ƒh”Ô†‚ð +// Šù’è’l‚É‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚·: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/Debug/BuildLog.htm b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/Debug/BuildLog.htm new file mode 100644 index 0000000..d168d31 Binary files /dev/null and b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/Debug/BuildLog.htm differ diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/ReadMe.txt b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/ReadMe.txt new file mode 100644 index 0000000..8a44902 --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/ReadMe.txt @@ -0,0 +1,29 @@ +=============================================================================== + ƒAƒvƒŠƒP[ƒVƒ‡ƒ“ : RomFilenameDecoderTWL ƒvƒƒWƒFƒNƒg‚ÌŠT—v +=============================================================================== + +‚±‚Ì RomFilenameDecoderTWL ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ÍAAppWizard ‚É‚æ‚Á‚Ä쬂³‚ê‚Ü‚µ‚½B + +‚±‚̃tƒ@ƒCƒ‹‚É‚ÍARomFilenameDecoderTWL ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ð\¬‚·‚éŠeƒtƒ@ƒCƒ‹‚Ì +“à—e‚ÌŠT—ª‚ª‹Lq‚³‚ê‚Ä‚¢‚Ü‚·B + +RomFilenameDecoderTWL.vcproj + ‚±‚ê‚ÍAƒAƒvƒŠƒP[ƒVƒ‡ƒ“ ƒEƒBƒU[ƒh‚Ŷ¬‚³‚ê‚é VC++ ƒvƒƒWƒFƒNƒg‚̃ƒCƒ“‚Ì + ƒvƒƒWƒFƒNƒg ƒtƒ@ƒCƒ‹‚Å‚·B + ƒtƒ@ƒCƒ‹‚𶬂µ‚½ Visual C++ ‚̃o[ƒWƒ‡ƒ“î•ñ‚ÆAƒAƒvƒŠƒP[ƒVƒ‡ƒ“ ƒEƒBƒU[ + ƒh‚Å‘I‘ð‚µ‚½ƒvƒ‰ƒbƒgƒtƒH[ƒ€A\¬A‚¨‚æ‚уvƒƒWƒFƒNƒg‚Ì‹@”\‚ÉŠÖ‚·‚éî•ñ‚ª + ‹Lq‚³‚ê‚Ä‚¢‚Ü‚·B + +RomFilenameDecoderTWL.cpp + ‚±‚ê‚ÍAƒƒCƒ“‚̃AƒvƒŠƒP[ƒVƒ‡ƒ“ ƒ\[ƒX ƒtƒ@ƒCƒ‹‚Å‚·B + +AssemblyInfo.cpp + ƒAƒZƒ“ƒuƒŠ ƒƒ^ƒf[ƒ^‚ð•ÏX‚·‚邽‚߂̃JƒXƒ^ƒ€‘®«‚ªŠÜ‚Ü‚ê‚Ä‚¢‚Ü‚·B + +/////////////////////////////////////////////////////////////////////////////// +‚»‚Ì‘¼‚̃ƒ‚ : + +AppWizard ‚Å‚ÍA"TODO:" ‚ðŽg—p‚µ‚ÄAƒ†[ƒU[‚ª’ljÁ‚Ü‚½‚̓JƒXƒ^ƒ}ƒCƒY‚·‚éƒ\[ƒX +•”•ª‚ðŽ¦‚µ‚Ü‚·B + +/////////////////////////////////////////////////////////////////////////////// diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/Release/BuildLog.htm b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/Release/BuildLog.htm new file mode 100644 index 0000000..1101546 Binary files /dev/null and b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/Release/BuildLog.htm differ diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/RomFilenameDecoderTWL.cpp b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/RomFilenameDecoderTWL.cpp new file mode 100644 index 0000000..bc92ea0 --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/RomFilenameDecoderTWL.cpp @@ -0,0 +1,91 @@ +// RomFilenameDecoderTWL.cpp : ƒƒCƒ“ ƒvƒƒWƒFƒNƒg ƒtƒ@ƒCƒ‹‚Å‚·B + +#include "stdafx.h" +#include "rfd_context.h" +#include +#include +#include +#include + +using namespace System; + +int printResult( RomFilenameDecoderTWL::RCContext ^context, + RomFilenameDecoderTWL::RCFilenameItems ^items ); + +int main(array ^args) +{ + // ˆø”‰ðÍ + RomFilenameDecoderTWL::RCContext ^context + = gcnew RomFilenameDecoderTWL::RCContext( args ); + // ƒtƒ@ƒCƒ‹–¼‚̉ðÍ + RomFilenameDecoderTWL::RCFilenameItems ^items + = gcnew RomFilenameDecoderTWL::RCFilenameItems( context->Romfile ); + // ”äŠr + items->compareRomHeader(); + + int retval = printResult( context, items ); + return retval; +} + +// ------------------------------------------------------- +// ƒGƒ‰[‰ðÍ +// ------------------------------------------------------- +int printResult( RomFilenameDecoderTWL::RCContext ^context, + RomFilenameDecoderTWL::RCFilenameItems ^items ) +{ + System::UInt16 tadver = items->RemasterVersion; + tadver = (tadver << 8) | ((System::UInt16)items->SubmissionVersion); + + if( context->IsSubmitVersion ) + { + if( items->Error != RomFilenameDecoderTWL::ECError::NOERROR ) + { + printf( "%d", (int)items->Error ); + } + else + { + printf( "%d", (int)items->SubmissionVersion ); + } + } + + else if( context->IsTadVersion ) + { + if( items->Error != RomFilenameDecoderTWL::ECError::NOERROR ) + { + printf( "%d", (int)items->Error ); + } + else + { + printf( "%d", (int)tadver ); + } + } + + else + { + System::Console::WriteLine(); + System::Console::WriteLine( "Rom Filename: " + context->Romfile ); + System::Console::WriteLine(); + + const char *rhgc = items->Rh->s.game_code; + char fgc[4]; + RomFilenameDecoderTWL::setStringToChars( fgc, items->InitialCode, 4, 0 ); + printf( " RomHeader Filename\n" ); + printf( "----------------------------------------------\n" ); + printf( "InitialCode: %c%c%c%c %c%c%c%c\n", rhgc[0], rhgc[1], rhgc[2], rhgc[3], fgc[0], fgc[1], fgc[2], fgc[3] ); + printf( "RemasterVersion: %02X %02X\n", items->Rh->s.rom_version, items->RemasterVersion ); + printf( "SubmissionVersion: - %d(%02X)\n", items->SubmissionVersion, items->SubmissionVersion ); + printf( "----------------------------------------------\n" ); + printf( "TAD Version: - %d(%04X)\n", (int)tadver, tadver ); + printf( "----------------------------------------------\n" ); + printf( "Result: " ); + if( items->Error == RomFilenameDecoderTWL::ECError::NOERROR ) + { + printf( "OK\n" ); + } + else + { + printf( "NG (%d)\n", (int)items->Error ); + } + } + return ((int)items->Error); +} \ No newline at end of file diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/RomFilenameDecoderTWL.vcproj b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/RomFilenameDecoderTWL.vcproj new file mode 100644 index 0000000..ab99d59 --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/RomFilenameDecoderTWL.vcproj @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/RomFilenameDecoderTWL.vcproj.RED.nishikawa_takeshi.user b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/RomFilenameDecoderTWL.vcproj.RED.nishikawa_takeshi.user new file mode 100644 index 0000000..7963a7f --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/RomFilenameDecoderTWL.vcproj.RED.nishikawa_takeshi.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/app.ico b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/app.ico differ diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/app.rc b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/app.rc new file mode 100644 index 0000000..2ad8e34 --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ ‚Ŷ¬‚³‚ꂽƒŠƒ\[ƒX ƒXƒNƒŠƒvƒg‚Å‚·B +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// ‰pŒê (•Ä‘) ƒŠƒ\[ƒX + + +///////////////////////////////////////////////////////////////////////////// +// +// ƒAƒCƒRƒ“ +// + +// ʼn‚É”z’u‚³‚ꂽƒAƒCƒRƒ“A‚Ü‚½‚Í ID ’l‚ªÅ‚à’á‚¢ƒAƒCƒRƒ“‚ªAƒAƒvƒŠƒP[ƒVƒ‡ƒ“ ƒAƒCƒRƒ“‚ɂȂè‚Ü‚·B + +LANGUAGE 17, 1 +#pragma code_page(932) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE 3 ƒŠƒ\[ƒX‚©‚綬‚³‚ê‚Ü‚µ‚½B +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // APSTUDIO_INVOKED ‚łȂ¢ê‡ + diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/resource.h b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/resource.h new file mode 100644 index 0000000..1f2251c --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/rfd_context.h b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/rfd_context.h new file mode 100644 index 0000000..d8c7e65 --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/rfd_context.h @@ -0,0 +1,272 @@ +#pragma once + +#include +#include +#include +#include +#include "rfd_util.h" + +namespace RomFilenameDecoderTWL +{ + +// ----------------------------------------------------------- +// ƒGƒ‰[ƒR[ƒh +// ----------------------------------------------------------- +enum class ECError +{ + NOERROR = 0, + ERROR_READ_FILE = -1, + ERROR_FILE_NAME = -2, + // -3..-7 —\–ñ + ERROR_INITIAL_CODE = -8, + ERROR_REMASTER_VERSION = -9, +}; + +// ----------------------------------------------------------- +// ŽÀscontext +// ----------------------------------------------------------- +ref class RCContext +{ +private: + // ˆø”‚̉ðÍŒ‹‰Ê + System::String ^romfile; // “ü—̓tƒ@ƒCƒ‹–¼ + System::Int32 argc; // ˆø”‚Ì” + // ƒIƒvƒVƒ‡ƒ“‚ð•\‚·ƒtƒ‰ƒO + System::Boolean isSubmitVersion; + System::Boolean isTadVersion; +public: + // ReadOnly‚É‚·‚é + property System::String^ Romfile + { + System::String^ get(void) + { + if( !romfile ) + { + return nullptr; + } + return System::String::Copy( this->romfile ); + } + } + property System::Int32 Argc + { + System::Int32 get(void){ return this->argc; } + } + property System::Boolean IsSubmitVersion + { + System::Boolean get(void){ return this->isSubmitVersion; } + } + property System::Boolean IsTadVersion + { + System::Boolean get(void){ return this->isTadVersion; } + } +private: + RCContext(){} // ••‚¶‚é +public: + // ƒRƒ“ƒXƒgƒ‰ƒNƒ^‚ł͈ø”‚ð‚à‚ç‚Á‚ătƒ‰ƒO‚ð‰ðÍ‚·‚é + RCContext( cli::array ^args ) + { + this->parseArgs( args ); + } +private: + // ˆø”‰ðÍ + void parseArgs( cli::array ^args ) + { + System::Collections::Generic::List ^indexList + = gcnew System::Collections::Generic::List; + + int numopt = 0; + int i; + for( i=0; i < args->Length; i++ ) + { + if( args[i]->StartsWith( "-s" ) ) + { + this->isSubmitVersion = true; + numopt++; + } + else if( args[i]->StartsWith( "-t" ) ) + { + this->isTadVersion = true; + numopt++; + } + else if( !args[i]->StartsWith( "-" ) ) // ƒIƒvƒVƒ‡ƒ“‚łȂ¢ˆø”‚Ìindex‚ð‹L˜^ + { + indexList->Add(i); + } + } + i=0; + for each( System::Int32 index in indexList ) // ƒIƒvƒVƒ‡ƒ“‚łȂ¢ˆø”‚ð‘O‚ɂ‚߂Ă¢‚­ + { + args[i] = args[index]; + i++; + } + this->argc = args->Length - numopt; // ˆø”‚Ì”‚©‚çƒIƒvƒVƒ‡ƒ“‚Ì”‚𜂭 + if( this->argc > 0 ) + { + this->romfile = System::String::Copy( args[0] ); + } + else + { + this->romfile = nullptr; + } + } +}; //ref class RCContext + +// ----------------------------------------------------------- +// ƒtƒ@ƒCƒ‹–¼‚©‚çŽæ“¾‚Å‚«‚éî•ñ +// ----------------------------------------------------------- +ref class RCFilenameItems +{ +private: + // ƒtƒ@ƒCƒ‹–¼‚©‚çŽæ“¾‚Å‚«‚éî•ñ + System::String^ initialCode; + System::Byte remasterVersion; + System::Byte submissionVersion; + // ƒtƒ@ƒCƒ‹‚©‚ç“ǂݞ‚ñ‚¾ROMƒwƒbƒ_ + ROM_Header *rh; + // ƒGƒ‰[î•ñ + RomFilenameDecoderTWL::ECError error; +public: + property System::String^ InitialCode + { + System::String^ get(void){ return System::String::Copy(this->initialCode); } + } + property System::Byte RemasterVersion + { + System::Byte get(void){ return this->remasterVersion; } + } + property System::Byte SubmissionVersion + { + System::Byte get(void){ return this->submissionVersion; } + } + property const ROM_Header* Rh + { + const ROM_Header* get(void){ return this->rh; } + } + property RomFilenameDecoderTWL::ECError Error + { + RomFilenameDecoderTWL::ECError get(void){ return this->error; } + } +private: + RCFilenameItems(){} +public: + RCFilenameItems( System::String ^filepath ) + { + this->initialCode = gcnew System::String(""); + this->remasterVersion = 0; + this->submissionVersion = 0; + this->rh = new ROM_Header; + memset( this->rh, 0, sizeof(ROM_Header) ); + this->error = RomFilenameDecoderTWL::ECError::NOERROR; + + this->parseFilename( filepath ); + if( this->error == RomFilenameDecoderTWL::ECError::NOERROR ) + { + this->readRomHeader( filepath ); + } + } + ~RCFilenameItems() + { + this->!RCFilenameItems(); + } + !RCFilenameItems() + { + delete this->rh; + } +private: + // ROMƒwƒbƒ_‚ð“ǂݞ‚Þ + void readRomHeader( System::String ^filepath ) + { + if( !RomFilenameDecoderTWL::readRomHeader( filepath, this->rh ) ) + { + this->error = RomFilenameDecoderTWL::ECError::ERROR_READ_FILE; + } + } + // ƒtƒ@ƒCƒ‹–¼‚ð‰ðÍ‚µ‚ăƒ“ƒo•Ï”‚ðÝ’è‚·‚é + void parseFilename( System::String ^filepath ) + { + if( !filepath ) // Žw’肳‚ê‚Ä‚¢‚È‚¢ê‡ + { + this->error = RomFilenameDecoderTWL::ECError::ERROR_FILE_NAME; + return; + } + System::String^ prefix = System::IO::Path::GetFileNameWithoutExtension( filepath ); // Šg’£Žq‚ƃfƒBƒŒƒNƒgƒŠƒpƒX‚𜂭 + if( prefix->Length < 7 ) // T****@#.SRL / T****0#E.SRL ‚Ì‚¢‚¸‚ê‚© + { + this->error = RomFilenameDecoderTWL::ECError::ERROR_FILE_NAME; + return; + } + this->initialCode = prefix->Substring(1,4); + this->remasterVersion = this->parseStrToByte( prefix->Substring(5,1) ); + if( prefix->Length >= 8 ) + { + if( ((char)prefix[7] == 'E') && (this->remasterVersion == 0) ) + { + this->remasterVersion = 0xE0; + } + } + this->submissionVersion = this->parseStrToByte( prefix->Substring(6,1) ); + } //void parseFilename() +public: + // 1Œ…‚Ì”Žš‚ð”’l‚ɕϊ· + System::Byte parseStrToByte( System::String ^str ) + { + if( str->Length > 1 ) + { + return 0xff; + } + System::Byte val; + + // ’Êí 0..F ‚¾‚ª ‚»‚Ìã‚ð G..Z ‚Å•\‚·‰Â”\«‚ª‚ ‚é + char c = (char)str[0]; + if( ('G' <= c) && (c <= 'Z') ) // F‚æ‚èã‚ÍG..Z‚Å•\Œ»‚³‚ê‚Ä‚¢‚­(‰Â”\«‚ ‚è) + { + val = c - 'G' + 16; + } + else if( ('g' <= c) && (c <= 'z') ) + { + val = c - 'g' + 16; + } + else + { + try + { + val = System::Byte::Parse( str, System::Globalization::NumberStyles::AllowHexSpecifier ); + } + catch(System::Exception ^e ) + { + (void)e; + val = 0xff; + } + } + return val; + } //parseStrToByte() +public: + // ROMƒwƒbƒ_‚Ìî•ñ‚ÆŽ©g‚Ìî•ñ‚ð”äŠr(ƒGƒ‰[î•ñ‚̓ƒ“ƒo•Ï”‚ÉÝ’è) + void compareRomHeader() + { + // ‚·‚łɃGƒ‰[‚ª‚ ‚éꇂɂ͉½‚à‚µ‚È‚¢ + if( this->error != RomFilenameDecoderTWL::ECError::NOERROR ) + { + return; + } + // ƒCƒjƒVƒƒƒ‹ƒR[ƒh‚Ì”äŠr + char inicode[4]; + RomFilenameDecoderTWL::setStringToChars( inicode, this->initialCode, 4, 0 ); + if( memcmp( this->rh->s.game_code, inicode, 4 ) != 0 ) + { + this->error = RomFilenameDecoderTWL::ECError::ERROR_INITIAL_CODE; + return; + } + // ƒŠƒ}ƒXƒ^[ƒo[ƒWƒ‡ƒ“‚Ì”äŠr + if( this->rh->s.rom_version != this->remasterVersion ) + { + this->error = RomFilenameDecoderTWL::ECError::ERROR_REMASTER_VERSION; + return; + } + // ’ñoƒo[ƒWƒ‡ƒ“‚ÍROMƒwƒbƒ_‚ɂȂ¢‚̂ŔäŠr‚Å‚«‚È‚¢ + this->error = RomFilenameDecoderTWL::ECError::NOERROR; + return; + } //void compareRomHeader() +}; //ref class RCFilenameItems + +} //namespace RomFilenameDecoderTWL \ No newline at end of file diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/rfd_util.cpp b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/rfd_util.cpp new file mode 100644 index 0000000..3b94ff4 --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/rfd_util.cpp @@ -0,0 +1,55 @@ +#include "stdafx.h" +#include +#include +#include +#include +#include "rfd_util.h" + +// ------------------------------------------------------------------ +// ROMƒwƒbƒ_‚̓ǂݞ‚Ý +// ------------------------------------------------------------------ + +System::Boolean RomFilenameDecoderTWL::readRomHeader( System::String ^srlfile, ROM_Header *rh ) +{ + FILE *fp = NULL; + const char *pchFilename = + (const char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( srlfile ).ToPointer(); + + // ƒtƒ@ƒCƒ‹‚ðŠJ‚¢‚ÄROMƒwƒbƒ_‚̂ݓǂÝo‚· + if( fopen_s( &fp, pchFilename, "rb" ) != NULL ) + { + return false; + } + (void)fseek( fp, 0, SEEK_SET ); // ROMƒwƒbƒ_‚Ísrl‚Ìæ“ª‚©‚ç + + // 1ƒoƒCƒg‚ðsizeof(~)‚¾‚¯ƒŠ[ƒh (‹t‚¾‚ƕԂè’l‚ªsizeof(~)‚ɂȂç‚È‚¢‚̂ŒˆÓ) + if( fread( (void*)rh, 1, sizeof(ROM_Header), fp ) != sizeof(ROM_Header) ) + { + fclose( fp ); + return false; + } + fclose( fp ); + return true; +} + +// ------------------------------------------------------------------ +// String ‚ð char ”z—ñ‚ÉŠi”[ +// ------------------------------------------------------------------ + +// @arg [out] Ši”[æ +// @arg [in] Ši”[Œ³ +// @arg [in] •¶Žš—ñ’· +// @arg [in] —]‚è‚ð–„‚ß‚é padding +void RomFilenameDecoderTWL::setStringToChars( + char *pDst, System::String ^hSrc, + const System::Int32 nMax, const System::SByte pad ) +{ + System::Int32 i; + + memset( pDst, pad, nMax ); + for( i=0; (i < hSrc->Length) && (i < nMax); i++ ) + { + pDst[i] = (char)hSrc[i]; + } +} + diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/rfd_util.h b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/rfd_util.h new file mode 100644 index 0000000..13fcaad --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/rfd_util.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +namespace RomFilenameDecoderTWL +{ + +// ------------------------------------------------------------------ +// ROMƒwƒbƒ_‚̓ǂݞ‚Ý +// ------------------------------------------------------------------ +System::Boolean readRomHeader( System::String ^srlfile, ROM_Header *rh ); + +// ------------------------------------------------------------------ +// String ‚ð char ”z—ñ‚ÉŠi”[ +// ------------------------------------------------------------------ + +// @arg [out] Ši”[æ +// @arg [in] Ši”[Œ³ +// @arg [in] •¶Žš—ñ’· +// @arg [in] —]‚è‚ð–„‚ß‚é padding +void setStringToChars( char *pDst, System::String ^hSrc, + const System::Int32 nMax, const System::SByte pad ); + +} //namespace RomFilenameDecoderTWL diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/stdafx.cpp b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/stdafx.cpp new file mode 100644 index 0000000..2505a5b --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : •W€ƒCƒ“ƒNƒ‹[ƒh RomFilenameDecoderTWL.pch ‚݂̂ð +// ŠÜ‚Þƒ\[ƒX ƒtƒ@ƒCƒ‹‚ÍAƒvƒŠƒRƒ“ƒpƒCƒ‹Ï‚݃wƒbƒ_[‚ɂȂè‚Ü‚·B +// stdafx.obj ‚ɂ̓vƒŠƒRƒ“ƒpƒCƒ‹Ï‚ÝŒ^î•ñ‚ªŠÜ‚Ü‚ê‚Ü‚·B + +#include "stdafx.h" + + diff --git a/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/stdafx.h b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/stdafx.h new file mode 100644 index 0000000..d0e2c99 --- /dev/null +++ b/build/tools/MasterEditor/RomFilenameDecoderTWL/RomFilenameDecoderTWL/stdafx.h @@ -0,0 +1,8 @@ +// stdafx.h : •W€‚̃VƒXƒeƒ€ ƒCƒ“ƒNƒ‹[ƒh ƒtƒ@ƒCƒ‹‚̃Cƒ“ƒNƒ‹[ƒh ƒtƒ@ƒCƒ‹A‚Ü‚½‚Í +// ŽQƉñ”‚ª‘½‚­A‚©‚‚ ‚Ü‚è•ÏX‚³‚ê‚È‚¢AƒvƒƒWƒFƒNƒgê—p‚̃Cƒ“ƒNƒ‹[ƒh ƒtƒ@ƒCƒ‹ +// ‚ð‹Lq‚µ‚Ü‚·B +// + +#pragma once + +// TODO: ƒvƒƒOƒ‰ƒ€‚É•K—v‚ȒljÁƒwƒbƒ_[‚ð‚±‚±‚ÅŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B