mirror of
https://github.com/fadden/6502bench.git
synced 2025-01-19 08:29:48 +00:00
Fix lastOffset calculations in Apple II hi-res visualizer
The calculations were wrong for certain situations, generating answers that were useless or that caused a false-positive overflow error. This adds a couple of simple regression tests, modeled after layout of the Lode Runner sprite sheet (which worked fine before) and the Empire II EWS3 font (which failed). This also bumps up some of the arbitrary limits in the visualizer. (issue #94)
This commit is contained in:
parent
b415424368
commit
33ccdd91eb
@ -23,6 +23,8 @@ namespace CommonUtil {
|
||||
/// so glyphs can be packed tightly.
|
||||
/// </summary>
|
||||
public static class Font8x8 {
|
||||
private static List<int[]> sBitData;
|
||||
|
||||
/// <summary>
|
||||
/// Returns an 8-byte array for the specified character. Each byte represents one
|
||||
/// row. The first byte holds the top row, and the most significant bit in each
|
||||
@ -41,6 +43,11 @@ namespace CommonUtil {
|
||||
return sBitData[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps a character value to an index into sFontData.
|
||||
/// </summary>
|
||||
/// <param name="ch">Character to find.</param>
|
||||
/// <returns>Index of character's glyph, or index of REPLACEMENT CHARACTER.</returns>
|
||||
private static int MapChar(char ch) {
|
||||
if (ch == ' ') {
|
||||
return 1;
|
||||
@ -53,8 +60,6 @@ namespace CommonUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<int[]> sBitData;
|
||||
|
||||
/// <summary>
|
||||
/// Converts the easy-to-edit string data into easy-to-process bitmaps.
|
||||
/// </summary>
|
||||
@ -170,7 +175,7 @@ namespace CommonUtil {
|
||||
"#.....#." +
|
||||
".#####.." +
|
||||
"........",
|
||||
// ' '
|
||||
// '7'
|
||||
"#######." +
|
||||
"......#." +
|
||||
".....#.." +
|
||||
@ -179,7 +184,7 @@ namespace CommonUtil {
|
||||
"..#....." +
|
||||
".#......" +
|
||||
"........",
|
||||
// ' '
|
||||
// '8'
|
||||
".#####.." +
|
||||
"#.....#." +
|
||||
"#.....#." +
|
||||
|
@ -64,9 +64,9 @@ namespace RuntimeData.Apple {
|
||||
new VisParamDescr("Height",
|
||||
P_HEIGHT, typeof(int), 1, 1024, 0, 1),
|
||||
new VisParamDescr("Column stride (bytes)",
|
||||
P_COL_STRIDE, typeof(int), 0, 1024, 0, 0),
|
||||
P_COL_STRIDE, typeof(int), 0, 4096, 0, 0),
|
||||
new VisParamDescr("Row stride (bytes)",
|
||||
P_ROW_STRIDE, typeof(int), 0, 1024, 0, 0),
|
||||
P_ROW_STRIDE, typeof(int), 0, 4096, 0, 0),
|
||||
new VisParamDescr("Color",
|
||||
P_IS_COLOR, typeof(bool), 0, 0, 0, true),
|
||||
new VisParamDescr("First col odd",
|
||||
@ -88,13 +88,13 @@ namespace RuntimeData.Apple {
|
||||
new VisParamDescr("Cell height",
|
||||
P_ITEM_HEIGHT, typeof(int), 1, 192, 0, 1),
|
||||
new VisParamDescr("Column stride (bytes)",
|
||||
P_COL_STRIDE, typeof(int), 0, 1024, 0, 0),
|
||||
P_COL_STRIDE, typeof(int), 0, 4096, 0, 0),
|
||||
new VisParamDescr("Row stride (bytes)",
|
||||
P_ROW_STRIDE, typeof(int), 0, 1024, 0, 0),
|
||||
P_ROW_STRIDE, typeof(int), 0, 4096, 0, 0),
|
||||
new VisParamDescr("Cell stride (bytes)",
|
||||
P_CELL_STRIDE, typeof(int), 0, 4096, 0, 0),
|
||||
new VisParamDescr("Number of items",
|
||||
P_COUNT, typeof(int), 1, 1024, 0, 64),
|
||||
P_COUNT, typeof(int), 1, 4096, 0, 64),
|
||||
new VisParamDescr("Color",
|
||||
P_IS_COLOR, typeof(bool), 0, 0, 0, true),
|
||||
new VisParamDescr("First col odd",
|
||||
@ -205,11 +205,14 @@ namespace RuntimeData.Apple {
|
||||
return null;
|
||||
}
|
||||
|
||||
int lastOffset = offset + rowStride * height - (colStride - 1) - 1;
|
||||
int lastOffset = offset + rowStride * (height - 1) +
|
||||
colStride * (byteWidth - 1);
|
||||
if (lastOffset >= mFileData.Length) {
|
||||
mAppRef.ReportError("Bitmap runs off end of file (last offset +" +
|
||||
lastOffset.ToString("x6") + ")");
|
||||
return null;
|
||||
//} else {
|
||||
// mAppRef.DebugLog("last offset=+" + lastOffset.ToString("x6"));
|
||||
}
|
||||
|
||||
VisBitmap8 vb = new VisBitmap8(byteWidth * 7, height);
|
||||
@ -283,11 +286,15 @@ namespace RuntimeData.Apple {
|
||||
}
|
||||
|
||||
int lastOffset = offset + (cellStride * (count - 1)) +
|
||||
rowStride * itemHeight - (colStride - 1) - 1;
|
||||
rowStride * (itemHeight - 1) +
|
||||
colStride * (itemByteWidth - 1);
|
||||
if (lastOffset >= mFileData.Length) {
|
||||
mAppRef.ReportError("Bitmap runs off end of file (last offset +" +
|
||||
lastOffset.ToString("x6") + ")");
|
||||
return null;
|
||||
//} else {
|
||||
// mAppRef.DebugLog("lastOffset=+" + lastOffset.ToString("x6") +
|
||||
// ", len=" + mFileData.Length.ToString("x6"));
|
||||
}
|
||||
|
||||
// Set the number of horizontal cells. For small counts we try to make it square,
|
||||
|
BIN
SourceGen/SGTestData/Visualization/apple2-grid-test1
Normal file
BIN
SourceGen/SGTestData/Visualization/apple2-grid-test1
Normal file
Binary file not shown.
89
SourceGen/SGTestData/Visualization/apple2-grid-test1.dis65
Normal file
89
SourceGen/SGTestData/Visualization/apple2-grid-test1.dis65
Normal file
@ -0,0 +1,89 @@
|
||||
### 6502bench SourceGen dis65 v1.0 ###
|
||||
{
|
||||
"_ContentVersion":4,
|
||||
"FileDataLength":40,
|
||||
"FileDataCrc32":-1890840498,
|
||||
"ProjectProps":{
|
||||
"CpuName":"65C02",
|
||||
"IncludeUndocumentedInstr":false,
|
||||
"TwoByteBrk":false,
|
||||
"EntryFlags":32702671,
|
||||
"AutoLabelStyle":"Simple",
|
||||
"AnalysisParams":{
|
||||
"AnalyzeUncategorizedData":true,
|
||||
"DefaultTextScanMode":"LowHighAscii",
|
||||
"MinCharsForString":4,
|
||||
"SeekNearbyTargets":true,
|
||||
"UseRelocData":false,
|
||||
"SmartPlpHandling":false,
|
||||
"SmartPlbHandling":true},
|
||||
|
||||
"PlatformSymbolFileIdentifiers":["RT:Apple/F8-ROM.sym65",
|
||||
"RT:Apple/Cxxx-IO.sym65",
|
||||
"RT:Apple/C08x-DiskII.sym65",
|
||||
"RT:Apple/ProDOS8.sym65"],
|
||||
"ExtensionScriptFileIdentifiers":["RT:Apple/ProDOS8.cs",
|
||||
"RT:Apple/VisHiRes.cs"],
|
||||
"ProjectSyms":{
|
||||
}},
|
||||
|
||||
"AddressMap":[{
|
||||
"Offset":0,
|
||||
"Addr":8192}],
|
||||
"TypeHints":[{
|
||||
"Low":0,
|
||||
"High":0,
|
||||
"Hint":"Code"}],
|
||||
"StatusFlagOverrides":{
|
||||
},
|
||||
|
||||
"Comments":{
|
||||
},
|
||||
|
||||
"LongComments":{
|
||||
"-2147483647":{
|
||||
"Text":"Grid with 5 1x8 bitmaps, with a large row stride.",
|
||||
"BoxMode":false,
|
||||
"MaxWidth":80,
|
||||
"BackgroundColor":0}},
|
||||
|
||||
"Notes":{
|
||||
},
|
||||
|
||||
"UserLabels":{
|
||||
},
|
||||
|
||||
"OperandFormats":{
|
||||
"0":{
|
||||
"Length":40,
|
||||
"Format":"Dense",
|
||||
"SubFormat":"None",
|
||||
"SymbolRef":null}},
|
||||
|
||||
"LvTables":{
|
||||
},
|
||||
|
||||
"Visualizations":[{
|
||||
"Tag":"vis000000",
|
||||
"VisGenIdent":"apple2-hi-res-bitmap-grid",
|
||||
"VisGenParams":{
|
||||
"offset":0,
|
||||
"itemByteWidth":1,
|
||||
"itemHeight":8,
|
||||
"colStride":0,
|
||||
"rowStride":5,
|
||||
"cellStride":1,
|
||||
"count":5,
|
||||
"isColor":true,
|
||||
"isFirstOdd":false,
|
||||
"isHighBitFlipped":false}}],
|
||||
"VisualizationAnimations":[],
|
||||
"VisualizationSets":{
|
||||
"0":{
|
||||
"Tags":["vis000000"]}},
|
||||
|
||||
"RelocList":{
|
||||
},
|
||||
|
||||
"DbrValues":{
|
||||
}}
|
BIN
SourceGen/SGTestData/Visualization/apple2-grid-test2
Normal file
BIN
SourceGen/SGTestData/Visualization/apple2-grid-test2
Normal file
Binary file not shown.
86
SourceGen/SGTestData/Visualization/apple2-grid-test2.dis65
Normal file
86
SourceGen/SGTestData/Visualization/apple2-grid-test2.dis65
Normal file
@ -0,0 +1,86 @@
|
||||
### 6502bench SourceGen dis65 v1.0 ###
|
||||
{
|
||||
"_ContentVersion":4,
|
||||
"FileDataLength":80,
|
||||
"FileDataCrc32":1433343667,
|
||||
"ProjectProps":{
|
||||
"CpuName":"65C02",
|
||||
"IncludeUndocumentedInstr":false,
|
||||
"TwoByteBrk":false,
|
||||
"EntryFlags":32702671,
|
||||
"AutoLabelStyle":"Simple",
|
||||
"AnalysisParams":{
|
||||
"AnalyzeUncategorizedData":true,
|
||||
"DefaultTextScanMode":"LowHighAscii",
|
||||
"MinCharsForString":4,
|
||||
"SeekNearbyTargets":true,
|
||||
"UseRelocData":false,
|
||||
"SmartPlpHandling":false,
|
||||
"SmartPlbHandling":true},
|
||||
|
||||
"PlatformSymbolFileIdentifiers":["RT:Apple/F8-ROM.sym65",
|
||||
"RT:Apple/Cxxx-IO.sym65",
|
||||
"RT:Apple/C08x-DiskII.sym65",
|
||||
"RT:Apple/ProDOS8.sym65"],
|
||||
"ExtensionScriptFileIdentifiers":["RT:Apple/ProDOS8.cs",
|
||||
"RT:Apple/VisHiRes.cs"],
|
||||
"ProjectSyms":{
|
||||
}},
|
||||
|
||||
"AddressMap":[{
|
||||
"Offset":0,
|
||||
"Addr":8192}],
|
||||
"TypeHints":[],
|
||||
"StatusFlagOverrides":{
|
||||
},
|
||||
|
||||
"Comments":{
|
||||
},
|
||||
|
||||
"LongComments":{
|
||||
"-2147483647":{
|
||||
"Text":"Lode Runner-style sprite sheet.",
|
||||
"BoxMode":false,
|
||||
"MaxWidth":80,
|
||||
"BackgroundColor":0}},
|
||||
|
||||
"Notes":{
|
||||
},
|
||||
|
||||
"UserLabels":{
|
||||
},
|
||||
|
||||
"OperandFormats":{
|
||||
"0":{
|
||||
"Length":80,
|
||||
"Format":"Dense",
|
||||
"SubFormat":"None",
|
||||
"SymbolRef":null}},
|
||||
|
||||
"LvTables":{
|
||||
},
|
||||
|
||||
"Visualizations":[{
|
||||
"Tag":"vis000000",
|
||||
"VisGenIdent":"apple2-hi-res-bitmap-grid",
|
||||
"VisGenParams":{
|
||||
"offset":0,
|
||||
"itemByteWidth":2,
|
||||
"itemHeight":8,
|
||||
"colStride":5,
|
||||
"rowStride":0,
|
||||
"cellStride":1,
|
||||
"count":5,
|
||||
"isColor":true,
|
||||
"isFirstOdd":false,
|
||||
"isHighBitFlipped":false}}],
|
||||
"VisualizationAnimations":[],
|
||||
"VisualizationSets":{
|
||||
"0":{
|
||||
"Tags":["vis000000"]}},
|
||||
|
||||
"RelocList":{
|
||||
},
|
||||
|
||||
"DbrValues":{
|
||||
}}
|
Loading…
x
Reference in New Issue
Block a user