UserChannelPersistence.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Ryujinx.HLE.HOS
  5. {
  6. public class UserChannelPersistence
  7. {
  8. private Stack<byte[]> _userChannelStorages;
  9. public int PreviousIndex { get; private set; }
  10. public int Index { get; private set; }
  11. public ProgramSpecifyKind Kind { get; private set; }
  12. public UserChannelPersistence()
  13. {
  14. _userChannelStorages = new Stack<byte[]>();
  15. Kind = ProgramSpecifyKind.ExecuteProgram;
  16. PreviousIndex = -1;
  17. Index = 0;
  18. }
  19. public void Clear()
  20. {
  21. _userChannelStorages.Clear();
  22. }
  23. public void Push(byte[] data)
  24. {
  25. _userChannelStorages.Push(data);
  26. }
  27. public byte[] Pop()
  28. {
  29. _userChannelStorages.TryPop(out byte[] result);
  30. return result;
  31. }
  32. public bool IsEmpty => _userChannelStorages.Count == 0;
  33. public void ExecuteProgram(ProgramSpecifyKind kind, ulong value)
  34. {
  35. Kind = kind;
  36. PreviousIndex = Index;
  37. switch (kind)
  38. {
  39. case ProgramSpecifyKind.ExecuteProgram:
  40. Index = (int)value;
  41. break;
  42. case ProgramSpecifyKind.RestartProgram:
  43. break;
  44. default:
  45. throw new NotImplementedException($"{kind} not implemented");
  46. }
  47. }
  48. }
  49. }