Skip to content

Commit

Permalink
Release 0.5.5.0 - Added Asset Window and connected with the Tile Editor.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtremblay committed May 19, 2021
1 parent fe33e83 commit 740abb6
Show file tree
Hide file tree
Showing 38 changed files with 17,372 additions and 17,022 deletions.
10 changes: 5 additions & 5 deletions Main/App.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="FoenixIDE.Simulator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="FoenixIDE.Simulator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<userSettings>
<FoenixIDE.Simulator.Properties.Settings>
Expand All @@ -18,4 +18,4 @@
</setting>
</FoenixIDE.Simulator.Properties.Settings>
</userSettings>
</configuration>
</configuration>
2 changes: 1 addition & 1 deletion Main/Devices/VDMA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override void WriteByte(int Address, byte Value)
{
int size1DTransfer = isSystemSource ? ReadLong(0x28) : ReadLong(0x8); // Address $AF:0408 - maximum 4MB
buffer = new byte[size1DTransfer];
srcMemory.CopyIntoBuffer(srcAddr, buffer, 0, size1DTransfer);
srcMemory.CopyIntoBuffer(srcAddr, size1DTransfer, buffer);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions Main/Display/Gpu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ private unsafe void DrawBitmap(int* p, bool gammaCorrection, int layer, bool bkg
int* ptr = p + pixelOffset;
//int col = borderXSize;
byte pixVal = 0;
VRAM.CopyIntoBuffer(offsetAddress, pixVals, 0, width);
VRAM.CopyIntoBuffer(offsetAddress, width, pixVals);

//while (col < width - borderXSize)
for (int col = borderXSize; col < width - borderXSize; col++)
Expand All @@ -617,8 +617,8 @@ private unsafe void DrawBitmap(int* p, bool gammaCorrection, int layer, bool bkg
if (pixVal != 0)
{
colorVal = GetLUTValue(lutIndex, pixVal, gammaCorrection);
ptr[col] = colorVal;
}
ptr[col] = colorVal;
}
}

Expand Down Expand Up @@ -655,7 +655,7 @@ private unsafe void DrawTiles(int* p, bool gammaCorrection, byte TextColumns, in
int tilemapItemCount = width / TILE_SIZE + 1;
byte[] tiles = new byte[tilemapItemCount * 2];
int[] tilesetOffsets = new int[tilemapItemCount];
VRAM.CopyIntoBuffer(tilemapAddress + (1 + tilemapWindowX / TILE_SIZE) * 2 + (tileRow + 0) * tilemapWidth * 2, tiles, 0, tilemapItemCount * 2);
VRAM.CopyIntoBuffer(tilemapAddress + (1 + tilemapWindowX / TILE_SIZE) * 2 + (tileRow + 0) * tilemapWidth * 2, tilemapItemCount * 2, tiles);

// cache of tilesetPointers
int[] tilesetPointers = new int[8];
Expand Down
56 changes: 42 additions & 14 deletions Main/FileFormat/FoenixmlFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using static FoenixIDE.Simulator.FileFormat.ResourceChecker;

namespace FoenixIDE.Simulator.FileFormat
{
class FoeniXmlFile
{
private ResourceChecker Resources;
private const int PHRASE_LENGTH = 16;
private Processor.Breakpoints BreakPoints;
private SortedList<int, DebugLine> codeList;
Expand All @@ -25,16 +25,15 @@ private FoeniXmlFile() { }
public FoeniXmlFile(FoenixSystem kernel, ResourceChecker resources)
{
this.kernel = kernel;
this.Resources = resources;
this.codeList = kernel.lstFile.Lines;
this.BreakPoints = kernel.Breakpoints;
watchList = kernel.WatchList;
}

private static string tabs = "\t\t\t\t\t\t\t\t";
public void Write(String filename, bool compact)
{
XmlWriter xmlWriter = XmlWriter.Create(filename);
string tabs = "\t\t\t\t\t\t\t\t";

xmlWriter.WriteStartDocument();
xmlWriter.WriteRaw("\r");
xmlWriter.WriteComment("Export of FoenixIDE for C256. All values are in hexadecimal form");
Expand All @@ -49,14 +48,15 @@ public void Write(String filename, bool compact)
xmlWriter.WriteRaw(tabs.Substring(0, 1));
xmlWriter.WriteStartElement("resources");
xmlWriter.WriteRaw("\r");
foreach (ResourceChecker.Resource res in Resources.Items)
foreach (ResourceChecker.Resource res in kernel.ResCheckerRef.Items)
{
xmlWriter.WriteRaw(tabs.Substring(0, 2));
xmlWriter.WriteStartElement("resource");
xmlWriter.WriteAttributeString("name", res.Name);
xmlWriter.WriteAttributeString("source", res.SourceFile);
xmlWriter.WriteAttributeString("start-address", res.StartAddress.ToString("X6"));
xmlWriter.WriteAttributeString("length", res.Length.ToString("X"));
xmlWriter.WriteAttributeString("resource-type", res.FileType.ToString());
xmlWriter.WriteEndElement(); // end resource
xmlWriter.WriteRaw("\r");
}
Expand Down Expand Up @@ -156,6 +156,7 @@ public void Write(String filename, bool compact)
}
xmlWriter.WriteRaw(tabs.Substring(0, 1));
xmlWriter.WriteEndElement(); // end pages
xmlWriter.WriteRaw("\r");

xmlWriter.WriteRaw(tabs.Substring(0, 1));
xmlWriter.WriteStartElement("vicky");
Expand All @@ -169,6 +170,28 @@ public void Write(String filename, bool compact)
}
xmlWriter.WriteRaw(tabs.Substring(0, 1));
xmlWriter.WriteEndElement(); // end vicky

// Video RAM for resources
xmlWriter.WriteRaw(tabs.Substring(0, 1));
xmlWriter.WriteStartElement("video");
xmlWriter.WriteRaw("\r");
foreach (ResourceChecker.Resource res in kernel.ResCheckerRef.Items)
{
// If the assets were loaded in RAM, they would have been saved already
if (res.StartAddress >= 0xB0_0000)
{
for (int i = res.StartAddress; i < res.StartAddress + res.Length; i = i + 256)
{
if (PageChecksum(i) != 0)
{
WriteData(i, xmlWriter, compact);
}
}
}
}
xmlWriter.WriteRaw(tabs.Substring(0, 1));
xmlWriter.WriteEndElement(); // end video

xmlWriter.WriteRaw("\r");
xmlWriter.WriteEndElement(); // end project

Expand Down Expand Up @@ -232,6 +255,7 @@ public void ReadWatches(string filename)

private void WriteData(int startAddress, XmlWriter writer, bool compact)
{
writer.WriteRaw(tabs.Substring(0, 1));
writer.WriteStartElement("page");
writer.WriteAttributeString("start-address", "$" + startAddress.ToString("X6"));
writer.WriteAttributeString("bank", "$" + startAddress.ToString("X6").Substring(0, 2));
Expand All @@ -242,6 +266,7 @@ private void WriteData(int startAddress, XmlWriter writer, bool compact)
{
WritePhrase(startAddress + i, writer, compact);
}
writer.WriteRaw(tabs.Substring(0, 1));
writer.WriteEndElement();
writer.WriteRaw("\r");
}
Expand All @@ -251,6 +276,7 @@ private void WritePhrase(int startAddress, XmlWriter writer, bool compact)
{
if (PhraseChecksum(startAddress) == 0 && !compact || PhraseChecksum(startAddress) != 0)
{
writer.WriteRaw(tabs.Substring(0, 2));
writer.WriteStartElement("data");
writer.WriteAttributeString("address", "$" + (startAddress).ToString("X6"));
for (int i = 0; i < PHRASE_LENGTH; i++)
Expand Down Expand Up @@ -291,14 +317,7 @@ public void Load(String filename)
{
XmlReader reader = XmlReader.Create(filename);
Version = BoardVersion.RevB;
if (Resources == null)
{
Resources = new ResourceChecker();
}
else
{
Resources.Clear();
}
kernel.ResCheckerRef.Clear();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
Expand All @@ -317,7 +336,16 @@ public void Load(String filename)
StartAddress = Convert.ToInt32(reader.GetAttribute("start-address"), 16),
Length = Convert.ToInt32(reader.GetAttribute("length"), 16)
};
Resources.Add(res);
string resType = reader.GetAttribute("resource-type");
if (resType != null)
{
res.FileType = (ResourceType)Enum.Parse(typeof(ResourceType), resType);
}
else
{
res.FileType = ResourceType.raw;
}
kernel.ResCheckerRef.Add(res);
continue;
}
if (reader.Name.Equals("code"))
Expand Down
23 changes: 22 additions & 1 deletion Main/FileFormat/ResourceChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ namespace FoenixIDE.Simulator.FileFormat
{
public class ResourceChecker
{
public enum ResourceType
{
raw,
bitmap,
tileset,
tilemap,
sprite,
lut
}
public class Resource
{
public int StartAddress = 0;
public int Length = 0;
public string Name;
public string SourceFile;
public int FileType = 0; // 0 = Raw, 1-5 = tilemap, 6-13 = tileset, 14-77 = sprite
public ResourceType FileType = ResourceType.raw;
}

List<Resource> resources = new List<Resource>();
Expand Down Expand Up @@ -53,5 +62,17 @@ public List<Resource> Items
return resources;
}
}

public Resource Find(ResourceType resType, int startAddress)
{
foreach (Resource res in Items)
{
if (res.FileType == resType && res.StartAddress == startAddress)
{
return res;
}
}
return null;
}
}
}
21 changes: 16 additions & 5 deletions Main/FoenixIDE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand Down Expand Up @@ -127,6 +128,12 @@
<Compile Include="UI\AccumulatorControl.Designer.cs">
<DependentUpon>AccumulatorControl.cs</DependentUpon>
</Compile>
<Compile Include="UI\AssetWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\AssetWindow.Designer.cs">
<DependentUpon>AssetWindow.cs</DependentUpon>
</Compile>
<Compile Include="UI\CharEditor\CharEditorWindow.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -202,11 +209,11 @@
<DependentUpon>RegisterDisplay.cs</DependentUpon>
</Compile>
<Compile Include="SystemLog.cs" />
<Compile Include="UI\BitmapLoader.cs">
<Compile Include="UI\AssetLoader.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\BitmapLoader.Designer.cs">
<DependentUpon>BitmapLoader.cs</DependentUpon>
<Compile Include="UI\AssetLoader.Designer.cs">
<DependentUpon>AssetLoader.cs</DependentUpon>
</Compile>
<Compile Include="UI\SerialTerminal.cs">
<SubType>Form</SubType>
Expand Down Expand Up @@ -244,6 +251,9 @@
<EmbeddedResource Include="UI\AccumulatorControl.resx">
<DependentUpon>AccumulatorControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\AssetWindow.resx">
<DependentUpon>AssetWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\CharEditor\CharEditorWindow.resx">
<DependentUpon>CharEditorWindow.cs</DependentUpon>
</EmbeddedResource>
Expand Down Expand Up @@ -284,8 +294,8 @@
<EmbeddedResource Include="UI\RegisterDisplay.resx">
<DependentUpon>RegisterDisplay.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\BitmapLoader.resx">
<DependentUpon>BitmapLoader.cs</DependentUpon>
<EmbeddedResource Include="UI\AssetLoader.resx">
<DependentUpon>AssetLoader.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\SDCardWindow.resx">
<DependentUpon>SDCardWindow.cs</DependentUpon>
Expand Down Expand Up @@ -335,6 +345,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
<None Include="Resources\save_btn.bmp" />
<None Include="Resources\kernel_U_Plus.hex" />
<None Include="UI\Images\memory-btn.png" />
<None Include="UI\Images\delete-btn.png" />
Expand Down
4 changes: 2 additions & 2 deletions Main/FoenixSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class FoenixSystem
public MemoryManager MemMgr = null;
public Processor.CPU CPU = null;

public ResourceChecker Resources;
public ResourceChecker ResCheckerRef;
public Processor.Breakpoints Breakpoints = new Processor.Breakpoints();
public ListFile lstFile;
private BoardVersion boardVersion;
Expand Down Expand Up @@ -175,7 +175,7 @@ public bool ResetCPU(string kernelFilename)
if (LoadedKernel.EndsWith(".fnxml", true, null))
{
this.ResetMemory();
FoeniXmlFile fnxml = new FoeniXmlFile(this, Resources);
FoeniXmlFile fnxml = new FoeniXmlFile(this, ResCheckerRef);
fnxml.Load(LoadedKernel);
boardVersion = fnxml.Version;
}
Expand Down
4 changes: 4 additions & 0 deletions Main/MemoryLocations/IMappable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ public interface IMappable
int StartAddress { get; }
int Length { get; }
int EndAddress { get; }

void CopyBuffer(byte[] src, int srcAddress, int destAddress, int length);
void CopyIntoBuffer(int srcAddress, int srcLength, byte[] buffer);

}
}
18 changes: 18 additions & 0 deletions Main/MemoryLocations/MemoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,5 +289,23 @@ internal void Write(int Address, int Value, int Length)
if (Length >= 3)
device.WriteByte(deviceAddress + 2, (byte)(Value >> 16 & 0xff));
}

public void CopyBuffer(byte[] src, int srcAddress, int destAddress, int length)
{
GetDeviceAt(destAddress, out IMappable device, out int deviceAddress);
if (device != null)
{
device.CopyBuffer(src, srcAddress, deviceAddress, length);
}
}

public void CopyIntoBuffer(int srcAddress, int srcLength, byte[] buffer)
{
GetDeviceAt(srcAddress, out IMappable device, out int deviceAddress);
if (device != null)
{
device.CopyIntoBuffer(deviceAddress, srcLength, buffer);
}
}
}
}
10 changes: 5 additions & 5 deletions Main/MemoryLocations/MemoryRAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ internal void Duplicate(int SourceAddress, int DestAddress, int Length)
System.Array.Copy(data, SourceAddress, data, DestAddress, Length);
}

// Copy data from a buffer to RAM
internal void CopyBuffer(byte[] buffer, int SourceAddress, int DestAddress, int Length)
public void CopyIntoBuffer(int srcAddress, int srcLength, byte[] buffer)
{
System.Array.Copy(buffer, SourceAddress, data, DestAddress, Length);
System.Array.Copy(data, srcAddress, buffer, 0, srcLength);
}

internal void CopyIntoBuffer(int SourceAddress, byte[] buffer, int DestAddress, int Length)
// Copy data from a buffer to RAM
public void CopyBuffer(byte[] src, int srcAddress, int destAddress, int length)
{
System.Array.Copy(data, SourceAddress, buffer, DestAddress, Length);
System.Array.Copy(src, srcAddress, data, destAddress, length);
}
}
}
4 changes: 2 additions & 2 deletions Main/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.4.3")]
[assembly: AssemblyFileVersion("0.5.4.3")]
[assembly: AssemblyVersion("0.5.5.0")]
[assembly: AssemblyFileVersion("0.5.5.0")]
Loading

0 comments on commit 740abb6

Please sign in to comment.