WriteToStream() public méthode

Writes the chunks to a Quetzal file.
public WriteToStream ( Stream stream ) : void
stream Stream The stream to write to.
Résultat void
Exemple #1
0
        private void SaveToStream(Stream stream, uint destType, uint destAddr)
        {
            if (stream == null)
            {
                return;
            }

            Quetzal quetzal = new Quetzal();

            // 'IFhd' identifies the first 128 bytes of the game file
            quetzal["IFhd"] = image.GetOriginalIFHD();

            // 'CMem' or 'UMem' are the compressed/uncompressed contents of RAM
            byte[] origRam = image.GetOriginalRAM();
            byte[] newRomRam = image.GetMemory();
            int ramSize = (int)(image.EndMem - image.RamStart);
            #if !SAVE_UNCOMPRESSED
            quetzal["CMem"] = Quetzal.CompressMemory(
                origRam, 0, origRam.Length,
                newRomRam, (int)image.RamStart, ramSize);
            #else
            byte[] umem = new byte[ramSize + 4];
            BigEndian.WriteInt32(umem, 0, (uint)ramSize);
            Array.Copy(newRomRam, (int)image.RamStart, umem, 4, ramSize);
            quetzal["UMem"] = umem;
            #endif

            // 'Stks' is the contents of the stack, with a stub on top
            // identifying the destination of the save opcode.
            PushCallStub(new CallStub(destType, destAddr, pc, fp));
            byte[] trimmed = new byte[sp];
            Array.Copy(stack, trimmed, (int)sp);
            quetzal["Stks"] = trimmed;
            PopCallStub();

            // 'MAll' is the list of heap blocks
            if (heap != null)
                quetzal["MAll"] = heap.Save();
            else
            {

            }

            quetzal.WriteToStream(stream);
        }