Start implementing primitives and entities

This commit is contained in:
Nahuel Rocchetti 2023-08-21 13:41:18 -03:00
parent 2bb732b4d6
commit 6009d9f121
7 changed files with 80 additions and 14 deletions

View file

@ -14,6 +14,9 @@ namespace OpenTS2.SimAntics
public class Node public class Node
{ {
public const ushort ErrorReturnValue = 0xFFFC;
public const ushort TrueReturnValue = 0xFFFD;
public const ushort FalseReturnValue = 0xFFFE;
public ushort OpCode; public ushort OpCode;
public ushort TrueTarget; public ushort TrueTarget;
public ushort FalseTarget; public ushort FalseTarget;

View file

@ -104,13 +104,14 @@ namespace OpenTS2.SimAntics
{ {
// None / Error // None / Error
case 0xFD: case 0xFD:
return 0xFFFC; return BHAVAsset.Node.ErrorReturnValue;
// True // True
case 0xFE: case 0xFE:
return 0xFFFD; return BHAVAsset.Node.TrueReturnValue;
// False // False
case 0xFF: case 0xFF:
return 0xFFFE; return BHAVAsset.Node.FalseReturnValue;
// probably already an okay value
default: default:
return target; return target;
} }

View file

@ -6,16 +6,6 @@ namespace OpenTS2.SimAntics
{ {
public class VM public class VM
{ {
// Start is called before the first frame update public List<VMEntity> Entities = new List<VMEntity>();
void Start()
{
}
// Update is called once per frame
void Update()
{
}
} }
} }

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenTS2.SimAntics
{
public class VMEntity
{
public ushort ID = 1;
public short[] Temps = new short[20];
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17d0bfd1bb2c4ab48a5e03c6c55d4c3d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenTS2.SimAntics
{
public abstract class VMPrimitive
{
public abstract ReturnValue Execute();
public enum ExitCode : byte
{
GoToTrue,
GoToFalse
}
public struct ReturnValue
{
private ExitCode Code;
public int Ticks;
public static ReturnValue GoToTrue = new ReturnValue { Code = ExitCode.GoToTrue, Ticks = 0 };
public static ReturnValue GoToFalse = new ReturnValue { Code = ExitCode.GoToFalse, Ticks = 0 };
public static ReturnValue ContinueOnFutureTick( ExitCode exitCode, int ticksToSleep )
{
return new ReturnValue
{
Code = exitCode,
Ticks = ticksToSleep
};
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 636b30d1f9f76fa4b8ff19785fe663f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: