2018-09-28 17:05:11 +00:00
|
|
|
|
/*
|
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
# inline_entry equ $e100a8
|
|
|
|
|
# jsl inline_entry
|
|
|
|
|
# dc i2'callnum'
|
|
|
|
|
# dc i4'parmblock'
|
|
|
|
|
# bcs error
|
|
|
|
|
|
|
|
|
|
# stack_entry equ $e100b0
|
|
|
|
|
# pea parmblock|-16
|
|
|
|
|
# pea parmblock
|
|
|
|
|
# pea callnum
|
|
|
|
|
# jsl stack_entry
|
|
|
|
|
# bcs error
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace RuntimeData.Apple {
|
2019-10-14 01:19:28 +00:00
|
|
|
|
public class GSOS : MarshalByRefObject, IPlugin, IPlugin_SymbolList, IPlugin_InlineJsl {
|
2018-09-28 17:05:11 +00:00
|
|
|
|
private const string GSOS_FUNC_TAG = "AppleIIgs-GSOS-Functions"; // tag used in .sym65 file
|
|
|
|
|
private bool VERBOSE = false;
|
|
|
|
|
|
|
|
|
|
private IApplication mAppRef;
|
|
|
|
|
private byte[] mFileData;
|
2019-10-04 23:53:31 +00:00
|
|
|
|
private Dictionary<int, PlSymbol> mFunctionList;
|
2018-09-28 17:05:11 +00:00
|
|
|
|
|
|
|
|
|
public string Identifier {
|
|
|
|
|
get {
|
|
|
|
|
return "Apple IIgs GS/OS call handler";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 01:19:28 +00:00
|
|
|
|
public void Prepare(IApplication appRef, byte[] fileData, AddressTranslate addrTrans) {
|
2018-09-28 17:05:11 +00:00
|
|
|
|
mAppRef = appRef;
|
|
|
|
|
mFileData = fileData;
|
|
|
|
|
|
|
|
|
|
mAppRef.DebugLog("GSOS(id=" + AppDomain.CurrentDomain.Id + "): prepare()");
|
|
|
|
|
//System.Diagnostics.Debugger.Break();
|
2019-12-01 01:52:33 +00:00
|
|
|
|
}
|
2018-09-28 17:05:11 +00:00
|
|
|
|
|
2019-12-01 01:52:33 +00:00
|
|
|
|
public void Unprepare() {
|
|
|
|
|
mAppRef = null;
|
|
|
|
|
mFileData = null;
|
2019-10-14 01:19:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateSymbolList(List<PlSymbol> plSyms) {
|
|
|
|
|
// Extract the list of function name constants from the platform symbol file.
|
|
|
|
|
mFunctionList = PlSymbol.GeneratePlatformValueList(plSyms, GSOS_FUNC_TAG, mAppRef);
|
|
|
|
|
}
|
|
|
|
|
public bool IsLabelSignificant(string beforeLabel, string afterLabel) {
|
|
|
|
|
return false;
|
2018-09-28 17:05:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 20:15:25 +00:00
|
|
|
|
public void CheckJsl(int offset, int operand, out bool noContinue) {
|
|
|
|
|
const int INLINE_ENTRY = 0xe100a8;
|
|
|
|
|
|
2018-09-28 17:05:11 +00:00
|
|
|
|
noContinue = false;
|
2019-10-17 20:15:25 +00:00
|
|
|
|
if (offset + 7 < mFileData.Length && operand == INLINE_ENTRY) {
|
2018-09-28 17:05:11 +00:00
|
|
|
|
// match!
|
|
|
|
|
|
|
|
|
|
int req = Util.GetWord(mFileData, offset + 4, 2, false);
|
|
|
|
|
if (VERBOSE) {
|
|
|
|
|
int addr = Util.GetWord(mFileData, offset + 6, 4, false);
|
|
|
|
|
mAppRef.DebugLog("GSOS call detected at +" + offset.ToString("x6") +
|
|
|
|
|
", cmd=$" + req.ToString("x4") + " addr=$" + addr.ToString("x6"));
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-04 23:53:31 +00:00
|
|
|
|
PlSymbol sym;
|
2018-09-28 17:05:11 +00:00
|
|
|
|
if (mFunctionList.TryGetValue(req, out sym)) {
|
|
|
|
|
mAppRef.SetInlineDataFormat(offset + 4, 2, DataType.NumericLE,
|
|
|
|
|
DataSubType.Symbol, sym.Label);
|
|
|
|
|
} else {
|
|
|
|
|
mAppRef.SetInlineDataFormat(offset + 4, 2, DataType.NumericLE,
|
|
|
|
|
DataSubType.None, null);
|
|
|
|
|
}
|
|
|
|
|
mAppRef.SetInlineDataFormat(offset + 6, 4, DataType.NumericLE,
|
|
|
|
|
DataSubType.Address, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|