Added some tests for interpreting Global Terminal data.

This commit is contained in:
Greg Edwards
2014-05-09 16:36:57 -04:00
parent 7d5dff9851
commit f98c71237d
8 changed files with 275 additions and 0 deletions

BIN
gts/Box Upload Xor Pad.bin Normal file

Binary file not shown.

View File

@@ -57,9 +57,11 @@
<ItemGroup>
<Content Include="AllPokemon.aspx" />
<Content Include="css\main.css" />
<Content Include="test\BoxUp.aspx" />
<Content Include="test\Decode.aspx" />
<Content Include="Default.aspx" />
<Content Include="Global.asax" />
<Content Include="test\RngTest.aspx" />
<Content Include="Web.config" />
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
@@ -76,6 +78,13 @@
<Compile Include="AllPokemon.aspx.designer.cs">
<DependentUpon>AllPokemon.aspx</DependentUpon>
</Compile>
<Compile Include="test\BoxUp.aspx.cs">
<DependentUpon>BoxUp.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="test\BoxUp.aspx.designer.cs">
<DependentUpon>BoxUp.aspx</DependentUpon>
</Compile>
<Compile Include="test\Decode.aspx.cs">
<DependentUpon>Decode.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -112,6 +121,13 @@
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="src\GtsSessionManager.cs" />
<Compile Include="test\RngTest.aspx.cs">
<DependentUpon>RngTest.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="test\RngTest.aspx.designer.cs">
<DependentUpon>RngTest.aspx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />

24
gts/test/BoxUp.aspx Normal file
View File

@@ -0,0 +1,24 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeBehind="BoxUp.aspx.cs" Inherits="PkmnFoundations.GTS.debug.BoxUp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cpHead" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMain" runat="server">
<form id="theForm" runat="server">
<div>
<p>Uplaod your Generation IV box upload, battle video, and dressup capture:</p>
<asp:FileUpload ID="fuBox" runat="server" />
&nbsp;Pad offset:
<asp:TextBox ID="txtOffset" runat="server" />
<asp:Button ID="btnSend" Text="Send" OnClick="btnSend_Click" runat="server" />
</div>
<asp:Literal ID="litMessage" runat="server" />
<asp:PlaceHolder ID="phDecoded" Visible="false" runat="server">
<div>
<div class="code">
<asp:Literal ID="litDecoded" runat="server" />
</div>
</div>
</asp:PlaceHolder>
</form>
</asp:Content>

60
gts/test/BoxUp.aspx.cs Normal file
View File

@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.IO;
namespace PkmnFoundations.GTS.debug
{
public partial class BoxUp : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
litMessage.Text = "";
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSend_Click(object sender, EventArgs e)
{
phDecoded.Visible = false;
byte[] data = fuBox.FileBytes;
FileStream s = File.Open(Server.MapPath("~/Box Upload Xor Pad.bin"), FileMode.Open);
byte[] pad = new byte[s.Length];
s.Read(pad, 0, pad.Length);
s.Close();
int padOffset = Convert.ToInt32(txtOffset.Text);
for (int x = 4; x < data.Length; x++)
{
data[x] ^= pad[(x + padOffset) % 256];
}
litDecoded.Text = RenderHex(data.ToHexStringLower());
phDecoded.Visible = true;
}
private String RenderHex(String hex)
{
StringBuilder builder = new StringBuilder();
for (int x = 0; x < hex.Length; x += 16)
{
if (x % 32 == 0)
{
builder.Append((x >> 1).ToString("x4"));
builder.Append(": ");
}
builder.Append(hex.Substring(x, Math.Min(16, hex.Length - x)));
builder.Append((x % 32 == 0) ? " " : "<br />");
}
return builder.ToString();
}
}
}

78
gts/test/BoxUp.aspx.designer.cs generated Normal file
View File

@@ -0,0 +1,78 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PkmnFoundations.GTS.debug {
public partial class BoxUp {
/// <summary>
/// theForm control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm theForm;
/// <summary>
/// fuBox control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.FileUpload fuBox;
/// <summary>
/// txtOffset control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtOffset;
/// <summary>
/// btnSend control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button btnSend;
/// <summary>
/// litMessage control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litMessage;
/// <summary>
/// phDecoded control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.PlaceHolder phDecoded;
/// <summary>
/// litDecoded control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litDecoded;
}
}

10
gts/test/RngTest.aspx Normal file
View File

@@ -0,0 +1,10 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeBehind="RngTest.aspx.cs" Inherits="PkmnFoundations.GTS.test.RngTest" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cpHead" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMain" runat="server">
<div class="code">
<asp:Literal ID="litRandom" runat="server" />
</div>
</asp:Content>

63
gts/test/RngTest.aspx.cs Normal file
View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
namespace PkmnFoundations.GTS.test
{
public partial class RngTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int seed = 0;
byte[] data = new byte[512];
for (int x = 0; x < data.Length; x++)
{
seed = Rng1(seed);
data[x] = (byte)((seed >> 8) & 0xff);
}
litRandom.Text = RenderHex(data.ToHexStringLower());
}
private String RenderHex(String hex)
{
StringBuilder builder = new StringBuilder();
for (int x = 0; x < hex.Length; x += 16)
{
if (x % 32 == 0)
{
builder.Append((x >> 1).ToString("x4"));
builder.Append(": ");
}
builder.Append(hex.Substring(x, Math.Min(16, hex.Length - x)));
builder.Append((x % 32 == 0) ? " " : "<br />");
}
return builder.ToString();
}
protected static int Rng1(int prev)
{
return (prev * 0x45 + 0x1111) & 0x7fffffff;
}
protected static int Rng2(int prev)
{
return (int)((0x41C64E6Du * (uint)prev) + 0x6073u);
}
protected static int Rng3(int prev)
{
return (int)((0x6C078965u * (uint)prev) + 0x1);
}
}
}

24
gts/test/RngTest.aspx.designer.cs generated Normal file
View File

@@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PkmnFoundations.GTS.test {
public partial class RngTest {
/// <summary>
/// litRandom control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litRandom;
}
}