mirror of
https://github.com/fadden/6502bench.git
synced 2024-12-01 22:50:35 +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.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the Applesoft BASIC Programming Reference Manual, pages 91-100, for a full
|
||||
/// description of the format.
|
||||
/// <para>See the Applesoft BASIC Programming Reference Manual, pages 91-100, for a full
|
||||
/// description of the format.</para>
|
||||
///
|
||||
/// Table format:
|
||||
/// <para>Table format:</para>
|
||||
/// <code>
|
||||
/// +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
|
||||
/// </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
|
||||
/// 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
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
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.
|
||||
/// </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) {
|
||||
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
|
||||
|
@ -225,8 +225,15 @@ Neither has any effect on black & white bitmaps.</p>
|
||||
half-pixel shifts are not represented.</p>
|
||||
|
||||
<p>The VisShapeTable script renders Applesoft shape tables, which can
|
||||
have multiple vector shapes. The only parameter other than the offset
|
||||
is the shape number.</p>
|
||||
have multiple vector shapes. There are two generators:</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>
|
||||
|
Loading…
Reference in New Issue
Block a user