Exemplo n.º 1
0
        public unsafe void LoadGame(byte[] bytes)
        {
            if (bytes == null || bytes.Length == 0)
            {
                return;
            }

            var offset = (0x400 << bytes[0x7FD7] == bytes.Length) ? 0x7000 : 0xF000;

            RomHeader = new RomHeader
            {
                GameTitle       = System.Text.Encoding.GetEncoding("iso-2022-jp").GetString(bytes, offset | 0xFC0, 21).Trim(),
                RomType         = bytes[offset | 0xFD6],
                RomSize         = 0x400 << bytes[offset | 0xFD7],
                    SaveRamSize = 0x400 << bytes[offset | 0xFD8],
                    CountryCode = bytes[offset | 0xFD9],
                    License     = bytes[offset | 0xFDA],
                    Version     = bytes[offset | 0xFDB]
            };


            var arrayPointer = Marshal.AllocHGlobal(bytes.Length * Marshal.SizeOf(typeof(byte)));

            Marshal.Copy(bytes, 0, arrayPointer, bytes.Length);

            GameInfo = new GameInfo
            {
                path = (char *)Marshal.StringToHGlobalUni(Path.Combine(Buffers.TemporaryDataPath, "temp.bytes")).ToPointer(),
                size = (uint)bytes.Length,
                data = arrayPointer.ToPointer()
            };

            Bridges.retro_unload_game();
            if (!Bridges.retro_load_game(ref GameInfo))
            {
                throw new ArgumentException();
            }

            SystemAvInfo = new SystemAvInfo();
            Bridges.retro_get_system_av_info(ref SystemAvInfo);
            Buffers.SetSystemAvInfo(SystemAvInfo);
            Buffers.SetStateSize(Bridges.retro_serialize_size());
        }
Exemplo n.º 2
0
        private unsafe void LoadGame(byte[] bytes)
        {
            var arrayPointer = Marshal.AllocHGlobal(bytes.Length * Marshal.SizeOf(typeof(byte)));

            Marshal.Copy(bytes, 0, arrayPointer, bytes.Length);

            GameInfo = new GameInfo
            {
                path = (char *)Marshal.StringToHGlobalUni(Path.GetTempFileName()).ToPointer(),
                size = (uint)bytes.Length,
                data = arrayPointer.ToPointer()
            };

            if (!Bridges.retro_load_game(ref GameInfo))
            {
                throw new ArgumentException();
            }
            SystemAvInfo = new SystemAvInfo();
            Bridges.retro_get_system_av_info(ref SystemAvInfo);
            Buffers.SetSystemAvInfo(SystemAvInfo);
            Buffers.SetStateSize(Bridges.retro_serialize_size());
        }