1
0

Implement GSAVE -1

This commit is contained in:
otya128
2017-07-09 22:44:25 +09:00
parent 946e3a1c1b
commit ee4ab7bc9d
5 changed files with 60 additions and 5 deletions

View File

@@ -579,7 +579,15 @@ class BuiltinFunction
{
if (size > ary.length)
{
ary.integerArray.length = size;
if (ary.dimCount != 2)
{
ary.integerArray.length = size;
}
else
{
ary.integerArray.dim[0..2] = [w, h];
ary.integerArray.array = new int[size];
}
}
p.graphic.gsave(savepage, x, y, w, h, ary.integerArray.array, flag);
}
@@ -587,7 +595,15 @@ class BuiltinFunction
{
if (size > ary.length)
{
ary.doubleArray.length = size;
if (ary.dimCount != 2)
{
ary.doubleArray.length = size;
}
else
{
ary.doubleArray.dim[0..2] = [w, h];
ary.doubleArray.array = new double[size];
}
}
p.graphic.gsave(savepage, x, y, w, h, ary.doubleArray.array, flag);
}

View File

@@ -226,6 +226,14 @@ class IllegalSymbolString : SmileBasicError
super("Illegal symbol string");
}
}
class IllegalFileFormat : SmileBasicError
{
this(string func)
{
this.errnum = 35;
super("Illegal file format(" ~ func ~ ")");
}
}
class UsePRGEDITBeforeAnyPRGFunction : SmileBasicError
{
this(string func)

View File

@@ -1206,7 +1206,13 @@ class Graphic2 : Graphic
{
int arrayH = h, arrayW = w;
int sx, sy;
int* buffer = cast(int*)GRP[savepage].surface.pixels;
int* buffer;
if (savepage == -1)
{
buffer = cast(int*)petitcom.console.GRPF.surface.pixels;
}
else
buffer = cast(int*)GRP[savepage].surface.pixels;
for (int iy = sy; iy < h; iy++)
{
for (int ix = sx; ix < w; ix++)

View File

@@ -180,8 +180,8 @@ r"ファイルを書き込みます。
return true;
}
bool loadDataFile(T)(FileName file, ref Array!T contents)
if (is(T == int) || is(T == double))
bool loadDataFile(T)(FileName file, ref Array!T contents, out DataHeader header)
if (is(T == int) || is(T == double))
{
wstring project;
result = DialogResult.FAILURE;
@@ -211,6 +211,7 @@ r"ファイルを書き込みます。
harray[0].dim[] = [cast(int)(f.size / int.sizeof), 0, 0, 0];
harray[0].type = DataType.int_;
}
header = harray[0];
if (harray[0].dimension != contents.dimCount)
{
throw new TypeMismatch("LOAD");
@@ -260,6 +261,12 @@ r"ファイルを書き込みます。
contents.dimCount = harray[0].dimension;
return true;
}
bool loadDataFile(T)(FileName file, ref Array!T contents)
if (is(T == int) || is(T == double))
{
DataHeader dh;
return loadDataFile(file, contents, dh);
}
void saveTextFile(FileName file, wstring content)
{
@@ -359,6 +366,8 @@ r"ファイルを書き込みます。
return Resource.data;
case "TXT":
return Resource.text;
case "GRPF":
return Resource.graphicFont;
default:
return Resource.illegal;
}
@@ -406,6 +415,7 @@ enum Resource
data,
text,
illegal,
graphicFont,
}
struct FileName

View File

@@ -138,6 +138,21 @@ struct Value
this.type = ValueType.Function;
this.func = func;
}
this(Array!int a)
{
this.type = ValueType.IntegerArray;
this.integerArray = a;
}
this(Array!double a)
{
this.type = ValueType.DoubleArray;
this.doubleArray = a;
}
this(Array!(Array!wchar) a)
{
this.type = ValueType.StringArray;
this.stringArray = a;
}
void castOp(ValueType type)
{
switch(type)