mirror of
https://github.com/fadden/6502bench.git
synced 2025-02-27 04:29:04 +00:00
Fix Applesoft shape table visualizer
An edge case wasn't being handled correctly.
This commit is contained in:
parent
9784ad043e
commit
b1ca87e3c8
@ -25,28 +25,33 @@ namespace RuntimeData.Apple {
|
|||||||
/// limited to hi-res graphics. It's really just a list of vectors.
|
/// limited to hi-res graphics. It's really just a list of vectors.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// See the Applesoft BASIC Programming Reference Manual, pages 91-100, for a full
|
/// <para>See the Applesoft BASIC Programming Reference Manual, pages 91-100, for a full
|
||||||
/// description of the format.
|
/// description of the format.</para>
|
||||||
///
|
///
|
||||||
/// Table format:
|
/// <para>Table format:</para>
|
||||||
|
/// <code>
|
||||||
/// +00 number of shapes
|
/// +00 number of shapes
|
||||||
/// +01 (unused)
|
/// +01 (undefined)
|
||||||
/// +02/03 offset from start of table to first shape
|
/// +02/03 offset from start of table to first shape
|
||||||
/// +04/05 offset from start of table to second shape
|
/// +04/05 offset from start of table to second shape
|
||||||
/// ...
|
/// ...
|
||||||
/// +xx shape #1 data
|
/// +xx shape #1 data
|
||||||
/// +yy shape #2 data
|
/// +yy shape #2 data
|
||||||
|
/// </code>
|
||||||
///
|
///
|
||||||
/// Shape data is a series of bytes ending in $00. Each byte holds three vectors,
|
/// <para>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
|
/// 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
|
/// 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").</para>
|
||||||
|
/// <para>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.</para>
|
||||||
|
/// </remarks>
|
||||||
///
|
///
|
||||||
/// TODO: optionally render as it would on the hi-res screen. Some shapes draw with
|
/// 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.
|
/// HCOLOR=white but use alternating vertical lines to render multiple colors.
|
||||||
/// TODO: support ROT, using Applesoft-style ugly rotation handling. Could also support
|
/// 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.
|
/// SCALE but that's only interesting w.r.t. hi-res color changes.
|
||||||
/// </remarks>
|
|
||||||
public class VisShapeTable : MarshalByRefObject, IPlugin, IPlugin_Visualizer {
|
public class VisShapeTable : MarshalByRefObject, IPlugin, IPlugin_Visualizer {
|
||||||
// IPlugin
|
// IPlugin
|
||||||
public string Identifier {
|
public string Identifier {
|
||||||
@ -69,7 +74,7 @@ namespace RuntimeData.Apple {
|
|||||||
new VisParamDescr("File offset (hex)",
|
new VisParamDescr("File offset (hex)",
|
||||||
P_OFFSET, typeof(int), 0, 0x00ffffff, VisParamDescr.SpecialMode.Offset, 0),
|
P_OFFSET, typeof(int), 0, 0x00ffffff, VisParamDescr.SpecialMode.Offset, 0),
|
||||||
new VisParamDescr("Image index",
|
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 VisDescr(VIS_GEN_SHAPE_TABLE_SHAPE, "Apple II Shape Table Shape", VisDescr.VisType.Bitmap,
|
||||||
new VisParamDescr[] {
|
new VisParamDescr[] {
|
||||||
@ -190,14 +195,27 @@ namespace RuntimeData.Apple {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bits = val & 0x07;
|
// "If all the remaining sections of the byte contain only zeroes, then those
|
||||||
DrawVector(bits, false, ref xc, ref yc, ref xmin, ref xmax, ref ymin, ref ymax, vb);
|
// sections are ignored." We ignore C if it's zero, and if B and C are both zero
|
||||||
bits = (val >> 3) & 0x07;
|
// then both parts are ignored.
|
||||||
DrawVector(bits, false, ref xc, ref yc, ref xmin, ref xmax, ref ymin, ref ymax, vb);
|
int abits = val & 0x07;
|
||||||
bits = (val >> 6) & 0x03;
|
int bbits = (val >> 3) & 0x07;
|
||||||
DrawVector(bits, true, ref xc, ref yc, ref xmin, ref xmax, ref ymin, ref ymax, vb);
|
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;
|
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
|
/// min/max values are updated if a point is plotted -- no need to expand the bitmap
|
||||||
/// outside the range of actual plotted points.
|
/// outside the range of actual plotted points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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) {
|
ref int xmin, ref int xmax, ref int ymin, ref int ymax, VisBitmap8 vb) {
|
||||||
if ((bits & 0x04) != 0) {
|
if ((bits & 0x04) != 0) {
|
||||||
if (vb != null) {
|
if (vb != null) {
|
||||||
@ -228,12 +246,8 @@ namespace RuntimeData.Apple {
|
|||||||
}
|
}
|
||||||
switch (bits & 0x03) {
|
switch (bits & 0x03) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
if (isC) {
|
// move up
|
||||||
// do nothing
|
yc--;
|
||||||
} else {
|
|
||||||
// move up
|
|
||||||
yc--;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
// move right
|
// move right
|
||||||
|
@ -225,8 +225,15 @@ Neither has any effect on black & white bitmaps.</p>
|
|||||||
half-pixel shifts are not represented.</p>
|
half-pixel shifts are not represented.</p>
|
||||||
|
|
||||||
<p>The VisShapeTable script renders Applesoft shape tables, which can
|
<p>The VisShapeTable script renders Applesoft shape tables, which can
|
||||||
have multiple vector shapes. The only parameter other than the offset
|
have multiple vector shapes. There are two generators:</p>
|
||||||
is the shape number.</p>
|
<ul>
|
||||||
|
<li><b>Shape Table</b> - full table. Set the offset to the first
|
||||||
|
byte of the table, and set the image index to the desired shape
|
||||||
|
index. (Note: indices here start at zero, but in Applesoft programs
|
||||||
|
they start at 1.)</li>
|
||||||
|
<li><b>Shape Table Shape</b> - single shape. Set the offset to the
|
||||||
|
first byte of the shape definition.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
<h3>Atari 2600 : Atari/Vis2600</h3>
|
<h3>Atari 2600 : Atari/Vis2600</h3>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user