Exemple #1
0
        private void WriteGimmicks()
        {
            int i = cDMult.SelectedIndex;

            if (i > 0)
            {
                ROMFuncs.ApplyHack(ModsDir + "dm-" + i.ToString());
            }
            ;
            i = cDType.SelectedIndex;
            if (i > 0)
            {
                ROMFuncs.ApplyHack(ModsDir + "de-" + i.ToString());
            }
            ;
            i = cGravity.SelectedIndex;
            if (i > 0)
            {
                ROMFuncs.ApplyHack(ModsDir + "movement-" + i.ToString());
            }
            ;
            i = cFloors.SelectedIndex;
            if (i > 0)
            {
                ROMFuncs.ApplyHack(ModsDir + "floor-" + i.ToString());
            }
            ;
        }
Exemple #2
0
        private void WriteGimmicks()
        {
            int damageMultiplier = (int)Settings.DamageMode;

            if (damageMultiplier > 0)
            {
                ROMFuncs.ApplyHack(ModsDirectory + "dm-" + damageMultiplier.ToString());
            }

            int damageEffect = (int)Settings.DamageEffect;

            if (damageEffect > 0)
            {
                ROMFuncs.ApplyHack(ModsDirectory + "de-" + damageEffect.ToString());
            }

            int gravityType = (int)Settings.MovementMode;

            if (gravityType > 0)
            {
                ROMFuncs.ApplyHack(ModsDirectory + "movement-" + gravityType.ToString());
            }

            int floorType = (int)Settings.FloorType;

            if (floorType > 0)
            {
                ROMFuncs.ApplyHack(ModsDirectory + "floor-" + floorType.ToString());
            }
        }
Exemple #3
0
        private void MakeROM(string InFile, string FileName)
        {
            BinaryReader OldROM = new BinaryReader(File.Open(InFile, FileMode.Open));

            ROMFuncs.ReadFileTable(OldROM);
            OldROM.Close();
            WriteAudioSeq();
            WriteLinkAppearance();
            if (cMode.SelectedIndex != 2)
            {
                ROMFuncs.ApplyHack(ModsDir + "title-screen");
                ROMFuncs.ApplyHack(ModsDir + "misc-changes");
                ROMFuncs.ApplyHack(ModsDir + "cm-cs");
                WriteFileSelect();
            }
            ;
            ROMFuncs.ApplyHack(ModsDir + "init-file");
            WriteQuickText();
            WriteCutscenes();
            WriteTatlColour();
            WriteDungeons();
            WriteGimmicks();
            WriteEnemies();
            WriteItems();
            WriteGossipQuotes();
            WriteStartupStrings();
            WriteSpoilerLog();
            byte[] ROM = ROMFuncs.BuildROM(FileName);
            if (Output_VC)
            {
                string VCFileName = saveWad.FileName;
                ROMFuncs.BuildVC(ROM, VCDir, Path.GetFullPath(VCFileName));
            }
            ;
        }
Exemple #4
0
 private void WriteCutscenes()
 {
     if (Settings.ShortenCutscenes)
     {
         ROMFuncs.ApplyHack(ModsDirectory + "short-cutscenes");
     }
 }
Exemple #5
0
 private void WriteQuickText()
 {
     if (Settings.QuickTextEnabled)
     {
         ROMFuncs.ApplyHack(ModsDirectory + "quick-text");
     }
 }
Exemple #6
0
        /// <summary>
        /// Update the gossip stone actor to not check mask of truth
        /// </summary>
        private void WriteFreeHints()
        {
            int  address = 0x00E0A810 + 0x378;
            byte val     = 0x00;

            ROMFuncs.WriteToROM(address, val);
        }
Exemple #7
0
        private void mByteswap_Click(object sender, EventArgs e)
        {
            if (openBROM.ShowDialog() == DialogResult.OK)
            {
                int r = ROMFuncs.ByteswapROM(openBROM.FileName);
                switch (r)
                {
                case 0:
                    MessageBox.Show("Successfully byteswapped ROM.",
                                    "Success", MessageBoxButtons.OK, MessageBoxIcon.None);
                    break;

                case 1:
                    MessageBox.Show("ROM appears to be big endian.",
                                    "Success", MessageBoxButtons.OK, MessageBoxIcon.None);
                    break;

                default:
                    MessageBox.Show("Could not byteswap ROM.",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
                ;
            }
            ;
        }
Exemple #8
0
 private void WriteQuickText()
 {
     if (cQText.Checked)
     {
         ROMFuncs.ApplyHack(ModsDir + "quick-text");
     }
     ;
 }
Exemple #9
0
 private void WriteEnemies()
 {
     if (Settings.RandomizeEnemies)
     {
         SeedRNG();
         ROMFuncs.ShuffleEnemies(RNG);
     }
 }
Exemple #10
0
 private void WriteCutscenes()
 {
     if (cCutsc.Checked)
     {
         ROMFuncs.ApplyHack(ModsDir + "short-cutscenes");
     }
     ;
 }
Exemple #11
0
        private void WriteItems()
        {
            if (cMode.SelectedIndex == 2)
            {
                WriteFreeItem(Deku_Mask);
                if (cCutsc.Checked)
                {
                    //giants cs were removed
                    WriteFreeItem(Song_Oath);
                }
                ;
                return;
            }
            ;
            //write free item
            int j = ItemList.FindIndex(u => u.Replaces == 0);

            WriteFreeItem(ItemList[j].ID);
            //write everything else
            ROMFuncs.ReplaceGetItemTable(ModsDir);
            ROMFuncs.InitItems();
            for (int i = 0; i < ItemList.Count; i++)
            {
                if (ItemList[i].Replaces == -1)
                {
                    continue;
                }
                ;
                j = ItemList[i].ID;
                bool repeat = REPEATABLE.Contains(j);
                bool cycle  = CYCLE_REPEATABLE.Contains(j);
                int  r      = ItemList[i].Replaces;
                if (j > IST_NEW)
                {
                    j -= 23;
                }
                ;
                if (r > IST_NEW)
                {
                    r -= 23;
                }
                ;
                if ((i >= B_Fairy) && (i <= B_Mushroom))
                {
                    ROMFuncs.WriteNewBottle(r, j);
                }
                else
                {
                    ROMFuncs.WriteNewItem(r, j, repeat, cycle);
                };
            }
            ;
            if (Shops)
            {
                ROMFuncs.ApplyHack(ModsDir + "fix-shop-checks");
            }
            ;
        }
Exemple #12
0
        private void WriteItems()
        {
            if (Settings.LogicMode == LogicMode.Vanilla)
            {
                WriteFreeItem(Items.MaskDeku);

                if (Settings.ShortenCutscenes)
                {
                    //giants cs were removed
                    WriteFreeItem(Items.SongOath);
                }

                return;
            }

            //write free item
            int itemId = ItemList.FindIndex(u => u.ReplacesItemId == 0);

            WriteFreeItem(ItemList[itemId].ID);

            //write everything else
            ROMFuncs.ReplaceGetItemTable(ModsDirectory);
            ROMFuncs.InitItems();

            for (int i = 0; i < ItemList.Count; i++)
            {
                itemId = ItemList[i].ID;

                // Unused item
                if (ItemList[i].ReplacesItemId == -1)
                {
                    continue;
                }
                ;

                bool isRepeatable      = Items.REPEATABLE.Contains(itemId);
                bool isCycleRepeatable = Items.CYCLE_REPEATABLE.Contains(itemId);
                int  replacesItemId    = ItemList[i].ReplacesItemId;

                itemId -= ItemUtils.GetItemOffset(itemId);

                replacesItemId -= ItemUtils.GetItemOffset(replacesItemId);

                if (ItemUtils.IsBottleCatchContent(i))
                {
                    ROMFuncs.WriteNewBottle(replacesItemId, itemId);
                }
                else
                {
                    ROMFuncs.WriteNewItem(replacesItemId, itemId, isRepeatable, isCycleRepeatable);
                }
            }

            if (Settings.AddShopItems)
            {
                ROMFuncs.ApplyHack(ModsDirectory + "fix-shop-checks");
            }
        }
Exemple #13
0
        private void WriteFileSelect()
        {
            if (cMode.SelectedIndex == 2)
            {
                return;
            }
            ;
            ROMFuncs.ApplyHack(ModsDir + "file-select");
            byte[]       SkyboxDefault = new byte[] { 0x91, 0x78, 0x9B, 0x28, 0x00, 0x28 };
            List <int[]> Addrs         = ROMFuncs.GetAddresses(AddrsDir + "skybox-init");
            Random       R             = new Random();
            int          rot           = R.Next(360);

            for (int i = 0; i < 2; i++)
            {
                Color c = Color.FromArgb(SkyboxDefault[i * 3], SkyboxDefault[i * 3 + 1], SkyboxDefault[i * 3 + 2]);
                float h = c.GetHue();
                h += rot;
                h %= 360f;
                c  = ROMFuncs.FromAHSB(c.A, h, c.GetSaturation(), c.GetBrightness());
                SkyboxDefault[i * 3]     = c.R;
                SkyboxDefault[i * 3 + 1] = c.G;
                SkyboxDefault[i * 3 + 2] = c.B;
            }
            ;
            for (int i = 0; i < 3; i++)
            {
                ROMFuncs.WriteROMAddr(Addrs[i], new byte[] { SkyboxDefault[i * 2], SkyboxDefault[i * 2 + 1] });
            }
            ;
            rot = R.Next(360);
            byte[] FSDefault = new byte[] { 0x64, 0x96, 0xFF, 0x96, 0xFF, 0xFF, 0x64, 0xFF, 0xFF };
            Addrs = ROMFuncs.GetAddresses(AddrsDir + "fs-colour");
            for (int i = 0; i < 3; i++)
            {
                Color c = Color.FromArgb(FSDefault[i * 3], FSDefault[i * 3 + 1], FSDefault[i * 3 + 2]);
                float h = c.GetHue();
                h += rot;
                h %= 360f;
                c  = ROMFuncs.FromAHSB(c.A, h, c.GetSaturation(), c.GetBrightness());
                FSDefault[i * 3]     = c.R;
                FSDefault[i * 3 + 1] = c.G;
                FSDefault[i * 3 + 2] = c.B;
            }
            ;
            for (int i = 0; i < 9; i++)
            {
                if (i < 6)
                {
                    ROMFuncs.WriteROMAddr(Addrs[i], new byte[] { 0x00, FSDefault[i] });
                }
                else
                {
                    ROMFuncs.WriteROMAddr(Addrs[i], new byte[] { FSDefault[i] });
                };
            }
            ;
        }
Exemple #14
0
 private void WriteEnemies()
 {
     if (cEnemy.Checked)
     {
         SeedRNG();
         ROMFuncs.ShuffleEnemies(RNG);
     }
     ;
 }
Exemple #15
0
        private void WriteStartupStrings()
        {
            if (Settings.LogicMode == LogicMode.Vanilla)
            {
                //ROMFuncs.ApplyHack(ModsDir + "postman-testing");
                return;
            }
            Version v = Assembly.GetExecutingAssembly().GetName().Version;

            ROMFuncs.SetStrings(ModsDirectory + "logo-text", $"v{v}", tSString.Text);
        }
Exemple #16
0
        private void WriteTunicColour()
        {
            Color t = Settings.TunicColor;

            byte[]       c    = { t.R, t.G, t.B };
            List <int[]> locs = ROMFuncs.GetAddresses(AddrsDirectory + "tunic-colour");

            for (int i = 0; i < locs.Count; i++)
            {
                ROMFuncs.WriteROMAddr(locs[i], c);
            }
        }
Exemple #17
0
        private void WriteTunicColour(byte[] obj, int i)
        {
            Color t = Settings.TunicColor;

            byte[]       c    = { t.R, t.G, t.B };
            List <int[]> locs = ROMFuncs.GetAddresses(AddrsDirectory + "tunic-" + i.ToString());

            for (int j = 0; j < locs.Count; j++)
            {
                ROMFuncs.WriteFileAddr(locs[j], c, obj);
            }
        }
Exemple #18
0
        private void WriteGossipQuotes()
        {
            if (Settings.LogicMode == LogicMode.Vanilla)
            {
                return;
            }

            if (Settings.EnableGossipHints)
            {
                SeedRNG();
                ROMFuncs.WriteGossipMessage(GossipQuotes, RNG);
            }
        }
Exemple #19
0
        private bool ValidateROM(string FileName)
        {
            bool         res = false;
            BinaryReader ROM = new BinaryReader(File.Open(FileName, FileMode.Open));

            if (ROM.BaseStream.Length == 0x2000000)
            {
                res = ROMFuncs.CheckOldCRC(ROM);
            }
            ;
            ROM.Close();
            return(res);
        }
Exemple #20
0
        private bool ValidateROM(string FileName)
        {
            bool res = false;

            using (BinaryReader ROM = new BinaryReader(File.Open(FileName, FileMode.Open, FileAccess.Read)))
            {
                if (ROM.BaseStream.Length == 0x2000000)
                {
                    res = ROMFuncs.CheckOldCRC(ROM);
                }
            }
            return(res);
        }
Exemple #21
0
 private void WriteGossipQuotes()
 {
     if (cMode.SelectedIndex == 2)
     {
         return;
     }
     ;
     if (cGossip.Checked)
     {
         SeedRNG();
         ROMFuncs.WriteGossipMsg(GossipQuotes, RNG);
     }
     ;
 }
Exemple #22
0
        private void WriteStartupStrings()
        {
            if (cMode.SelectedIndex == 2)
            {
                //ROMFuncs.ApplyHack(ModsDir + "postman-testing");
                return;
            }
            ;
            Version v       = Assembly.GetExecutingAssembly().GetName().Version;
            string  ver     = String.Format("v{0}.{1}", v.Major, v.Minor);
            string  setting = tSString.Text;

            ROMFuncs.SetStrings(ModsDir + "logo-text", ver, setting);
        }
Exemple #23
0
 private void WriteAudioSeq()
 {
     if (!cBGM.Checked)
     {
         return;
     }
     ;
     foreach (SeqInfo s in SeqList)
     {
         s.Name = MusicDir + s.Name;
     }
     ;
     ROMFuncs.ApplyHack(ModsDir + "fix-music");
     ROMFuncs.ApplyHack(ModsDir + "inst24-swap-guitar");
     ROMFuncs.RebuildAudioSeq(SeqList);
 }
Exemple #24
0
        private void WriteDungeons()
        {
            if ((Settings.LogicMode == LogicMode.Vanilla) || (!Settings.RandomizeDungeonEntrances))
            {
                return;
            }

            ROMFuncs.WriteEntrances(Values.OldEntrances.ToArray(), _newEntrances);
            ROMFuncs.WriteEntrances(Values.OldExits.ToArray(), _newExits);
            byte[]       li   = new byte[] { 0x24, 0x02, 0x00, 0x00 };
            List <int[]> addr = new List <int[]>();

            addr = ROMFuncs.GetAddresses(AddrsDirectory + "d-check");
            for (int i = 0; i < addr.Count; i++)
            {
                li[3] = (byte)_newExts[i];
                ROMFuncs.WriteROMAddr(addr[i], li);
            }

            ROMFuncs.ApplyHack(ModsDirectory + "fix-dungeons");
            addr = ROMFuncs.GetAddresses(AddrsDirectory + "d-exit");

            for (int i = 0; i < addr.Count; i++)
            {
                if (i == 2)
                {
                    ROMFuncs.WriteROMAddr(addr[i], new byte[] { (byte)((Values.OldExits[_newEnts[i + 1]] & 0xFF00) >> 8), (byte)(Values.OldExits[_newEnts[i + 1]] & 0xFF) });
                }
                else
                {
                    ROMFuncs.WriteROMAddr(addr[i], new byte[] { (byte)((Values.OldExits[_newEnts[i]] & 0xFF00) >> 8), (byte)(Values.OldExits[_newEnts[i]] & 0xFF) });
                }
            }

            addr = ROMFuncs.GetAddresses(AddrsDirectory + "dc-flagload");
            for (int i = 0; i < addr.Count; i++)
            {
                ROMFuncs.WriteROMAddr(addr[i], new byte[] { (byte)((_newDCFlags[i] & 0xFF00) >> 8), (byte)(_newDCFlags[i] & 0xFF) });
            }

            addr = ROMFuncs.GetAddresses(AddrsDirectory + "dc-flagmask");
            for (int i = 0; i < addr.Count; i++)
            {
                ROMFuncs.WriteROMAddr(addr[i], new byte[] { (byte)((_newDCMasks[i] & 0xFF00) >> 8), (byte)(_newDCMasks[i] & 0xFF) });
            }
        }
Exemple #25
0
        private void WriteAudioSeq()
        {
            if (!Settings.RandomizeBGM)
            {
                return;
            }
            ;

            foreach (SequenceInfo s in SequenceList)
            {
                s.Name = MusicDirectory + s.Name;
            }
            ;
            ROMFuncs.ApplyHack(ModsDirectory + "fix-music");
            ROMFuncs.ApplyHack(ModsDirectory + "inst24-swap-guitar");
            ROMFuncs.RebuildAudioSeq(SequenceList);
        }
Exemple #26
0
        private void WriteDungeons()
        {
            if ((cMode.SelectedIndex == 2) || (!cDEnt.Checked))
            {
                return;
            }
            ;
            ROMFuncs.WriteEntrances(ENTRANCE_OLD, ENTRANCE_NEW);
            ROMFuncs.WriteEntrances(EXIT_OLD, EXIT_NEW);
            byte[]       li   = new byte[] { 0x24, 0x02, 0x00, 0x00 };
            List <int[]> addr = new List <int[]>();

            addr = ROMFuncs.GetAddresses(AddrsDir + "d-check");
            for (int i = 0; i < addr.Count; i++)
            {
                li[3] = (byte)NewExts[i];
                ROMFuncs.WriteROMAddr(addr[i], li);
            }
            ;
            ROMFuncs.ApplyHack(ModsDir + "fix-dungeons");
            addr = ROMFuncs.GetAddresses(AddrsDir + "d-exit");
            for (int i = 0; i < addr.Count; i++)
            {
                if (i == 2)
                {
                    ROMFuncs.WriteROMAddr(addr[i], new byte[] { (byte)((EXIT_OLD[NewEnts[i + 1]] & 0xFF00) >> 8), (byte)(EXIT_OLD[NewEnts[i + 1]] & 0xFF) });
                }
                else
                {
                    ROMFuncs.WriteROMAddr(addr[i], new byte[] { (byte)((EXIT_OLD[NewEnts[i]] & 0xFF00) >> 8), (byte)(EXIT_OLD[NewEnts[i]] & 0xFF) });
                };
            }
            ;
            addr = ROMFuncs.GetAddresses(AddrsDir + "dc-flagload");
            for (int i = 0; i < addr.Count; i++)
            {
                ROMFuncs.WriteROMAddr(addr[i], new byte[] { (byte)((DC_FLAG_NEW[i] & 0xFF00) >> 8), (byte)(DC_FLAG_NEW[i] & 0xFF) });
            }
            ;
            addr = ROMFuncs.GetAddresses(AddrsDir + "dc-flagmask");
            for (int i = 0; i < addr.Count; i++)
            {
                ROMFuncs.WriteROMAddr(addr[i], new byte[] { (byte)((DC_MASK_NEW[i] & 0xFF00) >> 8), (byte)(DC_MASK_NEW[i] & 0xFF) });
            }
            ;
        }
Exemple #27
0
 private void WriteTatlColour()
 {
     if (cTatl.SelectedIndex != 5)
     {
         byte[]       c    = new byte[8];
         List <int[]> locs = ROMFuncs.GetAddresses(AddrsDir + "tatl-colour");
         for (int i = 0; i < locs.Count; i++)
         {
             ROMFuncs.Arr_WriteU32(c, 0, TATL_COLOURS[cTatl.SelectedIndex, i << 1]);
             ROMFuncs.Arr_WriteU32(c, 4, TATL_COLOURS[cTatl.SelectedIndex, (i << 1) + 1]);
             ROMFuncs.WriteROMAddr(locs[i], c);
         }
         ;
     }
     else
     {
         ROMFuncs.ApplyHack(ModsDir + "rainbow-tatl");
     };
 }
Exemple #28
0
 private void WriteTatlColour()
 {
     if (Settings.TatlColorSchema != TatlColorSchema.Random)
     {
         var          selectedColorSchemaIndex = (int)Settings.TatlColorSchema;
         byte[]       c    = new byte[8];
         List <int[]> locs = ROMFuncs.GetAddresses(AddrsDirectory + "tatl-colour");
         for (int i = 0; i < locs.Count; i++)
         {
             ROMFuncs.Arr_WriteU32(c, 0, Values.TatlColours[selectedColorSchemaIndex, i << 1]);
             ROMFuncs.Arr_WriteU32(c, 4, Values.TatlColours[selectedColorSchemaIndex, (i << 1) + 1]);
             ROMFuncs.WriteROMAddr(locs[i], c);
         }
     }
     else
     {
         ROMFuncs.ApplyHack(ModsDirectory + "rainbow-tatl");
     }
 }
Exemple #29
0
        private void WriteFreeItem(int Item)
        {
            ROMFuncs.WriteToROM(ITEM_ADDRS[Item], ITEM_VALUES[Item]);
            switch (Item)
            {
            case 1:     //bow
                ROMFuncs.WriteToROM(0xC5CE6F, (byte)0x01);
                break;

            case 5:     //bomb bag
                ROMFuncs.WriteToROM(0xC5CE6F, (byte)0x08);
                break;

            case 19:     //sword upgrade
                ROMFuncs.WriteToROM(0xC5CE00, (byte)0x4E);
                break;

            case 20:
                ROMFuncs.WriteToROM(0xC5CE00, (byte)0x4F);
                break;

            case 22:     //quiver upgrade
                ROMFuncs.WriteToROM(0xC5CE6F, (byte)0x02);
                break;

            case 23:
                ROMFuncs.WriteToROM(0xC5CE6F, (byte)0x03);
                break;

            case 24:    //bomb bag upgrade
                ROMFuncs.WriteToROM(0xC5CE6F, (byte)0x10);
                break;

            case 25:
                ROMFuncs.WriteToROM(0xC5CE6F, (byte)0x18);
                break;

            default:
                break;
            }
            ;
        }
Exemple #30
0
        private void WriteLinkAppearance()
        {
            if (cLink.SelectedIndex == 0)
            {
                WriteTunicColour();
            }
            else if (cLink.SelectedIndex < 4)
            {
                int          i   = cLink.SelectedIndex;
                BinaryReader b   = new BinaryReader(File.Open(ObjsDir + "link-" + i.ToString(), FileMode.Open));
                byte[]       obj = new byte[b.BaseStream.Length];
                b.Read(obj, 0, obj.Length);
                b.Close();
                if (i < 3)
                {
                    WriteTunicColour(obj, i);
                }
                ;
                ROMFuncs.ApplyHack(ModsDir + "fix-link-" + i.ToString());
                ROMFuncs.InsertObj(obj, 0x11);
                if (i == 3)
                {
                    b   = new BinaryReader(File.Open(ObjsDir + "kafei", FileMode.Open));
                    obj = new byte[b.BaseStream.Length];
                    b.Read(obj, 0, obj.Length);
                    b.Close();
                    WriteTunicColour(obj, i);
                    ROMFuncs.InsertObj(obj, 0x1C);
                    ROMFuncs.ApplyHack(ModsDir + "fix-kafei");
                }
                ;
            }
            ;
            List <int[]> Others = ROMFuncs.GetAddresses(AddrsDir + "tunic-forms");

            ROMFuncs.UpdateFormTunics(Others, bTunic.BackColor);
        }