Implement SPxx OUT function
This commit is contained in:
@@ -1920,6 +1920,18 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
p.sprite.sphome(i, hx, hy);
|
p.sprite.sphome(i, hx, hy);
|
||||||
}
|
}
|
||||||
|
static void SPHOME(PetitComputer p, int i, out int hx, out int hy)
|
||||||
|
{
|
||||||
|
if (!p.sprite.isValidSpriteId(i))
|
||||||
|
{
|
||||||
|
throw new OutOfRange(smilebasicFunctionName, 1);
|
||||||
|
}
|
||||||
|
if (!p.sprite.isSpriteDefined(i))
|
||||||
|
{
|
||||||
|
throw new IllegalFunctionCall("SPHOME", 1);
|
||||||
|
}
|
||||||
|
p.sprite.getsphome(i, hx, hy);
|
||||||
|
}
|
||||||
static void SPSCALE(PetitComputer p, int i, double x, double y)
|
static void SPSCALE(PetitComputer p, int i, double x, double y)
|
||||||
{
|
{
|
||||||
if (!p.sprite.isValidSpriteId(i))
|
if (!p.sprite.isValidSpriteId(i))
|
||||||
@@ -1956,6 +1968,18 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
p.sprite.sprot(i, rot);
|
p.sprite.sprot(i, rot);
|
||||||
}
|
}
|
||||||
|
static void SPROT(PetitComputer p, int i, out double rot)
|
||||||
|
{
|
||||||
|
if (!p.sprite.isValidSpriteId(i))
|
||||||
|
{
|
||||||
|
throw new OutOfRange(smilebasicFunctionName, 1);
|
||||||
|
}
|
||||||
|
if (!p.sprite.isSpriteDefined(i))
|
||||||
|
{
|
||||||
|
throw new IllegalFunctionCall("SPROT", 1);
|
||||||
|
}
|
||||||
|
p.sprite.getsprot(i, rot);
|
||||||
|
}
|
||||||
static void SPCOLOR(PetitComputer p, int id, int color)
|
static void SPCOLOR(PetitComputer p, int id, int color)
|
||||||
{
|
{
|
||||||
if (!p.sprite.isValidSpriteId(id))
|
if (!p.sprite.isValidSpriteId(id))
|
||||||
@@ -1968,6 +1992,18 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
p.sprite.spcolor(id, cast(uint)color);
|
p.sprite.spcolor(id, cast(uint)color);
|
||||||
}
|
}
|
||||||
|
static void SPCOLOR(PetitComputer p, int id, out int color)
|
||||||
|
{
|
||||||
|
if (!p.sprite.isValidSpriteId(id))
|
||||||
|
{
|
||||||
|
throw new OutOfRange(smilebasicFunctionName, 1);
|
||||||
|
}
|
||||||
|
if (!p.sprite.isSpriteDefined(id))
|
||||||
|
{
|
||||||
|
throw new IllegalFunctionCall("SPCOLOR", 1);
|
||||||
|
}
|
||||||
|
p.sprite.getspcolor(id, color);
|
||||||
|
}
|
||||||
static void SPLINK(PetitComputer p, int child, int parent)
|
static void SPLINK(PetitComputer p, int child, int parent)
|
||||||
{
|
{
|
||||||
if (!p.sprite.isValidSpriteId(child))
|
if (!p.sprite.isValidSpriteId(child))
|
||||||
|
|||||||
@@ -250,6 +250,11 @@ class PetitComputer
|
|||||||
//ARGB -> ABGR
|
//ARGB -> ABGR
|
||||||
return (color & 0xFF00FF00) | (color >> 16 & 0xFF) | ((color & 0xFF) << 16);
|
return (color & 0xFF00FF00) | (color >> 16 & 0xFF) | ((color & 0xFF) << 16);
|
||||||
}
|
}
|
||||||
|
uint fromGLColor(uint color)
|
||||||
|
{
|
||||||
|
//ARGB <- ABGR
|
||||||
|
return (color & 0xFF00FF00) | (color >> 16 & 0xFF) | ((color & 0xFF) << 16);
|
||||||
|
}
|
||||||
struct ConsoleCharacter
|
struct ConsoleCharacter
|
||||||
{
|
{
|
||||||
wchar character;
|
wchar character;
|
||||||
|
|||||||
@@ -1021,6 +1021,15 @@ class Sprite
|
|||||||
sprites[i].homey = hy;
|
sprites[i].homey = hy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void getsphome(int i, out int hx, out int hy)
|
||||||
|
{
|
||||||
|
i = spid(i);
|
||||||
|
synchronized (this)
|
||||||
|
{
|
||||||
|
hx = sprites[i].homex;
|
||||||
|
hy = sprites[i].homey;
|
||||||
|
}
|
||||||
|
}
|
||||||
void spscale(int i, double x, double y)
|
void spscale(int i, double x, double y)
|
||||||
{
|
{
|
||||||
i = spid(i);
|
i = spid(i);
|
||||||
@@ -1044,11 +1053,21 @@ class Sprite
|
|||||||
i = spid(i);
|
i = spid(i);
|
||||||
sprites[i].r = rot;
|
sprites[i].r = rot;
|
||||||
}
|
}
|
||||||
|
void getsprot(int i, out double rot)
|
||||||
|
{
|
||||||
|
i = spid(i);
|
||||||
|
rot = sprites[i].r;
|
||||||
|
}
|
||||||
void spcolor(int id, uint color)
|
void spcolor(int id, uint color)
|
||||||
{
|
{
|
||||||
id = spid(id);
|
id = spid(id);
|
||||||
sprites[id].color = petitcom.toGLColor(color);
|
sprites[id].color = petitcom.toGLColor(color);
|
||||||
}
|
}
|
||||||
|
void getspcolor(int id, out int color)
|
||||||
|
{
|
||||||
|
id = spid(id);
|
||||||
|
petitcom.fromGLColor(sprites[id].color);
|
||||||
|
}
|
||||||
void splink(int child, int parent)
|
void splink(int child, int parent)
|
||||||
{
|
{
|
||||||
if(parent >= child)
|
if(parent >= child)
|
||||||
|
|||||||
Reference in New Issue
Block a user