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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
# Visual Studio cache directory
.vs/

# Visual Studio Code directory
.vscode/

# Gradle cache directory
.gradle/

Expand Down Expand Up @@ -71,3 +74,6 @@ crashlytics-build.properties
/[Aa]ssets/[Ss]treamingAssets/aa/*
/.idea
/.vsconfig

# Why not gitignore the f****** projectversion
ProjectSettings/ProjectVersion.txt
3 changes: 3 additions & 0 deletions Assets/Scripts/Description/Helpers/ChipTypeHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using UnityEngine.TextCore.Text;

namespace DLS.Description
{
Expand Down Expand Up @@ -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 ----
Expand Down
5 changes: 4 additions & 1 deletion Assets/Scripts/Description/Types/SubTypes/ChipTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public enum ChipType
BusTerminus_8Bit,

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

// ---- Time ----
RTC,

}
}
22 changes: 21 additions & 1 deletion Assets/Scripts/Game/Project/BuiltinChipCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public static ChipDescription[] CreateAllBuiltinChipDescriptions()
CreateBus(PinBitCount.Bit8),
CreateBusTerminus(PinBitCount.Bit8),
// ---- Audio ----
CreateBuzzer()
CreateBuzzer(),
// ---- Time ----
CreateRTC(),
};
}

Expand Down Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions Assets/Scripts/Simulation/Simulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
{
Expand Down
2 changes: 1 addition & 1 deletion TestData/Projects/MainTest/Chips/BuzzTest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"DLSVersion": "2.1.5",
"DLSVersion": "2.1.6",
"Name": "BuzzTest",
"NameLocation": 0,
"ChipType": 0,
Expand Down
135 changes: 135 additions & 0 deletions TestData/Projects/MainTest/Chips/RTCTest.json
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 10 additions & 5 deletions TestData/Projects/MainTest/ProjectDescription.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -62,7 +62,8 @@
"RAM-sync",
"TEST MergeSplit",
"#",
"BuzzTest"
"BuzzTest",
"RTCTest"
],
"StarredList":[
{
Expand Down Expand Up @@ -96,6 +97,10 @@
{
"Name":"BuzzTest",
"IsCollection":false
},
{
"Name":"RTCTest",
"IsCollection":false
}
],
"ChipCollections":[
Expand Down Expand Up @@ -140,7 +145,7 @@
"Name":"TEST"
},
{
"Chips":["PULSE","TEST MergeSplit"],
"Chips":["PULSE","TEST MergeSplit","BUZZER","RTC","#","BuzzTest"],
"IsToggledOpen":true,
"Name":"OTHER"
}
Expand Down