mirror of
https://github.com/livingcomputermuseum/ContrAlto.git
synced 2026-03-06 19:11:42 +00:00
Initial commit of changes for 1.2.3. This includes:
- Scripting support: Allows for recording and playback of mouse/keyboard input and various system control actions. Simple (i.e. basic) scripting format. - Fix for stale packets left in ethernet input queue; packets received by pcap while Alto's receiver is off are discarded. - Mouse input made more accurate, and tweaked to avoid Alto microcode bug that causes erroneous mouse inputs under very rare circumstances on real hardware, but much more frequently under emulation. - Small code cleanup here and there. Moved many UI strings to resources, many more to go.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
along with ContrAlto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Contralto.Scripting;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
@@ -23,6 +24,22 @@ namespace Contralto
|
||||
|
||||
public delegate bool StepCallbackDelegate();
|
||||
public delegate void ErrorCallbackDelegate(Exception e);
|
||||
public delegate void ShutdownCallbackDelegate(bool commitDisks);
|
||||
|
||||
public class ShutdownException : Exception
|
||||
{
|
||||
public ShutdownException(bool commitDisks) : base()
|
||||
{
|
||||
_commitDisks = commitDisks;
|
||||
}
|
||||
|
||||
public bool CommitDisks
|
||||
{
|
||||
get { return _commitDisks; }
|
||||
}
|
||||
|
||||
private bool _commitDisks;
|
||||
}
|
||||
|
||||
|
||||
public class ExecutionController
|
||||
@@ -46,29 +63,56 @@ namespace Contralto
|
||||
{
|
||||
_userAbort = true;
|
||||
|
||||
if (_execThread != null)
|
||||
if (System.Threading.Thread.CurrentThread !=
|
||||
_execThread)
|
||||
{
|
||||
_execThread.Join();
|
||||
_execThread = null;
|
||||
//
|
||||
// Call is asynchronous, we will wait for the
|
||||
// execution thread to finish.
|
||||
//
|
||||
if (_execThread != null)
|
||||
{
|
||||
_execThread.Join();
|
||||
_execThread = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset(AlternateBootType bootType)
|
||||
{
|
||||
bool running = IsRunning;
|
||||
|
||||
if (running)
|
||||
if (System.Threading.Thread.CurrentThread ==
|
||||
_execThread)
|
||||
{
|
||||
StopExecution();
|
||||
//
|
||||
// Call is from within the execution thread
|
||||
// so we can just reset the system without worrying
|
||||
// about synchronization.
|
||||
//
|
||||
_system.Reset();
|
||||
_system.PressBootKeys(bootType);
|
||||
}
|
||||
_system.Reset();
|
||||
_system.PressBootKeys(bootType);
|
||||
|
||||
if (running)
|
||||
else
|
||||
{
|
||||
StartExecution(AlternateBootType.None);
|
||||
//
|
||||
// Call is asynchronous, we need to stop the
|
||||
// execution thread and restart it after resetting
|
||||
// the system.
|
||||
//
|
||||
bool running = IsRunning;
|
||||
|
||||
if (running)
|
||||
{
|
||||
StopExecution();
|
||||
}
|
||||
_system.Reset();
|
||||
_system.PressBootKeys(bootType);
|
||||
|
||||
if (running)
|
||||
{
|
||||
StartExecution(AlternateBootType.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRunning
|
||||
{
|
||||
@@ -87,6 +131,12 @@ namespace Contralto
|
||||
set { _errorCallback = value; }
|
||||
}
|
||||
|
||||
public ShutdownCallbackDelegate ShutdownCallback
|
||||
{
|
||||
get { return _shutdownCallback; }
|
||||
set { _shutdownCallback = value; }
|
||||
}
|
||||
|
||||
private void StartAltoExecutionThread()
|
||||
{
|
||||
if (_execThread != null && _execThread.IsAlive)
|
||||
@@ -104,11 +154,29 @@ namespace Contralto
|
||||
private void ExecuteProc()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
{
|
||||
// Execute a single microinstruction
|
||||
try
|
||||
{
|
||||
_system.SingleStep();
|
||||
|
||||
if (ScriptManager.IsPlaying ||
|
||||
ScriptManager.IsRecording)
|
||||
{
|
||||
ScriptManager.ScriptScheduler.Clock();
|
||||
}
|
||||
}
|
||||
catch(ShutdownException s)
|
||||
{
|
||||
//
|
||||
// We will only actually shut down if someone
|
||||
// is listening to this event.
|
||||
//
|
||||
if (_shutdownCallback != null)
|
||||
{
|
||||
_shutdownCallback(s.CommitDisks);
|
||||
_execAbort = true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -139,6 +207,7 @@ namespace Contralto
|
||||
|
||||
private StepCallbackDelegate _stepCallback;
|
||||
private ErrorCallbackDelegate _errorCallback;
|
||||
private ShutdownCallbackDelegate _shutdownCallback;
|
||||
|
||||
private AltoSystem _system;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user