Example #1
0
 /// <summary>
 /// Determines whether a zscii character is a valid function key code.
 /// </summary>
 /// <param name="zsciiCharacter">
 /// The zscii character.
 /// </param>
 /// <returns>
 /// A value indicating whether the zscii character is a valid function key code.
 /// </returns>
 protected static bool ValidFunctionKeyCode(Zscii zsciiCharacter)
 {
     return zsciiCharacter >= Zscii.CursorUp && zsciiCharacter <= Zscii.NumberPad9;
 }
Example #2
0
        /// <summary>
        /// Gets the index of a character in the zscii alphabet.
        /// </summary>
        /// <param name="zsciiCharacter">
        /// The character.
        /// </param>
        /// <returns>
        /// The index of the character or -1 if the character is not found.
        /// </returns>
        private int GetZsciiAlphabetIndex(Zscii zsciiCharacter)
        {
            const byte ZsciiAlphabetCharacterCount = 78;
            for (byte zsciiAlphabetIndex = 0; zsciiAlphabetIndex < ZsciiAlphabetCharacterCount; zsciiAlphabetIndex++)
            {
                if (zsciiCharacter == this.GetZsciiAlphabetCharacter(zsciiAlphabetIndex))
                {
                    return zsciiAlphabetIndex;
                }
            }

            return -1;
        }
Example #3
0
 /// <summary>
 /// Determines if a mouse click type is valid.
 /// </summary>
 /// <param name="zsciiCharacter">
 /// The zscii character.
 /// </param>
 /// <returns>
 /// A value indicating whether the mouse click type is valid.
 /// </returns>
 protected override bool ValidMouseClick(Zscii zsciiCharacter)
 {
     return zsciiCharacter == Zscii.MenuClick || base.ValidMouseClick(zsciiCharacter);
 }
Example #4
0
        /// <summary>
        /// Converts a zscii character to a unicode character.
        /// </summary>
        /// <param name="zsciiCharacter">
        /// The zscii character.
        /// </param>
        /// <returns>
        /// The unicode character.
        /// </returns>
        protected char ZsciiToUnicode(Zscii zsciiCharacter)
        {
            switch (zsciiCharacter)
            {
                case Zscii.Tab:
                case Zscii.NewLine:
                    return (char)zsciiCharacter;
                case Zscii.SentenceSpace:
                    return UnicodeSentenceSpace;
                default:
                    if (IsStandardZscii(zsciiCharacter))
                    {
                        return (char)zsciiCharacter;
                    }

                    if (zsciiCharacter >= Zscii.FirstUnicodeCharacter && zsciiCharacter < Zscii.FirstUnicodeCharacter + this.UnicodeCharacterCount)
                    {
                        // todo: prevent control character output.
                        return this.GetUnicodeCharacter(zsciiCharacter - Zscii.FirstUnicodeCharacter);
                    }

                    this.FrontEnd.ErrorNotification(ErrorCondition.InvalidOutput, "Invalid character (" + zsciiCharacter + ").");
                    return (char)Zscii.QuestionMark;
            }
        }
Example #5
0
 /// <summary>
 /// Determines if a character is standard zscii.
 /// </summary>
 /// <param name="zsciiCharacter">
 /// The value to check.
 /// </param>
 /// <returns>
 /// A value indicating whether the value is standard zscii.
 /// </returns>
 private static bool IsStandardZscii(Zscii zsciiCharacter)
 {
     return zsciiCharacter >= Zscii.Space && zsciiCharacter <= Zscii.Tilde;
 }
Example #6
0
 /// <summary>
 /// Converts a zscii character to z-characters.
 /// </summary>
 /// <param name="zsciiCharacter">
 /// The zscii character.
 /// </param>
 /// <param name="zsciiText">
 /// The zscii text following the zscii character.
 /// </param>
 /// <param name="lockedAlphabet">
 /// The locked alphabet.
 /// </param>
 /// <param name="characters">
 /// The z-characters to add the results to.
 /// </param>
 /// <remarks>
 /// Newline is now part of the zscii alphabet.
 /// </remarks>
 protected virtual void ZsciiCharacterToZCharacters(Zscii zsciiCharacter, ImmutableStack<Zscii> zsciiText, ref byte lockedAlphabet, ref ImmutableStack<byte> characters)
 {
     switch (zsciiCharacter)
     {
         case Zscii.Null:
             break;
         case Zscii.Space:
             characters = characters.Add((byte)0);
             break;
         case Zscii.NewLine:
             characters = characters.Add((byte)1);
             break;
         default:
             this.ZsciiAlphabetCharacterToZCharacters(zsciiCharacter, zsciiText, ref lockedAlphabet, ref characters);
             break;
     }
 }
Example #7
0
        /// <summary>
        /// Converts a zscii alphabet character to z-characters.
        /// </summary>
        /// <param name="zsciiCharacter">
        /// The zscii character.
        /// </param>
        /// <param name="zsciiText">
        /// The zscii text.
        /// </param>
        /// <param name="lockedAlphabet">
        /// The locked alphabet.
        /// </param>
        /// <param name="characters">
        /// The z-characters.
        /// </param>
        protected void ZsciiAlphabetCharacterToZCharacters(Zscii zsciiCharacter, ImmutableStack<Zscii> zsciiText, ref byte lockedAlphabet, ref ImmutableStack<byte> characters)
        {
            var zsciiAlphabetIndex = this.GetZsciiAlphabetIndex(zsciiCharacter);
            var neededAlphabet = (byte)((zsciiAlphabetIndex == -1) ? 2 : zsciiAlphabetIndex / 26);
            if (neededAlphabet != lockedAlphabet)
            {
                this.AddAlphabetShiftToZCharacters(neededAlphabet, zsciiText, ref lockedAlphabet, ref characters);
            }

            if (zsciiAlphabetIndex > -1)
            {
                characters = characters.Add((byte)((zsciiAlphabetIndex % 26) + 6));
            }
            else
            {
                characters = characters.Add((byte)6);
                characters = characters.Add((byte)((ushort)zsciiCharacter / 32));
                characters = characters.Add((byte)((ushort)zsciiCharacter & 31));
            }
        }
Example #8
0
        /// <summary>
        /// Converts a zscii character to z-characters.
        /// </summary>
        /// <param name="zsciiCharacter">
        /// The zscii character.
        /// </param>
        /// <param name="zsciiText">
        /// The zscii text following the zscii character.
        /// </param>
        /// <param name="lockedAlphabet">
        /// The locked alphabet.
        /// </param>
        /// <param name="characters">
        /// The z-characters to add the results to.
        /// </param>
        /// <remarks>
        /// Newline is now part of the zscii alphabet.
        /// </remarks>
        protected override void ZsciiCharacterToZCharacters(Zscii zsciiCharacter, ImmutableStack<Zscii> zsciiText, ref byte lockedAlphabet, ref ImmutableStack<byte> characters)
        {
            if (zsciiCharacter == Zscii.NewLine)
            {
                this.ZsciiAlphabetCharacterToZCharacters(zsciiCharacter, zsciiText, ref lockedAlphabet, ref characters);
                return;
            }

            base.ZsciiCharacterToZCharacters(zsciiCharacter, zsciiText, ref lockedAlphabet, ref characters);
        }
Example #9
0
        /// <summary>
        /// Determines whether a zscii character is in the terminating characters table.
        /// </summary>
        /// <param name="zsciiCharacter">
        /// The zscii character.
        /// </param>
        /// <returns>
        /// A value indicating whether the zscii character is in the terminating characters table.
        /// </returns>
        /// <remarks>
        /// A value of 255 in the table will match any value.
        /// </remarks>
        private bool IsTerminator(Zscii zsciiCharacter)
        {
            int terminatingCharactersTable = this.Memory.ReadWord(46);
            if (terminatingCharactersTable != 0)
            {
                byte terminator;
                while ((terminator = this.Memory.ReadByte(terminatingCharactersTable++)) != 0)
                {
                    if ((Zscii)terminator == zsciiCharacter || terminator == byte.MaxValue)
                    {
                        return true;
                    }
                }
            }

            return false;
        }
Example #10
0
 /// <summary>
 /// Determines if a mouse click is valid.
 /// </summary>
 /// <param name="zsciiCharacter">
 /// The zscii character.
 /// </param>
 /// <returns>
 /// A value indicating whether the mouse click is valid.
 /// </returns>
 protected virtual bool ValidMouseClick(Zscii zsciiCharacter)
 {
     return zsciiCharacter == Zscii.SingleClick || zsciiCharacter == Zscii.DoubleClick;
 }