2015-08-20 15:30:34 +09:00
|
|
|
module otya.smilebasic.systemvariable;
|
|
|
|
|
import otya.smilebasic.type;
|
|
|
|
|
import otya.smilebasic.error;
|
2015-08-23 20:37:56 +09:00
|
|
|
import otya.smilebasic.vm;
|
2015-08-20 15:30:34 +09:00
|
|
|
class SystemVariable
|
|
|
|
|
{
|
2015-08-30 13:41:52 +09:00
|
|
|
VM vm;
|
2015-08-20 15:30:34 +09:00
|
|
|
@property
|
2015-08-30 13:41:52 +09:00
|
|
|
abstract Value value();
|
2015-08-20 15:30:34 +09:00
|
|
|
@property
|
|
|
|
|
void value(Value value)
|
|
|
|
|
{
|
|
|
|
|
throw new TypeMismatch();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
import std.datetime;
|
|
|
|
|
import std.string;
|
|
|
|
|
import std.conv;
|
|
|
|
|
class Date : SystemVariable
|
|
|
|
|
{
|
|
|
|
|
@property
|
2015-08-30 13:41:52 +09:00
|
|
|
override Value value()
|
2015-08-20 15:30:34 +09:00
|
|
|
{
|
|
|
|
|
auto currentTime = Clock.currTime();
|
|
|
|
|
wstring timeString = format("%04d/%02d/%02d", currentTime.year, currentTime.month, currentTime.day).to!wstring;
|
|
|
|
|
return Value(timeString);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class Time : SystemVariable
|
|
|
|
|
{
|
|
|
|
|
@property
|
2015-08-30 13:41:52 +09:00
|
|
|
override Value value()
|
2015-08-20 15:30:34 +09:00
|
|
|
{
|
|
|
|
|
auto currentTime = Clock.currTime();
|
|
|
|
|
wstring timeString = format("%02d:%02d:%02d", currentTime.hour, currentTime.minute, currentTime.second).to!wstring;
|
|
|
|
|
return Value(timeString);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-23 20:37:56 +09:00
|
|
|
class Maincnt : SystemVariable
|
|
|
|
|
{
|
|
|
|
|
@property
|
2015-08-30 13:41:52 +09:00
|
|
|
override Value value()
|
2015-08-23 20:37:56 +09:00
|
|
|
{
|
|
|
|
|
return Value(vm.petitcomputer.maincnt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class CSRX : SystemVariable
|
|
|
|
|
{
|
|
|
|
|
@property
|
2015-08-30 13:41:52 +09:00
|
|
|
override Value value()
|
2015-08-23 20:37:56 +09:00
|
|
|
{
|
2016-12-02 23:43:13 +09:00
|
|
|
return Value(vm.petitcomputer.console.CSRX);
|
2015-08-23 20:37:56 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class CSRY : SystemVariable
|
|
|
|
|
{
|
|
|
|
|
@property
|
2015-08-30 13:41:52 +09:00
|
|
|
override Value value()
|
2015-08-23 20:37:56 +09:00
|
|
|
{
|
2016-12-02 23:43:13 +09:00
|
|
|
return Value(vm.petitcomputer.console.CSRY);
|
2015-08-23 20:37:56 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class CSRZ : SystemVariable
|
|
|
|
|
{
|
|
|
|
|
@property
|
2015-08-30 13:41:52 +09:00
|
|
|
override Value value()
|
2015-08-23 20:37:56 +09:00
|
|
|
{
|
2016-12-02 23:43:13 +09:00
|
|
|
return Value(vm.petitcomputer.console.CSRZ);
|
2015-08-23 20:37:56 +09:00
|
|
|
}
|
|
|
|
|
}
|
2015-08-30 13:41:52 +09:00
|
|
|
class TabStep : SystemVariable
|
|
|
|
|
{
|
|
|
|
|
@property
|
|
|
|
|
override Value value()
|
|
|
|
|
{
|
2016-12-02 23:43:13 +09:00
|
|
|
return Value(vm.petitcomputer.console.TABSTEP);
|
2015-08-30 13:41:52 +09:00
|
|
|
}
|
|
|
|
|
@property
|
|
|
|
|
override void value(Value value)
|
|
|
|
|
{
|
|
|
|
|
if(!value.isNumber)
|
|
|
|
|
{
|
|
|
|
|
throw new TypeMismatch();
|
|
|
|
|
}
|
|
|
|
|
int i = value.castInteger;
|
|
|
|
|
if(i < 0 || i > 16)
|
|
|
|
|
{
|
|
|
|
|
throw new OutOfRange();
|
|
|
|
|
}
|
2016-12-02 23:43:13 +09:00
|
|
|
vm.petitcomputer.console.TABSTEP = i;
|
2015-08-30 13:41:52 +09:00
|
|
|
}
|
|
|
|
|
}
|
2015-08-27 21:35:15 +09:00
|
|
|
class Version : SystemVariable
|
|
|
|
|
{
|
2016-02-23 18:23:42 +09:00
|
|
|
static VERSIONSTRING = "3.1.0";
|
|
|
|
|
static VERSION = 0x3010000;
|
2015-08-27 21:35:15 +09:00
|
|
|
@property
|
2015-08-30 13:41:52 +09:00
|
|
|
override Value value()
|
2015-08-27 21:35:15 +09:00
|
|
|
{
|
2016-02-23 18:23:42 +09:00
|
|
|
return Value(VERSION);
|
2015-08-27 21:35:15 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class FreeMem : SystemVariable
|
|
|
|
|
{
|
|
|
|
|
@property
|
2015-08-30 13:41:52 +09:00
|
|
|
override Value value()
|
2015-08-27 21:35:15 +09:00
|
|
|
{
|
|
|
|
|
return Value(8327164);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-05 21:28:25 +09:00
|
|
|
class Result : SystemVariable
|
|
|
|
|
{
|
|
|
|
|
@property
|
|
|
|
|
override Value value()
|
|
|
|
|
{
|
|
|
|
|
return Value(vm.petitcomputer.project.result);
|
|
|
|
|
}
|
|
|
|
|
}
|