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); } } }
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); }
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); }
static LevelScript() { // Use reflections to detect declared parse methods Type t = typeof(LevelScript); for (int i = 0; i < size; i++) { regionParser[i] = RegionParse_common; string name = "RegionParse_cmd" + string.Format("{0:X2}", i); MethodInfo info = t.GetMethod(name, BindingFlags.NonPublic | BindingFlags.Static); if (info == null) { continue; } RegionParseCmd cmd = Delegate.CreateDelegate(typeof(RegionParseCmd), info) as RegionParseCmd; if (cmd == null) { continue; } regionParser[i] = cmd; } for (int i = 0; i < size; i++) { relocationParser[i] = RelocationParse_common; string name = "RelocationParse_cmd" + string.Format("{0:X2}", i); MethodInfo info = t.GetMethod(name, BindingFlags.NonPublic | BindingFlags.Static); if (info == null) { continue; } RelocationParseCmd cmd = Delegate.CreateDelegate(typeof(RelocationParseCmd), info) as RelocationParseCmd; if (cmd == null) { continue; } relocationParser[i] = cmd; } }
static DisplayList() { Type t = typeof(DisplayList); for (int i = 0x00; i < 0xFF; i++) { parser[i] = RegionParse_common; string name = "RegionParse_cmd" + string.Format("{0:X2}", i); MethodInfo info = t.GetMethod(name, BindingFlags.NonPublic | BindingFlags.Static); if (info == null) { continue; } RegionParseCmd cmd = Delegate.CreateDelegate(typeof(RegionParseCmd), info) as RegionParseCmd; if (cmd == null) { continue; } parser[i] = cmd; } for (int i = 0; i < 0xFF; i++) { relocationParser[i] = RelocationParse_common; string name = "RelocationParse_cmd" + string.Format("{0:X2}", i); MethodInfo info = t.GetMethod(name, BindingFlags.NonPublic | BindingFlags.Static); if (info == null) { continue; } RelocationParseCmd cmd = Delegate.CreateDelegate(typeof(RelocationParseCmd), info) as RelocationParseCmd; if (cmd == null) { continue; } relocationParser[i] = cmd; } }