1
0

Implement SPDEF id OUT ...

This commit is contained in:
otya128
2016-12-06 18:39:56 +09:00
parent 627e92126c
commit b2b9779eea
3 changed files with 53 additions and 0 deletions

View File

@@ -83,6 +83,7 @@ class BuiltinFunctions
//一応可変長は最後 //一応可変長は最後
if(va) return va; if(va) return va;
writeln("====function overloads==="); writeln("====function overloads===");
writefln("func = %s argc = %d outargc = %d", func[0].name, argc, outargc);
foreach(f; func) foreach(f; func)
{ {
writefln("name=\"%s\", argments=%s, results = %s, variadic = %s, startoptional = %d, function pointer=%s", f.name, f.argments, f.results, f.variadic, f.startskip, f.func); writefln("name=\"%s\", argments=%s, results = %s, variadic = %s, startoptional = %d, function pointer=%s", f.name, f.argments, f.results, f.variadic, f.startskip, f.func);
@@ -1043,6 +1044,34 @@ class BuiltinFunction
} }
p.sprite.spchr(id, defno); p.sprite.spchr(id, defno);
} }
static void SPCHR(PetitComputer p, int id, out int defno)
{
if (!p.sprite.isSpriteDefined(id))
{
throw new IllegalFunctionCall("SPCHR", 1);
}
p.sprite.spchr(id, defno);
}
static void SPCHR(PetitComputer p, int id, out int u, out int v, out int w, out int h, out int attr)
{
if (!p.sprite.isSpriteDefined(id))
{
throw new IllegalFunctionCall("SPCHR", 1);
}
SpriteAttr spriteattr;
p.sprite.spchr(id, u, v, w, h, spriteattr);
attr = cast(int)spriteattr;
}
static void SPCHR(PetitComputer p, int id, out int u, out int v)
{
int w, h, attr;
SPCHR(p, id, u, v, w, h , attr);
}
static void SPCHR(PetitComputer p, int id, out int u, out int v, out int w, out int h)
{
int attr;
SPCHR(p, id, u, v, w, h , attr);
}
static void SPHIDE(PetitComputer p, int id) static void SPHIDE(PetitComputer p, int id)
{ {
p.sprite.sphide(id); p.sprite.sphide(id);

View File

@@ -55,6 +55,11 @@ class IllegalFunctionCall : SmileBasicError
this.errnum = 4; this.errnum = 4;
super("Illegal function call(" ~ func ~ ")"); super("Illegal function call(" ~ func ~ ")");
} }
this(string func, int arg)
{
this.errnum = 4;
super("Illegal function call(" ~ func ~ ":" ~ arg.to!string ~ ")");
}
} }
class StackOverFlow : SmileBasicError class StackOverFlow : SmileBasicError
{ {

View File

@@ -343,6 +343,11 @@ class Sprite
HY= SPDEFTable[id].hy; HY= SPDEFTable[id].hy;
A = SPDEFTable[id].a; A = SPDEFTable[id].a;
} }
bool isSpriteDefined(int i)
{
i = spid(i);
return sprites[i].define;
}
void spchr(int i, int d) void spchr(int i, int d)
{ {
i = spid(i); i = spid(i);
@@ -354,6 +359,20 @@ class Sprite
auto spdef = SpriteDef(u, v, w, h, sprites[id].homex, sprites[id].homey, attr); auto spdef = SpriteDef(u, v, w, h, sprites[id].homex, sprites[id].homey, attr);
sprites[id].change(spdef); sprites[id].change(spdef);
} }
void spchr(int i, out int d)
{
i = spid(i);
d = sprites[i].defno;
}
void spchr(int id, out int u, out int v, out int w, out int h, out SpriteAttr attr)
{
id = spid(id);
u = sprites[id].u;
v = sprites[id].v;
w = sprites[id].w;
h = sprites[id].h;
attr = sprites[id].attr;
}
this(PetitComputer petitcom) this(PetitComputer petitcom)
{ {
initSpriteAnimationTable(); initSpriteAnimationTable();