public void WriteSprites() { var sprites = new OverworldSpriteList(new SourceBlock(Source, 0x0C93B)).ToList(); var renderer = new SpriteRenderer(); var palette = new NtscNesPalette(); var index = 0x00; // Grayscale renderer.Colors[0] = palette[0x0F]; renderer.Colors[1] = palette[0x00]; renderer.Colors[2] = palette[0x10]; renderer.Colors[3] = palette[0x20]; // Render out sprites foreach (var sprite in sprites) { using (var bitmap = renderer.Render(sprite)) using (var mem = new MemoryStream()) { bitmap.Save(mem, ImageFormat.Png); WriteToDesktopPath(mem.ToArray(), "overworld", $"{index:X2}.png"); } index++; } }
/// <summary> /// Create a data adapter. /// </summary> public ZeldaCartridge(ISource source) { var conversionTable = new Lazy <ITextConversionTable>(() => new TextConversionTable()); var speechConverter = new Lazy <IStringConverter>(() => new SpeechStringConverter(conversionTable.Value)); var textConverter = new Lazy <IStringConverter>(() => new TextStringConverter(conversionTable.Value)); var fixedStringConverter = new Lazy <IFixedStringConverter>(() => new FixedStringConverter(conversionTable.Value)); var speechFormatter = new Lazy <IStringFormatter>(() => new StringFormatter()); // Character Text _characterText = new Lazy <IList <string> >(() => new CharacterText( new WordPointerTable(new SourceBlock(source, 0x4000), new SourceBlock(source, -0x4000), 0x26), speechFormatter.Value, speechConverter.Value, 0x556, 0x26)); // Ending Text _endingText = new Lazy <IEndingText>(() => new EndingText( new StringData(new SourceBlock(source, 0xA959), speechConverter.Value, 38), new FixedStringData(new SourceBlock(source, 0xAB07), fixedStringConverter.Value, 8), new FixedStringData(new SourceBlock(source, 0xAB0F), fixedStringConverter.Value, 24), new FixedStringData(new SourceBlock(source, 0xAB27), fixedStringConverter.Value, 20))); // Menu Text _menuText = new Lazy <IMenuText>(() => new MenuText( new FixedStringData(new SourceBlock(source, 0x09D48), fixedStringConverter.Value, 17), new FixedStringData(new SourceBlock(source, 0x09D5E), fixedStringConverter.Value, 18), new FixedStringData(new SourceBlock(source, 0x09D70), fixedStringConverter.Value, 8), new FixedStringData(new SourceBlock(source, 0x09EEB), fixedStringConverter.Value, 5))); // Underworld _underworld = new Lazy <IUnderworld>(() => { var underworldColumnPointers = new WordPointerTable( new SourceBlock(source, 0x16704), new SourceBlock(source, 0xC000), 10); var columnLibraries = new UnderworldColumnLibraryList( underworldColumnPointers); var grids = new UnderworldGridList( new SourceBlock(source, 0x18700), 4); var roomLayouts = new UnderworldRoomLayoutList( new SourceBlock(source, 0x160DE), 42); var levels = new UnderworldLevelList( new SourceBlock(source, 0x193FF), 9); return(new Underworld { ColumnLibraries = columnLibraries, Grids = grids, Levels = levels, RoomLayouts = roomLayouts }); }); // Overworld _overworld = new Lazy <IOverworld>(() => { var overworldColumnPointers = new WordPointerTable( new SourceBlock(source, 0x19D0F), new SourceBlock(source, 0x0C000), 16); var columnLibraries = new OverworldColumnLibraryList( overworldColumnPointers); var grid = new OverworldGrid( new SourceBlock(source, 0x18580)); var roomLayouts = new OverworldRoomLayoutList( new SourceBlock(source, 0x15418), 124); var tiles = new OverworldTileList( new SourceBlock(source, 0x1697C)); var detailTiles = new OverworldDetailTileList( new SourceBlock(source, 0x169B4)); var sprites = new OverworldSpriteList( new SourceBlock(source, 0x0C93B)); var level = new OverworldLevel( new SourceBlock(source, 0x19303)); var start = new OverworldStart( new SourceBlock(source, 0x19328)); return(new Overworld { ColumnLibraries = columnLibraries, Grid = grid, DetailTiles = detailTiles, RoomLayouts = roomLayouts, Tiles = tiles, Sprites = sprites, Level = level, Start = start }); }); // Shops _shops = new Lazy <IReadOnlyList <IShop> >(() => new ShopList( new SourceBlock(source, 0x18600), new SourceBlock(source, 0x045A2), new SourceBlock(source, 0x06E6F), 20)); // Intro scene _introScene = new Lazy <IScene>(() => new Scene( new SourceBlock(source, 0x1A3FE), conversionTable.Value)); // Title scene _titleScene = new Lazy <IScene>(() => new Scene( new SourceBlock(source, 0x1A869), conversionTable.Value)); // Hit points _hitPointTable = new Lazy <HitPointTable>(() => new HitPointTable( new SourceBlock(source, 0x1FB4E))); }