Skip to content

Commit

Permalink
Add MSX (experimental)
Browse files Browse the repository at this point in the history
  • Loading branch information
CatmanFan committed Mar 11, 2024
1 parent 86af445 commit 99343ac
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 6 deletions.
2 changes: 2 additions & 0 deletions FriishProduce/FriishProduce.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="_classes\Injectors\Forwarder.cs" />
<Compile Include="_classes\Injectors\WiiVC\MSX.cs" />
<Compile Include="_classes\Language.cs" />
<Compile Include="_classes\ROM\MSX.cs" />
<Compile Include="_classes\ROM\N64.cs" />
<Compile Include="_classes\ROM\NeoGeo.cs" />
<Compile Include="_classes\ROM\NES.cs" />
Expand Down
8 changes: 8 additions & 0 deletions FriishProduce/InjectorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ private void Form_Shown(object sender, EventArgs e)

case Console.MSX:
TIDCode = "X";
ROM = new ROM_MSX();
break;

default:
Expand Down Expand Up @@ -796,6 +797,13 @@ public void WiiVCInject()
BIOSPath = null
};
break;


// MSX
// *******
case Console.MSX:
VC = new WiiVC.MSX();
break;
}

VC.WAD = OutWAD;
Expand Down
4 changes: 2 additions & 2 deletions FriishProduce/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ private void AutoSetStrip()
// new ToolStripMenuItem(null, new Icon(Properties.Resources.nec_turbografx_16, 16, 16).ToBitmap(), AddProject, Console.PCE.ToString()),
// new ToolStripSeparator(),
new ToolStripMenuItem(null, new Icon(Properties.Resources.snk_neo_geo_aes, 16, 16).ToBitmap(), AddProject, Console.NeoGeo.ToString()),
// new ToolStripSeparator(),
// new ToolStripMenuItem(null, new Icon(SystemIcons.Shield, 16, 16).ToBitmap(), AddProject, Console.MSX.ToString())
new ToolStripSeparator(),
new ToolStripMenuItem(null, new Icon(SystemIcons.Shield, 16, 16).ToBitmap(), AddProject, Console.MSX.ToString())
//})
};

Expand Down
112 changes: 112 additions & 0 deletions FriishProduce/_classes/Injectors/WiiVC/MSX.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using libWiiSharp;

namespace FriishProduce.WiiVC
{
public class MSX : InjectorWiiVC
{
protected override void Load()
{
NeedsMainDOL = false;
MainContentIndex = 5;
NeedsManualLoaded = true;

base.Load();
}

/// <summary>
/// Replaces ROM within extracted content5 directory.
/// </summary>
protected override void ReplaceROM()
{
ROM.CheckSize();

// -----------------------
// Check for ROM string file name index and replace original ROM
// -----------------------

int index = MainContent.GetNodeIndex("SLOT1.ROM") != -1 ? MainContent.GetNodeIndex("SLOT1.ROM") : MainContent.GetNodeIndex("MEGAROM.ROM");
if (index == -1) throw new Exception(Language.Get("Error.002"));

MainContent.ReplaceFile(index, ROM.Bytes);
}

/// <summary>
/// This is the same process as in NeoGeo
/// </summary>
protected override void ReplaceSaveData(string[] lines, ImageHelper Img)
{
// -----------------------
// TEXT
// -----------------------

byte[] contents = null;

try { contents = MainContent.Data[MainContent.GetNodeIndex("banner.bin")]; } catch { }
if (contents == null) return;

// Text addition format: UTF-16 (Big Endian)
// ****************
for (int i = 32; i < 96; i++)
{
try { contents[i] = Encoding.BigEndianUnicode.GetBytes(lines[0])[i - 32]; }
catch { contents[i] = 0x00; }
}

for (int i = 96; i < 160; i++)
{
try { contents[i] = Encoding.BigEndianUnicode.GetBytes(lines[1])[i - 96]; }
catch { contents[i] = 0x00; }
}

// -----------------------
// IMAGE
// -----------------------

// TPL contents in banner.bin does not have TPL header, so it has to be manually added
// ****************
var header = new byte[] { 0x00, 0x20, 0xAF, 0x30, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
0x61, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x73, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x85, 0xA0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x97, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xA9, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xBB, 0xA0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x00, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xCD, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0xDF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

var placeholder = new List<byte>();

// Create TPL byte array
// ****************
placeholder.AddRange(header);
placeholder.AddRange(contents.Skip(160).Take(contents.Length - 160).ToArray());

// Inject new TPL
// ****************
Img.CreateSaveTPL(Console.MSX, placeholder.ToArray()).ToByteArray().Skip(header.Length).ToArray().CopyTo(contents, 160);

// Replace original savebanner
// ****************
MainContent.ReplaceFile(MainContent.GetNodeIndex("banner.bin"), contents);
}

protected override void ModifyEmulatorSettings()
{
// Not exists
return;
}
}
}
4 changes: 0 additions & 4 deletions FriishProduce/_classes/Injectors/WiiVC/SNES.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public class SNES : InjectorWiiVC

protected override void Load()
{
// -----------------------
// Maximum ROM limit allowed: 4 MB
// -----------------------

NeedsMainDOL = true;
MainContentIndex = 5;
NeedsManualLoaded = true;
Expand Down
12 changes: 12 additions & 0 deletions FriishProduce/_classes/ROM/MSX.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace FriishProduce
{
public class ROM_MSX : ROM
{
public ROM_MSX() : base()
{
MaxSize = 524288;
}
}
}

0 comments on commit 99343ac

Please sign in to comment.