Merge pull request #13 from PhoenixBound/master

Tool-related changes
This commit is contained in:
jeffman 2018-04-04 22:12:47 -04:00 committed by GitHub
commit 2be6d41d41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 20 deletions

View File

@ -11,6 +11,8 @@ namespace ScriptTool
{
private static int[] virtualWidths;
private static int[] renderWidths;
private static int[] virtualWidthsSaturn;
private static int[] renderWidthsSaturn;
public IEnumerable<IControlCode> ControlCodes { get; set; }
public Dictionary<string, int> AddressMap { get; set; }
@ -19,13 +21,18 @@ namespace ScriptTool
static Compiler()
{
byte[] widths = File.ReadAllBytes("m2-widths-main.bin");
byte[] saturnWidths = File.ReadAllBytes("m2-widths-saturn.bin");
virtualWidths = new int[widths.Length / 2];
renderWidths = new int[widths.Length / 2];
virtualWidthsSaturn = new int[saturnWidths.Length / 2];
renderWidthsSaturn = new int[saturnWidths.Length / 2];
for (int i = 0; i < widths.Length; i += 2)
{
virtualWidths[i / 2] = widths[i];
renderWidths[i / 2] = widths[i + 1];
virtualWidthsSaturn[i / 2] = saturnWidths[i];
renderWidthsSaturn[i / 2] = saturnWidths[i + 1];
}
}
@ -312,6 +319,7 @@ namespace ScriptTool
var sb = new StringBuilder();
widths = new List<int>();
int currentWidth = 0;
bool useSaturnWidths = false;
var strings = new List<string>();
@ -382,15 +390,20 @@ namespace ScriptTool
case 0x11:
case 0x12:
case 0x15:
case 0x1A:
case 0x2D:
case 0x9F:
case 0xAD:
// Name/item code
// Name code
sb.Append("[NAME]");
currentWidth += 60;
break;
case 0x1A:
// Name (60/96) or item (80/??) or number (36/72).
sb.Append("[NAME]");
currentWidth += 80;
break;
case 0x0:
case 0x1:
case 0x2:
@ -403,12 +416,12 @@ namespace ScriptTool
break;
case 0x20:
sb.Append("[SMAAASH]");
sb.Append("[SMAAAASH!!]");
currentWidth += 72;
break;
case 0x21:
sb.Append("[YOU WIN]");
sb.Append("[YOU WON!]");
currentWidth += 72;
break;
@ -432,11 +445,18 @@ namespace ScriptTool
currentWidth += 18;
break;
case 0x1E:
case 0x1F:
sb.Append("_");
currentWidth += 10;
break;
case 0x7B:
useSaturnWidths = true;
break;
case 0x7C:
useSaturnWidths = false;
break;
}
}
}
@ -458,7 +478,8 @@ namespace ScriptTool
if (!(str[i] == '\r') && !(str[i] == '\n'))
{
sb.Append(str[i]);
currentWidth += virtualWidths[GetByte(str[i], charLookup) - 0x50];
int v = GetByte(str[i], charLookup) - 0x50;
currentWidth += useSaturnWidths ? virtualWidthsSaturn[v] : virtualWidths[v];
}
i++;
}

View File

@ -90,6 +90,9 @@
<None Include="m2-widths-main.bin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="m2-widths-saturn.bin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

View File

@ -57,17 +57,17 @@
},
{
"Identifier": 0xE,
"Description": "Paula's name (1C 02 02)",
"Description": "Paula's name (1C 02 02 or 1C 01 1E)",
"Length": 2
},
{
"Identifier": 0xF,
"Description": "Jeff's name (1C 02 03)",
"Description": "Jeff's name (1C 02 03 or 1C 01 34)",
"Length": 2
},
{
"Identifier": 0x10,
"Description": "Poo's name (1C 02 04)",
"Description": "Poo's name (1C 02 04 or 1C 01 4A)",
"Length": 2
},
{
@ -87,7 +87,7 @@
},
{
"Identifier": 0x15,
"Description": "King's name (1C 02 07)",
"Description": "King's name (1C 02 07 or 1C 01 03)",
"Length": 2
},
{
@ -102,7 +102,7 @@
},
{
"Identifier": 0x1A,
"Description": "Display string {0:X}? (Appears after 90 FF)",
"Description": "Display string in string slot as kind {0:X} (Appears after 90 FF)",
"Length": 4
},
{
@ -112,7 +112,7 @@
},
{
"Identifier": 0x1C,
"Description": "If flag {0:X} is set, jump to offset {1:X} and return (06)",
"Description": "If flag {0:X} is set, jump to offset {1:X} and don't return (06)",
"Length": 8,
"HasReferences": true,
"ReferenceOffset": 4
@ -144,7 +144,7 @@
},
{
"Identifier": 0x22,
"Description": "Unknown",
"Description": "Wait with prompt, even in battle (14, sometimes used in place of 03)",
"Length": 2
},
{
@ -463,7 +463,7 @@
},
{
"Identifier": 0x90,
"Description": "Load character/item name {0:X} into memory (?)",
"Description": "Store {0:X} to string slot (for 1A FF printing). If 00, store argumentary memory to string slot.",
"Length": 3
},
{
@ -596,12 +596,12 @@
},
{
"Identifier": 0xA9,
"Description": "Unknown (1F EA, values don't match)",
"Description": "Apply 'cutscene' visual/sound FX associated with sprite {0:X}? (1F EA, values don't match)",
"Length": 4
},
{
"Identifier": 0xAA,
"Description": "Unknown (1F E7, values don't match)",
"Description": "Apply 'cutscene' visual/sound FX associated with A0 FF-generate sprite {0:X}? (1F E7, values don't match)",
"Length": 4
},
{
@ -753,7 +753,7 @@
},
{
"Identifier": 0xC8,
"Description": "Number selector with {0:X} digits (1F 52)",
"Description": "Number selector with {0:X} digits and {1:X} style (1F 52)",
"Length": 4
},
{

Binary file not shown.

View File

@ -303,6 +303,7 @@
this.ebString.Location = new System.Drawing.Point(3, 4);
this.ebString.Multiline = true;
this.ebString.Name = "ebString";
this.ebString.ReadOnly = true;
this.ebString.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.ebString.Size = new System.Drawing.Size(786, 128);
this.ebString.TabIndex = 9;
@ -315,6 +316,7 @@
this.m12String.Location = new System.Drawing.Point(3, 138);
this.m12String.Multiline = true;
this.m12String.Name = "m12String";
this.m12String.ReadOnly = true;
this.m12String.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.m12String.Size = new System.Drawing.Size(786, 128);
this.m12String.TabIndex = 10;

View File

@ -365,7 +365,7 @@ namespace ScriptToolGui
}
else
{
m12String.BackColor = Color.White;
m12String.BackColor = SystemColors.Control;
}
}
@ -459,12 +459,12 @@ namespace ScriptToolGui
}
else
{
m12String.BackColor = Color.White;
m12String.BackColor = SystemColors.Control;
}
}
else
{
m12String.BackColor = Color.White;
m12String.BackColor = SystemColors.Control;
}
previousNavigationState = new ReferenceNavigationEntry(game, label);

BIN
m2-widths-saturn.bin Normal file

Binary file not shown.