Exemplo n.º 1
0
 private void Level_SelectedIndexChange(object sender, EventArgs e)
 {
     LevelScripts.SelectedLevel = (uint)LevelComboBox.SelectedIndex;
     LevelScripts.ExitDecode    = false;
     ROMManager.InitialiseModelLoad(ClientRectangle, RenderPanel); //init without rendering
     LevelScripts.ParseLevelScripts(ROMManager.SM64ROM, LevelScripts.LVLSCRIPTSTART);
     AreaComboBox.Items.Clear();
     for (int i = 0; i < LevelScripts.GeoLayoutOffsets.Length; i++)
     {
         AreaComboBox.Items.Add(i + 1);
     }
     AreaComboBox.SelectedIndex = 0;
     Renderer.Render(ClientRectangle, Width, Height, RenderPanel);
     if (AreaComboBox.Items.Count > 1)
     {
         AreaComboBox.Enabled = true;
     }
     else
     {
         AreaComboBox.Enabled = false;
     }
     TextureNumBox.Items.Clear();
     UpdateStatusText();
     if (ROMManager.SM64ROM.getSegmentStart(0x0E) < 0x1200000)
     {
         TexturesGroupBox.Visible = false; return;
     }
     groupBoxForce.Visible    = ROMManager.LevelHasLighting();
     TexturesGroupBox.Visible = true;
     for (uint i = 0; i < Textures.TextureArray.Length; i++)
     {
         TextureNumBox.Items.Add("Tex" + (i + 1));
     }
     TextureNumBox.SelectedIndex = 0;
 }
Exemplo n.º 2
0
 private void LevelArea_SelectedIndexChange(object sender, EventArgs e)
 {
     Renderer.LevelArea = (uint)AreaComboBox.SelectedIndex;
     ROMManager.InitialiseModelLoad(ClientRectangle, RenderPanel, Width, Height);
     UpdateStatusText();
     if (ROMManager.SM64ROM.getSegmentStart(0x0E) >= 0x1200000)
     {
         ROMManager.AdjustCombiners();
     }
 }
Exemplo n.º 3
0
        private void ImportTexture_Click(object sender, EventArgs e)
        {
            int index = TextureNumBox.SelectedIndex;
            // Displays an OpenFileDialog so the user can select a Cursor.
            OpenFileDialog OpenTexture = OFD();

            OpenTexture.Filter = "Image Files|*.png;*.bmp;*.jpg";
            OpenTexture.Title  = "Select a texture image file";
            if (OpenTexture.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Bitmap TextureBMP  = (Bitmap)Image.FromFile(OpenTexture.FileName);
                double widthpower  = Math.Log(TextureBMP.Width, 2);
                double heightpower = Math.Log(TextureBMP.Height, 2);
                if ((widthpower % 1) != 0 || (heightpower % 1) != 0)
                {
                    MessageBox.Show("Only texture sizes in powers of 2 \n(ie 16x16, 32x32, 64x64, 128x64) are supported!", "Invalid texture resolution");
                    return;
                }
                Vector2 originalpowers = Textures.getWidthHeightPowers(index);
                if ((Math.Pow(2, originalpowers.X) * Math.Pow(2, originalpowers.Y)) < (Math.Pow(2, widthpower) * Math.Pow(2, heightpower)))
                {
                    MessageBox.Show("Texture is beyond the max data for this tile! \nTry lowering resolution or bitsize.", "Texture data too large!");
                    return;
                }
                else if (TexFormatBox.SelectedIndex == 2 && ((Math.Pow(2, originalpowers.X) * Math.Pow(2, originalpowers.Y)) < (Math.Pow(2, widthpower + 1) * Math.Pow(2, heightpower)))) //CI4 needs twice data atm for palette
                {
                    MessageBox.Show("Texture is beyond the max data for this tile! \nTry lowering resolution or bitsize.\n(CI needs extra data for palette and commands)", "Texture data too large!");
                    return;
                }
                else if (TexFormatBox.SelectedIndex == 2 && BitsizeBox.SelectedIndex == 0 && Textures.getImageColors(TextureBMP).Length > 16)
                {
                    MessageBox.Show("Texture has too many colours for CI4.\nPlease reduce colour count to 16."); return;
                }
                Textures.ResizeTexture(index, Convert.ToInt32(widthpower), Convert.ToInt32(heightpower));
                Textures.ImportBMPtoTexture(TextureBMP, index);
                UInt32[] F5CMDs = Textures.F5CMDArray[TextureNumBox.SelectedIndex]; ROM SM64ROM = ROMManager.SM64ROM;
                ROMManager.InitialiseModelLoad(ClientRectangle, RenderPanel, Width, Height);
                UpdateTextureNum();
                int    width           = TextureBMP.Width;
                int    selectedbitsize = (int)(4 * Math.Pow(2, BitsizeBox.SelectedIndex));
                ushort linesperword    = Convert.ToUInt16((64d * 2048d) / ((double)TextureBMP.Width * selectedbitsize));
                ushort texelcount      = (ushort)((double)(TextureBMP.Width * TextureBMP.Height) * ((double)selectedbitsize / 16d) - 1);
                for (uint i = 0; i < F5CMDs.Length; i++) //Update F5 scanline width
                {
                    uint F5 = F5CMDs[i];
                    if (SM64ROM.getByte(F5 - 0x10) == 0xF3)
                    {
                        SM64ROM.WriteEightBytes(F5 - 0x10, 0xF300000007000000 | (uint)(texelcount << 12) | linesperword);
                    }
                    SM64ROM.WriteTwoBytes(F5 + 1, (ushort)((SM64ROM.ReadTwoBytes(F5CMDs[i] + 1) & 0xFC00) | ((width * selectedbitsize / 64) << 1)));
                }
                TextureBMP.Dispose();
            }
        }
Exemplo n.º 4
0
        private void TPropertiesBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Textures.FirstTexLoad || ROMManager.SM64ROM == null)
            {
                return;
            }
            uint index      = (uint)TextureNumBox.SelectedIndex;
            byte TParamByte = ROMManager.SM64ROM.getByte(Textures.F5CMDArray[index][0] + 5);
            int  Tparam     = ((TParamByte >> 2) & 0x03);
            int  dif        = TPropertiesBox.SelectedIndex - Tparam;

            for (uint i = 0; i < Textures.F5CMDArray[index].Length; i++)
            {
                ROMManager.SM64ROM.changeByte(Textures.F5CMDArray[index][i] + 5, (byte)(TParamByte + (dif * 4)));
            }                                                                                                     //*4 for << 2 with negative carried
            ROMManager.InitialiseModelLoad(ClientRectangle, RenderPanel, Width, Height);
        }
Exemplo n.º 5
0
        private void SPropertiesBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Textures.FirstTexLoad || ROMManager.SM64ROM == null)
            {
                return;
            }
            uint index      = (uint)TextureNumBox.SelectedIndex;
            byte SParamByte = ROMManager.SM64ROM.getByte(Textures.F5CMDArray[index][0] + 6);
            int  Sparam     = (SParamByte & 0x03);
            int  dif        = SPropertiesBox.SelectedIndex - Sparam;

            for (uint i = 0; i < Textures.F5CMDArray[index].Length; i++)
            {
                ROMManager.SM64ROM.changeByte(Textures.F5CMDArray[index][i] + 6, (byte)(SParamByte + dif));
            }
            ROMManager.InitialiseModelLoad(ClientRectangle, RenderPanel, Width, Height);
        }
Exemplo n.º 6
0
        private void BitsizeBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            BitSizeCheck();
            if (Textures.FirstTexLoad || ROMManager.SM64ROM == null)
            {
                return;
            }
            ROM SM64ROM = ROMManager.SM64ROM;

            UInt32[] F5CMDs      = Textures.F5CMDArray[TextureNumBox.SelectedIndex];
            byte     BitsizeByte = SM64ROM.getByte(F5CMDs[0] + 1);
            int      BitsizePWR  = ((BitsizeByte >> 3) & 0x03);
            int      dif         = BitsizeBox.SelectedIndex - BitsizePWR;
            byte     bitsize     = (byte)(BitsizeByte + (dif * 8)); //*8 for << 3 with negative carried

            for (uint i = 0; i < F5CMDs.Length; i++)
            {
                SM64ROM.changeByte(F5CMDs[i] + 1, bitsize);
            }
            uint[] F5CMD           = Textures.F5CMDArray[(uint)TextureNumBox.SelectedIndex];
            byte   WidthsizeByte   = SM64ROM.getByte(F5CMD[0] + 7);
            ushort HeightsizeShort = SM64ROM.ReadTwoBytes(F5CMD[0] + 5);
            int    ogHeightPower   = (HeightsizeShort >> 6 & 0x0F);
            int    ogWidthPower    = (WidthsizeByte >> 4);

            if (ogWidthPower < ogHeightPower)
            {
                Textures.ResizeTexture(TextureNumBox.SelectedIndex, ogWidthPower - dif, ogHeightPower);
            }
            else
            {
                Textures.ResizeTexture(TextureNumBox.SelectedIndex, ogWidthPower, ogHeightPower - dif);
            }
            if (!WaitToRender)
            {
                ROMManager.InitialiseModelLoad(ClientRectangle, RenderPanel, Width, Height);
            }
            if (!WaitToRender)
            {
                UpdateTextureNum();
            }
        }
Exemplo n.º 7
0
        private void TexFormatBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            WaitToRender = true;
            BitSizeCheck();
            if (Textures.FirstTexLoad || ROMManager.SM64ROM == null)
            {
                WaitToRender = false; return;
            }
            uint index      = (uint)TextureNumBox.SelectedIndex;
            byte FormatByte = ROMManager.SM64ROM.getByte(Textures.F5CMDArray[index][0] + 1);
            int  Format     = FormatByte >> 5;
            int  dif        = TexFormatBox.SelectedIndex - Format;

            for (uint i = 0; i < Textures.F5CMDArray[index].Length; i++)
            {
                ROMManager.SM64ROM.changeByte(Textures.F5CMDArray[index][i] + 1, (byte)(FormatByte + (dif * 32)));
            }                                                                                                    //*32 for << 5 with negative carried
            ROMManager.InitialiseModelLoad(ClientRectangle, RenderPanel, Width, Height);
            UpdateTextureNum();
            WaitToRender = false;
        }