Example #1
0
 void LoadLoopParts(NSPC.NSPC nspc)
 {
     foreach (var s in Songs)
     {
         foreach (var p in s.Parts)
         {
             foreach (var c in p.Channels)
             {
                 foreach (var cmd in c.Commands.OfType <CallLoopCommand>().ToList())
                 {
                     if (false == this.LoopParts.ContainsKey(cmd.LoopAddress))
                     {
                         CallLoopPart loopPart = new CallLoopPart();
                         loopPart.Address  = cmd.LoopAddress;
                         loopPart.Commands = ChannelCommand.GetChannelCommandsFromRawData(nspc.aramBuffer, loopPart.Address);
                         this.LoopParts.Add(loopPart.Address, loopPart);
                         cmd.LoopPart = loopPart;
                     }
                     else
                     {
                         cmd.LoopPart = this.LoopParts[cmd.LoopAddress];
                     }
                 }
             }
         }
     }
 }
Example #2
0
        void LoadSongs(NSPC.NSPC nspc)
        {
            int songIndex = 1; // why is this game 1 based? (0 will do strange things)

            foreach (var s in nspc.Songs)
            {
                var song = new Song();
                song.SongIndex = songIndex;
                songIndex++;

                foreach (var p in s.Parts)
                {
                    var part = new Part();

                    foreach (var t in p.Tracks)
                    {
                        var channel = new Channel();

                        channel.LoadFromNSPCTrack(t);

                        part.Channels.Add(channel);
                    }

                    song.Parts.Add(part);
                }

                Songs.Add(song);
            }
        }
Example #3
0
        public void LoadFromNspc(NSPC.NSPC nspc)
        {
            NSPC = nspc;

            LoadSongs(nspc);

            LoadLoopParts(nspc);
        }
Example #4
0
        public void LoadRom(string filename)
        {
            romData = File.ReadAllBytes(filename);

            if (false == this.IsValidRom)
            {
                throw new Exception("Invalid rom file");
            }

            BaseSongs = new SongCollection(SongCollectionType.Base);
            LoadSongCollection(BaseSongs, 0x90A, 0x906, 0x902); // vanilla should be $198000 -> $C8000

            OverworldSongs = new SongCollection(SongCollectionType.Overworld);
            LoadSongCollection(OverworldSongs, 0x91C, 0x918, 0x914); // vanilla should be $1A9EF5 -> 0xD1EF5

            IndoorSongs = new SongCollection(SongCollectionType.Indoor);
            LoadSongCollection(IndoorSongs, 0x92E, 0x92A, 0x926); // vanilla should be $1B8000 -> 0xD8000

            EndingSongs = new SongCollection(SongCollectionType.Ending);
            LoadSongCollection(EndingSongs, 0x93A, 0x936, 0x932); // vanilla should be $1AD380 -> 0xD5380

            var baseNspc        = new NSPC.NSPC();
            int baseNspcAddress = LoadNspcAddress(0x90A, 0x906, 0x902); // vanilla should be $198000 -> $C8000

            baseNspc.LoadRom(this, baseNspcAddress);
            this.BaseNSPC = baseNspc;
            this.BaseSongs.LoadFromNspc(baseNspc);
            this.BaseSongs.FixDurations();
            this.BaseSongs.LoadDefaultSongNames();

            var overworldNspc        = new NSPC.NSPC();
            int overworldNspcAddress = LoadNspcAddress(0x91C, 0x918, 0x914); // vanilla should be $1A9EF5 -> 0xD1EF5

            overworldNspc.LoadRom(this, overworldNspcAddress);
            this.OverworldNSPC = overworldNspc;
            this.OverworldSongs.LoadFromNspc(overworldNspc);
            this.OverworldSongs.FixDurations();
            this.OverworldSongs.LoadDefaultSongNames();

            var indoorNspc        = new NSPC.NSPC();
            int indoorNspcAddress = LoadNspcAddress(0x92E, 0x92A, 0x926); // vanilla should be $1B8000 -> 0xD8000

            indoorNspc.LoadRom(this, indoorNspcAddress);
            this.IndoorNSPC = indoorNspc;
            this.IndoorSongs.LoadFromNspc(indoorNspc);
            this.IndoorSongs.FixDurations();
            this.IndoorSongs.LoadDefaultSongNames();

            var endingNspc        = new NSPC.NSPC();
            int endingNspcAddress = LoadNspcAddress(0x93A, 0x936, 0x932); // vanilla should be $1AD380 -> 0xD5380

            endingNspc.LoadRom(this, endingNspcAddress);
            this.EndingNSPC = endingNspc;
            this.EndingSongs.LoadFromNspc(endingNspc);
            this.EndingSongs.FixDurations();
            this.EndingSongs.LoadDefaultSongNames();
        }