Implement SPSET (5),(6)
This commit is contained in:
@@ -1319,6 +1319,40 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
p.sprite.spset(id, defno);
|
p.sprite.spset(id, defno);
|
||||||
}
|
}
|
||||||
|
static void SPSET(PetitComputer p, int lower, int upper, int defno, out int ix)
|
||||||
|
{
|
||||||
|
if (!p.sprite.isValidSpriteId(upper))
|
||||||
|
throw new OutOfRange("SPSET", 1);
|
||||||
|
if (!p.sprite.isValidSpriteId(lower))
|
||||||
|
throw new OutOfRange("SPSET", 2);
|
||||||
|
if (upper < lower)
|
||||||
|
throw new IllegalFunctionCall("SPSET", 2);
|
||||||
|
ix = p.sprite.allocSprite(lower, upper);
|
||||||
|
if (ix == -1)
|
||||||
|
return;
|
||||||
|
p.sprite.spset(ix, defno);
|
||||||
|
}
|
||||||
|
static void SPSET(PetitComputer p, int upper, int lower, int u, int v, out int ix)
|
||||||
|
{
|
||||||
|
SPSET(p, upper, lower, u, v, 16, 16, 0x01, ix);
|
||||||
|
}
|
||||||
|
static void SPSET(PetitComputer p, int upper, int lower, int u, int v, int w, int h, out int ix)
|
||||||
|
{
|
||||||
|
SPSET(p, upper, lower, u, v, w, h, 0x01, ix);
|
||||||
|
}
|
||||||
|
static void SPSET(PetitComputer p, int lower, int upper, int u, int v, int w, int h, int attr, out int ix)
|
||||||
|
{
|
||||||
|
if (!p.sprite.isValidSpriteId(upper))
|
||||||
|
throw new OutOfRange("SPSET", 1);
|
||||||
|
if (!p.sprite.isValidSpriteId(lower))
|
||||||
|
throw new OutOfRange("SPSET", 2);
|
||||||
|
if (upper < lower)
|
||||||
|
throw new IllegalFunctionCall("SPSET", 2);
|
||||||
|
ix = p.sprite.allocSprite(lower, upper);
|
||||||
|
if (ix == -1)
|
||||||
|
return;
|
||||||
|
p.sprite.spset(ix, u, v, w, h, cast(SpriteAttr)attr);
|
||||||
|
}
|
||||||
static void SPCHR(PetitComputer p, int id, int defno, DefaultValue!(int, false) V, DefaultValue!(int, false) W, DefaultValue!(int, false) H, DefaultValue!(int, false) ATTR)
|
static void SPCHR(PetitComputer p, int id, int defno, DefaultValue!(int, false) V, DefaultValue!(int, false) W, DefaultValue!(int, false) H, DefaultValue!(int, false) ATTR)
|
||||||
{
|
{
|
||||||
if(!V.isDefault && !W.isDefault)
|
if(!V.isDefault && !W.isDefault)
|
||||||
|
|||||||
@@ -870,6 +870,16 @@ class Sprite
|
|||||||
synchronized (this)
|
synchronized (this)
|
||||||
sprites[id] = SpriteData(id, spdef, 0/*要調査*/);
|
sprites[id] = SpriteData(id, spdef, 0/*要調査*/);
|
||||||
}
|
}
|
||||||
|
int allocSprite(int lower, int upper)
|
||||||
|
{
|
||||||
|
for (int i = lower; i <= upper; i++)
|
||||||
|
{
|
||||||
|
int id = spid(i);
|
||||||
|
if (!sprites[id].define)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
int spchk(int id)
|
int spchk(int id)
|
||||||
{
|
{
|
||||||
id = spid(id);
|
id = spid(id);
|
||||||
@@ -1179,4 +1189,19 @@ class Sprite
|
|||||||
}
|
}
|
||||||
clipRect[petitcom.displaynum] = SDL_Rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
|
clipRect[petitcom.displaynum] = SDL_Rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
|
||||||
}
|
}
|
||||||
|
bool isValidSpriteId(int id)
|
||||||
|
{
|
||||||
|
if (id < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (petitcom.displaynum == 0)
|
||||||
|
{
|
||||||
|
return spmax > id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return sprites.length > id + spmax;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user