From f301968ea119afadb2790b1e7b9c0ada3a2b5c24 Mon Sep 17 00:00:00 2001 From: BeboKhouja <73379481+BeboKhouja@users.noreply.github.com> Date: Fri, 23 May 2025 22:00:07 +0700 Subject: [PATCH 1/5] Add RTC --- .vscode/extensions.json | 5 + .vscode/launch.json | 10 ++ .vscode/settings.json | 70 +++++++++ .../Description/Helpers/ChipTypeHelper.cs | 3 + .../Description/Types/SubTypes/ChipTypes.cs | 5 +- .../Game/Project/BuiltinChipCreator.cs | 22 ++- Assets/Scripts/Simulation/Simulator.cs | 10 ++ ProjectSettings/ProjectVersion.txt | 4 +- .../Projects/MainTest/Chips/BuzzTest.json | 2 +- TestData/Projects/MainTest/Chips/RTCTest.json | 135 ++++++++++++++++++ .../Projects/MainTest/ProjectDescription.json | 15 +- 11 files changed, 271 insertions(+), 10 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 TestData/Projects/MainTest/Chips/RTCTest.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..ddb6ff85 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "visualstudiotoolsforunity.vstuc" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..da60e25a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,10 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Unity", + "type": "vstuc", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..12dd4d4f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,70 @@ +{ + "files.exclude": { + "**/.DS_Store": true, + "**/.git": true, + "**/.vs": true, + "**/.gitmodules": true, + "**/.vsconfig": true, + "**/*.booproj": true, + "**/*.pidb": true, + "**/*.suo": true, + "**/*.user": true, + "**/*.userprefs": true, + "**/*.unityproj": true, + "**/*.dll": true, + "**/*.exe": true, + "**/*.pdf": true, + "**/*.mid": true, + "**/*.midi": true, + "**/*.wav": true, + "**/*.gif": true, + "**/*.ico": true, + "**/*.jpg": true, + "**/*.jpeg": true, + "**/*.png": true, + "**/*.psd": true, + "**/*.tga": true, + "**/*.tif": true, + "**/*.tiff": true, + "**/*.3ds": true, + "**/*.3DS": true, + "**/*.fbx": true, + "**/*.FBX": true, + "**/*.lxo": true, + "**/*.LXO": true, + "**/*.ma": true, + "**/*.MA": true, + "**/*.obj": true, + "**/*.OBJ": true, + "**/*.asset": true, + "**/*.cubemap": true, + "**/*.flare": true, + "**/*.mat": true, + "**/*.meta": true, + "**/*.prefab": true, + "**/*.unity": true, + "build/": true, + "Build/": true, + "Library/": true, + "library/": true, + "obj/": true, + "Obj/": true, + "Logs/": true, + "logs/": true, + "ProjectSettings/": true, + "UserSettings/": true, + "temp/": true, + "Temp/": true + }, + "files.associations": { + "*.asset": "yaml", + "*.meta": "yaml", + "*.prefab": "yaml", + "*.unity": "yaml", + }, + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.patterns": { + "*.sln": "*.csproj", + }, + "dotnet.defaultSolution": "Digital-Logic-Sim.sln" +} \ No newline at end of file diff --git a/Assets/Scripts/Description/Helpers/ChipTypeHelper.cs b/Assets/Scripts/Description/Helpers/ChipTypeHelper.cs index 3d1e60d0..e8c027fd 100644 --- a/Assets/Scripts/Description/Helpers/ChipTypeHelper.cs +++ b/Assets/Scripts/Description/Helpers/ChipTypeHelper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using UnityEngine.TextCore.Text; namespace DLS.Description { @@ -33,6 +34,8 @@ public static class ChipTypeHelper { ChipType.Buzzer, "BUZZER" }, + { ChipType.RTC, "RTC" }, + // ---- Not really chips (but convenient to treat them as such anyway) ---- // ---- Inputs/Outputs ---- diff --git a/Assets/Scripts/Description/Types/SubTypes/ChipTypes.cs b/Assets/Scripts/Description/Types/SubTypes/ChipTypes.cs index 610f0298..a61f01c0 100644 --- a/Assets/Scripts/Description/Types/SubTypes/ChipTypes.cs +++ b/Assets/Scripts/Description/Types/SubTypes/ChipTypes.cs @@ -47,7 +47,10 @@ public enum ChipType BusTerminus_8Bit, // ---- Audio ---- - Buzzer + Buzzer, + + // ---- Time ---- + RTC, } } \ No newline at end of file diff --git a/Assets/Scripts/Game/Project/BuiltinChipCreator.cs b/Assets/Scripts/Game/Project/BuiltinChipCreator.cs index c757f1e1..42b3f243 100644 --- a/Assets/Scripts/Game/Project/BuiltinChipCreator.cs +++ b/Assets/Scripts/Game/Project/BuiltinChipCreator.cs @@ -51,7 +51,9 @@ public static ChipDescription[] CreateAllBuiltinChipDescriptions() CreateBus(PinBitCount.Bit8), CreateBusTerminus(PinBitCount.Bit8), // ---- Audio ---- - CreateBuzzer() + CreateBuzzer(), + // ---- Time ---- + CreateRTC(), }; } @@ -82,6 +84,24 @@ static ChipDescription CreateBuzzer() return CreateBuiltinChipDescription(ChipType.Buzzer, size, col, inputPins, null, null); } + static ChipDescription CreateRTC() + { + Color col = new(0.4f, 0.4f, 0.4f); + + PinDescription[] outputPins = + { + CreatePinDescription("D", 3, PinBitCount.Bit8), + CreatePinDescription("C", 2, PinBitCount.Bit8), + CreatePinDescription("B", 1, PinBitCount.Bit8), + CreatePinDescription("A", 0, PinBitCount.Bit8), + }; + + float height = SubChipInstance.MinChipHeightForPins(outputPins, null); + Vector2 size = new(CalculateGridSnappedWidth(GridSize * 9), height); + + return CreateBuiltinChipDescription(ChipType.RTC, size, col, null, outputPins); + } + static ChipDescription dev_CreateRAM_8() { Color col = new(0.85f, 0.45f, 0.3f); diff --git a/Assets/Scripts/Simulation/Simulator.cs b/Assets/Scripts/Simulation/Simulator.cs index 1d777628..323f51cb 100644 --- a/Assets/Scripts/Simulation/Simulator.cs +++ b/Assets/Scripts/Simulation/Simulator.cs @@ -506,6 +506,16 @@ static void ProcessBuiltinChip(SimChip chip) audioState.RegisterNote(freqIndex, (uint)volumeIndex); break; } + case ChipType.RTC: + { + const uint ByteMask = 0b11111111; + int unixTime = (int) DateTimeOffset.UtcNow.ToUnixTimeSeconds(); + chip.OutputPins[0].State = (ushort)((unixTime >> 24) & ByteMask); + chip.OutputPins[1].State = (ushort)((unixTime >> 16) & ByteMask); + chip.OutputPins[2].State = (ushort)((unixTime >> 8) & ByteMask); + chip.OutputPins[3].State = (ushort)(unixTime & ByteMask); + break; + } // ---- Bus types ---- default: { diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 8678d93f..7a12cc2b 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 6000.0.46f1 -m_EditorVersionWithRevision: 6000.0.46f1 (fb93bc360d3a) +m_EditorVersion: 6000.0.49f1 +m_EditorVersionWithRevision: 6000.0.49f1 (840e0a9776d9) diff --git a/TestData/Projects/MainTest/Chips/BuzzTest.json b/TestData/Projects/MainTest/Chips/BuzzTest.json index 40fc6f42..17d284ca 100644 --- a/TestData/Projects/MainTest/Chips/BuzzTest.json +++ b/TestData/Projects/MainTest/Chips/BuzzTest.json @@ -1,5 +1,5 @@ { - "DLSVersion": "2.1.5", + "DLSVersion": "2.1.6", "Name": "BuzzTest", "NameLocation": 0, "ChipType": 0, diff --git a/TestData/Projects/MainTest/Chips/RTCTest.json b/TestData/Projects/MainTest/Chips/RTCTest.json new file mode 100644 index 00000000..93127ad3 --- /dev/null +++ b/TestData/Projects/MainTest/Chips/RTCTest.json @@ -0,0 +1,135 @@ +{ + "DLSVersion": "2.1.6", + "Name": "RTCTest", + "NameLocation": 0, + "ChipType": 0, + "Size": { + "x": 1.175, + "y": 2.0 + }, + "Colour": { + "r": 0.8187522, + "g": 0.385453254, + "b": 0.334759057, + "a": 1 + }, + "InputPins":[], + "OutputPins":[ + { + "Name":"OUT", + "ID":1492030497, + "Position":{ + "x":1.25, + "y":1.0 + }, + "BitCount":8, + "Colour":0, + "ValueDisplayMode":1 + }, + { + "Name":"OUT", + "ID":900692905, + "Position":{ + "x":1.25, + "y":0.5 + }, + "BitCount":8, + "Colour":0, + "ValueDisplayMode":1 + }, + { + "Name":"OUT", + "ID":1767071873, + "Position":{ + "x":1.25, + "y":0.0 + }, + "BitCount":8, + "Colour":0, + "ValueDisplayMode":1 + }, + { + "Name":"OUT", + "ID":1820587991, + "Position":{ + "x":1.25, + "y":-0.5 + }, + "BitCount":8, + "Colour":0, + "ValueDisplayMode":1 + } + ], + "SubChips":[ + { + "Name":"RTC", + "ID":2097162199, + "Label":"", + "Position":{ + "x":-1.0, + "y":0.25 + }, + "OutputPinColourInfo":[{"PinColour":0,"PinID":3},{"PinColour":0,"PinID":2},{"PinColour":0,"PinID":1},{"PinColour":0,"PinID":0}], + "InternalData":null + } + ], + "Wires":[ + { + "SourcePinAddress":{ + "PinID":3, + "PinOwnerID":2097162199 + }, + "TargetPinAddress":{ + "PinID":0, + "PinOwnerID":1492030497 + }, + "ConnectionType":0, + "ConnectedWireIndex":-1, + "ConnectedWireSegmentIndex":-1, + "Points":[{"x":0.0,"y":0.0},{"x":0.0,"y":0.0}] + }, + { + "SourcePinAddress":{ + "PinID":2, + "PinOwnerID":2097162199 + }, + "TargetPinAddress":{ + "PinID":0, + "PinOwnerID":900692905 + }, + "ConnectionType":0, + "ConnectedWireIndex":-1, + "ConnectedWireSegmentIndex":-1, + "Points":[{"x":0.0,"y":0.0},{"x":0.0,"y":0.0}] + }, + { + "SourcePinAddress":{ + "PinID":1, + "PinOwnerID":2097162199 + }, + "TargetPinAddress":{ + "PinID":0, + "PinOwnerID":1767071873 + }, + "ConnectionType":0, + "ConnectedWireIndex":-1, + "ConnectedWireSegmentIndex":-1, + "Points":[{"x":0.0,"y":0.0},{"x":0.0,"y":0.0}] + }, + { + "SourcePinAddress":{ + "PinID":0, + "PinOwnerID":2097162199 + }, + "TargetPinAddress":{ + "PinID":0, + "PinOwnerID":1820587991 + }, + "ConnectionType":0, + "ConnectedWireIndex":-1, + "ConnectedWireSegmentIndex":-1, + "Points":[{"x":0.0,"y":0.0},{"x":0.0,"y":0.0}] + } + ], + "Displays": null +} \ No newline at end of file diff --git a/TestData/Projects/MainTest/ProjectDescription.json b/TestData/Projects/MainTest/ProjectDescription.json index 6d1823ff..46922961 100644 --- a/TestData/Projects/MainTest/ProjectDescription.json +++ b/TestData/Projects/MainTest/ProjectDescription.json @@ -1,9 +1,9 @@ { "ProjectName": "MainTest", - "DLSVersion_LastSaved": "2.1.5", + "DLSVersion_LastSaved": "2.1.6", "DLSVersion_EarliestCompatible": "2.0.0", - "CreationTime": "2025-03-14T18:23:30.404+01:00", - "LastSaveTime": "2025-05-04T09:15:41.061+02:00", + "CreationTime": "2025-03-15T00:23:30.404+07:00", + "LastSaveTime": "2025-05-23T21:42:49.409+07:00", "Prefs_MainPinNamesDisplayMode": 2, "Prefs_ChipPinNamesDisplayMode": 1, "Prefs_GridDisplayMode": 1, @@ -62,7 +62,8 @@ "RAM-sync", "TEST MergeSplit", "#", - "BuzzTest" + "BuzzTest", + "RTCTest" ], "StarredList":[ { @@ -96,6 +97,10 @@ { "Name":"BuzzTest", "IsCollection":false + }, + { + "Name":"RTCTest", + "IsCollection":false } ], "ChipCollections":[ @@ -140,7 +145,7 @@ "Name":"TEST" }, { - "Chips":["PULSE","TEST MergeSplit"], + "Chips":["PULSE","TEST MergeSplit","BUZZER","RTC","#","BuzzTest"], "IsToggledOpen":true, "Name":"OTHER" } From 75cc289c4b4403321db15887655e27c48348d0b2 Mon Sep 17 00:00:00 2001 From: BeboKhouja <73379481+BeboKhouja@users.noreply.github.com> Date: Sat, 31 May 2025 18:52:14 +0700 Subject: [PATCH 2/5] Update gitignore to ignore vscode dirs --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index dc00d664..b5563351 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,9 @@ # Visual Studio cache directory .vs/ +# Visual Studio Code directory +.vscode/ + # Gradle cache directory .gradle/ From 54de44d94721896d8ee45fa2568367546142b025 Mon Sep 17 00:00:00 2001 From: BeboKhouja <73379481+BeboKhouja@users.noreply.github.com> Date: Sat, 31 May 2025 18:59:08 +0700 Subject: [PATCH 3/5] Remove vscode dirs --- .vscode/extensions.json | 5 --- .vscode/launch.json | 10 ------ .vscode/settings.json | 70 ----------------------------------------- 3 files changed, 85 deletions(-) delete mode 100644 .vscode/extensions.json delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index ddb6ff85..00000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "recommendations": [ - "visualstudiotoolsforunity.vstuc" - ] -} diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index da60e25a..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Attach to Unity", - "type": "vstuc", - "request": "attach" - } - ] -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 12dd4d4f..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "files.exclude": { - "**/.DS_Store": true, - "**/.git": true, - "**/.vs": true, - "**/.gitmodules": true, - "**/.vsconfig": true, - "**/*.booproj": true, - "**/*.pidb": true, - "**/*.suo": true, - "**/*.user": true, - "**/*.userprefs": true, - "**/*.unityproj": true, - "**/*.dll": true, - "**/*.exe": true, - "**/*.pdf": true, - "**/*.mid": true, - "**/*.midi": true, - "**/*.wav": true, - "**/*.gif": true, - "**/*.ico": true, - "**/*.jpg": true, - "**/*.jpeg": true, - "**/*.png": true, - "**/*.psd": true, - "**/*.tga": true, - "**/*.tif": true, - "**/*.tiff": true, - "**/*.3ds": true, - "**/*.3DS": true, - "**/*.fbx": true, - "**/*.FBX": true, - "**/*.lxo": true, - "**/*.LXO": true, - "**/*.ma": true, - "**/*.MA": true, - "**/*.obj": true, - "**/*.OBJ": true, - "**/*.asset": true, - "**/*.cubemap": true, - "**/*.flare": true, - "**/*.mat": true, - "**/*.meta": true, - "**/*.prefab": true, - "**/*.unity": true, - "build/": true, - "Build/": true, - "Library/": true, - "library/": true, - "obj/": true, - "Obj/": true, - "Logs/": true, - "logs/": true, - "ProjectSettings/": true, - "UserSettings/": true, - "temp/": true, - "Temp/": true - }, - "files.associations": { - "*.asset": "yaml", - "*.meta": "yaml", - "*.prefab": "yaml", - "*.unity": "yaml", - }, - "explorer.fileNesting.enabled": true, - "explorer.fileNesting.patterns": { - "*.sln": "*.csproj", - }, - "dotnet.defaultSolution": "Digital-Logic-Sim.sln" -} \ No newline at end of file From 2a3e0451d86eda19ce2d1d88da3da49747c7ac9a Mon Sep 17 00:00:00 2001 From: BeboKhouja <73379481+BeboKhouja@users.noreply.github.com> Date: Sat, 31 May 2025 19:25:39 +0700 Subject: [PATCH 4/5] Gitignore projectversion --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b5563351..94eef259 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,6 @@ crashlytics-build.properties /[Aa]ssets/[Ss]treamingAssets/aa/* /.idea /.vsconfig + +# Why not gitignore the f****** projectversion +ProjectSettings/ProjectVersion.txt From cb2567532306cc089a620124e9328453a32c40e9 Mon Sep 17 00:00:00 2001 From: BeboKhouja <73379481+BeboKhouja@users.noreply.github.com> Date: Sat, 31 May 2025 19:27:30 +0700 Subject: [PATCH 5/5] Change projectversion --- ProjectSettings/ProjectVersion.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 7a12cc2b..8678d93f 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 6000.0.49f1 -m_EditorVersionWithRevision: 6000.0.49f1 (840e0a9776d9) +m_EditorVersion: 6000.0.46f1 +m_EditorVersionWithRevision: 6000.0.46f1 (fb93bc360d3a)