Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified __pycache__/util.cpython-37.pyc
Binary file not shown.
30 changes: 20 additions & 10 deletions msbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,19 @@ def parseMSB(fname):
elif seg_id == 'TXT2':
parsed['TXT2'] = []
count = struct.unpack('>i',seg_data[:4])[0]
for i in range(count):
ptr = struct.unpack('>i',seg_data[4+4*i:0x8+4*i])[0]
parsed['TXT2'].append(seg_data[ptr:].decode('utf-16be').split('\x00',1)[0])
ptrlist=[struct.unpack('>i',seg_data[4+4*i:0x8+4*i])[0] for i in range(count)]
for (i, ptr) in enumerate(ptrlist):
if len(ptrlist) == i+1:
ptrend=0
else:
ptrend=ptrlist[i+1]
text = seg_data[ptr:ptrend-2].decode('utf-16-be')
parsed['TXT2'].append(text)
#for i in range(count):
# ptr = struct.unpack('>i',seg_data[4+4*i:0x8+4*i])[0]
# text = seg_data[ptr:].decode('utf-16be')
# print(seg_data[ptr-10:ptr])
# parsed['TXT2'].append(text.split('\x00',1)[0])
else:
raise Exception('unimplemented '+seg_id)
return parsed
Expand Down Expand Up @@ -172,13 +182,13 @@ def printEvflFile(file,parsed,parsedMsbt):
f2=open('output/event/'+fname.split(os.sep)[-1].replace('.msbf','.json'),'w', encoding='utf-16le')
f2.write(objToJson(parsed))
f2.close()
f2=open('output/event2/'+fname.split(os.sep)[-1].replace('.msbf','.c'),'w', encoding='utf-16le')
f2=open('output/event2/'+fname.split(os.sep)[-1].replace('.msbf','.c'),'w', encoding='utf-8')
printEvflFile(f2,parsed,parsedMsbt)
f2.close()

print('-----------------------------------------------')
print('50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F')
print('-----------------------------------------------')
for i in range(len(flagindex_names)):
print(flagindex_names[i])
printHex(cumulative_flags_set[i])
#print('-----------------------------------------------')
#print('50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F')
#print('-----------------------------------------------')
#for i in range(len(flagindex_names)):
# print(flagindex_names[i])
# printHex(cumulative_flags_set[i])
Binary file modified output/event2/002-System.c
Binary file not shown.
Binary file modified output/event2/003-ItemGet.c
Binary file not shown.
Binary file modified output/event2/004-Object.c
Binary file not shown.
Binary file modified output/event2/006-1KenseiNormal.c
Binary file not shown.
Binary file modified output/event2/006-2KenseiNormal.c
Binary file not shown.
Binary file modified output/event2/006-3KenseiNormal.c
Binary file not shown.
Binary file modified output/event2/006-4KenseiNormal.c
Binary file not shown.
Binary file modified output/event2/006-5KenseiNormal.c
Binary file not shown.
Binary file modified output/event2/006-6KenseiNormal.c
Binary file not shown.
Binary file modified output/event2/006-7KenseiNormal.c
Binary file not shown.
Binary file modified output/event2/006-8KenseiNormal.c
Binary file not shown.
Binary file modified output/event2/006-9KenseiNormal.c
Binary file not shown.
Binary file modified output/event2/006-KenseiNormal.c
Binary file not shown.
Binary file modified output/event2/008-Hint.c
Binary file not shown.
Binary file modified output/event2/100-Town.c
Binary file not shown.
Binary file modified output/event2/101-Shop.c
Binary file not shown.
Binary file modified output/event2/102-Zelda.c
Binary file not shown.
Binary file modified output/event2/103-DaiShinkan.c
Binary file not shown.
Binary file modified output/event2/104-Rival.c
Binary file not shown.
Binary file modified output/event2/105-Terry.c
Binary file not shown.
Binary file modified output/event2/106-DrugStore.c
Binary file not shown.
Binary file modified output/event2/107-Kanban.c
Binary file not shown.
Binary file modified output/event2/108-ShinkanA.c
Binary file not shown.
Binary file modified output/event2/109-TakeGoron.c
Binary file not shown.
Binary file modified output/event2/110-DivingGame.c
Binary file not shown.
Binary file modified output/event2/111-FortuneTeller.c
Binary file not shown.
Binary file modified output/event2/112-Trustee.c
Binary file not shown.
Binary file modified output/event2/113-RemodelStore.c
Binary file not shown.
Binary file modified output/event2/114-Friend.c
Binary file not shown.
Binary file modified output/event2/115-Town2.c
Binary file not shown.
Binary file modified output/event2/116-InsectGame.c
Binary file not shown.
Binary file modified output/event2/117-Pumpkin.c
Binary file not shown.
Binary file modified output/event2/118-Town3.c
Binary file not shown.
Binary file modified output/event2/119-Captain.c
Binary file not shown.
Binary file modified output/event2/120-Nushi.c
Binary file not shown.
Binary file modified output/event2/121-AkumaKun.c
Binary file not shown.
Binary file modified output/event2/122-Town4.c
Binary file not shown.
Binary file modified output/event2/123-Town5.c
Binary file not shown.
Binary file modified output/event2/124-Town6.c
Binary file not shown.
Binary file modified output/event2/125-D3.c
Binary file not shown.
Binary file modified output/event2/150-Siren.c
Binary file not shown.
Binary file modified output/event2/199-Demo.c
Binary file not shown.
Binary file modified output/event2/200-Forest.c
Binary file not shown.
Binary file modified output/event2/201-ForestD1.c
Binary file not shown.
Binary file modified output/event2/202-ForestD2.c
Binary file not shown.
Binary file modified output/event2/203-ForestF2.c
Binary file not shown.
Binary file modified output/event2/204-ForestF3.c
Binary file not shown.
Binary file modified output/event2/250-ForestSiren.c
Binary file not shown.
Binary file modified output/event2/251-Salvage.c
Binary file not shown.
Binary file modified output/event2/299-Demo.c
Binary file not shown.
Binary file modified output/event2/300-Mountain.c
Binary file not shown.
Binary file modified output/event2/301-MountainD1.c
Binary file not shown.
Binary file modified output/event2/302-Anahori.c
Binary file not shown.
Binary file modified output/event2/303-MountainF2.c
Binary file not shown.
Binary file modified output/event2/304-MountainD2.c
Binary file not shown.
Binary file modified output/event2/305-MountainF3.c
Binary file not shown.
Binary file modified output/event2/350-MountainSiren.c
Binary file not shown.
Binary file modified output/event2/351-Salvage.c
Binary file not shown.
Binary file modified output/event2/399-Demo.c
Binary file not shown.
Binary file modified output/event2/400-Desert.c
Binary file not shown.
Binary file modified output/event2/401-DesertD2.c
Binary file not shown.
Binary file modified output/event2/402-DesertF2.c
Binary file not shown.
Binary file modified output/event2/403-DesertD1.c
Binary file not shown.
Binary file modified output/event2/404-DesertF3.c
Binary file not shown.
Binary file modified output/event2/405-DesertD2Clear.c
Binary file not shown.
Binary file modified output/event2/406-TrolleyRace.c
Binary file not shown.
Binary file modified output/event2/450-DesertSiren.c
Binary file not shown.
Binary file modified output/event2/451-Salvage.c
Binary file not shown.
Binary file modified output/event2/460-RairyuMinigame.c
Binary file not shown.
Binary file modified output/event2/499-Demo.c
Binary file not shown.
Binary file modified output/event2/500-CenterField.c
Binary file not shown.
Binary file modified output/event2/501-Inpa.c
Binary file not shown.
Binary file modified output/event2/502-CenterFieldBack.c
Binary file not shown.
Binary file modified output/event2/503-Goron.c
Binary file not shown.
Binary file modified output/event2/510-Salvage.c
Binary file not shown.
Binary file modified output/event2/599-Demo.c
Binary file not shown.
37 changes: 37 additions & 0 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,43 @@ def setBit(bytestr, bitindex):
bits[(bitindex//8)^1] |= (1 << (bitindex%8))
return bitOr(bytestr, bits)

fix=[(1,'01'),(1,'02'),(1,'04'),(1,'08'),(1,'10'),(1,'20'),(1,'40'),(1,'80'),(0,'01'),(0,'02'),(0,'04'),(0,'08'),(0,'10'),(0,'20'),(0,'40'),(0,'80')]
def idx_to_scene_flag(idx):
rest=idx%16
return '0x{:01X} '.format(idx//16*2+fix[rest][0])+str(fix[rest][1])

flagindex_to_stages = [
["D000","F000","F001r","F002r","F004r","F005r","F006r","F007r",
"F008r","F009r","F012r","F013r","F014r","F015r","F016r","F017r","F018r"],
["F100","F100_1","F101"],
["F102","F102_1","F102_2"],
["F103","F103_1"],
["F200","F202_3","F202_4","F210","F211"],
["F201_1","F201_2","F201_3","F201_4","F202","F202_1","F202_2","F221"],
# unused
[],
["F300","F300_1","F300_2","F300_3","F300_4"],
["F301","F301_1","F301_2","F301_3","F301_4","F301_5","F301_6","F301_7"],
["F302","F303"],
["B400","F400","F401","F402","F403","F404","F406","F407"],
["B100","B100_1","D100"],
["B101","B101_1","D101"],
# unused
[],
["B200","B210","D200"],
["B201","B201_1","D201","D201_1"],
[],
["D300","D300_1","B300","F300_5"],
["B301","D301","D301_1"],
[],
["D003_0","D003_1","D003_2","D003_3","D003_4","D003_5",
"D003_6","D003_7","D003_8"],
["F010r","F011r","F019r","F020","F023"],
["S100"],
["S200"],
["S300"],
["S000"]]

flagindex_names = ["Skyloft",
"Faron Woods",
"Lake Floria",
Expand Down