Advertisement
rubixcuber

MWL Music

Jan 24th, 2021
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. private void SetMWLMusic(string path, byte music)
  2. {
  3.  
  4. int o, o2, o3, o4;
  5. int obj, ext;
  6.  
  7. BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Write));
  8. BinaryWriter writer = new BinaryWriter(File.Open(path, FileMode.Open, FileAccess.Write, FileShare.Read));
  9.  
  10. try
  11. {
  12. reader.BaseStream.Seek(4, SeekOrigin.Begin);
  13. o = reader.ReadInt32() + 8;
  14. reader.BaseStream.Seek(o, SeekOrigin.Begin);
  15. o = reader.ReadInt32() + 5 + 8;
  16. reader.BaseStream.Seek(o, SeekOrigin.Begin);
  17.  
  18. while (true)
  19. {
  20. o = reader.ReadByte();
  21. if (o == 0xFF)
  22. {
  23. reader.Close();
  24. writer.Close();
  25. return;
  26. }
  27.  
  28. o2 = reader.ReadByte();
  29. o3 = reader.ReadByte();
  30.  
  31. obj = (o & 0x60) / 2 | (o2 & 0xF0) / 16;
  32.  
  33. if (obj == 0)
  34. {
  35. ext = o3;
  36. if (ext == 0)
  37. {
  38. o4 = reader.ReadByte();
  39. }
  40. if (ext == 2)
  41. {
  42. o4 = reader.ReadByte();
  43. o4 = reader.ReadByte();
  44. }
  45. }
  46. else
  47. {
  48. switch (obj)
  49. {
  50. case 0x22:
  51. case 0x23:
  52. o4 = reader.ReadByte();
  53. break;
  54. case 0x26:
  55. long off = reader.BaseStream.Position - 1;
  56. writer.Seek((int)(off), SeekOrigin.Begin);
  57. writer.Write((byte)(music+1));
  58.  
  59. reader.Close();
  60. writer.Close();
  61. return;
  62. case 0x27:
  63. case 0x29:
  64. o4 = reader.ReadByte();
  65. o4 &= 0xC0;
  66.  
  67. switch (o4)
  68. {
  69. case 0x00:
  70. case 0x40:
  71. o4 = reader.ReadByte();
  72. break;
  73. case 0x80:
  74. o4 = reader.ReadByte();
  75. o4 = reader.ReadByte();
  76. break;
  77. case 0xC0:
  78. o4 = reader.ReadByte();
  79. o4 = reader.ReadByte();
  80. o4 = reader.ReadByte();
  81. break;
  82. }
  83.  
  84. break;
  85. case 0x2D:
  86. o4 = reader.ReadByte();
  87. o4 = reader.ReadByte();
  88. break;
  89. }
  90. }
  91. }
  92. }
  93. catch (Exception e)
  94. {
  95.  
  96. }
  97. reader.Close();
  98. writer.Close();
  99.  
  100. return;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement