FLOOR,IF THEN @LABEL,ボタン入力を実�
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
GOSUB@A
|
GOSUB@A
|
||||||
GOTO@B
|
GOTO@B
|
||||||
'A=SIN(B)
|
'A=SIN(B)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class BuiltinFunction
|
|||||||
}
|
}
|
||||||
static int BUTTON(PetitComputer p, DefaultValue!(int, false) mode)
|
static int BUTTON(PetitComputer p, DefaultValue!(int, false) mode)
|
||||||
{
|
{
|
||||||
return 0;
|
return p.button;
|
||||||
}
|
}
|
||||||
static void VISIBLE(PetitComputer p, DefaultValue!(int) console, DefaultValue!(int) graphic, DefaultValue!(int) BG, DefaultValue!(int) sprite)
|
static void VISIBLE(PetitComputer p, DefaultValue!(int) console, DefaultValue!(int) graphic, DefaultValue!(int) BG, DefaultValue!(int) sprite)
|
||||||
{
|
{
|
||||||
@@ -192,6 +192,10 @@ class BuiltinFunction
|
|||||||
double val = str.to!double;
|
double val = str.to!double;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
static double FLOOR(double val)
|
||||||
|
{
|
||||||
|
return val.floor;
|
||||||
|
}
|
||||||
static wstring MID(wstring str, int i, int len)
|
static wstring MID(wstring str, int i, int len)
|
||||||
{
|
{
|
||||||
//挙動未定
|
//挙動未定
|
||||||
|
|||||||
@@ -614,12 +614,20 @@ class Parser
|
|||||||
Statements ifStatements()
|
Statements ifStatements()
|
||||||
{
|
{
|
||||||
auto statements = new Statements();
|
auto statements = new Statements();
|
||||||
|
bool flag = true;
|
||||||
while(!lex.empty())
|
while(!lex.empty())
|
||||||
{
|
{
|
||||||
auto type = lex.front().type;
|
auto type = lex.front().type;
|
||||||
|
flag = false;
|
||||||
if(type == TokenType.NewLine) break;
|
if(type == TokenType.NewLine) break;
|
||||||
if(type == TokenType.Else) break;
|
if(type == TokenType.Else) break;
|
||||||
if(type == TokenType.Endif) break;
|
if(type == TokenType.Endif) break;
|
||||||
|
if(type == TokenType.Label)
|
||||||
|
{
|
||||||
|
statements.addStatement(new Goto(lex.front.value.stringValue));
|
||||||
|
lex.popFront;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
auto statement = statement();
|
auto statement = statement();
|
||||||
if(statement != Statement.NOP)
|
if(statement != Statement.NOP)
|
||||||
{
|
{
|
||||||
@@ -1110,13 +1118,12 @@ class Parser
|
|||||||
{
|
{
|
||||||
var.addDefineArray(cast(DefineArray)v);
|
var.addDefineArray(cast(DefineArray)v);
|
||||||
}
|
}
|
||||||
|
token = lex.front();
|
||||||
//VARの評価順は順番通り
|
//VARの評価順は順番通り
|
||||||
//VAR iden[=expr],
|
//VAR iden[=expr],
|
||||||
if(token.type == TokenType.Comma)
|
if(token.type == TokenType.Comma)
|
||||||
{
|
{
|
||||||
lex.popFront();
|
lex.popFront();
|
||||||
writeln("NOTIMPL");
|
|
||||||
syntaxError();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,23 @@ import std.string;
|
|||||||
import std.c.stdio;
|
import std.c.stdio;
|
||||||
import core.sync.mutex;
|
import core.sync.mutex;
|
||||||
import otya.smilebasic.parser;
|
import otya.smilebasic.parser;
|
||||||
|
enum Button
|
||||||
|
{
|
||||||
|
UP = 1,
|
||||||
|
DOWN = 2,
|
||||||
|
LEFT = 4,
|
||||||
|
RIGHT = 8,
|
||||||
|
A = 16,
|
||||||
|
B = 32,
|
||||||
|
X = 64,
|
||||||
|
Y = 128,
|
||||||
|
L = 256,
|
||||||
|
R = 512,
|
||||||
|
UNUSED = 1024,
|
||||||
|
ZR = 2048,
|
||||||
|
ZL = 4096,
|
||||||
|
START = 8192,
|
||||||
|
}
|
||||||
class GraphicPage
|
class GraphicPage
|
||||||
{
|
{
|
||||||
static GLenum textureScaleMode = GL_NEAREST;
|
static GLenum textureScaleMode = GL_NEAREST;
|
||||||
@@ -120,6 +137,7 @@ class PetitComputer
|
|||||||
{
|
{
|
||||||
return SDL_Color(r >> 5 << 5, g >> 5 << 5, b >> 5 << 5, a == 255 ? 255 : 0);
|
return SDL_Color(r >> 5 << 5, g >> 5 << 5, b >> 5 << 5, a == 255 ? 255 : 0);
|
||||||
}
|
}
|
||||||
|
Button button;
|
||||||
ConsoleCharacter[][] console;
|
ConsoleCharacter[][] console;
|
||||||
bool visibleGRP = true;
|
bool visibleGRP = true;
|
||||||
int showGRP;
|
int showGRP;
|
||||||
@@ -480,9 +498,16 @@ class PetitComputer
|
|||||||
drawflag = false;
|
drawflag = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Button[] buttonTable;
|
||||||
void render()
|
void render()
|
||||||
{
|
{
|
||||||
bool renderprofile;
|
buttonTable = new Button[SDL_SCANCODE_SLEEP + 1];
|
||||||
|
buttonTable[SDL_SCANCODE_UP] = Button.UP;
|
||||||
|
buttonTable[SDL_SCANCODE_DOWN] = Button.DOWN;
|
||||||
|
buttonTable[SDL_SCANCODE_LEFT] = Button.LEFT;
|
||||||
|
buttonTable[SDL_SCANCODE_RIGHT] = Button.RIGHT;
|
||||||
|
buttonTable[SDL_SCANCODE_SPACE] = Button.A;
|
||||||
|
bool renderprofile;// = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
version(Windows)
|
version(Windows)
|
||||||
@@ -554,19 +579,28 @@ class PetitComputer
|
|||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return;
|
return;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYUP:
|
||||||
auto key = event.key.keysym.sym;
|
|
||||||
if(key == SDLK_BACKSPACE)
|
|
||||||
{
|
{
|
||||||
keybuffermutex.lock();
|
auto key = event.key.keysym.sym;
|
||||||
sendKey('\u0008');
|
button &= ~buttonTable[event.key.keysym.scancode];
|
||||||
keybuffermutex.unlock();
|
|
||||||
}
|
}
|
||||||
if(key == SDLK_RETURN)
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
{
|
{
|
||||||
keybuffermutex.lock();
|
auto key = event.key.keysym.sym;
|
||||||
sendKey('\u000D');
|
button |= buttonTable[event.key.keysym.scancode];
|
||||||
keybuffermutex.unlock();
|
if(key == SDLK_BACKSPACE)
|
||||||
|
{
|
||||||
|
keybuffermutex.lock();
|
||||||
|
sendKey('\u0008');
|
||||||
|
keybuffermutex.unlock();
|
||||||
|
}
|
||||||
|
if(key == SDLK_RETURN)
|
||||||
|
{
|
||||||
|
keybuffermutex.lock();
|
||||||
|
sendKey('\u000D');
|
||||||
|
keybuffermutex.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
@@ -584,7 +618,7 @@ class PetitComputer
|
|||||||
}
|
}
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
long delay = (1000/60) - cast(long)(SDL_GetTicks() - profile);
|
long delay = (1000/60) - (cast(long)SDL_GetTicks() - profile);
|
||||||
if(delay > 0)
|
if(delay > 0)
|
||||||
SDL_Delay(cast(uint)delay);
|
SDL_Delay(cast(uint)delay);
|
||||||
break;
|
break;
|
||||||
@@ -621,7 +655,8 @@ class PetitComputer
|
|||||||
thread.start();
|
thread.start();
|
||||||
auto startTicks = SDL_GetTicks();
|
auto startTicks = SDL_GetTicks();
|
||||||
//とりあえず
|
//とりあえず
|
||||||
auto parser = new Parser(readText("./SYS/EX5BIORHYTHM.TXT").to!wstring
|
auto parser = new Parser(
|
||||||
|
readText("./SYS/EX7ALIEN.TXT").to!wstring
|
||||||
//readText(input("LOAD PROGRAM:", true).to!string).to!wstring
|
//readText(input("LOAD PROGRAM:", true).to!string).to!wstring
|
||||||
//readText("./SYS/EX1TEXT.TXT").to!wstring
|
//readText("./SYS/EX1TEXT.TXT").to!wstring
|
||||||
//readText("FIZZBUZZ.TXT").to!wstring
|
//readText("FIZZBUZZ.TXT").to!wstring
|
||||||
@@ -668,10 +703,10 @@ class PetitComputer
|
|||||||
auto vm = parser.compile();
|
auto vm = parser.compile();
|
||||||
bool running = true;
|
bool running = true;
|
||||||
vm.init(this);
|
vm.init(this);
|
||||||
gpset(0, 10, 10, 0xFF00FF00);
|
//gpset(0, 10, 10, 0xFF00FF00);
|
||||||
gline(0, 0, 0, 399, 239, RGB(0, 255, 0));
|
//gline(0, 0, 0, 399, 239, RGB(0, 255, 0));
|
||||||
gfill(0, 78, 78, 40, 40, RGB(0, 255, 255));
|
//gfill(0, 78, 78, 40, 40, RGB(0, 255, 255));
|
||||||
gbox(0, 78, 78, 40, 40, RGB(255, 255, 0));
|
//gbox(0, 78, 78, 40, 40, RGB(255, 255, 0));
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
uint elapse;
|
uint elapse;
|
||||||
@@ -918,8 +953,8 @@ class PetitComputer
|
|||||||
}
|
}
|
||||||
void renderConsoleGL()
|
void renderConsoleGL()
|
||||||
{
|
{
|
||||||
consolem.lock();
|
//consolem.lock();
|
||||||
scope(exit) consolem.unlock();
|
//scope(exit) consolem.unlock();
|
||||||
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
glBindTexture(GL_TEXTURE_2D, GRPF.glTexture);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|||||||
Reference in New Issue
Block a user