diff --git a/SourceGen/RuntimeData/Apple/VisShapeTable.cs b/SourceGen/RuntimeData/Apple/VisShapeTable.cs index e59043e..3c8c7be 100644 --- a/SourceGen/RuntimeData/Apple/VisShapeTable.cs +++ b/SourceGen/RuntimeData/Apple/VisShapeTable.cs @@ -25,28 +25,33 @@ namespace RuntimeData.Apple { /// limited to hi-res graphics. It's really just a list of vectors. /// /// - /// See the Applesoft BASIC Programming Reference Manual, pages 91-100, for a full - /// description of the format. + /// See the Applesoft BASIC Programming Reference Manual, pages 91-100, for a full + /// description of the format. /// - /// Table format: + /// Table format: + /// /// +00 number of shapes - /// +01 (unused) + /// +01 (undefined) /// +02/03 offset from start of table to first shape /// +04/05 offset from start of table to second shape /// ... /// +xx shape #1 data /// +yy shape #2 data + /// /// - /// Shape data is a series of bytes ending in $00. Each byte holds three vectors, + /// Shape data is a series of bytes ending in $00. Each byte holds three vectors, /// CCBBBAAA. AAA and BBB specify a direction (up/right/down/left) and whether or /// not to plot a point. CC cannot specify whether to plot and cannot move up (a 00 - /// in CC means "do nothing"). + /// in CC means "do nothing"). + /// The shape indices should start at 1, as is done in Applesoft, but an earlier + /// version of this visualizer started at 0. So we're stuck with it in the name of + /// backward compatibility. + /// /// /// TODO: optionally render as it would on the hi-res screen. Some shapes draw with /// HCOLOR=white but use alternating vertical lines to render multiple colors. /// TODO: support ROT, using Applesoft-style ugly rotation handling. Could also support /// SCALE but that's only interesting w.r.t. hi-res color changes. - /// public class VisShapeTable : MarshalByRefObject, IPlugin, IPlugin_Visualizer { // IPlugin public string Identifier { @@ -69,7 +74,7 @@ namespace RuntimeData.Apple { new VisParamDescr("File offset (hex)", P_OFFSET, typeof(int), 0, 0x00ffffff, VisParamDescr.SpecialMode.Offset, 0), new VisParamDescr("Image index", - P_INDEX, typeof(int), 0, 256, 0, 0), + P_INDEX, typeof(int), 0, 255, 0, 0), }), new VisDescr(VIS_GEN_SHAPE_TABLE_SHAPE, "Apple II Shape Table Shape", VisDescr.VisType.Bitmap, new VisParamDescr[] { @@ -190,14 +195,27 @@ namespace RuntimeData.Apple { break; } - int bits = val & 0x07; - DrawVector(bits, false, ref xc, ref yc, ref xmin, ref xmax, ref ymin, ref ymax, vb); - bits = (val >> 3) & 0x07; - DrawVector(bits, false, ref xc, ref yc, ref xmin, ref xmax, ref ymin, ref ymax, vb); - bits = (val >> 6) & 0x03; - DrawVector(bits, true, ref xc, ref yc, ref xmin, ref xmax, ref ymin, ref ymax, vb); + // "If all the remaining sections of the byte contain only zeroes, then those + // sections are ignored." We ignore C if it's zero, and if B and C are both zero + // then both parts are ignored. + int abits = val & 0x07; + int bbits = (val >> 3) & 0x07; + int cbits = val >> 6; + + DrawVector(abits, ref xc, ref yc, ref xmin, ref xmax, ref ymin, ref ymax, vb); + if (bbits != 0 || cbits != 0) { + DrawVector(bbits, ref xc, ref yc, ref xmin, ref xmax, ref ymin, ref ymax, vb); + } + if (cbits != 0) { + DrawVector(cbits, ref xc, ref yc, ref xmin, ref xmax, ref ymin, ref ymax, vb); + } } + // Return true if we actually plotted something. + if (xmax < 0 || ymax < 0) { + mAppRef.ReportError("Shape definition doesn't draw anything"); + return false; + } return true; } @@ -206,7 +224,7 @@ namespace RuntimeData.Apple { /// min/max values are updated if a point is plotted -- no need to expand the bitmap /// outside the range of actual plotted points. /// - private void DrawVector(int bits, bool isC, ref int xc, ref int yc, + private void DrawVector(int bits, ref int xc, ref int yc, ref int xmin, ref int xmax, ref int ymin, ref int ymax, VisBitmap8 vb) { if ((bits & 0x04) != 0) { if (vb != null) { @@ -228,12 +246,8 @@ namespace RuntimeData.Apple { } switch (bits & 0x03) { case 0x00: - if (isC) { - // do nothing - } else { - // move up - yc--; - } + // move up + yc--; break; case 0x01: // move right diff --git a/docs/sgmanual/visualization.html b/docs/sgmanual/visualization.html index 8929ee7..9aa72a2 100644 --- a/docs/sgmanual/visualization.html +++ b/docs/sgmanual/visualization.html @@ -225,8 +225,15 @@ Neither has any effect on black & white bitmaps.

half-pixel shifts are not represented.

The VisShapeTable script renders Applesoft shape tables, which can -have multiple vector shapes. The only parameter other than the offset -is the shape number.

+have multiple vector shapes. There are two generators:

+

Atari 2600 : Atari/Vis2600