Skip to content

Commit

Permalink
Merge pull request #68 from GoldenretriverYT/fix-mrs
Browse files Browse the repository at this point in the history
Allow for external binary inclusion using incbin assembler directive
  • Loading branch information
quajak authored Jun 25, 2023
2 parents b06f2d7 + 08b8dfa commit 36e3917
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion source/XSharp/XSharp/Assembler/Gen1/DataMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ public class DataMember : BaseAssemblerElement, IComparable<DataMember>
private string Size;
private string StringValue;
private Type Type;
private bool isIncBin;

// Hack for not to emit raw data. See RawAsm
public DataMember()
{
Name = "Dummy";
}

public DataMember(string aName, string aValue, bool noConvert = false)
public DataMember(string aName, string aValue, bool noConvert = false, bool isIncBin = false)
{
this.isIncBin = isIncBin;

if (noConvert)
{
Name = aName;
Expand Down Expand Up @@ -154,6 +157,13 @@ public override void WriteText(Assembler aAssembler, TextWriter aOutput)
return;
}

if(isIncBin) {
aOutput.Write(Name);
aOutput.WriteLine(":");
aOutput.WriteLine("incbin \"" + StringValue + "\"");
return;
}

if (RawDefaultValue != null)
{
if (RawDefaultValue.Length == 0)
Expand Down
4 changes: 4 additions & 0 deletions source/XSharp/XSharp/Gen1/XS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,10 @@ public static void DataMember(string name, string value)
Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember(name, value));
}

public static void DataMember(string name, string value, bool isIncBin) {
Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember(name, value, true, isIncBin));
}

public static void DataMemberBytes(string name, byte[] value)
{
Assembler.Assembler.CurrentInstance.DataMembers.Add(new DataMember(name, value));
Expand Down

0 comments on commit 36e3917

Please sign in to comment.