public LiveHeXController(ISaveFileProvider boxes, IPKMView editor, InjectorCommunicationType ict)
        {
            SAV    = boxes;
            Editor = editor;
            var ValidVers = RamOffsets.GetValidVersions(boxes.SAV);

            Bot = new PokeSysBotMini(ValidVers[0], ict);
        }
Exemplo n.º 2
0
 public static void SendBox(PokeSysBotMini psb, byte[] boxData, int box)
 {
     byte[][] pkmData = boxData.Split(psb.SlotSize);
     for (int i = 0; i < psb.SlotCount; i++)
     {
         SendSlot(psb, pkmData[i], box, i);
     }
 }
Exemplo n.º 3
0
        public static void SendSlot(PokeSysBotMini psb, byte[] data, int box, int slot)
        {
            var slotofs      = psb.GetSlotOffset(box, slot);
            var StoredLength = psb.SlotSize - 0x1C;

            psb.com.WriteBytes(data.Slice(0, StoredLength), slotofs);
            psb.com.WriteBytes(data.AsSpan(StoredLength).ToArray(), slotofs + (ulong)StoredLength + 0x70);
        }
Exemplo n.º 4
0
        public static byte[] ReadSlot(PokeSysBotMini psb, int box, int slot)
        {
            var bytes        = psb.com.ReadBytes(psb.GetSlotOffset(box, slot), psb.SlotSize + psb.GapSize);
            var StoredLength = psb.SlotSize - 0x1C;
            var stored       = bytes.Slice(0, StoredLength);
            var party        = bytes.Slice(StoredLength + 0x70, 0x1C);

            return(ArrayUtil.ConcatAll(stored, party));
        }
Exemplo n.º 5
0
        // Reflection method
        public static bool ReadBlockFromString(PokeSysBotMini psb, SaveFile sav, string block, out byte[]?read)
        {
            read = null;
            var obj = RamOffsets.GetOffsets(psb.Version);

            if (obj == null)
            {
                return(false);
            }
            try
            {
                var offset = obj.GetType().GetField(block).GetValue(obj);
                if (offset is uint and 0)
                {
                    return(false);
                }
                var    allblocks = sav.GetType().GetProperty("Blocks").GetValue(sav);
                var    blockprop = allblocks.GetType().GetProperty(block);
                object data;
                if (allblocks is SCBlockAccessor scba && blockprop == null)
                {
                    var key = allblocks.GetType().GetField(block, BindingFlags.NonPublic | BindingFlags.Static).GetValue(allblocks);
                    data = scba.GetBlock((uint)key);
                }
                else
                {
                    data = blockprop.GetValue(allblocks);
                }

                if (data is SaveBlock sb)
                {
                    read = psb.com.ReadBytes((uint)offset, sb.Data.Length);
                    read.CopyTo(sb.Data, sb.Offset);
                }
                else if (data is SCBlock scb)
                {
                    read = psb.com.ReadBytes((ulong)offset, scb.Data.Length);
                    read.CopyTo(scb.Data, 0);
                }
                else
                {
                    return(false);
                }
                return(true);
            }
Exemplo n.º 6
0
        public static byte[] ReadBox(PokeSysBotMini psb, int box, int len, List <byte[]> allpkm)
        {
            var bytes = psb.com.ReadBytes(psb.GetBoxOffset(box), len);

            if (psb.GapSize == 0)
            {
                return(bytes);
            }
            var currofs = 0;

            for (int i = 0; i < psb.SlotCount; i++)
            {
                var stored = bytes.Slice(currofs, psb.SlotSize);
                allpkm.Add(stored);
                currofs += psb.SlotSize + psb.GapSize;
            }
            return(ArrayUtil.ConcatAll(allpkm.ToArray()));
        }
Exemplo n.º 7
0
 public static void SendSlot(PokeSysBotMini psb, byte[] data, int box, int slot) => psb.com.WriteBytes(data, psb.GetSlotOffset(box, slot));
Exemplo n.º 8
0
 public static byte[] ReadSlot(PokeSysBotMini psb, int box, int slot) => psb.com.ReadBytes(psb.GetSlotOffset(box, slot), psb.SlotSize + psb.GapSize);