public static ObjRec[] readBlocksLinear(byte[] romdata, int addr, int w, int h, int count, bool withAttribs, bool transposeIndexes = false, int stride = 0) { var objects = new ObjRec[count]; int blockSize = w * h; int pw = (int)Math.Ceiling(w / 2.0); int ph = (int)Math.Ceiling(h / 2.0); int palSize = pw * ph; int fullSize = withAttribs ? blockSize + palSize : blockSize; for (int i = 0; i < count; i++) { var indexes = new int[blockSize]; var palBytes = new int[palSize]; int baseAddr = addr + i * (fullSize + stride); Array.Copy(romdata, baseAddr, indexes, 0, blockSize); if (withAttribs) { Array.Copy(romdata, baseAddr + blockSize, palBytes, 0, palSize); } if (transposeIndexes) { indexes = Utils.transpose(indexes, w, h); } objects[i] = new ObjRec(w, h, indexes, palBytes); } return(objects); }
public static ObjRec[] readBlocksFromAlignedArrays(byte[] romdata, int addr, int count) { //capcom version var objects = new ObjRec[count]; for (int i = 0; i < count; i++) { byte c1, c2, c3, c4, typeColor; c1 = romdata[addr + i]; c2 = romdata[addr + count * 1 + i]; c3 = romdata[addr + count * 2 + i]; c4 = romdata[addr + count * 3 + i]; typeColor = romdata[addr + count * 4 + i]; objects[i] = new ObjRec(c1, c2, c3, c4, typeColor); } return(objects); }