Beispiel #1
0
        private static Vector3 getTotalOffset()
        {
            Vector3       newOffset = Vector3.Zero;
            GeoScriptNode n         = nodeCurrent;

            while (n.parent != null)
            {
                newOffset += n.offset;
                n          = n.parent;
            }
            return(newOffset);
        }
Beispiel #2
0
        private static void CMD_04()
        {
            GeoScriptNode newNode = new GeoScriptNode();

            newNode.ID     = nodeCurrent.ID + 1;
            newNode.parent = nodeCurrent;
            if (nodeCurrent.callSwitch)
            {
                newNode.switchPos   = 0;
                newNode.switchCount = nodeCurrent.switchCount;
                newNode.switchFunc  = nodeCurrent.switchFunc;
                newNode.isSwitch    = true;
            }
            nodeCurrent = newNode;
        }
        private static void CMD_04()
        {
            GeoScriptNode newNode = new GeoScriptNode();

            newNode.ID     = nodeCurrent.ID + 1;
            newNode.parent = nodeCurrent;

            /*
             * if (nodeCurrent.callSwitch)
             * {
             *  newNode.switchPos = 0;
             *  newNode.switchCount = nodeCurrent.switchCount;
             *  newNode.switchFunc = nodeCurrent.switchFunc;
             *  //newNode.isSwitch = true;
             * }
             */
            nodeCurrent = newNode;
        }
Beispiel #4
0
        public static void parse(ref Model3D mdl, ref Level lvl, byte seg, uint off, byte?areaID)
        {
            if (seg == 0)
            {
                return;
            }
            ROM rom = ROM.Instance;

            byte[] data = rom.getSegment(seg, areaID);
            bool   end  = false;

            while (!end)
            {
                byte   cmdLen       = getCmdLength(data[off]);
                byte[] cmd          = rom.getSubArray_safe(data, off, cmdLen);
                string desc         = "Unknown command";
                bool   alreadyAdded = false;
                if (cmd[0] != 0x05 && nodeCurrent.isSwitch && nodeCurrent.switchPos != 1)
                {
                    if (nodeCurrent.switchFunc == 0x8029DB48)
                    {
                        //rom.printArray(cmd, cmdLen);
                        //Console.WriteLine(nodeCurrent.switchPos);
                    }
                    nodeCurrent.switchPos++;
                    off += cmdLen;
                    continue;
                }

                switch (cmd[0])
                {
                case 0x00:
                    desc = "Branch and Store (unused)";
                    end  = true;
                    break;

                case 0x01:
                    desc = "End geometry layout";
                    end  = true;
                    break;

                case 0x02:
                    desc = "Branch geometry layout to address 0x" + bytesToInt(cmd, 4, 4).ToString("X8");
                    addGLSCommandToDump(ref mdl, cmd, seg, off, desc, areaID);
                    alreadyAdded = true;
                    CMD_02(ref mdl, ref lvl, cmd, areaID);
                    break;

                case 0x03:
                    desc = "Return from branch";
                    end  = true;
                    break;

                case 0x04:
                    desc = "Open New Node";
                    CMD_04();
                    break;

                case 0x05:
                    desc = "Close Node";
                    if (nodeCurrent != rootNode)
                    {
                        nodeCurrent = nodeCurrent.parent;
                    }
                    break;

                case 0x08:
                    desc = "Set screen rendering area (" +
                           "center X = " + (short)bytesToInt(cmd, 4, 2) +
                           ", center Y = " + (short)bytesToInt(cmd, 6, 2) +
                           ", Width = " + (short)(bytesToInt(cmd, 8, 2) * 2) +
                           ", Height = " + (short)(bytesToInt(cmd, 10, 2) * 2) + ")";
                    break;

                case 0x0A:
                    desc = "Set camera frustum (" +
                           "FOV = " + (short)bytesToInt(cmd, 2, 2) +
                           ", Near = " + (short)bytesToInt(cmd, 4, 2) +
                           ", Far = " + (short)bytesToInt(cmd, 6, 2) + ")";
                    break;

                case 0x0B:
                    desc = "Start geometry layout";
                    break;

                case 0x0C:
                    if (cmd[1] == 0x00)
                    {
                        desc = "Disable Z-Buffer";
                    }
                    else
                    {
                        desc = "Enable Z-Buffer";
                    }
                    break;

                case 0x0D:
                    desc = "Set render range from camera (min = " +
                           (short)bytesToInt(cmd, 4, 2) + ", max = " +
                           (short)bytesToInt(cmd, 6, 2) + ")";
                    break;

                case 0x0E:
                    desc = "Switch case with following display lists using ASM function 0x" + bytesToInt(cmd, 4, 4).ToString("X8");
                    //rom.printArray(cmd, cmdLen);
                    CMD_0E(ref mdl, ref lvl, cmd);
                    break;

                case 0x10:
                    desc = "Translate and rotate";
                    //CMD_10(ref mdl, ref lvl, cmd);
                    break;

                case 0x11:
                    //rom.printArray(cmd, cmdLen);
                    CMD_11(ref mdl, ref lvl, cmd);
                    break;

                case 0x13:
                    desc = "Load display list 0x" + bytesToInt(cmd, 8, 4).ToString("X8") +
                           " into layer " + cmd[1] + " and offset position by (" +
                           (short)bytesToInt(cmd, 2, 2) +
                           "," + (short)bytesToInt(cmd, 2, 2) +
                           "," + (short)bytesToInt(cmd, 2, 2) +
                           ")";
                    //rom.printArray(cmd, cmdLen);
                    CMD_13(ref mdl, ref lvl, cmd, areaID);
                    break;

                case 0x14:
                    desc = "Billboard Model";
                    //CMD_10(ref mdl, ref lvl, cmd);
                    break;

                case 0x15:
                    desc = "Load display list 0x" + bytesToInt(cmd, 4, 4).ToString("X8") +
                           " into layer " + cmd[1];
                    CMD_15(ref mdl, ref lvl, cmd, areaID);
                    // rom.printArray(cmd, cmdLen);
                    break;

                case 0x16:
                    desc = "Start geometry layout with a shadow. (type = " + cmd[3] +
                           ", solidity = " + cmd[5] + ", scale = " +
                           bytesToInt(cmd, 6, 2) + ")";
                    //CMD_10(ref mdl, ref lvl, cmd);
                    break;

                case 0x17:
                    desc = "Setup display lists for level objects";
                    break;

                case 0x18:
                    desc = "Create display list(s) from the ASM function 0x" + bytesToInt(cmd, 4, 4).ToString("X8")
                           + " (a0 = " + bytesToInt(cmd, 2, 2) + ")";
                    CMD_18(ref mdl, ref lvl, cmd);
                    // rom.printArray(cmd, cmdLen);
                    break;

                case 0x19:
                    if (bytesToInt(cmd, 4, 4) == 0x00000000)
                    {
                        desc = "Draw solid color background. Color = (";
                        ushort color = (ushort)bytesToInt(cmd, 2, 2);
                        desc += (((color >> 11) & 0x1F) * 8) + ","
                                + (((color >> 6) & 0x1F) * 8) + ","
                                + (((color >> 1) & 0x1F) * 8) + ")";
                    }
                    else
                    {
                        desc = "Draw background image. bgID = " + bytesToInt(cmd, 2, 2) +
                               ", calls ASM function 0x" + bytesToInt(cmd, 4, 4).ToString("X8");
                    }
                    CMD_19(ref mdl, ref lvl, cmd, rom.decodeSegmentAddress(seg, off, areaID));
                    // rom.printArray(cmd, cmdLen);
                    break;

                case 0x1D:
                    desc = "Scale following node by " + ((bytesToInt(cmd, 4, 4) / 65536.0f) * 100.0f) + "%";
                    CMD_1D(ref mdl, cmd);
                    break;

                case 0x1A:
                case 0x1E:
                case 0x1F:
                    desc = "Do nothing";
                    break;

                case 0x20:
                    desc = "Start geometry layout with render area of " + bytesToInt(cmd, 2, 2);
                    break;
                }
                if (!alreadyAdded)
                {
                    addGLSCommandToDump(ref mdl, cmd, seg, off, desc, areaID);
                }
                off += cmdLen;
                if (nodeCurrent.isSwitch)
                {
                    nodeCurrent.switchPos++;
                }
            }
        }
Beispiel #5
0
 public static void resetNodes()
 {
     rootNode    = new GeoScriptNode();
     nodeCurrent = rootNode;
 }
Beispiel #6
0
        public static void parse(ref Model3D mdl, ref Level lvl, byte seg, uint off)
        {
            if (seg == 0)
            {
                return;
            }
            ROM rom = ROM.Instance;

            byte[] data = rom.getSegment(seg);
            bool   end  = false;

            while (!end)
            {
                byte   cmdLen = getCmdLength(data[off]);
                byte[] cmd    = rom.getSubArray(data, off, cmdLen);
                //rom.printArray(cmd, cmdLen);
                if (cmd[0] != 0x05 && nodeCurrent.isSwitch && nodeCurrent.switchPos != 1)
                {
                    if (nodeCurrent.switchFunc == 0x8029DB48)
                    {
                        //rom.printArray(cmd, cmdLen);
                        //Console.WriteLine(nodeCurrent.switchPos);
                    }
                    nodeCurrent.switchPos++;
                    off += cmdLen;
                    continue;
                }

                switch (cmd[0])
                {
                case 0x00:
                case 0x01:
                    end = true;
                    break;

                case 0x02:
                    CMD_02(ref mdl, ref lvl, cmd);
                    break;

                case 0x03:
                    end = true;
                    break;

                case 0x04:
                    CMD_04();
                    break;

                case 0x05:
                    if (nodeCurrent != rootNode)
                    {
                        nodeCurrent = nodeCurrent.parent;
                    }
                    break;

                case 0x0E:
                    //rom.printArray(cmd, cmdLen);
                    CMD_0E(ref mdl, ref lvl, cmd);
                    break;

                case 0x10:
                    //CMD_10(ref mdl, ref lvl, cmd);
                    break;

                case 0x11:
                    //rom.printArray(cmd, cmdLen);
                    CMD_11(ref mdl, ref lvl, cmd);
                    break;

                case 0x13:
                    //rom.printArray(cmd, cmdLen);
                    CMD_13(ref mdl, ref lvl, cmd);
                    break;

                case 0x15:
                    CMD_15(ref mdl, ref lvl, cmd);
                    // rom.printArray(cmd, cmdLen);
                    break;

                case 0x1D:
                    CMD_1D(ref mdl, cmd);
                    break;
                }
                off += cmdLen;
                if (nodeCurrent.isSwitch)
                {
                    nodeCurrent.switchPos++;
                }
            }
        }