using System; using System.Collections.Generic; using System.IO; namespace OpenVIII { /// /// Loads strings from FF8 files /// public partial class Strings { #region Classes /// /// Kernel.bin Strings /// Has Multibyte Characters, Requires Namedic /// public class Kernel : StringsBase { #region Fields protected uint[] StringsPadLoc; #endregion Fields #region Constructors public Kernel() { } static public Kernel Load() => Load(); protected override void DefaultValues() { SetValues(Memory.Archives.A_MAIN, "kernel.bin"); } #endregion Constructors #region Properties /// /// uint pointer locations, tuple(uint StringLocation,uint get, unit skip) /// /// So you read the pointers at location, you get so many pointers then skip so many /// bytes before getting more pointers. Do this till start of next section. /// /// /// Colly's list of string pointers. Adapted. /// public Dictionary> StringLocations { get; private set; } #endregion Properties #region Methods /// /// Read Section Pointers /// /// protected override void GetFileLocations(BinaryReader br) { uint count = br.ReadUInt32(); while (count-- > 0) { Loc l = new Loc { seek = br.ReadUInt32() }; if (count <= 0) l.length = (uint)br.BaseStream.Length - l.seek; else { l.length = br.ReadUInt32() - l.seek; br.BaseStream.Seek(-4, SeekOrigin.Current); } Files.subPositions.Add(l); } } /// /// Fetch strings from kernel.bin /// /// protected override void LoadArchiveFiles() { Settings = (FF8StringReference.Settings.MultiCharByte | FF8StringReference.Settings.Namedic); ArchiveWorker aw = new ArchiveWorker(Archive); Files = new StringFile(56); MemoryStream ms = null; using (BinaryReader br = new BinaryReader(ms = new MemoryStream(aw.GetBinaryFile(Filenames[0], true)))) { GetFileLocations(br); //index, grab, skip StringLocations = new Dictionary> { //working {0, new Tuple(31,2,4) }, {1, new Tuple(32,2,56) }, {2, new Tuple(33,2,128) }, {3, new Tuple(34,1,18) },//38,58,178, or 78 {4, new Tuple(35,1,10) }, {5, new Tuple(36,2,20) }, {6, new Tuple(37,1,34) },//+1interval 70 //character names here. {7, new Tuple(38,2,20) }, {8, new Tuple(39,1,0) }, {9, new Tuple(40,1,18) }, {11, new Tuple(41,2,4) }, {12, new Tuple(42,2,4) }, {13, new Tuple(43,2,4) }, {14, new Tuple(44,2,4) }, {15, new Tuple(45,2,4) }, {16, new Tuple(46,2,4) }, {17, new Tuple(47,2,4) }, {18, new Tuple(48,2,20) }, {19, new Tuple(49,2,12) }, {21, new Tuple(50,2,20) }, {22, new Tuple(51,2,28) }, {24, new Tuple(52,2,4) }, {25, new Tuple(53,1,18) }, {28, new Tuple(54,1,10) }, {30, new Tuple(55,1,0) }, }; for (uint key = 0; key < Files.subPositions.Count; key++) { Loc fpos = Files.subPositions[(int)key]; if (StringLocations.ContainsKey(key)) { Get_Strings_BinMSG(br, Filenames[0], key, Files.subPositions[(int)(StringLocations[key].Item1)].seek, StringLocations[key].Item2, StringLocations[key].Item3); } } ms = null; } } #endregion Methods } #endregion Classes } }