Beispiel #1
0
        // Free space calculation
        public static int FreeMenuTextSpace()
        {
            int      used         = 0;
            MenuText lastMenuText = null;

            foreach (var text in Model.Menu_Texts)
            {
                if (lastMenuText != null && text.Length != 0 && Bits.Compare(text.Text, lastMenuText.Text))
                {
                    continue;
                }
                lastMenuText = text;
                used        += text.Length + 1;
            }
            return(0x700 - used);
        }
Beispiel #2
0
        // Saving
        private void WriteToROM()
        {
            int offset = 0;

            byte[]   temp         = new byte[0x700];
            MenuText lastMenuText = null;

            foreach (var text in Model.Menu_Texts)
            {
                if (lastMenuText != null && text.Length != 0 && Bits.Compare(text.Text, lastMenuText.Text))
                {
                    Bits.SetShort(Model.ROM, text.Index * 2 + 0x3EEF00, lastMenuText.Offset);
                    text.Offset = lastMenuText.Offset;
                    continue;
                }
                if (offset + text.Length + 1 >= 0x700)
                {
                    MessageBox.Show("Menu texts exceed allotted ROM space. Stopped saving at index " + text.Index + ".");
                    break;
                }
                text.Offset  = offset;
                lastMenuText = text;
                //
                Bits.SetShort(Model.ROM, text.Index * 2 + 0x3EEF00, offset);
                Bits.SetChars(temp, offset, text.Text);
                offset        += text.Length;
                temp[offset++] = 0;
                switch (text.Index)
                {
                case 14: Bits.SetByteBits(Model.ROM, 0x03328E, (byte)(text.X * 2), 0x3F); break;

                case 15: Bits.SetByteBits(Model.ROM, 0x03327E, (byte)(text.X * 2), 0x3F); break;

                case 16: Bits.SetByteBits(Model.ROM, 0x033282, (byte)(text.X * 2), 0x3F); break;

                case 17: Bits.SetByteBits(Model.ROM, 0x033286, (byte)(text.X * 2), 0x3F); break;

                case 18: Bits.SetByteBits(Model.ROM, 0x03328A, (byte)(text.X * 2), 0x3F); break;

                case 19: Bits.SetByteBits(Model.ROM, 0x03327A, (byte)(text.X * 2), 0x3F); break;
                }
            }
            Bits.SetBytes(Model.ROM, 0x3EF000, temp);
        }