1
0

Implement SAVE (1)

This commit is contained in:
otya128
2016-12-27 15:41:07 +09:00
parent ab86a9fb4e
commit 618a145c9c
2 changed files with 23 additions and 1 deletions

View File

@@ -2269,7 +2269,7 @@ class BuiltinFunction
} }
if(resname == "" || resname.indexOf("PRG") == 0) if(resname == "" || resname.indexOf("PRG") == 0)
{ {
int lot; int lot = p.currentSlot;
if(resname != "" && resname != "PRG") if(resname != "" && resname != "PRG")
{ {
auto num = resname[3..$]; auto num = resname[3..$];
@@ -2294,6 +2294,25 @@ class BuiltinFunction
flag.setDefaultValue(0); flag.setDefaultValue(0);
throw new IllegalFunctionCall("NOTIMPL:LOAD"); 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) static void SAVE(PetitComputer p, wstring name, Value data)
{ {
auto file = Projects.parseFileName(name); auto file = Projects.parseFileName(name);

View File

@@ -1671,6 +1671,9 @@ class PetitComputer
currentDisplay.yoffset = currentDisplay.windowSize.height; currentDisplay.yoffset = currentDisplay.windowSize.height;
updateWindowSize(); updateWindowSize();
} }
int currentSlot;
int slotSize = 4;
//プチコン内部表現はRGB5_A1 //プチコン内部表現はRGB5_A1
static uint toGLColor(GLenum format, ubyte r, ubyte g, ubyte b, ubyte a) static uint toGLColor(GLenum format, ubyte r, ubyte g, ubyte b, ubyte a)
{ {