提出確認書チェックツール:提出確認書とSRLの情報が一致するか調べるツール。提出バージョンの取得もできる。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@45 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
nishikawa_takeshi 2008-11-10 11:49:02 +00:00
parent 2e010d013a
commit f1ae04cfdf
21 changed files with 1333 additions and 0 deletions

View File

@ -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

View File

@ -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;
//
// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
// アセンブリに関連付けられている情報を変更するには、
// これらの属性値を変更してください。
//
[assembly:AssemblyTitleAttribute("SheetCheckerTWL")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("任天堂株式会社")];
[assembly:AssemblyProductAttribute("SheetCheckerTWL")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) 任天堂株式会社 2008")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// すべての値を指定するか、下のように '*' を使ってリビジョンおよびビルド番号を
// 既定値にすることができます:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];

View File

@ -0,0 +1,29 @@
===============================================================================
アプリケーション : SheetCheckerTWL プロジェクトの概要
===============================================================================
この SheetCheckerTWL アプリケーションは、AppWizard によって作成されました。
このファイルには、SheetCheckerTWL アプリケーションを構成する各ファイルの
内容の概略が記述されています。
SheetCheckerTWL.vcproj
これは、アプリケーション ウィザードで生成される VC++ プロジェクトのメインの
プロジェクト ファイルです。
ファイルを生成した Visual C++ のバージョン情報と、アプリケーション ウィザー
ドで選択したプラットフォーム、構成、およびプロジェクトの機能に関する情報が
記述されています。
SheetCheckerTWL.cpp
これは、メインのアプリケーション ソース ファイルです。
AssemblyInfo.cpp
アセンブリ メタデータを変更するためのカスタム属性が含まれています。
///////////////////////////////////////////////////////////////////////////////
その他のメモ :
AppWizard では、"TODO:" を使用して、ユーザーが追加またはカスタマイズするソース
部分を示します。
///////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,289 @@
// SheetCheckerTWL.cpp : メイン プロジェクト ファイルです。
#include "stdafx.h"
#include "SheetCheckerTWL.h"
#include "crc_whole.h"
#include <twl/types.h>
#include <twl/os/common/format_rom.h>
#include <cstdio>
using namespace System;
// ------------------------------------------------------------------
// 宣言
// ------------------------------------------------------------------
System::Int32 parseOption( array<System::String ^> ^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<System::String ^> ^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ヘッダの読み込み
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 );
// 提出確認書の読み込み
SheetItem ^hItem = gcnew SheetItem;
if( !readSheet( hSheetFile, hItem ) )
{
hContext->ErrorCode = SheetCheckerError::ERROR_READ_SHEET;
}
// 一致判定
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 );
}
}
// オプションのときの表示
if( hContext->bSubmitVersion )
{
if( hContext->ErrorCode == SheetCheckerError::NOERROR )
{
printf( "%d\n", hItem->SubmitVersion );
}
else
{
printf( "%d\n", hContext->ErrorCode ); // エラーのときはエラーコード
}
}
if( hContext->bResult )
{
printf( "%d\n", hContext->ErrorCode );
}
return 0;
}
// ------------------------------------------------------------------
// ROMヘッダの読み込み
// ------------------------------------------------------------------
System::Boolean readRomHeader( System::String ^srlfile, ROM_Header *rh )
{
FILE *fp = NULL;
const char *pchFilename =
(const char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( srlfile ).ToPointer();
// ファイルを開いてROMヘッダのみ読み出す
if( fopen_s( &fp, pchFilename, "rb" ) != NULL )
{
return false;
}
(void)fseek( fp, 0, SEEK_SET ); // ROMヘッダはsrlの先頭から
// 1バイトをsizeof(~)だけリード (逆だと返り値がsizeof(~)にならないので注意)
if( fread( (void*)rh, 1, sizeof(ROM_Header), fp ) != sizeof(ROM_Header) )
{
fclose( fp );
return false;
}
fclose( fp );
return true;
}
// ------------------------------------------------------------------
// 提出確認書の読み込み
// ------------------------------------------------------------------
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からデータを抽出
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; // 代入したらコピーするように property を定義している
text = getXPathText( root, "/Sheet/RomVersion" );
if( text->Contains( "(" ) ) // 事前版のときには"(事前版)"が入る
{
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 );
}
}
// 中間ファイルを削除
if( System::IO::File::Exists( tmpfile ) )
{
System::IO::File::Delete( tmpfile );
}
return true;
}
// ------------------------------------------------------------------
// getopt
// ------------------------------------------------------------------
// 返り値: オプションを除いたときのargc
System::Int32 parseOption( array<System::String ^> ^args, SheetCheckerContext ^context )
{
System::Collections::Generic::List<System::Int32> ^indexList
= gcnew System::Collections::Generic::List<System::Int32>;
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( "-" ) ) // オプションでない引数のindexを記録
{
indexList->Add(i);
}
}
i=0;
for each( System::Int32 index in indexList ) // オプションでない引数を前につめていく
{
args[i] = args[index];
i++;
}
return (args->Length - numopt);
}
// ------------------------------------------------------------------
// XMLタグ検索
// ------------------------------------------------------------------
// @ret テキストが存在するときそのテキストを返す。存在しないときnullptr。
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;
}

View File

@ -0,0 +1,94 @@
#pragma once
#include <cstdio>
#include <cstring>
// ------------------------------------------------------------------
// 構造体
// ------------------------------------------------------------------
// エラーコード
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,
};
// 実行Context
ref class SheetCheckerContext
{
private:
System::Boolean ^hbSubmitVersion; // オプションフラグ
System::Boolean ^hbResult;
SheetCheckerError ^hErrorCode; // エラー情報
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; }
};
};
// 提出確認書内の情報
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; }
}
};

View File

@ -0,0 +1,262 @@
<?xml version="1.0" encoding="shift_jis"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="SheetCheckerTWL"
ProjectGUID="{426F4BD7-3EEB-421A-87AB-697DF71DFB47}"
RootNamespace="SheetCheckerTWL"
Keyword="ManagedCProj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
ManagedExtensions="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="C:\twlsdk\include"
PreprocessorDefinitions="WIN32;_DEBUG"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
AssemblyDebug="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
ManagedExtensions="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="C:\twlsdk\include"
PreprocessorDefinitions="WIN32;NDEBUG"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
<AssemblyReference
RelativePath="System.dll"
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
<AssemblyReference
RelativePath="System.Data.dll"
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
MinFrameworkVersion="131072"
/>
<AssemblyReference
RelativePath="System.XML.dll"
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
</References>
<Files>
<Filter
Name="ソース ファイル"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\AssemblyInfo.cpp"
>
</File>
<File
RelativePath=".\crc_whole.cpp"
>
</File>
<File
RelativePath=".\SheetCheckerTWL.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="ヘッダー ファイル"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\crc_whole.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\SheetCheckerTWL.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
</Filter>
<Filter
Name="リソース ファイル"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\app.ico"
>
</File>
<File
RelativePath=".\app.rc"
>
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="shift_jis"?>
<VisualStudioUserFile
ProjectType="Visual C++"
Version="9.00"
ShowAllFiles="false"
>
<Configurations>
<Configuration
Name="Debug|Win32"
>
<DebugSettings
Command="$(TargetPath)"
WorkingDirectory=""
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="PC2355"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor=""
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
>
<DebugSettings
Command="$(TargetPath)"
WorkingDirectory=""
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="PC2355"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor=""
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
</Configurations>
</VisualStudioUserFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,63 @@
// Microsoft Visual C++ で生成されたリソース スクリプトです。
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// 英語 (米国) リソース
/////////////////////////////////////////////////////////////////////////////
//
// アイコン
//
// 最初に配置されたアイコン、または ID 値が最も低いアイコンが、アプリケーション アイコンになります。
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 リソースから生成されました。
//
/////////////////////////////////////////////////////////////////////////////
#endif // APSTUDIO_INVOKED でない場合

View File

@ -0,0 +1,185 @@
// crc_whole.h の実装
#include "stdafx.h"
#include <apptype.h>
#include "common.h"
#include "crc_whole.h"
#include <cstring>
#include <cstdio>
#define CRCPOLY 0x1021
#define BUFLEN 0x1000
namespace MasterEditorTWL
{
u16 crc_table[0x100];
/*----------------------------------------------------------------------------
関数名
inittable - initialize table
形式
static void inittable(unsigned short *table);
解説
CRC算出を高速化するための参照テーブルを作成する。
----------------------------------------------------------------------------*/
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計算
製品技術部のCRCテーブルを使ったCRC計算関数
偶数バイトと奇数バイトを入れ替えてから計算する。
*============================================================================*/
static u16 newGetCRC
(
u16 start, // CRC初期値累積値
u16 *datap, // データの先頭を指すポインタ、中島さんのと違い、u8
u32 size // バイト単位でのデータサイズ
)
{
u32 i;
u16 crc;
u8* byte;
crc = start;
byte = (u8 *)datap;
for (i=0; i<size; i+=2)
{
u8 byte0, byte1;
byte0 = *byte; byte++;
byte1 = *byte; byte++;
crc = (crc << 8) ^ crc_table[(crc >> 8) ^ byte1];
crc = (crc << 8) ^ crc_table[(crc >> 8) ^ byte0];
}
return crc;
}
/*---------------------------------------------------------------------------*
Name: getSeg3CRCInFp
Description: Segment3(0x3000-0x3fff)のCRCを算出
Arguments: [in] srlファイルのファイルポインタ
[out] CRC格納先
Return: 成功ならTRUE.
*---------------------------------------------------------------------------*/
BOOL getSeg3CRCInFp( FILE *fp, u16 *pCRC )
{
u16 crc;
u16 data[ 0x1000 / 2 ]; // 64Kバイト(512Kビット)
if( !fp )
{
return FALSE;
}
// CRCテーブル初期化製品技術部のコード
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ファイル全体のCRCを算出
Arguments: [in] srlファイルのファイルポインタ
[out] CRC格納先
Return: 成功ならTRUE.
*---------------------------------------------------------------------------*/
BOOL getWholeCRCInFp( FILE *fp, u16 *pCRC )
{
u32 file_size;
u16 crc;
u32 i;
u16 data[ 0x1000 / 2 ]; // 64Kバイト(512Kビット)
if( !fp )
{
return FALSE;
}
// ファイルサイズチェック
fseek( fp, 0, SEEK_END );
file_size = ftell( fp );
// CRCテーブル初期化製品技術部のコード
inittable(crc_table);
// ファイル全体のCRC をとる
fseek( fp, 0, SEEK_SET );
crc = 0;
for ( i=0; i<file_size; i+=sizeof(data) )
{
fread( (void*)data, sizeof(data), 1, fp );
crc = newGetCRC( crc, data, sizeof(data) );
}
*pCRC = crc;
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: getWholeCRCInFile
Description: srlファイル全体のCRCを算出
Arguments: [in] srlファイル名(呼び出し前に閉じておくこと)
[out] CRC格納先
Return: None.
*---------------------------------------------------------------------------*/
BOOL getWholeCRCInFile( System::String ^filename, u16 *pCRC )
{
FILE* fp;
const char *pchFilename =
(const char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( filename ).ToPointer();
fopen_s( &fp, pchFilename, "rb" );
if ( fp == NULL )
{
return FALSE;
}
getWholeCRCInFp( fp, pCRC );
fclose( fp );
return TRUE;
}
} // end of namespace MasterEditorTWL

View File

@ -0,0 +1,179 @@
// crc_whole.h の実装
#include "stdafx.h"
#include "crc_whole.h"
#include <cstring>
#include <cstdio>
#define CRCPOLY 0x1021
#define BUFLEN 0x1000
u16 crc_table[0x100];
/*----------------------------------------------------------------------------
inittable - initialize table
static void inittable(unsigned short *table);
CRC算出を高速化するための参照テーブルを作成する
----------------------------------------------------------------------------*/
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計算
CRCテーブルを使ったCRC計算関数
*============================================================================*/
static u16 newGetCRC
(
u16 start, // CRC初期値累積値
u16 *datap, // データの先頭を指すポインタ、中島さんのと違い、u8
u32 size // バイト単位でのデータサイズ
)
{
u32 i;
u16 crc;
u8* byte;
crc = start;
byte = (u8 *)datap;
for (i=0; i<size; i+=2)
{
u8 byte0, byte1;
byte0 = *byte; byte++;
byte1 = *byte; byte++;
crc = (crc << 8) ^ crc_table[(crc >> 8) ^ byte1];
crc = (crc << 8) ^ crc_table[(crc >> 8) ^ byte0];
}
return crc;
}
/*---------------------------------------------------------------------------*
Name: getSeg3CRCInFp
Description: Segment3(0x3000-0x3fff)CRCを算出
Arguments: [in] srlファイルのファイルポインタ
[out] CRC格納先
Return: TRUE.
*---------------------------------------------------------------------------*/
BOOL getSeg3CRCInFp( FILE *fp, u16 *pCRC )
{
u16 crc;
u16 data[ 0x1000 / 2 ]; // 64Kバイト(512Kビット)
if( !fp )
{
return FALSE;
}
// CRCテーブル初期化製品技術部のコード
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ファイル全体のCRCを算出
Arguments: [in] srlファイルのファイルポインタ
[out] CRC格納先
Return: TRUE.
*---------------------------------------------------------------------------*/
BOOL getWholeCRCInFp( FILE *fp, u16 *pCRC )
{
u32 file_size;
u16 crc;
u32 i;
u16 data[ 0x1000 / 2 ]; // 64Kバイト(512Kビット)
if( !fp )
{
return FALSE;
}
// ファイルサイズチェック
fseek( fp, 0, SEEK_END );
file_size = ftell( fp );
// CRCテーブル初期化製品技術部のコード
inittable(crc_table);
// ファイル全体のCRC をとる
fseek( fp, 0, SEEK_SET );
crc = 0;
for ( i=0; i<file_size; i+=sizeof(data) )
{
fread( (void*)data, sizeof(data), 1, fp );
crc = newGetCRC( crc, data, sizeof(data) );
}
*pCRC = crc;
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: getWholeCRCInFile
Description: srlファイル全体のCRCを算出
Arguments: [in] srlファイル名()
[out] CRC格納先
Return: None.
*---------------------------------------------------------------------------*/
BOOL getWholeCRCInFile( System::String ^filename, u16 *pCRC )
{
FILE* fp;
const char *pchFilename =
(const char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( filename ).ToPointer();
fopen_s( &fp, pchFilename, "rb" );
if ( fp == NULL )
{
return FALSE;
}
getWholeCRCInFp( fp, pCRC );
fclose( fp );
return TRUE;
}

View File

@ -0,0 +1,49 @@
#pragma once
// 署名用の鍵データの宣言
#include <twl/types.h>
#include <cstdio>
/*---------------------------------------------------------------------------*
Name: getSeg3CRCInFp
Description: Segment3(0x3000-0x3fff)CRCを算出
Arguments: [in] srlファイルのファイルポインタ
[out] CRC格納先
Return: TRUE.
*---------------------------------------------------------------------------*/
BOOL getSeg3CRCInFp( FILE *fp, u16 *pCRC );
/*---------------------------------------------------------------------------*
Name: getWholeCRCInFp
Description: srlファイル全体のCRCを算出
Arguments: [in] srlファイルのファイルポインタ
[out] CRC格納先
Return: TRUE.
*---------------------------------------------------------------------------*/
BOOL getWholeCRCInFp( FILE *fp, u16 *pCRC );
/*---------------------------------------------------------------------------*
Name: getWholeCRCInFile
Description: srlファイル全体のCRCを算出
Arguments: [in] srlファイル名()
[out] CRC格納先
Return: None.
*---------------------------------------------------------------------------*/
BOOL getWholeCRCInFile( System::String ^filename, u16 *pCRC );

View File

@ -0,0 +1,3 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc

View File

@ -0,0 +1,7 @@
// stdafx.cpp : 標準インクルード SheetCheckerTWL.pch のみを
// 含むソース ファイルは、プリコンパイル済みヘッダーになります。
// stdafx.obj にはプリコンパイル済み型情報が含まれます。
#include "stdafx.h"

View File

@ -0,0 +1,8 @@
// stdafx.h : 標準のシステム インクルード ファイルのインクルード ファイル、または
// 参照回数が多く、かつあまり変更されない、プロジェクト専用のインクルード ファイル
// を記述します。
//
#pragma once
// TODO: プログラムに必要な追加ヘッダーをここで参照してください。

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<xsl:template match="/">
<Sheet>
<xsl:apply-templates select="ss:Workbook/ss:Worksheet/ss:Table/ss:Row/ss:Cell" />
</Sheet>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates />
</xsl:template>
<!-- 特定のセルだけ抜き出して新たにタグづけする -->
<xsl:template match="ss:Cell">
<!-- NamedCellードの名前を変数に代入 -->
<xsl:variable name="tag">
<xsl:apply-templates select="ss:NamedCell" />
</xsl:variable>
<!-- NamedCellードの名前がSubmitVersionのときのみ出力 -->
<xsl:if test="$tag='SubmitVersion'">
<SubmitVersion><xsl:value-of select="ss:Data" /></SubmitVersion>
</xsl:if>
<xsl:if test="$tag='GameCode'">
<GameCode><xsl:value-of select="ss:Data" /></GameCode>
</xsl:if>
<xsl:if test="$tag='RomVersion'">
<RomVersion><xsl:value-of select="ss:Data" /></RomVersion>
</xsl:if>
<xsl:if test="$tag='CRC'">
<CRC><xsl:value-of select="ss:Data" /></CRC>
</xsl:if>
</xsl:template>
<!-- NamedCellードの名前(属性で指定されている)を取得 -->
<xsl:template match="ss:NamedCell">
<xsl:value-of select="@ss:Name" />
</xsl:template>
</xsl:stylesheet>