Properly integrate pre-rendering tool with other tools + names complete list + expand fonts

This commit is contained in:
Lorenzo Carletti 2020-08-24 00:51:59 +02:00
parent 07ab2d7b46
commit 75598e7eb3
27 changed files with 327 additions and 163 deletions

View File

@ -3,3 +3,5 @@ $pwd = $pwd.Path
& dotnet build tools/ScriptTool -o "$([IO.Path]::Combine($pwd, "bin/ScriptTool"))"
if ($LASTEXITCODE -ne 0) { exit -1 }
& dotnet build tools/RenderCastRoll -o "$([IO.Path]::Combine($pwd, "bin/RenderCastRoll"))"
if ($LASTEXITCODE -ne 0) { exit -1 }

View File

@ -6,6 +6,8 @@ $output_rom_file = "bin/m12.gba"
$eb_rom_file = "bin/eb.smc"
$working_dir = "working"
$src_dir = "src"
$data_dir = "src/data"
$cast_roll_file = "working/cast_roll.json"
$compiled_asm_file = "src/m2-compiled.asm"
$includes_asm_file = "m12-includes.asm" # implicitly rooted in working_dir
$hack_asm_file = "m2-hack.asm" # implicitly rooted in src_dir
@ -24,6 +26,7 @@ $input_c_files =
$base_c_address = 0x83755B8;
$scripttool_cmd = "bin/ScriptTool/ScriptTool.dll"
$rendercastroll_cmd= "bin/RenderCastRoll/RenderCastRoll.dll"
$gcc_cmd = "arm-none-eabi-gcc"
$ld_cmd = "arm-none-eabi-ld"
$objdump_cmd = "arm-none-eabi-objdump"
@ -48,6 +51,10 @@ $scripttool_args =
$working_dir,
$eb_rom_file,
$input_rom_file
$rendercastroll_args =
$cast_roll_file,
$data_dir
$gcc_args =
"-c",
@ -348,6 +355,10 @@ Copy-Item -Path $input_rom_file -Destination $output_rom_file
& dotnet $scripttool_cmd $scripttool_args
if ($LASTEXITCODE -ne 0) { exit -1 }
"Pre-rendering cast roll..."
& dotnet $rendercastroll_cmd $rendercastroll_args
if ($LASTEXITCODE -ne 0) { exit -1 }
# ------------------------ ASSEMBLE GAME TEXT -----------------------
"Assembling game text..."
& $asm_cmd -root $working_dir -sym $includes_sym_file $includes_asm_file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,22 +0,0 @@
{
"Renders":[
{
"Y":10,
"Center_X":10,
"Text":"This is a test...",
"Font": 0
},
{
"Y":12,
"Center_X":10,
"Text":"This is a test2...",
"Font": 0
},
{
"Y":16,
"Center_X":30,
"Text":"\"",
"Font": 0
}
]
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

View File

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace RenderCastRoll

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections.Generic;
namespace GBA
{

View File

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace RenderCastRoll
@ -74,10 +71,8 @@ namespace RenderCastRoll
{
int pos = buffers[i].startPos + 1 + (renders[i].Y * 0x20); //The + 1 is here because the scene's map starts from tile 1. Not tile 0
for (int j = 0; j < buffers[i].used; j++)
{
Arrangements[pos + j] = buffers[i].arrangements[0, j];
Arrangements[pos + 0x20 + j] = buffers[i].arrangements[1, j];
}
for(int k = 0; k < WritingBuffer.yLength; k++)
Arrangements[pos + j + (k * 0x20)] = buffers[i].arrangements[k, j];
}
//Convert the 1bpp tiles to 4bpp
@ -128,12 +123,9 @@ namespace RenderCastRoll
for (int i = 0; i < buf.used; i++)
{
for (int j = 0; j < 2; j++)
for (int j = 0; j < WritingBuffer.yLength; j++)
{
_1bppTile tile = buf.tiles[j, i];
_1bppTile rotatedXTile = null;
_1bppTile rotatedYTile = null;
_1bppTile rotatedXYTile = null;
int rot = 0;
int pos = -1;
@ -145,20 +137,17 @@ namespace RenderCastRoll
if (pos == -1)
{
rot = 1;
rotatedXTile = tile.rotateX();
pos = getPosInFinal(rotatedXTile, total, _1bppGraphics_RotX);
pos = getPosInFinal(tile, total, _1bppGraphics_RotX);
if (pos == -1)
{
rot = 2;
rotatedYTile = tile.rotateY();
pos = getPosInFinal(rotatedYTile, total, _1bppGraphics_RotY);
pos = getPosInFinal(tile, total, _1bppGraphics_RotY);
if (pos == -1)
{
rotatedXYTile = rotatedXTile.rotateY();
rot = 3;
pos = getPosInFinal(rotatedXYTile, total, _1bppGraphics_RotXY);
pos = getPosInFinal(tile, total, _1bppGraphics_RotXY);
}
}
}
@ -168,9 +157,9 @@ namespace RenderCastRoll
rot = 0;
pos = total++;
_1bppGraphics[pos] = tile; //If we're here, we already calculated all four of them
_1bppGraphics_RotX[pos] = rotatedXTile;
_1bppGraphics_RotY[pos] = rotatedYTile;
_1bppGraphics_RotXY[pos] = rotatedXYTile;
_1bppGraphics_RotX[pos] = tile.rotateX();
_1bppGraphics_RotY[pos] = tile.rotateY();
_1bppGraphics_RotXY[pos] = _1bppGraphics_RotX[pos].rotateY();
}
buf.arrangements[j, i] = (ushort)(Palette | (pos + arrStart) | (rot << 0xA));
@ -218,26 +207,41 @@ namespace RenderCastRoll
int tileX = x >> 3;
int chrPos = chr * tileWidth * tileHeight * 8;
int offsetX = x & 7;
int startOffsetY = 3 & 7;
byte vWidth = Fonts[font].fontWidth[chr * 2];
byte rWidth = Fonts[font].fontWidth[(chr * 2) + 1];
if (font == 1 && vWidth != rWidth) //The Saturn font is compressed horizontally by removing 1 trailing pixel
vWidth -= 1;
for(int dTileY = 0; dTileY < tileHeight; dTileY++)
{
int dTileX = 0;
int renderedWidth = rWidth;
while (renderedWidth > 0)
{
int offsetY = startOffsetY & 7;
int tileIndexX = tileX + dTileX;
int tileIndexY = dTileY;
_1bppTile leftTile = buf.tiles[dTileY, tileIndexX];
_1bppTile rightTile = buf.tiles[dTileY, tileIndexX + 1];
for (int row = 0; row < 8; row++)
{
ushort canvasRow = (ushort)(leftTile.getRow(row) | (rightTile.getRow(row) << 8));
ushort canvasRow = (ushort)(leftTile.getRow(row + offsetY) | (rightTile.getRow(row + offsetY) << 8));
ushort glyphRow = (ushort)(Fonts[font].font[chrPos + row + (((dTileY * tileWidth) + dTileX) * 8)] << offsetX);
canvasRow |= glyphRow;
leftTile.setRow(row, (byte)(canvasRow & 0xFF));
rightTile.setRow(row, (byte)((canvasRow >> 8) & 0xFF));
leftTile.setRow(row + offsetY, (byte)(canvasRow & 0xFF));
rightTile.setRow(row + offsetY, (byte)((canvasRow >> 8) & 0xFF));
if(row != 7 && row + offsetY == 7)
{
offsetY = -(row + 1);
tileIndexY++;
leftTile = buf.tiles[tileIndexY, tileIndexX];
rightTile = buf.tiles[tileIndexY, tileIndexX + 1];
}
}
renderedWidth -= 8;
@ -271,7 +275,11 @@ namespace RenderCastRoll
{
int len = 0;
for (int i = 0; i < text.Length; i++)
len += Fonts[Font].fontWidth[2 * text[i]];
{
len += Fonts[Font].fontWidth[2 * text[i]];
if (Font == 1 && Fonts[Font].fontWidth[2 * text[i]] != Fonts[Font].fontWidth[(2 * text[i]) + 1]) //Handle Saturn font compression
len -= 1;
}
return len;
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("RenderCastRoll")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP Inc.")]
[assembly: AssemblyProduct("RenderCastRoll")]
[assembly: AssemblyCopyright("Copyright © HP Inc. 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
// COM, impostare su true l'attributo ComVisible per tale tipo.
[assembly: ComVisible(false)]
// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi
[assembly: Guid("dd1c607c-5a74-4921-81a4-6bf530a191d7")]
// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
//
// Versione principale
// Versione secondaria
// Numero di build
// Revisione
//
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,9 @@
{
"profiles": {
"ScriptTool": {
"commandName": "Project",
"commandLineArgs": "-compile -main -misc \"..\\working\" \"..\\eb.smc\" \"..\\m12fresh.gba\"",
"workingDirectory": "C:\\Users\\jeffe\\M12\\bin\\ScriptTool"
}
}
}

View File

@ -1,66 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DD1C607C-5A74-4921-81A4-6BF530A191D7}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>RenderCastRoll</RootNamespace>
<AssemblyName>RenderCastRoll</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFramework>netcoreapp2.1</TargetFramework>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
<ItemGroup>
<Compile Include="Asset.cs" />
<Compile Include="LZ77.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RenderTools.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="bits_to_nybbles.bin">
<None Update="bits_to_nybbles.bin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="m12-byte-lookup.json">
<None Update="m12-byte-lookup.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>

View File

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RenderCastRoll
{
@ -98,10 +95,20 @@ namespace RenderCastRoll
}
return newTile;
}
public override String ToString()
{
String str = "";
for (int i = 0; i < 8; i++)
str += getRow(i).ToString("X") + " ";
return str;
}
}
public class WritingBuffer
{
public static readonly int yLength = 3;
public _1bppTile[,] tiles;
public ushort[,] arrangements;
public int used;
@ -111,9 +118,9 @@ namespace RenderCastRoll
{
used = 0;
startPos = 0;
tiles = new _1bppTile[2, 0x20];
arrangements = new ushort[2, 0x20];
for (int i = 0; i < 2; i++)
tiles = new _1bppTile[yLength, 0x20];
arrangements = new ushort[yLength, 0x20];
for (int i = 0; i < yLength; i++)
for (int j = 0; j < 0x20; j++)
{
tiles[i, j] = new _1bppTile();

View File

@ -13,7 +13,7 @@
"+": 11,
",": 12,
"-": 13,
".": 14,
".": 129,
"/": 15,
"0": 16,
"1": 17,
@ -47,7 +47,7 @@
"M": 45,
"N": 46,
"O": 47,
"P": 47,
"P": 48,
"Q": 49,
"R": 50,
"S": 51,
@ -94,5 +94,6 @@
"|": 92,
"}": 93,
"~": 94,
"[AF]": 95
"[AF]": 95,
"[DOT]": 128
}

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
</packages>

244
working/cast_roll.json Normal file
View File

@ -0,0 +1,244 @@
{
"Renders":[
{
"Y":16,
"Center_X":120,
"Text":"Picky Minch",
"Font": 0
},
{
"Y":24,
"Center_X":64,
"Text":"Lardna Minch",
"Font": 0
},
{
"Y":24,
"Center_X":176,
"Text":"Aloysius Minch",
"Font": 0
},
{
"Y":32,
"Center_X":120,
"Text":"Pokey Minch",
"Font": 0
},
{
"Y":42,
"Center_X":120,
"Text":"Buzz Buzz",
"Font": 0
},
{
"Y":51,
"Center_X":120,
"Text":"Lier`X.`Agerate",
"Font": 0
},
{
"Y":62,
"Center_X":120,
"Text":"Frank Fly",
"Font": 0
},
{
"Y":71,
"Center_X":120,
"Text":"The Sharks",
"Font": 0
},
{
"Y":82,
"Center_X":120,
"Text":"B. H. Pirkle",
"Font": 0
},
{
"Y":93,
"Center_X":120,
"Text":"Captain Strong",
"Font": 0
},
{
"Y":102,
"Center_X":120,
"Text":"Onett police force",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"[DOT]",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Orange kid",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Apple kid",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Mr. Everdred",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Runaway Five",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Happy Happyists",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Carpainter",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Bubble Monkey",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Tony",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Maxwell",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Tessie",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Tessie-Watching Club",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Brickroad",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Dr. Andonuts",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"mr.saturn",
"Font": 1
},
{
"Y":108,
"Center_X":120,
"Text":"Master Belch",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"George Montague",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Gerardo Montague",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Talah Rama",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Geldegarde Monotoli",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Venus",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Star Master",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Dungeon Man",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Noble warrior",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Tenda tribesmen",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Flying Men",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Dad",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Tracy",
"Font": 0
},
{
"Y":108,
"Center_X":120,
"Text":"Mom",
"Font": 0
}
]
}