This commit is contained in:
parent
feb4773c65
commit
366de77a2c
79
test/pch.h
79
test/pch.h
|
|
@ -40,6 +40,24 @@ static SqNewSlot* SQNewSlot = (SqNewSlot*)0x135AA80;
|
||||||
// 平栈
|
// 平栈
|
||||||
typedef int(SqPopTop)(uint32_t v);
|
typedef int(SqPopTop)(uint32_t v);
|
||||||
static SqPopTop* SQPopTop = (SqPopTop*)0x1358FF0;
|
static SqPopTop* SQPopTop = (SqPopTop*)0x1358FF0;
|
||||||
|
// 平栈
|
||||||
|
typedef int(SqPop)(uint32_t v, int n);
|
||||||
|
static SqPop* SQPop = (SqPop*)0x1358FD0;
|
||||||
|
//SQ_Get
|
||||||
|
typedef int(Sq_Get)(uint32_t v, int n);
|
||||||
|
static Sq_Get* SQ_Get = (Sq_Get*)0x135AE30;
|
||||||
|
//SQ_Rawget
|
||||||
|
typedef int(Sq_Rawget)(uint32_t v, int n);
|
||||||
|
static Sq_Rawget* SQ_Rawget = (Sq_Rawget*)0x135AEA0;
|
||||||
|
//SQ*Getlocal
|
||||||
|
typedef wchar_t* (SqGetlocal)(uint32_t v, int n, int idx);
|
||||||
|
static SqGetlocal* SQGetlocal = (SqGetlocal*)0x135AFD0;
|
||||||
|
//SQ_Wakeupvm
|
||||||
|
typedef int (Sq_Wakeupvm)(uint32_t v, int n, int retval, int raiseerror);
|
||||||
|
static Sq_Wakeupvm* SQ_Wakeupvm = (Sq_Wakeupvm*)0x135B0D0;
|
||||||
|
//SQ_Call
|
||||||
|
typedef int (Sq_Call)(uint32_t v, int params, int retval, int raiseerror);
|
||||||
|
static Sq_Call* SQ_Call = (Sq_Call*)0x1359280;
|
||||||
//GetInt
|
//GetInt
|
||||||
typedef int(SqGetIntFunc)(uint32_t v, uint32_t stackIndex, int* sint);
|
typedef int(SqGetIntFunc)(uint32_t v, uint32_t stackIndex, int* sint);
|
||||||
static SqGetIntFunc* SQGetInt = (SqGetIntFunc*)0x1358D70;
|
static SqGetIntFunc* SQGetInt = (SqGetIntFunc*)0x1358D70;
|
||||||
|
|
@ -86,32 +104,63 @@ void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v = NULL);
|
||||||
//注册Nut函数
|
//注册Nut函数
|
||||||
void RegisterNut();
|
void RegisterNut();
|
||||||
|
|
||||||
//新增Nut接口绑定C函数 返回值必须为 SQInteger
|
//新增Nut接口绑定C函数
|
||||||
// 示例如下
|
// 示例如下
|
||||||
/*
|
/*
|
||||||
static SQInteger math_abs(HSQUIRRELVM v)
|
static int GoDungeon(uint32_t v)
|
||||||
{
|
{
|
||||||
SQInteger n;
|
int n1 = 0;
|
||||||
const SQChar* str;
|
int n2 = 0;
|
||||||
|
int n3 = 0;
|
||||||
|
int n4 = 0;
|
||||||
|
|
||||||
//获取nut脚本传来的第一个参数, 索引为2
|
int num;
|
||||||
//索引为1的参数是this指针
|
num = SQGetTop(v);
|
||||||
//sq_getinteger(v, 2, &n);
|
|
||||||
|
|
||||||
//获取字符串
|
if (num == 2)
|
||||||
//sq_getstring(v, 2, &str);
|
{
|
||||||
|
SQGetInt(v, 2, &n1);
|
||||||
|
}
|
||||||
|
else if (num == 5)
|
||||||
|
{
|
||||||
|
SQGetInt(v, 2, &n1);
|
||||||
|
SQGetInt(v, 3, &n2);
|
||||||
|
SQGetInt(v, 4, &n3);
|
||||||
|
SQGetInt(v, 5, &n4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SQPushBool(v, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_SendpacksType(*_SendClass, 0, 15);
|
||||||
|
_SendPacks();
|
||||||
|
|
||||||
//返回一个整数给nut脚本
|
_SendpacksType(*_SendClass, 0, 16);
|
||||||
//sq_pushinteger(v, (SQInteger)(n));
|
_SendPacksWord(*_SendClass, 0, n1);
|
||||||
|
_SendPacksByte(*_SendClass, 0, n2);
|
||||||
|
_SendPacksByte(*_SendClass, 0, n3);
|
||||||
|
_SendPacksByte(*_SendClass, 0, n4);
|
||||||
|
_SendPacks();
|
||||||
|
|
||||||
//返回一个字符串给nut脚本 参数3为大小?
|
SQPushBool(v, true);
|
||||||
sq_pushstring(v, str, 5);
|
//return 1 表示该函数有返回值传给nut脚本 0则无
|
||||||
|
|
||||||
//return 1 表示该函数有返回值传给nut脚本
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
//新增C++调用 nut
|
||||||
|
// 示例如下
|
||||||
|
/*
|
||||||
|
uint32_t v = GetSqVm();
|
||||||
|
SQPushRootTable(v);
|
||||||
|
SQPushString(v, L"dofile", -1);
|
||||||
|
SQ_Get(v, -2);
|
||||||
|
SQPushRootTable(v);
|
||||||
|
SQPushString(v, L"1.cpp", -1);
|
||||||
|
SQ_Call(v, 2, 1, 0);
|
||||||
|
SQPop(v, 2);
|
||||||
|
*/
|
||||||
//-------------------------------------------------------------------------------------------Squirrel
|
//-------------------------------------------------------------------------------------------Squirrel
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue