Beispiel #1
0
        void navigate()
        {
            sHeaderOffset = BitConverter.ToInt32(read.ReadBytes(SpriteTable + 4 * Index, 4), 0) - 0x8000000;

            byte[] HeaderBytes = read.ReadBytes(sHeaderOffset, 36);

            sWidth = BitConverter.ToInt32(new byte[4] {
                HeaderBytes[8], HeaderBytes[9], 0, 0
            }, 0);
            sHeight = BitConverter.ToInt32(new byte[4] {
                HeaderBytes[10], HeaderBytes[11], 0, 0
            }, 0);

            sPaletteIndex = HeaderBytes[2];

            sPointer1 = BitConverter.ToInt32(new byte[4] {
                HeaderBytes[16], HeaderBytes[17], HeaderBytes[18], HeaderBytes[19]
            }, 0) - 0x8000000;
            sPointer2 = BitConverter.ToInt32(new byte[4] {
                HeaderBytes[20], HeaderBytes[21], HeaderBytes[22], HeaderBytes[23]
            }, 0) - 0x8000000;
            sPointer3 = BitConverter.ToInt32(new byte[4] {
                HeaderBytes[28], HeaderBytes[29], HeaderBytes[30], HeaderBytes[31]
            }, 0) - 0x8000000;

            ImageOffset = read.ReadPointer(sPointer3 + 8 * Frame);
            cFrameSize  = read.ReadBytes(sPointer3 + 8 * Frame + 4, 2);

            #region FindPalette
            PaletteOffset = read.ReadPointer(PaletteTable);

            byte indicator = 0x1;
            int  take      = 0;
            while (indicator != 0x0)
            {
                if (read.ReadByte(PaletteTable + 8 * take + 4) == sPaletteIndex)
                {
                    PaletteOffset = read.ReadPointer(PaletteTable + 8 * take);
                    indicator     = 0x0;
                }
                else
                {
                    indicator = read.ReadByte(PaletteTable + 8 * take + 5);
                    take++;
                }
            }
            #endregion

            NSE_Framework.Data.Sprite OW = new NSE_Framework.Data.Sprite(ImageOffset, PaletteOffset, sWidth / 8, sHeight / 8, NSE_Framework.Data.Sprite.SpriteType.Color16, read);

            Sprite     = new Bitmap(sWidth, sHeight);//new Bitmap(sWidth * 2, sHeight * 2);
            byteSprite = read.ReadBytes(ImageOffset, sWidth * sHeight / 2);

            SpritePalette = new NSE_Framework.Data.SpritePalette(NSE_Framework.Data.SpritePalette.PaletteType.Color16, read.ReadBytes(PaletteOffset, 32));

            NSE_Framework.Draw.uDrawData(ref Sprite, byteSprite, SpritePalette, new Size(sWidth / 8, sHeight / 8));
            PictureBoxSprite.Image     = Sprite;
            PictureBoxSprite.BackColor = SpritePalette.Colors[0].Color;
            PictureBoxSprite.Size      = new System.Drawing.Size(sWidth * 2, sHeight * 2);
            PictureBoxSprite.Invalidate();

            #region Labels
            LabelPaletteOffset.Text = "Palette " + sPaletteIndex.ToString("X2") + " Offset:";

            dLabelStarterBytes.Text = HeaderBytes[0].ToString("X2") + HeaderBytes[1].ToString("X2");
            // Byte 2 is the palette index
            // Byte 3 is always 0x11
            dLabelTypeSize.Text  = HeaderBytes[4].ToString("X2") + HeaderBytes[5].ToString("X2");
            dLabelFrameSize.Text = HeaderBytes[7].ToString("X2") + HeaderBytes[6].ToString("X2");
            // Bytes 8,9,10,11 are width and height
            dLabelWidth.Text  = sWidth.ToString();
            dLabelHeight.Text = sHeight.ToString();

            dLabelPalReg.Text   = HeaderBytes[12].ToString("X2") + "-" + HeaderBytes[13].ToString("X2") + " " + HeaderBytes[14].ToString("X2") + HeaderBytes[15].ToString("X2");
            dLabelPointer1.Text = HeaderBytes[19].ToString("X2") + HeaderBytes[18].ToString("X2") + HeaderBytes[17].ToString("X2") + HeaderBytes[16].ToString("X2");
            dLabelPointer2.Text = HeaderBytes[23].ToString("X2") + HeaderBytes[22].ToString("X2") + HeaderBytes[21].ToString("X2") + HeaderBytes[20].ToString("X2");
            dLabelAnim.Text     = HeaderBytes[27].ToString("X2") + HeaderBytes[26].ToString("X2") + HeaderBytes[25].ToString("X2") + HeaderBytes[24].ToString("X2");
            dLabelPointer3.Text = HeaderBytes[31].ToString("X2") + HeaderBytes[30].ToString("X2") + HeaderBytes[29].ToString("X2") + HeaderBytes[28].ToString("X2");

            dLabelSpriteOffset.Text  = "0x" + sHeaderOffset.ToString("X2");
            dLabelImageOffset.Text   = "0x" + ImageOffset.ToString("X2");
            dLabelPaletteOffset.Text = "0x" + PaletteOffset.ToString("X2");
            dLabelCFrameSize.Text    = cFrameSize[1].ToString("X2") + cFrameSize[0].ToString("X2");

            TextBoxPalette.Text = sPaletteIndex.ToString("X2");
            #endregion

            editBlock = 0;
            drawBlock();
            fillCanvas();
            fillPalette();

            iSelectedColor.BackColor = SpritePalette.Colors[editColorIndex].Color;
        }
Beispiel #2
0
        private void NumericUpDownPalette_ValueChanged(object sender, EventArgs e)
        {
            if (!Navigating)
            {
                int  INDEX   = int.Parse(IndexText.Text);
                byte P_INDEX = (byte)NumericUpDownPalette.Value;

                Write.WriteByte(P_INDEX, MiniPaletteIndex + INDEX);

                // Read palette pointer
                int paletteOffset = Read.ReadPointer(MiniPalettes + 8 * P_INDEX);

                // Fix both MINI frames
                EditBox.Sprites[4].Palette = new SpritePalette(SpritePalette.PaletteType.Color16, Read.ReadBytes(paletteOffset, 32));
                EditBox.Sprites[5].Palette = EditBox.Sprites[4].Palette;

                NSE_Framework.Draw.uDrawSprite(ref bM1, EditBox.Sprites[4]);
                NSE_Framework.Draw.uDrawSprite(ref bM2, EditBox.Sprites[5]);

                PictureboxA1.Image = bM1;
                PictureboxA2.Image = bM2;

                if (EditBox.CurrentIndex == 4 || EditBox.CurrentIndex == 5)
                {
                    EditBox.Redraw();
                }
            }
        }