示例#1
0
        private void DefaultPrimitive(IFFDecode P)
        {
            int Op = P.Operand(0); //Operation code

            //Primitives
            int BHAVString139Len = (BHAVStrings.BHAVString139.Length / BHAVStrings.BHAVString139[0].Length) - 1;

            if (Op < BHAVString139Len)
            {
                P.OutStream.Append(BHAVStrings.BHAVString139[Op]);
            }
            else
            {
                P.OutStream.Append("PRIM_" + Op);
            }

            P.OutStream.Append("(" + P.Operand(4) + ", " + P.Operand(6) + ", " +
                               P.Operand(8) + ", " + P.Operand(10) + ")");
        }
示例#2
0
        public void DecodeInstruction(ref IFFDecode P)
        {
            int K = P.Operand(0);

            if (K < 256)
            {
                DecodePrimitive(P);
                return;
            }

            string Name = EntryName("BHAV", K);

            if (m_GlobalSubsLen == 0)
            {
                m_GlobalSubsLen = (m_GlobalSubs.Length / m_GlobalSubs[0].Length) - 1;
            }

            if (Name != "\0")
            {
                P.OutStream.Append(Name);
            }
            else if (K < (uint)(m_GlobalSubsLen + 256))
            {
                P.OutStream.Append(m_GlobalSubs[K - 256]);
            }
            else if (K < 4096)
            {
                P.OutStream.Append("Call global[" + K + "]");
            }
            else if (K < 8192)
            {
                P.OutStream.Append("Call local[" + K + "]");
            }
            else
            {
                P.OutStream.Append("Call semi-global[" + K + "]");
            }

            if (P.Operand(4) == 0xFFFF && P.Operand(6) == 0xFFFF && P.Operand(8) == 0xFFFF && P.Operand(10) == 0xFFFF)
            {
                P.OutStream.Append("(temps)");
            }
            else
            {
                P.OutStream.Append("(" + (short)(P.Operand(4)) +
                                   ", " + (short)(P.Operand(6)) +
                                   ", " + (short)(P.Operand(8)) +
                                   ", " + (short)(P.Operand(10)) +
                                   ")");
            }
        }
示例#3
0
        private void DecodePrimitive(IFFDecode P)
        {
            int Op = P.Operand(0); //Operation code.
            int U  = 0;

            switch (Op)
            {
            default:
                DefaultPrimitive(P);
                break;

            case 0:
                P.OutStream.Append("0: sleep ");
                DoExpressionOperation(9, P.Operand(4));
                P.OutStream.Append(" ticks");
                break;

            case 1:     //Generic sim call
                int BHAVStr220Len = (BHAVStrings.BHAVString220.Length / BHAVStrings.BHAVString220[0].Length) - 1;
                int T             = P.Operand(4);

                if (T < BHAVStr220Len)
                {
                    P.OutStream.Append(BHAVStrings.BHAVString220[T]);
                }
                else
                {
                    P.OutStream.Append("1: generic sim call " + T);
                }
                break;

            case 2:
                ExpressionPrimitive(P.Instruction);
                break;

            case 3:
                P.OutStream.Append("3: find best interaction");
                break;

            case 4:
                P.OutStream.Append("4: grab stack object");
                break;

            case 5:
                P.OutStream.Append("5: drop stack object");
                break;

            case 6:
                ChangeSuitOrAccessoryPrimitive(P.Instruction);
                break;

            case 7:     //Update
                P.OutStream.Append("7: refresh ");

                int BHAVStr153Len = (BHAVStrings.BHAVString153.Length / BHAVStrings.BHAVString153[0].Length) - 1;

                if (P[4] < BHAVStr153Len)
                {
                    P.OutStream.Append(BHAVStrings.BHAVString153[P[4]]);
                }
                else
                {
                    P.OutStream.Append("WHO=" + (int)(P[4]));
                }

                P.OutStream.Append(" ");

                int BHAVStr212Len = (BHAVStrings.BHAVString212.Length / BHAVStrings.BHAVString212[0].Length) - 1;

                if (P[6] < BHAVStr212Len)
                {
                    P.OutStream.Append(BHAVStrings.BHAVString212[P[6]]);
                }
                else
                {
                    P.OutStream.Append("WHAT=" + (int)(P[6]));
                }
                break;

            case 8:     //Random
                DoExpressionOperation(P[6], P.Operand(4));
                P.OutStream.Append(" := random ");
                DoExpressionOperation(P[10], P.Operand(8));
                break;

            case 9:     //Burn
                P.OutStream.Append("9: burn ");

                int BHAVStr231Len = (BHAVStrings.BHAVString231.Length / BHAVStrings.BHAVString231[0].Length) - 1;

                if (P[4] < BHAVStr231Len)
                {
                    P.OutStream.Append(BHAVStrings.BHAVString231[P[4]]);
                }
                else
                {
                    P.OutStream.Append("WHAT [" + (int)(P[4]) + "]");
                }
                break;

            case 10:     //Tutorial
                // STR#238 - situation action descriptions
                P.OutStream.Append("10: tutorial " + ((P[4] == 0) ? "begin" : "end"));
                break;

            case 11:     //Distance
                DoExpressionOperation(8, P.Operand(4));
                P.OutStream.Append(" := distance from stack object to ");

                U = P.Operand(8);

                if (P[6] == 0)
                {
                    P.OutStream.Append("me");
                }
                else if (P[9] == 3 && U == 11)
                {
                    P.OutStream.Append("me");
                }
                else
                {
                    DoExpressionOperation(P[9], U);
                }
                break;

            case 12:     //Direction to
                DoExpressionOperation(P[6], P.Operand(4));
                P.OutStream.Append(" := direction from stack object to ");

                U = P.Operand(10);

                if (P[8] == 0)
                {
                    P.OutStream.Append("me");
                }
                else if (P[9] == 3 && U == 11)
                {
                    P.OutStream.Append("me");
                }
                else
                {
                    DoExpressionOperation(P[9], U);
                }
                break;

            case 13:     //Push interaction
                P.OutStream.Append("13: queue ");
                P.OutStream.Append((int)(P.OutStream[4]) + " of ");
                DoExpressionOperation(((P[7] & 2) != 0) ? 25 : 9, P[5]);

                int BHAVString224Len = (BHAVStrings.BHAVString224.Length / BHAVStrings.BHAVString224[0].Length) - 1;

                if (P[6] < BHAVString224Len)
                {
                    if (P[6] > 0)
                    {
                        //cout << " pri=" << BhavStr224[p[6]];
                    }
                }
                else
                {
                    P.OutStream.Append(" PRI=" + (int)(P[6]));
                }

                if ((P[7] & 1) != 0)
                {
                    P.OutStream.Append(" icon=");
                    DoExpressionOperation(25, P.Operand(8));
                }

                if ((P[7] & 0x04) != 0)
                {
                    P.OutStream.Append(", continue as current ");
                }
                if ((P[7] & 0x08) != 0)
                {
                    P.OutStream.Append(", use name ");
                }

                break;

            case 14:     //Find the best object for...
                U = P.Operand(4);
                P.OutStream.Append("14: find best object for ");

                int BHAVString201Len = (BHAVStrings.BHAVString201Obj.Length / BHAVStrings.BHAVString201Obj[0].Length) - 1;

                if (U < BHAVString201Len)
                {
                    P.OutStream.Append(BHAVStrings.BHAVString201Obj[U]);
                }
                else
                {
                    P.OutStream.Append("function " + (int)(U));
                }

                int X = P.Operand(6),
                    Y = P.Operand(8),
                    Z = P.Operand(10);

                if (X == 0 && Y == 0 && Z == 0)
                {
                    break;
                }

                P.OutStream.Append("(" + (int)(X) + ", " + (int)(Y) + ", " + (int)(Z) + ")");

                break;

            case 15:     //Tree breakpoint
                P.OutStream.Append("15: tree breakpoint");
                U = P.Operand(4);

                if (P[6] != 7 || U == 0)
                {
                    P.OutStream.Append(" if ");
                    DoExpressionOperation(P[6], U);
                    P.OutStream.Append(" != 0");
                }
                break;

            case 16:     //Find location for
                P.OutStream.Append("16: find: ");

                if ((P[6] & 2) != 0)
                {
                    P.OutStream.Append("empty ");
                }

                int BHAVStr239Len = (BHAVStrings.BHAVString239.Length / BHAVStrings.BHAVString239[0].Length) - 1;

                if (P[4] < BHAVStr239Len)
                {
                    P.OutStream.Append(BHAVStrings.BHAVString239[P[4]]);
                }
                else
                {
                    P.OutStream.Append("LOC=" + (int)(P[4]));
                }

                P.OutStream.Append(" loc");

                if ((P[6] & 1) != 0)
                {
                    P.OutStream.Append(" start at ");
                    DoExpressionOperation(25, P[5]);
                }

                if ((P[6] & 4) != 0)
                {
                    P.OutStream.Append(" user-editable");
                }
                break;

            case 17:     //Idle for input
                P.OutStream.Append("17: idle for input ");
                DoExpressionOperation(9, P.Operand(4));

                U = P.Operand(6);
                P.OutStream.Append(" ticks, " + ((U == 0) ? "forbid" : "allow") + " push");
                break;

            case 18:     //Remove object instance
                P.OutStream.Append("18: remove ");
                int Who = P.Operand(4);
                BHAVStr153Len = (BHAVStrings.BHAVString153.Length / BHAVStrings.BHAVString153[0].Length) - 1;

                if (Who < BHAVStr153Len)
                {
                    P.OutStream.Append(BHAVStrings.BHAVString153[Who]);
                }
                else
                {
                    P.OutStream.Append("object[" + Who + "]'s");
                }

                P.OutStream.Append(" instance");

                if ((P[6] & 1) != 0)
                {
                    P.OutStream.Append(", return immediately");
                }
                if ((P[6] & 2) != 0)
                {
                    P.OutStream.Append(", clean up all");
                }
                break;

            case 19:     //Make new character
                P.OutStream.Append("19: make new character(");
                DoExpressionOperation(25, P[4]);
                P.OutStream.Append(",");
                DoExpressionOperation(25, P[5]);
                P.OutStream.Append(",");
                DoExpressionOperation(25, P[6]);
                P.OutStream.Append(")");
                break;

            case 20:     //Run functional tree
                T = P.Operand(4);
                P.OutStream.Append("20: run ");
                BHAVString201Len = (BHAVStrings.BHAVString201Run.Length / BHAVStrings.BHAVString201Run[0].Length) - 1;

                if (T < BHAVString201Len)
                {
                    P.OutStream.Append("\"" + BHAVStrings.BHAVString201Run[T] + "\"");
                }
                else
                {
                    P.OutStream.Append("function " + (int)T);
                }

                T = (short)P.Operand(6);
                if (T != 0)
                {
                    P.OutStream.Append(" with new icon");
                }
                break;
            }
        }