Exemple #1
0
        private static void ExecuteAlphaAssignment()
        {
            long?targetPos = null;
            bool isBuffer  = false;

            targetPos = MemPos.GetPosAlpha(_tokens[_tokenNum]);
            if (!targetPos.HasValue)
            {
                targetPos = MemPos.GetPosBufferAlpha(_tokens[_tokenNum]);
                if (targetPos.HasValue)
                {
                    isBuffer = true;
                }
            }
            if (!targetPos.HasValue)
            {
                throw new SystemException("Cannot parse alpha assignment: Target not found");
            }
            _tokenNum++;
            if (_tokens[_tokenNum] == "[")
            {
                _tokenNum++; // "["
                long offset = GetNumericExpression();
                if (_tokens[_tokenNum++] != "]")
                {
                    throw new SystemException("ExecuteAlphaAssignment: No closing \"]\"");
                }
                targetPos += offset;
            }
            if (_tokens[_tokenNum] != "=")
            {
                throw new SystemException("Cannot parse alpha expression: Equals sign expected");
            }
            _tokenNum++;
            string result = GetAlphaExpression();

            if (isBuffer)
            {
                long bufferTargetPos = Mem.GetByte(targetPos.Value)
                                       + (256 * Mem.GetByte(targetPos.Value + 1));
                Mem.SetAlpha(bufferTargetPos, result);
                if (result == "")
                {
                    bufferTargetPos += 1;
                }
                else
                {
                    bufferTargetPos += result.Length;
                }
                Mem.SetByte(targetPos.Value + 1, bufferTargetPos / 256);
                Mem.SetByte(targetPos.Value, bufferTargetPos % 256);
            }
            else
            {
                Mem.SetAlpha(targetPos.Value, result);
            }
        }
Exemple #2
0
 private static bool IsAlphaTarget()
 {
     if (MemPos.GetPosAlpha(_tokens[_tokenNum]).HasValue ||
         MemPos.GetPosBufferAlpha(_tokens[_tokenNum]).HasValue)
     {
         if (_tokenNum < _tokenCount)
         {
             if (_tokens[_tokenNum + 1] == "=" ||
                 _tokens[_tokenNum + 1] == "[")
             {
                 return(true);
             }
         }
     }
     return(false);
 }