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
27 changes: 23 additions & 4 deletions Assets/Scripts/Description/Helpers/ChipTypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,30 @@ public static class ChipTypeHelper
{ ChipType.TriStateBuffer, "3-STATE BUFFER" },
// ---- Memory ----
{ ChipType.dev_Ram_8Bit, "dev.RAM-8" },
{ ChipType.Rom_256x2x8, $"ROM 256{mulSymbol}x2x8" },
{ ChipType.Rom_256x16, $"ROM 256{mulSymbol}16" },
{ ChipType.Rom_256x32, $"ROM 256{mulSymbol}32" },
// ---- Split / Merge ----
{ ChipType.Split_4To1Bit, "4-1BIT" },
{ ChipType.Split_8To1Bit, "8-1BIT" },
{ ChipType.Split_8To4Bit, "8-4BIT" },
{ ChipType.Split_16To1Bit, "16-1BIT" },
{ ChipType.Split_16To4Bit, "16-4BIT" },
{ ChipType.Split_16To8Bit, "16-8BIT" },
{ ChipType.Merge_4To8Bit, "4-8BIT" },
{ ChipType.Merge_1To8Bit, "1-8BIT" },
{ ChipType.Merge_1To4Bit, "1-4BIT" },
{ ChipType.Merge_1To16Bit, "1-16BIT" },
{ ChipType.Merge_4To16Bit, "4-16BIT" },
{ ChipType.Merge_8To16Bit, "8-16BIT" },

// ---- Displays -----
{ ChipType.DisplayRGB, "RGB DISPLAY" },
{ ChipType.DisplayDot, "DOT DISPLAY" },
{ ChipType.SevenSegmentDisplay, "7-SEGMENT" },
{ ChipType.DisplayLED, "LED" },
{ ChipType.DisplayRGBLED, "RGBLED" },
{ ChipType.DisplayAscii_8Bit, "A"},

{ ChipType.Buzzer, "BUZZER" },

Expand All @@ -39,28 +49,32 @@ public static class ChipTypeHelper
{ ChipType.In_1Bit, "IN-1" },
{ ChipType.In_4Bit, "IN-4" },
{ ChipType.In_8Bit, "IN-8" },
{ ChipType.In_16Bit, "IN-16" },
{ ChipType.Out_1Bit, "OUT-1" },
{ ChipType.Out_4Bit, "OUT-4" },
{ ChipType.Out_8Bit, "OUT-8" },
{ ChipType.Out_16Bit, "OUT-16" },
{ ChipType.Key, "KEY" },
// ---- Buses ----
{ ChipType.Bus_1Bit, "BUS-1" },
{ ChipType.Bus_4Bit, "BUS-4" },
{ ChipType.Bus_8Bit, "BUS-8" },
{ ChipType.Bus_16Bit, "BUS-16" },
{ ChipType.BusTerminus_1Bit, "BUS-TERMINUS-1" },
{ ChipType.BusTerminus_4Bit, "BUS-TERMINUS-4" },
{ ChipType.BusTerminus_8Bit, "BUS-TERMINUS-8" }
{ ChipType.BusTerminus_8Bit, "BUS-TERMINUS-8" },
{ ChipType.BusTerminus_16Bit, "BUS-TERMINUS-16" }
};

public static string GetName(ChipType type) => Names[type];

public static bool IsBusType(ChipType type) => IsBusOriginType(type) || IsBusTerminusType(type);

public static bool IsBusOriginType(ChipType type) => type is ChipType.Bus_1Bit or ChipType.Bus_4Bit or ChipType.Bus_8Bit;
public static bool IsBusOriginType(ChipType type) => type is ChipType.Bus_1Bit or ChipType.Bus_4Bit or ChipType.Bus_8Bit or ChipType.Bus_16Bit;

public static bool IsBusTerminusType(ChipType type) => type is ChipType.BusTerminus_1Bit or ChipType.BusTerminus_4Bit or ChipType.BusTerminus_8Bit;
public static bool IsBusTerminusType(ChipType type) => type is ChipType.BusTerminus_1Bit or ChipType.BusTerminus_4Bit or ChipType.BusTerminus_8Bit or ChipType.BusTerminus_16Bit;

public static bool IsRomType(ChipType type) => type == ChipType.Rom_256x16;
public static bool IsRomType(ChipType type) => type is ChipType.Rom_256x2x8 or ChipType.Rom_256x16 or ChipType.Rom_256x32;

public static ChipType GetCorrespondingBusTerminusType(ChipType type)
{
Expand All @@ -69,6 +83,7 @@ public static ChipType GetCorrespondingBusTerminusType(ChipType type)
ChipType.Bus_1Bit => ChipType.BusTerminus_1Bit,
ChipType.Bus_4Bit => ChipType.BusTerminus_4Bit,
ChipType.Bus_8Bit => ChipType.BusTerminus_8Bit,
ChipType.Bus_16Bit => ChipType.BusTerminus_16Bit,
_ => throw new Exception("No corresponding bus terminus found for type: " + type)
};
}
Expand All @@ -82,6 +97,7 @@ public static ChipType GetPinType(bool isInput, PinBitCount numBits)
PinBitCount.Bit1 => ChipType.In_1Bit,
PinBitCount.Bit4 => ChipType.In_4Bit,
PinBitCount.Bit8 => ChipType.In_8Bit,
PinBitCount.Bit16 => ChipType.In_16Bit,
_ => throw new Exception("No input pin type found for bitcount: " + numBits)
};
}
Expand All @@ -91,6 +107,7 @@ public static ChipType GetPinType(bool isInput, PinBitCount numBits)
PinBitCount.Bit1 => ChipType.Out_1Bit,
PinBitCount.Bit4 => ChipType.Out_4Bit,
PinBitCount.Bit8 => ChipType.Out_8Bit,
PinBitCount.Bit16 => ChipType.Out_16Bit,
_ => throw new Exception("No output pin type found for bitcount: " + numBits)
};
}
Expand All @@ -105,6 +122,8 @@ public static (bool isInput, bool isOutput, PinBitCount numBits) IsInputOrOutput
ChipType.Out_4Bit => (false, true, PinBitCount.Bit4),
ChipType.In_8Bit => (true, false, PinBitCount.Bit8),
ChipType.Out_8Bit => (false, true, PinBitCount.Bit8),
ChipType.In_16Bit => (true, false, PinBitCount.Bit16),
ChipType.Out_16Bit => (false, true, PinBitCount.Bit16),
_ => (false, false, PinBitCount.Bit1)
};
}
Expand Down
15 changes: 14 additions & 1 deletion Assets/Scripts/Description/Types/SubTypes/ChipTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,41 @@ public enum ChipType

// ---- Memory ----
dev_Ram_8Bit,
Rom_256x2x8,
Rom_256x16,
Rom_256x32,

// ---- Displays ----
SevenSegmentDisplay,
DisplayRGB,
DisplayDot,
DisplayLED,
DisplayRGBLED,
DisplayAscii_8Bit,

// ---- Merge / Split ----
Merge_1To4Bit,
Merge_1To8Bit,
Merge_4To8Bit,
Merge_1To16Bit,
Merge_4To16Bit,
Merge_8To16Bit,
Split_4To1Bit,
Split_8To4Bit,
Split_8To1Bit,
Split_16To1Bit,
Split_16To4Bit,
Split_16To8Bit,

// ---- In / Out Pins ----
In_1Bit,
In_4Bit,
In_8Bit,
In_16Bit,
Out_1Bit,
Out_4Bit,
Out_8Bit,
Out_16Bit,

Key,

Expand All @@ -45,9 +57,10 @@ public enum ChipType
BusTerminus_4Bit,
Bus_8Bit,
BusTerminus_8Bit,
Bus_16Bit,
BusTerminus_16Bit,

// ---- Audio ----
Buzzer

}
}
3 changes: 2 additions & 1 deletion Assets/Scripts/Description/Types/SubTypes/PinDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public enum PinBitCount
{
Bit1 = 1,
Bit4 = 4,
Bit8 = 8
Bit8 = 8,
Bit16 = 16
}

public enum PinColour
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Game/Elements/DevPinInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public DevPinInstance(PinDescription pinDescription, bool isInput)
PinBitCount.Bit1 => new Vector2Int(1, 1),
PinBitCount.Bit4 => new Vector2Int(2, 2),
PinBitCount.Bit8 => new Vector2Int(4, 2),
PinBitCount.Bit16 => new Vector2Int(4, 4),
_ => throw new Exception("Bit count not implemented")
};
StateGridSize = BitCount switch
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Game/Elements/SubChipInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ public static float PinHeightFromBitCount(PinBitCount bitCount)
PinBitCount.Bit1 => DrawSettings.PinRadius * 2,
PinBitCount.Bit4 => DrawSettings.PinHeight4Bit,
PinBitCount.Bit8 => DrawSettings.PinHeight8Bit,
PinBitCount.Bit16 => DrawSettings.PinHeight16Bit,
_ => throw new Exception("Bit count not implemented " + bitCount)
};
}
Expand Down
Loading