"You have too much collision data.", "Error: Unable to Write", JOptionPane.ERROR_MESSAGE);
"You have too much collision data:\n" + e.getMessage(), "Error: Unable to Write", JOptionPane.ERROR_MESSAGE);
    private static void writeCollision(AbstractRom rom)    {        // Collision info can not be written separately        // Check if collision data has been changed, just return if not        if (!isCollisionChanged())            return;        int cc = 0, l; // cc = number of collision sequences written so far        int cp[] = new int[20480]; // cp = collision pointers        int cpi = 0; // cp incrementer        boolean tmp;        try        {            for (int i = 0; i < tilesets.length; i++)            {                // only care about used arrangements                int j = tilesets[i].getArrangementCount();                // collision pointer offset is number of pointers written so                // far * 2 (each pointer is two bytes)                tilesets[i].collisionAddress = cpi * 2;                for (int k = 0; k < j; k++) // go through every used                // arrangement...                {                    // look through collision data written so far                    tmp = true;                    colloop: for (l = 0; l < cc; l++)                        if (rom.compare(0x180200 + 16 * l, tilesets[i]                            .getCollisionDataFlat(k), 16))                        {                            // if collision data already written, use it                            tmp = false;                            break colloop;                        }                    if (tmp) // if collision data not yet written, write it                    {                        if (0x180200 + (16 * (cc + 2)) > 0x18F8B6)                            throw (new RomWriteOutOfRangeException(                                "No space for another collision sequence."));                        if (cc == 4092)                            throw (new RomWriteOutOfRangeException(                                "Someone should optimize this saving routine..."                                    + "(too many unique properties)"));                        rom.write(0x180200 + (16 * cc++), tilesets[i]                            .getCollisionDataFlat(k), 16);                        tmp = false;                    }                    cp[cpi++] = l * 16; // pointer to where the data is                }            }            if (0x180200 + (16 * cc) + (cpi * 2) > 0x18F8B6)                throw (new RomWriteOutOfRangeException(                    "No space for collision pointers."));            rom.write(0x180200 + (16 * cc), cp, cpi, 2);            System.out.println("Collision stuff ends at: "                + (0x180200 + (16 * cc) + (cpi * 2)));            // write collision pointers after collision data            for (int i = 0; i < 20; i++)            {                // collisionAddress currently holds the offset of where the                // info is                // add the place of the start of the pointers                tilesets[i].collisionAddress += 0x180200 + (16 * cc);                rom.write(0x2F137B + (4 * i), HackModule                    .toSnesPointer(tilesets[i].collisionAddress), 4);            }        }        catch (RomWriteOutOfRangeException e)        {            System.out.println("You have too much collision data.");            JOptionPane.showMessageDialog(null,                "You have too much collision data.", "Error: Unable to Write",                JOptionPane.ERROR_MESSAGE);        }    }