Implement XON/XOFF
This commit is contained in:
@@ -2011,3 +2011,18 @@ class PushVarExpression : Code
|
||||
vm.push(vm.currentSlot.global[vmv.index]);
|
||||
}
|
||||
}
|
||||
|
||||
class SetX : Code
|
||||
{
|
||||
wstring func;
|
||||
bool value;
|
||||
this(wstring f, bool value)
|
||||
{
|
||||
this.func = f;
|
||||
this.value = value;
|
||||
}
|
||||
override void execute(VM vm)
|
||||
{
|
||||
vm.petitcomputer.setX(func, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -908,6 +908,14 @@ class Compiler
|
||||
compilePushReference(swap.item1, sc);
|
||||
genCode(new SwapCode());
|
||||
}
|
||||
void compileXOn(XOn x, Scope sc)
|
||||
{
|
||||
genCode(new SetX(x.func, true));
|
||||
}
|
||||
void compileXOff(XOff x, Scope sc)
|
||||
{
|
||||
genCode(new SetX(x.func, false));
|
||||
}
|
||||
void compileStatement(Statement i, Scope s)
|
||||
{
|
||||
switch(i.type)
|
||||
@@ -1170,6 +1178,12 @@ class Compiler
|
||||
case NodeType.Swap:
|
||||
compileSwap(cast(Swap)i, s);
|
||||
break;
|
||||
case NodeType.XOn:
|
||||
compileXOn(cast(XOn)i, s);
|
||||
break;
|
||||
case NodeType.XOff:
|
||||
compileXOff(cast(XOff)i, s);
|
||||
break;
|
||||
default:
|
||||
stderr.writeln("Compile:NotImpl ", i.type);
|
||||
}
|
||||
|
||||
@@ -1236,6 +1236,37 @@ class PetitComputer
|
||||
{
|
||||
return page >= 0 && page < 6;
|
||||
}
|
||||
struct X
|
||||
{
|
||||
bool motion;
|
||||
bool expad;
|
||||
bool mic;
|
||||
bool wiiU;
|
||||
}
|
||||
X x;
|
||||
public void setX(wstring func, bool value)
|
||||
{
|
||||
if (func == "WIIU")
|
||||
{
|
||||
x.wiiU = value;
|
||||
}
|
||||
else if (func == "MIC")
|
||||
{
|
||||
x.mic = value;
|
||||
}
|
||||
else if (func == "EXPAD")
|
||||
{
|
||||
x.expad = value;
|
||||
}
|
||||
else if (func == "MOTION")
|
||||
{
|
||||
x.motion = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
std.stdio.stderr.writefln("Unknown %s %s", value ? "XON" : "XOFF", func);
|
||||
}
|
||||
}
|
||||
//プチコン内部表現はRGB5_A1
|
||||
static uint toGLColor(GLenum format, ubyte r, ubyte g, ubyte b, ubyte a)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user