1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-09-25 03:27:01 +00:00

Add inline string script sample

Also, updated LZ4FH sample, which needed to have explicit widths on
a couple of zero-page pointers.

Also, updated Zippy sample, which had a ton of unnecessary format
entries for a couple of pointers.
This commit is contained in:
Andy McFadden
2019-10-08 10:44:49 -07:00
parent 86c4331cce
commit b5d1881cf0
8 changed files with 213 additions and 181 deletions

View File

@@ -0,0 +1,69 @@
// Copyright 2019 faddenSoft. All Rights Reserved.
// See the LICENSE.txt file for distribution terms (Apache 2.0).
using System;
using System.Collections.Generic;
using PluginCommon;
namespace ExtensionScriptSample {
/// <summary>
/// Sample class for handling a JSR followed by an inline null-terminated string.
/// </summary>
public class InlineNullStringHandler : MarshalByRefObject, IPlugin, IPlugin_InlineJsr {
private IApplication mAppRef;
private byte[] mFileData;
private int mInlineNullStringAddr; // jsr
public string Identifier {
get {
return "Inline null-terminated ASCII string handler";
}
}
public void Prepare(IApplication appRef, byte[] fileData, AddressTranslate addrTrans,
List<PlSymbol> plSyms) {
mAppRef = appRef;
mFileData = fileData;
mAppRef.DebugLog("InlineNullStringHandler(id=" +
AppDomain.CurrentDomain.Id + "): prepare()");
// reset this every time, in case they remove the label
mInlineNullStringAddr = -1;
foreach (PlSymbol sym in plSyms) {
if (sym.Label == "PrintInlineZString") {
mInlineNullStringAddr = sym.Value;
break;
}
}
mAppRef.DebugLog("PrintInlineZString @ $" + mInlineNullStringAddr.ToString("x6"));
}
public void CheckJsr(int offset, out bool noContinue) {
noContinue = false;
int target = Util.GetWord(mFileData, offset + 1, 2, false);
if (target == mInlineNullStringAddr) {
// search for the terminating null byte
int nullOff = offset + 3;
while (nullOff < mFileData.Length) {
if (mFileData[nullOff] == 0) {
break;
}
nullOff++;
}
if (nullOff == mFileData.Length) {
mAppRef.DebugLog("Unable to find end of null-terminated string at +" +
(offset+3).ToString("x6"));
return;
}
// Assuming ASCII. This can be hard-coded, use auto-detection, or look
// up a value in a project constant.
mAppRef.SetInlineDataFormat(offset + 3, nullOff - (offset + 3) + 1,
DataType.StringNullTerm, DataSubType.Ascii, null);
}
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,8 @@
org $1000
jsr PrintInlineZString
asc 'Testing',00
rts
PrintInlineZString
rts

View File

@@ -0,0 +1,24 @@
### 6502bench SourceGen dis65 v1.0 ###
{
"_ContentVersion":2,"FileDataLength":13,"FileDataCrc32":205674068,"ProjectProps":{
"CpuName":"65816","IncludeUndocumentedInstr":false,"EntryFlags":32702671,"AutoLabelStyle":"Simple","AnalysisParams":{
"AnalyzeUncategorizedData":true,"DefaultTextScanMode":"LowHighAscii","MinCharsForString":4,"SeekNearbyTargets":true,"SmartPlpHandling":true},
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":["PROJ:InlineNullTerm.cs"],"ProjectSyms":{
}},
"AddressMap":[{
"Offset":0,"Addr":4096}],"TypeHints":[{
"Low":0,"High":0,"Hint":"Code"}],"StatusFlagOverrides":{
},
"Comments":{
},
"LongComments":{
},
"Notes":{
},
"UserLabels":{
"12":{
"Label":"PrintInlineZString","Value":4108,"Source":"User","Type":"LocalOrGlobalAddr"}},
"OperandFormats":{
},
"LvTables":{
}}