예제 #1
0
 private void WriteQuickText()
 {
     if (Settings.QuickTextEnabled)
     {
         ROMFuncs.ApplyHack(ModsDirectory + "quick-text");
     }
 }
예제 #2
0
파일: Build.cs 프로젝트: pkmnfrk/mm-rando
        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());
            }
            ;
        }
예제 #3
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());
            }
        }
예제 #4
0
파일: Build.cs 프로젝트: pkmnfrk/mm-rando
        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));
            }
            ;
        }
예제 #5
0
 private void WriteCutscenes()
 {
     if (Settings.ShortenCutscenes)
     {
         ROMFuncs.ApplyHack(ModsDirectory + "short-cutscenes");
     }
 }
예제 #6
0
파일: Build.cs 프로젝트: pkmnfrk/mm-rando
 private void WriteCutscenes()
 {
     if (cCutsc.Checked)
     {
         ROMFuncs.ApplyHack(ModsDir + "short-cutscenes");
     }
     ;
 }
예제 #7
0
파일: Build.cs 프로젝트: pkmnfrk/mm-rando
 private void WriteQuickText()
 {
     if (cQText.Checked)
     {
         ROMFuncs.ApplyHack(ModsDir + "quick-text");
     }
     ;
 }
예제 #8
0
파일: Build.cs 프로젝트: pkmnfrk/mm-rando
        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");
            }
            ;
        }
예제 #9
0
파일: Build.cs 프로젝트: pkmnfrk/mm-rando
        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] });
                };
            }
            ;
        }
예제 #10
0
파일: Build.cs 프로젝트: Bribz/mm-rando
        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");
            }
        }
예제 #11
0
파일: Build.cs 프로젝트: pkmnfrk/mm-rando
 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);
 }
예제 #12
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);
        }
예제 #13
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) });
            }
        }
예제 #14
0
파일: Build.cs 프로젝트: pkmnfrk/mm-rando
        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) });
            }
            ;
        }
예제 #15
0
파일: Build.cs 프로젝트: pkmnfrk/mm-rando
 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");
     };
 }
예제 #16
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");
     }
 }
예제 #17
0
파일: Build.cs 프로젝트: pkmnfrk/mm-rando
        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);
        }
예제 #18
0
        private void WriteLinkAppearance()
        {
            if (Settings.Character == Character.LinkMM)
            {
                WriteTunicColour();
            }
            else if (Settings.Character == Character.LinkOOT ||
                     Settings.Character == Character.AdultLink ||
                     Settings.Character == Character.Kafei)
            {
                int          characterIndex = (int)Settings.Character;
                BinaryReader b   = new BinaryReader(File.Open(ObjsDirectory + "link-" + characterIndex.ToString(), FileMode.Open));
                byte[]       obj = new byte[b.BaseStream.Length];
                b.Read(obj, 0, obj.Length);
                b.Close();
                if (characterIndex < 3)
                {
                    WriteTunicColour(obj, characterIndex);
                }

                ROMFuncs.ApplyHack(ModsDirectory + "fix-link-" + characterIndex.ToString());
                ROMFuncs.InsertObj(obj, 0x11);
                if (characterIndex == 3)
                {
                    b   = new BinaryReader(File.Open(ObjsDirectory + "kafei", FileMode.Open));
                    obj = new byte[b.BaseStream.Length];
                    b.Read(obj, 0, obj.Length);
                    b.Close();
                    WriteTunicColour(obj, characterIndex);
                    ROMFuncs.InsertObj(obj, 0x1C);
                    ROMFuncs.ApplyHack(ModsDirectory + "fix-kafei");
                }
            }
            List <int[]> Others = ROMFuncs.GetAddresses(AddrsDirectory + "tunic-forms");

            ROMFuncs.UpdateFormTunics(Others, Settings.TunicColor);
        }
예제 #19
0
        private void MakeROM(string InFile, string FileName, BackgroundWorker worker)
        {
            using (BinaryReader OldROM = new BinaryReader(File.Open(InFile, FileMode.Open, FileAccess.Read)))
            {
                ROMFuncs.ReadFileTable(OldROM);
            }

            worker.ReportProgress(55, "Writing Audio...");
            WriteAudioSeq();

            worker.ReportProgress(60, "Writing Character...");
            WriteLinkAppearance();
            if (Settings.LogicMode != LogicMode.Vanilla)
            {
                worker.ReportProgress(61, "Applying hacks...");
                ROMFuncs.ApplyHack(ModsDirectory + "title-screen");
                ROMFuncs.ApplyHack(ModsDirectory + "misc-changes");
                ROMFuncs.ApplyHack(ModsDirectory + "cm-cs");
                WriteFileSelect();
            }
            ROMFuncs.ApplyHack(ModsDirectory + "init-file");

            worker.ReportProgress(62, "Writing quick text...");
            WriteQuickText();

            worker.ReportProgress(64, "Writing cutscenes...");
            WriteCutscenes();

            worker.ReportProgress(66, "Writing Tatl...");
            WriteTatlColour();

            worker.ReportProgress(68, "Writing dungeons...");
            WriteDungeons();

            worker.ReportProgress(70, "Writing gimmicks...");
            WriteGimmicks();

            worker.ReportProgress(72, "Writing enemies...");
            WriteEnemies();

            worker.ReportProgress(75, "Writing items...");
            WriteItems();

            worker.ReportProgress(85, "Writing gossip...");
            WriteGossipQuotes();

            worker.ReportProgress(87, "Writing startup...");
            WriteStartupStrings();

            worker.ReportProgress(89, "Writing spoiler log...");
            WriteSpoilerLog();

            worker.ReportProgress(90, "Building ROM...");

            byte[] ROM = ROMFuncs.BuildROM(FileName);
            if (_outputVC)
            {
                worker.ReportProgress(98, "Building VC...");
                ROMFuncs.BuildVC(ROM, VCDirectory, Path.ChangeExtension(FileName, "wad"));
            }
            worker.ReportProgress(100, "Done!");
        }