diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index fc2e2ea..537b0f9 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -2269,7 +2269,7 @@ class BuiltinFunction } if(resname == "" || resname.indexOf("PRG") == 0) { - int lot; + int lot = p.currentSlot; if(resname != "" && resname != "PRG") { auto num = resname[3..$]; @@ -2294,6 +2294,25 @@ class BuiltinFunction flag.setDefaultValue(0); throw new IllegalFunctionCall("NOTIMPL:LOAD"); } + static void SAVE(PetitComputer p, wstring name) + { + auto file = Projects.parseFileName(name); + if (file.resource != Resource.program && file.resource != Resource.none) + { + throw new IllegalFunctionCall("SAVE"/*, 1*/); + } + auto slot = p.currentSlot; + if (file.hasResourceNumber) + { + slot = file.resourceNumber; + } + if (slot >= p.slotSize) + { + throw new IllegalFunctionCall("SAVE"/*, 1*/); + } + auto str = cast(immutable)p.slot[slot].text; + p.project.saveTextFile(file, str); + } static void SAVE(PetitComputer p, wstring name, Value data) { auto file = Projects.parseFileName(name); diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index df6a5b7..a2e9ed1 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -1671,6 +1671,9 @@ class PetitComputer currentDisplay.yoffset = currentDisplay.windowSize.height; updateWindowSize(); } + + int currentSlot; + int slotSize = 4; //プチコン内部表現はRGB5_A1 static uint toGLColor(GLenum format, ubyte r, ubyte g, ubyte b, ubyte a) {