Skip to content

Commit

Permalink
Release 0.5.3.5
Browse files Browse the repository at this point in the history
---------------
Made autorun by default when the appication is started.
  • Loading branch information
dtremblay committed Dec 23, 2020
1 parent e02c411 commit 58f5815
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 75 deletions.
3 changes: 2 additions & 1 deletion Main/Devices/BoardVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace FoenixIDE.Simulator.Devices
public enum BoardVersion
{
RevB,
RevC
RevC,
RevU
}
}
109 changes: 106 additions & 3 deletions Main/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,118 @@ static class Program
[STAThread]
static void Main(string[] args)
{
Dictionary<string, string> context = null;
bool OkToContinue = true;
if (args.Length > 0)
{
Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);
context = DecodeProgramArguments(args);
OkToContinue = "true".Equals(context["Continue"]);
}
if (OkToContinue)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainWindow(context));
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainWindow(args));
}

private static Dictionary<String,String> DecodeProgramArguments(string[] args)
{
Dictionary<string, string> context = new Dictionary<string, string>();
context.Add("Continue", "true");
for (int i = 0; i < args.Length; i++)
{
switch (args[i].Trim())
{
// the hex file to load is specified
case "-h":
case "--hex":
// a kernel file must be specified
if (args[i + 1].Trim().StartsWith("-") || !args[i + 1].Trim().EndsWith("hex"))
{
Console.Out.WriteLine("You must specify a hex file.");
context["Continue"] = "false";
}
context.Add("defaultKernel", args[i + 1]);
i++; // skip the next argument
break;
case "-j":
case "--jump":
// An address must be specified
int value = Convert.ToInt32(args[i + 1].Replace("$:", ""), 16);
if (value != 0)
{
context.Add("jumpStartAddress", value.ToString());
i++; // skip the next argument
}
else
{
Console.Out.WriteLine("Invalid address specified: " + args[i + 1]);
context["Continue"] = "false";
}
break;
// Autorun - a value is not expected for this one
case "-r":
case "--run":
string runValue = "true";
if (args.Length > (i + 1) && !args[i+1].StartsWith("-"))
{
runValue = args[i + 1];
if (!"true".Equals(runValue) && !"false".Equals(runValue))
{
runValue = "true";
}
i++; // skip the next argument
}
context.Add("autoRun", runValue);
break;
// Disable IRQs - a value is not expected for this one
case "-i":
case "--irq":
context.Add("disabledIRQs", "true");
break;
// Board Version B or C
case "-b":
case "--board":
string verArg = args[i + 1];
switch (verArg.ToLower())
{
case "b":
context.Add("version", "RevB");
break;
case "c":
context.Add("version", "RevC");
break;
case "u":
context.Add("version", "RevU");
break;
}
break;
case "--help":
DisplayUsage();
context["Continue"] = "false";
break;
default:
Console.Out.WriteLine("Unknown switch used:" + args[i].Trim());
DisplayUsage();
context["Continue"] = "false";
break;
}
}
return context;
}

static void DisplayUsage()
{
Console.Out.WriteLine("Foenix IDE Command Line Usage:");
Console.Out.WriteLine(" -h, --hex: kernel file name");
Console.Out.WriteLine(" -j, --jump: jump to specified address");
Console.Out.WriteLine(" -r, --run: autorun true/false");
Console.Out.WriteLine(" -i, --irq: disable IRQs true/false");
Console.Out.WriteLine(" -b, --board: board revision b, c or u");
Console.Out.WriteLine(" --help: show this usage");
}
static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
{
Application.Exit();
Expand Down
4 changes: 2 additions & 2 deletions Main/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.3.4")]
[assembly: AssemblyFileVersion("0.5.3.4")]
[assembly: AssemblyVersion("0.5.3.5")]
[assembly: AssemblyFileVersion("0.5.3.5")]
107 changes: 38 additions & 69 deletions Main/UI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,79 +43,48 @@ public partial class MainWindow : Form
private String defaultKernel = @"roms\kernel.hex";
private int jumpStartAddress;
private bool disabledIRQs = false;
private bool autoRun = false;
private bool autoRun = true;
private BoardVersion version = BoardVersion.RevC;
public static MainWindow Instance = null;
private delegate void WriteCPSFPSFunction(string CPS, string FPS);
private bool fullScreen = false;

public MainWindow(string[] programArgs)
public MainWindow(Dictionary<string, string> context)
{
if (programArgs.Length >0)
if (context != null)
{
DecodeProgramArguments(programArgs);
}
InitializeComponent();
Instance = this;
}

private void DecodeProgramArguments(string[] args)
{
for (int i = 0; i < args.Length; i++)
{
switch(args[i].Trim())
if (context.ContainsKey("jumpStartAddress"))
{
// the hex file to load is specified
case "-h":
case "--hex":
// a kernel file must be specified
if (args[i+1].Trim().StartsWith("-") || !args[i + 1].Trim().EndsWith("hex"))
{
throw new Exception("You must specify a hex file.");
}
defaultKernel = args[i+1];
i++; // skip the next argument
break;
case "-j":
case "--jump":
// An address must be specified
int value = Convert.ToInt32(args[i+1].Replace("$:", ""), 16);
if (value != 0)
{
jumpStartAddress = value;
i++; // skip the next argument
} else
{
throw new Exception("Invalid address specified: " + args[i + 1]);
}
break;
// Autorun - a value is not expected for this one
case "-r":
case "--run":
autoRun = true;
break;
// Disable IRQs - a value is not expected for this one
case "-i":
case "--irq":
disabledIRQs = true;
break;
// Board Version B or C
case "-b":
case "--board":
string verArg = args[i + 1];
switch (verArg.ToLower())
{
case "b":
version = BoardVersion.RevB;
break;
case "c":
version = BoardVersion.RevC;
break;
}
break;
default:
throw new Exception("Unknown switch used:" + args[i].Trim());
jumpStartAddress = int.Parse(context["jumpStartAddress"]);
}
if (context.ContainsKey("defaultKernel"))
{
defaultKernel = context["defaultKernel"];
}
if (context.ContainsKey("autoRun"))
{
autoRun = "true".Equals(context["autoRun"]);
}
if (context.ContainsKey("disabledIRQs"))
{
disabledIRQs = "true".Equals(context["disabledIRQs"]);
}
if (context.ContainsKey("version"))
{
if (context["version"] == "RevB")
{
version = BoardVersion.RevB;
}
else if (context["version"] == "RevU")
{
version = BoardVersion.RevU;
}
}
}
if (context == null || "true".Equals(context["Continue"]))
{
InitializeComponent();
Instance = this;
}
}

Expand All @@ -136,11 +105,6 @@ private void BasicWindow_Load(object sender, EventArgs e)
debugWindow.DisableIRQs(true);
}

if (autoRun)
{
debugWindow.RunButton_Click(null, null);
}

this.Top = 0;
this.Left = 0;
//this.Width = debugWindow.Left;
Expand All @@ -164,6 +128,11 @@ private void BasicWindow_Load(object sender, EventArgs e)
DisplayBoardVersion();
EnableMenuItems();
ResetSDCard();

if (autoRun)
{
debugWindow.RunButton_Click(null, null);
}
}

private void LoadHexFile(string Filename, bool ResetMemory)
Expand Down
Binary file modified bin/Release/FoenixIDE.exe
Binary file not shown.

0 comments on commit 58f5815

Please sign in to comment.