diff --git a/SMILEBASIC/console.d b/SMILEBASIC/console.d index da09186..09c9ee1 100644 --- a/SMILEBASIC/console.d +++ b/SMILEBASIC/console.d @@ -651,4 +651,20 @@ class Console petitcom.graphic.GRPFHeight = GRPF.surface.h; GRPF.createTexture(petitcom.renderer, petitcom.textureScaleMode); } -} \ No newline at end of file +} + +class NativeConsole : Console +{ + File file; + this(File file, PetitComputer p) + { + super(p); + this.file = file; + } + override void printString(wstring text) + { + super.printString(text); + file.write(text); + file.flush; + } +} diff --git a/SMILEBASIC/main.d b/SMILEBASIC/main.d index e8e9c45..30e64ef 100644 --- a/SMILEBASIC/main.d +++ b/SMILEBASIC/main.d @@ -12,7 +12,8 @@ int main(string[] argv) bool nodirectmode; string inputfile; bool antialiasing; - auto helpInformation = getopt(argv, "no-direct-mode", &nodirectmode, "file", &inputfile, "anti-aliasing", "Enable antialiasing.", &antialiasing); + bool redirectConsole; + auto helpInformation = getopt(argv, "redirect-console", &redirectConsole, "no-direct-mode", &nodirectmode, "file", &inputfile, "anti-aliasing", "Enable antialiasing.", &antialiasing); if (helpInformation.helpWanted) { defaultGetoptPrinter("Some information about the program.", @@ -22,7 +23,7 @@ int main(string[] argv) //try { auto pc = new PetitComputer(); - pc.run(nodirectmode, inputfile, antialiasing); + pc.run(nodirectmode, inputfile, antialiasing, redirectConsole); } /*(Throwable t) { diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index 1c69cba..03895d4 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -280,6 +280,7 @@ class PetitComputer } int[2] bgpage; Projects project; + bool redirectConsole; void init() { random = new Random(); @@ -313,7 +314,7 @@ class PetitComputer screenWidthDisplay1 = 320; screenHeightDisplay1 = 240; currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)]); - console = new Console(this); + console = redirectConsole ? new NativeConsole(std.stdio.stdout, this) : new Console(this); if(!exists(fontTableFile)) { writeln("create font table"); @@ -844,7 +845,7 @@ class PetitComputer renderCondition.notify(); } - while(true) + while(!quit) { auto profile = SDL_GetTicks(); if(console.showCursor) @@ -1127,7 +1128,7 @@ class PetitComputer bool isRunningDirectMode = false; GLenum textureScaleMode; int maincnt; - void run(bool nodirectmode = false, string inputfile = "", bool antialiasing = false) + void run(bool nodirectmode = false, string inputfile = "", bool antialiasing = false, bool redirectConsole = false) { if (antialiasing) { @@ -1137,6 +1138,7 @@ class PetitComputer { textureScaleMode = GL_NEAREST; } + this.redirectConsole = redirectConsole; buttonLock = new Object(); program = new Program(); keybuffer = new Key[128]; @@ -1359,6 +1361,8 @@ class PetitComputer } if(!running || stopflg) { + if (nodirectmode) + quit = true; if(stopflg) { loc = vm.currentLocation; diff --git a/appveyor.yml b/appveyor.yml index ac54b2d..bbe814a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -39,7 +39,7 @@ after_build: test_script: - cd c:\projects\otyaSMILEBASIC - - c:\projects\dub\dub.exe test -- -h + - c:\projects\dub\dub.exe test -- --no-direct-mode --file c:\projects\otyaSMILEBASIC\SMILEBASIC\TEST.TXT --redirect-console artifacts: - path: otyasmilebasic.zip