Example #1
0
        private static void VisualMapParse_cmdBB(ROM rom, VisualMap map, VisualMapParseState state)
        {
            if ((UInt64)rom.Read64() == 0xBB000000FFFFFFFF)
            {
                state.state = VisualMapParseStateCmd.Footer;
            }

            VisualMapParse_common(rom, map, state);
        }
Example #2
0
        public static void PerformVisualMapRebuild(ROM realRom, Region region, int maxDLLength)
        {
            // This is fake rom but it works anyways, just more convenient
            // Want to be safe with overwriting the whole display list
            ROM fakeRom = new ROM(region.data);
            VisualMapParseState state = new VisualMapParseState();

            DisplayListRegion dlRegion = (DisplayListRegion)region;
            VisualMap         map      = new VisualMap();

            byte curCmdIndex;

            do
            {
                curCmdIndex = fakeRom.Read8();
                VisualMapParserCmd func = visualMapParser[curCmdIndex];
                func(fakeRom, map, state);
                fakeRom.AddOffset(8);
            }while (fakeRom.offset < region.length);

            ROM visualMapROM    = new ROM(new byte[maxDLLength]);
            int visualMapLength = map.MakeF3D(visualMapROM);


            // Now write data to real rom + trimming
            // bzero
            fakeRom.offset = 0;
            realRom.PushOffset(region.romStart);
            {
                do
                {
                    realRom.Write64(0x0101010101010101);
                    realRom.AddOffset(8);
                    fakeRom.AddOffset(8);
                } while (fakeRom.offset < region.length);
            }
            realRom.PopOffset();

            visualMapROM.offset = 0;
            realRom.PushOffset(region.romStart);
            {
                int start = region.romStart;
                do
                {
                    Int64 cmd = visualMapROM.Read64();
                    visualMapROM.AddOffset(8);

                    realRom.Write64((ulong)cmd);
                    realRom.AddOffset(8);
                } while (visualMapROM.offset < visualMapLength);

                region.length = realRom.offset - start;
                region.data   = new byte[region.length];
                realRom.ReadData(region.romStart, region.length, region.data);
            }
            realRom.PopOffset();
        }
Example #3
0
        private static void VisualMapParse_cmdFD(ROM rom, VisualMap map, VisualMapParseState state)
        {
            UInt64 fdCmd = state.td.GetTextureCMD();

            if (state.state != VisualMapParseStateCmd.Texture)
            {
                state.state = VisualMapParseStateCmd.Texture;
                state.td    = new TextureDescription();
                if (state.envColorCmd != null)
                {
                    state.td.Add(state.envColorCmd.GetValueOrDefault(), 0 /*FIXME*/);
                }
            }
            VisualMapParse_common(rom, map, state);
        }
Example #4
0
        private static void VisualMapParse_cmdFB(ROM rom, VisualMap map, VisualMapParseState state)
        {
            // Some importers have the only EnvColor func for everything lmfao
            if (rom.Read8(8) != 0xFD)
            {
                goto fini;
            }

            state.envColorCmd = (ulong)rom.Read64();
            state.state       = VisualMapParseStateCmd.Texture;
            state.td          = new TextureDescription();

fini:
            VisualMapParse_common(rom, map, state);
        }
Example #5
0
        private static void VisualMapParse_common(ROM rom, VisualMap map, VisualMapParseState state)
        {
            switch (state.state)
            {
            case VisualMapParseStateCmd.Header:
                map.AddHeaderCmd((UInt64)rom.Read64());
                break;

            case VisualMapParseStateCmd.Texture:
                state.td.Add((UInt64)rom.Read64(), rom.GetSegmentedAddress(rom.offset));
                break;

            case VisualMapParseStateCmd.Footer:
                map.AddFooterCmd((UInt64)rom.Read64());
                break;
            }
        }
Example #6
0
 private static void VisualMapParse_cmdF2(ROM rom, VisualMap map, VisualMapParseState state)
 {
     VisualMapParse_common(rom, map, state);
     state.state = state.isHeader ? VisualMapParseStateCmd.Header : VisualMapParseStateCmd.Footer; // Case for fog
 }
Example #7
0
 private static void VisualMapParse_cmdBF(ROM rom, VisualMap map, VisualMapParseState state)
 {
     state.isHeader = false;
     state.state    = VisualMapParseStateCmd.Footer;
     map.AddTriangle(state.td, state.vertexLoadCmd, (UInt64)rom.Read64());
 }
Example #8
0
 private static void VisualMapParse_cmd04(ROM rom, VisualMap map, VisualMapParseState state)
 {
     state.vertexLoadCmd = (UInt64)rom.Read64();
 }