/// <summary> /// 给ROM打补丁 /// </summary> /// <param name="fileName">ROM文件名</param> private static void Patch(string fileName) { Byte[] prgData = Common.GetPRGData(fileName); Byte[] chrData = Common.GetCHRData(fileName); foreach (TranslationInfo info in s_TranslationInfos) { int addrLo = TableOrganizer.GetAbsoluteAddress(info.addrLo); int addrHi = TableOrganizer.GetAbsoluteAddress(info.addrHi); int addr = TableOrganizer.GetAbsoluteAddress(info.addr); prgData[addrLo] = (Byte)((info.addr >> 0) & 0xFF); prgData[addrHi] = (Byte)((info.addr >> 8) & 0xFF); int offset = 0; foreach (TextBlockInfo ti in info.textBlocks) { for (int i = 0; i < ti.data.Count; ++i) { // 因为ASCII占据了最刚开始的若干个tile,所以这里要对汉字的idx进行偏移 int offs = 0; if (ti.data[i] >= 0x60 && ti.data[i] <= 0x7F) { offs = (int)Math.Ceiling(s_DicUniqueASCII[ti.bankNo].Length / 4.0); } prgData[addr + offset + i] = (Byte)(ti.data[i] + offs); } offset += ti.data.Count; } } foreach (KeyValuePair <int, string> kv in s_DicUniqueChars) { int bankNo = kv.Key; string uniqueChars = kv.Value; string uniqueASCII = s_DicUniqueASCII[bankNo]; TileCreator.GeneratePatternTable(ref chrData, bankNo, uniqueChars, uniqueASCII); } Common.PatchROM(fileName, prgData, chrData); }
public static void Start(string ROMFileName) { Byte[] prgData = Common.GetPRGData(ROMFileName); Byte[] chrData = Common.GetCHRData(ROMFileName); int absoluteAddr = TableOrganizer.GetAbsoluteAddress(startAddr, hataageBank); int curText = 0; int offset = 0; while (curText < cnTexts.Length) { prgData[absoluteAddr + offset] = opCodes[curText]; offset++; char[] chars = cnTexts[curText].ToCharArray(); for (int i = 0; i < chars.Length; ++i) { prgData[absoluteAddr + offset] = findChar(chars[i]); offset++; } prgData[absoluteAddr + offset] = 0xCC; offset++; prgData[absoluteAddr + offset] = 0xFF; offset++; curText++; } Byte[] data = TileCreator.CreateGiantFont(cnChars); for (int i = 0; i < data.Length; ++i) { chrData[0x10000 + i] = data[i]; } Common.PatchROM(ROMFileName, prgData, chrData); }