Exemple #1
0
        private static void ListView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (Form.TreeView.SelectedNode == null ||
                Form.TreeView.SelectedNode.Parent == null)
            {
                return;
            }

            var item = Form.ListView.SelectedItems.Cast <ListViewItem>().FirstOrDefault();

            if (item == null)
            {
                return;
            }

            var node = Form.TreeView.SelectedNode;

            if (node.Name == "Songs")
            {
                var song    = int.Parse(item.Name);
                var address = int.Parse(item.SubItems[1].Text, System.Globalization.NumberStyles.HexNumber);

                var position = address;

                var length = SuperNintendo.Console.Memory[position++] | (SuperNintendo.Console.Memory[position++] << 8);

                //Array.Copy(SuperNintendo.Console.Memory, position, SuperNintendo.Apu.Memory, 0x2000, length);

                for (var index = 0; index < length; index++)
                {
                    var source = ((position & 0xff0000) >> 1) | (position & 0x7fff);
                    source += index;
                    source  = ((source & 0x7f8000) << 1) | (source & 0x7fff) | 0x8000;

                    var destination = 0x2000 + index;

                    SuperNintendo.Apu.Memory[destination] = SuperNintendo.Console.Memory[source];
                }

                SongReader.Position = 0x2000;
                SongReader.Read();

                MidiPlayer.Song = song;
                SongPlayer.Reset();

                SongWindow.Show();
            }
        }