public void Create(Hash id, U32 state, Vec <U8Arr16> metaXy, Balance intrinsic, U8 level, Vec <BlockNumber> phases, Vec <Hash> adaptations)
        {
            var start = 0;

            Id     = id;
            start += id.Bytes.Length;

            State  = state;
            start += state.Bytes.Length;

            MetaXy = metaXy;
            start += metaXy.Bytes.Length;

            Intrinsic = intrinsic;
            start    += intrinsic.Bytes.Length;

            Level  = level;
            start += level.Bytes.Length;

            Phases = phases;
            start += phases.Bytes.Length;

            Adaptations = adaptations;
            start      += adaptations.Bytes.Length;

            _size = start;
        }
        public override void Decode(byte[] byteArray, ref int p)
        {
            var start = p;

            Id = new Hash();
            Id.Decode(byteArray, ref p);

            State = new U32();
            State.Decode(byteArray, ref p);

            MetaXy = new Vec <U8Arr16>();
            MetaXy.Decode(byteArray, ref p);

            Intrinsic = new Balance();
            Intrinsic.Decode(byteArray, ref p);

            Level = new U8();
            Level.Decode(byteArray, ref p);

            Phases = new Vec <BlockNumber>();
            Phases.Decode(byteArray, ref p);

            Adaptations = new Vec <Hash>();
            Adaptations.Decode(byteArray, ref p);

            _size = p - start;
        }
 public Increment(Func <Label, U8> handlerListAdd, LiveQueue queue, Label execContinue, Label _)
 {
     _liveQueue           = queue;
     _executeLoopContinue = execContinue;
     _opHoriz             = handlerListAdd(LabelFor(Handler_Horiz));
     _opVert = handlerListAdd(LabelFor(Handler_Vert));
 }
 public void For(U8 frames)
 {
     _liveQueue.Write(Y, () => {
         _liveQueue.Push(_opPause);
         _liveQueue.Push(frames);
     });
 }
示例#5
0
 public void WriteROM(Label lbl, U8 len)
 {
     Raw(Id);
     Raw(lbl.Lo());
     Raw(lbl.Hi());
     Raw(len);
 }
示例#6
0
        public static void Palettes()
        {
            U8 black = 0x0F;

            Raw(black, 0x03, 0x23, 0x33, black, 0x01, 0x21, 0x31, black, 0x30, 0x21, 0x0F, black, 0x27, 0x17, 0x0F);
            Raw(black, 0x06, 0x16, 0x26, black, 0x04, 0x24, 0x34, black, 0x1C, 0x15, 0x14, black, 0x02, 0x38, 0x3C);
        }
示例#7
0
 public void DrawTile(U8 tile)
 {
     _liveQueue.Write(Y, () => {
         _liveQueue.Push(_opTile);
         _liveQueue.Push(tile);
     });
 }
        public override void Decode(byte[] byteArray, ref int p)
        {
            if (_metaData is null)
            {
                throw new NotImplementedException("Need MetaData in ctor to decode.");
            }

            ModuleIndex = new U8();
            ModuleIndex.Decode(byteArray, ref p);

            var module = _metaData.Modules[ModuleIndex.Value];

            ModuleName = module.Name;

            EventIndex = new U8();
            EventIndex.Decode(byteArray, ref p);

            var moduleEvent = module.Events[EventIndex.Value];

            EventName = moduleEvent.Name;

            EventArgs = new IType[moduleEvent.EventArgs.Length];
            for (var i = 0; i < moduleEvent.EventArgs.Length; i++)
            {
                var eventArgStr = moduleEvent.EventArgs[i];
                EventArgs[i] = TypeUtil.Mapper(eventArgStr, byteArray, ref p);
            }
        }
示例#9
0
 static void PlatformDetection_DetectWiiU8(string path, U8 u8, PlatformList platforms)
 {
     if (DetectDirectoryNode != null)
     {
         DetectDirectoryNode(path, u8.Root, platforms);
     }
 }
示例#10
0
        static void Main(string[] args)
        {
            string dir;

            if (args.Length == 1)
            {
                dir = Path.Combine(Path.GetDirectoryName(args[0]), Path.GetFileNameWithoutExtension(args[0]));
            }
            else if (args.Length != 2)
            {
                Console.WriteLine("Usage: u8extractor /path/to/file.arc [/extract/path]");
                return;
            }
            else
            {
                dir = args[1];
            }

            Stream filestream = new FileStream(args[0], FileMode.Open, FileAccess.Read, FileShare.Read);
            Stream stream     = filestream;

            try {
                DlcBin dlc = new DlcBin(filestream);
                stream = dlc.Data;
            } catch (FormatException) { }

            U8 u8 = new U8(stream);

            u8.Root.Extract(dir);

            filestream.Close();
        }
示例#11
0
 public static void Clamp(VByte v, U8 low, U8 high)
 {
     If.Block(c => c
              .True(() => A.Set(v).LessThan(low), () => v.Set(low))
              .True(() => A.GreaterThan(high), () => v.Set(high))
              );
 }
示例#12
0
 public void WriteROM(Label lbl, U8 len)
 {
     Raw(_opFromAddress);
     Raw(lbl.Lo());
     Raw(lbl.Hi());
     Raw(len);
 }
示例#13
0
        private void doPack(object files)
        {
            setControls(false, true);
            string input  = ((string[])files)[0];
            string output = ((string[])files)[1];

            try
            {
                U8 u = new U8();
                u.Progress += new EventHandler <System.ComponentModel.ProgressChangedEventArgs>(pack_Progress);

                u.CreateFromDirectory(input);

                u.Lz77Compress = lz77;
                if (imd5)
                {
                    u.AddHeaderImd5();
                }

                u.Save(output);

                MessageBox.Show("Successfully packed U8 file to:\n" + output, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            finally { setControls(true, true); }
        }
示例#14
0
        public static GenericExtrinsicCall UpdateConfig(U8 index)
        {
            var optionByte = new U8();

            optionByte.Create(0);
            return(new GenericExtrinsicCall("DotMogModule", "update_config", index, optionByte));
        }
示例#15
0
        public void Should_FailEqualityForDifferentDataTypes()
        {
            var numericItem  = new F4(1);
            var numericItem2 = new U8(5);

            Assert.IsFalse(numericItem.Equals(numericItem2));
        }
        public void VecU8EncodingTest()
        {
            var tc     = new GenericTypeConverter <Vec <U8> >();
            var actual = (Vec <U8>)tc.Create("0x200101020304050607");

            Assert.AreEqual(actual.Bytes, actual.Encode());

            var t1 = new U8(); t1.Create(actual.Value[0].Value);
            var t2 = new U8(); t2.Create(actual.Value[1].Value);
            var t3 = new U8(); t3.Create(actual.Value[2].Value);
            var t4 = new U8(); t4.Create(actual.Value[3].Value);
            var t5 = new U8(); t5.Create(actual.Value[4].Value);
            var t6 = new U8(); t6.Create(actual.Value[5].Value);
            var t7 = new U8(); t7.Create(actual.Value[6].Value);
            var t8 = new U8(); t8.Create(actual.Value[7].Value);

            List <U8> list = new List <U8>()
            {
                t1, t2, t3, t4, t5, t6, t7, t8
            };

            var vecU8 = new Vec <U8>();

            vecU8.Create(list);

            Assert.AreEqual("0x200101020304050607", Utils.Bytes2HexString(vecU8.Bytes));
        }
示例#17
0
        void bwIconReplace_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                BackgroundWorker bwIconReplace = sender as BackgroundWorker;
                replacedIcon = (string)e.Argument;

                bwIconReplace.ReportProgress(0);

                if (replacedIcon.ToLower().EndsWith(".bin"))
                {
                    bwIconReplace.ReportProgress(0, "Loading icon.bin...");
                    newIconBin.LoadFile(replacedIcon);
                }
                else if (replacedIcon.ToLower().EndsWith(".app"))
                {
                    bwIconReplace.ReportProgress(0, "Loading 00000000.app...");
                    U8 tmpU8 = U8.Load(replacedIcon);

                    bwIconReplace.ReportProgress(50, "Loading icon.bin...");
                    for (int i = 0; i < tmpU8.NumOfNodes; i++)
                    {
                        if (tmpU8.StringTable[i].ToLower() == "icon.bin")
                        {
                            newIconBin.LoadFile(tmpU8.Data[i]); break;
                        }
                    }
                }
                else //wad
                {
                    bwIconReplace.ReportProgress(0, "Loading WAD...");
                    WAD tmpWad = WAD.Load(replacedIcon);

                    if (!tmpWad.HasBanner)
                    {
                        throw new Exception("CustomizeMii only handles Channel WADs!");
                    }

                    bwIconReplace.ReportProgress(60, "Loading icon.bin...");
                    for (int i = 0; i < tmpWad.BannerApp.NumOfNodes; i++)
                    {
                        if (tmpWad.BannerApp.StringTable[i].ToLower() == "icon.bin")
                        {
                            newIconBin.LoadFile(tmpWad.BannerApp.Data[i]); break;
                        }
                    }
                }

                iconTransparents.Clear();

                addTpls();
                addBrlyts();
                addBrlans();
            }
            catch (Exception ex)
            {
                replacedIcon = string.Empty;
                errorBox(ex.Message);
            }
        }
示例#18
0
        public void Should_FailEqualityForDifferentNumericValues()
        {
            var numericItem  = new U8(1);
            var numericItem2 = new U8(2);

            Assert.IsFalse(numericItem.Equals(numericItem2));
        }
示例#19
0
 public void For(U8 frames)
 {
     Queue._liveQueue.Write(Y, () => {
         Queue._liveQueue.Push(Id);
         Queue._liveQueue.Push(frames);
     });
 }
示例#20
0
        private static void TestKey(string[] args)
        {
            var accountId = new AccountId();

            accountId.Create(Utils.GetPublicKeyFrom("5CxW5DWQDpXi4cpACd62wzbPjbYrx4y67TZEmRXBcvmDTNaM"));
            Console.WriteLine($"AccountId: {accountId}");
            Console.WriteLine($"Public Key: {Utils.Bytes2HexString(accountId.Bytes).ToLower()}");

            var str = "0x200101020304050607";

            var memory    = Utils.HexToByteArray(str).AsMemory();
            var vecU8     = new List <U8>();
            var byteArray = memory.ToArray();
            var p         = 0;
            var length    = CompactInteger.Decode(byteArray, ref p);

            Console.WriteLine($"Length: {length}, p = {p}");
            for (var i = 0; i < length; i++)
            {
                var u8 = new U8();
                u8.Decode(byteArray, ref p);
                vecU8.Add(u8);
            }

            Console.WriteLine(JsonConvert.SerializeObject(vecU8));
        }
示例#21
0
        public void Should_BeEqualIfNumericItemsEqual()
        {
            var numericItem  = new U8(1);
            var numericItem2 = new U8(1);

            Assert.IsTrue(numericItem.Equals(numericItem2));
        }
示例#22
0
        public void Should_FailEqualityForDifferetObjectTypes()
        {
            var numericItem = new U8(1);
            var obj         = "test";

            Assert.IsFalse(numericItem.Equals(obj));
        }
示例#23
0
        public void Should_CreateCorrecU4Item()
        {
            var numericItem = new U8(1);

            Assert.IsTrue(numericItem.Value == 1);
            Assert.IsTrue(numericItem.Type == Format.U8);
        }
示例#24
0
 public Increment(Func <Label, U8> handlerListAdd, LiveQueue queue)
 {
     //TODO: add a way to store multiple op IDs, one per callback
     _liveQueue = queue;
     _opHoriz   = handlerListAdd(LabelFor(Handler_Horiz));
     _opVert    = handlerListAdd(LabelFor(Handler_Vert));
 }
示例#25
0
        public override void Decode(byte[] byteArray, ref int p)
        {
            var start = p;

            var optionByte = new U8();

            optionByte.Decode(byteArray, ref p);

            OptionFlag = optionByte.Value > 0;

            T t = default;

            if (optionByte.Value > 0)
            {
                t = new T();
                t.Decode(byteArray, ref p);
            }

            _size = p - start;

            var bytes = new byte[_size];

            Array.Copy(byteArray, start, bytes, 0, _size);

            Bytes = bytes;
            Value = t != null ? t : default;
        }
示例#26
0
 public Pause(Func <Label, U8> handlerListAdd, LiveQueue queue, Label _, Label execBreak)
 {
     _liveQueue        = queue;
     _executeLoopBreak = execBreak;
     _pauseCount       = VByte.New(NES.ram, "VRamQueue_pauseCount");
     _opPause          = handlerListAdd(LabelFor(Handler));
 }
示例#27
0
 public ExecuteRom(Func <Label, U8> handlerListAdd, LiveQueue queue, Label execContinue, Label _)
 {
     _liveQueue           = queue;
     _executeLoopContinue = execContinue;
     _opExecuteRom        = handlerListAdd(LabelFor(Handler));
     _ptrRomStart         = Ptr.New(NES.zp, "VRamQueue_ExecuteRom_ptrRomStart");
 }
示例#28
0
 public void Write(Label lbl, U8 len)
 {
     _liveQueue.Write(Y, () => {
         _liveQueue.Push(_opExecuteRom);
         _liveQueue.Push(lbl.Lo());
         _liveQueue.Push(lbl.Hi());
     });
 }
示例#29
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (BingoMissionGroupId != 0)
            {
                hash ^= BingoMissionGroupId.GetHashCode();
            }
            if (U2 != 0)
            {
                hash ^= U2.GetHashCode();
            }
            if (ScheduleId.Length != 0)
            {
                hash ^= ScheduleId.GetHashCode();
            }
            if (BingoMissionCardId != 0)
            {
                hash ^= BingoMissionCardId.GetHashCode();
            }
            if (BingoMissionRewardId != 0)
            {
                hash ^= BingoMissionRewardId.GetHashCode();
            }
            if (U6 != 0)
            {
                hash ^= U6.GetHashCode();
            }
            if (BannerId != 0)
            {
                hash ^= BannerId.GetHashCode();
            }
            if (U8 != 0)
            {
                hash ^= U8.GetHashCode();
            }
            if (PrevBingoMissionGroupId != 0)
            {
                hash ^= PrevBingoMissionGroupId.GetHashCode();
            }
            if (BingoMissionGroupPermissionId != 0)
            {
                hash ^= BingoMissionGroupPermissionId.GetHashCode();
            }
            if (U11 != 0)
            {
                hash ^= U11.GetHashCode();
            }
            if (U12 != 0)
            {
                hash ^= U12.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#30
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (MoveID != 0)
            {
                hash ^= MoveID.GetHashCode();
            }
            if (U2 != 0)
            {
                hash ^= U2.GetHashCode();
            }
            if (U3 != 0)
            {
                hash ^= U3.GetHashCode();
            }
            if (U4 != 0)
            {
                hash ^= U4.GetHashCode();
            }
            if (U5 != 0)
            {
                hash ^= U5.GetHashCode();
            }
            if (Type != 0)
            {
                hash ^= Type.GetHashCode();
            }
            if (U7 != 0)
            {
                hash ^= U7.GetHashCode();
            }
            if (U8 != 0)
            {
                hash ^= U8.GetHashCode();
            }
            if (Drain != 0)
            {
                hash ^= Drain.GetHashCode();
            }
            if (Power != 0)
            {
                hash ^= Power.GetHashCode();
            }
            if (Accuracy != 0)
            {
                hash ^= Accuracy.GetHashCode();
            }
            if (U12 != 0)
            {
                hash ^= U12.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#31
0
 public U8Viewer(U8 Archive)
 {
     Root = Archive.ToFileSystem();
     InitializeComponent();
 }