1
0

Add --redirect-console option

This commit is contained in:
otya128
2017-07-08 17:41:31 +09:00
parent 18719c0c17
commit 2076af47f6
4 changed files with 28 additions and 7 deletions

View File

@@ -652,3 +652,19 @@ class Console
GRPF.createTexture(petitcom.renderer, petitcom.textureScaleMode); GRPF.createTexture(petitcom.renderer, petitcom.textureScaleMode);
} }
} }
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;
}
}

View File

@@ -12,7 +12,8 @@ int main(string[] argv)
bool nodirectmode; bool nodirectmode;
string inputfile; string inputfile;
bool antialiasing; 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) if (helpInformation.helpWanted)
{ {
defaultGetoptPrinter("Some information about the program.", defaultGetoptPrinter("Some information about the program.",
@@ -22,7 +23,7 @@ int main(string[] argv)
//try //try
{ {
auto pc = new PetitComputer(); auto pc = new PetitComputer();
pc.run(nodirectmode, inputfile, antialiasing); pc.run(nodirectmode, inputfile, antialiasing, redirectConsole);
} }
/*(Throwable t) /*(Throwable t)
{ {

View File

@@ -280,6 +280,7 @@ class PetitComputer
} }
int[2] bgpage; int[2] bgpage;
Projects project; Projects project;
bool redirectConsole;
void init() void init()
{ {
random = new Random(); random = new Random();
@@ -313,7 +314,7 @@ class PetitComputer
screenWidthDisplay1 = 320; screenWidthDisplay1 = 320;
screenHeightDisplay1 = 240; screenHeightDisplay1 = 240;
currentDisplay = Display([SDL_Rect(0, 0, screenWidth, screenHeight)]); 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)) if(!exists(fontTableFile))
{ {
writeln("create font table"); writeln("create font table");
@@ -844,7 +845,7 @@ class PetitComputer
renderCondition.notify(); renderCondition.notify();
} }
while(true) while(!quit)
{ {
auto profile = SDL_GetTicks(); auto profile = SDL_GetTicks();
if(console.showCursor) if(console.showCursor)
@@ -1127,7 +1128,7 @@ class PetitComputer
bool isRunningDirectMode = false; bool isRunningDirectMode = false;
GLenum textureScaleMode; GLenum textureScaleMode;
int maincnt; 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) if (antialiasing)
{ {
@@ -1137,6 +1138,7 @@ class PetitComputer
{ {
textureScaleMode = GL_NEAREST; textureScaleMode = GL_NEAREST;
} }
this.redirectConsole = redirectConsole;
buttonLock = new Object(); buttonLock = new Object();
program = new Program(); program = new Program();
keybuffer = new Key[128]; keybuffer = new Key[128];
@@ -1359,6 +1361,8 @@ class PetitComputer
} }
if(!running || stopflg) if(!running || stopflg)
{ {
if (nodirectmode)
quit = true;
if(stopflg) if(stopflg)
{ {
loc = vm.currentLocation; loc = vm.currentLocation;

View File

@@ -39,7 +39,7 @@ after_build:
test_script: test_script:
- cd c:\projects\otyaSMILEBASIC - 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: artifacts:
- path: otyasmilebasic.zip - path: otyasmilebasic.zip