From 60654d16e42f02853a4bae50c2e4d3d1a43ee3ed Mon Sep 17 00:00:00 2001 From: otya128 Date: Sun, 12 Jul 2015 13:12:07 +0900 Subject: [PATCH] =?UTF-8?q?=E7=B5=84=E3=81=BF=E8=BE=BC=E3=81=BF=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=97=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3,PRINT=E3=81=AE=E8=A7=A3=E6=9E=90=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3,PRINT=E3=81=ABmutex=E4=BD=BF=E3=81=86=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SMILEBASIC/VM.d | 2 +- SMILEBASIC/parser.d | 4 +++- SMILEBASIC/petitcomputer.d | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/SMILEBASIC/VM.d b/SMILEBASIC/VM.d index 8835b8c..3b614a8 100644 --- a/SMILEBASIC/VM.d +++ b/SMILEBASIC/VM.d @@ -885,6 +885,6 @@ class CallBuiltinFunction : Code result = vm.stack[vm.stacki - argcount..vm.stacki - argcount + outcount];//雑; } func.func(vm.petitcomputer, arg, result); - vm.stacki -= func.argments.length; + vm.stacki -= func.argments.length - outcount; } } diff --git a/SMILEBASIC/parser.d b/SMILEBASIC/parser.d index 47e3673..a27245e 100644 --- a/SMILEBASIC/parser.d +++ b/SMILEBASIC/parser.d @@ -1055,7 +1055,7 @@ class Parser //3号から厳密になって必ずいる if(token.type == TokenType.Colon || token.type == TokenType.NewLine) { - print.addLine(); + if(addline) print.addLine(); break; } addline = true; @@ -1091,12 +1091,14 @@ class Parser if(token.type == TokenType.Semicolon) { addline = false; + token = lex.front(); continue; } if(token.type == TokenType.Comma) { print.addTab(); addline = false; + token = lex.front(); continue; } token = lex.front(); diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index 4b27afe..45ec910 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -7,6 +7,7 @@ import std.stdio; import std.conv; import std.string; import std.c.stdio; +import core.sync.mutex; import otya.smilebasic.parser; class GraphicPage { @@ -358,6 +359,10 @@ DEF FACT(N) RETURN N*FACT(N-1) END"*/ `CLS : CL=0 : Z=0 +WHILE 1 +Z=Z+1 +?Z; +WEND WHILE 1 INC Z : IF Z>200 THEN Z=0 FOR I=0 TO 15 @@ -373,7 +378,7 @@ FOR I=0 TO 15 PRINT "Ё プチコン3ゴウ Ж" NEXT CL=(CL+1) MOD 16 : VSYNC 1 -WEND`*/ +WEND` /* `CLS : CL=0 @LOOP @@ -387,6 +392,7 @@ GOTO @LOOP`*/ auto vm = parser.compile(); bool running = true; vm.init(this); + consolem = new Mutex(); core.thread.Thread thread = new core.thread.Thread(&render); thread.start(); auto startTicks = SDL_GetTicks(); @@ -434,8 +440,11 @@ GOTO @LOOP`*/ int CSRY; int CSRZ; int consoleForeColor, consoleBackColor; + Mutex consolem; void renderConsole() { + consolem.lock(); + scope(exit) consolem.unlock(); for(int y = 0; y < consoleHeight; y++) for(int x = 0; x < consoleWidth; x++) { @@ -474,6 +483,9 @@ GOTO @LOOP`*/ } void printConsoleString(wstring text) { + consolem.lock(); + scope(exit) consolem.unlock(); + //write(text); foreach(wchar c; text) { if(CSRY >= consoleHeight) @@ -501,7 +513,7 @@ GOTO @LOOP`*/ } console[consoleHeight - 1] = tmp; tmp[] = ConsoleCharacter(0, consoleForeColor, consoleBackColor); - assert(console[0] != console[2]); + //assert(console[0] != console[2]); CSRY = consoleHeight - 1; } }