Chip gets a promotion

This commit is contained in:
Matt Nadareski
2020-08-25 22:48:46 -07:00
parent 0fa843a587
commit 143668c56a
13 changed files with 457 additions and 218 deletions

View File

@@ -271,6 +271,9 @@ namespace SabreTools.Library.DatFiles
case "biosset":
itemType = ItemType.BiosSet;
break;
case "chip":
itemType = ItemType.Chip;
break;
case "disk":
itemType = ItemType.Disk;
break;
@@ -387,24 +390,39 @@ namespace SabreTools.Library.DatFiles
break;
case "default":
if (item.ItemType == ItemType.BiosSet)
((BiosSet)item).Default = attrVal.ToLowerInvariant().AsYesNo();
((BiosSet)item).Default = attrVal.AsYesNo();
else if (item.ItemType == ItemType.Release)
((Release)item).Default = attrVal.ToLowerInvariant().AsYesNo();
((Release)item).Default = attrVal.AsYesNo();
break;
case "description":
if (item.ItemType == ItemType.BiosSet)
((BiosSet)item).Description = attrVal.ToLowerInvariant();
((BiosSet)item).Description = attrVal;
break;
case "region":
if (item.ItemType == ItemType.Release)
((Release)item).Region = attrVal.ToLowerInvariant();
((Release)item).Region = attrVal;
break;
case "language":
if (item.ItemType == ItemType.Release)
((Release)item).Language = attrVal.ToLowerInvariant();
((Release)item).Language = attrVal;
break;
case "tag":
if (item.ItemType == ItemType.Chip)
((Chip)item).Tag = attrVal;
break;
case "type":
if (item.ItemType == ItemType.Chip)
((Chip)item).ChipType = attrVal;
break;
case "clock":
if (item.ItemType == ItemType.Chip)
((Chip)item).Clock = attrVal;
break;
}
@@ -674,6 +692,16 @@ namespace SabreTools.Library.DatFiles
cmpw.WriteEndElement();
break;
case ItemType.Chip:
var chip = datItem as Chip;
cmpw.WriteStartElement("chip");
cmpw.WriteRequiredAttributeString("name", chip.Name);
cmpw.WriteOptionalAttributeString("tag", chip.Tag);
cmpw.WriteOptionalAttributeString("type", chip.ChipType);
cmpw.WriteOptionalAttributeString("clock", chip.Clock);
cmpw.WriteEndElement();
break;
case ItemType.Disk:
var disk = datItem as Disk;
cmpw.WriteStartElement("disk");

View File

@@ -88,6 +88,12 @@ namespace SabreTools.Library.DatFiles
[JsonIgnore]
public long BiosSetCount { get; private set; } = 0;
/// <summary>
/// Number of Chip items
/// </summary>
[JsonIgnore]
public long ChipCount { get; private set; } = 0;
/// <summary>
/// Number of Disk items
/// </summary>
@@ -388,6 +394,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.BiosSet:
BiosSetCount += 1;
break;
case ItemType.Chip:
ChipCount += 1;
break;
case ItemType.Disk:
DiskCount += 1;
if (((Disk)item).ItemStatus != ItemStatus.Nodump)
@@ -508,6 +517,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.BiosSet:
BiosSetCount -= 1;
break;
case ItemType.Chip:
ChipCount -= 1;
break;
case ItemType.Disk:
DiskCount -= 1;
if (((Disk)item).ItemStatus != ItemStatus.Nodump)

View File

@@ -232,6 +232,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.Blank:
datItem = datItemObj.ToObject<Blank>();
break;
case ItemType.Chip:
datItem = datItemObj.ToObject<Chip>();
break;
case ItemType.Disk:
datItem = datItemObj.ToObject<Disk>();
break;

View File

@@ -283,17 +283,19 @@ namespace SabreTools.Library.DatFiles
break;
case "chip":
var chip = new ListXmlChip();
chip.Name = reader.GetAttribute("name");
chip.Tag = reader.GetAttribute("tag");
chip.Type = reader.GetAttribute("type");
chip.Clock = reader.GetAttribute("clock");
datItems.Add(new Chip
{
Name = reader.GetAttribute("name"),
Tag = reader.GetAttribute("tag"),
ChipType = reader.GetAttribute("type"),
Clock = reader.GetAttribute("clock"),
// Ensure the list exists
if (machine.Chips == null)
machine.Chips = new List<ListXmlChip>();
machine.Chips.Add(chip);
Source = new Source
{
Index = indexId,
Name = filename,
},
});
reader.Read();
break;
@@ -1122,21 +1124,6 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
}
}
if (datItem.Machine.Chips != null)
{
foreach (var chip in datItem.Machine.Chips)
{
xtw.WriteStartElement("chip");
xtw.WriteOptionalAttributeString("name", chip.Name);
xtw.WriteOptionalAttributeString("tag", chip.Tag);
xtw.WriteOptionalAttributeString("type", chip.Type);
xtw.WriteOptionalAttributeString("clock", chip.Clock);
// End chip
xtw.WriteEndElement();
}
}
if (datItem.Machine.Displays != null)
{
foreach (var display in datItem.Machine.Displays)
@@ -1558,6 +1545,16 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
break;
case ItemType.Chip:
var chip = datItem as Chip;
xtw.WriteStartElement("chip");
xtw.WriteRequiredAttributeString("name", chip.Name);
xtw.WriteOptionalAttributeString("tag", chip.Tag);
xtw.WriteOptionalAttributeString("type", chip.ChipType);
xtw.WriteOptionalAttributeString("clock", chip.Clock);
xtw.WriteEndElement();
break;
case ItemType.Disk:
var disk = datItem as Disk;
xtw.WriteStartElement("disk");

View File

@@ -528,6 +528,31 @@ namespace SabreTools.Library.DatFiles
reader.Read();
break;
case "chip":
containsItems = true;
DatItem chiprom = new Chip
{
Name = reader.GetAttribute("name"),
Tag = reader.GetAttribute("tag"),
ChipType = reader.GetAttribute("type"),
Clock = reader.GetAttribute("clock"),
Source = new Source
{
Index = indexId,
Name = filename,
},
};
chiprom.CopyMachineInformation(machine);
// Now process and add the rom
key = ParseAddHelper(chiprom);
reader.Read();
break;
default:
reader.Read();
break;
@@ -968,6 +993,16 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
break;
case ItemType.Chip:
var chip = datItem as Chip;
xtw.WriteStartElement("chip");
xtw.WriteRequiredAttributeString("name", chip.Name);
xtw.WriteOptionalAttributeString("tag", chip.Tag);
xtw.WriteOptionalAttributeString("type", chip.ChipType);
xtw.WriteOptionalAttributeString("clock", chip.Clock);
xtw.WriteEndElement();
break;
case ItemType.Disk:
var disk = datItem as Disk;
xtw.WriteStartElement("disk");

View File

@@ -383,6 +383,22 @@ namespace SabreTools.Library.DatFiles
};
break;
case "chip":
datItem = new Chip
{
Name = reader.GetAttribute("name"),
Tag = reader.GetAttribute("tag"),
ChipType = reader.GetAttribute("chiptype"),
Clock = reader.GetAttribute("clock"),
Source = new Source
{
Index = indexId,
Name = filename,
},
};
break;
case "disk":
datItem = new Disk
{
@@ -855,6 +871,17 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
break;
case ItemType.Chip:
var chip = datItem as Chip;
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "chip");
xtw.WriteRequiredAttributeString("name", chip.Name);
xtw.WriteOptionalAttributeString("tag", chip.Tag);
xtw.WriteOptionalAttributeString("chiptype", chip.ChipType);
xtw.WriteOptionalAttributeString("clock", chip.Clock);
xtw.WriteEndElement();
break;
case ItemType.Disk:
var disk = datItem as Disk;
xtw.WriteStartElement("file");