diff --git a/__pycache__/util.cpython-37.pyc b/__pycache__/util.cpython-37.pyc index 6d4c95cd..10bdc09e 100644 Binary files a/__pycache__/util.cpython-37.pyc and b/__pycache__/util.cpython-37.pyc differ diff --git a/msbf.py b/msbf.py index 90345ff9..5aede1b8 100644 --- a/msbf.py +++ b/msbf.py @@ -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 @@ -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]) diff --git a/output/event2/002-System.c b/output/event2/002-System.c index d8503197..2ba55b9d 100644 Binary files a/output/event2/002-System.c and b/output/event2/002-System.c differ diff --git a/output/event2/003-ItemGet.c b/output/event2/003-ItemGet.c index d5457930..adea414d 100644 Binary files a/output/event2/003-ItemGet.c and b/output/event2/003-ItemGet.c differ diff --git a/output/event2/004-Object.c b/output/event2/004-Object.c index 4031dafd..84903e4e 100644 Binary files a/output/event2/004-Object.c and b/output/event2/004-Object.c differ diff --git a/output/event2/006-1KenseiNormal.c b/output/event2/006-1KenseiNormal.c index 9e39d66c..7abfcebd 100644 Binary files a/output/event2/006-1KenseiNormal.c and b/output/event2/006-1KenseiNormal.c differ diff --git a/output/event2/006-2KenseiNormal.c b/output/event2/006-2KenseiNormal.c index 624c0021..4bb82cd0 100644 Binary files a/output/event2/006-2KenseiNormal.c and b/output/event2/006-2KenseiNormal.c differ diff --git a/output/event2/006-3KenseiNormal.c b/output/event2/006-3KenseiNormal.c index 16724a14..4c69be2b 100644 Binary files a/output/event2/006-3KenseiNormal.c and b/output/event2/006-3KenseiNormal.c differ diff --git a/output/event2/006-4KenseiNormal.c b/output/event2/006-4KenseiNormal.c index f95e884a..d494b407 100644 Binary files a/output/event2/006-4KenseiNormal.c and b/output/event2/006-4KenseiNormal.c differ diff --git a/output/event2/006-5KenseiNormal.c b/output/event2/006-5KenseiNormal.c index 3e622358..b34c7843 100644 Binary files a/output/event2/006-5KenseiNormal.c and b/output/event2/006-5KenseiNormal.c differ diff --git a/output/event2/006-6KenseiNormal.c b/output/event2/006-6KenseiNormal.c index 7f576b34..4ac31bee 100644 Binary files a/output/event2/006-6KenseiNormal.c and b/output/event2/006-6KenseiNormal.c differ diff --git a/output/event2/006-7KenseiNormal.c b/output/event2/006-7KenseiNormal.c index de576a7b..48f7f8cb 100644 Binary files a/output/event2/006-7KenseiNormal.c and b/output/event2/006-7KenseiNormal.c differ diff --git a/output/event2/006-8KenseiNormal.c b/output/event2/006-8KenseiNormal.c index 3123c364..5fb5b116 100644 Binary files a/output/event2/006-8KenseiNormal.c and b/output/event2/006-8KenseiNormal.c differ diff --git a/output/event2/006-9KenseiNormal.c b/output/event2/006-9KenseiNormal.c index 28ee5627..e8bb6ed4 100644 Binary files a/output/event2/006-9KenseiNormal.c and b/output/event2/006-9KenseiNormal.c differ diff --git a/output/event2/006-KenseiNormal.c b/output/event2/006-KenseiNormal.c index 52885245..79022605 100644 Binary files a/output/event2/006-KenseiNormal.c and b/output/event2/006-KenseiNormal.c differ diff --git a/output/event2/008-Hint.c b/output/event2/008-Hint.c index 176cc5c3..0b29baec 100644 Binary files a/output/event2/008-Hint.c and b/output/event2/008-Hint.c differ diff --git a/output/event2/100-Town.c b/output/event2/100-Town.c index d8f34a16..6ffd3469 100644 Binary files a/output/event2/100-Town.c and b/output/event2/100-Town.c differ diff --git a/output/event2/101-Shop.c b/output/event2/101-Shop.c index 0d0dae00..f16cd7c4 100644 Binary files a/output/event2/101-Shop.c and b/output/event2/101-Shop.c differ diff --git a/output/event2/102-Zelda.c b/output/event2/102-Zelda.c index 2fc5ab10..25aa2f01 100644 Binary files a/output/event2/102-Zelda.c and b/output/event2/102-Zelda.c differ diff --git a/output/event2/103-DaiShinkan.c b/output/event2/103-DaiShinkan.c index abcd97b4..545a7dd4 100644 Binary files a/output/event2/103-DaiShinkan.c and b/output/event2/103-DaiShinkan.c differ diff --git a/output/event2/104-Rival.c b/output/event2/104-Rival.c index 09e7ab91..07b905a4 100644 Binary files a/output/event2/104-Rival.c and b/output/event2/104-Rival.c differ diff --git a/output/event2/105-Terry.c b/output/event2/105-Terry.c index 9c92a837..e27be47b 100644 Binary files a/output/event2/105-Terry.c and b/output/event2/105-Terry.c differ diff --git a/output/event2/106-DrugStore.c b/output/event2/106-DrugStore.c index bc292657..f295086e 100644 Binary files a/output/event2/106-DrugStore.c and b/output/event2/106-DrugStore.c differ diff --git a/output/event2/107-Kanban.c b/output/event2/107-Kanban.c index dfeb5f51..327d07c8 100644 Binary files a/output/event2/107-Kanban.c and b/output/event2/107-Kanban.c differ diff --git a/output/event2/108-ShinkanA.c b/output/event2/108-ShinkanA.c index f42dec30..2cad1114 100644 Binary files a/output/event2/108-ShinkanA.c and b/output/event2/108-ShinkanA.c differ diff --git a/output/event2/109-TakeGoron.c b/output/event2/109-TakeGoron.c index 57351b05..89ad6b5d 100644 Binary files a/output/event2/109-TakeGoron.c and b/output/event2/109-TakeGoron.c differ diff --git a/output/event2/110-DivingGame.c b/output/event2/110-DivingGame.c index 294bd467..4314f433 100644 Binary files a/output/event2/110-DivingGame.c and b/output/event2/110-DivingGame.c differ diff --git a/output/event2/111-FortuneTeller.c b/output/event2/111-FortuneTeller.c index 56f600e4..4c2a1751 100644 Binary files a/output/event2/111-FortuneTeller.c and b/output/event2/111-FortuneTeller.c differ diff --git a/output/event2/112-Trustee.c b/output/event2/112-Trustee.c index 68601b26..de3ea955 100644 Binary files a/output/event2/112-Trustee.c and b/output/event2/112-Trustee.c differ diff --git a/output/event2/113-RemodelStore.c b/output/event2/113-RemodelStore.c index e980461f..1091c938 100644 Binary files a/output/event2/113-RemodelStore.c and b/output/event2/113-RemodelStore.c differ diff --git a/output/event2/114-Friend.c b/output/event2/114-Friend.c index 48ac505e..694626df 100644 Binary files a/output/event2/114-Friend.c and b/output/event2/114-Friend.c differ diff --git a/output/event2/115-Town2.c b/output/event2/115-Town2.c index 9e866b74..b54668a1 100644 Binary files a/output/event2/115-Town2.c and b/output/event2/115-Town2.c differ diff --git a/output/event2/116-InsectGame.c b/output/event2/116-InsectGame.c index 76dded03..582575e4 100644 Binary files a/output/event2/116-InsectGame.c and b/output/event2/116-InsectGame.c differ diff --git a/output/event2/117-Pumpkin.c b/output/event2/117-Pumpkin.c index 7dafe8ec..3bd432f0 100644 Binary files a/output/event2/117-Pumpkin.c and b/output/event2/117-Pumpkin.c differ diff --git a/output/event2/118-Town3.c b/output/event2/118-Town3.c index 6fde8e62..352dc3e3 100644 Binary files a/output/event2/118-Town3.c and b/output/event2/118-Town3.c differ diff --git a/output/event2/119-Captain.c b/output/event2/119-Captain.c index 7561ec8e..0a211326 100644 Binary files a/output/event2/119-Captain.c and b/output/event2/119-Captain.c differ diff --git a/output/event2/120-Nushi.c b/output/event2/120-Nushi.c index 932152b2..915effe7 100644 Binary files a/output/event2/120-Nushi.c and b/output/event2/120-Nushi.c differ diff --git a/output/event2/121-AkumaKun.c b/output/event2/121-AkumaKun.c index ee0395d7..ab5308fd 100644 Binary files a/output/event2/121-AkumaKun.c and b/output/event2/121-AkumaKun.c differ diff --git a/output/event2/122-Town4.c b/output/event2/122-Town4.c index f52e3511..12e3de19 100644 Binary files a/output/event2/122-Town4.c and b/output/event2/122-Town4.c differ diff --git a/output/event2/123-Town5.c b/output/event2/123-Town5.c index 58ddca05..3e10e6a4 100644 Binary files a/output/event2/123-Town5.c and b/output/event2/123-Town5.c differ diff --git a/output/event2/124-Town6.c b/output/event2/124-Town6.c index 01c26ec3..b6c92fe3 100644 Binary files a/output/event2/124-Town6.c and b/output/event2/124-Town6.c differ diff --git a/output/event2/125-D3.c b/output/event2/125-D3.c index 82e883a4..97e10d0c 100644 Binary files a/output/event2/125-D3.c and b/output/event2/125-D3.c differ diff --git a/output/event2/150-Siren.c b/output/event2/150-Siren.c index b5e0ec4e..9038cadb 100644 Binary files a/output/event2/150-Siren.c and b/output/event2/150-Siren.c differ diff --git a/output/event2/199-Demo.c b/output/event2/199-Demo.c index 5296613d..4bd176c0 100644 Binary files a/output/event2/199-Demo.c and b/output/event2/199-Demo.c differ diff --git a/output/event2/200-Forest.c b/output/event2/200-Forest.c index 910e5d48..ec338210 100644 Binary files a/output/event2/200-Forest.c and b/output/event2/200-Forest.c differ diff --git a/output/event2/201-ForestD1.c b/output/event2/201-ForestD1.c index 3cfc1e64..64030d37 100644 Binary files a/output/event2/201-ForestD1.c and b/output/event2/201-ForestD1.c differ diff --git a/output/event2/202-ForestD2.c b/output/event2/202-ForestD2.c index 1cd28606..5e5c0151 100644 Binary files a/output/event2/202-ForestD2.c and b/output/event2/202-ForestD2.c differ diff --git a/output/event2/203-ForestF2.c b/output/event2/203-ForestF2.c index 2d03cfd3..129e940a 100644 Binary files a/output/event2/203-ForestF2.c and b/output/event2/203-ForestF2.c differ diff --git a/output/event2/204-ForestF3.c b/output/event2/204-ForestF3.c index ecd3ec60..dade20d4 100644 Binary files a/output/event2/204-ForestF3.c and b/output/event2/204-ForestF3.c differ diff --git a/output/event2/250-ForestSiren.c b/output/event2/250-ForestSiren.c index 8e301aec..f06902f1 100644 Binary files a/output/event2/250-ForestSiren.c and b/output/event2/250-ForestSiren.c differ diff --git a/output/event2/251-Salvage.c b/output/event2/251-Salvage.c index 979d07be..7a40945b 100644 Binary files a/output/event2/251-Salvage.c and b/output/event2/251-Salvage.c differ diff --git a/output/event2/299-Demo.c b/output/event2/299-Demo.c index 38102615..3b39a893 100644 Binary files a/output/event2/299-Demo.c and b/output/event2/299-Demo.c differ diff --git a/output/event2/300-Mountain.c b/output/event2/300-Mountain.c index c44180b3..7525bd2d 100644 Binary files a/output/event2/300-Mountain.c and b/output/event2/300-Mountain.c differ diff --git a/output/event2/301-MountainD1.c b/output/event2/301-MountainD1.c index 98dbb0bf..b173f307 100644 Binary files a/output/event2/301-MountainD1.c and b/output/event2/301-MountainD1.c differ diff --git a/output/event2/302-Anahori.c b/output/event2/302-Anahori.c index 36c0a3b3..251cfc53 100644 Binary files a/output/event2/302-Anahori.c and b/output/event2/302-Anahori.c differ diff --git a/output/event2/303-MountainF2.c b/output/event2/303-MountainF2.c index d262817a..eadd2275 100644 Binary files a/output/event2/303-MountainF2.c and b/output/event2/303-MountainF2.c differ diff --git a/output/event2/304-MountainD2.c b/output/event2/304-MountainD2.c index ac240582..b856267b 100644 Binary files a/output/event2/304-MountainD2.c and b/output/event2/304-MountainD2.c differ diff --git a/output/event2/305-MountainF3.c b/output/event2/305-MountainF3.c index aa0fa8eb..7c809531 100644 Binary files a/output/event2/305-MountainF3.c and b/output/event2/305-MountainF3.c differ diff --git a/output/event2/350-MountainSiren.c b/output/event2/350-MountainSiren.c index 9867d2a7..45b1a1da 100644 Binary files a/output/event2/350-MountainSiren.c and b/output/event2/350-MountainSiren.c differ diff --git a/output/event2/351-Salvage.c b/output/event2/351-Salvage.c index 09e7e111..a5a2b892 100644 Binary files a/output/event2/351-Salvage.c and b/output/event2/351-Salvage.c differ diff --git a/output/event2/399-Demo.c b/output/event2/399-Demo.c index ad65c5c9..83ae6ee6 100644 Binary files a/output/event2/399-Demo.c and b/output/event2/399-Demo.c differ diff --git a/output/event2/400-Desert.c b/output/event2/400-Desert.c index c8eeab08..c264810c 100644 Binary files a/output/event2/400-Desert.c and b/output/event2/400-Desert.c differ diff --git a/output/event2/401-DesertD2.c b/output/event2/401-DesertD2.c index dafd6f62..6c265fa9 100644 Binary files a/output/event2/401-DesertD2.c and b/output/event2/401-DesertD2.c differ diff --git a/output/event2/402-DesertF2.c b/output/event2/402-DesertF2.c index 1a96377f..49d77274 100644 Binary files a/output/event2/402-DesertF2.c and b/output/event2/402-DesertF2.c differ diff --git a/output/event2/403-DesertD1.c b/output/event2/403-DesertD1.c index 27f8e8d4..1df67b93 100644 Binary files a/output/event2/403-DesertD1.c and b/output/event2/403-DesertD1.c differ diff --git a/output/event2/404-DesertF3.c b/output/event2/404-DesertF3.c index 189fbee0..972b4a1e 100644 Binary files a/output/event2/404-DesertF3.c and b/output/event2/404-DesertF3.c differ diff --git a/output/event2/405-DesertD2Clear.c b/output/event2/405-DesertD2Clear.c index 301c2878..0a58a471 100644 Binary files a/output/event2/405-DesertD2Clear.c and b/output/event2/405-DesertD2Clear.c differ diff --git a/output/event2/406-TrolleyRace.c b/output/event2/406-TrolleyRace.c index 92fa06f5..30d2a87f 100644 Binary files a/output/event2/406-TrolleyRace.c and b/output/event2/406-TrolleyRace.c differ diff --git a/output/event2/450-DesertSiren.c b/output/event2/450-DesertSiren.c index 9230ffe0..2aebc00f 100644 Binary files a/output/event2/450-DesertSiren.c and b/output/event2/450-DesertSiren.c differ diff --git a/output/event2/451-Salvage.c b/output/event2/451-Salvage.c index af1a5f7f..1a974b34 100644 Binary files a/output/event2/451-Salvage.c and b/output/event2/451-Salvage.c differ diff --git a/output/event2/460-RairyuMinigame.c b/output/event2/460-RairyuMinigame.c index 450fffa9..02b41cc4 100644 Binary files a/output/event2/460-RairyuMinigame.c and b/output/event2/460-RairyuMinigame.c differ diff --git a/output/event2/499-Demo.c b/output/event2/499-Demo.c index 10306283..f308ae0e 100644 Binary files a/output/event2/499-Demo.c and b/output/event2/499-Demo.c differ diff --git a/output/event2/500-CenterField.c b/output/event2/500-CenterField.c index 4148e149..712d818b 100644 Binary files a/output/event2/500-CenterField.c and b/output/event2/500-CenterField.c differ diff --git a/output/event2/501-Inpa.c b/output/event2/501-Inpa.c index 7d305a6c..5c47560f 100644 Binary files a/output/event2/501-Inpa.c and b/output/event2/501-Inpa.c differ diff --git a/output/event2/502-CenterFieldBack.c b/output/event2/502-CenterFieldBack.c index 177ad8e8..ff0c3716 100644 Binary files a/output/event2/502-CenterFieldBack.c and b/output/event2/502-CenterFieldBack.c differ diff --git a/output/event2/503-Goron.c b/output/event2/503-Goron.c index aea946c7..6bfdf977 100644 Binary files a/output/event2/503-Goron.c and b/output/event2/503-Goron.c differ diff --git a/output/event2/510-Salvage.c b/output/event2/510-Salvage.c index 19a53e1d..4354d886 100644 Binary files a/output/event2/510-Salvage.c and b/output/event2/510-Salvage.c differ diff --git a/output/event2/599-Demo.c b/output/event2/599-Demo.c index 50a98c0c..24f46575 100644 Binary files a/output/event2/599-Demo.c and b/output/event2/599-Demo.c differ diff --git a/util.py b/util.py index 062767f7..d19a7625 100644 --- a/util.py +++ b/util.py @@ -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",