Skip to content

Instantly share code, notes, and snippets.

@notwa
Created July 27, 2020 02:57
Show Gist options
  • Save notwa/122075846e1954c69fe6a93d26156fbc to your computer and use it in GitHub Desktop.
Save notwa/122075846e1954c69fe6a93d26156fbc to your computer and use it in GitHub Desktop.
# this code generated the text at https://wiki.cloudmodding.com/mm/File_List/U_1.0
from struct import unpack
# you'll probably want to change these:
filenames_filepath = "fn M US10.txt"
dmadata_filepath = "dump/mm-US10-d6133ace5afaa0882cf214cf88daba39e266c078/0002 V0001A500"
def readu32(f):
return unpack(">I", f.read(4))[0]
with open(filenames_filepath, "r") as f:
names = [line.strip() for line in f.readlines()]
table = []
with open(dmadata_filepath, "rb") as f:
eof = f.seek(0, 2)
f.seek(0, 0)
while f.tell() != eof: # ugh python why can't you just tell me
row = [readu32(f), readu32(f), readu32(f), readu32(f)]
if row == [0, 0, 0, 0]:
break
table.append(row)
table_header = """
{| class="wikitable" style="text-align: center; font-family: monospace; margin: left;"
! rowspan=2 | Dec.
! rowspan=2 | Hex
! colspan=2 | VROM
! colspan=2 | ROM
! rowspan=2 | Size
! rowspan=2 | File Name
|-
! Start
! End
! Start
! End
"""[1:-1]
#! rowspan=2 | Contents
table_footer = "|}"
def dumprow(i, row, name, human_name, links=True):
print("|-")
print("| {:04}".format(i))
print("| {:04X}".format(i))
size = row[1] - row[0]
print("| {:08X}".format(row[0]))
print("| {:08X}".format(row[1]))
print("| {:08X}".format(row[2]))
print("| {:08X}".format(row[3]))
print("| {:08X}".format(size))
if links:
print('| style="text-align: left;" | [[{}]]'.format(name))
else:
print('| style="text-align: left;" | {}'.format(name))
#print('| style="text-align: left;" | {}'.format(human_name))
print("{{subpage}}")
print("The original releases of ''Majora's Mask'' contain relatively few file names. In order to compile the list below, additional names have been procured by cross-referencing data from the ''Majora's Mask'' Debug ROM, ''Majora's Mask 3D'', and the ''Ocarina of Time'' Debug ROM, and then applied to the files retroactively.")
def dumpsome(a, b, links=False):
print(table_header)
for i in range(a, b + 1):
row = table[i]
name = names[i].strip()
dumprow(i, row, name, "TODO", links=links)
print(table_footer)
print()
print("==File 0000 to 0031 (Various)==")
print()
dumpsome(0, 31)
print()
print("==File 0032 to 0648 (Actors)==")
print()
print("For further information on the actors below, please view the individual file pages, or see the [[Actor List]].")
print()
dumpsome(32, 648)
print()
print("==File 0649 to 1113 (Objects)==")
print()
print("For further information on the objects below, please view the individual file pages, or see the [[Object List]].")
dumpsome(649, 1113)
print()
print("==File 1114 to 1136 (Various)==")
print()
dumpsome(1114, 1136)
print()
print("==File 1137 to 1537 (Scenes & Rooms)==")
print()
dumpsome(1137, 1537, links=False)
print()
print("==File 1538 to 1551 (Various)==")
print()
dumpsome(1538, 1551, links=False)
print()
print("[[Category: File Listings]]")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment