Skip to content

Commit

Permalink
screen exits seem to be functional, merge experimental with main
Browse files Browse the repository at this point in the history
  • Loading branch information
danielah05 committed Feb 25, 2022
1 parent 1423bb8 commit 785bf59
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions mwl2bin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os, sys

import os, sys

# create directories and stuff
if not os.path.isdir("lvl"):
os.mkdir("lvl")
Expand Down Expand Up @@ -27,9 +29,34 @@

print("converted obj: "+filename)

# -------------------------------
# level data - obj (screen exits)
# -------------------------------

warpamount = input("enter the amount of screen exits in the level: ")

print("fixing "+warpamount+" screen exit(s)...")

warpdata = obj_data[-4*int(warpamount):]
nowarpdata = obj_data[:-4*int(warpamount)]

# do multiple replace checks to make sure warps are correct
warpdatacheck1 = warpdata.replace(b"\x05\x00", b"\x00\x00") # default pipe, no sub exit
warpdatacheck2 = warpdatacheck1.replace(b"\x07\x00", b"\x02\x00") # default pipe, sub exit
warpdatacheck3 = warpdatacheck2.replace(b"\x0f\x00", b"\x02\x00") # default pipe, sub exit water flag (custom lunar magic value, so it gets converted to 02)
warpdatacheck4 = warpdatacheck3.replace(b"\x0d\x00", b"\x00\x00") # default pipe, midway exit (custom lunar magic value, so it gets converted to 00)

warpdatafinal = warpdatacheck4

reconstructedwarps = nowarpdata+warpdatafinal

print(str(warpdata)+" -> "+str(warpdatafinal))

print("(hopefully) fixed screen exits: "+filename)

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

# ----------------
Expand All @@ -49,4 +76,6 @@
# export finished bin
with open("lvl/spr/"+filename+".bin", "wb") as binspr:
binspr.write(spr_data)
binspr.write(b"\xff")
binspr.write(b"\xff")

input("press enter to exit!")

0 comments on commit 785bf59

Please sign in to comment.