if (t < 0 || k < 0)
if (t < 0 || t >= NUM_TILESETS || k < 0)
    private static void readPalettes(AbstractRom rom)    {        for (int i = 0; i < 32; i++)        {            int t = rom.read(0x2F121B + 2 * i);            int k = rom.readMulti(0x2F12FB + ((i + 1) * 4), 4)                - rom.readMulti(0x2F12FB + (i * 4), 4);            if (i == 31)                k = 0xDAFAA7 - rom.readMulti(0x2F12FB + (i * 4), 4);            if (t < 0 || k < 0)            {                JOptionPane                    .showMessageDialog(null,                        "Unknown error reading tileset palettes.\n"                            + "Some or all palettes may be missing.",                        "Error reading tileset palettes",                        JOptionPane.ERROR_MESSAGE);                continue;            }            for (int j = 0; j < k / 0xC0; j++)            {                Tileset.Palette tempPal = new Tileset.Palette();                tempPal.mtileset = i;                tempPal.mpalette = j;                tempPal.start = rom.readMulti(0x2F12FB + (i * 4), 4) - 0xBFFE00                    + 0xC0 * j;                tilesets[t].addPalette(tempPal);            }        }        paletteIsInited = true;    }