diff --git a/PluginCommon/VisBitmap8.cs b/PluginCommon/VisBitmap8.cs index 4645e7f..3f7d9c2 100644 --- a/PluginCommon/VisBitmap8.cs +++ b/PluginCommon/VisBitmap8.cs @@ -14,9 +14,7 @@ * limitations under the License. */ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Text; namespace PluginCommon { /// @@ -34,7 +32,7 @@ namespace PluginCommon { private byte[] mData; private int[] mPalette; - private int mNextColor; + private int mNextColorIdx; /// @@ -52,7 +50,7 @@ namespace PluginCommon { mData = new byte[width * height]; mPalette = new int[256]; - mNextColor = 0; + mNextColorIdx = 0; } public int GetPixel(int x, int y) { @@ -60,22 +58,32 @@ namespace PluginCommon { return mPalette[pix]; } + /// + /// Sets the color for a single pixel. + /// + /// X coordinate. + /// Y coordinate. + /// Color index. public void SetPixelIndex(int x, int y, byte colorIndex) { if (x < 0 || x >= Width || y < 0 || y >= Height) { throw new ArgumentException("Bad x/y: " + x + "," + y + " (width=" + Width + " height=" + Height + ")"); } - if (colorIndex < 0 || colorIndex >= mNextColor) { + if (colorIndex < 0 || colorIndex >= mNextColorIdx) { throw new ArgumentException("Bad color: " + colorIndex + " (nextCol=" + - mNextColor + ")"); + mNextColorIdx + ")"); } mData[x + y * Width] = colorIndex; } + /// + /// Sets the color for all pixels. + /// + /// Color index. public void SetAllPixelIndices(byte colorIndex) { - if (colorIndex < 0 || colorIndex >= mNextColor) { + if (colorIndex < 0 || colorIndex >= mNextColorIdx) { throw new ArgumentException("Bad color: " + colorIndex + " (nextCol=" + - mNextColor + ")"); + mNextColorIdx + ")"); } for (int i = 0; i < mData.Length; i++) { mData[i] = colorIndex; @@ -89,8 +97,8 @@ namespace PluginCommon { // IVisualization2d public int[] GetPalette() { - int[] pal = new int[mNextColor]; - for (int i = 0; i < mNextColor; i++) { + int[] pal = new int[mNextColorIdx]; + for (int i = 0; i < mNextColorIdx; i++) { pal[i] = mPalette[i]; } return pal; @@ -103,18 +111,19 @@ namespace PluginCommon { /// /// 32-bit ARGB color value. public void AddColor(int color) { - if (mNextColor == 256) { + if (mNextColorIdx == 256) { Debug.WriteLine("Palette is full"); return; } - for (int i = 0; i < mNextColor; i++) { + // I'm expecting palettes to only have a few colors, so O(n^2) is fine for now. + for (int i = 0; i < mNextColorIdx; i++) { if (mPalette[i] == color) { Debug.WriteLine("Color " + color.ToString("x6") + " already exists in palette (" + i + ")"); return; } } - mPalette[mNextColor++] = color; + mPalette[mNextColorIdx++] = color; } /// diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index dc2b0fa..ab4aa30 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -3623,7 +3623,6 @@ namespace SourceGen { } break; case LineListGen.Line.Type.VisualizationSet: - // TODO(xyzzy) lineTypeStr = "visualization set"; break; default: diff --git a/SourceGen/RuntimeData/Apple/VisHiRes.cs b/SourceGen/RuntimeData/Apple/VisHiRes.cs index 8a7f6a7..2c20e57 100644 --- a/SourceGen/RuntimeData/Apple/VisHiRes.cs +++ b/SourceGen/RuntimeData/Apple/VisHiRes.cs @@ -14,9 +14,7 @@ * limitations under the License. */ using System; -using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Text; using PluginCommon; @@ -303,6 +301,24 @@ namespace RuntimeData.Apple { private enum ColorMode { Mono, SimpleColor, IIgsRGB }; + /// + /// Renders bitmap data. + /// + /// Data source, typically the file data. + /// Offset into data of the first byte. + /// Width, in bytes, of the data to render. Each byte + /// represents 7 pixels in the output (more or less). + /// Height, in lines, of the data to render. + /// Column stride. The number of bytes used to hold each + /// byte of data. Must be >= 1. + /// Row stride. The number of bytes used to hold each row + /// of data. Must be >= (colStride * byteWidth - (colStride - 1)). + /// Color conversion mode. + /// If true, render as if we're starting on an odd column. + /// This affects the colors. + /// Output bitmap object. + /// Initial X position in the output. + /// Initial Y position in the output. private void RenderBitmap(byte[] data, int offset, int byteWidth, int height, int colStride, int rowStride, ColorMode colorMode, bool isFirstOdd, VisBitmap8 vb, int xstart, int ystart) { @@ -505,11 +521,6 @@ namespace RuntimeData.Apple { White1 = 2 } - // Maps HiResColors to the palette entries. Used for mapping 2-bit values to colors. - private static readonly byte[] sHiResColorMap = new byte[8] { - 1, 3, 4, 2, 1, 5, 6, 2 - }; - private void SetHiResPalette(VisBitmap8 vb) { // These don't match directly to hi-res color numbers because we want to // avoid adding black/white twice. The colors correspond to Apple IIgs RGB diff --git a/SourceGen/RuntimeData/Atari/VisAtari2600.cs b/SourceGen/RuntimeData/Atari/Vis2600.cs similarity index 98% rename from SourceGen/RuntimeData/Atari/VisAtari2600.cs rename to SourceGen/RuntimeData/Atari/Vis2600.cs index 09ad412..77210ca 100644 --- a/SourceGen/RuntimeData/Atari/VisAtari2600.cs +++ b/SourceGen/RuntimeData/Atari/Vis2600.cs @@ -14,14 +14,12 @@ * limitations under the License. */ using System; -using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Text; using PluginCommon; namespace RuntimeData.Atari { - public class VisAtari2600 : MarshalByRefObject, IPlugin, IPlugin_Visualizer { + public class Vis2600 : MarshalByRefObject, IPlugin, IPlugin_Visualizer { // IPlugin public string Identifier { get { return "Atari 2600 Graphic Visualizer"; } diff --git a/SourceGen/RuntimeData/Commodore/VisC64.cs b/SourceGen/RuntimeData/Commodore/VisC64.cs index 4fb8c84..260d33b 100644 --- a/SourceGen/RuntimeData/Commodore/VisC64.cs +++ b/SourceGen/RuntimeData/Commodore/VisC64.cs @@ -14,9 +14,7 @@ * limitations under the License. */ using System; -using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Text; using PluginCommon; diff --git a/SourceGen/RuntimeData/Help/visualization.html b/SourceGen/RuntimeData/Help/visualization.html index e9fcd26..c084789 100644 --- a/SourceGen/RuntimeData/Help/visualization.html +++ b/SourceGen/RuntimeData/Help/visualization.html @@ -40,8 +40,12 @@ e.g. it's in the middle of a multi-byte instruction or data item. The editors will try to prevent you from doing this.

Bitmaps will always be scaled up as much as possible to make them easy to see. This means that small shapes and large shapes may appears -to be the same size. Bear in mind that this is a disassembler, not a -graphics conversion tool.

+to be the same size when displayed as thumbnails in the code list.

+

The role of a visualization generator is to take a collection of input +parameters and generate graphical data. It's most useful for graphical +sources like bitmaps, but it's not limited to that. You could, for example, +write a script that generates random flowers, and use it to make your +source listings more cheerful.

Visualizations and Visualization Sets

@@ -52,8 +56,8 @@ contained in sets that are placed at arbitrary offsets. Each set can contain multiple items. For example, if a file has data for 10 bitmaps, you can place a visualization near each, or create a single visualization set with all 10 items and put it at the start of the file. -You can display a visualization near the instructions that perform the -drawing.

+You can display a visualization near the data or near the instructions +that perform the drawing. Or both.

To create a visualization set, select a code or data line, and use Actions > Create/Edit Visualization Set. To edit a visualization set, @@ -112,6 +116,11 @@ Some less-common parameters include:

visualizer will default to no interleave (stride == 1). +

Remember that this is a disassembler, not an image converter. The +results do not need to be perfectly accurate to be useful when disassembling +code.

+ +

Apple II - Apple/VisHiRes

There is no standard format for small hi-res bitmaps, but certain @@ -143,11 +152,13 @@ but has no effect on black or white.

The converter generates one output pixel for every source pixel, so half-pixel shifts are not rendered.

-

Atari 2600 - Atari/VisAtari2600

+

Atari 2600 - Atari/Vis2600

The Atari 2600 graphics system has registers that determine the -appearance of a sprite or playfield on a single row. The visualization -generator works for data stored in a straightforward fashion.

+appearance of a sprite or playfield on a single row. The register +values are typically changed as the screen is drawn to get different +data on successive rows. The visualization generator works for data +stored in a straightforward fashion.