Exemplo n.º 1
0
        private void FromJsonFilesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog of = new OpenFileDialog();

            if (of.ShowDialog() == DialogResult.OK)
            {
                FileStream fs   = new FileStream(of.FileName, FileMode.Open, FileAccess.Read);
                byte[]     temp = new byte[fs.Length];
                fs.Read(temp, 0, (int)fs.Length);
                fs.Close();

                ROM.SetRom(temp, out bool isHeadered);

                if (isHeadered)
                {
                    writeLog(TextAndTranslationManager.GetString("form_parent_notice_headered"), Color.Orange);
                }

                temp = null;

                /*
                 * Reset the progress bar if the user exports again.
                 * This prevents crashing.
                 */
                progressBar1.Value = 0;

                importer = new Importer(ROM.DATA, progressBar1, logTextbox);
                UpdateStatistics();
            }
        }
Exemplo n.º 2
0
 public void movePointers(int newAddress)
 {
     if (!isConnPatched)
     {
         if (ROM.IsEmpty(newAddress, size))
         {
             if (AddressLoROM.PcToSnes_Hi(newAddress) == AddressLoROM.PcToSnes_Bank(primaryPointer))
             {
                 ROM.Swap(secondaryPointer, newAddress, size);
                 byte[] b = new byte[]
                 {
                     (byte)(AddressLoROM.PcToSnes_Lo(newAddress)),
                     (byte)(AddressLoROM.PcToSnes_Hi(newAddress + 1)),
                 };
                 ROM.Write(primaryPointer, b.Length, b);
                 updatePointers();
             }
             else
             {
                 throw new Exception("Address must be within the bank.");
             }
         }
         else
         {
             throw new Exception(TextAndTranslationManager.GetString(Dungeon.moveError));
         }
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Exemplo n.º 3
0
    public static void generateStrings()
    {
        pot_item_names         = new string[22];
        sprite_names           = new string[byte.MaxValue];
        pot_item_special_names = new string[5];

        for (int i = 0; i < pot_item_names.Length; i++)
        {
            pot_item_names[i] = TextAndTranslationManager.GetString("pot_item_op" + i.ToString("000"));
        }

        for (int i = 0; i < pot_item_special_names.Length; i++)
        {
            pot_item_special_names[i] = TextAndTranslationManager.GetString("pot_item_special_op" + i);
        }

        for (int i = 0; i <= 242; i++)
        {
            sprite_names[i] = TextAndTranslationManager.GetString("sprite_names_op" + i.ToString("000"));
        }
    }
Exemplo n.º 4
0
    public void movePointers(int newAddress)
    {
        if (ROM.IsEmpty(newAddress, pointerSize))
        {
            PointerRead.CheckAddressWithinRangeOf3Byte(newAddress);
            ROM.Swap(primaryPointer_address[1], newAddress, pointerSize);

            byte[] b = PointerRead.GeneratePointer3(newAddress);

            for (int i = 0; i < primaryPointer_location.Length; i++)
            {
                b[0] += (byte)((i % 2 == 0) ? 1 : -1); //works if the first byte is ($actualPointer + 1)
                ROM.Write(primaryPointer_location[i], 3, b);
            }

            updatePrimaryPointers();
        }
        else
        {
            throw new Exception(TextAndTranslationManager.GetString(Dungeon.moveError));
        }
    }
Exemplo n.º 5
0
    public void movePointers(uint pointerNo, int newAddress)
    {
        if (!(pointerNo <= getNumberOfPointers()))
        {
            throw new ArgumentOutOfRangeException();
        }

        int size = dataSize[pointerNo];

        if (ROM.IsEmpty(newAddress, size))
        {
            PointerRead.CheckAddressWithinRangeOf3Byte(newAddress);
            ROM.Swap(primaryPointer_address[pointerNo], newAddress, size);
            byte[] newPointer = PointerRead.GeneratePointer3(newAddress);
            ROM.Write(primaryPointer_location[pointerNo], newPointer.Length, newPointer);
            refreshPointer3Bytes();
        }
        else
        {
            throw new Exception(TextAndTranslationManager.GetString(Dungeon.moveError));
        }
    }
Exemplo n.º 6
0
 private void Form1_Load(object sender, EventArgs e)
 {
     UpdateStatistics();
     TextAndTranslationManager.SetupLanguage(TextAndTranslationManager.XLanguage.English_US, "");
 }
Exemplo n.º 7
0
    public void writeAllBlocks(SortedList <ushort, List <i_block> > allDungeonBlocks)
    {
        List <i_block> allBlocks = new List <i_block>();

        foreach (ushort i in allDungeonBlocks.Keys)
        {
            foreach (i_block blocky in allDungeonBlocks[i])
            {
                allBlocks.Add(blocky);
            }
        }

        const string error = "dungeon_error_block_overload";

        if (allBlocks.Count > maxBlockEntries)
        {
            throw new Exception(TextAndTranslationManager.GetString(error));
        }

        byte[][] blockData_set = new byte[numberOfPointers][];

        int currentEntry = 0;

        /* Convert block data to byte arrays and attempt to insert into array blockData_set.
         *
         * blockData_set is of length pointerNumber (the number of pointers for the blocks.
         * Each index represents the locations to insert the location. Therefore, all data
         * at index i is stored at the address primaryPointer_address[i].
         */

        foreach (i_block blocky in allBlocks)
        {
            /* You get this error if you run out of space, or in other words,
             * if you are inserting too many blocks.
             */
            if (currentEntry > numberOfPointers)
            {
                throw new Exception(TextAndTranslationManager.GetString(error));
            }

            byte[] blockData;
            blocky.getBytes(out blockData);

            if (blockData_set[currentEntry] == null)
            {
                /* Store the block entry. No need to check storage limits here
                 * because it's very unlikely that an entire space dedicated
                 * to block storage is less than a single block.
                 */
                blockData_set[currentEntry] = blockData;
            }
            else if (blockData_set[currentEntry].Length < dataSize[currentEntry] + blockData.Length)
            {
                //Store the block entry if space is available.
                blockData_set[currentEntry] = blockData_set[currentEntry].Concat(blockData).ToArray();
            }
            else
            {
                //otherwise move to the next location, if it exists
                currentEntry++;

                if (currentEntry > numberOfPointers)
                {
                    throw new Exception(TextAndTranslationManager.GetString(error));
                }
                else
                {
                    blockData_set[currentEntry] = blockData;
                }
            }
        }

        for (int i = 0; i < numberOfPointers; i++)
        {
            if (blockData_set[i] != null)
            {
                ROM.Write(primaryPointer_address[i], blockData_set[i].Length, blockData_set[i]);
            }

            //clear up unused space

            int size = blockData_set[i] == null ? 0 : blockData_set[i].Length;
            for (int j = size; j < dataSize[i]; j++)
            {
                ROM.Write(primaryPointer_address[i] + j, Dungeon.nullValue);
            }
        }
    }