diff --git a/build-tools.ps1 b/build-tools.ps1 index 68b5441..3acef7d 100644 --- a/build-tools.ps1 +++ b/build-tools.ps1 @@ -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 } diff --git a/build.ps1 b/build.ps1 index 94ce9a9..525d209 100644 --- a/build.ps1 +++ b/build.ps1 @@ -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 diff --git a/src/data/cast_roll_arrangements_[c].bin b/src/data/cast_roll_arrangements_[c].bin index e9e9194..f86d04f 100644 Binary files a/src/data/cast_roll_arrangements_[c].bin and b/src/data/cast_roll_arrangements_[c].bin differ diff --git a/src/data/cast_roll_graphics_[c].bin b/src/data/cast_roll_graphics_[c].bin index 05c20e2..9ba4a24 100644 Binary files a/src/data/cast_roll_graphics_[c].bin and b/src/data/cast_roll_graphics_[c].bin differ diff --git a/src/data/cast_sign_graphics.bin b/src/data/cast_sign_graphics.bin index a7a25eb..a43ed83 100644 Binary files a/src/data/cast_sign_graphics.bin and b/src/data/cast_sign_graphics.bin differ diff --git a/src/data/m2-font-battle.bin b/src/data/m2-font-battle.bin index e74245d..c135d08 100644 Binary files a/src/data/m2-font-battle.bin and b/src/data/m2-font-battle.bin differ diff --git a/src/data/m2-font-big.bin b/src/data/m2-font-big.bin index 266bcc9..497f245 100644 Binary files a/src/data/m2-font-big.bin and b/src/data/m2-font-big.bin differ diff --git a/src/data/m2-font-main.bin b/src/data/m2-font-main.bin index 954335f..5d00678 100644 Binary files a/src/data/m2-font-main.bin and b/src/data/m2-font-main.bin differ diff --git a/src/data/m2-font-saturn.bin b/src/data/m2-font-saturn.bin index 5beb2c2..2e7aa59 100644 Binary files a/src/data/m2-font-saturn.bin and b/src/data/m2-font-saturn.bin differ diff --git a/src/data/m2-font-tiny.bin b/src/data/m2-font-tiny.bin index ebfc2c1..ad6b743 100644 Binary files a/src/data/m2-font-tiny.bin and b/src/data/m2-font-tiny.bin differ diff --git a/src/data/m2-widths-battle.bin b/src/data/m2-widths-battle.bin index 81899d2..8febc0e 100644 Binary files a/src/data/m2-widths-battle.bin and b/src/data/m2-widths-battle.bin differ diff --git a/src/data/m2-widths-big.bin b/src/data/m2-widths-big.bin index 133d2a4..df56457 100644 Binary files a/src/data/m2-widths-big.bin and b/src/data/m2-widths-big.bin differ diff --git a/src/data/m2-widths-main.bin b/src/data/m2-widths-main.bin index 840ea45..4612f71 100644 Binary files a/src/data/m2-widths-main.bin and b/src/data/m2-widths-main.bin differ diff --git a/src/data/m2-widths-saturn.bin b/src/data/m2-widths-saturn.bin index c838d6d..baabe1d 100644 Binary files a/src/data/m2-widths-saturn.bin and b/src/data/m2-widths-saturn.bin differ diff --git a/src/data/m2-widths-tiny.bin b/src/data/m2-widths-tiny.bin index fd1025e..caa023f 100644 Binary files a/src/data/m2-widths-tiny.bin and b/src/data/m2-widths-tiny.bin differ diff --git a/test.json b/test.json deleted file mode 100644 index 1679dce..0000000 --- a/test.json +++ /dev/null @@ -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 - } - ] -} \ No newline at end of file diff --git a/tools/RenderCastRoll/App.config b/tools/RenderCastRoll/App.config deleted file mode 100644 index 731f6de..0000000 --- a/tools/RenderCastRoll/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/tools/RenderCastRoll/Asset.cs b/tools/RenderCastRoll/Asset.cs index 21fba14..07b087a 100644 --- a/tools/RenderCastRoll/Asset.cs +++ b/tools/RenderCastRoll/Asset.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.IO; namespace RenderCastRoll diff --git a/tools/RenderCastRoll/LZ77.cs b/tools/RenderCastRoll/LZ77.cs index 3899017..36f57ef 100644 --- a/tools/RenderCastRoll/LZ77.cs +++ b/tools/RenderCastRoll/LZ77.cs @@ -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 { diff --git a/tools/RenderCastRoll/Program.cs b/tools/RenderCastRoll/Program.cs index 14005ea..83575c2 100644 --- a/tools/RenderCastRoll/Program.cs +++ b/tools/RenderCastRoll/Program.cs @@ -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; } } diff --git a/tools/RenderCastRoll/Properties/AssemblyInfo.cs b/tools/RenderCastRoll/Properties/AssemblyInfo.cs deleted file mode 100644 index 662d477..0000000 --- a/tools/RenderCastRoll/Properties/AssemblyInfo.cs +++ /dev/null @@ -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")] diff --git a/tools/RenderCastRoll/Properties/launchSettings.json b/tools/RenderCastRoll/Properties/launchSettings.json new file mode 100644 index 0000000..0c015e9 --- /dev/null +++ b/tools/RenderCastRoll/Properties/launchSettings.json @@ -0,0 +1,9 @@ +{ + "profiles": { + "ScriptTool": { + "commandName": "Project", + "commandLineArgs": "-compile -main -misc \"..\\working\" \"..\\eb.smc\" \"..\\m12fresh.gba\"", + "workingDirectory": "C:\\Users\\jeffe\\M12\\bin\\ScriptTool" + } + } +} \ No newline at end of file diff --git a/tools/RenderCastRoll/RenderCastRoll.csproj b/tools/RenderCastRoll/RenderCastRoll.csproj index c1ad873..251742a 100644 --- a/tools/RenderCastRoll/RenderCastRoll.csproj +++ b/tools/RenderCastRoll/RenderCastRoll.csproj @@ -1,66 +1,22 @@ - - - + + - Debug - AnyCPU - {DD1C607C-5A74-4921-81A4-6BF530A191D7} Exe - RenderCastRoll - RenderCastRoll - v4.6.1 - 512 - true - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + netcoreapp2.1 + true + - - ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - - - - - - - - - + + - - - - - - - - - + Always - + Always - - - \ No newline at end of file + + diff --git a/tools/RenderCastRoll/RenderTools.cs b/tools/RenderCastRoll/RenderTools.cs index 4e38ebb..de59e63 100644 --- a/tools/RenderCastRoll/RenderTools.cs +++ b/tools/RenderCastRoll/RenderTools.cs @@ -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(); diff --git a/tools/RenderCastRoll/m12-byte-lookup.json b/tools/RenderCastRoll/m12-byte-lookup.json index bc39cdc..8af69be 100644 --- a/tools/RenderCastRoll/m12-byte-lookup.json +++ b/tools/RenderCastRoll/m12-byte-lookup.json @@ -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 } \ No newline at end of file diff --git a/tools/RenderCastRoll/packages.config b/tools/RenderCastRoll/packages.config deleted file mode 100644 index 8ab13a9..0000000 --- a/tools/RenderCastRoll/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/working/cast_roll.json b/working/cast_roll.json new file mode 100644 index 0000000..331b2ca --- /dev/null +++ b/working/cast_roll.json @@ -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 + } + ] +} \ No newline at end of file