Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ public bool InitializeSprite()
Image = "/Svg/Seal.svg",
Name = "PutChars"
});
ExportTypesList.Add(new ExportTypeDescrioptionItem()
{
Description = "Conrado Badenas MaskedSprites library.",
ExportType = ExportTypes.MaskedSprites,
Image = "/Svg/Mask.svg",
Name = "MaskedSprites"
});
/*
ExportTypesList.Add(new ExportTypeDescrioptionItem()
{
Expand All @@ -73,7 +80,6 @@ public bool InitializeSprite()
});
*/
lstOptions.ItemsSource = ExportTypesList;

lstOptions.SelectionChanged += LstOptions_SelectionChanged;

return true;
Expand Down
144 changes: 144 additions & 0 deletions ZXBStudio/DocumentEditors/ZXGraphics/SpriteExportDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ private void Refresh()
CreateExample_PutChars();
}
break;
case ExportTypes.MaskedSprites:
CreateExportPath(".bas");
if (canExport)
{
CreateExample_MaskedSprites();
}
break;
default:
grdOptions.IsVisible = false;
break;
Expand Down Expand Up @@ -264,6 +271,143 @@ private void CreateExample_PutChars()
txtCode.Text = sb.ToString();
}


private void CreateExample_MaskedSprites()
{
if (sprites == null || sprites.Count() == 0)
{
txtCode.Text = "";
}

var sb = new StringBuilder();
switch (exportConfig.ExportDataType)
{
case ExportDataTypes.DIM:
{
var sprite = sprites.ElementAt(0);
sb.AppendLine("'- Includes -----------------------------------------------");
sb.AppendLine("#INCLUDE <retrace.bas>");
sb.AppendLine("#INCLUDE \"maskedsprites.bas\"");
sb.AppendLine("");
sb.AppendLine("'- Sprites definition -------------------------------------");
sb.AppendLine(string.Format("' Can use: #INCLUDE \"{0}\"",
Path.GetFileName(exportConfig.ExportFilePath)));
sb.AppendLine(ExportManager.Export_Sprite_MaskedSprites(exportConfig, sprites));
sb.AppendLine("' - Init vars ---------------------------------------------");
sb.AppendLine("#define NumberofMaskedSprites 1");
sb.AppendLine("DIM sprDir, sprBackDir AS UInteger");
sb.AppendLine("");
sb.AppendLine("'- Initialise the sprite engine ---------------------------");
sb.AppendLine("InitMaskedSpritesFileSystem()");
sb.AppendLine("' Create sprite");
sb.AppendLine($"sprDir = RegisterSpriteImageInMSFS(@{exportConfig.LabelName}{sprite.Name.Replace(" ", "_")}(0))");
sb.AppendLine("' Save background for first time");
sb.AppendLine("sprBackDir = MaskedSpritesBackground(0)");
sb.AppendLine("");
sb.AppendLine("'- Draw sprite --------------------------------------------");
sb.AppendLine("DIM n AS UByte");
sb.AppendLine("DO");
sb.AppendLine(" ' Sync with raytrace");
sb.AppendLine(" waitretrace");
sb.AppendLine(" ' Restore background");
sb.AppendLine(" RestoreBackground(100,52,sprBackDir)");
sb.AppendLine(" ");
sb.AppendLine(" ' Print a number");
sb.AppendLine(" PRINT AT 7,12;n;");
sb.AppendLine(" n = n + 1");
sb.AppendLine(" ' Draw sprite");
sb.AppendLine(" SaveBackgroundAndDrawSpriteRegisteredInMSFS(100,52,sprBackDir,sprDir) ");
sb.AppendLine("LOOP");
sb.AppendLine("");
}
break;

case ExportDataTypes.ASM:
{
var sprite = sprites.ElementAt(0);
sb.AppendLine("'- Includes -----------------------------------------------");
sb.AppendLine("#INCLUDE <retrace.bas>");
sb.AppendLine("#INCLUDE \"maskedsprites.bas\"");
sb.AppendLine("");
sb.AppendLine("' - Init vars ---------------------------------------------");
sb.AppendLine("#define NumberofMaskedSprites 1");
sb.AppendLine("DIM sprDir, sprBackDir AS UInteger");
sb.AppendLine("");
sb.AppendLine("'- Initialise the sprite engine ---------------------------");
sb.AppendLine("InitMaskedSpritesFileSystem()");
sb.AppendLine("' Create sprite");
sb.AppendLine($"sprDir = RegisterSpriteImageInMSFS(@{exportConfig.LabelName}_{sprite.Name.Replace(" ", "_")})");
sb.AppendLine("' Save background for first time");
sb.AppendLine("sprBackDir = MaskedSpritesBackground(0)");
sb.AppendLine("");
sb.AppendLine("'- Draw sprite --------------------------------------------");
sb.AppendLine("DIM n AS UByte");
sb.AppendLine("DO");
sb.AppendLine(" ' Sync with raytrace");
sb.AppendLine(" waitretrace");
sb.AppendLine(" ' Restore background");
sb.AppendLine(" RestoreBackground(100,52,sprBackDir)");
sb.AppendLine(" ");
sb.AppendLine(" ' Print a number");
sb.AppendLine(" PRINT AT 7,12;n;");
sb.AppendLine(" n = n + 1");
sb.AppendLine(" ' Draw sprite");
sb.AppendLine(" SaveBackgroundAndDrawSpriteRegisteredInMSFS(100,52,sprBackDir,sprDir) ");
sb.AppendLine("LOOP");
sb.AppendLine("");
sb.AppendLine("' - This section must not be executed --------------------");
sb.AppendLine(string.Format("' Can use: #INCLUDE \"{0}\"",
Path.GetFileName(exportConfig.ExportFilePath)));
sb.AppendLine(ExportManager.Export_Sprite_MaskedSprites(exportConfig, sprites));
}
break;

case ExportDataTypes.BIN:
{
sb.AppendLine("'- Includes -----------------------------------------------");
sb.AppendLine("#INCLUDE <putchars.bas>");
sb.AppendLine("");
sb.AppendLine("'- Draw sprite --------------------------------------------");
var sprite = sprites.ElementAt(0);
sb.AppendLine(string.Format(
"putChars(10,5,{0},{1},@{2})",
sprite.Width / 8,
sprite.Height / 8,
exportConfig.LabelName));
sb.AppendLine("");
sb.AppendLine("' This section must not be executed");
sb.AppendLine(string.Format(
"{0}:",
exportConfig.LabelName));
sb.AppendLine("ASM");
sb.AppendLine(string.Format("\tINCBIN \"{0}\"",
Path.GetFileName(exportConfig.ExportFilePath)));
sb.AppendLine("END ASM");
}
break;

case ExportDataTypes.TAP:
{
sb.AppendLine("'- Includes -----------------------------------------------");
sb.AppendLine("#INCLUDE <putchars.bas>");
sb.AppendLine("");
sb.AppendLine("' Load .tap data ------------------------------------------");
sb.AppendLine("LOAD \"\" CODE");
sb.AppendLine("");
sb.AppendLine("'- Draw sprite --------------------------------------------");
var sprite = sprites.ElementAt(0);
sb.AppendLine(string.Format(
"putChars(10,5,{0},{1},@{2})",
sprite.Width / 8,
sprite.Height / 8,
exportConfig.LabelName));
sb.AppendLine("");
}
break;
}

txtCode.Text = sb.ToString();
}
#endregion


Expand Down
Loading
Loading