示例#1
0
        private static void RelocationParse_cmd24(ROM rom, RelocationTable table, RegionParseState state)
        {
            int behaviour = rom.Read32(0x14);

            if (behaviour == scrollBehaviour || behaviour == scrollBehaviourLegacy)
            {
                int address = 0;

                int    intX  = rom.Read16(0x04);
                float  X     = intX;
                byte[] Xdata = BitConverter.GetBytes(X);

                address += Xdata[2] * 0x10000;
                address += (ushort)rom.Read16(0x10);

                int segmentedAddress = address - 0x20000 + 0x0E000000;

                int newSegmentedAddress = table.Relocate((int)state.area, segmentedAddress);
                if (newSegmentedAddress == -1)
                {
                    throw new ArgumentException("Failed to relocate scrolling texture!");
                }

                int newAddress = newSegmentedAddress - 0x0E000000 + 0x20000;

                Xdata[2] = (byte)((newAddress >> 16) & 0xFF);
                float newX    = BitConverter.ToSingle(Xdata, 0);
                int   newIntX = Convert.ToInt16(newX);

                rom.Write16(newIntX, 0x04);
                rom.Write16(newAddress & 0xFFFF, 0x10);
                rom.Write32(scrollBehaviourLegacy, 0x14);
            }
        }
示例#2
0
        public static void PerformRegionRelocation(Region region, RelocationTable table, sbyte area = -1)
        {
            // This is fake rom but it works anyways, just more convenient
            ROM rom = new ROM(region.data);
            RegionParseState state = new RegionParseState();

            state.area = area;

            byte curCmdIndex;

            while (rom.offset < region.length)
            {
                curCmdIndex = rom.Read8();
                byte curCmdSize = rom.Read8(1);

                if (curCmdSize == 0)
                {
                    throw new ArgumentException("cmd size is 0, loop detected");
                }

                RelocationParseCmd func = relocationParser[curCmdIndex];
                func(rom, table, state);

                if (curCmdIndex != 0x7)
                {
                    rom.AddOffset(curCmdSize);
                }
            }
        }
示例#3
0
        public static void PerformRegionRelocation(Region region, RelocationTable table)
        {
            // This is fake rom but it works anyways, just more convenient
            ROM rom = new ROM(region.data);

            byte cmd;

            do
            {
                cmd = rom.Read8();
                int cmdSize = cmdSizeTable[cmd];
                if (cmdSize == 0)
                {
                    throw new ArgumentException("Loop detected");
                }

                RelocationParseCmd func = relocationParser[cmd];
                func(rom, table);

                if (cmdSize != 0xFF)
                {
                    rom.AddOffset(cmdSize);
                }
            }while (rom.offset < region.length);
        }
示例#4
0
        private static void RelocationParse_cmdB9(ROM rom, RelocationTable table, DisplayListRegion region)
        {
            if (!region.DLFixesNeeded)
            {
                return;
            }

            if (!region.isFogEnabled)
            {
                return;
            }

            if ((ulong)rom.Read64(-8) != 0xBA00140200000000)
            {
                return;
            }

            if (region.layer == 1)
            {
                rom.Write64(0xB900031D00552078);
            }
            if (region.layer == 4)
            {
                rom.Write64(0xB900031D00443078);
            }
            if (region.layer == 5)
            {
                rom.Write64(0xB900031D005049D8);
            }
        }
示例#5
0
        public static void PerformRegionRelocation(Region region, RelocationTable table)
        {
            // This is fake rom but it works anyways, just more convenient
            ROM rom = new ROM(region.data);

            byte curCmdIndex;

            do
            {
                curCmdIndex = rom.Read8();
                RelocationParseCmd func = relocationParser[curCmdIndex];
                func(rom, table, (DisplayListRegion)region);
                rom.AddOffset(8);
            }while (rom.offset < region.length);
        }
示例#6
0
 private static void RelocationParse_common(ROM rom, RelocationTable table, RegionParseState state)
 {
 }
示例#7
0
 public abstract void Relocate(RelocationTable table);
示例#8
0
 private static void RelocationParse_cmdFD(ROM rom, RelocationTable table, DisplayListRegion region)
 {
     table.RelocateOffset(rom, 4);
 }
示例#9
0
        private static void RelocationParse_cmdFC(ROM rom, RelocationTable table, DisplayListRegion region)
        {
            if (!region.DLFixesNeeded)
            {
                return;
            }


            UInt64 FCcmd = 0;

            if (region.FCCountFixed == 0)
            {
                if (region.isFogEnabled)
                {
                    if ((ulong)region.B9cmdfirst == 0xB900031DC8112078)
                    {
                        FCcmd = 0xFC127FFFFFFFF838;
                    }

                    if ((ulong)region.B9cmdfirst == 0xB900031DC8113078)
                    {
                        FCcmd = 0xFCFFFFFFFFFCF238;
                    }

                    if (region.isEnvcolorEnabled)
                    {
                        FCcmd = 0xFC127FFFFFFFFA38;
                    }
                }
                else
                {
                    if (region.FCCount == 1)
                    {
                        FCcmd = 0xFC127E24FFFFF9FC;
                    }
                    else
                    {
                        if (!region.isEnvcolorEnabled)
                        {
                            FCcmd = 0xFC121824FF33FFFF;
                        }
                        else
                        {
                            FCcmd = 0xFC122E24FFFFFBFD;
                        }
                    }
                }
            }
            else
            {
                FCcmd = 0xFC127E24FFFFF9FC;
            }

            if (FCcmd == 0)
            {
                MessageBox.Show("Parser could not choose the right combiner! Combiners won't be fixed", "Display List", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                region.FCCountFixed++;
                rom.Write64(FCcmd);
            }
        }
示例#10
0
 public override void Relocate(RelocationTable table)
 {
     DisplayList.PerformRegionRelocation(this, table);
 }
示例#11
0
 private static void RelocationParse_cmd1D(ROM rom, RelocationTable table)
 {
     // TODO: msbit thing
     rom.AddOffset(0x8);
 }
示例#12
0
 private static void RelocationParse_cmd15(ROM rom, RelocationTable table)
 {
     table.RelocateOffset(rom, 4);
 }
示例#13
0
        private static void RelocationParse_cmd0A(ROM rom, RelocationTable table)
        {
            int useAsm = rom.Read8(1);

            rom.AddOffset(useAsm == 0 ? 0x8 : 0xC);
        }
示例#14
0
 public override void Relocate(RelocationTable table)
 {
     LevelScript.PerformRegionRelocation(this, table);
 }
示例#15
0
 public override void Relocate(RelocationTable table)
 {
 }
示例#16
0
 private static void RelocationParse_cmd1F(ROM rom, RelocationTable table, RegionParseState state)
 {
     rom.Write8((byte)state.area, 2);
     table.RelocateOffset((int)state.area, rom, 4);
 }
示例#17
0
        private static void RelocationParse_cmd22(ROM rom, RelocationTable table, RegionParseState state)
        {
            int model = rom.Read8(3);

            table.RelocateOffset(model, rom, 4);
        }
示例#18
0
 private static void RelocationParse_common(ROM rom, RelocationTable table, DisplayListRegion region)
 {
 }
示例#19
0
 private static void RelocationParse_cmd2E(ROM rom, RelocationTable table, RegionParseState state)
 {
     table.RelocateOffset((int)state.area, rom, 4);
 }
示例#20
0
 public override void Relocate(RelocationTable table)
 {
     GeoLayout.PerformRegionRelocation(this, table);
 }