Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Added support for more command-line arguments. Now you can pass in a …
Browse files Browse the repository at this point in the history
…list of disks with spaces or use -[d]isk path as a flag. The first disk path is automatically be mounted. See .gulp/tasks/launch.js for an example.
  • Loading branch information
jessefreeman committed Jan 4, 2021
1 parent ad6d6ef commit e27b6ea
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .gulp/tasks/launch.js
Expand Up @@ -4,7 +4,7 @@ let {run} = require('gulp-dotnet-cli');
gulp.task('build-run', ()=>{
return gulp.src(process.env.PROJECT, {read: false})
.pipe(run({
additionalArgs: ['Disks/PixelVisionOS/'],
additionalArgs: ['Disks/PixelVisionOS/', 'Disks/APIExamples/'], // ['-d', 'Disks/PixelVisionOS/', '-disk', 'Disks/APIExamples/']
echo: true
}));
});
Expand Down
10 changes: 5 additions & 5 deletions Program.cs
Expand Up @@ -9,13 +9,13 @@ public static class Program
[STAThread]
public static void Main(string[] args)
{
var root = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content");

using (var game = new DesktopRunner(root, args.Length > 0 ? args[0] : null))
var root = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content");

using (var game = new DesktopRunner(root, args))
{
game.Run();
}

}

}
}
}
6 changes: 3 additions & 3 deletions SDK/Engine/Chips/Game/GameChipLite.cs
Expand Up @@ -343,13 +343,13 @@ public void Clear()
/// the overscan value set on the display chip. To calculate the exact overscan in pixels, you must subtract
/// the full size from the visible size. Simply supply false as an argument to get the full display dimensions.
/// </summary>
public Point Display(bool visible = true)
public Point Display()
{
// offsetX = visible ? DisplayChip.OverscanXPixels : 0;
// offsetY = visible ? DisplayChip.OverscanYPixels : 0;

// display.X = display.X;// - offsetX;
// display.Y = display.Y;// - offsetY;
display.X = DisplayChip.Width;// - offsetX;
display.Y = DisplayChip.Height;// - offsetY;

return display;
}
Expand Down
2 changes: 1 addition & 1 deletion SDK/Lua/Chips/Game/LuaGameChip.cs
Expand Up @@ -73,7 +73,7 @@ protected virtual void RegisterLuaServices()
#region Display APIs

LuaScript.Globals["Clear"] = new Action(Clear);
LuaScript.Globals["Display"] = new Func<bool, Point>(Display);
LuaScript.Globals["Display"] = new Func<Point>(Display);
LuaScript.Globals["DrawPixels"] =
new Action<int[], int, int, int, int, bool, bool, DrawMode, int>(DrawPixels);
LuaScript.Globals["DrawSprite"] =
Expand Down
75 changes: 66 additions & 9 deletions SDK/Runner/DesktopRunner.cs
Expand Up @@ -114,7 +114,7 @@ public class DesktopRunner : GameRunner
public IServiceLocator ServiceManager { get; }
protected RunnerMode mode;
protected bool displayProgress;
private string bootDisk;
private List<string> bootDisks = new List<string>();

protected override bool RunnerActive
{
Expand All @@ -127,7 +127,7 @@ protected override bool RunnerActive
}

// Default path to where PV8 workspaces will go
public DesktopRunner(string rootPath, string bootDisk = null)
public DesktopRunner(string rootPath, string[] args = null)
{
// Fix a bug related to parsing numbers in Europe, among other things
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
Expand All @@ -139,10 +139,58 @@ public DesktopRunner(string rootPath, string bootDisk = null)
server = new MoonSharpVsCodeDebugServer(1985);
server.Start();

if (bootDisk != null && bootDisk.EndsWith(".pv8") ? File.Exists(bootDisk) : Directory.Exists(bootDisk))
if(args != null)
ParseArguments(args);

}

private void ParseArguments(string[] args)
{

if(args.Length == 0)
return;

if(args.Length == 1 && args[0].EndsWith(".pv8") ? File.Exists(args[0]) : Directory.Exists(args[0]))
{
this.bootDisk = bootDisk;
bootDisks.Add(args[0]);
}

var pairs = args.Length / 2;

for (int i = 0; i < pairs; i++)
{
try
{
var param = args[i * 2];
var val = args[i * 2 + 1];

switch(param){

case "-d": case "-disk":

bootDisks.Add(val);

break;
default:

for (int j = 0; j < args.Length; j++)
{
bootDisks.Add(args[j]);
}

break;

}

}
catch (System.Exception error)
{
Console.WriteLine("Issue with command line argumes");
throw;
}

}

}

protected MoonSharpVsCodeDebugServer server;
Expand Down Expand Up @@ -808,17 +856,26 @@ public void BootDone(bool safeMode = false)
}
}

if (bootDisk == null)
if (bootDisks.Count == 0)
{
AutoLoadDefaultGame();
}
else
{
// Force runner to auto run disk
autoRunEnabled = true;

// Mount the disk
MountDisk(bootDisk);
for (int i = 0; i < bootDisks.Count; i++)
{

// Force runner to auto run disk
autoRunEnabled = i == 0;

// Mount the disk
MountDisk(bootDisks[i]);

autoRunEnabled = true;

}

}

}
Expand Down
2 changes: 0 additions & 2 deletions SDK/Runner/Services/LoadService.cs
Expand Up @@ -89,8 +89,6 @@ public virtual void ParseFiles(string[] files, IEngine engine, SaveFlags saveFla
{
Reset();

Console.WriteLine("Font Test " + _fileLoadHelper.Exists("/PixelVisionOS/Tools/Fonts/large.font.png"));

// Save the engine so we can work with it during loading
targetEngine = engine;

Expand Down

0 comments on commit e27b6ea

Please sign in to comment.