Beispiel #1
0
        static public void CoreRequestToBytes(MemoryByteStream stream, CoreRequest request)
        {
            switch (request.Type)
            {
            case CoreRequest.Types.KeyPress:
                stream.Write(_coreActionKeyPress);
                stream.Write(request.KeyCode);
                stream.Write(request.KeyDown);
                break;

            case CoreRequest.Types.Reset:
                stream.Write(_coreActionReset);
                break;

            case CoreRequest.Types.LoadDisc:
                stream.Write(_coreActionLoadDisc);
                stream.Write(request.Drive);
                stream.WriteArray(request.MediaBuffer.GetBytes());
                break;

            case CoreRequest.Types.LoadTape:
                stream.Write(_coreActionLoadTape);
                stream.WriteArray(request.MediaBuffer.GetBytes());
                break;

            case CoreRequest.Types.RunUntil:
                stream.Write(_coreActionRunUntil);
                stream.Write(request.StopTicks);
                break;

            case CoreRequest.Types.LoadCore:
                stream.Write(_coreActionLoadCore);
                stream.WriteArray(request.CoreState.GetBytes());
                break;

            case CoreRequest.Types.CoreVersion:
                stream.Write(_coreActionCoreVersion);
                stream.Write(request.Version);
                break;

            case CoreRequest.Types.CreateSnapshot:
                stream.Write(_coreActionCreateSnapshot);
                stream.Write(request.SnapshotId);
                break;

            case CoreRequest.Types.DeleteSnapshot:
                stream.Write(_coreActionDeleteSnapshot);
                stream.Write(request.SnapshotId);
                break;

            case CoreRequest.Types.RevertToSnapshot:
                stream.Write(_coreActionRevertToSnapshot);
                stream.Write(request.SnapshotId);
                break;

            default:
                throw new Exception(String.Format("Unknown CoreRequest type {0}!", request.Type));
            }
        }