rom.write(oldPointer, data, newLen);
if (oldPointer < 0x300200) rom.write(oldPointer, rawData, newLen); else { if (latePointer) rom.write(pointerLoc, rom.readMulti(pointerLoc, pointerLen) + 1, pointerLen); rom.write(oldPointer, data, newLen); }
    public boolean writetoFree(byte[] data, int pointerLoc, int pointerBase,        int pointerLen, int oldLen, int newLen, int beginAt, boolean mustBeInExpanded)    {    	// 0xff shielding if the new data starts or ends with 0    	if ((data[0] == 0) && (data[data.length - 1] == 0))    	{    		byte[] tmp = new byte[data.length + 2];    		tmp[0] = (byte) 0xff;    		tmp[tmp.length - 1] = (byte) 0xff;    		System.arraycopy(data, 0, tmp, 1, data.length);    		data = tmp;    		newLen += 2;    	}    	else if (data[0] == 0)    	{    		byte[] tmp = new byte[data.length + 1];    		tmp[0] = (byte) 0xff;    		System.arraycopy(data, 0, tmp, 1, data.length);    		data = tmp;    		newLen++;    	}    	else if (data[data.length - 1] == 0)    	{    		byte[] tmp = new byte[data.length + 1];    		tmp[tmp.length - 1] = (byte) 0xff;    		System.arraycopy(data, 0, tmp, 0, data.length);    		data = tmp;    		newLen += 2;    	}    	        //make sure ROM is expanded if needed        if ((newLen > oldLen) || mustBeInExpanded)            askExpandType();        //store old pointer for use later        int oldPointer = toRegPointer(rom.readMulti(pointerLoc, pointerLen) + pointerBase);        if ((newLen <= oldLen)        		&& !(mustBeInExpanded && (oldPointer < 0x300200))				&& (oldPointer + oldLen <= beginAt))        {            //if it fits in the same place, then write there            nullifyArea(oldPointer, oldLen);            rom.write(oldPointer, data, newLen);            return true;        }        else        {            //if it's too big to fit in the same place...            //back-up old data in case there isn't enough space            byte[] oldData = rom.readByte(oldPointer, oldLen);            //delete old data from ROM, it may be part of the empty space            // found            nullifyArea(oldPointer, oldLen);            try            {                //look for space...                int newPointer = findFreeRange(beginAt, newLen);                //write data there                rom.write(newPointer, data, newLen);                //change pointer                newPointer = toSnesPointer(newPointer - pointerBase);                	                //write pointer                rom.write(pointerLoc, newPointer, pointerLen);                //success!                return true;            }            catch (EOFException e)            {                //if there isn't space, rewrite old data, and return failure                rom.write(oldPointer, oldData);                return false;            }        }    }