Skip to content

Commit

Permalink
Advances
Browse files Browse the repository at this point in the history
  • Loading branch information
gusmanb committed Jan 15, 2024
1 parent b47db5b commit 5ff7b1a
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public bool Build(string BuildPath, ZXBuildStage Stage, ZXBuildType BuildType, Z
{
case ZXBuildStage.PreBuild:

return BuildDiskAndCode(BuildPath, OutputLog);
return BuildDiskAndCode(BuildPath, BuildType, OutputLog);

case ZXBuildStage.PostBuild:

Expand Down Expand Up @@ -65,7 +65,7 @@ private bool InjectDisk(string buildPath, ZXProgram compiledProgram, TextWriter
return true;
}

private bool BuildDiskAndCode(string buildPath, TextWriter outputLog)
private bool BuildDiskAndCode(string buildPath, ZXBuildType BuildType, TextWriter outputLog)
{
string[] diskBuilds = Directory.GetFiles(buildPath, "*" + ZXDocumentProvider.GetDocumentTypeInstance(typeof(ZXRamDiskDocument)).DocumentExtensions[0], SearchOption.AllDirectories);

Expand All @@ -92,7 +92,6 @@ private bool BuildDiskAndCode(string buildPath, TextWriter outputLog)
List<byte> data = new List<byte>();

sb.AppendLine($"#define {diskFile.DiskName} {(int)diskFile.Bank}");
sb.AppendLine($"#define {diskFile.DiskName}_SIZE {diskFile.Files.Sum(f => f.Size)}");

foreach(var file in diskFile.Files)
{
Expand All @@ -108,10 +107,15 @@ private bool BuildDiskAndCode(string buildPath, TextWriter outputLog)
}

data.AddRange(fileData);
sb.AppendLine($"#define {file.Name}_SIZE {fileData.Length}");
sb.AppendLine($"#define {file.Name}Size {fileData.Length}");

sb.AppendLine($"#define Load{file.Name}From{diskFile.DiskName}(Dest) LoadRamData({diskFile.DiskName}, {file.Name} + $C000, Dest, {file.Name}Size)");

sb.AppendLine($"#define LoadPartial{file.Name}From{diskFile.DiskName}(Dest, Size) LoadRamData({diskFile.DiskName}, {file.Name} + $C000, Dest, Size)");
}

sb.AppendLine($"\r\nLoadRamDisk({diskFile.DiskName})");
if(BuildType == ZXBuildType.Release)
sb.AppendLine($"\r\nLoadRamDisk({diskFile.DiskName})");

outputLog.WriteLine("Writting binary disk...");
File.WriteAllBytes(diskPath.Substring(0, diskPath.Length - 4) + ".zxrbin", data.ToArray());
Expand Down

0 comments on commit 5ff7b1a

Please sign in to comment.