Esempio n. 1
0
        public DisplayedText LowTextManager(uint textNum, ushort width, ushort logicNum, byte color, bool center)
        {
            GetText(textNum);
            DisplayedText textInfo = DisplayText(_textBuffer.ToString(), null, center, width, color);

            uint    compactNum = Logic.FIRST_TEXT_COMPACT;
            Compact cpt        = _skyCompact.FetchCpt((ushort)compactNum);

            while (cpt.Core.status != 0)
            {
                compactNum++;
                cpt = _skyCompact.FetchCpt((ushort)compactNum);
            }

            cpt.Core.flag = (ushort)(compactNum - Logic.FIRST_TEXT_COMPACT + FirstTextBuffer);

            SkyEngine.ItemList[cpt.Core.flag] = textInfo.TextData;

            cpt.Core.logic  = logicNum;
            cpt.Core.status = Logic.ST_LOGIC | Logic.ST_FOREGROUND | Logic.ST_RECREATE;
            cpt.Core.screen = (ushort)Logic.ScriptVariables[Logic.SCREEN];

            textInfo.CompactNum = (ushort)compactNum;
            return(textInfo);
        }
Esempio n. 2
0
        private bool FnPrintCredit(uint a, uint b, uint c)
        {
            DisplayedText creditText  = _skyText.LowTextManager(a, 240, 0, 248, true);
            Compact       credCompact = _skyCompact.FetchCpt(creditText.CompactNum);

            credCompact.Core.xcood = 168;
            if ((a == 558) && (c == 215))
            {
                credCompact.Core.ycood = 211;
            }
            else
            {
                credCompact.Core.ycood = (ushort)c;
            }
            _scriptVariables[RESULT] = creditText.CompactNum;
            return(true);
        }
Esempio n. 3
0
        private bool FnLincTextModule(uint textPos, uint textNo, uint buttonAction)
        {
            ushort cnt;

            if ((buttonAction & 0x8000) != 0)
            {
                for (cnt = LINC_DIGIT_0; cnt <= LINC_DIGIT_9; cnt++)
                {
                    _scriptVariables[cnt] = 0;
                }
            }
            buttonAction &= 0x7FFF;
            if (buttonAction < 10)
            {
                _scriptVariables[(int)(LINC_DIGIT_0 + buttonAction)] = textNo;
            }

            DisplayedText text = _skyText.LowTextManager(textNo, 220, 0, 215, false);

            Compact textCpt = _skyCompact.FetchCpt(text.CompactNum);

            if (textPos < 20)
            { // line number (for text)
                textCpt.Core.xcood = 152;
                textCpt.Core.ycood = (ushort)(textPos * 13 + 170);
            }
            else if (textPos > 20)
            { // x coordinate (for numbers)
                textCpt.Core.xcood = (ushort)textPos;
                textCpt.Core.ycood = 214;
            }
            else
            {
                //TODO:  warning("::fnLincTextModule: textPos == 20");
            }
            textCpt.Core.getToFlag = (ushort)textNo;
            return(true);
        }
Esempio n. 4
0
        private bool FnLookAt(uint a, uint b, uint c)
        {
            DisplayedText textInfo = _skyText.LowTextManager(a, 240, 0, 248, true);
            Compact       textCpt  = _skyCompact.FetchCpt(textInfo.CompactNum);

            textCpt.Core.xcood = 168;
            textCpt.Core.ycood = (ushort)c;

            _skyScreen.Recreate();
            _skyScreen.SpriteEngine();
            _skyScreen.Flip();

            FnNoHuman(0, 0, 0);
            _skyMouse.LockMouse();

            _skyMouse.WaitMouseNotPressed(800);

            _skyMouse.UnlockMouse();
            FnAddHuman(0, 0, 0);
            textCpt.Core.status = 0;

            return(true);
        }
Esempio n. 5
0
        private bool FnChooser(uint a, uint b, uint c)
        {
            // setup the text questions to be clicked on
            // read from TEXT1 until 0

            SystemVars.Instance.SystemFlags |= SystemFlags.Choosing; // can't save/restore while choosing

            _scriptVariables[THE_CHOSEN_ONE] = 0;                    // clear result

            int    p     = TEXT1;
            ushort ycood = TOP_LEFT_Y; // rolling coordinate

            while (_scriptVariables[p] != 0)
            {
                uint textNum = _scriptVariables[p++];

                DisplayedText lowText = _skyText.LowTextManager(textNum, GAME_SCREEN_WIDTH, 0, 241, false);

                byte[] data   = lowText.TextData;
                var    header = ServiceLocator.Platform.ToStructure <DataFileHeader>(data, 0);

                // stipple the text

                uint size   = (uint)(header.s_height * header.s_width);
                uint index  = 0;
                uint width  = header.s_width;
                uint height = header.s_height;

                var dataPos = ServiceLocator.Platform.SizeOf <DataFileHeader>();

                while (index < size)
                {
                    if (index % width <= 1)
                    {
                        index ^= 1; //index++;
                    }
                    if (data[dataPos + index] == 0)
                    {
                        data[dataPos + index] = 1;
                    }
                    index += 2;
                }

                Compact textCompact = _skyCompact.FetchCpt(lowText.CompactNum);

                textCompact.Core.getToFlag = (ushort)textNum;
                textCompact.Core.downFlag  = (ushort)_scriptVariables[p++]; // get animation number

                textCompact.Core.status |= ST_MOUSE;                        // mouse detects

                textCompact.Core.xcood = TOP_LEFT_X;                        // set coordinates
                textCompact.Core.ycood = ycood;
                ycood += (ushort)height;
            }

            if (p == TEXT1)
            {
                return(true);
            }

            _compact.Core.logic = L_CHOOSE; // player frozen until choice made
            FnAddHuman(0, 0, 0);            // bring back mouse

            return(false);
        }
Esempio n. 6
0
        public DisplayedText DisplayText(string text, byte[] dest, bool center, ushort pixelWidth, byte color)
        {
            //Render text pointed to by *textPtr in buffer *dest
            var    centerTable = new uint[10];
            ushort lineWidth   = 0;

            uint numLines = 0;

            NumLetters = 2;

            // work around bug #778105 (line width exceeded)
            text = text.Replace("MUND-BEATMUNG!", "MUND BEATMUNG!");

            // work around bug #1151924 (line width exceeded when talking to gardener using spanish text)
            // This text apparently only is broken in the floppy versions, the CD versions contain
            // the correct string "MANIFESTACION - ARTISTICA.", which doesn't break the algorithm/game.
            var textBytes = text.Replace("MANIFESTACION-ARTISTICA.", "MANIFESTACION ARTISTICA.").ToCharArray().Select(c => (byte)c).ToArray();

            var curPos    = 0;
            var lastSpace = 0;
            var textChar  = textBytes[curPos++];

            while (textChar >= 0x20 && curPos <= textBytes.Length)
            {
                if ((_curCharSet == 1) && (textChar >= 0x80))
                {
                    textChar = 0x20;
                }

                textChar -= 0x20;
                if (textChar == 0)
                {
                    lastSpace             = curPos; //keep track of last space
                    centerTable[numLines] = lineWidth;
                }

                lineWidth += _characterSet[textChar]; //add character width
                lineWidth += (ushort)_dtCharSpacing;  //include character spacing

                if (pixelWidth <= lineWidth)
                {
                    if (textBytes[lastSpace - 1] == 10)
                    {
                        throw new InvalidOperationException("line width exceeded");
                    }

                    textBytes[lastSpace - 1] = 10;
                    lineWidth = 0;
                    numLines++;
                    curPos = lastSpace; //go back for new count
                }

                textChar = textBytes.Length == curPos ? (byte)0 : textBytes[curPos++];
                NumLetters++;
            }

            uint dtLastWidth = lineWidth;      //save width of last line

            centerTable[numLines] = lineWidth; //and update centering table
            numLines++;

            if (numLines > MaxNoLines)
            {
                throw new InvalidOperationException("Maximum no. of lines exceeded");
            }

            var dtLineSize           = pixelWidth * _charHeight;
            var sizeOfDataFileHeader = ServiceLocator.Platform.SizeOf <DataFileHeader>();
            var numBytes             = (int)(dtLineSize * numLines + sizeOfDataFileHeader + 4);

            if (dest == null)
            {
                dest = new byte[numBytes];
            }

            // clear text sprite buffer
            Array.Clear(dest, sizeOfDataFileHeader, numBytes - sizeOfDataFileHeader);

            //make the header
            using (var header = ServiceLocator.Platform.WriteStructure <DataFileHeader>(dest, 0))
            {
                header.Object.s_width    = pixelWidth;
                header.Object.s_height   = (ushort)(_charHeight * numLines);
                header.Object.s_sp_size  = (ushort)(pixelWidth * _charHeight * numLines);
                header.Object.s_offset_x = 0;
                header.Object.s_offset_y = 0;
            }

            //reset position
            curPos = 0;

            var curDest      = sizeOfDataFileHeader; //point to where pixels start
            var prevDest     = curDest;
            var centerTblPtr = 0;

            do
            {
                if (center)
                {
                    var width = (int)(pixelWidth - centerTable[centerTblPtr]) >> 1;
                    centerTblPtr++;
                    curDest += width;
                }

                textChar = textBytes[curPos++];
                while (textChar >= 0x20)
                {
                    MakeGameCharacter((byte)(textChar - 0x20), _characterSet, dest, ref curDest, color, pixelWidth);
                    textChar = textBytes.Length == curPos ? (byte)0 : textBytes[curPos++];
                }

                prevDest = curDest = prevDest + dtLineSize; //start of last line + start of next
            } while (textChar >= 10);

            var ret = new DisplayedText
            {
                TextData  = dest,
                TextWidth = dtLastWidth
            };

            return(ret);
        }
Esempio n. 7
0
        public DisplayedText DisplayText(string text, byte[] dest, bool center, ushort pixelWidth, byte color)
        {
            //Render text pointed to by *textPtr in buffer *dest
            var centerTable = new uint[10];
            ushort lineWidth = 0;

            uint numLines = 0;
            NumLetters = 2;

            // work around bug #778105 (line width exceeded)
            text = text.Replace("MUND-BEATMUNG!", "MUND BEATMUNG!");

            // work around bug #1151924 (line width exceeded when talking to gardener using spanish text)
            // This text apparently only is broken in the floppy versions, the CD versions contain
            // the correct string "MANIFESTACION - ARTISTICA.", which doesn't break the algorithm/game.
            var textBytes = text.Replace("MANIFESTACION-ARTISTICA.", "MANIFESTACION ARTISTICA.").ToCharArray().Select(c => (byte)c).ToArray();

            var curPos = 0;
            var lastSpace = 0;
            var textChar = textBytes[curPos++];

            while (textChar >= 0x20 && curPos <= textBytes.Length)
            {
                if ((_curCharSet == 1) && (textChar >= 0x80))
                    textChar = 0x20;

                textChar -= 0x20;
                if (textChar == 0)
                {
                    lastSpace = curPos; //keep track of last space
                    centerTable[numLines] = lineWidth;
                }

                lineWidth += _characterSet[textChar]; //add character width
                lineWidth += (ushort)_dtCharSpacing; //include character spacing

                if (pixelWidth <= lineWidth)
                {
                    if (textBytes[lastSpace - 1] == 10)
                        throw new InvalidOperationException("line width exceeded");

                    textBytes[lastSpace - 1] = 10;
                    lineWidth = 0;
                    numLines++;
                    curPos = lastSpace; //go back for new count
                }

                textChar = textBytes.Length == curPos ? (byte)0 : textBytes[curPos++];
                NumLetters++;
            }

            uint dtLastWidth = lineWidth; //save width of last line
            centerTable[numLines] = lineWidth; //and update centering table
            numLines++;

            if (numLines > MaxNoLines)
                throw new InvalidOperationException("Maximum no. of lines exceeded");

            var dtLineSize = pixelWidth * _charHeight;
            var sizeOfDataFileHeader = ServiceLocator.Platform.SizeOf<DataFileHeader>();
            var numBytes = (int)(dtLineSize * numLines + sizeOfDataFileHeader + 4);

            if (dest == null)
                dest = new byte[numBytes];

            // clear text sprite buffer
            Array.Clear(dest, sizeOfDataFileHeader, numBytes - sizeOfDataFileHeader);

            //make the header
            using (var header = ServiceLocator.Platform.WriteStructure<DataFileHeader>(dest, 0))
            {
                header.Object.s_width = pixelWidth;
                header.Object.s_height = (ushort)(_charHeight * numLines);
                header.Object.s_sp_size = (ushort)(pixelWidth * _charHeight * numLines);
                header.Object.s_offset_x = 0;
                header.Object.s_offset_y = 0;
            }

            //reset position
            curPos = 0;

            var curDest = sizeOfDataFileHeader; //point to where pixels start
            var prevDest = curDest;
            var centerTblPtr = 0;

            do
            {
                if (center)
                {
                    var width = (int)(pixelWidth - centerTable[centerTblPtr]) >> 1;
                    centerTblPtr++;
                    curDest += width;
                }

                textChar = textBytes[curPos++];
                while (textChar >= 0x20)
                {
                    MakeGameCharacter((byte)(textChar - 0x20), _characterSet, dest, ref curDest, color, pixelWidth);
                    textChar = textBytes.Length == curPos ? (byte)0 : textBytes[curPos++];
                }

                prevDest = curDest = prevDest + dtLineSize; //start of last line + start of next
            } while (textChar >= 10);

            var ret = new DisplayedText
            {
                TextData = dest,
                TextWidth = dtLastWidth
            };
            return ret;
        }