Exemplo n.º 1
0
        public int?GetMemoryValue(RolandFileMemory memory)
        {
            var data = memory.GetFromFile(FileAddress, PrimitiveTypeLength);

            if (data == null)
            {
                return(null);
            }

            return(DecodeValueAsInt(data, PrimitiveTypeLength, PrimitiveTypeBits));
        }
Exemplo n.º 2
0
        public (byte[] address, byte[] data) ConvertMemoryValue(RolandFileMemory memory)
        {
            if (PrimitiveTypeName == "string")
            {
                return(null, null);
            }

            int?defaultValue = null;

            if (int.TryParse(DefaultValue, out int defaultInt))
            {
                defaultValue = defaultInt;
            }

            var tmpMemVal = GetMemoryValue(memory);

            if (tmpMemVal == null)
            {
                return(null, null);
            }

            var memVal = (int)tmpMemVal;

            if (OverrideMemory)
            {
                memVal = OverrideMemoryValue;
            }

            if (!IsValueInsideRange(memVal))
            {
                if (defaultValue != null)
                {
                    memVal = (int)defaultValue;
                }
                else
                {
                    throw new Exception("Value outside of range but default is not specified");
                }
            }

            var addr = BigEndian.GetBytes(MemoryAddress);

            return(addr, BigEndian.GetBytes(memVal));
        }