1
0

Implement BGSAVE

This commit is contained in:
otya128
2016-12-14 21:26:52 +09:00
parent 992e42f9d8
commit 430aed0264
2 changed files with 56 additions and 0 deletions

View File

@@ -11,6 +11,10 @@ struct BGChip
{
return i;
}
void screenData(int a)
{
i = a;
}
}
//912枚まで描画されるみたい
//->899枚まで描画してその後は一番下のみ描画の様子
@@ -179,4 +183,20 @@ class BG
return chip[x + y * width].screenData;
}
}
void save(T)(int x, int y, int w, int h, T[] array)
if (is(T == int) || is(T == double))
{
int desti;
for (int i = x; i < x + w; i++)
{
for (int j = y; j < y + h; j++)
{
desti++;
int index = i + j * width;
if (index < 0)
continue;
array[desti - 1] = cast(int)chip[index].screenData;
}
}
}
}

View File

@@ -1828,6 +1828,42 @@ class BuiltinFunction
{
return p.getBG(layer).get(x, y, flag);
}
static void BGSAVE(PetitComputer p, int layer, int x, int y, int w, int h, Value ary)
{
if (w < 1)
{
throw new OutOfRange("BGSAVE", 4);
}
if (h < 1)
{
throw new OutOfRange("BGSAVE", 4);
}
if (!ary.isNumberArray)
{
throw new TypeMismatch("BGSAVE", 6);
}
if (ary.type == ValueType.IntegerArray)
{
if (w * h > ary.length)
ary.integerArray.length = w * h;
p.getBG(layer).save(x, y, w, h, ary.integerArray.array);
}
if (ary.type == ValueType.DoubleArray)
{
if (w * h > ary.length)
ary.doubleArray.length = w * h;
p.getBG(layer).save(x, y, w, h, ary.doubleArray.array);
}
}
static void BGSAVE(PetitComputer p, int layer, Value ary)
{
if (!ary.isNumberArray)
{
throw new TypeMismatch("BGSAVE", 2);
}
BGSAVE(p, layer, 0, 0, p.getBG(layer).width, p.getBG(layer).height, ary);
}
static void EFCON()
{
}