Allow scripts to handle COP and WDM inlines

The code that allows scripts to catch and handle BRK/JSR/JSL followed
by inline data now also handles COP and WDM.

(issue #177)
This commit is contained in:
Andy McFadden committed 2025-11-30 14:59:39 -08:00
1 parent 5a3d288707
commit 037b982d94
11 files changed
+154 -15

No files matched your search

@@ -0,0 +1,63 @@
// Copyright 2025 faddenSoft. All Rights Reserved.
// See the LICENSE.txt file for distribution terms (Apache 2.0).
using System;
using System.Collections.Generic;
using PluginCommon;
// COP/WDM handler
namespace RuntimeData.Test20180 {
public class Test20180C : MarshalByRefObject, IPlugin, IPlugin_InlineCop, IPlugin_InlineWdm {
private IApplication mAppRef;
private byte[] mFileData;
private AddressTranslate mAddrTrans;
public string Identifier {
get {
return "Test 20180-extension-scripts C";
}
}
public void Prepare(IApplication appRef, byte[] fileData, AddressTranslate addrTrans) {
mAppRef = appRef;
mFileData = fileData;
mAddrTrans = addrTrans;
mAppRef.DebugLog("Test20180-C(id=" + AppDomain.CurrentDomain.Id + "): prepare()");
}
public void Unprepare() {
mAppRef = null;
mFileData = null;
mAddrTrans = null;
}
public void CheckCop(int offset, out bool noContinue) {
HandleString(offset, out noContinue);
}
public void CheckWdm(int offset, out bool noContinue) {
HandleString(offset, out noContinue);
}
private void HandleString(int offset, out bool noContinue) {
const int INSTR_LEN = 2; // opcode + byte
noContinue = false;
// Handle as string with 8-bit length prefix.
if (offset + INSTR_LEN >= mFileData.Length) {
return; // length byte is off end
}
int len = mFileData[offset + INSTR_LEN];
if (offset + INSTR_LEN + 1 + len > mFileData.Length) {
// ran off the end
mAppRef.DebugLog("L1 string ran off end of file at +" +
(offset + INSTR_LEN).ToString("x6"));
return;
}
mAppRef.SetInlineDataFormat(offset + INSTR_LEN, len + 1,
DataType.StringL8, DataSubType.Ascii, null);
}
}
}
Binary file not shown.
@@ -2,7 +2,7 @@
{
"_ContentVersion":7,
"FileDataLength":544,
"FileDataCrc32":1948144462,
"FileDataCrc32":371480162,
"ProjectProps":{
"CpuName":"65816",
"IncludeUndocumentedInstr":false,
@@ -20,7 +20,8 @@
"PlatformSymbolFileIdentifiers":["PROJ:20182-extension-scripts.sym65"],
"ExtensionScriptFileIdentifiers":["PROJ:20180-extension-scripts-a.cs",
"PROJ:20180-extension-scripts-b.cs"],
"PROJ:20180-extension-scripts-b.cs",
"PROJ:20180-extension-scripts-c.cs"],
"ProjectSyms":{
"PrintInlineDciString":{
"DataDescriptor":{
@@ -74,9 +74,14 @@ Next clc
.byte $00
.byte $80
_L10B8 rts
_L10B8 cop #$03
.enc "sg_ascii"
.ptext "COP!"
.byte $42,$04
.ptext "WDM!"
rts
.fill 327,$00
.fill 313,$00
.logical $1800
L1800 jsr PrintInlineNullString
@@ -89,7 +94,6 @@ L1800 jsr PrintInlineNullString
.byte $01
.here
.logical $1840
.enc "sg_ascii"
.text "string"
.byte $00
.byte $60
@@ -68,9 +68,13 @@ Next clc
!byte $00
!byte $80
@L10B8 rts
@L10B8 cop $03
!text $04,"COP!"
!byte $42,$04
!text $04,"WDM!"
rts
!fill 327,$00
!fill 313,$00
!pseudopc $1800 {
L1800 jsr PrintInlineNullString
@@ -71,9 +71,13 @@ Next: clc
.byte $00
.byte $80
@L10B8: rts
@L10B8: cop $03
.byte $04,"COP!"
wdm $04
.byte $04,"WDM!"
rts
.res 327,$00
.res 313,$00
.org $1800
L1800: jsr PrintInlineNullString
@@ -63,9 +63,13 @@ Next clc
dfb $00
dfb $80
:L10B8 rts
:L10B8 cop $03
str 'COP!'
wdm $04
str 'WDM!'
rts
ds 327
ds 313
org $1800
L1800 jsr PrintInlineNullString
@@ -10,7 +10,7 @@
; check basics
jsr PrintInline8String
asc '01234567'
asc '01234567' ;hard-coded to 8 bytes long
jsr PrintInlineRev8String
asc '76543210'
jsr PrintInlineNullString
@@ -18,7 +18,7 @@ PrintInlineDciString equ $013000 ;EDIT: add to project symbols
; check basics
jsr PrintInline8String
asc '01234567'
asc '01234567' ;hard-coded to 8 bytes long
jsr PrintInlineRev8String
asc '76543210'
jsr PrintInlineNullString
@@ -81,6 +81,12 @@ Next
brk $80
:BrkNext
; test COP and WDM
cop $03
str 'COP!'
wdm $04
str 'WDM!'
rts