提出確認書チェッカ:新バージョン。GUI起動可能。GUIを起動せずにコンソール出力も可能。前バージョンのバグフィックス。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@52 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
nishikawa_takeshi 2008-11-14 06:26:16 +00:00
parent 3b0c79d14a
commit 0099945087
24 changed files with 2001 additions and 0 deletions

View File

@ -0,0 +1,43 @@
<?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:if test="$tag='Media'">
<Media><xsl:value-of select="ss:Data" /></Media>
</xsl:if>
</xsl:template>
<!-- NamedCellードの名前(属性で指定されている)を取得 -->
<xsl:template match="ss:NamedCell">
<xsl:value-of select="@ss:Name" />
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,43 @@
<?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:if test="$tag='Media'">
<Media><xsl:value-of select="ss:Data" /></Media>
</xsl:if>
</xsl:template>
<!-- NamedCellードの名前(属性で指定されている)を取得 -->
<xsl:template match="ss:NamedCell">
<xsl:value-of select="@ss:Name" />
</xsl:template>
</xsl:stylesheet>

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", "{43100A48-45C5-488A-AE74-0642E14043F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{43100A48-45C5-488A-AE74-0642E14043F2}.Debug|Win32.ActiveCfg = Debug|Win32
{43100A48-45C5-488A-AE74-0642E14043F2}.Debug|Win32.Build.0 = Debug|Win32
{43100A48-45C5-488A-AE74-0642E14043F2}.Release|Win32.ActiveCfg = Release|Win32
{43100A48-45C5-488A-AE74-0642E14043F2}.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,479 @@
#pragma once
#include "SheetCheckerTWL.h"
#include "crc_whole.h"
#include <twl/types.h>
#include <twl/os/common/format_rom.h>
#include <cstdio>
namespace SheetCheckerTWL {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Form1 の概要
///
/// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた
/// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを
/// 変更する必要があります。この変更を行わないと、
/// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、
/// 正しく相互に利用できなくなります。
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
private:
ROM_Header *rh;
SheetItem ^sheet;
System::UInt16 ^fileCRC;
SheetCheckerError ^error;
System::Boolean ^bReadSrl; // 一度でも読み込まれたらtrueにする
private: System::Windows::Forms::DataGridViewTextBoxColumn^ colTitle;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ colSrl;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ colSheet;
System::Boolean ^bReadSheet;
public:
Form1(void)
{
InitializeComponent();
//
//TODO: ここにコンストラクタ コードを追加します
//
this->rh = new ROM_Header();
this->sheet = gcnew SheetItem();
this->fileCRC = gcnew System::UInt16;
this->error = gcnew SheetCheckerError(SheetCheckerError::NOERROR);
this->bReadSrl = gcnew System::Boolean(false);
this->bReadSheet = gcnew System::Boolean(false);
memset( this->rh, 0, sizeof(ROM_Header) );
this->labVersion->Text = "ver. " + this->getVersion();
}
protected:
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
~Form1()
{
delete this->rh; // 忘れずに
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ labVersion;
private: System::Windows::Forms::TextBox^ tboxSrl;
private: System::Windows::Forms::TextBox^ tboxSheet;
private: System::Windows::Forms::Button^ butSrl;
private: System::Windows::Forms::Button^ butSheet;
private: System::Windows::Forms::DataGridView^ gridCompare;
private: System::Windows::Forms::TextBox^ tboxResult;
private: System::Windows::Forms::Label^ labResult;
private:
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
/// </summary>
void InitializeComponent(void)
{
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle17 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle18 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle19 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle20 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
this->tboxSrl = (gcnew System::Windows::Forms::TextBox());
this->tboxSheet = (gcnew System::Windows::Forms::TextBox());
this->butSrl = (gcnew System::Windows::Forms::Button());
this->butSheet = (gcnew System::Windows::Forms::Button());
this->gridCompare = (gcnew System::Windows::Forms::DataGridView());
this->tboxResult = (gcnew System::Windows::Forms::TextBox());
this->labResult = (gcnew System::Windows::Forms::Label());
this->labVersion = (gcnew System::Windows::Forms::Label());
this->colTitle = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->colSrl = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->colSheet = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->gridCompare))->BeginInit();
this->SuspendLayout();
//
// tboxSrl
//
this->tboxSrl->AllowDrop = true;
this->tboxSrl->Location = System::Drawing::Point(31, 32);
this->tboxSrl->Name = L"tboxSrl";
this->tboxSrl->ReadOnly = true;
this->tboxSrl->Size = System::Drawing::Size(250, 19);
this->tboxSrl->TabIndex = 0;
this->tboxSrl->DragDrop += gcnew System::Windows::Forms::DragEventHandler(this, &Form1::tboxSrl_DragDrop);
this->tboxSrl->DragEnter += gcnew System::Windows::Forms::DragEventHandler(this, &Form1::tboxSrl_DragEnter);
//
// tboxSheet
//
this->tboxSheet->AllowDrop = true;
this->tboxSheet->Location = System::Drawing::Point(31, 66);
this->tboxSheet->Name = L"tboxSheet";
this->tboxSheet->ReadOnly = true;
this->tboxSheet->Size = System::Drawing::Size(250, 19);
this->tboxSheet->TabIndex = 1;
this->tboxSheet->DragDrop += gcnew System::Windows::Forms::DragEventHandler(this, &Form1::tboxSheet_DragDrop);
this->tboxSheet->DragEnter += gcnew System::Windows::Forms::DragEventHandler(this, &Form1::tboxSheet_DragEnter);
//
// butSrl
//
this->butSrl->Location = System::Drawing::Point(287, 30);
this->butSrl->Name = L"butSrl";
this->butSrl->Size = System::Drawing::Size(107, 23);
this->butSrl->TabIndex = 4;
this->butSrl->Text = L"SRLを開く";
this->butSrl->UseVisualStyleBackColor = true;
this->butSrl->Click += gcnew System::EventHandler(this, &Form1::butSrl_Click);
//
// butSheet
//
this->butSheet->Location = System::Drawing::Point(287, 64);
this->butSheet->Name = L"butSheet";
this->butSheet->Size = System::Drawing::Size(107, 23);
this->butSheet->TabIndex = 5;
this->butSheet->Text = L"提出確認書を開く";
this->butSheet->UseVisualStyleBackColor = true;
this->butSheet->Click += gcnew System::EventHandler(this, &Form1::butSheet_Click);
//
// gridCompare
//
dataGridViewCellStyle17->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
dataGridViewCellStyle17->BackColor = System::Drawing::SystemColors::Control;
dataGridViewCellStyle17->Font = (gcnew System::Drawing::Font(L"MS UI Gothic", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(128)));
dataGridViewCellStyle17->ForeColor = System::Drawing::SystemColors::WindowText;
dataGridViewCellStyle17->SelectionBackColor = System::Drawing::SystemColors::Highlight;
dataGridViewCellStyle17->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
dataGridViewCellStyle17->WrapMode = System::Windows::Forms::DataGridViewTriState::True;
this->gridCompare->ColumnHeadersDefaultCellStyle = dataGridViewCellStyle17;
this->gridCompare->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->gridCompare->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(3) {this->colTitle,
this->colSrl, this->colSheet});
this->gridCompare->Location = System::Drawing::Point(31, 113);
this->gridCompare->Name = L"gridCompare";
this->gridCompare->RowHeadersVisible = false;
this->gridCompare->RowTemplate->Height = 21;
this->gridCompare->Size = System::Drawing::Size(363, 148);
this->gridCompare->TabIndex = 6;
//
// tboxResult
//
this->tboxResult->Location = System::Drawing::Point(294, 273);
this->tboxResult->Name = L"tboxResult";
this->tboxResult->ReadOnly = true;
this->tboxResult->Size = System::Drawing::Size(100, 19);
this->tboxResult->TabIndex = 7;
//
// labResult
//
this->labResult->AutoSize = true;
this->labResult->Location = System::Drawing::Point(235, 276);
this->labResult->Name = L"labResult";
this->labResult->Size = System::Drawing::Size(53, 12);
this->labResult->TabIndex = 8;
this->labResult->Text = L"判定結果";
//
// labVersion
//
this->labVersion->AutoSize = true;
this->labVersion->Location = System::Drawing::Point(353, 9);
this->labVersion->Name = L"labVersion";
this->labVersion->Size = System::Drawing::Size(41, 12);
this->labVersion->TabIndex = 9;
this->labVersion->Text = L"ver. 0.0";
//
// colTitle
//
dataGridViewCellStyle18->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
dataGridViewCellStyle18->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(224)),
static_cast<System::Int32>(static_cast<System::Byte>(224)), static_cast<System::Int32>(static_cast<System::Byte>(224)));
this->colTitle->DefaultCellStyle = dataGridViewCellStyle18;
this->colTitle->HeaderText = L"";
this->colTitle->Name = L"colTitle";
this->colTitle->Width = 120;
//
// colSrl
//
dataGridViewCellStyle19->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
this->colSrl->DefaultCellStyle = dataGridViewCellStyle19;
this->colSrl->HeaderText = L"SRL";
this->colSrl->Name = L"colSrl";
this->colSrl->Width = 120;
//
// colSheet
//
dataGridViewCellStyle20->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
this->colSheet->DefaultCellStyle = dataGridViewCellStyle20;
this->colSheet->HeaderText = L"提出確認書";
this->colSheet->Name = L"colSheet";
this->colSheet->Width = 120;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(428, 302);
this->Controls->Add(this->labVersion);
this->Controls->Add(this->labResult);
this->Controls->Add(this->tboxResult);
this->Controls->Add(this->gridCompare);
this->Controls->Add(this->butSheet);
this->Controls->Add(this->butSrl);
this->Controls->Add(this->tboxSheet);
this->Controls->Add(this->tboxSrl);
this->Name = L"Form1";
this->Text = L"TWL提出確認書チェッカー";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->gridCompare))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private:
// バージョン情報を取得
System::String^ getVersion( void )
{
System::Reflection::Assembly ^ass = System::Reflection::Assembly::GetEntryAssembly();
System::Version ^ver = ass->GetName()->Version;
return ( ver->Major.ToString() + "." + ver->Minor.ToString() );
}
private:
// 比較を表示して一致するか判定
void updateResult()
{
if( !(*this->bReadSrl) || !(*this->bReadSheet) ) // 両方とも読み込まないと判定しない
{
return;
}
// 一致するか判定
if( *this->error == SheetCheckerError::NOERROR )
{
*this->error = checkSheet( this->rh, *this->fileCRC, this->sheet );
}
// ひとつひとつgridに登録
System::String ^tmp1, ^tmp2; // grid には文字列で追加しなければならない
this->gridCompare->Rows->Clear();
System::Text::UTF8Encoding^ utf8 = gcnew System::Text::UTF8Encoding( true ); // char->String変換に必要
tmp1 = gcnew System::String( this->rh->s.game_code, 0, GAME_CODE_MAX, utf8 );
tmp2 = gcnew System::String( this->sheet->GameCode, 0, GAME_CODE_MAX, utf8 );
this->gridCompare->Rows->Add( "イニシャルコード", tmp1, tmp2 );
if( *this->error == SheetCheckerError::ERROR_VERIFY_GAME_CODE )
{
System::Int32 last = this->gridCompare->Rows->Count - 2; // 追加直後の行
this->gridCompare->Rows[ last ]->DefaultCellStyle->ForeColor = System::Drawing::Color::Red;
}
tmp1 = this->rh->s.rom_version.ToString( "X02" );
tmp2 = this->sheet->RomVersion.ToString( "X02" );
this->gridCompare->Rows->Add( "リマスターバージョン", tmp1, tmp2 );
if( *this->error == SheetCheckerError::ERROR_VERIFY_ROM_VERSION )
{
System::Int32 last = this->gridCompare->Rows->Count - 2;
this->gridCompare->Rows[ last ]->DefaultCellStyle->ForeColor = System::Drawing::Color::Red;
}
tmp1 = this->fileCRC->ToString( "X02" );
tmp2 = this->sheet->FileCRC.ToString( "X02" );
this->gridCompare->Rows->Add( "ファイル全体のCRC", tmp1, tmp2 );
if( *this->error == SheetCheckerError::ERROR_VERIFY_CRC )
{
System::Int32 last = this->gridCompare->Rows->Count - 2;
this->gridCompare->Rows[ last ]->DefaultCellStyle->ForeColor = System::Drawing::Color::Red;
}
tmp2 = this->sheet->SubmitVersion.ToString() + " (" + this->sheet->SubmitVersion.ToString( "X1" ) + ")";
this->gridCompare->Rows->Add( "提出バージョン", "-", tmp2 );
System::UInt16 tadver = sheet->RomVersion;
tadver = (tadver << 8) | sheet->SubmitVersion;
tmp2 = tadver.ToString() + " (" + tadver.ToString( "X04" ) + ")";
this->gridCompare->Rows->Add( "TADバージョン", "-", tmp2);
if( *this->error == SheetCheckerError::NOERROR )
{
this->tboxResult->Text = "OK";
}
else
{
int code = (int)(*this->error);
this->tboxResult->Text = "NG" + " (" + code.ToString() + ")";
}
}
private:
// ファイルをダイアログで取得
System::String ^prevDir; // 初期値はnullptr
System::String^ openFile( System::String ^filter ) // ファイルの拡張子フィルタを引数で指定
{
System::Windows::Forms::OpenFileDialog ^dlg = gcnew (OpenFileDialog);
if( System::String::IsNullOrEmpty( this->prevDir ) || !System::IO::Directory::Exists( this->prevDir ) )
{
dlg->InitialDirectory = System::Environment::GetFolderPath( System::Environment::SpecialFolder::Desktop );
}
else
{
dlg->InitialDirectory = this->prevDir; // 前に選んだディレクトリをデフォルトにする
}
dlg->Filter = filter;
dlg->FilterIndex = 1;
dlg->RestoreDirectory = true;
if( dlg->ShowDialog() != System::Windows::Forms::DialogResult::OK )
{
return nullptr;
}
this->prevDir = System::IO::Path::GetDirectoryName( dlg->FileName );
return dlg->FileName;
}
private:
// SRLを開く ボタンとドラッグアンドドロップの2種類があるためラップしておく
void openSrl( System::String ^filename )
{
if( !filename )
{
memset( this->rh, 0, sizeof(ROM_Header) );
this->tboxSrl->Text = "";
*this->fileCRC = 0;
*this->error = SheetCheckerError::ERROR_READ_SRL;
}
else
{
if( !readRomHeader( filename, this->rh ) )
{
memset( this->rh, 0, sizeof(ROM_Header) );
this->tboxSrl->Text = "";
*this->fileCRC = 0;
*this->error = SheetCheckerError::ERROR_READ_SRL;
}
else
{
this->tboxSrl->Text = System::IO::Path::GetFileName( filename );
u16 crc;
getWholeCRCInFile( filename, &crc );
*this->fileCRC = crc;
*this->bReadSrl = true; // 一度でも読み込んだらtrue
*this->error = SheetCheckerError::NOERROR;
}
}
this->updateResult();
}
private:
// 提出確認書を開く
void openSheet( System::String ^filename )
{
if( !filename )
{
this->tboxSheet->Text = "";
*this->error = SheetCheckerError::ERROR_READ_SHEET;
}
else
{
if( !readSheet( filename, this->sheet ) )
{
this->tboxSheet->Text = "";
*this->error = SheetCheckerError::ERROR_READ_SHEET;
}
else
{
this->tboxSheet->Text = System::IO::Path::GetFileName( filename );
*this->error = SheetCheckerError::NOERROR;
*this->bReadSheet = true;
}
}
this->updateResult();
}
private:
// SRLの読み込みボタン
System::Void butSrl_Click(System::Object^ sender, System::EventArgs^ e)
{
System::String ^filename = openFile( "srl format (*.srl)|*.srl|All files (*.*)|*.*" );
this->openSrl( filename );
}
private:
// 提出確認書の読み込みボタン
System::Void butSheet_Click(System::Object^ sender, System::EventArgs^ e)
{
System::String ^filename = openFile( "xml format (*.xml)|*.xml|All files (*.*)|*.*" );
this->openSheet( filename );
}
private:
// テキストボックスにドラッグされたとき
System::Void tboxSrl_DragEnter(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e)
{
if( e->Data->GetDataPresent( DataFormats::FileDrop ) )
{
e->Effect = DragDropEffects::All;
}
}
private:
// ドラッグしてボタンが離されたとき
System::Void tboxSrl_DragDrop(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e)
{
array<System::String^> ^files = dynamic_cast< array<System::String^> ^>(e->Data->GetData( DataFormats::FileDrop ));
System::String ^filename = files[0];
if( System::IO::File::Exists(filename) == false )
{
this->openSrl( nullptr ); // 失敗したときの処理は呼び出したメソッド内で実行
}
else
{
this->openSrl( filename );
}
}
private:
System::Void tboxSheet_DragEnter(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e)
{
if( e->Data->GetDataPresent( DataFormats::FileDrop ) )
{
e->Effect = DragDropEffects::All;
}
}
private:
System::Void tboxSheet_DragDrop(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e)
{
array<System::String^> ^files = dynamic_cast< array<System::String^> ^>(e->Data->GetData( DataFormats::FileDrop ));
System::String ^filename = files[0];
if( System::IO::File::Exists(filename) == false )
{
this->openSheet( nullptr );
}
else
{
this->openSheet( filename );
}
}
};
}

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="colTitle.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colSrl.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colSheet.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,34 @@
===============================================================================
アプリケーション : SheetCheckerTWL プロジェクトの概要
===============================================================================
この SheetCheckerTWL アプリケーションは、AppWizard によって作成されました。
このファイルには、SheetCheckerTWL アプリケーションを構成する各ファイルの
内容の概略が記述されています。
SheetCheckerTWL.vcproj
これは、アプリケーション ウィザードで生成される VC++ プロジェクトのメインの
プロジェクト ファイルです。
ファイルを生成した Visual C++ のバージョン情報と、アプリケーション ウィザー
ドで選択したプラットフォーム、構成、およびプロジェクトの機能に関する情報が
記述されています。
SheetCheckerTWL.cpp
これは、メインのアプリケーション ソース ファイルです。
フォームを表示するコードが含まれています。
Form1.h
ユーザーのフォーム クラスの実装と、InitializeComponent() 関数が含まれています。
AssemblyInfo.cpp
アセンブリ メタデータを変更するためのカスタム属性が含まれています。
///////////////////////////////////////////////////////////////////////////////
その他の標準ファイル :
StdAfx.h, StdAfx.cpp
これらのファイルは、コンパイル済みヘッダー (PCH) ファイル SheetCheckerTWL.pch
とプリコンパイル済み型ファイル StdAfx.obj をビルドするために使用します。
///////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,377 @@
// 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>
#include "Form1.h"
using namespace SheetCheckerTWL;
// ------------------------------------------------------------------
// 宣言
// ------------------------------------------------------------------
System::Int32 parseOption( array<System::String ^> ^args, SheetCheckerContext ^context );
int printResult( SheetCheckerContext ^context, ROM_Header *rh, SheetItem ^item,
System::String ^srlfile, System::String ^sheetfile, System::UInt16 srlcrc );
int consoleRun( array<System::String ^> ^args, int argc, SheetCheckerContext ^hContext );
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
SheetCheckerContext ^hContext = gcnew SheetCheckerContext;
// getopt
int argc = parseOption( args, hContext );
if( argc > 0 )
{
int ret = consoleRun( args, argc, hContext );
return ret;
}
// コントロールが作成される前に、Windows XP ビジュアル効果を有効にします
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// メイン ウィンドウを作成して、実行します
Application::Run(gcnew Form1());
return 0;
}
// ------------------------------------------------------------------
// コンソール処理
// ------------------------------------------------------------------
int consoleRun( array<System::String ^> ^args, int argc, SheetCheckerContext ^hContext )
{
ROM_Header rh;
memset( (void*)&rh, 0, sizeof(ROM_Header) );
SheetItem ^hItem = gcnew SheetItem;
// 引数処理
if( argc != 2 )
{
hContext->ErrorCode = SheetCheckerError::ERROR_ARG;
printResult( hContext, &rh, hItem, nullptr, nullptr, 0 );
return -1;
}
System::String ^hSrlFile = args[0];
System::String ^hSheetFile = args[1];
// ROMヘッダの読み込み
if( !readRomHeader( hSrlFile, &rh ) )
{
hContext->ErrorCode = SheetCheckerError::ERROR_READ_SRL;
printResult( hContext, &rh, hItem, hSrlFile, hSheetFile, 0 );
return -1;
}
System::UInt16 crc;
getWholeCRCInFile( hSrlFile, &crc );
// 提出確認書の読み込み
if( !readSheet( hSheetFile, hItem ) )
{
hContext->ErrorCode = SheetCheckerError::ERROR_READ_SHEET;
printResult( hContext, &rh, hItem, hSrlFile, hSheetFile, crc );
return -1;
}
// 一致判定
hContext->ErrorCode = checkSheet( &rh, crc, hItem );
// 結果表示
int ret = printResult( hContext, &rh, hItem, hSrlFile, hSheetFile, crc );
return ret;
}
// ------------------------------------------------------------------
// 一致判定
// ------------------------------------------------------------------
SheetCheckerError checkSheet( ROM_Header *rh, System::UInt16 crc, SheetItem ^item )
{
SheetCheckerError error;
if( memcmp( rh->s.game_code, item->GameCode, 4 ) != 0 )
{
error = SheetCheckerError::ERROR_VERIFY_GAME_CODE;
}
else if( rh->s.rom_version != item->RomVersion )
{
error = SheetCheckerError::ERROR_VERIFY_ROM_VERSION;
}
else if( crc != item->FileCRC )
{
error = SheetCheckerError::ERROR_VERIFY_CRC;
}
else
{
error = SheetCheckerError::NOERROR;
}
return error;
}
// ------------------------------------------------------------------
// 結果表示
// ------------------------------------------------------------------
int printResult( SheetCheckerContext ^context, ROM_Header *rh, SheetItem ^item,
System::String ^srlfile, System::String ^sheetfile, System::UInt16 srlcrc )
{
System::UInt16 tadver = item->RomVersion;
tadver = (tadver << 8) | item->SubmitVersion;
// 通常の表示
if( !context->bSubmitVersion && !context->bResult && !context->bTadVersion )
{
Console::WriteLine( "" );
Console::WriteLine( "SRL: " + srlfile );
Console::WriteLine( "Sheet: " + sheetfile );
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],
item->GameCode[0], item->GameCode[1], item->GameCode[2], item->GameCode[3] );
printf( "RemasterVersion: %02X %02X\n", rh->s.rom_version, item->RomVersion );
printf( "File CRC: %04X %04X\n", srlcrc, item->FileCRC );
printf( "---------------------------------------\n" );
printf( "SubmitVersion: - %d (%02X)\n", item->SubmitVersion, item->SubmitVersion );
printf( "TAD Version: %d (%04X)\n", tadver, tadver );
printf( "---------------------------------------\n" );
printf( "Result: " );
if( context->ErrorCode == SheetCheckerError::NOERROR )
{
printf( "OK\n" );
}
else
{
printf( "NG (%d)\n", context->ErrorCode );
}
}
// オプションのときの表示
if( context->bSubmitVersion )
{
if( context->ErrorCode == SheetCheckerError::NOERROR )
{
printf( "%d", item->SubmitVersion );
}
else
{
printf( "%d", context->ErrorCode ); // エラーのときはエラーコード
}
}
if( context->bTadVersion )
{
if( context->ErrorCode == SheetCheckerError::NOERROR )
{
printf( "%d", tadver );
}
else
{
printf( "%d", context->ErrorCode );
}
}
if( context->bResult )
{
printf( "%d", context->ErrorCode );
}
if( context->ErrorCode != SheetCheckerError::NOERROR )
{
return -1;
}
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;
System::String ^xslpath = System::IO::Path::GetDirectoryName( System::Reflection::Assembly::GetEntryAssembly()->Location )
+ "\\extract_sheet.xsl";
try
{
//Console::WriteLine( "xslpath: " + xslpath );
xslt->Load( xslpath );
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;
//Console::WriteLine( "Load error" );
return false;
}
// XMLからデータを抽出
System::Xml::XmlElement ^root = doc->DocumentElement;
System::String ^text;
try
{
item->Media = getXPathText( root, "/Sheet/Media" );
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("(") );
}
text = text->Trim();
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 - 'G' + 16;
}
else if( ('g' <= c) && (c <= 'z') )
{
item->SubmitVersion = c - 'g' + 16;
}
else
{
item->SubmitVersion = System::Byte::Parse( text, System::Globalization::NumberStyles::AllowHexSpecifier );
}
}
catch( System::Exception ^ex )
{
(void)ex;
return false;
}
// 中間ファイルを削除
if( System::IO::File::Exists( tmpfile ) )
{
System::IO::File::Delete( tmpfile );
}
return true;
}
// ------------------------------------------------------------------
// getopt
// ------------------------------------------------------------------
// @ret オプションを除いたときの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( "-t" ) )
{
context->bTadVersion = true;
numopt++;
}
else if( args[i]->StartsWith( "-c" ) )
{
context->bConsole = 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,135 @@
#pragma once
#include <cstdio>
#include <cstring>
#include <twl/types.h>
#include <twl/os/common/format_rom.h>
// ------------------------------------------------------------------
// 構造体
// ------------------------------------------------------------------
// エラーコード
enum class SheetCheckerError
{
NOERROR = 0,
ERROR_VERIFY_GAME_CODE = -1,
ERROR_VERIFY_ROM_VERSION = -2,
ERROR_VERIFY_CRC = -3,
ERROR_READ_SRL = -8,
ERROR_READ_SHEET = -9,
ERROR_ARG = -10,
};
// 実行Context
ref class SheetCheckerContext
{
private:
System::Boolean ^hbSubmitVersion; // オプションフラグ
System::Boolean ^hbResult;
System::Boolean ^hbTadVersion;
System::Boolean ^hbConsole;
SheetCheckerError ^hErrorCode; // エラー情報
public:
SheetCheckerContext()
{
this->hbSubmitVersion = gcnew System::Boolean(false);
this->hbResult = gcnew System::Boolean(false);
this->hbTadVersion = gcnew System::Boolean(false);
this->hbConsole = 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 System::Boolean bTadVersion
{
void set( System::Boolean flg ){ this->hbTadVersion = gcnew System::Boolean(flg); }
System::Boolean get(){ return *this->hbTadVersion; }
};
property System::Boolean bConsole
{
void set( System::Boolean flg ){ this->hbConsole = gcnew System::Boolean(flg); }
System::Boolean get(){ return *this->hbConsole; }
};
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:
System::String ^hMedia;
public:
SheetItem()
{
this->pGameCode = new char[4];
std::memset( this->pGameCode, 0, 4 );
this->hRomVersion = gcnew System::Byte(0);
this->hFileCRC = gcnew System::UInt16(0);
this->hSubmitVersion = gcnew System::Byte(0);
this->hMedia = gcnew System::String("");
}
~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; }
}
property System::String ^Media
{
void set( System::String ^str )
{
if( str != nullptr )
this->hMedia = System::String::Copy(str);
else
this->hMedia = gcnew System::String("");
}
System::String^ get(){ return System::String::Copy( this->hMedia ); }
}
};
// ------------------------------------------------------------------
// utlity functions
// ------------------------------------------------------------------
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 );
SheetCheckerError checkSheet( ROM_Header *rh, System::UInt16 crc, SheetItem ^item );
// eof

View File

@ -0,0 +1,286 @@
<?xml version="1.0" encoding="shift_jis"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="SheetCheckerTWL"
ProjectGUID="{43100A48-45C5-488A-AE74-0642E14043F2}"
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="2"
>
<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"
SubSystem="1"
EntryPointSymbol="main"
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="2"
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"
SubSystem="1"
EntryPointSymbol="main"
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.Drawing.dll"
AssemblyName="System.Drawing, Version=2.0.0.0, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
<AssemblyReference
RelativePath="System.Windows.Forms.dll"
AssemblyName="System.Windows.Forms, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
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=".\Form1.h"
FileType="3"
>
<File
RelativePath=".\Form1.resX"
SubType="Designer"
>
</File>
</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,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,6 @@
// stdafx.h : 標準のシステム インクルード ファイルのインクルード ファイル、または
// 参照回数が多く、かつあまり変更されない、プロジェクト専用のインクルード ファイル
// を記述します。
#pragma once
// TODO: プログラムに必要な追加ヘッダーをここで参照してください。

View File

@ -0,0 +1,43 @@
<?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:if test="$tag='Media'">
<Media><xsl:value-of select="ss:Data" /></Media>
</xsl:if>
</xsl:template>
<!-- NamedCellードの名前(属性で指定されている)を取得 -->
<xsl:template match="ss:NamedCell">
<xsl:value-of select="@ss:Name" />
</xsl:template>
</xsl:stylesheet>