Problem Writing a Function
@Gleeok
@Saffith
I created some functions to write to Link's tiles (using setlinktile(), not something wholly new), as follows:
Code:
//Link.h/cpp
void setTile(int state, int tile, int dir, int flip);
void LinkClass::setTile(int state, int tile, int dir, int flip){
setlinktile(tile, flip, getExtend(state), state, dir);
}
int getExtend();
int LinkClass::getExtend()
{
return walkspr[dir][spr_extend];
}
//ffasm.cpp
{ "SETLINKTILE", 0, 0, 0, 0}
//ffscript.cpp
case SETLINKTILE:
set_link_tile(false);
break;
void set_link_tile(bool v)
{
int state = SH::read_stack(ri->sp + 3) / 10000;
int tile = SH::read_stack(ri->sp + 2) / 10000;
int dir = SH::read_stack(ri->sp + 1) / 10000;
int flip = SH::read_stack(ri->sp + 0) / 10000;
Link.setTile(vbound(state,1,14),vbound(tile,0,65519),vbound(dir,0,16),vbound(flip,0,16));
}
//ffscript.h
SETLINKTILE, //0x00F1
//Bytecode.cpp
string OSetLinkTile::toString()
{
return "SETLINKTILE";
}
//Bytecode.h
class OSetLinkTile : public Opcode
{
public:
string toString();
Opcode *clone()
{
return new OSetLinkTile();
}
};
//GLobalSymbols.cpp
//void SetLinkTile(link, int,int,int,int)
{
int id = memberids["SetTile"];
int label = lt.functionToLabel(id);
vector<Opcode *> code;
Opcode *first = new OSetLinkTile();
first->setLabel(label);
code.push_back(first);
code.push_back(new OPopRegister(new VarArgument(EXP2)));
code.push_back(new OPopRegister(new VarArgument(EXP2)));
code.push_back(new OPopRegister(new VarArgument(EXP2)));
code.push_back(new OPopRegister(new VarArgument(EXP2)));
//pop pointer, and ignore it
code.push_back(new OPopRegister(new VarArgument(NUL)));
code.push_back(new OPopRegister(new VarArgument(EXP2)));
code.push_back(new OGotoRegister(new VarArgument(EXP2)));
rval[label]=code;
}
{ "SetTile", ScriptParser::TYPE_VOID, FUNCTION, 0, 1, { ScriptParser::TYPE_LINK, ScriptParser::TYPE_FLOAT, ScriptParser::TYPE_FLOAT, ScriptParser::TYPE_FLOAT, ScriptParser::TYPE_FLOAT, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } },
Does any of that look amiss? The function doesn't seem to do a blasted thing...
Also, could someone define what the four values used after the string in the array inside ffasm.cpp do, individually?
Number of args, is the stack inputs, AFAIK, buwhat do the next three values mean? It looks like the first two are meant as boolean flags; and what in the world is 'more'?
These...
Code:
//ffasm.cpp
script_command command_list[NUMCOMMANDS+1]=
{
//name args arg1 arg2 more
{ "SETLINKTILE", 0, 0, 0, 0}
It would be nice to have a basic reference on how these relate to the stack, and what arg1, arg2, and more are, specifically.
Also, in the 'would be nice' category:
Code:
{ "GETTILEPIXELV", 1, 1, 0, 0},
{ "GETTILEPIXELR", 1, 0, 0, 0},
{ "SETTILEPIXELV", 1, 1, 0, 0},
{ "SETTILEPIXELR", 1, 0, 0, 0},
I would love to finish these, once I fully comprehend the stack values and operations.