mirror of
https://github.com/notwa/mm
synced 2025-02-05 13:23:23 -08:00
NEVER AGAIN.
This commit is contained in:
parent
89ead305aa
commit
cae40acc0f
4 changed files with 220 additions and 191 deletions
4
.gitattributes
vendored
Normal file
4
.gitattributes
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
*.lua text eol=lf
|
||||||
|
*.py text eol=lf
|
||||||
|
*.pyx text eol=lf
|
||||||
|
*.pyxbld text eol=lf
|
|
@ -1,20 +1,39 @@
|
||||||
def try_scene(f):
|
def try_makerom(f):
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
while True:
|
if f.read(12) == b'\x80\x37\x12\x40\x00\x00\x00\x0f\x80\x00\x04\x00':
|
||||||
command = f.read(8)
|
return True
|
||||||
if len(command) == 0:
|
return False
|
||||||
|
|
||||||
|
def try_dmadata(f):
|
||||||
|
f.seek(0)
|
||||||
|
if f.read(20) == b"\x00\x00\x00\x00\x00\x00\x10\x60\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x60":
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def try_actor(f):
|
||||||
|
if True:
|
||||||
|
# this is dumb.
|
||||||
|
# actors are just object files really,
|
||||||
|
# so anything we can detect with would just detect code
|
||||||
|
# or inconsistent data.
|
||||||
|
# maybe there's some common-looking function between them.
|
||||||
|
return False
|
||||||
|
f.seek(-4*4, 2)
|
||||||
|
end = f.tell()
|
||||||
|
for i in range(end, end - 0x200, -4):
|
||||||
|
if i <= 0:
|
||||||
return False
|
return False
|
||||||
if command[2:4] != b'\x00\x00':
|
f.seek(i)
|
||||||
|
#row = f.read(0x10)
|
||||||
|
row = f.read(0xC)
|
||||||
|
if len(row) == 0:
|
||||||
return False
|
return False
|
||||||
if command[0] > 0x1e:
|
#if row == b'\x82\x00\x00\x10\x82\x00\x00\x14\x82\x00\x00\x18\x82\x00\x00\x1c':
|
||||||
return False
|
# return True
|
||||||
if command[4] != 0x02 and command[4] != 0x00:
|
if row == b'\x82\x00\x00\x10\x82\x00\x00\x14\x82\x00\x00\x18':
|
||||||
if command[0] not in (0x05, 0x10, 0x11, 0x12):
|
|
||||||
return False
|
|
||||||
if command == b'\x14\x00\x00\x00\x00\x00\x00\x00':
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def try_room(f):
|
def try_scene_or_room(f, bank=2):
|
||||||
# note: doesn't detect syotes_room_0 because it's missing a header
|
# note: doesn't detect syotes_room_0 because it's missing a header
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
while True:
|
while True:
|
||||||
|
@ -25,16 +44,22 @@ def try_room(f):
|
||||||
return False
|
return False
|
||||||
if command[0] > 0x1e:
|
if command[0] > 0x1e:
|
||||||
return False
|
return False
|
||||||
if command[4] != 0x03 and command[4] != 0x00:
|
if command[4] != bank and command[4] != 0x00:
|
||||||
if command[0] not in (0x05, 0x10, 0x11, 0x12):
|
if command[0] not in (0x05, 0x10, 0x11, 0x12):
|
||||||
return False
|
return False
|
||||||
if command == b'\x14\x00\x00\x00\x00\x00\x00\x00':
|
if command == b'\x14\x00\x00\x00\x00\x00\x00\x00':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def detect_format(f, fn=None):
|
def detect_format(f, fn=None):
|
||||||
if try_scene(f):
|
if try_makerom(f):
|
||||||
|
return None
|
||||||
|
if try_dmadata(f):
|
||||||
|
return None
|
||||||
|
if try_actor(f):
|
||||||
|
return 'actor'
|
||||||
|
if try_scene_or_room(f, 2):
|
||||||
return 'scene'
|
return 'scene'
|
||||||
if try_room(f):
|
if try_scene_or_room(f, 3):
|
||||||
return 'room'
|
return 'room'
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Add table
Reference in a new issue