diff --git a/build/tools/MasterEditor/SheetCheckerTWL/Debug/SheetCheckerTWL.ilk b/build/tools/MasterEditor/SheetCheckerTWL/Debug/SheetCheckerTWL.ilk new file mode 100644 index 0000000..e69de29 diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.ncb b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.ncb new file mode 100644 index 0000000..582ce26 Binary files /dev/null and b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.ncb differ diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.sln b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.sln new file mode 100644 index 0000000..18dd1c0 --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SheetCheckerTWL", "SheetCheckerTWL\SheetCheckerTWL.vcproj", "{426F4BD7-3EEB-421A-87AB-697DF71DFB47}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {426F4BD7-3EEB-421A-87AB-697DF71DFB47}.Debug|Win32.ActiveCfg = Debug|Win32 + {426F4BD7-3EEB-421A-87AB-697DF71DFB47}.Debug|Win32.Build.0 = Debug|Win32 + {426F4BD7-3EEB-421A-87AB-697DF71DFB47}.Release|Win32.ActiveCfg = Release|Win32 + {426F4BD7-3EEB-421A-87AB-697DF71DFB47}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.suo b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.suo new file mode 100644 index 0000000..535e8f1 Binary files /dev/null and b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL.suo differ diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/AssemblyInfo.cpp b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/AssemblyInfo.cpp new file mode 100644 index 0000000..841b355 --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/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("SheetCheckerTWL")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("”C“V“°Š”Ž®‰ïŽÐ")]; +[assembly:AssemblyProductAttribute("SheetCheckerTWL")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) ”C“V“°Š”Ž®‰ïŽÐ 2008")]; +[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/SheetCheckerTWL/SheetCheckerTWL/Debug/BuildLog.htm b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Debug/BuildLog.htm new file mode 100644 index 0000000..6358380 Binary files /dev/null and b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Debug/BuildLog.htm differ diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/ReadMe.txt b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/ReadMe.txt new file mode 100644 index 0000000..169b620 --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/ReadMe.txt @@ -0,0 +1,29 @@ +=============================================================================== + ƒAƒvƒŠƒP[ƒVƒ‡ƒ“ : SheetCheckerTWL ƒvƒƒWƒFƒNƒg‚ÌŠT—v +=============================================================================== + +‚±‚Ì SheetCheckerTWL ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ÍAAppWizard ‚É‚æ‚Á‚Ä쬂³‚ê‚Ü‚µ‚½B + +‚±‚̃tƒ@ƒCƒ‹‚É‚ÍASheetCheckerTWL ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ð\¬‚·‚éŠeƒtƒ@ƒCƒ‹‚Ì +“à—e‚ÌŠT—ª‚ª‹Lq‚³‚ê‚Ä‚¢‚Ü‚·B + +SheetCheckerTWL.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 + +SheetCheckerTWL.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/SheetCheckerTWL/SheetCheckerTWL/Release/BuildLog.htm b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Release/BuildLog.htm new file mode 100644 index 0000000..36b3cbe Binary files /dev/null and b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/Release/BuildLog.htm differ diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.cpp b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.cpp new file mode 100644 index 0000000..70c3bc1 --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.cpp @@ -0,0 +1,289 @@ +// SheetCheckerTWL.cpp : ƒƒCƒ“ ƒvƒƒWƒFƒNƒg ƒtƒ@ƒCƒ‹‚Å‚·B + +#include "stdafx.h" +#include "SheetCheckerTWL.h" +#include "crc_whole.h" +#include +#include +#include + +using namespace System; + +// ------------------------------------------------------------------ +// 錾 +// ------------------------------------------------------------------ + +System::Int32 parseOption( array ^args, SheetCheckerContext ^context ); +System::Boolean readRomHeader( System::String ^srlfile, ROM_Header *rh ); +System::Boolean readSheet( System::String ^sheetfile, SheetItem ^item ); +System::String^ getXPathText( System::Xml::XmlElement ^root, System::String ^xpath ); + + +// ------------------------------------------------------------------ +// –{‘Ì +// ------------------------------------------------------------------ + +int main(array ^args) +{ + SheetCheckerContext ^hContext = gcnew SheetCheckerContext; + + // getopt + int argc = parseOption( args, hContext ); + + // ˆø”ˆ— + if( argc != 2 ) + { + hContext->ErrorCode = SheetCheckerError::ERROR_ARG; + Console::WriteLine( "error arguments" ); + return 0; + } + System::String ^hSrlFile = args[0]; + System::String ^hSheetFile = args[1]; + + // ROMƒwƒbƒ_‚̓ǂݞ‚Ý + ROM_Header rh; + memset( (void*)&rh, 0, sizeof(ROM_Header) ); + if( !readRomHeader( hSrlFile, &rh ) ) + { + hContext->ErrorCode = SheetCheckerError::ERROR_READ_SRL; + } + System::UInt16 crc; + getWholeCRCInFile( hSrlFile, &crc ); + + // ’ñoŠm”F‘‚̓ǂݞ‚Ý + SheetItem ^hItem = gcnew SheetItem; + if( !readSheet( hSheetFile, hItem ) ) + { + hContext->ErrorCode = SheetCheckerError::ERROR_READ_SHEET; + } + + // ˆê’v”»’è + if( hContext->ErrorCode == SheetCheckerError::NOERROR ) + { + if( memcmp( rh.s.game_code, hItem->GameCode, 4 ) != 0 ) + { + hContext->ErrorCode = SheetCheckerError::ERROR_VERIFY_GAME_CODE; + } + else if( rh.s.rom_version != hItem->RomVersion ) + { + hContext->ErrorCode = SheetCheckerError::ERROR_VERIFY_ROM_VERSION; + } + else if( crc != hItem->FileCRC ) + { + hContext->ErrorCode = SheetCheckerError::ERROR_VERIFY_CRC; + } + } + + // ’Êí‚Ì•\ަ + if( !hContext->bSubmitVersion && !hContext->bResult ) + { + + Console::WriteLine( "" ); + Console::WriteLine( "SRL: " + hSrlFile ); + Console::WriteLine( "Sheet: " + hSheetFile ); + Console::WriteLine( "" ); + + printf( " SRL Sheet\n" ); + printf( "------------------------------------\n" ); + printf( "InitialCode: %c%c%c%c %c%c%c%c\n", + rh.s.game_code[0], rh.s.game_code[1], rh.s.game_code[2], rh.s.game_code[3], + hItem->GameCode[0], hItem->GameCode[1], hItem->GameCode[2], hItem->GameCode[3] ); + printf( "RemasterVersion: %02X %02X\n", rh.s.rom_version, hItem->RomVersion ); + printf( "File CRC: %04X %04X\n", crc, hItem->FileCRC ); + printf( "------------------------------------\n" ); + printf( "SubmitVersion: - %d\n", hItem->SubmitVersion ); + printf( "------------------------------------\n" ); + printf( "Result: " ); + if( hContext->ErrorCode == SheetCheckerError::NOERROR ) + { + printf( "OK\n" ); + } + else + { + printf( "NG (%d)\n", hContext->ErrorCode ); + } + } + + // ƒIƒvƒVƒ‡ƒ“‚̂Ƃ«‚Ì•\ަ + if( hContext->bSubmitVersion ) + { + if( hContext->ErrorCode == SheetCheckerError::NOERROR ) + { + printf( "%d\n", hItem->SubmitVersion ); + } + else + { + printf( "%d\n", hContext->ErrorCode ); // ƒGƒ‰[‚̂Ƃ«‚̓Gƒ‰[ƒR[ƒh + } + } + if( hContext->bResult ) + { + printf( "%d\n", hContext->ErrorCode ); + } + + return 0; +} + +// ------------------------------------------------------------------ +// ROMƒwƒbƒ_‚̓ǂݞ‚Ý +// ------------------------------------------------------------------ + +System::Boolean 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; +} + +// ------------------------------------------------------------------ +// ’ñoŠm”F‘‚̓ǂݞ‚Ý +// ------------------------------------------------------------------ + +System::Boolean readSheet( System::String ^sheetfile, SheetItem ^item ) +{ + // XSL‚É‚æ‚Á‚ÄXML•ÏŠ· + System::String ^tmpfile = ".\\temp" + System::DateTime::Now.ToString("yyyyMMddHHmmss") + ".xml"; + System::Xml::Xsl::XslCompiledTransform ^xslt = gcnew System::Xml::Xsl::XslCompiledTransform; + try + { + xslt->Load( ".\\extract_sheet.xsl" ); + xslt->Transform( sheetfile, tmpfile ); + } + catch( System::Exception ^ex ) + { + (void)ex; + //Console::WriteLine( "XSLT Error" ); + return false; + } + // •ÏŠ·‚µ‚½XML‚ð“ǂݞ‚Ý + System::Xml::XmlDocument ^doc = gcnew System::Xml::XmlDocument; + try + { + doc->Load( tmpfile ); + } + catch( System::Exception ^ex ) + { + (void)ex; + return false; + } + + // XML‚©‚çƒf[ƒ^‚ð’Šo + System::Xml::XmlElement ^root = doc->DocumentElement; + System::String ^text; + { + text = getXPathText( root, "/Sheet/GameCode" ); + char code[4]; + int i; + for(i=0; i<4; i++ ) + { + code[i] = (char)text[i]; + } + item->GameCode = code; // ‘ã“ü‚µ‚½‚çƒRƒs[‚·‚邿‚¤‚É property ‚ð’è‹`‚µ‚Ä‚¢‚é + + text = getXPathText( root, "/Sheet/RomVersion" ); + if( text->Contains( "(" ) ) // Ž–‘O”ł̂Ƃ«‚É‚Í"(Ž–‘O”Å)"‚ª“ü‚é + { + text = text->Remove( text->IndexOf("(") ); + } + item->RomVersion = System::Byte::Parse( text, System::Globalization::NumberStyles::AllowHexSpecifier ); + + text = getXPathText( root, "/Sheet/CRC" ); + if( text->Contains( "0x" ) ) + { + text = text->Substring( text->IndexOf("x")+1 ); + } + item->FileCRC = System::UInt16::Parse( text, System::Globalization::NumberStyles::AllowHexSpecifier ); + + text = getXPathText( root, "/Sheet/SubmitVersion" ); + char c = (char)text[0]; + if( ('G' <= c) && (c <= 'Z') ) // F‚æ‚èã‚ÍG..Z‚Å•\Œ»‚³‚ê‚Ä‚¢‚­ + { + item->SubmitVersion = c - 'F' + 16; + } + else if( ('g' <= c) && (c <= 'z') ) + { + item->SubmitVersion = c - 'f' + 16; + } + else + { + item->SubmitVersion = System::Byte::Parse( text, System::Globalization::NumberStyles::AllowHexSpecifier ); + } + } + + // ’†ŠÔƒtƒ@ƒCƒ‹‚ðíœ + if( System::IO::File::Exists( tmpfile ) ) + { + System::IO::File::Delete( tmpfile ); + } + return true; +} + +// ------------------------------------------------------------------ +// getopt +// ------------------------------------------------------------------ + +// •Ô‚è’l: ƒIƒvƒVƒ‡ƒ“‚𜂢‚½‚Æ‚«‚Ìargc +System::Int32 parseOption( array ^args, SheetCheckerContext ^context ) +{ + 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" ) ) + { + context->bSubmitVersion = true; + numopt++; + } + else if( args[i]->StartsWith( "-r" ) ) + { + context->bResult = 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++; + } + return (args->Length - numopt); +} + +// ------------------------------------------------------------------ +// XMLƒ^ƒOŒŸõ +// ------------------------------------------------------------------ + +// @ret ƒeƒLƒXƒg‚ª‘¶Ý‚·‚邯‚«‚»‚̃eƒLƒXƒg‚ð•Ô‚·B‘¶Ý‚µ‚È‚¢‚Æ‚«nullptrB +System::String^ getXPathText( System::Xml::XmlElement ^root, System::String ^xpath ) +{ + System::Xml::XmlNode ^tmp = root->SelectSingleNode( xpath ); + if( tmp && tmp->FirstChild && tmp->FirstChild->Value ) + { + return tmp->FirstChild->Value; + } + return nullptr; +} + diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.h b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.h new file mode 100644 index 0000000..da775ca --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.h @@ -0,0 +1,94 @@ +#pragma once + +#include +#include + +// ------------------------------------------------------------------ +// \‘¢‘Ì +// ------------------------------------------------------------------ + +// ƒGƒ‰[ƒR[ƒh +enum class SheetCheckerError +{ + NOERROR = 0, + ERROR_VERIFY_CRC = -1, + ERROR_VERIFY_GAME_CODE = -2, + ERROR_VERIFY_ROM_VERSION = -3, + ERROR_READ_SRL = -8, + ERROR_READ_SHEET = -9, + ERROR_ARG = -0xA, +}; + +// ŽÀsContext +ref class SheetCheckerContext +{ +private: + System::Boolean ^hbSubmitVersion; // ƒIƒvƒVƒ‡ƒ“ƒtƒ‰ƒO + System::Boolean ^hbResult; + SheetCheckerError ^hErrorCode; // ƒGƒ‰[î•ñ +public: + SheetCheckerContext() + { + this->hbSubmitVersion = gcnew System::Boolean(false); + this->hbResult = gcnew System::Boolean(false); + this->hErrorCode = gcnew SheetCheckerError( SheetCheckerError::NOERROR ); + } + property System::Boolean bSubmitVersion + { + void set( System::Boolean flg ){ this->hbSubmitVersion = gcnew System::Boolean(flg); } + System::Boolean get(){ return *this->hbSubmitVersion; } + }; + property System::Boolean bResult + { + void set( System::Boolean flg ){ this->hbResult = gcnew System::Boolean(flg); } + System::Boolean get(){ return *this->hbResult; } + }; + property SheetCheckerError ErrorCode + { + void set( SheetCheckerError code ){ this->hErrorCode = gcnew SheetCheckerError(code); } + SheetCheckerError get(){ return *this->hErrorCode; } + }; +}; + +// ’ñoŠm”F‘“à‚Ìî•ñ +ref class SheetItem +{ +private: + char *pGameCode; + System::Byte ^hRomVersion; + System::UInt16 ^hFileCRC; + System::Byte ^hSubmitVersion; +public: + SheetItem() + { + this->pGameCode = new char[4]; + std::memset( this->pGameCode, 0, 4 ); + this->hRomVersion = gcnew System::Byte(0xFF); + this->hFileCRC = gcnew System::UInt16(0); + this->hSubmitVersion = gcnew System::Byte(0xFF); + } + ~SheetItem() + { + delete []this->pGameCode; + } + property char* GameCode + { + void set( char* p ){ memcpy( this->pGameCode, p, 4 ); } + char* get(){ return this->pGameCode; } + } + property System::Byte RomVersion + { + void set( System::Byte v ){ *this->hRomVersion = v; } + System::Byte get(){ return *this->hRomVersion; } + } + property System::UInt16 FileCRC + { + void set( System::UInt16 v ){ *this->hFileCRC = v; } + System::UInt16 get(){ return *this->hFileCRC; } + } + property System::Byte SubmitVersion + { + void set( System::Byte v ){ *this->hSubmitVersion = v; } + System::Byte get(){ return *this->hSubmitVersion; } + } +}; diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.vcproj b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.vcproj new file mode 100644 index 0000000..a23ebc0 --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.vcproj @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.vcproj.RED.nishikawa_takeshi.user b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.vcproj.RED.nishikawa_takeshi.user new file mode 100644 index 0000000..7963a7f --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/SheetCheckerTWL.vcproj.RED.nishikawa_takeshi.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/app.ico b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/app.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/app.ico differ diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/app.rc b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/app.rc new file mode 100644 index 0000000..2ad8e34 --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/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/SheetCheckerTWL/SheetCheckerTWL/crc_whole.BAK b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/crc_whole.BAK new file mode 100644 index 0000000..a984cf5 --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/crc_whole.BAK @@ -0,0 +1,185 @@ +// crc_whole.h ‚ÌŽÀ‘• + +#include "stdafx.h" +#include +#include "common.h" +#include "crc_whole.h" +#include +#include + +#define CRCPOLY 0x1021 +#define BUFLEN 0x1000 + +namespace MasterEditorTWL +{ + u16 crc_table[0x100]; + + /*---------------------------------------------------------------------------- + ŠÖ”–¼ + inittable - initialize table + + Œ`Ž® + static void inittable(unsigned short *table); + + ‰ðà + CRCŽZo‚ð‚‘¬‰»‚·‚邽‚߂̎Qƃe[ƒuƒ‹‚ð쬂·‚éB + ----------------------------------------------------------------------------*/ + static void inittable(unsigned short *table) + { + unsigned short i, j, r; + + for(i = 0; i < 0x100; i++) { + r = i << 8; + for(j = 0; j < 8; j++) { + if(r & 0x8000U) + r = (r << 1) ^ CRCPOLY; + else + r <<= 1; + } + *table++ = r; + } + } + + /*============================================================================* + CRCŒvŽZ + »•i‹Zp•”‚ÌCRCƒe[ƒuƒ‹‚ðŽg‚Á‚½CRCŒvŽZŠÖ” + + ‹ô”ƒoƒCƒg‚ƊoƒCƒg‚ð“ü‚ê‘Ö‚¦‚Ä‚©‚çŒvŽZ‚·‚éB + *============================================================================*/ + static u16 newGetCRC + ( + u16 start, // CRC‰Šú’li—ÝÏ’lj + u16 *datap, // ƒf[ƒ^‚Ìæ“ª‚ðŽw‚·ƒ|ƒCƒ“ƒ^A’†“‡‚³‚ñ‚̂ƈႢAu8 + u32 size // ƒoƒCƒg’PˆÊ‚ł̃f[ƒ^ƒTƒCƒY + ) + { + u32 i; + u16 crc; + u8* byte; + + crc = start; + byte = (u8 *)datap; + + for (i=0; i> 8) ^ byte1]; + crc = (crc << 8) ^ crc_table[(crc >> 8) ^ byte0]; + } + + return crc; + } + + /*---------------------------------------------------------------------------* + + Name: getSeg3CRCInFp + + Description: Segment3(0x3000-0x3fff)‚ÌCRC‚ðŽZo + + Arguments: [in] srlƒtƒ@ƒCƒ‹‚̃tƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^ + [out] CRCŠi”[æ + + Return: ¬Œ÷‚È‚çTRUE. + + *---------------------------------------------------------------------------*/ + BOOL getSeg3CRCInFp( FILE *fp, u16 *pCRC ) + { + u16 crc; + u16 data[ 0x1000 / 2 ]; // 64KƒoƒCƒg(512Kƒrƒbƒg) + + if( !fp ) + { + return FALSE; + } + + // CRCƒe[ƒuƒ‹‰Šú‰»i»•i‹Zp•”‚̃R[ƒhj + inittable(crc_table); + + // 0x3000 ‚©‚ç 0x3fff ‚Ü‚Å‚Ì CRC ‚ð‚Æ‚é + fseek( fp, 0x3000, SEEK_SET ); + fread( (void*)data, sizeof(data), 1, fp ); + crc = newGetCRC( 0, data, sizeof(data) ); + *pCRC = crc; + + return TRUE; + } + + /*---------------------------------------------------------------------------* + + Name: getWholeCRCInFp + + Description: srlƒtƒ@ƒCƒ‹‘S‘Ì‚ÌCRC‚ðŽZo + + Arguments: [in] srlƒtƒ@ƒCƒ‹‚̃tƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^ + [out] CRCŠi”[æ + + Return: ¬Œ÷‚È‚çTRUE. + + *---------------------------------------------------------------------------*/ + BOOL getWholeCRCInFp( FILE *fp, u16 *pCRC ) + { + u32 file_size; + u16 crc; + u32 i; + u16 data[ 0x1000 / 2 ]; // 64KƒoƒCƒg(512Kƒrƒbƒg) + + if( !fp ) + { + return FALSE; + } + + // ƒtƒ@ƒCƒ‹ƒTƒCƒYƒ`ƒFƒbƒN + fseek( fp, 0, SEEK_END ); + file_size = ftell( fp ); + + // CRCƒe[ƒuƒ‹‰Šú‰»i»•i‹Zp•”‚̃R[ƒhj + inittable(crc_table); + + // ƒtƒ@ƒCƒ‹‘S‘Ì‚ÌCRC ‚ð‚Æ‚é + fseek( fp, 0, SEEK_SET ); + crc = 0; + for ( i=0; i +#include + +#define CRCPOLY 0x1021 +#define BUFLEN 0x1000 + +u16 crc_table[0x100]; + +/*---------------------------------------------------------------------------- + ŠÖ”–¼ + inittable - initialize table + + Œ`Ž® + static void inittable(unsigned short *table); + + ‰ðà + CRCŽZo‚ð‚‘¬‰»‚·‚邽‚߂̎Qƃe[ƒuƒ‹‚ð쬂·‚éB +----------------------------------------------------------------------------*/ +static void inittable(unsigned short *table) +{ + unsigned short i, j, r; + + for(i = 0; i < 0x100; i++) { + r = i << 8; + for(j = 0; j < 8; j++) { + if(r & 0x8000U) + r = (r << 1) ^ CRCPOLY; + else + r <<= 1; + } + *table++ = r; + } +} + +/*============================================================================* + CRCŒvŽZ + »•i‹Zp•”‚ÌCRCƒe[ƒuƒ‹‚ðŽg‚Á‚½CRCŒvŽZŠÖ” + + ‹ô”ƒoƒCƒg‚ƊoƒCƒg‚ð“ü‚ê‘Ö‚¦‚Ä‚©‚çŒvŽZ‚·‚éB + *============================================================================*/ +static u16 newGetCRC + ( + u16 start, // CRC‰Šú’li—ÝÏ’lj + u16 *datap, // ƒf[ƒ^‚Ìæ“ª‚ðŽw‚·ƒ|ƒCƒ“ƒ^A’†“‡‚³‚ñ‚̂ƈႢAu8 + u32 size // ƒoƒCƒg’PˆÊ‚ł̃f[ƒ^ƒTƒCƒY + ) +{ + u32 i; + u16 crc; + u8* byte; + + crc = start; + byte = (u8 *)datap; + + for (i=0; i> 8) ^ byte1]; + crc = (crc << 8) ^ crc_table[(crc >> 8) ^ byte0]; + } + + return crc; +} + +/*---------------------------------------------------------------------------* + + Name: getSeg3CRCInFp + + Description: Segment3(0x3000-0x3fff)‚ÌCRC‚ðŽZo + + Arguments: [in] srlƒtƒ@ƒCƒ‹‚̃tƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^ + [out] CRCŠi”[æ + + Return: ¬Œ÷‚È‚çTRUE. + + *---------------------------------------------------------------------------*/ +BOOL getSeg3CRCInFp( FILE *fp, u16 *pCRC ) +{ + u16 crc; + u16 data[ 0x1000 / 2 ]; // 64KƒoƒCƒg(512Kƒrƒbƒg) + + if( !fp ) + { + return FALSE; + } + + // CRCƒe[ƒuƒ‹‰Šú‰»i»•i‹Zp•”‚̃R[ƒhj + inittable(crc_table); + + // 0x3000 ‚©‚ç 0x3fff ‚Ü‚Å‚Ì CRC ‚ð‚Æ‚é + fseek( fp, 0x3000, SEEK_SET ); + fread( (void*)data, sizeof(data), 1, fp ); + crc = newGetCRC( 0, data, sizeof(data) ); + *pCRC = crc; + + return TRUE; +} + +/*---------------------------------------------------------------------------* + + Name: getWholeCRCInFp + + Description: srlƒtƒ@ƒCƒ‹‘S‘Ì‚ÌCRC‚ðŽZo + + Arguments: [in] srlƒtƒ@ƒCƒ‹‚̃tƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^ + [out] CRCŠi”[æ + + Return: ¬Œ÷‚È‚çTRUE. + + *---------------------------------------------------------------------------*/ +BOOL getWholeCRCInFp( FILE *fp, u16 *pCRC ) +{ + u32 file_size; + u16 crc; + u32 i; + u16 data[ 0x1000 / 2 ]; // 64KƒoƒCƒg(512Kƒrƒbƒg) + + if( !fp ) + { + return FALSE; + } + + // ƒtƒ@ƒCƒ‹ƒTƒCƒYƒ`ƒFƒbƒN + fseek( fp, 0, SEEK_END ); + file_size = ftell( fp ); + + // CRCƒe[ƒuƒ‹‰Šú‰»i»•i‹Zp•”‚̃R[ƒhj + inittable(crc_table); + + // ƒtƒ@ƒCƒ‹‘S‘Ì‚ÌCRC ‚ð‚Æ‚é + fseek( fp, 0, SEEK_SET ); + crc = 0; + for ( i=0; i +#include + +/*---------------------------------------------------------------------------* + + Name: getSeg3CRCInFp + + Description: Segment3(0x3000-0x3fff)‚ÌCRC‚ðŽZo + + Arguments: [in] srlƒtƒ@ƒCƒ‹‚̃tƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^ + [out] CRCŠi”[æ + + Return: ¬Œ÷‚È‚çTRUE. + + *---------------------------------------------------------------------------*/ +BOOL getSeg3CRCInFp( FILE *fp, u16 *pCRC ); + +/*---------------------------------------------------------------------------* + + Name: getWholeCRCInFp + + Description: srlƒtƒ@ƒCƒ‹‘S‘Ì‚ÌCRC‚ðŽZo + + Arguments: [in] srlƒtƒ@ƒCƒ‹‚̃tƒ@ƒCƒ‹ƒ|ƒCƒ“ƒ^ + [out] CRCŠi”[æ + + Return: ¬Œ÷‚È‚çTRUE. + + *---------------------------------------------------------------------------*/ +BOOL getWholeCRCInFp( FILE *fp, u16 *pCRC ); + +/*---------------------------------------------------------------------------* + + Name: getWholeCRCInFile + + Description: srlƒtƒ@ƒCƒ‹‘S‘Ì‚ÌCRC‚ðŽZo + + Arguments: [in] srlƒtƒ@ƒCƒ‹–¼(ŒÄ‚Ño‚µ‘O‚ɕ‚¶‚Ä‚¨‚­‚±‚Æ) + [out] CRCŠi”[æ + + Return: None. + + *---------------------------------------------------------------------------*/ +BOOL getWholeCRCInFile( System::String ^filename, u16 *pCRC ); + diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/resource.h b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/resource.h new file mode 100644 index 0000000..1f2251c --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/stdafx.cpp b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/stdafx.cpp new file mode 100644 index 0000000..325ceb4 --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : •W€ƒCƒ“ƒNƒ‹[ƒh SheetCheckerTWL.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/SheetCheckerTWL/SheetCheckerTWL/stdafx.h b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/stdafx.h new file mode 100644 index 0000000..d0e2c99 --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/SheetCheckerTWL/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 diff --git a/build/tools/MasterEditor/SheetCheckerTWL/extract_sheet.xsl b/build/tools/MasterEditor/SheetCheckerTWL/extract_sheet.xsl new file mode 100644 index 0000000..3859138 --- /dev/null +++ b/build/tools/MasterEditor/SheetCheckerTWL/extract_sheet.xsl @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +