diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index 6da8dd2..4ee775f 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -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); } diff --git a/SMILEBASIC/error.d b/SMILEBASIC/error.d index 8873abc..a9ab4ec 100644 --- a/SMILEBASIC/error.d +++ b/SMILEBASIC/error.d @@ -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) diff --git a/SMILEBASIC/graphic.d b/SMILEBASIC/graphic.d index 4bea14c..57886d2 100644 --- a/SMILEBASIC/graphic.d +++ b/SMILEBASIC/graphic.d @@ -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++) diff --git a/SMILEBASIC/project.d b/SMILEBASIC/project.d index 54f2037..4a619aa 100644 --- a/SMILEBASIC/project.d +++ b/SMILEBASIC/project.d @@ -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 diff --git a/SMILEBASIC/type.d b/SMILEBASIC/type.d index d99d81e..250099c 100644 --- a/SMILEBASIC/type.d +++ b/SMILEBASIC/type.d @@ -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)