private void TilesViewer_Load(object sender, EventArgs e) { Tile16[] tiles16 = TilesLoader.LoadTile16(rom); //Need to load map data map = new OverworldMap(rom, 0); //allgfx16Ptr unsafe { byte *newPdata = (byte *)ZGraphics.allgfx16Ptr.ToPointer(); BitmapData bdata = b.LockBits(new Rectangle(0, 0, 128, 256), ImageLockMode.ReadWrite, PixelFormat.Format4bppIndexed); byte * pdata = (byte *)bdata.Scan0; int sheetPos = 0; for (int i = 0; i < 8; i++) { int d = 0; while (d < 2048) { byte mapByte = newPdata[d + (map.blocksets[i] * 2048)]; switch (i) { case 0: case 3: case 4: case 5: mapByte += 0x88; break; } pdata[d + (sheetPos * 2048)] = mapByte; d++; } sheetPos++; } b.UnlockBits(bdata); ColorPalette cp = b.Palette; for (int i = 0; i < 16; i++) { cp.Entries[i] = map.palettes[i + 32]; } b.Palette = cp; } mainTilesDisplay.Image = b; //mainTilesDisplay.Refresh(); //Need to load Palette Map Data //Need to load Blockset Map Data //-> will be able to draw a tile at this point }
private void buildMap(int mapid) { tiles8Bitmap = new Bitmap(128, 7136, 64, PixelFormat.Format4bppIndexed, tiles8GfxPtr); tiles16Bitmap = new Bitmap(128, 7520, 128, PixelFormat.Format8bppIndexed, tiles16GfxPtr); map[mapid] = new OverworldMap(rom, mapid); //allgfx16Ptr unsafe { byte *newPdata = (byte *)ZGraphics.allgfx16Ptr.ToPointer(); byte *sheetsData = (byte *)tiles8GfxPtr.ToPointer(); int sheetPos = 0; for (int i = 0; i < 16; i++) { int d = 0; while (d < 2048) { byte mapByte = newPdata[d + (map[mapid].blocksets[i] * 2048)]; switch (i) { case 0: case 3: case 4: case 5: mapByte += 0x88; break; } if (i == 7) { if (d > 1024) { if (mapid < 64) //Lightworld { mapByte = newPdata[d + ((0x5A + 1) * 2048)]; } else { mapByte = newPdata[d + ((0x58 + 1) * 2048)]; } } sheetsData[d + ((sheetPos) * 2048)] = mapByte; d++; } else { sheetsData[d + (sheetPos * 2048)] = mapByte; d++; } } sheetPos++; } } ColorPalette cp = tiles16Bitmap.Palette; for (int i = 0; i < 256; i++) { cp.Entries[i] = map[mapid].palettes[i]; } tiles16Bitmap.Palette = cp; map[mapid].mapBitmap.Palette = cp; BuildTiles16Gfx(tiles8GfxPtr, tiles16GfxPtr); UpdateTilesMap(map[mapid].mapGfxPtr, mapid); }