Advertisement
Soneek

mymusic2txt.py

Jul 15th, 2015
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. from sys import argv
  2. from struct import unpack
  3. import string
  4. import SmashULib
  5.  
  6. # for use with bgm_mymusic.mmb
  7.  
  8. mymusic = open(argv[1], 'rb')
  9. assert mymusic.read(3) == "MMB"
  10.  
  11. mymusic.seek(8)
  12.  
  13. # Getting the amount of "stages" (some are just single song menus)
  14. count = unpack('<I', mymusic.read(4))[0]
  15. # Stage offset table starts at 0xc
  16. # Stage offset is 0xc + count * 4
  17. stageStartOffset = 0xc + count * 4
  18. for m in range(0,count):
  19.     mymusic.seek(0xc + m * 4)
  20.     offset = unpack('<I', mymusic.read(4))[0]
  21.     mymusic.seek(stageStartOffset + offset)
  22.     # 0x20 bytes are reserved for the stage string, and just removing null bytes for now
  23.     stage = string.replace(mymusic.read(0x20), "\x00", "")
  24.     print stage
  25.     songCount = unpack('<I', mymusic.read(4))[0]
  26.     for s in range(0, songCount):
  27.         # Each song entry for a stage is 0x3c bytes
  28.         mymusic.seek(stageStartOffset + offset + 0x24 + s * 0x3c)
  29.         songID = unpack('<I', mymusic.read(4))[0]
  30.         songSlot = unpack('<H', mymusic.read(2))[0]
  31.         # Skiping 0xffff
  32.         mymusic.seek(2, 1)
  33.         priority = unpack('<I', mymusic.read(4))[0]
  34.         print "\tSlot " + str(songSlot) + " -\t" + SmashULib.smashSongs[songID] + "\t" + str(priority) + "%"
  35.         # The final 0x30 bytes are 0xffff, followed by 0x2e bytes of 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement