Skip to content

Commit

Permalink
mwl2bin git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
danielah05 committed Feb 21, 2022
0 parents commit d376bd1
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
52 changes: 52 additions & 0 deletions mwl2bin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os, sys

# create directories and stuff
if not os.path.isdir("lvl"):
os.mkdir("lvl")

if not os.path.isdir("lvl/obj"):
os.mkdir("lvl/obj")

if not os.path.isdir("lvl/spr"):
os.mkdir("lvl/spr")

# read mwl data
with open(sys.argv[1], "rb") as mwl:
data = mwl.read()

removepath = os.path.basename(sys.argv[1])
filename = os.path.splitext(removepath)[0]

# ----------------
# level data - obj
# ----------------

data_headerless = data[200:]
obj_datasplit = data_headerless.split(b"\xff", 1)
obj_data = obj_datasplit[0]

print("converted obj: "+filename)

# export finished bin
with open("lvl/obj/"+filename+".bin", "wb") as binobj:
binobj.write(obj_data)
binobj.write(b"\xff")

# ----------------
# level data - spr
# ----------------

data_objremove = data.split(b"\xff", 1)
data_objless = data_objremove[1]

data_sprstart = data_objless[2064:]

spr_datasplit = data_sprstart.split(b"\xff", 1)
spr_data = spr_datasplit[0]

print("converted spr: "+filename)

# export finished bin
with open("lvl/spr/"+filename+".bin", "wb") as binspr:
binspr.write(spr_data)
binspr.write(b"\xff")
23 changes: 23 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# mwl2bin
## a converter for turning lunar magic mwl files into bin files
**warning: this may or may not work on linux, i have not tried yet.**
### what is the point of this?
while lunar magic is good for level editing, the tool comes with some flaws.

lunar magic cannot edit every level in the game (examples: all of the sub sections in chocolate island 2).

the tool also auto patches your rom with custom assembly code, making technically every rom hack made with the level editor not vanilla.

with this, you can make any level you want and convert it to be used with SMWDisX: https://github.com/IsoFrieze/SMWDisX
### how to use
save your level inside lunar magic as a file by going to "file -> save level to file"

make sure to name the file the same as the bin file you are going to replace in the disassembly. (for example: 105 would be "105_YI1main.mwl")

after that, just drag the mwl file onto the python script and a new folder should appear called "lvl", this folder should have the two bin files.

just copy the "lvl" folder into the main directoy of the dissasembly and compile the rom.
### my game is crashing after importing the level, what does that mean?
this most likely means you have placed down a "direct map16 access" tile, make sure to get rid of that.

these tiles are not in the vanilla game, lunar magic automatically patches your rom with special code when saving for the first time to make those tiles work and because of that, they will not work inside the disassembly.

0 comments on commit d376bd1

Please sign in to comment.