// Read data from ROM at given PC address. public override bool ReadFromROM(Rom rom, int addressPC) { //byte [] buffer; //int DecompressedSize = Compression.ReadCompressedData (out buffer, addressPC); rom.Seek(addressPC); int compressedSize = rom.Decompress(out List <byte> buffer); CompressedData.Clear(); rom.Seek(addressPC); rom.Read(CompressedData, compressedSize); CompressionUpToDate = true; int decompressedSize = buffer.Count; int colour_count = decompressedSize / 2; R.Clear(); G.Clear(); B.Clear(); for (int n = 0; n < colour_count; n++) { int colour = Tools.ConcatBytes(buffer [n << 1], buffer [n << 1 | 1]); R.Add((byte)((colour & 0x001F) << 3)); G.Add((byte)((colour & 0x03E0) >> 2)); B.Add((byte)((colour & 0x7C00) >> 7)); } startAddressPC = addressPC; return(true); }
// Read data from ROM at given PC address. public override bool ReadFromROM(Rom rom, int addressPC) { rom.Seek(addressPC); int compressedSize = rom.Decompress(out Bytes); CompressedData.Clear(); rom.Seek(addressPC); rom.Read(CompressedData, compressedSize); CompressionUpToDate = true; return(true); }
// Read data from ROM at given PC address. public override bool ReadFromROM(Rom rom, int addressPC) { rom.Seek(addressPC); int compressedSize = rom.Decompress(out List <byte> buffer); CompressedData.Clear(); rom.Seek(addressPC); rom.Read(CompressedData, compressedSize); CompressionUpToDate = true; int decompressedSize = buffer.Count; int Layer1Size = Tools.ConcatBytes(buffer [0], buffer [1]); int BtsSize = Layer1Size / 2; // half the amount of data of layer one int Layer2Size; if (Layer1Size + BtsSize + 2 < decompressedSize) { Layer2Size = Layer1Size; // check if layer 2 data exists, } else { Layer2Size = 0; // if not, set its size to zero. } ScreenCount = BtsSize / 256; // divide by 256 tiles per screen. int Layer1Counter = 2; int BtsCounter = 2 + Layer1Size; int Layer2Counter = 2 + Layer1Size + BtsSize; for (int n = 0; n < BtsSize; n++) { Layer1.Add((ushort)Tools.ConcatBytes(buffer [Layer1Counter], buffer [Layer1Counter + 1])); Bts.Add(buffer [BtsCounter]); if (Layer2Size > 0) { Layer2.Add((ushort)Tools.ConcatBytes(buffer [Layer2Counter], buffer [Layer2Counter + 1])); } Layer1Counter += 2; BtsCounter += 1; Layer2Counter += 2; } startAddressPC = addressPC; return(decompressedSize > 0); }
// Read data from ROM at given PC address. public override bool ReadFromROM(Rom rom, int addressPC) { //byte [] buffer; //int DecompressedSize = Compression.ReadCompressedData (out buffer, addressPC); rom.Seek(addressPC); rom.Decompress(out List <byte> buffer); int decompressedSize = buffer.Count; int tile8Count = decompressedSize >> 1; for (int n = 0; n < tile8Count; n++) { Tiles8.Add(Tools.ConcatBytes(buffer [2 * n], buffer [2 * n + 1])); } startAddressPC = addressPC; return(true); }
// Read data from ROM at given PC address. public override bool ReadFromROM(Rom rom, int addressPC) { //byte [] buffer; //int decompressedSize = 0; int pixelCount = 0; byte bite; byte bit; //decompressedSize = Compression.ReadCompressedData (out b, addressPC); rom.Seek(addressPC); int compressedSize = rom.Decompress(out List <byte> buffer); CompressedData.Clear(); rom.Seek(addressPC); rom.Read(CompressedData, compressedSize); CompressionUpToDate = true; int decompressedSize = buffer.Count; // if (decompressedSize > 100000) // decompressedSize = 100000; // Dunno how important these lines are (some safety mechanism?) pixelCount = decompressedSize << 1; // 2x decompressed size (1 pixel uses 4 bits) TileCount = pixelCount >> 6; // this resizes the Bytes list for (int t = 0; t < TileCount; t++) { for (int n = 0; n < 8; n++) // bitplane 0 { bite = buffer [t << 5 | n << 1]; for (int i = 0; i < 8; i++) { bit = (byte)(bite & 1); Bytes [t << 6 | n << 3 | i] = bit; bite >>= 1; } } for (int n = 0; n < 8; n++) // bitplane 1 { bite = buffer [t << 5 | n << 1 | 1]; for (int i = 0; i < 8; i++) { bit = (byte)(bite & 1); Bytes [t << 6 | n << 3 | i] = (byte)(Bytes [t << 6 | n << 3 | i] | bit << 1); bite >>= 1; } } for (int n = 0; n < 8; n++) // bitplane 2 { bite = buffer [t << 5 | n << 1 | 16]; for (int i = 0; i < 8; i++) { bit = (byte)(bite & 1); Bytes [t << 6 | n << 3 | i] = (byte)(Bytes [t << 6 | n << 3 | i] | bit << 2); bite >>= 1; } } for (int n = 0; n < 8; n++) // bitplane 3 { bite = buffer [t << 5 | n << 1 | 17]; for (int i = 0; i < 8; i++) { bit = (byte)(bite & 1); Bytes [t << 6 | n << 3 | i] = (byte)(Bytes [t << 6 | n << 3 | i] | bit << 3); bite >>= 1; } } } startAddressPC = addressPC; return(true); }