Skip to content

Commit b9ebb58

Browse files
Merge branch 'main' into feat-SPSChip
2 parents b92cc58 + 6d943bb commit b9ebb58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1952
-67
lines changed

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"visualstudiotoolsforunity.vstuc"
4+
]
5+
}

.vscode/launch.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to Unity",
6+
"type": "vstuc",
7+
"request": "attach"
8+
}
9+
]
10+
}

.vscode/settings.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"files.exclude": {
3+
"**/.DS_Store": true,
4+
"**/.git": true,
5+
"**/.vs": true,
6+
"**/.gitmodules": true,
7+
"**/.vsconfig": true,
8+
"**/*.booproj": true,
9+
"**/*.pidb": true,
10+
"**/*.suo": true,
11+
"**/*.user": true,
12+
"**/*.userprefs": true,
13+
"**/*.unityproj": true,
14+
"**/*.dll": true,
15+
"**/*.exe": true,
16+
"**/*.pdf": true,
17+
"**/*.mid": true,
18+
"**/*.midi": true,
19+
"**/*.wav": true,
20+
"**/*.gif": true,
21+
"**/*.ico": true,
22+
"**/*.jpg": true,
23+
"**/*.jpeg": true,
24+
"**/*.png": true,
25+
"**/*.psd": true,
26+
"**/*.tga": true,
27+
"**/*.tif": true,
28+
"**/*.tiff": true,
29+
"**/*.3ds": true,
30+
"**/*.3DS": true,
31+
"**/*.fbx": true,
32+
"**/*.FBX": true,
33+
"**/*.lxo": true,
34+
"**/*.LXO": true,
35+
"**/*.ma": true,
36+
"**/*.MA": true,
37+
"**/*.obj": true,
38+
"**/*.OBJ": true,
39+
"**/*.asset": true,
40+
"**/*.cubemap": true,
41+
"**/*.flare": true,
42+
"**/*.mat": true,
43+
"**/*.meta": true,
44+
"**/*.prefab": true,
45+
"**/*.unity": true,
46+
"build/": true,
47+
"Build/": true,
48+
"Library/": true,
49+
"library/": true,
50+
"obj/": true,
51+
"Obj/": true,
52+
"Logs/": true,
53+
"logs/": true,
54+
"ProjectSettings/": true,
55+
"UserSettings/": true,
56+
"temp/": true,
57+
"Temp/": true
58+
},
59+
"files.associations": {
60+
"*.asset": "yaml",
61+
"*.meta": "yaml",
62+
"*.prefab": "yaml",
63+
"*.unity": "yaml",
64+
},
65+
"explorer.fileNesting.enabled": true,
66+
"explorer.fileNesting.patterns": {
67+
"*.sln": "*.csproj",
68+
},
69+
"dotnet.defaultSolution": "Digital-Logic-Sim.sln"
70+
}

Assets/Scripts/Description/Helpers/ChipTypeHelper.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using UnityEngine.TextCore.Text;
34

45
namespace DLS.Description
56
{
@@ -14,9 +15,11 @@ public static class ChipTypeHelper
1415
{ ChipType.Clock, "CLOCK" },
1516
{ ChipType.Pulse, "PULSE" },
1617
{ ChipType.TriStateBuffer, "3-STATE BUFFER" },
18+
{ ChipType.Constant_8Bit, "CONST" },
1719
// ---- Memory ----
18-
{ ChipType.dev_Ram_8Bit, "dev.RAM-8" },
20+
{ ChipType.dev_Ram_8Bit, "RAM-8" },
1921
{ ChipType.Rom_256x16, $"ROM 256{mulSymbol}16" },
22+
{ ChipType.EEPROM_256x16, $"EEPROM 256{mulSymbol}16" },
2023
// ---- Split / Merge ----
2124
{ ChipType.Split_4To1Bit, "4-1BIT" },
2225
{ ChipType.Split_8To1Bit, "8-1BIT" },
@@ -34,6 +37,7 @@ public static class ChipTypeHelper
3437
{ ChipType.Buzzer, "BUZZER" },
3538

3639
{ ChipType.SPS, "SPS" },
40+
{ ChipType.RTC, "RTC" },
3741

3842
// ---- Not really chips (but convenient to treat them as such anyway) ----
3943

@@ -45,6 +49,9 @@ public static class ChipTypeHelper
4549
{ ChipType.Out_4Bit, "OUT-4" },
4650
{ ChipType.Out_8Bit, "OUT-8" },
4751
{ ChipType.Key, "KEY" },
52+
{ ChipType.Button, "BUTTON" },
53+
{ ChipType.Toggle, "DIPSWITCH" },
54+
4855
// ---- Buses ----
4956
{ ChipType.Bus_1Bit, "BUS-1" },
5057
{ ChipType.Bus_4Bit, "BUS-4" },
@@ -62,7 +69,7 @@ public static class ChipTypeHelper
6269

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

65-
public static bool IsRomType(ChipType type) => type == ChipType.Rom_256x16;
72+
public static bool IsRomType(ChipType type) => type == ChipType.Rom_256x16 || type == ChipType.EEPROM_256x16;
6673

6774
public static ChipType GetCorrespondingBusTerminusType(ChipType type)
6875
{
@@ -110,5 +117,15 @@ public static (bool isInput, bool isOutput, PinBitCount numBits) IsInputOrOutput
110117
_ => (false, false, PinBitCount.Bit1)
111118
};
112119
}
120+
121+
public static bool IsClickableDisplayType(ChipType type) {
122+
// Return true for any chiptype that is a clickable display
123+
124+
return type == ChipType.Button || type == ChipType.Toggle;
125+
}
126+
127+
public static bool IsInternalDataModifiable(ChipType type) {
128+
return type == ChipType.EEPROM_256x16 || type == ChipType.Toggle;
129+
}
113130
}
114131
}

Assets/Scripts/Description/Types/SubTypes/ChipTypes.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public enum ChipType
1313
// ---- Memory ----
1414
dev_Ram_8Bit,
1515
Rom_256x16,
16+
EEPROM_256x16,
1617

1718
// ---- Displays ----
1819
SevenSegmentDisplay,
@@ -38,8 +39,13 @@ public enum ChipType
3839

3940
Key,
4041

41-
// ---- Buses ----
42-
Bus_1Bit,
42+
Button,
43+
Toggle,
44+
45+
Constant_8Bit,
46+
47+
// ---- Buses ----
48+
Bus_1Bit,
4349
BusTerminus_1Bit,
4450
Bus_4Bit,
4551
BusTerminus_4Bit,
@@ -49,6 +55,9 @@ public enum ChipType
4955
// ---- Audio ----
5056
Buzzer,
5157

58+
// ---- Time ----
59+
RTC,
60+
5261
// ---- Clock ----
5362
SPS,
5463
}

Assets/Scripts/Game/Elements/DisplayInstance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace DLS.Game
66
{
7-
public class DisplayInstance
7+
public class DisplayInstance : IClickable
88
{
99
public List<DisplayInstance> ChildDisplays;
1010
public DisplayDescription Desc;

Assets/Scripts/Game/Elements/SubChipInstance.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,12 @@ public void FlipBus()
378378
}
379379
}
380380

381+
public void UpdateInternalData(uint[] data)
382+
{
383+
if (!ChipTypeHelper.IsInternalDataModifiable(ChipType)) throw new Exception("Internal Data is not modifiable for the type of chip : " + ChipTypeHelper.GetName(ChipType));
384+
Array.Copy(data, InternalData, data.Length);
385+
}
386+
381387
void LoadOutputPinColours(OutputPinColourInfo[] cols)
382388
{
383389
if (cols == null) return;

Assets/Scripts/Game/Interaction/ChipInteractionController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class ChipInteractionController
5050
public bool CanInteractWithPin => CanInteract;
5151
public bool CanInteractWithPinStateDisplay => CanInteract && !IsCreatingWire && Project.ActiveProject.CanEditViewedChip;
5252
public bool CanInteractWithPinHandle => CanInteractWithPinStateDisplay;
53-
53+
public bool CanInteractWithButton => CanInteract;
5454

5555
public ChipInteractionController(Project project)
5656
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Numerics;
2+
using Seb.Types;
3+
4+
namespace DLS.Game
5+
{
6+
public interface IClickable : IInteractable
7+
{
8+
9+
}
10+
}

Assets/Scripts/Game/Interaction/Interfaces/IClickable.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)