1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-12-10 21:49:27 +00:00
6502bench/SourceGen/RuntimeData/Apple/IIgs-Toolbox.cs
Andy McFadden 365864ccdf More progress on visualization
Implemented Apple II hi-res bitmap conversion.  Supports B&W and
color.  Uses essentially the same algorithm as CiderPress.

Experimented with displaying non-text items in ListView.  I assumed
it would work, since it's the sort of thing WPF is designed to do,
but it's always wise to approach with caution.  Visualization Sets
now show a 64x64 button as a placeholder for the eventual thumbnail.

Some things were being flaky, which turned out to be because I
wasn't Prepare()ing the plugins before using them from Edit
Visualization.  To make this a deterministic failure I added an
Unprepare() call that tells the plugin that we're all done.

NOTE: this breaks all existing plugins.
2019-11-30 18:02:03 -08:00

89 lines
2.9 KiB
C#

/*
* Copyright 2018 faddenSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using PluginCommon;
/*
# pea ...
# pea ...
# ldx #function
# jsl $e10000
*/
namespace RuntimeData.Apple {
public class IIgsToolbox : MarshalByRefObject, IPlugin, IPlugin_SymbolList, IPlugin_InlineJsl {
private const string TOOLBOX_FUNC_TAG = "AppleIIgs-Toolbox-Functions"; // tag used in .sym65 file
private bool VERBOSE = false;
private IApplication mAppRef;
private byte[] mFileData;
private Dictionary<int, PlSymbol> mFunctionList;
public string Identifier {
get {
return "Apple IIgs toolbox call handler";
}
}
public void Prepare(IApplication appRef, byte[] fileData, AddressTranslate addrTrans) {
mAppRef = appRef;
mFileData = fileData;
mAppRef.DebugLog("IIgsToolbox(id=" + AppDomain.CurrentDomain.Id + "): prepare()");
}
public void Unprepare() {
mAppRef = null;
mFileData = null;
}
public void UpdateSymbolList(List<PlSymbol> plSyms) {
// Extract the list of function name constants from the platform symbol file.
mFunctionList = PlSymbol.GeneratePlatformValueList(plSyms, TOOLBOX_FUNC_TAG, mAppRef);
}
public bool IsLabelSignificant(string beforeLabel, string afterLabel) {
return false;
}
public void CheckJsl(int offset, int operand, out bool noContinue) {
const int TOOLBOX = 0xe10000;
noContinue = false;
if (offset < 3) {
return;
}
// This only works if the LDX with the function comes right before the JSL.
// Fortunately, the assembler macros all work that way.
if (operand == TOOLBOX && mFileData[offset - 3] == 0xa2 /*LDX imm*/) {
// match!
int func = Util.GetWord(mFileData, offset - 2, 2, false);
if (VERBOSE) {
mAppRef.DebugLog("Toolbox call detected at +" + offset.ToString("x6") +
", func=$" + func.ToString("x4"));
}
PlSymbol sym;
if (mFunctionList.TryGetValue(func, out sym)) {
mAppRef.SetOperandFormat(offset - 3, DataSubType.Symbol, sym.Label);
}
}
}
}
}