UserChannelPersistence.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. return _userChannelStorages.Pop();
  30. }
  31. public bool IsEmpty => _userChannelStorages.Count == 0;
  32. public void ExecuteProgram(ProgramSpecifyKind kind, ulong value)
  33. {
  34. Kind = kind;
  35. PreviousIndex = Index;
  36. switch (kind)
  37. {
  38. case ProgramSpecifyKind.ExecuteProgram:
  39. Index = (int)value;
  40. break;
  41. case ProgramSpecifyKind.RestartProgram:
  42. break;
  43. default:
  44. throw new NotImplementedException($"{kind} not implemented");
  45. }
  46. }
  47. }
  48. }